pidgin/gtkicon-theme.c

Fri, 05 Mar 2021 03:31:29 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 05 Mar 2021 03:31:29 -0600
changeset 40810
28d50eece92d
parent 39501
93cac808f4f7
child 41086
631e6cba8635
permissions
-rw-r--r--

Create a PidginAvatar widget.

This does everything the existing code does, but trying to integrate right now
is kind of difficult. The plan is to use this in a new PidginInfoPane I have
started, but that change got very large so I just packed it into the end of
the existing info pane.

The only things that are not implement right now, are making menu items
insensitive and that's because we need to figure out a better want to handle
custom avatars for users.

Testing Done:
Ran locally.

Reviewed at https://reviews.imfreedom.org/r/528/

23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
1 /*
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
2 * Icon Themes for Pidgin
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
3 *
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
4 * Pidgin is the legal property of its developers, whose names are too numerous
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
6 * source distribution.
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
7 *
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
12 *
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
17 *
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
21 */
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
22
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
23 #include "gtkicon-theme.h"
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
24
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
25 #include <gtk/gtk.h>
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
26
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
27 /******************************************************************************
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
28 * Structs
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
29 *****************************************************************************/
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
30
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
31 typedef struct {
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
32 /* used to store filenames of diffrent icons */
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
33 GHashTable *icon_files;
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
34 } PidginIconThemePrivate;
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
35
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
36 /******************************************************************************
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
37 * Globals
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
38 *****************************************************************************/
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
39
39238
53cfb9400de8 Port Pidgin away from deprecated g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 32438
diff changeset
40 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(PidginIconTheme, pidgin_icon_theme,
53cfb9400de8 Port Pidgin away from deprecated g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 32438
diff changeset
41 PURPLE_TYPE_THEME);
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
42
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
43 /******************************************************************************
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
44 * GObject Stuff
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
45 *****************************************************************************/
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
46
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
47 static void
39238
53cfb9400de8 Port Pidgin away from deprecated g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 32438
diff changeset
48 pidgin_icon_theme_init(PidginIconTheme *theme)
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
49 {
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
50 PidginIconThemePrivate *priv;
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
51
39238
53cfb9400de8 Port Pidgin away from deprecated g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 32438
diff changeset
52 priv = pidgin_icon_theme_get_instance_private(theme);
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
53
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23967
diff changeset
54 priv->icon_files = g_hash_table_new_full(g_str_hash,
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
55 g_str_equal, g_free, g_free);
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
56 }
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
57
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
58 static void
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23967
diff changeset
59 pidgin_icon_theme_finalize(GObject *obj)
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
60 {
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
61 PidginIconThemePrivate *priv;
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
62
39238
53cfb9400de8 Port Pidgin away from deprecated g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 32438
diff changeset
63 priv = pidgin_icon_theme_get_instance_private(PIDGIN_ICON_THEME(obj));
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
64
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
65 g_hash_table_destroy(priv->icon_files);
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
66
39238
53cfb9400de8 Port Pidgin away from deprecated g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 32438
diff changeset
67 G_OBJECT_CLASS(pidgin_icon_theme_parent_class)->finalize(obj);
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
68 }
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
69
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
70 static void
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23967
diff changeset
71 pidgin_icon_theme_class_init(PidginIconThemeClass *klass)
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
72 {
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
73 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
74
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
75 obj_class->finalize = pidgin_icon_theme_finalize;
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
76 }
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
77
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
78 /*****************************************************************************
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
79 * Public API functions
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
80 *****************************************************************************/
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
81
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
82 const gchar *
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23967
diff changeset
83 pidgin_icon_theme_get_icon(PidginIconTheme *theme,
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
84 const gchar *id)
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
85 {
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
86 PidginIconThemePrivate *priv;
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
87
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
88 g_return_val_if_fail(PIDGIN_IS_ICON_THEME(theme), NULL);
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
89
39238
53cfb9400de8 Port Pidgin away from deprecated g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 32438
diff changeset
90 priv = pidgin_icon_theme_get_instance_private(theme);
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
91
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
92 return g_hash_table_lookup(priv->icon_files, id);
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
93 }
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
94
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
95 void
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23967
diff changeset
96 pidgin_icon_theme_set_icon(PidginIconTheme *theme,
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
97 const gchar *id,
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
98 const gchar *filename)
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
99 {
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
100 PidginIconThemePrivate *priv;
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
101 g_return_if_fail(PIDGIN_IS_ICON_THEME(theme));
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
102
39238
53cfb9400de8 Port Pidgin away from deprecated g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 32438
diff changeset
103 priv = pidgin_icon_theme_get_instance_private(theme);
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
104
23972
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23967
diff changeset
105 if (filename != NULL)
90e0da03c053 theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents: 23967
diff changeset
106 g_hash_table_replace(priv->icon_files,
25875
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
107 g_strdup(id), g_strdup(filename));
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
108 else
a98b16817658 Lots of minor whitespace and comment changes:
Mark Doliner <markdoliner@pidgin.im>
parents: 23973
diff changeset
109 g_hash_table_remove(priv->icon_files, id);
23965
13cd30de531b Add the icon theme files, and re-work some things
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
diff changeset
110 }

mercurial