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