annotate pidgin/plugins/themeedit-icon.c @ 29189:afebd4e2fc1a

Retire the Lithuanian translator per email request.
author Paul Aurich <paul@darkrain42.org>
date Wed, 16 Dec 2009 06:27:38 +0000
parents 390c3a6a44c6
children 3c1563a54785
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;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109 char *dirname = "/tmp"; /* FIXME */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 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
111 "author", getlogin(),
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112 "directory", dirname,
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 NULL);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
115 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
116 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
117 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
118 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
119 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
120 if (!pixbuf)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
121 continue;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
122 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
123 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
124 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
125 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
126 GtkIconSize iconsize;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
127 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
128 char *name;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
129 GdkPixbuf *scale;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
130 GError *error = NULL;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131
26667
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
132 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
133 continue;
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
134
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
135 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
136 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
137 g_snprintf(size, sizeof(size), "%d", width);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
139 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
140 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
141 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
142 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
143 }
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
144
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
145 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
146 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
147 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
148 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
149 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
150 if (error)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
151 g_error_free(error);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 }
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 return theme;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
156 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 use_icon_theme(GtkWidget *w, GtkWidget *window)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 {
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
161 /* 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
162 * 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
163 * 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
164 * 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
165 *
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
166 * 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
167 * 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
168 * 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
169 * 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
170 * clearly.
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
171 * -- Sad
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
172 */
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 PidginStatusIconTheme *theme = create_icon_theme(window);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 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
175 pidgin_stock_load_stock_icon_theme((PidginStockIconTheme *)theme);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 pidgin_blist_refresh(purple_get_blist());
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 g_object_unref(theme);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179
26720
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
180 #ifdef NOT_SADRUL
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 save_icon_theme(GtkWidget *w, GtkWidget *window)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 /* TODO: SAVE! */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 gtk_widget_destroy(window);
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 #endif
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 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
190 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
191 {
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
192 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
193 }
26662
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 static void
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 stock_icon_selected(const char *filename, gpointer image)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 GError *error = NULL;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199 GdkPixbuf *scale;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200 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
201 GdkPixbuf *pixbuf;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
203 if (!filename)
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
204 return;
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
205
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
206 pixbuf = gdk_pixbuf_new_from_file(filename, &error);
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 if (error || !pixbuf) {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 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
209 filename, error ? error->message : "Reason unknown");
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 if (error)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211 g_error_free(error);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 return;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215 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
216 gtk_image_set_from_pixbuf(GTK_IMAGE(image), scale);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 g_object_unref(G_OBJECT(scale));
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 /* Update the size previews */
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 for (i = 0; stocksizes[i]; i++) {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 int width, height;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 GtkIconSize iconsize;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 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
224 if (!prev)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 continue;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 iconsize = gtk_icon_size_from_name(stocksizes[i]);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 gtk_icon_size_lookup(iconsize, &width, &height);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 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
229 gtk_image_set_from_pixbuf(GTK_IMAGE(prev), scale);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 g_object_unref(G_OBJECT(scale));
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 /* 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
234 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
235 (GDestroyNotify)g_object_unref);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 }
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 static gboolean
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239 change_stock_image(GtkWidget *widget, GdkEventButton *event, GtkWidget *image)
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241 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
242 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
243 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
244 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
245 gtk_widget_show_all(win);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 return TRUE;
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
26774
81559f83e993 Fix two warnings in the theme editor plugin
Paul Aurich <paul@darkrain42.org>
parents: 26720
diff changeset
250 void pidgin_icon_theme_edit(PurplePluginAction *unused)
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251 {
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 GtkWidget *dialog;
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253 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
254 GtkWidget *notebook;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255 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
256 int s, i, j;
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257 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
258 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
259
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
260 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
261 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
262 sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
264 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
265 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
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 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
268 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
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 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
271 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
272
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
273 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
274 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
275 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
276
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
285 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
286 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
287 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
288
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
289 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
290 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
291 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
292
26664
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
293 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
294 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
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 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
297 continue;
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
298
ed8385b26f6e Show preview of only the supported sizes for each class of icons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26666
diff changeset
299 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
300 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
301 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
302 }
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
303
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
304 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
305
5d71de58452c Make it possible to load non-status icons using a PidginStockIconTheme.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26663
diff changeset
306 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
307 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
309
26720
78bca07e6737 Disable the 'Save' buttons since they don't do nothing yet, man.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26667
diff changeset
310 #ifdef NOT_SADRUL
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
311 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
312 #endif
26662
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313 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
314 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
315 gtk_widget_show_all(dialog);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
316 g_object_unref(sizegroup);
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
317 }
0dddfdb3a24a A status-icon theme editor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
318