Mercurial > pidgin.yaz
annotate console/libgnt/gntstyle.c @ 15009:7589733ba1aa
[gaim-migrate @ 17789]
F10 to show the menu of a window. F11 to show the context-menu. I would've used
shift+F10 if terminfo permitted.
Fix a bug where F10 etc. could not be used for rebinding.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 20 Nov 2006 04:05:33 +0000 |
parents | f719225f988e |
children | d08d7b7375c7 |
rev | line source |
---|---|
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include "gntstyle.h" |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 #include "gntcolors.h" |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 |
14836
bfcdd361357e
[gaim-migrate @ 17605]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14793
diff
changeset
|
4 #include <ctype.h> |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
5 #include <string.h> |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
6 |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
7 #if GLIB_CHECK_VERSION(2,6,0) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
8 static GKeyFile *gkfile; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
9 #endif |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
10 |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
11 static char * str_styles[GNT_STYLES]; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
12 static int int_styles[GNT_STYLES]; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
13 static int bool_styles[GNT_STYLES]; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
14 |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
15 const char *gnt_style_get(GntStyle style) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
16 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
17 return str_styles[style]; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
18 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
19 |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
20 gboolean gnt_style_get_bool(GntStyle style, gboolean def) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
21 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
22 int i; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
23 const char * str; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
24 |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
25 if (bool_styles[style] != -1) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
26 return bool_styles[style]; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
27 |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
28 str = gnt_style_get(style); |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
29 |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
30 if (str) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
31 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
32 if (strcmp(str, "false") == 0) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
33 def = FALSE; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
34 else if (strcmp(str, "true") == 0) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
35 def = TRUE; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
36 else if (sscanf(str, "%d", &i) == 1) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
37 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
38 if (i) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
39 def = TRUE; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
40 else |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
41 def = FALSE; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
42 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
43 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
44 |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
45 bool_styles[style] = def; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
46 return bool_styles[style]; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
47 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
48 |
14979
f719225f988e
[gaim-migrate @ 17757]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14900
diff
changeset
|
49 static void |
f719225f988e
[gaim-migrate @ 17757]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14900
diff
changeset
|
50 refine(char *text) |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
51 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
52 char *s = text, *t = text; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
53 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
54 while (*s) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
55 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
56 if (*s == '^' && *(s + 1) == '[') |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
57 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
58 *t = '\033'; /* escape */ |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
59 s++; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
60 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
61 else if (*s == '\\') |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
62 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
63 if (*(s + 1) == '\0') |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
64 *t = ' '; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
65 else |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
66 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
67 s++; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
68 if (*s == 'r' || *s == 'n') |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
69 *t = '\r'; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
70 else if (*s == 't') |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
71 *t = '\t'; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
72 else |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
73 *t = *s; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
74 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
75 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
76 else |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
77 *t = *s; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
78 t++; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
79 s++; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
80 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
81 *t = '\0'; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
82 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
83 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
84 static char * |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
85 parse_key(const char *key) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
86 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
87 char *ret = NULL; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
88 int ctrl = 0, alt = 0; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
89 char k; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
90 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
91 /* XXX: Need to do something about ctrl/alt+home, end etc. */ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
92 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
93 #define SPECIAL_KEY(k, code) do { \ |
15009
7589733ba1aa
[gaim-migrate @ 17789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14979
diff
changeset
|
94 if (strcasecmp(key, k) == 0) \ |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
95 return g_strdup(code); \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
96 } while (0) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
97 |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
98 SPECIAL_KEY("home", GNT_KEY_HOME); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
99 SPECIAL_KEY("end", GNT_KEY_END); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
100 SPECIAL_KEY("pageup", GNT_KEY_PGUP); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
101 SPECIAL_KEY("pagedown", GNT_KEY_PGDOWN); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
102 SPECIAL_KEY("insert", GNT_KEY_INS); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
103 SPECIAL_KEY("delete", GNT_KEY_DEL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
104 |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
105 SPECIAL_KEY("left", GNT_KEY_LEFT); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
106 SPECIAL_KEY("right", GNT_KEY_RIGHT); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
107 SPECIAL_KEY("up", GNT_KEY_UP); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
108 SPECIAL_KEY("down", GNT_KEY_DOWN); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
109 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
110 SPECIAL_KEY("tab", "\t"); |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
111 SPECIAL_KEY("menu", GNT_KEY_POPUP); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
112 |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
113 SPECIAL_KEY("f1", GNT_KEY_F1); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
114 SPECIAL_KEY("f2", GNT_KEY_F2); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
115 SPECIAL_KEY("f3", GNT_KEY_F3); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
116 SPECIAL_KEY("f4", GNT_KEY_F4); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
117 SPECIAL_KEY("f5", GNT_KEY_F5); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
118 SPECIAL_KEY("f6", GNT_KEY_F6); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
119 SPECIAL_KEY("f7", GNT_KEY_F7); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
120 SPECIAL_KEY("f8", GNT_KEY_F8); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
121 SPECIAL_KEY("f9", GNT_KEY_F9); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
122 SPECIAL_KEY("f10", GNT_KEY_F10); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
123 SPECIAL_KEY("f11", GNT_KEY_F11); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
124 SPECIAL_KEY("f12", GNT_KEY_F12); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
125 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
126 #undef SPECIAL_KEY |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
127 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
128 #define MATCH(string, var) do { \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
129 if (strncasecmp(key, string, sizeof(string) - 1) == 0) { \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
130 key += sizeof(string) - 1; \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
131 var = 1; \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
132 } \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
133 }while (0) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
134 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
135 MATCH("c-", ctrl); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
136 MATCH("ctl-", ctrl); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
137 MATCH("ctr-", ctrl); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
138 MATCH("ctrl-", ctrl); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
139 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
140 MATCH("alt-", alt); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
141 MATCH("a-", alt); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
142 MATCH("m-", alt); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
143 MATCH("meta-", alt); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
144 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
145 if (strlen(key) != 1) /* We can only have stuff like "ctrl-alt-a" */ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
146 return NULL; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
147 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
148 if (ctrl && (strchr("hijm", *key) != NULL || !isalpha(*key))) { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
149 /* These keys cannot be used with ctrl */ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
150 return NULL; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
151 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
152 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
153 if (ctrl) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
154 k = *key | 0x20; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
155 else |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
156 k = *key; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
157 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
158 ret = g_strdup_printf("%s%c", alt ? "\033" : "", ctrl ? k - 0x60 : k); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
159 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
160 #undef MATCH |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
161 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
162 return ret; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
163 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
164 |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
165 void gnt_style_read_actions(GType type, GntBindableClass *klass) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
166 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
167 #if GLIB_CHECK_VERSION(2,6,0) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
168 char *name; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
169 GError *error = NULL; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
170 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
171 name = g_strdup_printf("%s::binding", g_type_name(type)); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
172 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
173 if (g_key_file_has_group(gkfile, name)) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
174 { |
14839
29c6bec37b96
[gaim-migrate @ 17608]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14836
diff
changeset
|
175 gsize len = 0; |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
176 char **keys; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
177 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
178 keys = g_key_file_get_keys(gkfile, name, &len, &error); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
179 if (error) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
180 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
181 g_printerr("GntStyle: %s\n", error->message); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
182 g_error_free(error); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
183 g_free(name); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
184 return; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
185 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
186 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
187 while (len--) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
188 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
189 char *key, *action; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
190 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
191 key = g_strdup(keys[len]); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
192 action = g_key_file_get_string(gkfile, name, keys[len], &error); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
193 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
194 if (error) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
195 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
196 g_printerr("GntStyle: %s\n", error->message); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
197 g_error_free(error); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
198 error = NULL; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
199 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
200 else |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
201 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
202 char *keycode = parse_key(key); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
203 if (keycode == NULL) { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
204 g_printerr("GntStyle: Invalid key-binding %s\n", key); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
205 } else { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
206 gnt_bindable_register_binding(klass, action, keycode, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
207 g_free(keycode); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
208 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
209 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
210 g_free(key); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
211 g_free(action); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
212 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
213 g_strfreev(keys); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
214 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
215 g_free(name); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
216 #endif |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
217 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
218 |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
219 void gnt_styles_get_keyremaps(GType type, GHashTable *hash) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
220 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
221 #if GLIB_CHECK_VERSION(2,6,0) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
222 char *name; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
223 GError *error = NULL; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
224 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
225 name = g_strdup_printf("%s::remap", g_type_name(type)); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
226 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
227 if (g_key_file_has_group(gkfile, name)) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
228 { |
14839
29c6bec37b96
[gaim-migrate @ 17608]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14836
diff
changeset
|
229 gsize len = 0; |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
230 char **keys; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
231 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
232 keys = g_key_file_get_keys(gkfile, name, &len, &error); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
233 if (error) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
234 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
235 g_printerr("GntStyle: %s\n", error->message); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
236 g_error_free(error); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
237 g_free(name); |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
238 return; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
239 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
240 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
241 while (len--) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
242 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
243 char *key, *replace; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
244 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
245 key = g_strdup(keys[len]); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
246 replace = g_key_file_get_string(gkfile, name, keys[len], &error); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
247 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
248 if (error) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
249 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
250 g_printerr("GntStyle: %s\n", error->message); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
251 g_error_free(error); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
252 error = NULL; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
253 g_free(key); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
254 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
255 else |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
256 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
257 refine(key); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
258 refine(replace); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
259 g_hash_table_insert(hash, key, replace); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
260 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
261 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
262 g_strfreev(keys); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
263 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
264 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
265 g_free(name); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
266 #endif |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
267 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
268 |
14210
bb38f32ab6aa
[gaim-migrate @ 16888]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
269 #if GLIB_CHECK_VERSION(2,6,0) |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
270 static void |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
271 read_general_style(GKeyFile *kfile) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
272 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
273 GError *error = NULL; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
274 gsize nkeys; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
275 char **keys = g_key_file_get_keys(kfile, "general", &nkeys, &error); |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
276 int i; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
277 struct |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
278 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
279 const char *style; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
280 GntStyle en; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
281 } styles[] = {{"shadow", GNT_STYLE_SHADOW}, |
14299
ea5193c23171
[gaim-migrate @ 16989]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14239
diff
changeset
|
282 {"customcolor", GNT_STYLE_COLOR}, |
14310
a766441af5ea
[gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14299
diff
changeset
|
283 {"mouse", GNT_STYLE_MOUSE}, |
14335
b1b76fb9c739
[gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14310
diff
changeset
|
284 {"wm", GNT_STYLE_WM}, |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
285 {NULL, 0}}; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
286 |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
287 if (error) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
288 { |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
289 g_printerr("GntStyle: %s\n", error->message); |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
290 g_error_free(error); |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
291 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
292 else |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
293 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
294 for (i = 0; styles[i].style; i++) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
295 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
296 error = NULL; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
297 str_styles[styles[i].en] = |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
298 g_key_file_get_string(kfile, "general", styles[i].style, &error); |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
299 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
300 } |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
301 g_strfreev(keys); |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
302 } |
14210
bb38f32ab6aa
[gaim-migrate @ 16888]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
303 #endif |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
304 |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
305 void gnt_style_read_configure_file(const char *filename) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
306 { |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
307 #if GLIB_CHECK_VERSION(2,6,0) |
14839
29c6bec37b96
[gaim-migrate @ 17608]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14836
diff
changeset
|
308 GError *error = NULL; |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
309 gkfile = g_key_file_new(); |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
310 |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
311 if (!g_key_file_load_from_file(gkfile, filename, G_KEY_FILE_NONE, &error)) |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
312 { |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
313 g_printerr("GntStyle: %s\n", error->message); |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
314 g_error_free(error); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
315 return; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
316 } |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
317 gnt_colors_parse(gkfile); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
318 read_general_style(gkfile); |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
319 #endif |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
320 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
321 |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
322 void gnt_init_styles() |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
323 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
324 int i; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
325 for (i = 0; i < GNT_STYLES; i++) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
326 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
327 str_styles[i] = NULL; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
328 int_styles[i] = -1; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
329 bool_styles[i] = -1; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
330 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
331 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
332 |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
333 void gnt_uninit_styles() |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
334 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
335 int i; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
336 for (i = 0; i < GNT_STYLES; i++) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
337 g_free(str_styles[i]); |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
338 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
339 #if GLIB_CHECK_VERSION(2,6,0) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
340 g_key_file_free(gkfile); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
341 #endif |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
342 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
343 |