summaryrefslogtreecommitdiff
path: root/ui/gtk/gui_utils.c
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2015-10-17 13:47:17 +0100
committerAnders Broman <a.broman58@gmail.com>2015-11-12 07:14:32 +0000
commit2d7b0fc7d046154a393c9a1e5f4b2e9b5fee3738 (patch)
tree8b14d373b97ea9162a46e8b61f42919f2a6c5514 /ui/gtk/gui_utils.c
parent1ab019f409f2855d3b51717a237cc482242887e9 (diff)
downloadwireshark-2d7b0fc7d046154a393c9a1e5f4b2e9b5fee3738.tar.gz
[GTK] Replace deprecated gdk_pixbuf_new_from_inline()
Use GResource instead, if available. Add autotools and cmake compile time checks for build requirements (GIO >= 2.32 and GDK-Pixbuf >= 2.26). Merge all the various static pixbuf csource header files into a single pixbuf-csource.h header with external linkage through use of the tools/make-pixbuf-csource.pl script. Fix inline pixbuf build target for some image paths (broken for GTK in gb4a4de7). Add missing 'expert_ok.png' file to distribution (GTK only). Minor improvements to style/structure of ui/gtk/Makefile.am. Bug: 10750 Change-Id: I031296b666ee8b92730400dfa6f71f9ee4304863 Reviewed-on: https://code.wireshark.org/review/10992 Petri-Dish: Anders Broman <a.broman58@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/gtk/gui_utils.c')
-rw-r--r--ui/gtk/gui_utils.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/ui/gtk/gui_utils.c b/ui/gtk/gui_utils.c
index 5ab2653160..d00d6095b6 100644
--- a/ui/gtk/gui_utils.c
+++ b/ui/gtk/gui_utils.c
@@ -50,10 +50,10 @@
#include "ui/gtk/gui_utils.h"
#include "ui/gtk/font_utils.h"
#include "ui/gtk/color_utils.h"
-
#include "ui/gtk/old-gtk-compat.h"
-
-#include "ui/gtk/wsicon.h"
+#ifndef HAVE_GRESOURCE
+#include "ui/gtk/pixbuf-csource.h"
+#endif
#ifdef _WIN32
#include <windows.h>
@@ -110,16 +110,23 @@ window_icon_realize_cb(GtkWidget *win,
{
#ifndef _WIN32
GList *ws_icon_list = NULL;
- GdkPixbuf *icon;
+ GdkPixbuf *icon16, *icon32, *icon48, *icon64;
- icon = gdk_pixbuf_new_from_inline(-1, wsicon_16_pb_data, FALSE, NULL);
- ws_icon_list = g_list_append(ws_icon_list, icon);
- icon = gdk_pixbuf_new_from_inline(-1, wsicon_32_pb_data, FALSE, NULL);
- ws_icon_list = g_list_append(ws_icon_list, icon);
- icon = gdk_pixbuf_new_from_inline(-1, wsicon_48_pb_data, FALSE, NULL);
- ws_icon_list = g_list_append(ws_icon_list, icon);
- icon = gdk_pixbuf_new_from_inline(-1, wsicon_64_pb_data, FALSE, NULL);
- ws_icon_list = g_list_append(ws_icon_list, icon);
+#ifdef HAVE_GRESOURCE
+ icon16 = ws_gdk_pixbuf_new_from_resource("/org/wireshark/image/wsicon16.png");
+ icon32 = ws_gdk_pixbuf_new_from_resource("/org/wireshark/image/wsicon32.png");
+ icon48 = ws_gdk_pixbuf_new_from_resource("/org/wireshark/image/wsicon48.png");
+ icon64 = ws_gdk_pixbuf_new_from_resource("/org/wireshark/image/wsicon64.png");
+#else
+ icon16 = gdk_pixbuf_new_from_inline(-1, wsicon_16_pb_data, FALSE, NULL);
+ icon32 = gdk_pixbuf_new_from_inline(-1, wsicon_32_pb_data, FALSE, NULL);
+ icon48 = gdk_pixbuf_new_from_inline(-1, wsicon_48_pb_data, FALSE, NULL);
+ icon64 = gdk_pixbuf_new_from_inline(-1, wsicon_64_pb_data, FALSE, NULL);
+#endif
+ ws_icon_list = g_list_append(ws_icon_list, icon16);
+ ws_icon_list = g_list_append(ws_icon_list, icon32);
+ ws_icon_list = g_list_append(ws_icon_list, icon48);
+ ws_icon_list = g_list_append(ws_icon_list, icon64);
gtk_window_set_icon_list(GTK_WINDOW(win), ws_icon_list);
@@ -515,13 +522,20 @@ xpm_to_widget(const char **xpm) {
return _gtk_image_new_from_pixbuf_unref(pixbuf);
}
-/* Convert an pixbuf data to a GtkWidget */
-/* Data should be created with "gdk-pixbuf-csource --raw" */
+/* Convert an pixbuf GResource to a GtkWidget */
GtkWidget *
+#ifdef HAVE_GRESOURCE
+pixbuf_to_widget(const char *pb_path) {
+#else
pixbuf_to_widget(const guint8 *pb_data) {
+#endif
GdkPixbuf *pixbuf;
+#ifdef HAVE_GRESOURCE
+ pixbuf = ws_gdk_pixbuf_new_from_resource(pb_path);
+#else
pixbuf = gdk_pixbuf_new_from_inline(-1, pb_data, FALSE, NULL);
+#endif
return _gtk_image_new_from_pixbuf_unref(pixbuf);
}
@@ -2035,6 +2049,19 @@ gdk_cairo_set_source_rgba(cairo_t *cr, const GdkRGBA *rgba)
}
#endif /* GTK_CHECK_VERSION(3,0,0) */
+#ifdef HAVE_GRESOURCE
+GdkPixbuf *
+ws_gdk_pixbuf_new_from_resource(const char *path)
+{
+ GdkPixbuf *pixbuf;
+ GError *err = NULL;
+
+ pixbuf = gdk_pixbuf_new_from_resource(path, &err);
+ g_assert_no_error(err);
+ return pixbuf;
+}
+#endif /* HAVE_GRESOURCE */
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*