finch/libgnt/gntstyle.c

Wed, 23 Apr 2014 12:35:57 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Wed, 23 Apr 2014 12:35:57 +0200
changeset 35883
44327a195f54
parent 35480
8d853ab9225c
child 36257
c5445f25f90f
permissions
-rw-r--r--

cross-win32: finch: keep your files in config dir

35456
821aa4bcb6fa Fix a bunch of gtk-doc warnings in finch
Ankit Vani <a@nevitus.org>
parents: 34306
diff changeset
1 /*
18114
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 static GKeyFile *gkfile;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
39
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
40 static char * str_styles[GNT_STYLES];
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
41 static int int_styles[GNT_STYLES];
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
42 static int bool_styles[GNT_STYLES];
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 const char *gnt_style_get(GntStyle 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 return str_styles[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
18370
1f3c329fe2b2 Plug a memory leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18361
diff changeset
49 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
50 {
35480
8d853ab9225c Fix crash when scanning libgnt
Ankit Vani <a@nevitus.org>
parents: 35456
diff changeset
51 const char *prg;
8d853ab9225c Fix crash when scanning libgnt
Ankit Vani <a@nevitus.org>
parents: 35456
diff changeset
52
8d853ab9225c Fix crash when scanning libgnt
Ankit Vani <a@nevitus.org>
parents: 35456
diff changeset
53 /* gkfile is NULL when run by gtkdoc-scanobj or g-ir-scanner */
8d853ab9225c Fix crash when scanning libgnt
Ankit Vani <a@nevitus.org>
parents: 35456
diff changeset
54 if (!gkfile)
8d853ab9225c Fix crash when scanning libgnt
Ankit Vani <a@nevitus.org>
parents: 35456
diff changeset
55 return NULL;
8d853ab9225c Fix crash when scanning libgnt
Ankit Vani <a@nevitus.org>
parents: 35456
diff changeset
56
8d853ab9225c Fix crash when scanning libgnt
Ankit Vani <a@nevitus.org>
parents: 35456
diff changeset
57 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
58 if ((group == NULL || *group == '\0') && prg &&
18782
b84a95130dd8 I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents: 18761
diff changeset
59 g_key_file_has_group(gkfile, prg))
b84a95130dd8 I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents: 18761
diff changeset
60 group = prg;
b84a95130dd8 I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents: 18761
diff changeset
61 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
62 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
63 return g_key_file_get_value(gkfile, group, key, NULL);
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 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
70 gsize n;
fc93ce6595e4 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21804
diff changeset
71 char **vals;
21893
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
72 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
73 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
74 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
75 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
76 bg = gnt_colors_get_color(vals[1]);
21893
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
77 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
78 }
21893
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
79 g_strfreev(vals);
c01f39ef23db Plug a small leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21855
diff changeset
80 return ret;
21855
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 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
86 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
87 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
88 group = prg;
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
89 if (!group)
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
90 group = "general";
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
91 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
92 }
931ef2cc7cfb Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents: 21245
diff changeset
93
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
94 gboolean gnt_style_get_bool(GntStyle style, gboolean def)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
95 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
96 const char * str;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
97
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
98 if (bool_styles[style] != -1)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
99 return bool_styles[style];
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 24822
diff changeset
100
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
101 str = gnt_style_get(style);
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
102
18758
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
103 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
104 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
105 }
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
106
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
107 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
108 {
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
109 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
110 int i;
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
111
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
112 if (str)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
113 {
18758
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
114 if (g_ascii_strcasecmp(str, "false") == 0)
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
115 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
116 else if (g_ascii_strcasecmp(str, "true") == 0)
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
117 def = TRUE;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
118 else if (sscanf(str, "%d", &i) == 1)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
119 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
120 if (i)
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
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
123 def = FALSE;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
124 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
125 }
18758
57ca4b456815 Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18416
diff changeset
126 return def;
14072
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
15040
433e06134a7b [gaim-migrate @ 17757]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14962
diff changeset
129 static void
433e06134a7b [gaim-migrate @ 17757]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14962
diff changeset
130 refine(char *text)
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
131 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
132 char *s = text, *t = text;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
133
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
134 while (*s)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
135 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
136 if (*s == '^' && *(s + 1) == '[')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
137 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
138 *t = '\033'; /* escape */
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
139 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 else if (*s == '\\')
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 if (*(s + 1) == '\0')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
144 *t = ' ';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
145 else
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 s++;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
148 if (*s == 'r' || *s == 'n')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
149 *t = '\r';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
150 else if (*s == 't')
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
151 *t = '\t';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
152 else
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
153 *t = *s;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
154 }
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 else
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
157 *t = *s;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
158 t++;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
159 s++;
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 *t = '\0';
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
162 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
163
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
164 static char *
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
165 parse_key(const char *key)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
166 {
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
167 return (char *)gnt_key_translate(key);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
168 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
169
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
170 void gnt_style_read_workspaces(GntWM *wm)
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
171 {
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
172 int i;
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
173 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
174 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
175
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
176 for (i = 1; i < MAX_WORKSPACES; ++i) {
34306
4fb8809f2f97 Fix finch warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33649
diff changeset
177 gsize j;
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
178 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
179 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
180 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
181 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
182 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
183 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
184 return;
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
185
18138
4bbda12891c1 Update for the new api.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18132
diff changeset
186 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
187 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
188 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
189
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 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
191 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
192 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
193 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
194 g_strfreev(titles);
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
195 }
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
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-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
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->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
201 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
202 }
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
203 }
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16025
diff changeset
204 }
33649
1d643f401252 Remove old GLib version checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
205
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
206 void gnt_style_read_actions(GType type, GntBindableClass *klass)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
207 {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
208 char *name;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
209 GError *error = NULL;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
210
35480
8d853ab9225c Fix crash when scanning libgnt
Ankit Vani <a@nevitus.org>
parents: 35456
diff changeset
211 /* gkfile is NULL when run by gtkdoc-scanobj or g-ir-scanner */
8d853ab9225c Fix crash when scanning libgnt
Ankit Vani <a@nevitus.org>
parents: 35456
diff changeset
212 if (!gkfile)
8d853ab9225c Fix crash when scanning libgnt
Ankit Vani <a@nevitus.org>
parents: 35456
diff changeset
213 return;
8d853ab9225c Fix crash when scanning libgnt
Ankit Vani <a@nevitus.org>
parents: 35456
diff changeset
214
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
215 name = g_strdup_printf("%s::binding", g_type_name(type));
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
216
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
217 if (g_key_file_has_group(gkfile, name))
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
218 {
14901
4e524abde87a [gaim-migrate @ 17608]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14898
diff changeset
219 gsize len = 0;
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
220 char **keys;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 24822
diff changeset
221
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
222 keys = g_key_file_get_keys(gkfile, name, &len, &error);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
223 if (error)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
224 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
225 gnt_warning("%s", error->message);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
226 g_error_free(error);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
227 g_free(name);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
228 return;
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
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
231 while (len--)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
232 {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
233 char *key, *action;
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 key = g_strdup(keys[len]);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
236 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
237
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
238 if (error)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
239 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
240 gnt_warning("%s", error->message);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
241 g_error_free(error);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
242 error = NULL;
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 else
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
245 {
15862
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15367
diff changeset
246 const char *keycode = parse_key(key);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
247 if (keycode == NULL) {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
248 gnt_warning("Invalid key-binding %s", key);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
249 } else {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
250 gnt_bindable_register_binding(klass, action, keycode, NULL);
14855
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 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
253 g_free(key);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
254 g_free(action);
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 g_strfreev(keys);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
257 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
258 g_free(name);
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
20821
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
261 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
262 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
263 char *kname;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
264 GError *error = NULL;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
265 gboolean ret = FALSE;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
266
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
267 kname = g_strdup_printf("%s::menu", name);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
268
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
269 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
270 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
271 gsize len = 0;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
272 char **keys;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 24822
diff changeset
273
20821
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
274 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
275 if (error)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
276 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
277 gnt_warning("%s", error->message);
20821
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
278 g_error_free(error);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
279 g_free(kname);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
280 return ret;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
281 }
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 while (len--)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
284 {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
285 char *key, *menuid;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
286
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
287 key = g_strdup(keys[len]);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
288 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
289
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
290 if (error)
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
291 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
292 gnt_warning("%s", error->message);
20821
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
293 g_error_free(error);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
294 error = NULL;
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 else
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 const char *keycode = parse_key(key);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
299 if (keycode == NULL) {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
300 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
301 } else {
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
302 ret = TRUE;
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
303 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
304 menuid = 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 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
307 g_free(key);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
308 g_free(menuid);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
309 }
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
310 g_strfreev(keys);
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(kname);
51bd63176b50 Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20180
diff changeset
314 return ret;
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
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
317 void gnt_styles_get_keyremaps(GType type, GHashTable *hash)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
318 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
319 char *name;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
320 GError *error = NULL;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 24822
diff changeset
321
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
322 name = g_strdup_printf("%s::remap", g_type_name(type));
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
323
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
324 if (g_key_file_has_group(gkfile, name))
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
325 {
14901
4e524abde87a [gaim-migrate @ 17608]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14898
diff changeset
326 gsize len = 0;
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
327 char **keys;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 24822
diff changeset
328
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
329 keys = g_key_file_get_keys(gkfile, name, &len, &error);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
330 if (error)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
331 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
332 gnt_warning("%s", error->message);
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
333 g_error_free(error);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
334 g_free(name);
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
335 return;
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
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
338 while (len--)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
339 {
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
340 char *key, *replace;
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 key = g_strdup(keys[len]);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
343 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
344
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
345 if (error)
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
346 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
347 gnt_warning("%s", error->message);
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
348 g_error_free(error);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
349 error = NULL;
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
350 g_free(key);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
351 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
352 else
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 refine(key);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
355 refine(replace);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
356 g_hash_table_insert(hash, key, replace);
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 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
359 g_strfreev(keys);
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
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
362 g_free(name);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
363 }
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
364
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
365 static void
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
366 read_general_style(GKeyFile *kfile)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
367 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
368 GError *error = NULL;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
369 gsize nkeys;
18416
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
370 const char *prgname = g_get_prgname();
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
371 char **keys = NULL;
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
372 int i;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
373 struct
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
374 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
375 const char *style;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
376 GntStyle en;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
377 } styles[] = {{"shadow", GNT_STYLE_SHADOW},
14361
4d6014205744 [gaim-migrate @ 16989]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14301
diff changeset
378 {"customcolor", GNT_STYLE_COLOR},
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
379 {"mouse", GNT_STYLE_MOUSE},
14397
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14372
diff changeset
380 {"wm", GNT_STYLE_WM},
15129
4722d1cf7938 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15070
diff changeset
381 {"remember_position", GNT_STYLE_REMPOS},
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
382 {NULL, 0}};
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
383
18416
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
384 if (prgname && *prgname)
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
385 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
386
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
387 if (keys == NULL) {
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
388 prgname = "general";
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
389 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
390 }
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
391
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
392 if (error)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
393 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
394 gnt_warning("%s", error->message);
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
395 g_error_free(error);
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
396 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
397 else
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
398 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
399 for (i = 0; styles[i].style; i++)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
400 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
401 str_styles[styles[i].en] =
18416
d8882fe1983c Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18370
diff changeset
402 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
403 }
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_strfreev(keys);
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
406 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
407
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
408 void gnt_style_read_configure_file(const char *filename)
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
409 {
14901
4e524abde87a [gaim-migrate @ 17608]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14898
diff changeset
410 GError *error = NULL;
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
411 gkfile = g_key_file_new();
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
412
18361
740fec710f0a This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18164
diff changeset
413 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
414 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
415 {
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21893
diff changeset
416 gnt_warning("%s", error->message);
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
417 g_error_free(error);
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
418 return;
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
419 }
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
420 gnt_colors_parse(gkfile);
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
421 read_general_style(gkfile);
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
422 }
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
423
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
424 void gnt_init_styles()
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
425 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
426 int i;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
427 for (i = 0; i < GNT_STYLES; i++)
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
428 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
429 str_styles[i] = NULL;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
430 int_styles[i] = -1;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
431 bool_styles[i] = -1;
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
432 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
433 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
434
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
435 void gnt_uninit_styles()
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
436 {
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
437 int i;
21245
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
438 for (i = 0; i < GNT_STYLES; i++) {
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
439 g_free(str_styles[i]);
21245
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
440 str_styles[i] = NULL;
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
441 }
14301
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
442
b47bf28806d1 [gaim-migrate @ 16921]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14272
diff changeset
443 g_key_file_free(gkfile);
21245
e34058c353d0 Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20821
diff changeset
444 gkfile = NULL;
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
445 }
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
446

mercurial