From 67165ce16e80ca5b424717a88f5c04880a5780cf Mon Sep 17 00:00:00 2001 From: jstebbins Date: Thu, 26 Mar 2015 22:13:24 +0000 Subject: LinGui: move icons into a GResource This allows me to eliminate a warning from gtk+-3.14 about deprecated gtk_icon_theme_add_builtin_icon(). git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7021 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- gtk/src/icons.c | 80 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'gtk/src/icons.c') diff --git a/gtk/src/icons.c b/gtk/src/icons.c index 5c22527ad..68a6ed701 100644 --- a/gtk/src/icons.c +++ b/gtk/src/icons.c @@ -1,61 +1,61 @@ #include "ghbcompat.h" -#include "values.h" -#include "resources.h" +#include "icon_res.h" void ghb_load_icons() { - GhbDictIter iter; - const gchar *key; - GhbValue *gval; +#if GTK_CHECK_VERSION(3, 14, 0) + ghb_icons_register_resource(); + gtk_icon_theme_add_resource_path(gtk_icon_theme_get_default(), + "/org/handbrake/icons"); +#else + ghb_icons_register_resource(); + GResource *icon_res = ghb_icons_get_resource(); - GhbValue *icons = ghb_resource_get("icons"); - ghb_dict_iter_init(icons, &iter); - while (ghb_dict_iter_next(icons, &iter, &key, &gval)) + char ** children = g_resource_enumerate_children(icon_res, + "/org/handbrake/icons/scalable/apps", 0, NULL); + + if (children == NULL) { - gint size; - GdkPixbuf *pb; - gboolean svg; - char *name = g_strdup(key); - char *pos; - const char *base64; - guint8 *data; + g_warning("No icons in resources!"); + return; + } + int ii; + for (ii = 0; children[ii] != NULL; ii++) + { + char *path = g_strdup_printf("/org/handbrake/icons/scalable/apps/%s", + children[ii]); + GBytes *gbytes = g_resource_lookup_data(icon_res, path, 0, NULL); gsize data_size; + gconstpointer data = g_bytes_get_data(gbytes, &data_size); + g_free(path); + char *pos; + char *name = g_strdup(children[ii]); pos = g_strstr_len(name, -1, "."); if (pos != NULL) *pos = '\0'; - GInputStream *gis; - svg = ghb_value_boolean(ghb_dict_lookup(gval, "svg")); - base64 = ghb_value_const_string(ghb_dict_lookup(gval, "data")); - data = g_base64_decode(base64, &data_size); - if (svg) - { - int ii; - int sizes[] = {16, 22, 24, 32, 48, 64, 128, 256, 0}; - for (ii = 0; sizes[ii]; ii++) - { - gis = g_memory_input_stream_new_from_data(data, data_size, - NULL); - pb = gdk_pixbuf_new_from_stream_at_scale(gis, - sizes[ii], sizes[ii], - TRUE, NULL, NULL); - g_input_stream_close(gis, NULL, NULL); - size = gdk_pixbuf_get_height(pb); - gtk_icon_theme_add_builtin_icon(name, size, pb); - g_object_unref(pb); - } - } - else + int jj; + int sizes[] = {16, 22, 24, 32, 48, 64, 128, 256, 0}; + for (jj = 0; sizes[jj]; jj++) { - gis = g_memory_input_stream_new_from_data(data, data_size, NULL); - pb = gdk_pixbuf_new_from_stream(gis, NULL, NULL); + GdkPixbuf *pb; + GInputStream *gis; + int size; + + gis = g_memory_input_stream_new_from_data(data, data_size, + NULL); + pb = gdk_pixbuf_new_from_stream_at_scale(gis, + sizes[jj], sizes[jj], + TRUE, NULL, NULL); g_input_stream_close(gis, NULL, NULL); size = gdk_pixbuf_get_height(pb); gtk_icon_theme_add_builtin_icon(name, size, pb); g_object_unref(pb); } - g_free(name); + g_bytes_unref(gbytes); } + g_strfreev(children); +#endif } -- cgit v1.2.3