annotate pidgin/plugins/themeedit-icon.c @ 26666:6bf58e156da2

Allow editing dialog icons.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 20 Apr 2009 06:07:43 +0000
parents df0915055560
children ed8385b26f6e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 /* Pidgin
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 *
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 * Pidgin is the legal property of its developers, whose names are too numerous
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 * source distribution.
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 *
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 * (at your option) any later version.
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 *
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 * GNU General Public License for more details.
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 *
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 #include "internal.h"
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 #include "pidgin.h"
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 #include "debug.h"
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 #include "version.h"
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 #include "theme-manager.h"
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 #include "gtkblist.h"
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 #include "gtkblist-theme.h"
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 #include "gtkutils.h"
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 #include "gtkplugin.h"
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 #include "pidginstock.h"
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 #include "themeedit-icon.h"
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 static const char *stocksizes [] = {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC,
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL,
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 PIDGIN_ICON_SIZE_TANGO_SMALL,
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 PIDGIN_ICON_SIZE_TANGO_MEDIUM,
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 PIDGIN_ICON_SIZE_TANGO_LARGE,
26663
7519de6ea00f We don't have huge status icons, and set only the icons changed from the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26662
diff changeset
42 NULL,
7519de6ea00f We don't have huge status icons, and set only the icons changed from the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26662
diff changeset
43 PIDGIN_ICON_SIZE_TANGO_HUGE, /* We don't have huge status icons, it seems! */
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 };
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
46 static const struct options {
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 const char *stockid;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 const char *text;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 } statuses[] = {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 {PIDGIN_STOCK_STATUS_AVAILABLE, N_("Available")},
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 {PIDGIN_STOCK_STATUS_AWAY, N_("Away")},
26665
df0915055560 Add some more status emblems, and since the dialog is too long, use a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26664
diff changeset
52 {PIDGIN_STOCK_STATUS_XA, N_("Extended Away")},
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 {PIDGIN_STOCK_STATUS_BUSY, N_("Busy")},
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 {PIDGIN_STOCK_STATUS_OFFLINE, N_("Offline")},
26665
df0915055560 Add some more status emblems, and since the dialog is too long, use a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26664
diff changeset
55 {PIDGIN_STOCK_STATUS_LOGIN, N_("Just logged in")},
df0915055560 Add some more status emblems, and since the dialog is too long, use a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26664
diff changeset
56 {PIDGIN_STOCK_STATUS_LOGOUT, N_("Just logged out")},
df0915055560 Add some more status emblems, and since the dialog is too long, use a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26664
diff changeset
57 {PIDGIN_STOCK_STATUS_PERSON, N_("Icon for Contact/\nIcon for Unknown person")},
df0915055560 Add some more status emblems, and since the dialog is too long, use a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26664
diff changeset
58 {PIDGIN_STOCK_STATUS_CHAT, N_("Icon for Chat")},
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 {NULL, NULL}
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
60 }, chatemblems[] = {
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
61 {PIDGIN_STOCK_STATUS_IGNORED, N_("Ignored")},
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
62 {PIDGIN_STOCK_STATUS_FOUNDER, N_("Founder")},
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
63 {PIDGIN_STOCK_STATUS_OPERATOR, N_("Operator")},
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
64 {PIDGIN_STOCK_STATUS_HALFOP, N_("Half Operator")},
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
65 {PIDGIN_STOCK_STATUS_VOICE, N_("Voice")},
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
66 {NULL, NULL}
26666
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
67 }, dialogicons[] = {
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
68 {PIDGIN_STOCK_DIALOG_AUTH, N_("Authorization dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
69 {PIDGIN_STOCK_DIALOG_ERROR, N_("Error dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
70 {PIDGIN_STOCK_DIALOG_INFO, N_("Information dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
71 {PIDGIN_STOCK_DIALOG_MAIL, N_("Mail dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
72 {PIDGIN_STOCK_DIALOG_QUESTION, N_("Question dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
73 {PIDGIN_STOCK_DIALOG_WARNING, N_("Warning dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
74 {NULL, NULL},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
75 {PIDGIN_STOCK_DIALOG_COOL, N_("What kind of dialog is this?")},
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
76 };
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
77
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
78 static const struct {
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
79 const char *heading;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
80 const struct options *options;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
81 } sections[] = {
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
82 {N_("Status Icons"), statuses},
26666
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
83 {N_("Chatroom Emblems"), chatemblems},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
84 {N_("Dialog Icons"), dialogicons},
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
85 {NULL, NULL}
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 };
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 static PidginStatusIconTheme *
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 create_icon_theme(GtkWidget *window)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 {
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
91 int s, i, j;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 char *dirname = "/tmp"; /* FIXME */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 PidginStatusIconTheme *theme = g_object_new(PIDGIN_TYPE_STATUS_ICON_THEME, "type", "status-icon",
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 "author", getlogin(),
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 "directory", dirname,
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 NULL);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
98 for (s = 0; sections[s].heading; s++) {
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
99 GtkWidget *vbox = g_object_get_data(G_OBJECT(window), sections[s].heading);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
100 for (i = 0; sections[s].options[i].stockid; i++) {
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
101 GtkWidget *image = g_object_get_data(G_OBJECT(vbox), sections[s].options[i].stockid);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
102 GdkPixbuf *pixbuf = g_object_get_data(G_OBJECT(image), "pixbuf");
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
103 if (!pixbuf)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
104 continue;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
105 pidgin_icon_theme_set_icon(PIDGIN_ICON_THEME(theme), sections[s].options[i].stockid,
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
106 sections[s].options[i].stockid);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
107 for (j = 0; stocksizes[j]; j++) {
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
108 int width, height;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
109 GtkIconSize iconsize;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
110 char size[8];
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
111 char *name;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
112 GdkPixbuf *scale;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
113 GError *error = NULL;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
115 iconsize = gtk_icon_size_from_name(stocksizes[j]);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
116 gtk_icon_size_lookup(iconsize, &width, &height);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
117 g_snprintf(size, sizeof(size), "%d", width);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
119 if (i == 0) {
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
120 name = g_build_filename(dirname, size, NULL);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
121 purple_build_dir(name, S_IRUSR | S_IWUSR | S_IXUSR);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
122 g_free(name);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
123 }
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
124
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
125 name = g_build_filename(dirname, size, sections[s].options[i].stockid, NULL);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
126 scale = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
127 gdk_pixbuf_save(scale, name, "png", &error, "compression", "9", NULL);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 g_free(name);
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
129 g_object_unref(G_OBJECT(scale));
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
130 if (error)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
131 g_error_free(error);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
133 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 return theme;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 use_icon_theme(GtkWidget *w, GtkWidget *window)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140 {
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
141 /* I don't quite understand the icon-theme stuff. For example, I don't
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
142 * know why PidginIconTheme needs to be abstract, or how PidginStatusIconTheme
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
143 * would be different from other PidginIconTheme's (e.g. PidginStockIconTheme)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
144 * etc., but anyway, this works for now.
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
145 *
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
146 * Here's an interesting note: A PidginStatusIconTheme can be used for both
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
147 * stock and status icons. Like I said, I don't quite know how they could be
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
148 * different. So I am going to just keep it as it is, for now anyway, until I
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
149 * have the time to dig through this, or someone explains this stuff to me
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
150 * clearly.
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
151 * -- Sad
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
152 */
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 PidginStatusIconTheme *theme = create_icon_theme(window);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154 pidgin_stock_load_status_icon_theme(PIDGIN_STATUS_ICON_THEME(theme));
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
155 pidgin_stock_load_stock_icon_theme((PidginStockIconTheme *)theme);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
156 pidgin_blist_refresh(purple_get_blist());
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157 g_object_unref(theme);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 save_icon_theme(GtkWidget *w, GtkWidget *window)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 /* TODO: SAVE! */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 gtk_widget_destroy(window);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 stock_icon_selected(const char *filename, gpointer image)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 GError *error = NULL;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 GdkPixbuf *scale;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 int i;
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
173 GdkPixbuf *pixbuf;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
175 if (!filename)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
176 return;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
177
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
178 pixbuf = gdk_pixbuf_new_from_file(filename, &error);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 if (error || !pixbuf) {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 purple_debug_error("theme-editor-icon", "Unable to load icon file '%s' (%s)\n",
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 filename, error ? error->message : "Reason unknown");
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 if (error)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 g_error_free(error);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 return;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 gtk_image_set_from_pixbuf(GTK_IMAGE(image), scale);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 g_object_unref(G_OBJECT(scale));
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 /* Update the size previews */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 for (i = 0; stocksizes[i]; i++) {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 int width, height;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194 GtkIconSize iconsize;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 GtkWidget *prev = g_object_get_data(G_OBJECT(image), stocksizes[i]);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 if (!prev)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 continue;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 iconsize = gtk_icon_size_from_name(stocksizes[i]);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199 gtk_icon_size_lookup(iconsize, &width, &height);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200 scale = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 gtk_image_set_from_pixbuf(GTK_IMAGE(prev), scale);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 g_object_unref(G_OBJECT(scale));
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205 /* Save the original pixbuf so we can use it for resizing later */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 g_object_set_data_full(G_OBJECT(image), "pixbuf", pixbuf,
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 (GDestroyNotify)g_object_unref);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 static gboolean
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211 change_stock_image(GtkWidget *widget, GdkEventButton *event, GtkWidget *image)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 GtkWidget *win = pidgin_buddy_icon_chooser_new(GTK_WINDOW(gtk_widget_get_toplevel(widget)),
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 stock_icon_selected, image);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215 gtk_widget_show_all(win);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 return TRUE;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 void pidgin_icon_theme_edit(void)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 GtkWidget *dialog;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 GtkWidget *box, *vbox;
26665
df0915055560 Add some more status emblems, and since the dialog is too long, use a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26664
diff changeset
224 GtkWidget *notebook;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 GtkSizeGroup *sizegroup;
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
226 int s, i, j;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 dialog = pidgin_create_dialog(_("Pidgin Icon Theme Editor"), 0, "theme-editor-icon", FALSE);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 box = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(dialog), FALSE, PIDGIN_HIG_BOX_SPACE);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229
26665
df0915055560 Add some more status emblems, and since the dialog is too long, use a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26664
diff changeset
230 notebook = gtk_notebook_new();
df0915055560 Add some more status emblems, and since the dialog is too long, use a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26664
diff changeset
231 gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, PIDGIN_HIG_BOX_SPACE);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232 sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
234 for (s = 0; sections[s].heading; s++) {
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
235 const char *heading = sections[s].heading;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
236
26665
df0915055560 Add some more status emblems, and since the dialog is too long, use a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26664
diff changeset
237 box = gtk_vbox_new(FALSE, 0);
df0915055560 Add some more status emblems, and since the dialog is too long, use a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26664
diff changeset
238 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), box, gtk_label_new(heading));
df0915055560 Add some more status emblems, and since the dialog is too long, use a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26664
diff changeset
239
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
240 vbox = pidgin_make_frame(box, heading);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
241 g_object_set_data(G_OBJECT(dialog), heading, vbox);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
243 for (i = 0; sections[s].options[i].stockid; i++) {
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
244 const char *id = sections[s].options[i].stockid;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
245 const char *text = _(sections[s].options[i].text);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
246
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
247 GtkWidget *hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
248 GtkWidget *label = gtk_label_new(text);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
249 GtkWidget *image = gtk_image_new_from_stock(id,
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
250 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
251 GtkWidget *ebox = gtk_event_box_new();
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
252 gtk_container_add(GTK_CONTAINER(ebox), image);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
253 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
255 g_signal_connect(G_OBJECT(ebox), "button-press-event", G_CALLBACK(change_stock_image), image);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
256 g_object_set_data(G_OBJECT(image), "property-name", (gpointer)id);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
258 gtk_size_group_add_widget(sizegroup, label);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
259 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
260 gtk_box_pack_start(GTK_BOX(hbox), ebox, FALSE, FALSE, 0);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
261
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
262 for (j = 0; stocksizes[j]; j++) {
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
263 GtkWidget *sh = gtk_image_new_from_stock(id, gtk_icon_size_from_name(stocksizes[j]));
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
264 gtk_box_pack_start(GTK_BOX(hbox), sh, FALSE, FALSE, 0);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
265 g_object_set_data(G_OBJECT(image), stocksizes[j], sh);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
266 }
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
267
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
268 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
269
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
270 g_object_set_data(G_OBJECT(vbox), id, image);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
271 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 pidgin_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_SAVE, G_CALLBACK(save_icon_theme), dialog);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275 pidgin_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_APPLY, G_CALLBACK(use_icon_theme), dialog);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
276 gtk_widget_show_all(dialog);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
277 g_object_unref(sizegroup);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
279