2 * Icon Themes for Pidgin
4 * Pidgin is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 #include "gtkicon-theme.h"
24 #include "pidginstock.h"
28 #define PIDGIN_ICON_THEME_GET_PRIVATE(Gobject) \
29 (G_TYPE_INSTANCE_GET_PRIVATE((Gobject), PIDGIN_TYPE_ICON_THEME, PidginIconThemePrivate))
31 /******************************************************************************
33 *****************************************************************************/
36 /* used to store filenames of diffrent icons */
37 GHashTable
*icon_files
;
38 } PidginIconThemePrivate
;
40 /******************************************************************************
42 *****************************************************************************/
44 static GObjectClass
*parent_class
= NULL
;
46 /******************************************************************************
48 *****************************************************************************/
51 pidgin_icon_theme_init(GTypeInstance
*instance
,
54 PidginIconThemePrivate
*priv
;
56 priv
= PIDGIN_ICON_THEME_GET_PRIVATE(instance
);
58 priv
->icon_files
= g_hash_table_new_full(g_str_hash
,
59 g_str_equal
, g_free
, g_free
);
63 pidgin_icon_theme_finalize(GObject
*obj
)
65 PidginIconThemePrivate
*priv
;
67 priv
= PIDGIN_ICON_THEME_GET_PRIVATE(obj
);
69 g_hash_table_destroy(priv
->icon_files
);
71 parent_class
->finalize(obj
);
75 pidgin_icon_theme_class_init(PidginIconThemeClass
*klass
)
77 GObjectClass
*obj_class
= G_OBJECT_CLASS(klass
);
79 parent_class
= g_type_class_peek_parent(klass
);
81 obj_class
->finalize
= pidgin_icon_theme_finalize
;
83 g_type_class_add_private(klass
, sizeof(PidginIconThemePrivate
));
87 pidgin_icon_theme_get_type(void)
89 static GType type
= 0;
91 static const GTypeInfo info
= {
92 sizeof(PidginIconThemeClass
),
94 NULL
, /* base_finalize */
95 (GClassInitFunc
)pidgin_icon_theme_class_init
, /* class_init */
96 NULL
, /* class_finalize */
97 NULL
, /* class_data */
98 sizeof(PidginIconTheme
),
100 pidgin_icon_theme_init
, /* instance_init */
101 NULL
, /* value table */
103 type
= g_type_register_static(PURPLE_TYPE_THEME
,
104 "PidginIconTheme", &info
, G_TYPE_FLAG_ABSTRACT
);
109 /*****************************************************************************
110 * Public API functions
111 *****************************************************************************/
114 pidgin_icon_theme_get_icon(PidginIconTheme
*theme
,
117 PidginIconThemePrivate
*priv
;
119 g_return_val_if_fail(PIDGIN_IS_ICON_THEME(theme
), NULL
);
121 priv
= PIDGIN_ICON_THEME_GET_PRIVATE(theme
);
123 return g_hash_table_lookup(priv
->icon_files
, id
);
127 pidgin_icon_theme_set_icon(PidginIconTheme
*theme
,
129 const gchar
*filename
)
131 PidginIconThemePrivate
*priv
;
132 g_return_if_fail(PIDGIN_IS_ICON_THEME(theme
));
134 priv
= PIDGIN_ICON_THEME_GET_PRIVATE(theme
);
136 if (filename
!= NULL
)
137 g_hash_table_replace(priv
->icon_files
,
138 g_strdup(id
), g_strdup(filename
));
140 g_hash_table_remove(priv
->icon_files
, id
);