annotate pidgin/plugins/themeedit-icon.c @ 28314:975e213733e8

Change some strings in Yahoo! for 2.6.1.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Sat, 18 Jul 2009 17:57:48 +0000
parents 801e54fde3df
children 390c3a6a44c6
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
26667
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
36 typedef enum
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
37 {
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
38 FLAG_SIZE_MICROSOPIC = 0,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
39 FLAG_SIZE_EXTRA_SMALL,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
40 FLAG_SIZE_SMALL,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
41 FLAG_SIZE_MEDIUM,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
42 FLAG_SIZE_LARGE,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
43 FLAG_SIZE_HUGE,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
44 FLAG_SIZE_NONE,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
45 } SectionFlags;
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
46
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
47 #define SECTION_FLAGS_ALL (0x3f)
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
48
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 static const char *stocksizes [] = {
26667
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
50 [FLAG_SIZE_MICROSOPIC] = PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
51 [FLAG_SIZE_EXTRA_SMALL] = PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
52 [FLAG_SIZE_SMALL] = PIDGIN_ICON_SIZE_TANGO_SMALL,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
53 [FLAG_SIZE_MEDIUM] = PIDGIN_ICON_SIZE_TANGO_MEDIUM,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
54 [FLAG_SIZE_LARGE] = PIDGIN_ICON_SIZE_TANGO_LARGE,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
55 [FLAG_SIZE_HUGE] = PIDGIN_ICON_SIZE_TANGO_HUGE,
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
56 [FLAG_SIZE_NONE] = NULL,
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 };
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
59 static const struct options {
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 const char *stockid;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 const char *text;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 } statuses[] = {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 {PIDGIN_STOCK_STATUS_AVAILABLE, N_("Available")},
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 {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
65 {PIDGIN_STOCK_STATUS_XA, N_("Extended Away")},
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 {PIDGIN_STOCK_STATUS_BUSY, N_("Busy")},
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 {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
68 {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
69 {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
70 {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
71 {PIDGIN_STOCK_STATUS_CHAT, N_("Icon for Chat")},
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 {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
73 }, chatemblems[] = {
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
74 {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
75 {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
76 {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
77 {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
78 {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
79 {NULL, NULL}
26666
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
80 }, dialogicons[] = {
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
81 {PIDGIN_STOCK_DIALOG_AUTH, N_("Authorization dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
82 {PIDGIN_STOCK_DIALOG_ERROR, N_("Error dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
83 {PIDGIN_STOCK_DIALOG_INFO, N_("Information dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
84 {PIDGIN_STOCK_DIALOG_MAIL, N_("Mail dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
85 {PIDGIN_STOCK_DIALOG_QUESTION, N_("Question dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
86 {PIDGIN_STOCK_DIALOG_WARNING, N_("Warning dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
87 {NULL, NULL},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
88 {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
89 };
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
90
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
91 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
92 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
93 const struct options *options;
26667
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
94 SectionFlags flags;
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
95 } sections[] = {
26667
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
96 {N_("Status Icons"), statuses, SECTION_FLAGS_ALL ^ (1 << FLAG_SIZE_HUGE)},
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
97 {N_("Chatroom Emblems"), chatemblems, FLAG_SIZE_SMALL},
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
98 {N_("Dialog Icons"), dialogicons, (1 << FLAG_SIZE_EXTRA_SMALL) | (1 << FLAG_SIZE_HUGE)},
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
99 {NULL, NULL, 0}
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 };
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 static PidginStatusIconTheme *
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 create_icon_theme(GtkWidget *window)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104 {
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
105 int s, i, j;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 char *dirname = "/tmp"; /* FIXME */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 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
108 "author", getlogin(),
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109 "directory", dirname,
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 NULL);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
112 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
113 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
114 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
115 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
116 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
117 if (!pixbuf)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
118 continue;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
119 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
120 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
121 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
122 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
123 GtkIconSize iconsize;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
124 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
125 char *name;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
126 GdkPixbuf *scale;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
127 GError *error = NULL;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128
26667
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
129 if (!(sections[s].flags & (1 << j)))
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
130 continue;
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
131
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
132 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
133 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
134 g_snprintf(size, sizeof(size), "%d", width);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
136 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
137 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
138 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
139 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
140 }
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
141
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
142 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
143 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
144 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
145 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
146 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
147 if (error)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
148 g_error_free(error);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 return theme;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
155 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
156 use_icon_theme(GtkWidget *w, GtkWidget *window)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157 {
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
158 /* 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
159 * 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
160 * 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
161 * 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
162 *
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
163 * 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
164 * 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
165 * 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
166 * 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
167 * clearly.
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
168 * -- Sad
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
169 */
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 PidginStatusIconTheme *theme = create_icon_theme(window);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 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
172 pidgin_stock_load_stock_icon_theme((PidginStockIconTheme *)theme);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 pidgin_blist_refresh(purple_get_blist());
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 g_object_unref(theme);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176
26720
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
177 #ifdef NOT_SADRUL
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 save_icon_theme(GtkWidget *w, GtkWidget *window)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 /* TODO: SAVE! */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 gtk_widget_destroy(window);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 }
26720
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
184 #endif
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
185
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
186 static void
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
187 close_icon_theme(GtkWidget *w, GtkWidget *window)
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
188 {
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
189 gtk_widget_destroy(window);
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
190 }
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 stock_icon_selected(const char *filename, gpointer image)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 GError *error = NULL;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 GdkPixbuf *scale;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 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
198 GdkPixbuf *pixbuf;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
200 if (!filename)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
201 return;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
202
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
203 pixbuf = gdk_pixbuf_new_from_file(filename, &error);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 if (error || !pixbuf) {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205 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
206 filename, error ? error->message : "Reason unknown");
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 if (error)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 g_error_free(error);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 return;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 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
213 gtk_image_set_from_pixbuf(GTK_IMAGE(image), scale);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 g_object_unref(G_OBJECT(scale));
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216 /* Update the size previews */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 for (i = 0; stocksizes[i]; i++) {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218 int width, height;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 GtkIconSize iconsize;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 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
221 if (!prev)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 continue;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 iconsize = gtk_icon_size_from_name(stocksizes[i]);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 gtk_icon_size_lookup(iconsize, &width, &height);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 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
226 gtk_image_set_from_pixbuf(GTK_IMAGE(prev), scale);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 g_object_unref(G_OBJECT(scale));
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 /* 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
231 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
232 (GDestroyNotify)g_object_unref);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
234
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 static gboolean
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 change_stock_image(GtkWidget *widget, GdkEventButton *event, GtkWidget *image)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 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
239 stock_icon_selected, image);
27310
801e54fde3df Change the name of the file selector from "Buddy Icon" to the name of the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26774
diff changeset
240 gtk_window_set_title(GTK_WINDOW(win),
801e54fde3df Change the name of the file selector from "Buddy Icon" to the name of the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26774
diff changeset
241 g_object_get_data(G_OBJECT(image), "localized-name"));
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 gtk_widget_show_all(win);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 return TRUE;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246
26774
81559f83e993 Fix two warnings in the theme editor plugin
Paul Aurich <paul@darkrain42.org>
parents: 26720
diff changeset
247 void pidgin_icon_theme_edit(PurplePluginAction *unused)
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249 GtkWidget *dialog;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 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
251 GtkWidget *notebook;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 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
253 int s, i, j;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 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
255 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
256
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
257 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
258 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
259 sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
261 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
262 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
263
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
264 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
265 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
266
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
267 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
268 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
269
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
270 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
271 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
272 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
273
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
274 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
275 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
276 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
277 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
278 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
279 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
280 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
281
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
282 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
283 g_object_set_data(G_OBJECT(image), "property-name", (gpointer)id);
27310
801e54fde3df Change the name of the file selector from "Buddy Icon" to the name of the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26774
diff changeset
284 g_object_set_data(G_OBJECT(image), "localized-name", (gpointer)text);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
285
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
286 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
287 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
288 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
289
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
290 for (j = 0; stocksizes[j]; j++) {
26667
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
291 GtkWidget *sh;
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
292
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
293 if (!(sections[s].flags & (1 << j)))
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
294 continue;
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
295
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
296 sh = gtk_image_new_from_stock(id, gtk_icon_size_from_name(stocksizes[j]));
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
297 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
298 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
299 }
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
300
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
301 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
302
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
303 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
304 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306
26720
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
307 #ifdef NOT_SADRUL
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 pidgin_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_SAVE, G_CALLBACK(save_icon_theme), dialog);
26720
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
309 #endif
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
310 pidgin_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_APPLY, G_CALLBACK(use_icon_theme), dialog);
26720
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
311 pidgin_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, G_CALLBACK(close_icon_theme), dialog);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
312 gtk_widget_show_all(dialog);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313 g_object_unref(sizegroup);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
314 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315