Mercurial > pidgin
annotate finch/libgnt/gntstyle.c @ 21738:e3e64d1e4869
Add color to the conversation window to indicate various message attributes
author | Richard Nelson <wabz@pidgin.im> |
---|---|
date | Mon, 03 Dec 2007 07:01:32 +0000 |
parents | 3ed9b027479d |
children | 350c93aa44d3 |
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 |
19681
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 |
15817 | 23 #include "gntstyle.h" |
24 #include "gntcolors.h" | |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
25 #include "gntws.h" |
15817 | 26 |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
27 #include <glib.h> |
15817 | 28 #include <ctype.h> |
18085
afd96f97c50a
Get rid of a little compile error
Mark Doliner <mark@kingant.net>
parents:
18069
diff
changeset
|
29 #include <stdlib.h> |
15817 | 30 #include <string.h> |
31 | |
17703
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
17698
diff
changeset
|
32 #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:
17698
diff
changeset
|
33 |
15817 | 34 #if GLIB_CHECK_VERSION(2,6,0) |
35 static GKeyFile *gkfile; | |
36 #endif | |
37 | |
38 static char * str_styles[GNT_STYLES]; | |
39 static int int_styles[GNT_STYLES]; | |
40 static int bool_styles[GNT_STYLES]; | |
41 | |
42 const char *gnt_style_get(GntStyle style) | |
43 { | |
44 return str_styles[style]; | |
45 } | |
46 | |
18317
8aff2d3d6820
Plug a memory leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18312
diff
changeset
|
47 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
|
48 { |
18312
adcb44a07a2d
This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18091
diff
changeset
|
49 #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
|
50 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
|
51 if ((group == NULL || *group == '\0') && prg && |
18530
fbca9cd907a1
I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents:
18509
diff
changeset
|
52 g_key_file_has_group(gkfile, prg)) |
fbca9cd907a1
I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents:
18509
diff
changeset
|
53 group = prg; |
fbca9cd907a1
I think this is the intended behaviour
Richard Nelson <wabz@pidgin.im>
parents:
18509
diff
changeset
|
54 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
|
55 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
|
56 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
|
57 #else |
8d9913d9fe5a
Get rid of compile warnings on older glib.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18581
diff
changeset
|
58 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
|
59 #endif |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
60 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
61 |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
62 int |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
63 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
|
64 { |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
65 #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
|
66 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
|
67 gsize n; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
68 char **vals; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
69 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
|
70 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
|
71 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
|
72 bg = gnt_colors_get_color(vals[1]); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
73 return gnt_color_add_pair(fg, bg); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
74 } |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
75 return 0; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
76 #else |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
77 return 0; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
78 #endif |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
79 } |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21691
diff
changeset
|
80 |
21691
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21255
diff
changeset
|
81 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
|
82 { |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21255
diff
changeset
|
83 #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
|
84 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
|
85 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
|
86 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
|
87 group = prg; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21255
diff
changeset
|
88 if (!group) |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21255
diff
changeset
|
89 group = "general"; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21255
diff
changeset
|
90 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
|
91 #else |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21255
diff
changeset
|
92 return NULL; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21255
diff
changeset
|
93 #endif |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21255
diff
changeset
|
94 } |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21255
diff
changeset
|
95 |
15817 | 96 gboolean gnt_style_get_bool(GntStyle style, gboolean def) |
97 { | |
98 const char * str; | |
99 | |
100 if (bool_styles[style] != -1) | |
101 return bool_styles[style]; | |
102 | |
103 str = gnt_style_get(style); | |
104 | |
18506
9f029b7208f1
Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18362
diff
changeset
|
105 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
|
106 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
|
107 } |
9f029b7208f1
Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18362
diff
changeset
|
108 |
9f029b7208f1
Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18362
diff
changeset
|
109 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
|
110 { |
9f029b7208f1
Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18362
diff
changeset
|
111 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
|
112 int i; |
9f029b7208f1
Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18362
diff
changeset
|
113 |
15817 | 114 if (str) |
115 { | |
18506
9f029b7208f1
Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18362
diff
changeset
|
116 if (g_ascii_strcasecmp(str, "false") == 0) |
15817 | 117 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
|
118 else if (g_ascii_strcasecmp(str, "true") == 0) |
15817 | 119 def = TRUE; |
120 else if (sscanf(str, "%d", &i) == 1) | |
121 { | |
122 if (i) | |
123 def = TRUE; | |
124 else | |
125 def = FALSE; | |
126 } | |
127 } | |
18506
9f029b7208f1
Allow one-line high buttons. Specify 'small-button = true' under 'general',
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18362
diff
changeset
|
128 return def; |
15817 | 129 } |
130 | |
19381
8d9913d9fe5a
Get rid of compile warnings on older glib.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18581
diff
changeset
|
131 #if GLIB_CHECK_VERSION(2,6,0) |
15817 | 132 static void |
133 refine(char *text) | |
134 { | |
135 char *s = text, *t = text; | |
136 | |
137 while (*s) | |
138 { | |
139 if (*s == '^' && *(s + 1) == '[') | |
140 { | |
141 *t = '\033'; /* escape */ | |
142 s++; | |
143 } | |
144 else if (*s == '\\') | |
145 { | |
146 if (*(s + 1) == '\0') | |
147 *t = ' '; | |
148 else | |
149 { | |
150 s++; | |
151 if (*s == 'r' || *s == 'n') | |
152 *t = '\r'; | |
153 else if (*s == 't') | |
154 *t = '\t'; | |
155 else | |
156 *t = *s; | |
157 } | |
158 } | |
159 else | |
160 *t = *s; | |
161 t++; | |
162 s++; | |
163 } | |
164 *t = '\0'; | |
165 } | |
166 | |
167 static char * | |
168 parse_key(const char *key) | |
169 { | |
170 return (char *)gnt_key_translate(key); | |
171 } | |
19381
8d9913d9fe5a
Get rid of compile warnings on older glib.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18581
diff
changeset
|
172 #endif |
15817 | 173 |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
174 void gnt_style_read_workspaces(GntWM *wm) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
175 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
176 #if GLIB_CHECK_VERSION(2,6,0) |
17703
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
17698
diff
changeset
|
177 int i; |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
178 gchar *name; |
17704
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:
17703
diff
changeset
|
179 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:
17703
diff
changeset
|
180 |
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:
17703
diff
changeset
|
181 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:
17703
diff
changeset
|
182 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:
17703
diff
changeset
|
183 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:
17703
diff
changeset
|
184 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
|
185 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
|
186 g_snprintf(group, sizeof(group), "Workspace-%d", i); |
17704
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:
17703
diff
changeset
|
187 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:
17703
diff
changeset
|
188 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:
17703
diff
changeset
|
189 return; |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
190 |
18076
da183b86a3ef
Update for the new api.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18069
diff
changeset
|
191 ws = gnt_ws_new(name); |
17704
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:
17703
diff
changeset
|
192 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:
17703
diff
changeset
|
193 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:
17703
diff
changeset
|
194 |
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:
17703
diff
changeset
|
195 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:
17703
diff
changeset
|
196 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:
17703
diff
changeset
|
197 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:
17703
diff
changeset
|
198 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:
17703
diff
changeset
|
199 g_strfreev(titles); |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
200 } |
17704
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:
17703
diff
changeset
|
201 |
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:
17703
diff
changeset
|
202 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:
17703
diff
changeset
|
203 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:
17703
diff
changeset
|
204 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:
17703
diff
changeset
|
205 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:
17703
diff
changeset
|
206 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:
17703
diff
changeset
|
207 } |
17698
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
208 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
209 #endif |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
15964
diff
changeset
|
210 } |
15817 | 211 void gnt_style_read_actions(GType type, GntBindableClass *klass) |
212 { | |
213 #if GLIB_CHECK_VERSION(2,6,0) | |
214 char *name; | |
215 GError *error = NULL; | |
216 | |
217 name = g_strdup_printf("%s::binding", g_type_name(type)); | |
218 | |
219 if (g_key_file_has_group(gkfile, name)) | |
220 { | |
221 gsize len = 0; | |
222 char **keys; | |
223 | |
224 keys = g_key_file_get_keys(gkfile, name, &len, &error); | |
225 if (error) | |
226 { | |
227 g_printerr("GntStyle: %s\n", error->message); | |
228 g_error_free(error); | |
229 g_free(name); | |
230 return; | |
231 } | |
232 | |
233 while (len--) | |
234 { | |
235 char *key, *action; | |
236 | |
237 key = g_strdup(keys[len]); | |
238 action = g_key_file_get_string(gkfile, name, keys[len], &error); | |
239 | |
240 if (error) | |
241 { | |
242 g_printerr("GntStyle: %s\n", error->message); | |
243 g_error_free(error); | |
244 error = NULL; | |
245 } | |
246 else | |
247 { | |
248 const char *keycode = parse_key(key); | |
249 if (keycode == NULL) { | |
250 g_printerr("GntStyle: Invalid key-binding %s\n", key); | |
251 } else { | |
252 gnt_bindable_register_binding(klass, action, keycode, NULL); | |
253 } | |
254 } | |
255 g_free(key); | |
256 g_free(action); | |
257 } | |
258 g_strfreev(keys); | |
259 } | |
260 g_free(name); | |
261 #endif | |
262 } | |
263 | |
21212
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
264 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
|
265 { |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
266 #if GLIB_CHECK_VERSION(2,6,0) |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
267 char *kname; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
268 GError *error = NULL; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
269 gboolean ret = FALSE; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
270 |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
271 kname = g_strdup_printf("%s::menu", name); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
272 |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
273 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
|
274 { |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
275 gsize len = 0; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
276 char **keys; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
277 |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
278 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
|
279 if (error) |
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 g_printerr("GntStyle: %s\n", error->message); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
282 g_error_free(error); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
283 g_free(kname); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
284 return ret; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
285 } |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
286 |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
287 while (len--) |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
288 { |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
289 char *key, *menuid; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
290 |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
291 key = g_strdup(keys[len]); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
292 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
|
293 |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
294 if (error) |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
295 { |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
296 g_printerr("GntStyle: %s\n", error->message); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
297 g_error_free(error); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
298 error = NULL; |
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 else |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
301 { |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
302 const char *keycode = parse_key(key); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
303 if (keycode == NULL) { |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
304 g_printerr("GntStyle: Invalid key-binding %s\n", key); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
305 } else { |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
306 ret = TRUE; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
307 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
|
308 menuid = NULL; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
309 } |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
310 } |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
311 g_free(key); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
312 g_free(menuid); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
313 } |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
314 g_strfreev(keys); |
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(kname); |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
318 return ret; |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
319 #endif |
b65f1bff6412
Allow binding key-shortcuts to menuitems.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20289
diff
changeset
|
320 return FALSE; |
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 |
15817 | 323 void gnt_styles_get_keyremaps(GType type, GHashTable *hash) |
324 { | |
325 #if GLIB_CHECK_VERSION(2,6,0) | |
326 char *name; | |
327 GError *error = NULL; | |
328 | |
329 name = g_strdup_printf("%s::remap", g_type_name(type)); | |
330 | |
331 if (g_key_file_has_group(gkfile, name)) | |
332 { | |
333 gsize len = 0; | |
334 char **keys; | |
335 | |
336 keys = g_key_file_get_keys(gkfile, name, &len, &error); | |
337 if (error) | |
338 { | |
339 g_printerr("GntStyle: %s\n", error->message); | |
340 g_error_free(error); | |
341 g_free(name); | |
342 return; | |
343 } | |
344 | |
345 while (len--) | |
346 { | |
347 char *key, *replace; | |
348 | |
349 key = g_strdup(keys[len]); | |
350 replace = g_key_file_get_string(gkfile, name, keys[len], &error); | |
351 | |
352 if (error) | |
353 { | |
354 g_printerr("GntStyle: %s\n", error->message); | |
355 g_error_free(error); | |
356 error = NULL; | |
357 g_free(key); | |
358 } | |
359 else | |
360 { | |
361 refine(key); | |
362 refine(replace); | |
363 g_hash_table_insert(hash, key, replace); | |
364 } | |
365 } | |
366 g_strfreev(keys); | |
367 } | |
368 | |
369 g_free(name); | |
370 #endif | |
371 } | |
372 | |
373 #if GLIB_CHECK_VERSION(2,6,0) | |
374 static void | |
375 read_general_style(GKeyFile *kfile) | |
376 { | |
377 GError *error = NULL; | |
378 gsize nkeys; | |
18362
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
379 const char *prgname = g_get_prgname(); |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
380 char **keys = NULL; |
15817 | 381 int i; |
382 struct | |
383 { | |
384 const char *style; | |
385 GntStyle en; | |
386 } styles[] = {{"shadow", GNT_STYLE_SHADOW}, | |
387 {"customcolor", GNT_STYLE_COLOR}, | |
388 {"mouse", GNT_STYLE_MOUSE}, | |
389 {"wm", GNT_STYLE_WM}, | |
390 {"remember_position", GNT_STYLE_REMPOS}, | |
391 {NULL, 0}}; | |
392 | |
18362
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
393 if (prgname && *prgname) |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
394 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
|
395 |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
396 if (keys == NULL) { |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
397 prgname = "general"; |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
398 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
|
399 } |
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
400 |
15817 | 401 if (error) |
402 { | |
403 g_printerr("GntStyle: %s\n", error->message); | |
404 g_error_free(error); | |
405 } | |
406 else | |
407 { | |
408 for (i = 0; styles[i].style; i++) | |
409 { | |
410 str_styles[styles[i].en] = | |
18362
65ed0916d3bc
Allowing specifying different styles for different applications.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18317
diff
changeset
|
411 g_key_file_get_string(kfile, prgname, styles[i].style, NULL); |
15817 | 412 } |
413 } | |
414 g_strfreev(keys); | |
415 } | |
416 #endif | |
417 | |
418 void gnt_style_read_configure_file(const char *filename) | |
419 { | |
420 #if GLIB_CHECK_VERSION(2,6,0) | |
421 GError *error = NULL; | |
422 gkfile = g_key_file_new(); | |
423 | |
18312
adcb44a07a2d
This is a more flexible way of getting random settings from .gntrc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18091
diff
changeset
|
424 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
|
425 G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) |
15817 | 426 { |
427 g_printerr("GntStyle: %s\n", error->message); | |
428 g_error_free(error); | |
429 return; | |
430 } | |
431 gnt_colors_parse(gkfile); | |
432 read_general_style(gkfile); | |
433 #endif | |
434 } | |
435 | |
436 void gnt_init_styles() | |
437 { | |
438 int i; | |
439 for (i = 0; i < GNT_STYLES; i++) | |
440 { | |
441 str_styles[i] = NULL; | |
442 int_styles[i] = -1; | |
443 bool_styles[i] = -1; | |
444 } | |
445 } | |
446 | |
447 void gnt_uninit_styles() | |
448 { | |
449 int i; | |
21255
430fd445a053
Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
450 for (i = 0; i < GNT_STYLES; i++) { |
15817 | 451 g_free(str_styles[i]); |
21255
430fd445a053
Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
452 str_styles[i] = NULL; |
430fd445a053
Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
453 } |
15817 | 454 |
455 #if GLIB_CHECK_VERSION(2,6,0) | |
456 g_key_file_free(gkfile); | |
21255
430fd445a053
Prevent occasional crashes on quit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21212
diff
changeset
|
457 gkfile = NULL; |
15817 | 458 #endif |
459 } | |
460 |