finch/libgnt/gntstyle.c

Wed, 13 May 2009 20:29:03 +0000

author
Marcus Lundblad <malu@pidgin.im>
date
Wed, 13 May 2009 20:29:03 +0000
changeset 27110
05ca719b901b
parent 24822
d7774462f2ba
child 31294
73607ab89c6f
permissions
-rw-r--r--

Support custom smileys in MUCs (when all participants support BoB and a maximum
of 10 participants are in the chat).
Always announce support for BoB, since disable custom smileys will still turn
off fetching them, and BoB can be used for other purposes further on.

18114
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
1 /**
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
2 * GNT - The GLib Ncurses Toolkit
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
3 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
4 * GNT is the legal property of its developers, whose names are too numerous
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
6 * source distribution.
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
7 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
8 * This library is free software; you can redistribute it and/or modify
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
9 * it under the terms of the GNU General Public License as published by
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
11 * (at your option) any later version.
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
12 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
13 * This program is distributed in the hope that it will be useful,
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
16 * GNU General Public License for more details.
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
17 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
18 * You should have received a copy of the GNU General Public License
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
19 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19562
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
18114
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
21 */
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18107
diff changeset
22
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
23 #include "gntinternal.h"
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
24 #undef GNT_LOG_DOMAIN
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
25 #define GNT_LOG_DOMAIN "Style"
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
26
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
27 #include "gntstyle.h"
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
28 #include "gntcolors.h"
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
29 #include "gntws.h"
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
30
18107
080301575c86 Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16025
diff changeset
31 #include <glib.h>
14898
107b971b39f2 [gaim-migrate @ 17605]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14855
diff changeset
32 #include <ctype.h>
18147
57b0643dc245 Get rid of a little compile error
Mark Doliner <markdoliner@pidgin.im>
parents: 18132
diff changeset
33 #include <stdlib.h>
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
34 #include <string.h>
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
35
16524
1f114ebacb0d Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents: 16519
diff changeset
36 #define MAX_WORKSPACES 99
1f114ebacb0d Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents: 16519
diff changeset
37
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
38 #if GLIB_CHECK_VERSION(2,6,0)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
39 static GKeyFile *gkfile;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
40 #endif
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
41
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
42 static char * str_styles[GNT_STYLES];
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
43 static int int_styles[GNT_STYLES];
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
44 static int bool_styles[GNT_STYLES];
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
45
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
46 const char *gnt_style_get(GntStyle style)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
47 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
48 return str_styles[style];
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
49 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
50
18370
1f3c329fe2b2 Plug a memory leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18361
diff changeset
51 char *gnt_style_get_from_name(const char *group, const char *key)
18107
080301575c86 Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16025
diff changeset
52 {
18361
740fec710f0a This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18164
diff changeset
53 #if GLIB_CHECK_VERSION(2,6,0)
18782
b84a95130dd8 I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents: 18761
diff changeset
54 const char *prg = g_get_prgname();
18792
f3b647ac9f6d Typo fix. This bit of code must be cursed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18782
diff changeset
55 if ((group == NULL || *group == '\0') && prg &&
18782
b84a95130dd8 I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents: 18761
diff changeset
56 g_key_file_has_group(gkfile, prg))
b84a95130dd8 I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents: 18761
diff changeset
57 group = prg;
b84a95130dd8 I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents: 18761
diff changeset
58 if (!group)
18758
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
59 group = "general";
18361
740fec710f0a This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18164
diff changeset
60 return g_key_file_get_value(gkfile, group, key, NULL);
19562
f7931803273a Get rid of compile warnings on older glib.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18847
diff changeset
61 #else
f7931803273a Get rid of compile warnings on older glib.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18847
diff changeset
62 return NULL;
18361
740fec710f0a This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18164
diff changeset
63 #endif
18107
080301575c86 Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16025
diff changeset
64 }
080301575c86 Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16025
diff changeset
65
21855
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
66 int
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
67 gnt_style_get_color(char *group, char *key)
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
68 {
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
69 #if GLIB_CHECK_VERSION(2,6,0)
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
70 int fg = 0, bg = 0;
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
71 gsize n;
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
72 char **vals;
21893
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
73 int ret = 0;
21855
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
74 vals = gnt_style_get_string_list(group, key, &n);
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
75 if (vals && n == 2) {
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
76 fg = gnt_colors_get_color(vals[0]);
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
77 bg = gnt_colors_get_color(vals[1]);
21893
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
78 ret = gnt_color_add_pair(fg, bg);
21855
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
79 }
21893
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
80 g_strfreev(vals);
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
81 return ret;
21855
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
82 #else
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
83 return 0;
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
84 #endif
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
85 }
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
86
21804
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
87 char **gnt_style_get_string_list(const char *group, const char *key, gsize *length)
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
88 {
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
89 #if GLIB_CHECK_VERSION(2,6,0)
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
90 const char *prg = g_get_prgname();
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
91 if ((group == NULL || *group == '\0') && prg &&
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
92 g_key_file_has_group(gkfile, prg))
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
93 group = prg;
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
94 if (!group)
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
95 group = "general";
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
96 return g_key_file_get_string_list(gkfile, group, key, length, NULL);
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
97 #else
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
98 return NULL;
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
99 #endif
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
100 }
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
101
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
102 gboolean gnt_style_get_bool(GntStyle style, gboolean def)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
103 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
104 const char * str;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
105
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
106 if (bool_styles[style] != -1)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
107 return bool_styles[style];
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
108
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
109 str = gnt_style_get(style);
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
110
18758
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
111 bool_styles[style] = str ? gnt_style_parse_bool(str) : def;
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
112 return bool_styles[style];
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
113 }
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
114
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
115 gboolean gnt_style_parse_bool(const char *str)
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
116 {
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
117 gboolean def = FALSE;
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
118 int i;
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
119
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
120 if (str)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
121 {
18758
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
122 if (g_ascii_strcasecmp(str, "false") == 0)
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
123 def = FALSE;
18758
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
124 else if (g_ascii_strcasecmp(str, "true") == 0)
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
125 def = TRUE;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
126 else if (sscanf(str, "%d", &i) == 1)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
127 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
128 if (i)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
129 def = TRUE;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
130 else
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
131 def = FALSE;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
132 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
133 }
18758
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
134 return def;
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
135 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
136
19562
f7931803273a Get rid of compile warnings on older glib.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18847
diff changeset
137 #if GLIB_CHECK_VERSION(2,6,0)
15040
433e06134a7b [gaim-migrate @ 17757]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14962
diff changeset
138 static void
433e06134a7b [gaim-migrate @ 17757]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14962
diff changeset
139 refine(char *text)
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
140 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
141 char *s = text, *t = text;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
142
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
143 while (*s)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
144 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
145 if (*s == '^' && *(s + 1) == '[')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
146 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
147 *t = '\033'; /* escape */
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
148 s++;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
149 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
150 else if (*s == '\\')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
151 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
152 if (*(s + 1) == '\0')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
153 *t = ' ';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
154 else
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
155 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
156 s++;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
157 if (*s == 'r' || *s == 'n')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
158 *t = '\r';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
159 else if (*s == 't')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
160 *t = '\t';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
161 else
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
162 *t = *s;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
163 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
164 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
165 else
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
166 *t = *s;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
167 t++;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
168 s++;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
169 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
170 *t = '\0';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
171 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
172
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
173 static char *
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
174 parse_key(const char *key)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
175 {
15874
46df7421a1b5 Enable DEBUG_CFLAGS in libgnt and fix up a number of compile warnings and
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15862
diff changeset
176 return (char *)gnt_key_translate(key);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
177 }
19562
f7931803273a Get rid of compile warnings on older glib.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18847
diff changeset
178 #endif
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
179
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
180 void gnt_style_read_workspaces(GntWM *wm)
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
181 {
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
182 #if GLIB_CHECK_VERSION(2,6,0)
16524
1f114ebacb0d Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents: 16519
diff changeset
183 int i;
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
184 gchar *name;
16525
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
185 gsize c;
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
186
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
187 for (i = 1; i < MAX_WORKSPACES; ++i) {
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
188 int j;
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
189 GntWS *ws;
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
190 gchar **titles;
18847
409cb01a636e This could have resulted in buffer overflow if the user had 10 or more
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18792
diff changeset
191 char group[32];
409cb01a636e This could have resulted in buffer overflow if the user had 10 or more
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18792
diff changeset
192 g_snprintf(group, sizeof(group), "Workspace-%d", i);
16525
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
193 name = g_key_file_get_value(gkfile, group, "name", NULL);
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
194 if (!name)
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
195 return;
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
196
18138
4bbda12891c1 Update for the new api.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18132
diff changeset
197 ws = gnt_ws_new(name);
16525
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
198 gnt_wm_add_workspace(wm, ws);
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
199 g_free(name);
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
200
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
201 titles = g_key_file_get_string_list(gkfile, group, "window-names", &c, NULL);
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
202 if (titles) {
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
203 for (j = 0; j < c; ++j)
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
204 g_hash_table_replace(wm->name_places, g_strdup(titles[j]), ws);
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
205 g_strfreev(titles);
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
206 }
16525
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
207
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
208 titles = g_key_file_get_string_list(gkfile, group, "window-titles", &c, NULL);
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
209 if (titles) {
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
210 for (j = 0; j < c; ++j)
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
211 g_hash_table_replace(wm->title_places, g_strdup(titles[j]), ws);
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
212 g_strfreev(titles);
6e207d99ffd9 New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents: 16524
diff changeset
213 }
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
214 }
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
215 #endif
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
216 }
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
217 void gnt_style_read_actions(GType type, GntBindableClass *klass)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
218 {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
219 #if GLIB_CHECK_VERSION(2,6,0)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
220 char *name;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
221 GError *error = NULL;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
222
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
223 name = g_strdup_printf("%s::binding", g_type_name(type));
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
224
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
225 if (g_key_file_has_group(gkfile, name))
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
226 {
14901
4e524abde87a [gaim-migrate @ 17608]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14898
diff changeset
227 gsize len = 0;
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
228 char **keys;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
229
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
230 keys = g_key_file_get_keys(gkfile, name, &len, &error);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
231 if (error)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
232 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
233 gnt_warning("%s", error->message);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
234 g_error_free(error);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
235 g_free(name);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
236 return;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
237 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
238
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
239 while (len--)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
240 {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
241 char *key, *action;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
242
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
243 key = g_strdup(keys[len]);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
244 action = g_key_file_get_string(gkfile, name, keys[len], &error);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
245
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
246 if (error)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
247 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
248 gnt_warning("%s", error->message);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
249 g_error_free(error);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
250 error = NULL;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
251 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
252 else
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
253 {
15862
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15367
diff changeset
254 const char *keycode = parse_key(key);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
255 if (keycode == NULL) {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
256 gnt_warning("Invalid key-binding %s", key);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
257 } else {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
258 gnt_bindable_register_binding(klass, action, keycode, NULL);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
259 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
260 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
261 g_free(key);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
262 g_free(action);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
263 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
264 g_strfreev(keys);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
265 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
266 g_free(name);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
267 #endif
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
268 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
269
20821
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
270 gboolean gnt_style_read_menu_accels(const char *name, GHashTable *table)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
271 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
272 #if GLIB_CHECK_VERSION(2,6,0)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
273 char *kname;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
274 GError *error = NULL;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
275 gboolean ret = FALSE;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
276
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
277 kname = g_strdup_printf("%s::menu", name);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
278
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
279 if (g_key_file_has_group(gkfile, kname))
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
280 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
281 gsize len = 0;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
282 char **keys;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
283
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
284 keys = g_key_file_get_keys(gkfile, kname, &len, &error);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
285 if (error)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
286 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
287 gnt_warning("%s", error->message);
20821
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
288 g_error_free(error);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
289 g_free(kname);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
290 return ret;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
291 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
292
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
293 while (len--)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
294 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
295 char *key, *menuid;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
296
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
297 key = g_strdup(keys[len]);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
298 menuid = g_key_file_get_string(gkfile, kname, keys[len], &error);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
299
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
300 if (error)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
301 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
302 gnt_warning("%s", error->message);
20821
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
303 g_error_free(error);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
304 error = NULL;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
305 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
306 else
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
307 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
308 const char *keycode = parse_key(key);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
309 if (keycode == NULL) {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
310 gnt_warning("Invalid key-binding %s", key);
20821
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
311 } else {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
312 ret = TRUE;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
313 g_hash_table_replace(table, g_strdup(keycode), menuid);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
314 menuid = NULL;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
315 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
316 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
317 g_free(key);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
318 g_free(menuid);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
319 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
320 g_strfreev(keys);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
321 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
322
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
323 g_free(kname);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
324 return ret;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
325 #endif
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
326 return FALSE;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
327 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
328
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
329 void gnt_styles_get_keyremaps(GType type, GHashTable *hash)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
330 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
331 #if GLIB_CHECK_VERSION(2,6,0)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
332 char *name;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
333 GError *error = NULL;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
334
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
335 name = g_strdup_printf("%s::remap", g_type_name(type));
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
336
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
337 if (g_key_file_has_group(gkfile, name))
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
338 {
14901
4e524abde87a [gaim-migrate @ 17608]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14898
diff changeset
339 gsize len = 0;
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
340 char **keys;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
341
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
342 keys = g_key_file_get_keys(gkfile, name, &len, &error);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
343 if (error)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
344 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
345 gnt_warning("%s", error->message);
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
346 g_error_free(error);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
347 g_free(name);
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
348 return;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
349 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
350
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
351 while (len--)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
352 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
353 char *key, *replace;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
354
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
355 key = g_strdup(keys[len]);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
356 replace = g_key_file_get_string(gkfile, name, keys[len], &error);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
357
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
358 if (error)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
359 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
360 gnt_warning("%s", error->message);
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
361 g_error_free(error);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
362 error = NULL;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
363 g_free(key);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
364 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
365 else
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
366 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
367 refine(key);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
368 refine(replace);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
369 g_hash_table_insert(hash, key, replace);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
370 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
371 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
372 g_strfreev(keys);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
373 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
374
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
375 g_free(name);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
376 #endif
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
377 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
378
14272
e1efc981a1ec [gaim-migrate @ 16888]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14072
diff changeset
379 #if GLIB_CHECK_VERSION(2,6,0)
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
380 static void
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
381 read_general_style(GKeyFile *kfile)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
382 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
383 GError *error = NULL;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
384 gsize nkeys;
18416
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
385 const char *prgname = g_get_prgname();
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
386 char **keys = NULL;
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
387 int i;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
388 struct
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
389 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
390 const char *style;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
391 GntStyle en;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
392 } styles[] = {{"shadow", GNT_STYLE_SHADOW},
14361
4d6014205744 [gaim-migrate @ 16989]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14301
diff changeset
393 {"customcolor", GNT_STYLE_COLOR},
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
394 {"mouse", GNT_STYLE_MOUSE},
14397
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14372
diff changeset
395 {"wm", GNT_STYLE_WM},
15129
4722d1cf7938 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15070
diff changeset
396 {"remember_position", GNT_STYLE_REMPOS},
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
397 {NULL, 0}};
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
398
18416
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
399 if (prgname && *prgname)
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
400 keys = g_key_file_get_keys(kfile, prgname, &nkeys, NULL);
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
401
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
402 if (keys == NULL) {
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
403 prgname = "general";
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
404 keys = g_key_file_get_keys(kfile, prgname, &nkeys, &error);
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
405 }
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
406
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
407 if (error)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
408 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
409 gnt_warning("%s", error->message);
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
410 g_error_free(error);
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
411 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
412 else
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
413 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
414 for (i = 0; styles[i].style; i++)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
415 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
416 str_styles[styles[i].en] =
18416
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
417 g_key_file_get_string(kfile, prgname, styles[i].style, NULL);
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
418 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
419 }
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
420 g_strfreev(keys);
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
421 }
14272
e1efc981a1ec [gaim-migrate @ 16888]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14072
diff changeset
422 #endif
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
423
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
424 void gnt_style_read_configure_file(const char *filename)
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
425 {
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
426 #if GLIB_CHECK_VERSION(2,6,0)
14901
4e524abde87a [gaim-migrate @ 17608]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14898
diff changeset
427 GError *error = NULL;
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
428 gkfile = g_key_file_new();
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
429
18361
740fec710f0a This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18164
diff changeset
430 if (!g_key_file_load_from_file(gkfile, filename,
740fec710f0a This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18164
diff changeset
431 G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error))
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
432 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
433 gnt_warning("%s", error->message);
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
434 g_error_free(error);
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
435 return;
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
436 }
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
437 gnt_colors_parse(gkfile);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
438 read_general_style(gkfile);
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
439 #endif
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
440 }
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
441
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
442 void gnt_init_styles()
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
443 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
444 int i;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
445 for (i = 0; i < GNT_STYLES; i++)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
446 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
447 str_styles[i] = NULL;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
448 int_styles[i] = -1;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
449 bool_styles[i] = -1;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
450 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
451 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
452
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
453 void gnt_uninit_styles()
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
454 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
455 int i;
21245
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
456 for (i = 0; i < GNT_STYLES; i++) {
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
457 g_free(str_styles[i]);
21245
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
458 str_styles[i] = NULL;
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
459 }
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
460
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
461 #if GLIB_CHECK_VERSION(2,6,0)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
462 g_key_file_free(gkfile);
21245
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
463 gkfile = NULL;
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
464 #endif
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
465 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
466

mercurial