OSDN Git Service

LinGui:
[handbrake-jp/handbrake-jp-git.git] / gtk / src / icons.c
1 #include <gtk/gtk.h>
2 #include "icon_tools.h"
3 #include "values.h"
4 #include "resources.h"
5
6 #if 0
7 void
8 ghb_load_icons()
9 {
10         GHashTableIter iter;
11         gchar *name;
12         GValue *gval;
13
14         GValue *icons = ghb_resource_get("icons");
15         ghb_dict_iter_init(&iter, icons);
16         // middle (void*) cast prevents gcc warning "defreferencing type-punned
17         // pointer will break strict-aliasing rules"
18         while (g_hash_table_iter_next(
19                         &iter, (gpointer*)(void*)&name, (gpointer*)(void*)&gval))
20         {
21                 gint colorspace, bps, width, height, rowstride;
22                 gboolean alpha;
23                 ghb_rawdata_t *rd;
24                 gint size;
25                 GdkPixbuf *pb;
26
27                 colorspace = ghb_value_int(ghb_dict_lookup(gval, "colorspace"));
28                 alpha = ghb_value_boolean(ghb_dict_lookup(gval, "alpha"));
29                 bps = ghb_value_int(ghb_dict_lookup(gval, "bps"));
30                 width = ghb_value_int(ghb_dict_lookup(gval, "width"));
31                 height = ghb_value_int(ghb_dict_lookup(gval, "height"));
32                 rowstride = ghb_value_int(ghb_dict_lookup(gval, "rowstride"));
33                 rd = g_value_get_boxed(ghb_dict_lookup(gval, "data"));
34                 pb = gdk_pixbuf_new_from_data(
35                                 rd->data, colorspace, alpha, bps,
36                                 width, height, rowstride,
37                                 NULL, NULL);
38                 size = gdk_pixbuf_get_height(pb);
39                 gtk_icon_theme_add_builtin_icon(name, size, pb);
40                 gdk_pixbuf_unref(pb);
41         }
42 }
43
44 #else
45
46 void
47 ghb_load_icons()
48 {
49         GdkPixbuf *pb;
50         GHashTableIter iter;
51         gchar *name;
52         GValue *gval;
53         ghb_rawdata_t *rd;
54         gint size;
55
56         GValue *icons = ghb_resource_get("icons");
57         ghb_dict_iter_init(&iter, icons);
58         // middle (void*) cast prevents gcc warning "defreferencing type-punned
59         // pointer will break strict-aliasing rules"
60         while (g_hash_table_iter_next(
61                         &iter, (gpointer*)(void*)&name, (gpointer*)(void*)&gval))
62         {
63                 rd = g_value_get_boxed(gval);
64                 pb = icon_deserialize(rd->data, rd->size);
65                 size = gdk_pixbuf_get_height(pb);
66                 gtk_icon_theme_add_builtin_icon(name, size, pb);
67                 gdk_pixbuf_unref(pb);
68         }
69 }
70 #endif