Mercurial > pidgin
annotate console/libgnt/gntcolors.c @ 14256:e7de1f6d9f35
[gaim-migrate @ 16938]
Mostly minor cleanups
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 21 Aug 2006 03:40:12 +0000 |
parents | bb38f32ab6aa |
children | ea5193c23171 |
rev | line source |
---|---|
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include <ncursesw/ncurses.h> |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 #include "gntcolors.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
4 #include <glib.h> |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
5 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
6 #include <stdlib.h> |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
7 #include <string.h> |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
8 |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
9 static struct |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
10 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
11 short r, g, b; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
12 } colors[GNT_TOTAL_COLORS]; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
13 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
14 static void |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
15 backup_colors() |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
16 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
17 short i; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
18 for (i = 0; i < GNT_TOTAL_COLORS; i++) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
19 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
20 color_content(i, &colors[i].r, |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
21 &colors[i].g, &colors[i].b); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
22 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
23 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
24 |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
25 static void |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
26 restore_colors() |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
27 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
28 short i; |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
29 for (i = 0; i < GNT_TOTAL_COLORS; i++) |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
30 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
31 init_color(i, colors[i].r, |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
32 colors[i].g, colors[i].b); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
33 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
34 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
35 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 void gnt_init_colors() |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 { |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
38 start_color(); |
13851
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
39 if (can_change_color()) |
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
40 { |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
41 backup_colors(); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
42 |
14256
e7de1f6d9f35
[gaim-migrate @ 16938]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
43 /* Do some init_color()s */ |
13851
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
44 init_color(GNT_COLOR_BLACK, 0, 0, 0); |
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
45 init_color(GNT_COLOR_RED, 1000, 0, 0); |
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
46 init_color(GNT_COLOR_GREEN, 0, 1000, 0); |
13897
eaaf73de9188
[gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
47 init_color(GNT_COLOR_BLUE, 250, 250, 700); |
13851
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
48 init_color(GNT_COLOR_WHITE, 1000, 1000, 1000); |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13882
diff
changeset
|
49 init_color(GNT_COLOR_GRAY, 699, 699, 699); |
13851
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
50 init_color(GNT_COLOR_DARK_GRAY, 256, 256, 256); |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 |
13851
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
52 /* Now some init_pair()s */ |
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
53 init_pair(GNT_COLOR_NORMAL, GNT_COLOR_BLACK, GNT_COLOR_WHITE); |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13882
diff
changeset
|
54 init_pair(GNT_COLOR_HIGHLIGHT, GNT_COLOR_WHITE, GNT_COLOR_BLUE); |
13851
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
55 init_pair(GNT_COLOR_SHADOW, GNT_COLOR_BLACK, GNT_COLOR_DARK_GRAY); |
13897
eaaf73de9188
[gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
56 |
eaaf73de9188
[gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
57 init_pair(GNT_COLOR_TITLE, GNT_COLOR_WHITE, GNT_COLOR_BLUE); |
eaaf73de9188
[gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
58 init_pair(GNT_COLOR_TITLE_D, GNT_COLOR_WHITE, GNT_COLOR_GRAY); |
eaaf73de9188
[gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
59 |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13882
diff
changeset
|
60 init_pair(GNT_COLOR_TEXT_NORMAL, GNT_COLOR_WHITE, GNT_COLOR_BLUE); |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13855
diff
changeset
|
61 init_pair(GNT_COLOR_HIGHLIGHT_D, GNT_COLOR_BLACK, GNT_COLOR_GRAY); |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13882
diff
changeset
|
62 init_pair(GNT_COLOR_DISABLED, GNT_COLOR_GRAY, GNT_COLOR_WHITE); |
13851
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
63 } |
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
64 else |
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
65 { |
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
66 init_pair(GNT_COLOR_NORMAL, COLOR_BLACK, COLOR_WHITE); |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13897
diff
changeset
|
67 init_pair(GNT_COLOR_HIGHLIGHT, COLOR_WHITE, COLOR_BLUE); |
13851
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
68 init_pair(GNT_COLOR_SHADOW, COLOR_BLACK, COLOR_BLACK); |
13911
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13897
diff
changeset
|
69 init_pair(GNT_COLOR_TITLE, COLOR_WHITE, COLOR_BLUE); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13897
diff
changeset
|
70 init_pair(GNT_COLOR_TITLE_D, COLOR_WHITE, COLOR_BLACK); |
b210409cdc56
[gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13897
diff
changeset
|
71 init_pair(GNT_COLOR_TEXT_NORMAL, COLOR_WHITE, COLOR_BLUE); |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13855
diff
changeset
|
72 init_pair(GNT_COLOR_HIGHLIGHT_D, COLOR_CYAN, COLOR_BLACK); |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13882
diff
changeset
|
73 init_pair(GNT_COLOR_DISABLED, COLOR_YELLOW, COLOR_WHITE); |
13851
41753203a94d
[gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13850
diff
changeset
|
74 } |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 |
13964
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
77 void |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
78 gnt_uninit_colors() |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
79 { |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
80 restore_colors(); |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
81 } |
0a0d2a1fd2bc
[gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13911
diff
changeset
|
82 |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
83 static int |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
84 get_color(char *key) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
85 { |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
86 int color; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
87 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
88 key = g_strstrip(key); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
89 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
90 if (strcmp(key, "black") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
91 color = GNT_COLOR_BLACK; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
92 else if (strcmp(key, "red") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
93 color = GNT_COLOR_RED; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
94 else if (strcmp(key, "green") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
95 color = GNT_COLOR_GREEN; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
96 else if (strcmp(key, "blue") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
97 color = GNT_COLOR_BLUE; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
98 else if (strcmp(key, "white") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
99 color = GNT_COLOR_WHITE; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
100 else if (strcmp(key, "gray") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
101 color = GNT_COLOR_GRAY; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
102 else if (strcmp(key, "darkgray") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
103 color = GNT_COLOR_DARK_GRAY; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
104 else |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
105 color = -1; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
106 return color; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
107 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
108 |
14210
bb38f32ab6aa
[gaim-migrate @ 16888]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
109 #if GLIB_CHECK_VERSION(2,6,0) |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
110 void gnt_colors_parse(GKeyFile *kfile) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
111 { |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
112 GError *error = NULL; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
113 gsize nkeys; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
114 char **keys = g_key_file_get_keys(kfile, "colors", &nkeys, &error); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
115 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
116 if (error) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
117 { |
14256
e7de1f6d9f35
[gaim-migrate @ 16938]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
118 g_printerr("GntColors: %s\n", error->message); |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
119 g_error_free(error); |
14256
e7de1f6d9f35
[gaim-migrate @ 16938]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
120 error = NULL; |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
121 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
122 else |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
123 { |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
124 while (nkeys--) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
125 { |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
126 gsize len; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
127 char *key = keys[nkeys]; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
128 char **list = g_key_file_get_string_list(kfile, "colors", key, &len, NULL); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
129 if (len == 3) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
130 { |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
131 int r = atoi(list[0]); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
132 int g = atoi(list[1]); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
133 int b = atoi(list[2]); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
134 int color = -1; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
135 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
136 g_ascii_strdown(key, -1); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
137 color = get_color(key); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
138 if (color == -1) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
139 continue; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
140 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
141 init_color(color, r, g, b); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
142 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
143 g_strfreev(list); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
144 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
145 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
146 g_strfreev(keys); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
147 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
148 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
149 gnt_color_pairs_parse(kfile); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
150 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
151 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
152 void gnt_color_pairs_parse(GKeyFile *kfile) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
153 { |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
154 GError *error = NULL; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
155 gsize nkeys; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
156 char **keys = g_key_file_get_keys(kfile, "colorpairs", &nkeys, &error); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
157 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
158 if (error) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
159 { |
14256
e7de1f6d9f35
[gaim-migrate @ 16938]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14210
diff
changeset
|
160 g_printerr("GntColors: %s\n", error->message); |
14004
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
161 g_error_free(error); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
162 return; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
163 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
164 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
165 while (nkeys--) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
166 { |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
167 gsize len; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
168 char *key = keys[nkeys]; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
169 char **list = g_key_file_get_string_list(kfile, "colorpairs", key, &len, NULL); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
170 if (len == 2) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
171 { |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
172 GntColorType type = 0; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
173 int fg = get_color(g_ascii_strdown(list[0], -1)); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
174 int bg = get_color(g_ascii_strdown(list[1], -1)); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
175 if (fg == -1 || bg == -1) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
176 continue; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
177 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
178 g_ascii_strdown(key, -1); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
179 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
180 if (strcmp(key, "normal") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
181 type = GNT_COLOR_NORMAL; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
182 else if (strcmp(key, "highlight") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
183 type = GNT_COLOR_HIGHLIGHT; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
184 else if (strcmp(key, "highlightd") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
185 type = GNT_COLOR_HIGHLIGHT_D; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
186 else if (strcmp(key, "shadow") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
187 type = GNT_COLOR_SHADOW; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
188 else if (strcmp(key, "title") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
189 type = GNT_COLOR_TITLE; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
190 else if (strcmp(key, "titled") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
191 type = GNT_COLOR_TITLE_D; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
192 else if (strcmp(key, "text") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
193 type = GNT_COLOR_TEXT_NORMAL; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
194 else if (strcmp(key, "disabled") == 0) |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
195 type = GNT_COLOR_DISABLED; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
196 else |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
197 continue; |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
198 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
199 init_pair(type, fg, bg); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
200 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
201 g_strfreev(list); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
202 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
203 |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
204 g_strfreev(keys); |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
205 } |
06f75fb84a78
[gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13964
diff
changeset
|
206 |
14210
bb38f32ab6aa
[gaim-migrate @ 16888]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14004
diff
changeset
|
207 #endif /* GKeyFile */ |