Replace functions which called once with their bodies
[pidgin-git.git] / pidgin / gtkicon-theme.c
blob5f0d40020a4848b04bd573d383108d61cadfcf9b
1 /*
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
6 * source distribution.
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"
25 #include <gtk/gtk.h>
27 /******************************************************************************
28 * Structs
29 *****************************************************************************/
31 typedef struct {
32 /* used to store filenames of diffrent icons */
33 GHashTable *icon_files;
34 } PidginIconThemePrivate;
36 /******************************************************************************
37 * Globals
38 *****************************************************************************/
40 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(PidginIconTheme, pidgin_icon_theme,
41 PURPLE_TYPE_THEME);
43 /******************************************************************************
44 * GObject Stuff
45 *****************************************************************************/
47 static void
48 pidgin_icon_theme_init(PidginIconTheme *theme)
50 PidginIconThemePrivate *priv;
52 priv = pidgin_icon_theme_get_instance_private(theme);
54 priv->icon_files = g_hash_table_new_full(g_str_hash,
55 g_str_equal, g_free, g_free);
58 static void
59 pidgin_icon_theme_finalize(GObject *obj)
61 PidginIconThemePrivate *priv;
63 priv = pidgin_icon_theme_get_instance_private(PIDGIN_ICON_THEME(obj));
65 g_hash_table_destroy(priv->icon_files);
67 G_OBJECT_CLASS(pidgin_icon_theme_parent_class)->finalize(obj);
70 static void
71 pidgin_icon_theme_class_init(PidginIconThemeClass *klass)
73 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
75 obj_class->finalize = pidgin_icon_theme_finalize;
78 /*****************************************************************************
79 * Public API functions
80 *****************************************************************************/
82 const gchar *
83 pidgin_icon_theme_get_icon(PidginIconTheme *theme,
84 const gchar *id)
86 PidginIconThemePrivate *priv;
88 g_return_val_if_fail(PIDGIN_IS_ICON_THEME(theme), NULL);
90 priv = pidgin_icon_theme_get_instance_private(theme);
92 return g_hash_table_lookup(priv->icon_files, id);
95 void
96 pidgin_icon_theme_set_icon(PidginIconTheme *theme,
97 const gchar *id,
98 const gchar *filename)
100 PidginIconThemePrivate *priv;
101 g_return_if_fail(PIDGIN_IS_ICON_THEME(theme));
103 priv = pidgin_icon_theme_get_instance_private(theme);
105 if (filename != NULL)
106 g_hash_table_replace(priv->icon_files,
107 g_strdup(id), g_strdup(filename));
108 else
109 g_hash_table_remove(priv->icon_files, id);