summaryrefslogtreecommitdiff
path: root/ui/gtk/stock_icons.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/stock_icons.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/stock_icons.c')
-rw-r--r--ui/gtk/stock_icons.c59
1 files changed, 56 insertions, 3 deletions
diff --git a/ui/gtk/stock_icons.c b/ui/gtk/stock_icons.c
index 397f0f0ce4..ea4d49b44e 100644
--- a/ui/gtk/stock_icons.c
+++ b/ui/gtk/stock_icons.c
@@ -28,8 +28,10 @@
#include <string.h>
#include "ui/gtk/stock_icons.h"
-#include "ui/gtk/toolbar_icons.h"
-#include "ui/gtk/wsicon.h"
+#ifndef HAVE_GRESOURCE
+#include "ui/gtk/pixbuf-csource.h"
+#endif
+#include "ui/gtk/gui_utils.h"
#include <wsutil/utf8_entities.h>
@@ -90,8 +92,15 @@ typedef struct stock_pixmap_tag{
typedef struct stock_pixbuf_tag{
const char * name;
+#ifdef HAVE_GRESOURCE
+ struct {
+ const char *p16; /* Optional */
+ const char *p24; /* Mandatory */
+ } path;
+#else
const guint8 * pb_data16; /* Optional */
const guint8 * pb_data24; /* Mandatory */
+#endif
} stock_pixbuf_t;
/*
@@ -314,6 +323,41 @@ void stock_icons_init(void) {
#endif
static const stock_pixbuf_t pixbufs[] = {
+#ifdef HAVE_GRESOURCE
+ { WIRESHARK_STOCK_ABOUT,
+ { "/org/wireshark/image/wsicon16.png",
+ "/org/wireshark/image/wsicon24.png" }
+ },
+ { WIRESHARK_STOCK_CAPTURE_INTERFACES,
+ { "/org/wireshark/image/toolbar/capture_interfaces_16.png",
+ "/org/wireshark/image/toolbar/capture_interfaces_24.png" }
+ },
+ { WIRESHARK_STOCK_CAPTURE_OPTIONS,
+ { "/org/wireshark/image/toolbar/16x16/x-capture-options.png",
+ "/org/wireshark/image/toolbar/24x24/x-capture-options.png" }
+ },
+ { WIRESHARK_STOCK_CAPTURE_RESTART,
+ { "/org/wireshark/image/toolbar/16x16/x-capture-restart.png",
+ "/org/wireshark/image/toolbar/24x24/x-capture-restart.png" }
+ },
+ { WIRESHARK_STOCK_CAPTURE_START,
+ { "/org/wireshark/image/toolbar/16x16/x-capture-start.png",
+ "/org/wireshark/image/toolbar/24x24/x-capture-start.png" }
+ },
+ { WIRESHARK_STOCK_CAPTURE_STOP,
+ { "/org/wireshark/image/toolbar/16x16/x-capture-stop.png",
+ "/org/wireshark/image/toolbar/24x24/x-capture-stop.png" }
+ },
+ { WIRESHARK_STOCK_SAVE,
+ { "/org/wireshark/image/toolbar/16x16/x-capture-file-save.png",
+ "/org/wireshark/image/toolbar/24x24/x-capture-file-save.png" }
+ },
+ { WIRESHARK_STOCK_WIKI,
+ { "/org/wireshark/image/toolbar/gnome_emblem_web_16.png",
+ "/org/wireshark/image/toolbar/gnome_emblem_web_24.png" }
+ },
+ { NULL, { NULL, NULL } }
+#else
{ WIRESHARK_STOCK_ABOUT, wsicon_16_pb_data, wsicon_24_pb_data },
{ WIRESHARK_STOCK_CAPTURE_INTERFACES, capture_interfaces_16_pb_data, capture_interfaces_24_pb_data },
{ WIRESHARK_STOCK_CAPTURE_OPTIONS, capture_options_alt1_16_pb_data, capture_options_alt1_24_pb_data },
@@ -323,6 +367,7 @@ void stock_icons_init(void) {
{ WIRESHARK_STOCK_SAVE, toolbar_wireshark_file_16_pb_data, toolbar_wireshark_file_24_pb_data},
{ WIRESHARK_STOCK_WIKI, gnome_emblem_web_16_pb_data, gnome_emblem_web_24_pb_data },
{ NULL, NULL, NULL }
+#endif
};
/* New images should be PNGs + pixbufs above. Please don't add to this list. */
@@ -409,8 +454,12 @@ void stock_icons_init(void) {
/* Add pixbufs as builtin theme icons */
for (i = 0; pixbufs[i].name != NULL; i++) {
+#ifdef HAVE_GRESOURCE
+ GdkPixbuf * pixbuf24 = ws_gdk_pixbuf_new_from_resource(pixbufs[i].path.p24);
+#else
GdkPixbuf * pixbuf24 = gdk_pixbuf_new_from_inline(-1, pixbufs[i].pb_data24, FALSE, NULL);
g_assert(pixbuf24);
+#endif
#if !GTK_CHECK_VERSION(3, WS_GTK3_MINOR_STOCK_DEPRECATION_STARTS, 0)
icon_set = gtk_icon_set_new_from_pixbuf(pixbuf24);
gtk_icon_factory_add (factory, pixbufs[i].name, icon_set);
@@ -419,10 +468,14 @@ void stock_icons_init(void) {
/* Default image */
gtk_icon_theme_add_builtin_icon(pixbufs[i].name, 24, pixbuf24);
-
+#ifdef HAVE_GRESOURCE
+ if (pixbufs[i].path.p16 != NULL) {
+ GdkPixbuf * pixbuf16 = ws_gdk_pixbuf_new_from_resource(pixbufs[i].path.p16);
+#else
if (pixbufs[i].pb_data16) {
GdkPixbuf * pixbuf16 = gdk_pixbuf_new_from_inline(-1, pixbufs[i].pb_data16, FALSE, NULL);
g_assert(pixbuf16);
+#endif
#if !GTK_CHECK_VERSION(3, WS_GTK3_MINOR_STOCK_DEPRECATION_STARTS, 0)
source16 = gtk_icon_source_new();
gtk_icon_source_set_pixbuf(source16, pixbuf16);