Mercurial > pidgin
annotate console/libgnt/gntstyle.c @ 14876:70623f0d5cdc
[gaim-migrate @ 17645]
Use terminfo/termcap information (from ncurses) as much as possible. There
still need to be some manual 'refinement' based on $TERM. I'll see if I
can get rid of those. Also, I am probably going to allow users to provide
information that terminfo can't provide, like the keycode for ctrl+up etc.
Let me know if any of the keybinding doesn't work.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 01 Nov 2006 03:38:23 +0000 |
parents | 29c6bec37b96 |
children | 065e7ac30338 |
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 |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
49 void refine(char *text) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
50 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
51 char *s = text, *t = text; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
52 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
53 while (*s) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
54 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
55 if (*s == '^' && *(s + 1) == '[') |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
56 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
57 *t = '\033'; /* escape */ |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
58 s++; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
59 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
60 else if (*s == '\\') |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
61 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
62 if (*(s + 1) == '\0') |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
63 *t = ' '; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
64 else |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
65 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
66 s++; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
67 if (*s == 'r' || *s == 'n') |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
68 *t = '\r'; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
69 else if (*s == 't') |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
70 *t = '\t'; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
71 else |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
72 *t = *s; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
73 } |
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 else |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
76 *t = *s; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
77 t++; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
78 s++; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
79 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
80 *t = '\0'; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
81 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
82 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
83 static char * |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
84 parse_key(const char *key) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
85 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
86 char *ret = NULL; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
87 int ctrl = 0, alt = 0; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
88 char k; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
89 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
90 /* 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
|
91 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
92 #define SPECIAL_KEY(k, code) do { \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
93 if (strncasecmp(key, k, sizeof(k) - 1) == 0) \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
94 return g_strdup(code); \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
95 } while (0) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
96 |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
97 SPECIAL_KEY("home", GNT_KEY_HOME); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
98 SPECIAL_KEY("end", GNT_KEY_END); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
99 SPECIAL_KEY("pageup", GNT_KEY_PGUP); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
100 SPECIAL_KEY("pagedown", GNT_KEY_PGDOWN); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
101 SPECIAL_KEY("insert", GNT_KEY_INS); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
102 SPECIAL_KEY("delete", GNT_KEY_DEL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
103 |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
104 SPECIAL_KEY("left", GNT_KEY_LEFT); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
105 SPECIAL_KEY("right", GNT_KEY_RIGHT); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
106 SPECIAL_KEY("up", GNT_KEY_UP); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
107 SPECIAL_KEY("down", GNT_KEY_DOWN); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
108 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
109 SPECIAL_KEY("tab", "\t"); |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
110 SPECIAL_KEY("menu", GNT_KEY_POPUP); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
111 |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
112 SPECIAL_KEY("f1", GNT_KEY_F1); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
113 SPECIAL_KEY("f2", GNT_KEY_F2); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
114 SPECIAL_KEY("f3", GNT_KEY_F3); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
115 SPECIAL_KEY("f4", GNT_KEY_F4); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
116 SPECIAL_KEY("f5", GNT_KEY_F5); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
117 SPECIAL_KEY("f6", GNT_KEY_F6); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
118 SPECIAL_KEY("f7", GNT_KEY_F7); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
119 SPECIAL_KEY("f8", GNT_KEY_F8); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
120 SPECIAL_KEY("f9", GNT_KEY_F9); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
121 SPECIAL_KEY("f10", GNT_KEY_F10); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
122 SPECIAL_KEY("f11", GNT_KEY_F11); |
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14839
diff
changeset
|
123 SPECIAL_KEY("f12", GNT_KEY_F12); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
124 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
125 #undef SPECIAL_KEY |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
126 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
127 #define MATCH(string, var) do { \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
128 if (strncasecmp(key, string, sizeof(string) - 1) == 0) { \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
129 key += sizeof(string) - 1; \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
130 var = 1; \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
131 } \ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
132 }while (0) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
133 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
134 MATCH("c-", ctrl); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
135 MATCH("ctl-", ctrl); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
136 MATCH("ctr-", ctrl); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
137 MATCH("ctrl-", ctrl); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
138 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
139 MATCH("alt-", alt); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
140 MATCH("a-", alt); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
141 MATCH("m-", alt); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
142 MATCH("meta-", alt); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
143 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
144 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
|
145 return NULL; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
146 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
147 if (ctrl && (strchr("hijm", *key) != NULL || !isalpha(*key))) { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
148 /* These keys cannot be used with ctrl */ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
149 return NULL; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
150 } |
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 if (ctrl) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
153 k = *key | 0x20; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
154 else |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
155 k = *key; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
156 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
157 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
|
158 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
159 #undef MATCH |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
160 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
161 return ret; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
162 } |
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 void gnt_style_read_actions(GType type, GntWidgetClass *klass) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
165 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
166 #if GLIB_CHECK_VERSION(2,6,0) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
167 char *name; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
168 GError *error = NULL; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
169 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
170 name = g_strdup_printf("%s::binding", g_type_name(type)); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
171 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
172 if (g_key_file_has_group(gkfile, name)) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
173 { |
14839
29c6bec37b96
[gaim-migrate @ 17608]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14836
diff
changeset
|
174 gsize len = 0; |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
175 char **keys; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
176 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
177 keys = g_key_file_get_keys(gkfile, name, &len, &error); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
178 if (error) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
179 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
180 g_printerr("GntStyle: %s\n", error->message); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
181 g_error_free(error); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
182 g_free(name); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
183 return; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
184 } |
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 while (len--) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
187 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
188 char *key, *action; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
189 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
190 key = g_strdup(keys[len]); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
191 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
|
192 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
193 if (error) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
194 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
195 g_printerr("GntStyle: %s\n", error->message); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
196 g_error_free(error); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
197 error = NULL; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
198 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
199 else |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
200 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
201 char *keycode = parse_key(key); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
202 if (keycode == NULL) { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
203 g_printerr("GntStyle: Invalid key-binding %s\n", key); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
204 } else { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
205 gnt_widget_register_binding(klass, action, keycode, NULL); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
206 g_free(keycode); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
207 } |
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 g_free(key); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
210 g_free(action); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
211 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
212 g_strfreev(keys); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
213 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
214 g_free(name); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
215 #endif |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
216 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
217 |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
218 void gnt_styles_get_keyremaps(GType type, GHashTable *hash) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
219 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
220 #if GLIB_CHECK_VERSION(2,6,0) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
221 char *name; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
222 GError *error = NULL; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
223 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
224 name = g_strdup_printf("%s::remap", g_type_name(type)); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
225 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
226 if (g_key_file_has_group(gkfile, name)) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
227 { |
14839
29c6bec37b96
[gaim-migrate @ 17608]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14836
diff
changeset
|
228 gsize len = 0; |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
229 char **keys; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
230 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
231 keys = g_key_file_get_keys(gkfile, name, &len, &error); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
232 if (error) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
233 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
234 g_printerr("GntStyle: %s\n", error->message); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
235 g_error_free(error); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
236 g_free(name); |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
237 return; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
238 } |
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 while (len--) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
241 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
242 char *key, *replace; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
243 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
244 key = g_strdup(keys[len]); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
245 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
|
246 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
247 if (error) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
248 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
249 g_printerr("GntStyle: %s\n", error->message); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
250 g_error_free(error); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
251 error = NULL; |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
252 g_free(key); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
253 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
254 else |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
255 { |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
256 refine(key); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
257 refine(replace); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
258 g_hash_table_insert(hash, key, replace); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
259 } |
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 g_strfreev(keys); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
262 } |
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 g_free(name); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
265 #endif |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
266 } |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
267 |
14210
bb38f32ab6aa
[gaim-migrate @ 16888]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
268 #if GLIB_CHECK_VERSION(2,6,0) |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
269 static void |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
270 read_general_style(GKeyFile *kfile) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
271 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
272 GError *error = NULL; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
273 gsize nkeys; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
274 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
|
275 int i; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
276 struct |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
277 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
278 const char *style; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
279 GntStyle en; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
280 } styles[] = {{"shadow", GNT_STYLE_SHADOW}, |
14299
ea5193c23171
[gaim-migrate @ 16989]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14239
diff
changeset
|
281 {"customcolor", GNT_STYLE_COLOR}, |
14310
a766441af5ea
[gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14299
diff
changeset
|
282 {"mouse", GNT_STYLE_MOUSE}, |
14335
b1b76fb9c739
[gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14310
diff
changeset
|
283 {"wm", GNT_STYLE_WM}, |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
284 {NULL, 0}}; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
285 |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
286 if (error) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
287 { |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
288 g_printerr("GntStyle: %s\n", error->message); |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
289 g_error_free(error); |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
290 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
291 else |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
292 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
293 for (i = 0; styles[i].style; i++) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
294 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
295 error = NULL; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
296 str_styles[styles[i].en] = |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
297 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
|
298 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
299 } |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
300 g_strfreev(keys); |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
301 } |
14210
bb38f32ab6aa
[gaim-migrate @ 16888]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
302 #endif |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
303 |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
304 void gnt_style_read_configure_file(const char *filename) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
305 { |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
306 #if GLIB_CHECK_VERSION(2,6,0) |
14839
29c6bec37b96
[gaim-migrate @ 17608]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14836
diff
changeset
|
307 GError *error = NULL; |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
308 gkfile = g_key_file_new(); |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
309 |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
310 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
|
311 { |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
312 g_printerr("GntStyle: %s\n", error->message); |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
313 g_error_free(error); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
314 return; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
315 } |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
316 gnt_colors_parse(gkfile); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
317 read_general_style(gkfile); |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
318 #endif |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
319 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
320 |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
321 void gnt_init_styles() |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
322 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
323 int i; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
324 for (i = 0; i < GNT_STYLES; i++) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
325 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
326 str_styles[i] = NULL; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
327 int_styles[i] = -1; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
328 bool_styles[i] = -1; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
329 } |
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 void gnt_uninit_styles() |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
333 { |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
334 int i; |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
335 for (i = 0; i < GNT_STYLES; i++) |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
336 g_free(str_styles[i]); |
14239
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
337 |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
338 #if GLIB_CHECK_VERSION(2,6,0) |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
339 g_key_file_free(gkfile); |
a0b1ab181316
[gaim-migrate @ 16921]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
340 #endif |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
341 } |
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
342 |