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 ((PidginIconThemePrivate *) ((PIDGIN_ICON_THEME(Gobject))->priv))
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 (PIDGIN_ICON_THEME(instance
))->priv
= g_new0(PidginIconThemePrivate
, 1);
58 priv
= PIDGIN_ICON_THEME_GET_PRIVATE(instance
);
60 priv
->icon_files
= g_hash_table_new_full(g_str_hash
,
61 g_str_equal
, g_free
, g_free
);
65 pidgin_icon_theme_finalize(GObject
*obj
)
67 PidginIconThemePrivate
*priv
;
69 priv
= PIDGIN_ICON_THEME_GET_PRIVATE(obj
);
71 g_hash_table_destroy(priv
->icon_files
);
74 parent_class
->finalize(obj
);
78 pidgin_icon_theme_class_init(PidginIconThemeClass
*klass
)
80 GObjectClass
*obj_class
= G_OBJECT_CLASS(klass
);
82 parent_class
= g_type_class_peek_parent(klass
);
84 obj_class
->finalize
= pidgin_icon_theme_finalize
;
88 pidgin_icon_theme_get_type(void)
90 static GType type
= 0;
92 static const GTypeInfo info
= {
93 sizeof(PidginIconThemeClass
),
95 NULL
, /* base_finalize */
96 (GClassInitFunc
)pidgin_icon_theme_class_init
, /* class_init */
97 NULL
, /* class_finalize */
98 NULL
, /* class_data */
99 sizeof(PidginIconTheme
),
101 pidgin_icon_theme_init
, /* instance_init */
102 NULL
, /* value table */
104 type
= g_type_register_static(PURPLE_TYPE_THEME
,
105 "PidginIconTheme", &info
, G_TYPE_FLAG_ABSTRACT
);
110 /*****************************************************************************
111 * Public API functions
112 *****************************************************************************/
115 pidgin_icon_theme_get_icon(PidginIconTheme
*theme
,
118 PidginIconThemePrivate
*priv
;
120 g_return_val_if_fail(PIDGIN_IS_ICON_THEME(theme
), NULL
);
122 priv
= PIDGIN_ICON_THEME_GET_PRIVATE(theme
);
124 return g_hash_table_lookup(priv
->icon_files
, id
);
128 pidgin_icon_theme_set_icon(PidginIconTheme
*theme
,
130 const gchar
*filename
)
132 PidginIconThemePrivate
*priv
;
133 g_return_if_fail(PIDGIN_IS_ICON_THEME(theme
));
135 priv
= PIDGIN_ICON_THEME_GET_PRIVATE(theme
);
137 if (filename
!= NULL
)
138 g_hash_table_replace(priv
->icon_files
,
139 g_strdup(id
), g_strdup(filename
));
141 g_hash_table_remove(priv
->icon_files
, id
);