finch/libgnt/gntstyle.c

Wed, 30 Jul 2008 03:58:21 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Wed, 30 Jul 2008 03:58:21 +0000
changeset 23931
8975bb78b51a
parent 21893
c01f39ef23db
child 24822
d7774462f2ba
permissions
-rw-r--r--

Cleanup unnecessary casts and etc.

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
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
23 #include "gntstyle.h"
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
24 #include "gntcolors.h"
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
25 #include "gntws.h"
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
26
18107
080301575c86 Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16025
diff changeset
27 #include <glib.h>
14898
107b971b39f2 [gaim-migrate @ 17605]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14855
diff changeset
28 #include <ctype.h>
18147
57b0643dc245 Get rid of a little compile error
Mark Doliner <markdoliner@pidgin.im>
parents: 18132
diff changeset
29 #include <stdlib.h>
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
30 #include <string.h>
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
31
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
32 #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
33
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
34 #if GLIB_CHECK_VERSION(2,6,0)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
35 static GKeyFile *gkfile;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
36 #endif
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
37
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
38 static char * str_styles[GNT_STYLES];
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
39 static int int_styles[GNT_STYLES];
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
40 static int bool_styles[GNT_STYLES];
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
41
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
42 const char *gnt_style_get(GntStyle style)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
43 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
44 return str_styles[style];
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
18370
1f3c329fe2b2 Plug a memory leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18361
diff changeset
47 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
48 {
18361
740fec710f0a This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18164
diff changeset
49 #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
50 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
51 if ((group == NULL || *group == '\0') && prg &&
18782
b84a95130dd8 I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents: 18761
diff changeset
52 g_key_file_has_group(gkfile, prg))
b84a95130dd8 I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents: 18761
diff changeset
53 group = prg;
b84a95130dd8 I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents: 18761
diff changeset
54 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
55 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
56 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
57 #else
f7931803273a Get rid of compile warnings on older glib.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18847
diff changeset
58 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
59 #endif
18107
080301575c86 Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16025
diff changeset
60 }
080301575c86 Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16025
diff changeset
61
21855
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
62 int
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
63 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
64 {
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
65 #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
66 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
67 gsize n;
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
68 char **vals;
21893
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
69 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
70 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
71 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
72 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
73 bg = gnt_colors_get_color(vals[1]);
21893
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
74 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
75 }
21893
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
76 g_strfreev(vals);
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
77 return ret;
21855
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
78 #else
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
79 return 0;
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
80 #endif
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
81 }
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
82
21804
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
83 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
84 {
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
85 #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
86 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
87 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
88 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
89 group = prg;
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
90 if (!group)
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
91 group = "general";
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
92 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
93 #else
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
94 return NULL;
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
95 #endif
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
96 }
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
97
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
98 gboolean gnt_style_get_bool(GntStyle style, gboolean def)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
99 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
100 const char * str;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
101
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
102 if (bool_styles[style] != -1)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
103 return bool_styles[style];
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
104
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
105 str = gnt_style_get(style);
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
106
18758
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
107 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
108 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
109 }
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
110
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
111 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
112 {
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
113 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
114 int i;
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
115
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
116 if (str)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
117 {
18758
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
118 if (g_ascii_strcasecmp(str, "false") == 0)
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
119 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
120 else if (g_ascii_strcasecmp(str, "true") == 0)
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
121 def = TRUE;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
122 else if (sscanf(str, "%d", &i) == 1)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
123 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
124 if (i)
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
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
127 def = FALSE;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
128 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
129 }
18758
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
130 return def;
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
131 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
132
19562
f7931803273a Get rid of compile warnings on older glib.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18847
diff changeset
133 #if GLIB_CHECK_VERSION(2,6,0)
15040
433e06134a7b [gaim-migrate @ 17757]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14962
diff changeset
134 static void
433e06134a7b [gaim-migrate @ 17757]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14962
diff changeset
135 refine(char *text)
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
136 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
137 char *s = text, *t = text;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
138
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
139 while (*s)
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 if (*s == '^' && *(s + 1) == '[')
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 *t = '\033'; /* escape */
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
144 s++;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
145 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
146 else if (*s == '\\')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
147 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
148 if (*(s + 1) == '\0')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
149 *t = ' ';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
150 else
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 s++;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
153 if (*s == 'r' || *s == 'n')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
154 *t = '\r';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
155 else if (*s == 't')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
156 *t = '\t';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
157 else
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
158 *t = *s;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
159 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
160 }
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 t++;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
164 s++;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
165 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
166 *t = '\0';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
167 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
168
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
169 static char *
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
170 parse_key(const char *key)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
171 {
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
172 return (char *)gnt_key_translate(key);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
173 }
19562
f7931803273a Get rid of compile warnings on older glib.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18847
diff changeset
174 #endif
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
175
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
176 void gnt_style_read_workspaces(GntWM *wm)
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
177 {
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
178 #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
179 int i;
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
180 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
181 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
182
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
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 return;
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
192
18138
4bbda12891c1 Update for the new api.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18132
diff changeset
193 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
194 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
195 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
196
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
197 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
198 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
199 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
200 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
201 g_strfreev(titles);
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
202 }
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
203
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 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
205 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
206 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
207 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
208 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
209 }
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
210 }
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
211 #endif
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
212 }
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
213 void gnt_style_read_actions(GType type, GntBindableClass *klass)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
214 {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
215 #if GLIB_CHECK_VERSION(2,6,0)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
216 char *name;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
217 GError *error = NULL;
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 name = g_strdup_printf("%s::binding", g_type_name(type));
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
220
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
221 if (g_key_file_has_group(gkfile, name))
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
222 {
14901
4e524abde87a [gaim-migrate @ 17608]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14898
diff changeset
223 gsize len = 0;
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
224 char **keys;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
225
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
226 keys = g_key_file_get_keys(gkfile, name, &len, &error);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
227 if (error)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
228 {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
229 g_printerr("GntStyle: %s\n", error->message);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
230 g_error_free(error);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
231 g_free(name);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
232 return;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
233 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
234
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
235 while (len--)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
236 {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
237 char *key, *action;
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 key = g_strdup(keys[len]);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
240 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
241
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
242 if (error)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
243 {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
244 g_printerr("GntStyle: %s\n", error->message);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
245 g_error_free(error);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
246 error = NULL;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
247 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
248 else
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
249 {
15862
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15367
diff changeset
250 const char *keycode = parse_key(key);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
251 if (keycode == NULL) {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
252 g_printerr("GntStyle: Invalid key-binding %s\n", key);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
253 } else {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
254 gnt_bindable_register_binding(klass, action, keycode, NULL);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
255 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
256 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
257 g_free(key);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
258 g_free(action);
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 g_strfreev(keys);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
261 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
262 g_free(name);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
263 #endif
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
264 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
265
20821
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
266 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
267 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
268 #if GLIB_CHECK_VERSION(2,6,0)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
269 char *kname;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
270 GError *error = NULL;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
271 gboolean ret = FALSE;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
272
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
273 kname = g_strdup_printf("%s::menu", name);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
274
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
275 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
276 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
277 gsize len = 0;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
278 char **keys;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
279
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
280 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
281 if (error)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
282 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
283 g_printerr("GntStyle: %s\n", error->message);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
284 g_error_free(error);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
285 g_free(kname);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
286 return ret;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
287 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
288
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
289 while (len--)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
290 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
291 char *key, *menuid;
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 key = g_strdup(keys[len]);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
294 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
295
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
296 if (error)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
297 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
298 g_printerr("GntStyle: %s\n", error->message);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
299 g_error_free(error);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
300 error = NULL;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
301 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
302 else
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
303 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
304 const char *keycode = parse_key(key);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
305 if (keycode == NULL) {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
306 g_printerr("GntStyle: Invalid key-binding %s\n", key);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
307 } else {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
308 ret = TRUE;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
309 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
310 menuid = NULL;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
311 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
312 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
313 g_free(key);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
314 g_free(menuid);
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 g_strfreev(keys);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
317 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
318
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
319 g_free(kname);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
320 return ret;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
321 #endif
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
322 return FALSE;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
323 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
324
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
325 void gnt_styles_get_keyremaps(GType type, GHashTable *hash)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
326 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
327 #if GLIB_CHECK_VERSION(2,6,0)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
328 char *name;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
329 GError *error = NULL;
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 name = g_strdup_printf("%s::remap", g_type_name(type));
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
332
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
333 if (g_key_file_has_group(gkfile, name))
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
334 {
14901
4e524abde87a [gaim-migrate @ 17608]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14898
diff changeset
335 gsize len = 0;
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
336 char **keys;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
337
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
338 keys = g_key_file_get_keys(gkfile, name, &len, &error);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
339 if (error)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
340 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
341 g_printerr("GntStyle: %s\n", error->message);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
342 g_error_free(error);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
343 g_free(name);
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
344 return;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
345 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
346
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
347 while (len--)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
348 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
349 char *key, *replace;
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 key = g_strdup(keys[len]);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
352 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
353
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
354 if (error)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
355 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
356 g_printerr("GntStyle: %s\n", error->message);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
357 g_error_free(error);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
358 error = NULL;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
359 g_free(key);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
360 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
361 else
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
362 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
363 refine(key);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
364 refine(replace);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
365 g_hash_table_insert(hash, key, replace);
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 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
368 g_strfreev(keys);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
369 }
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 g_free(name);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
372 #endif
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
14272
e1efc981a1ec [gaim-migrate @ 16888]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14072
diff changeset
375 #if GLIB_CHECK_VERSION(2,6,0)
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
376 static void
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
377 read_general_style(GKeyFile *kfile)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
378 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
379 GError *error = NULL;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
380 gsize nkeys;
18416
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
381 const char *prgname = g_get_prgname();
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
382 char **keys = NULL;
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
383 int i;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
384 struct
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
385 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
386 const char *style;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
387 GntStyle en;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
388 } styles[] = {{"shadow", GNT_STYLE_SHADOW},
14361
4d6014205744 [gaim-migrate @ 16989]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14301
diff changeset
389 {"customcolor", GNT_STYLE_COLOR},
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
390 {"mouse", GNT_STYLE_MOUSE},
14397
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14372
diff changeset
391 {"wm", GNT_STYLE_WM},
15129
4722d1cf7938 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15070
diff changeset
392 {"remember_position", GNT_STYLE_REMPOS},
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
393 {NULL, 0}};
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
394
18416
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
395 if (prgname && *prgname)
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
396 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
397
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
398 if (keys == NULL) {
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
399 prgname = "general";
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, &error);
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
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
403 if (error)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
404 {
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
405 g_printerr("GntStyle: %s\n", error->message);
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
406 g_error_free(error);
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
407 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
408 else
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
409 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
410 for (i = 0; styles[i].style; i++)
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 str_styles[styles[i].en] =
18416
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
413 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
414 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
415 }
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
416 g_strfreev(keys);
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
417 }
14272
e1efc981a1ec [gaim-migrate @ 16888]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14072
diff changeset
418 #endif
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
419
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
420 void gnt_style_read_configure_file(const char *filename)
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
421 {
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
422 #if GLIB_CHECK_VERSION(2,6,0)
14901
4e524abde87a [gaim-migrate @ 17608]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14898
diff changeset
423 GError *error = NULL;
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
424 gkfile = g_key_file_new();
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
425
18361
740fec710f0a This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18164
diff changeset
426 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
427 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
428 {
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
429 g_printerr("GntStyle: %s\n", error->message);
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
430 g_error_free(error);
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
431 return;
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
432 }
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
433 gnt_colors_parse(gkfile);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
434 read_general_style(gkfile);
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
435 #endif
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
436 }
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
437
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
438 void gnt_init_styles()
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
439 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
440 int i;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
441 for (i = 0; i < GNT_STYLES; i++)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
442 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
443 str_styles[i] = NULL;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
444 int_styles[i] = -1;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
445 bool_styles[i] = -1;
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 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
448
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
449 void gnt_uninit_styles()
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 int i;
21245
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
452 for (i = 0; i < GNT_STYLES; i++) {
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
453 g_free(str_styles[i]);
21245
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
454 str_styles[i] = NULL;
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
455 }
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
456
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
457 #if GLIB_CHECK_VERSION(2,6,0)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
458 g_key_file_free(gkfile);
21245
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
459 gkfile = NULL;
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
460 #endif
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
461 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
462

mercurial