Mercurial > pidgin
comparison pidgin/gtkicon-theme.c @ 25122:9525fb966efb
theme loader cleanup, and remove a few warnings
author | Justin Rodriguez <ffdragon@soc.pidgin.im> |
---|---|
date | Tue, 26 Aug 2008 08:28:25 +0000 |
parents | 0bbfb20bad19 |
children | 1a4417138a8f |
comparison
equal
deleted
inserted
replaced
25121:b37ccfd1697b | 25122:9525fb966efb |
---|---|
43 *****************************************************************************/ | 43 *****************************************************************************/ |
44 | 44 |
45 static GObjectClass *parent_class = NULL; | 45 static GObjectClass *parent_class = NULL; |
46 | 46 |
47 /****************************************************************************** | 47 /****************************************************************************** |
48 * Enums | |
49 *****************************************************************************/ | |
50 /****************************************************************************** | |
51 * GObject Stuff | 48 * GObject Stuff |
52 *****************************************************************************/ | 49 *****************************************************************************/ |
53 | 50 |
54 static void | 51 static void |
55 pidgin_icon_theme_init(GTypeInstance *instance, | 52 pidgin_icon_theme_init(GTypeInstance *instance, |
59 | 56 |
60 (PIDGIN_ICON_THEME(instance))->priv = g_new0(PidginIconThemePrivate, 1); | 57 (PIDGIN_ICON_THEME(instance))->priv = g_new0(PidginIconThemePrivate, 1); |
61 | 58 |
62 priv = PIDGIN_ICON_THEME_GET_PRIVATE(instance); | 59 priv = PIDGIN_ICON_THEME_GET_PRIVATE(instance); |
63 | 60 |
64 priv->icon_files = g_hash_table_new_full (g_str_hash, | 61 priv->icon_files = g_hash_table_new_full(g_str_hash, |
65 g_str_equal, | 62 g_str_equal, |
66 g_free, | 63 g_free, |
67 g_free); | 64 g_free); |
68 } | 65 } |
69 | 66 |
70 static void | 67 static void |
71 pidgin_icon_theme_finalize (GObject *obj) | 68 pidgin_icon_theme_finalize(GObject *obj) |
72 { | 69 { |
73 PidginIconThemePrivate *priv; | 70 PidginIconThemePrivate *priv; |
74 | 71 |
75 priv = PIDGIN_ICON_THEME_GET_PRIVATE(obj); | 72 priv = PIDGIN_ICON_THEME_GET_PRIVATE(obj); |
76 | 73 |
77 g_hash_table_destroy(priv->icon_files); | 74 g_hash_table_destroy(priv->icon_files); |
78 | 75 |
79 parent_class->finalize (obj); | 76 parent_class->finalize(obj); |
80 } | 77 } |
81 | 78 |
82 static void | 79 static void |
83 pidgin_icon_theme_class_init (PidginIconThemeClass *klass) | 80 pidgin_icon_theme_class_init(PidginIconThemeClass *klass) |
84 { | 81 { |
85 GObjectClass *obj_class = G_OBJECT_CLASS(klass); | 82 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
86 | 83 |
87 parent_class = g_type_class_peek_parent (klass); | 84 parent_class = g_type_class_peek_parent(klass); |
88 | 85 |
89 obj_class->finalize = pidgin_icon_theme_finalize; | 86 obj_class->finalize = pidgin_icon_theme_finalize; |
90 } | 87 } |
91 | 88 |
92 GType | 89 GType |
93 pidgin_icon_theme_get_type (void) | 90 pidgin_icon_theme_get_type(void) |
94 { | 91 { |
95 static GType type = 0; | 92 static GType type = 0; |
96 if (type == 0) { | 93 if (type == 0) { |
97 static const GTypeInfo info = { | 94 static const GTypeInfo info = { |
98 sizeof (PidginIconThemeClass), | 95 sizeof (PidginIconThemeClass), |
104 sizeof (PidginIconTheme), | 101 sizeof (PidginIconTheme), |
105 0, /* n_preallocs */ | 102 0, /* n_preallocs */ |
106 pidgin_icon_theme_init, /* instance_init */ | 103 pidgin_icon_theme_init, /* instance_init */ |
107 NULL, /* value table */ | 104 NULL, /* value table */ |
108 }; | 105 }; |
109 type = g_type_register_static (PURPLE_TYPE_THEME, | 106 type = g_type_register_static(PURPLE_TYPE_THEME, |
110 "PidginIconTheme", | 107 "PidginIconTheme", |
111 &info, G_TYPE_FLAG_ABSTRACT); | 108 &info, G_TYPE_FLAG_ABSTRACT); |
112 } | 109 } |
113 return type; | 110 return type; |
114 } | 111 } |
117 /***************************************************************************** | 114 /***************************************************************************** |
118 * Public API functions | 115 * Public API functions |
119 *****************************************************************************/ | 116 *****************************************************************************/ |
120 | 117 |
121 const gchar * | 118 const gchar * |
122 pidgin_icon_theme_get_file(PidginIconTheme *theme, | 119 pidgin_icon_theme_get_icon(PidginIconTheme *theme, |
123 const gchar *id) | 120 const gchar *id) |
124 { | 121 { |
125 PidginIconThemePrivate *priv; | 122 PidginIconThemePrivate *priv; |
126 | 123 |
127 g_return_val_if_fail(PIDGIN_IS_ICON_THEME(theme), NULL); | 124 g_return_val_if_fail(PIDGIN_IS_ICON_THEME(theme), NULL); |
130 | 127 |
131 return g_hash_table_lookup(priv->icon_files, id); | 128 return g_hash_table_lookup(priv->icon_files, id); |
132 } | 129 } |
133 | 130 |
134 void | 131 void |
135 pidgin_icon_theme_set_file(PidginIconTheme *theme, | 132 pidgin_icon_theme_set_icon(PidginIconTheme *theme, |
136 const gchar *id, | 133 const gchar *id, |
137 const gchar *filename) | 134 const gchar *filename) |
138 { | 135 { |
139 PidginIconThemePrivate *priv; | 136 PidginIconThemePrivate *priv; |
140 g_return_if_fail(PIDGIN_IS_ICON_THEME(theme)); | 137 g_return_if_fail(PIDGIN_IS_ICON_THEME(theme)); |
141 | 138 |
142 priv = PIDGIN_ICON_THEME_GET_PRIVATE(theme); | 139 priv = PIDGIN_ICON_THEME_GET_PRIVATE(theme); |
143 | 140 |
144 if (filename != NULL)g_hash_table_replace(priv->icon_files, | 141 if (filename != NULL) |
142 g_hash_table_replace(priv->icon_files, | |
145 g_strdup(id), | 143 g_strdup(id), |
146 g_strdup(filename)); | 144 g_strdup(filename)); |
147 else g_hash_table_remove(priv->icon_files, id); | 145 else g_hash_table_remove(priv->icon_files, id); |
148 } | 146 } |