annotate pidgin/plugins/themeedit-icon.c @ 32778:14787acaf9d7

Patch from OpenBSD Ports to fix finch build on OpenBSD
author Ethan Blanton <elb@pidgin.im>
date Fri, 21 Oct 2011 14:36:06 +0000
parents 3c1563a54785
children
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")},
28057
390c3a6a44c6 Add a comment for these two strings. A translator asked about
Mark Doliner <mark@kingant.net>
parents: 27310
diff changeset
76 /* A user in a chat room who has special privileges. */
26664
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_OPERATOR, N_("Operator")},
28057
390c3a6a44c6 Add a comment for these two strings. A translator asked about
Mark Doliner <mark@kingant.net>
parents: 27310
diff changeset
78 /* A half operator is someone who has a subset of the privileges
390c3a6a44c6 Add a comment for these two strings. A translator asked about
Mark Doliner <mark@kingant.net>
parents: 27310
diff changeset
79 that an operator has. */
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
80 {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
81 {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
82 {NULL, NULL}
26666
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
83 }, dialogicons[] = {
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
84 {PIDGIN_STOCK_DIALOG_AUTH, N_("Authorization dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
85 {PIDGIN_STOCK_DIALOG_ERROR, N_("Error dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
86 {PIDGIN_STOCK_DIALOG_INFO, N_("Information dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
87 {PIDGIN_STOCK_DIALOG_MAIL, N_("Mail dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
88 {PIDGIN_STOCK_DIALOG_QUESTION, N_("Question dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
89 {PIDGIN_STOCK_DIALOG_WARNING, N_("Warning dialog")},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
90 {NULL, NULL},
6bf58e156da2 Allow editing dialog icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26665
diff changeset
91 {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
92 };
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
93
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
94 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
95 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
96 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
97 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
98 } 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
99 {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
100 {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
101 {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
102 {NULL, NULL, 0}
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 };
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 static PidginStatusIconTheme *
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 create_icon_theme(GtkWidget *window)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 {
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
108 int s, i, j;
31338
3c1563a54785 Build the "Pidgin Theme Editor" plugin on Windows too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28057
diff changeset
109 const char *dirname = g_get_tmp_dir();
3c1563a54785 Build the "Pidgin Theme Editor" plugin on Windows too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28057
diff changeset
110 PidginStatusIconTheme *theme;
3c1563a54785 Build the "Pidgin Theme Editor" plugin on Windows too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28057
diff changeset
111 const char *author;
3c1563a54785 Build the "Pidgin Theme Editor" plugin on Windows too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28057
diff changeset
112 #ifndef _WIN32
3c1563a54785 Build the "Pidgin Theme Editor" plugin on Windows too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28057
diff changeset
113 author = getlogin();
3c1563a54785 Build the "Pidgin Theme Editor" plugin on Windows too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28057
diff changeset
114 #else
3c1563a54785 Build the "Pidgin Theme Editor" plugin on Windows too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28057
diff changeset
115 author = "user";
3c1563a54785 Build the "Pidgin Theme Editor" plugin on Windows too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28057
diff changeset
116 #endif
3c1563a54785 Build the "Pidgin Theme Editor" plugin on Windows too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28057
diff changeset
117 theme = g_object_new(PIDGIN_TYPE_STATUS_ICON_THEME, "type", "status-icon",
3c1563a54785 Build the "Pidgin Theme Editor" plugin on Windows too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28057
diff changeset
118 "author", author,
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 "directory", dirname,
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 NULL);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
122 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
123 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
124 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
125 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
126 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
127 if (!pixbuf)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
128 continue;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
129 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
130 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
131 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
132 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
133 GtkIconSize iconsize;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
134 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
135 char *name;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
136 GdkPixbuf *scale;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
137 GError *error = NULL;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138
26667
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
139 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
140 continue;
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
141
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
142 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
143 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
144 g_snprintf(size, sizeof(size), "%d", width);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
146 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
147 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
148 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
149 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
150 }
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
151
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
152 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
153 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
154 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
155 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
156 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
157 if (error)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
158 g_error_free(error);
26662
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 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 return theme;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 use_icon_theme(GtkWidget *w, GtkWidget *window)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 {
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
168 /* 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
169 * 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
170 * 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
171 * 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
172 *
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
173 * 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
174 * 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
175 * 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
176 * 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
177 * clearly.
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
178 * -- Sad
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
179 */
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 PidginStatusIconTheme *theme = create_icon_theme(window);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 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
182 pidgin_stock_load_stock_icon_theme((PidginStockIconTheme *)theme);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 pidgin_blist_refresh(purple_get_blist());
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 g_object_unref(theme);
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
26720
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
187 #ifdef NOT_SADRUL
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 save_icon_theme(GtkWidget *w, GtkWidget *window)
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 /* TODO: SAVE! */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 gtk_widget_destroy(window);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 }
26720
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
194 #endif
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
195
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
196 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
197 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
198 {
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
199 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
200 }
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 stock_icon_selected(const char *filename, gpointer image)
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 GError *error = NULL;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 GdkPixbuf *scale;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 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
208 GdkPixbuf *pixbuf;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
210 if (!filename)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
211 return;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
212
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
213 pixbuf = gdk_pixbuf_new_from_file(filename, &error);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 if (error || !pixbuf) {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215 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
216 filename, error ? error->message : "Reason unknown");
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 if (error)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218 g_error_free(error);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 return;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 }
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 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
223 gtk_image_set_from_pixbuf(GTK_IMAGE(image), scale);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 g_object_unref(G_OBJECT(scale));
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 /* Update the size previews */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 for (i = 0; stocksizes[i]; i++) {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 int width, height;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 GtkIconSize iconsize;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 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
231 if (!prev)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232 continue;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 iconsize = gtk_icon_size_from_name(stocksizes[i]);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
234 gtk_icon_size_lookup(iconsize, &width, &height);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 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
236 gtk_image_set_from_pixbuf(GTK_IMAGE(prev), scale);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 g_object_unref(G_OBJECT(scale));
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 /* 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
241 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
242 (GDestroyNotify)g_object_unref);
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
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245 static gboolean
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246 change_stock_image(GtkWidget *widget, GdkEventButton *event, GtkWidget *image)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 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
249 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
250 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
251 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
252 gtk_widget_show_all(win);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 return TRUE;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256
26774
81559f83e993 Fix two warnings in the theme editor plugin
Paul Aurich <paul@darkrain42.org>
parents: 26720
diff changeset
257 void pidgin_icon_theme_edit(PurplePluginAction *unused)
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
259 GtkWidget *dialog;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260 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
261 GtkWidget *notebook;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262 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
263 int s, i, j;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264 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
265 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
266
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
267 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
268 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
269 sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
271 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
272 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
273
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
274 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
275 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
276
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
277 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
278 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
279
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
280 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
281 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
282 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
283
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
284 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
285 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
286 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
287 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
288 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
289 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
290 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
291
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
292 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
293 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
294 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
295
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
296 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
297 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
298 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
299
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
300 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
301 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
302
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
303 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
304 continue;
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
305
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
306 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
307 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
308 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
309 }
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
310
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
311 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
312
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
313 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
314 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
316
26720
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
317 #ifdef NOT_SADRUL
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
318 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
319 #endif
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
320 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
321 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
322 gtk_widget_show_all(dialog);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
323 g_object_unref(sizegroup);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
324 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
325