annotate console/libgnt/gntcolors.c @ 14537:f915d073868f

[gaim-migrate @ 17258] Unless I'm missing something, VERSION.in isn't used at all anymore committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 12 Sep 2006 04:52:55 +0000
parents f3645fe3da47
children 444b7ee76492
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14421
553bbd68387e [gaim-migrate @ 17129]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
1 #include "config.h"
553bbd68387e [gaim-migrate @ 17129]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
2
14325
985e5e3f6f2c [gaim-migrate @ 17020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14302
diff changeset
3 #include <ncurses.h>
985e5e3f6f2c [gaim-migrate @ 17020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14302
diff changeset
4
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 #include "gntcolors.h"
14299
ea5193c23171 [gaim-migrate @ 16989]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
6 #include "gntstyle.h"
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
8 #include <glib.h>
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
9
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
10 #include <stdlib.h>
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
11 #include <string.h>
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
12
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
13 static struct
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
14 {
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
15 short r, g, b;
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
16 } colors[GNT_TOTAL_COLORS];
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
17
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
18 static void
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
19 backup_colors()
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
20 {
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
21 short i;
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
22 for (i = 0; i < GNT_TOTAL_COLORS; i++)
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 color_content(i, &colors[i].r,
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
25 &colors[i].g, &colors[i].b);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
26 }
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
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
29 static gboolean
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
30 can_use_custom_color()
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
31 {
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
32 return (gnt_style_get_bool(GNT_STYLE_COLOR, FALSE) && can_change_color());
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
33 }
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
34
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
35 static void
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
36 restore_colors()
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
37 {
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
38 short i;
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
39 for (i = 0; i < GNT_TOTAL_COLORS; i++)
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
40 {
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
41 init_color(i, colors[i].r,
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
42 colors[i].g, colors[i].b);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
43 }
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
44 }
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
45
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 void gnt_init_colors()
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 {
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
48 static gboolean init = FALSE;
14302
a8632e4bd849 [gaim-migrate @ 16992]
Ethan Blanton <elb@pidgin.im>
parents: 14301
diff changeset
49 int defaults;
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
50
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
51 if (init)
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
52 return;
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
53 init = TRUE;
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
54
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
55 start_color();
14302
a8632e4bd849 [gaim-migrate @ 16992]
Ethan Blanton <elb@pidgin.im>
parents: 14301
diff changeset
56 defaults = use_default_colors();
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
57
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
58 if (can_use_custom_color())
13851
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
59 {
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
60 backup_colors();
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
61
14256
e7de1f6d9f35 [gaim-migrate @ 16938]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14210
diff changeset
62 /* Do some init_color()s */
13851
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
63 init_color(GNT_COLOR_BLACK, 0, 0, 0);
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
64 init_color(GNT_COLOR_RED, 1000, 0, 0);
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
65 init_color(GNT_COLOR_GREEN, 0, 1000, 0);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
66 init_color(GNT_COLOR_BLUE, 250, 250, 700);
13851
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
67 init_color(GNT_COLOR_WHITE, 1000, 1000, 1000);
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13882
diff changeset
68 init_color(GNT_COLOR_GRAY, 699, 699, 699);
13851
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
69 init_color(GNT_COLOR_DARK_GRAY, 256, 256, 256);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70
13851
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
71 /* Now some init_pair()s */
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
72 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
73 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
74 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
75
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
76 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
77 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
78
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13882
diff changeset
79 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
80 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
81 init_pair(GNT_COLOR_DISABLED, GNT_COLOR_GRAY, GNT_COLOR_WHITE);
14387
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
82 init_pair(GNT_COLOR_URGENT, GNT_COLOR_WHITE, GNT_COLOR_RED);
13851
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
83 }
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
84 else
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
85 {
14387
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
86 int bg;
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
87
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
88 if (defaults == OK) {
14302
a8632e4bd849 [gaim-migrate @ 16992]
Ethan Blanton <elb@pidgin.im>
parents: 14301
diff changeset
89 init_pair(GNT_COLOR_NORMAL, -1, -1);
14387
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
90 bg = -1;
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
91 } else {
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
92 init_pair(GNT_COLOR_NORMAL, COLOR_BLACK, COLOR_WHITE);
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
93 bg = COLOR_WHITE;
14302
a8632e4bd849 [gaim-migrate @ 16992]
Ethan Blanton <elb@pidgin.im>
parents: 14301
diff changeset
94 }
14387
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
95 init_pair(GNT_COLOR_DISABLED, COLOR_YELLOW, bg);
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
96 init_pair(GNT_COLOR_URGENT, COLOR_GREEN, bg);
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
97
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
98 init_pair(GNT_COLOR_HIGHLIGHT, COLOR_WHITE, COLOR_BLUE);
13851
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
99 init_pair(GNT_COLOR_SHADOW, COLOR_BLACK, COLOR_BLACK);
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
100 init_pair(GNT_COLOR_TITLE, COLOR_WHITE, COLOR_BLUE);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
101 init_pair(GNT_COLOR_TITLE_D, COLOR_WHITE, COLOR_BLACK);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
102 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
103 init_pair(GNT_COLOR_HIGHLIGHT_D, COLOR_CYAN, COLOR_BLACK);
13851
41753203a94d [gaim-migrate @ 16310]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
104 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
107 void
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
108 gnt_uninit_colors()
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
109 {
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
110 if (can_use_custom_color())
14299
ea5193c23171 [gaim-migrate @ 16989]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
111 restore_colors();
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
112 }
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
113
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
114 static int
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
115 get_color(char *key)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
116 {
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
117 int color;
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
118 gboolean custom = can_use_custom_color();
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
119
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
120 key = g_strstrip(key);
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 if (strcmp(key, "black") == 0)
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
123 color = custom ? GNT_COLOR_BLACK : COLOR_BLACK;
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
124 else if (strcmp(key, "red") == 0)
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
125 color = custom ? GNT_COLOR_RED : COLOR_RED;
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
126 else if (strcmp(key, "green") == 0)
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
127 color = custom ? GNT_COLOR_GREEN : COLOR_GREEN;
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
128 else if (strcmp(key, "blue") == 0)
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
129 color = custom ? GNT_COLOR_BLUE : COLOR_BLUE;
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
130 else if (strcmp(key, "white") == 0)
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
131 color = custom ? GNT_COLOR_WHITE : COLOR_WHITE;
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
132 else if (strcmp(key, "gray") == 0)
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
133 color = custom ? GNT_COLOR_GRAY : COLOR_YELLOW; /* eh? */
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
134 else if (strcmp(key, "darkgray") == 0)
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
135 color = custom ? GNT_COLOR_DARK_GRAY : COLOR_BLACK;
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
136 else if (strcmp(key, "magenta") == 0)
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
137 color = COLOR_MAGENTA;
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
138 else if (strcmp(key, "cyan") == 0)
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
139 color = COLOR_CYAN;
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
140 else
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
141 color = -1;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
142 return color;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
143 }
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
144
14210
bb38f32ab6aa [gaim-migrate @ 16888]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14004
diff changeset
145 #if GLIB_CHECK_VERSION(2,6,0)
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
146 void gnt_colors_parse(GKeyFile *kfile)
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 GError *error = NULL;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
149 gsize nkeys;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
150 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
151
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
152 if (error)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
153 {
14256
e7de1f6d9f35 [gaim-migrate @ 16938]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14210
diff changeset
154 g_printerr("GntColors: %s\n", error->message);
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
155 g_error_free(error);
14256
e7de1f6d9f35 [gaim-migrate @ 16938]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14210
diff changeset
156 error = NULL;
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
157 }
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
158 else if (nkeys)
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
159 {
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
160 gnt_init_colors();
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
161 while (nkeys--)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
162 {
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
163 gsize len;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
164 char *key = keys[nkeys];
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
165 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
166 if (len == 3)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
167 {
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
168 int r = atoi(list[0]);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
169 int g = atoi(list[1]);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
170 int b = atoi(list[2]);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
171 int color = -1;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
172
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
173 g_ascii_strdown(key, -1);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
174 color = get_color(key);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
175 if (color == -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 init_color(color, r, g, b);
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 g_strfreev(list);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
181 }
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
182
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
183 g_strfreev(keys);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
184 }
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
185
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
186 gnt_color_pairs_parse(kfile);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
187 }
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
188
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
189 void gnt_color_pairs_parse(GKeyFile *kfile)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
190 {
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
191 GError *error = NULL;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
192 gsize nkeys;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
193 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
194
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
195 if (error)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
196 {
14256
e7de1f6d9f35 [gaim-migrate @ 16938]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14210
diff changeset
197 g_printerr("GntColors: %s\n", error->message);
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
198 g_error_free(error);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
199 return;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
200 }
14301
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
201 else if (nkeys)
9df5dd999402 [gaim-migrate @ 16991]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
202 gnt_init_colors();
14004
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 while (nkeys--)
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 gsize len;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
207 char *key = keys[nkeys];
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
208 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
209 if (len == 2)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
210 {
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
211 GntColorType type = 0;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
212 int fg = get_color(g_ascii_strdown(list[0], -1));
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
213 int bg = get_color(g_ascii_strdown(list[1], -1));
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
214 if (fg == -1 || bg == -1)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
215 continue;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
216
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
217 g_ascii_strdown(key, -1);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
218
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
219 if (strcmp(key, "normal") == 0)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
220 type = GNT_COLOR_NORMAL;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
221 else if (strcmp(key, "highlight") == 0)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
222 type = GNT_COLOR_HIGHLIGHT;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
223 else if (strcmp(key, "highlightd") == 0)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
224 type = GNT_COLOR_HIGHLIGHT_D;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
225 else if (strcmp(key, "shadow") == 0)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
226 type = GNT_COLOR_SHADOW;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
227 else if (strcmp(key, "title") == 0)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
228 type = GNT_COLOR_TITLE;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
229 else if (strcmp(key, "titled") == 0)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
230 type = GNT_COLOR_TITLE_D;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
231 else if (strcmp(key, "text") == 0)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
232 type = GNT_COLOR_TEXT_NORMAL;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
233 else if (strcmp(key, "disabled") == 0)
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
234 type = GNT_COLOR_DISABLED;
14387
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
235 else if (strcmp(key, "urgent") == 0)
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
236 type = GNT_COLOR_URGENT;
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
237 else
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
238 continue;
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
239
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
240 init_pair(type, fg, bg);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
241 }
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
242 g_strfreev(list);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
243 }
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
244
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
245 g_strfreev(keys);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
246 }
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
247
14210
bb38f32ab6aa [gaim-migrate @ 16888]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14004
diff changeset
248 #endif /* GKeyFile */