| |
1 /** |
| |
2 * @file gaimrc.c Gaim gtk resource control plugin. |
| |
3 * |
| |
4 * Copyright (C) 2005 Etan Reisner <deryni@eden.rutgers.edu> |
| |
5 * |
| |
6 * This program is free software; you can redistribute it and/or modify |
| |
7 * it under the terms of the GNU General Public License as published by |
| |
8 * the Free Software Foundation; either version 2 of the License, or |
| |
9 * (at your option) any later version. |
| |
10 * |
| |
11 * This program is distributed in the hope that it will be useful, |
| |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| |
14 * GNU General Public License for more details. |
| |
15 * |
| |
16 * You should have received a copy of the GNU General Public License |
| |
17 * along with this program; if not, write to the Free Software |
| |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| |
19 */ |
| |
20 |
| |
21 #include "internal.h" |
| |
22 #include "gtkplugin.h" |
| |
23 #include "gtkprefs.h" |
| |
24 #include "gtkutils.h" |
| |
25 #include "util.h" |
| |
26 #include "version.h" |
| |
27 |
| |
28 static guint pref_callback; |
| |
29 |
| |
30 static const char *color_prefs[] = { |
| |
31 "/plugins/gtk/gaimrc/color/GtkWidget::cursor-color", |
| |
32 "/plugins/gtk/gaimrc/color/GtkWidget::secondary-cursor-color", |
| |
33 "/plugins/gtk/gaimrc/color/GtkIMHtml::hyperlink-color" |
| |
34 }; |
| |
35 static const char *color_prefs_set[] = { |
| |
36 "/plugins/gtk/gaimrc/set/color/GtkWidget::cursor-color", |
| |
37 "/plugins/gtk/gaimrc/set/color/GtkWidget::secondary-cursor-color", |
| |
38 "/plugins/gtk/gaimrc/set/color/GtkIMHtml::hyperlink-color" |
| |
39 }; |
| |
40 static const char *color_names[] = { |
| |
41 N_("Cursor Color"), |
| |
42 N_("Secondary Cursor Color"), |
| |
43 N_("Hyperlink Color") |
| |
44 }; |
| |
45 static GtkWidget *color_widgets[G_N_ELEMENTS(color_prefs)]; |
| |
46 |
| |
47 static const char *widget_size_prefs[] = { |
| |
48 "/plugins/gtk/gaimrc/size/GtkTreeView::expander_size", |
| |
49 "/plugins/gtk/gaimrc/size/GtkTreeView::horizontal_separator" |
| |
50 }; |
| |
51 static const char *widget_size_prefs_set[] = { |
| |
52 "/plugins/gtk/gaimrc/set/size/GtkTreeView::expander_size", |
| |
53 "/plugins/gtk/gaimrc/set/size/GtkTreeView::horizontal_separator" |
| |
54 }; |
| |
55 static const char *widget_size_names[] = { |
| |
56 N_("GtkTreeView Expander Size"), |
| |
57 N_("GtkTreeView Horizontal Separation") |
| |
58 }; |
| |
59 static GtkWidget *widget_size_widgets[G_N_ELEMENTS(widget_size_prefs)]; |
| |
60 |
| |
61 static const char *font_prefs[] = { |
| |
62 "/plugins/gtk/gaimrc/font/*gaim_gtkconv_entry", |
| |
63 "/plugins/gtk/gaimrc/font/*gaim_gtkconv_imhtml", |
| |
64 "/plugins/gtk/gaimrc/font/*gaim_gtklog_imhtml", |
| |
65 "/plugins/gtk/gaimrc/font/*gaim_gtkrequest_imhtml", |
| |
66 "/plugins/gtk/gaimrc/font/*gaim_gtknotify_imhtml", |
| |
67 }; |
| |
68 static const char *font_prefs_set[] = { |
| |
69 "/plugins/gtk/gaimrc/set/font/*gaim_gtkconv_entry", |
| |
70 "/plugins/gtk/gaimrc/set/font/*gaim_gtkconv_imhtml", |
| |
71 "/plugins/gtk/gaimrc/set/font/*gaim_gtklog_imhtml", |
| |
72 "/plugins/gtk/gaimrc/set/font/*gaim_gtkrequest_imhtml", |
| |
73 "/plugins/gtk/gaimrc/set/font/*gaim_gtknotify_imhtml", |
| |
74 }; |
| |
75 static const char *font_names[] = { |
| |
76 N_("Conversation Entry"), |
| |
77 N_("Conversation History"), |
| |
78 N_("Log Viewer"), |
| |
79 N_("Request Dialog"), |
| |
80 N_("Notify Dialog") |
| |
81 }; |
| |
82 static GtkWidget *font_widgets[G_N_ELEMENTS(font_prefs)]; |
| |
83 |
| |
84 static const char *widget_bool_prefs[] = { |
| |
85 "/plugins/gtk/gaimrc/bool/GtkTreeView::indent_expanders", |
| |
86 }; |
| |
87 static const char *widget_bool_prefs_set[] = { |
| |
88 "/plugins/gtk/gaimrc/set/bool/GtkTreeView::indent_expanders", |
| |
89 }; |
| |
90 static const char *widget_bool_names[] = { |
| |
91 N_("GtkTreeView Indent Expanders"), |
| |
92 }; |
| |
93 static GtkWidget *widget_bool_widgets[G_N_ELEMENTS(widget_bool_prefs)]; |
| |
94 |
| |
95 static void |
| |
96 gaimrc_make_changes() |
| |
97 { |
| |
98 int i; |
| |
99 char *prefbase = NULL; |
| |
100 #if GTK_CHECK_VERSION(2,4,0) |
| |
101 GtkSettings *setting = NULL; |
| |
102 #endif |
| |
103 GString *style_string = g_string_new(""); |
| |
104 |
| |
105 if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-font-name")) { |
| |
106 const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name"); |
| |
107 g_string_append_printf(style_string, "gtk-font-name = \"%s\"\n", pref); |
| |
108 } |
| |
109 |
| |
110 if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")) { |
| |
111 const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-key-theme-name"); |
| |
112 g_string_append_printf(style_string, "gtk-key-theme-name = \"%s\"\n", pref); |
| |
113 } |
| |
114 |
| |
115 g_string_append(style_string, "style \"gaimrc_style\" {\n"); |
| |
116 |
| |
117 for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { |
| |
118 if (gaim_prefs_get_bool(color_prefs_set[i])) { |
| |
119 prefbase = g_path_get_basename(color_prefs[i]); |
| |
120 g_string_append_printf(style_string, |
| |
121 "%s = \"%s\"\n", prefbase, |
| |
122 gaim_prefs_get_string(color_prefs[i])); |
| |
123 g_free(prefbase); |
| |
124 } |
| |
125 } |
| |
126 |
| |
127 for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { |
| |
128 if (gaim_prefs_get_bool(widget_size_prefs_set[i])) { |
| |
129 prefbase = g_path_get_basename(widget_size_prefs[i]); |
| |
130 g_string_append_printf(style_string, |
| |
131 "%s = %d\n", prefbase, |
| |
132 gaim_prefs_get_int(widget_size_prefs[i])); |
| |
133 g_free(prefbase); |
| |
134 } |
| |
135 } |
| |
136 |
| |
137 for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { |
| |
138 if (gaim_prefs_get_bool(widget_bool_prefs_set[i])) { |
| |
139 prefbase = g_path_get_basename(widget_bool_prefs[i]); |
| |
140 g_string_append_printf(style_string, |
| |
141 "%s = %d\n", prefbase, |
| |
142 gaim_prefs_get_bool(widget_bool_prefs[i])); |
| |
143 g_free(prefbase); |
| |
144 } |
| |
145 } |
| |
146 |
| |
147 g_string_append(style_string, "}"); |
| |
148 g_string_append(style_string, "widget_class \"*\" style \"gaimrc_style\"\n"); |
| |
149 |
| |
150 for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { |
| |
151 if (gaim_prefs_get_bool(font_prefs_set[i])) { |
| |
152 prefbase = g_path_get_basename(font_prefs[i]); |
| |
153 g_string_append_printf(style_string, |
| |
154 "style \"%s_style\"\n" |
| |
155 "{font_name = \"%s\"}\n" |
| |
156 "widget \"%s\"" |
| |
157 "style \"%s_style\"\n", prefbase, |
| |
158 gaim_prefs_get_string(font_prefs[i]), |
| |
159 prefbase, prefbase); |
| |
160 g_free(prefbase); |
| |
161 } |
| |
162 } |
| |
163 |
| |
164 gtk_rc_parse_string(style_string->str); |
| |
165 g_string_free(style_string, TRUE); |
| |
166 |
| |
167 #if GTK_CHECK_VERSION(2,4,0) |
| |
168 setting = gtk_settings_get_default(); |
| |
169 gtk_rc_reset_styles(setting); |
| |
170 #endif |
| |
171 } |
| |
172 |
| |
173 static void |
| |
174 gaimrc_write(GtkWidget *widget, gpointer data) |
| |
175 { |
| |
176 int i; |
| |
177 GString *style_string = g_string_new(""); |
| |
178 char *prefbase = NULL; |
| |
179 |
| |
180 if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-font-name")) { |
| |
181 const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name"); |
| |
182 g_string_append_printf(style_string, "gtk-font-name = \"%s\"\n", pref); |
| |
183 } |
| |
184 |
| |
185 if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")) { |
| |
186 const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-key-theme-name"); |
| |
187 g_string_append_printf(style_string, "gtk-key-theme-name = \"%s\"\n", pref); |
| |
188 } |
| |
189 |
| |
190 g_string_append(style_string, "style \"gaimrc_style\" {\n"); |
| |
191 |
| |
192 for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { |
| |
193 if (gaim_prefs_get_bool(color_prefs_set[i])) { |
| |
194 prefbase = g_path_get_basename(color_prefs[i]); |
| |
195 g_string_append_printf(style_string, |
| |
196 "%s = \"%s\"\n", prefbase, |
| |
197 gaim_prefs_get_string(color_prefs[i])); |
| |
198 g_free(prefbase); |
| |
199 } |
| |
200 } |
| |
201 |
| |
202 for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { |
| |
203 if (gaim_prefs_get_bool(widget_size_prefs_set[i])) { |
| |
204 prefbase = g_path_get_basename(widget_size_prefs[i]); |
| |
205 g_string_append_printf(style_string, |
| |
206 "%s = %d\n", prefbase, |
| |
207 gaim_prefs_get_int(widget_size_prefs[i])); |
| |
208 g_free(prefbase); |
| |
209 } |
| |
210 } |
| |
211 |
| |
212 for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { |
| |
213 if (gaim_prefs_get_bool(widget_bool_prefs_set[i])) { |
| |
214 prefbase = g_path_get_basename(widget_bool_prefs[i]); |
| |
215 g_string_append_printf(style_string, |
| |
216 "%s = %d\n", prefbase, |
| |
217 gaim_prefs_get_bool(widget_bool_prefs[i])); |
| |
218 g_free(prefbase); |
| |
219 } |
| |
220 } |
| |
221 |
| |
222 g_string_append(style_string, "}"); |
| |
223 g_string_append(style_string, "widget_class \"*\" style \"gaimrc_style\"\n"); |
| |
224 |
| |
225 for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { |
| |
226 if (gaim_prefs_get_bool(font_prefs_set[i])) { |
| |
227 prefbase = g_path_get_basename(font_prefs[i]); |
| |
228 g_string_append_printf(style_string, |
| |
229 "style \"%s_style\"\n" |
| |
230 "{font_name = \"%s\"}\n" |
| |
231 "widget \"%s\"" |
| |
232 "style \"%s_style\"\n", prefbase, |
| |
233 gaim_prefs_get_string(font_prefs[i]), |
| |
234 prefbase, prefbase); |
| |
235 g_free(prefbase); |
| |
236 } |
| |
237 } |
| |
238 |
| |
239 gaim_util_write_data_to_file("gtkrc-2.0", style_string->str, -1); |
| |
240 |
| |
241 g_string_free(style_string, TRUE); |
| |
242 } |
| |
243 |
| |
244 static void |
| |
245 gaimrc_reread(GtkWidget *widget, gpointer data) |
| |
246 { |
| |
247 gtk_rc_reparse_all(); |
| |
248 /* I don't know if this is necessary but if not it shouldn't hurt. */ |
| |
249 gaimrc_make_changes(); |
| |
250 } |
| |
251 |
| |
252 static void |
| |
253 gaimrc_pref_changed_cb(const char *name, GaimPrefType type, |
| |
254 gconstpointer value, gpointer data) |
| |
255 { |
| |
256 gaimrc_make_changes(); |
| |
257 } |
| |
258 |
| |
259 static void |
| |
260 gaimrc_color_response(GtkDialog *color_dialog, gint response, gpointer data) |
| |
261 { |
| |
262 int subscript = GPOINTER_TO_INT(data); |
| |
263 |
| |
264 if (response == GTK_RESPONSE_OK) { |
| |
265 GtkWidget *colorsel = GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel; |
| |
266 GdkColor color; |
| |
267 char colorstr[8]; |
| |
268 |
| |
269 gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(colorsel), &color); |
| |
270 |
| |
271 g_snprintf(colorstr, sizeof(colorstr), "#%02X%02X%02X", |
| |
272 color.red/256, color.green/256, color.blue/256); |
| |
273 |
| |
274 gaim_prefs_set_string(color_prefs[subscript], colorstr); |
| |
275 } |
| |
276 gtk_widget_destroy(GTK_WIDGET(color_dialog)); |
| |
277 } |
| |
278 |
| |
279 static void |
| |
280 gaimrc_set_color(GtkWidget *widget, gpointer data) |
| |
281 { |
| |
282 GtkWidget *color_dialog = NULL; |
| |
283 GdkColor color; |
| |
284 char title[128]; |
| |
285 int subscript = GPOINTER_TO_INT(data); |
| |
286 |
| |
287 g_snprintf(title, sizeof(title), _("Select Color for %s"), |
| |
288 _(color_names[GPOINTER_TO_INT(data)])); |
| |
289 color_dialog = gtk_color_selection_dialog_new(_("Select Color")); |
| |
290 g_signal_connect(G_OBJECT(color_dialog), "response", |
| |
291 G_CALLBACK(gaimrc_color_response), data); |
| |
292 |
| |
293 if (gdk_color_parse(gaim_prefs_get_string(color_prefs[subscript]), |
| |
294 &color)) { |
| |
295 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel), &color); |
| |
296 } |
| |
297 |
| |
298 gtk_window_present(GTK_WINDOW(color_dialog)); |
| |
299 } |
| |
300 |
| |
301 static void |
| |
302 gaimrc_font_response(GtkDialog *font_dialog, gint response, gpointer data) |
| |
303 { |
| |
304 int subscript = GPOINTER_TO_INT(data); |
| |
305 |
| |
306 if (response == GTK_RESPONSE_OK) { |
| |
307 char *fontname = NULL; |
| |
308 |
| |
309 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog)); |
| |
310 |
| |
311 gaim_prefs_set_string(font_prefs[subscript], fontname); |
| |
312 g_free(fontname); |
| |
313 } |
| |
314 gtk_widget_destroy(GTK_WIDGET(font_dialog)); |
| |
315 } |
| |
316 |
| |
317 static void |
| |
318 gaimrc_set_font(GtkWidget *widget, gpointer data) |
| |
319 { |
| |
320 GtkWidget *font_dialog = NULL; |
| |
321 char title[128]; |
| |
322 int subscript = GPOINTER_TO_INT(data); |
| |
323 |
| |
324 g_snprintf(title, sizeof(title), _("Select Font for %s"), |
| |
325 _(font_names[subscript])); |
| |
326 font_dialog = gtk_font_selection_dialog_new(title); |
| |
327 g_signal_connect(G_OBJECT(font_dialog), "response", |
| |
328 G_CALLBACK(gaimrc_font_response), data); |
| |
329 |
| |
330 /* TODO Figure out a way to test for the presence of a value in the |
| |
331 * actual pref |
| |
332 if (gaim_prefs_get_bool(font_prefs[subscript])) { |
| |
333 gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(font_dialog)->fontsel), gaim_prefs_get_string(font_prefs[subscript])); |
| |
334 } |
| |
335 */ |
| |
336 |
| |
337 gtk_window_present(GTK_WINDOW(font_dialog)); |
| |
338 } |
| |
339 |
| |
340 static void |
| |
341 gaimrc_font_response_special(GtkDialog *font_dialog, gint response, |
| |
342 gpointer data) |
| |
343 { |
| |
344 if (response == GTK_RESPONSE_OK) { |
| |
345 char *fontname = NULL; |
| |
346 |
| |
347 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog)); |
| |
348 |
| |
349 gaim_prefs_set_string("/plugins/gtk/gaimrc/gtk-font-name", |
| |
350 fontname); |
| |
351 g_free(fontname); |
| |
352 } |
| |
353 gtk_widget_destroy(GTK_WIDGET(font_dialog)); |
| |
354 } |
| |
355 |
| |
356 static void |
| |
357 gaimrc_set_font_special(GtkWidget *widget, gpointer data) |
| |
358 { |
| |
359 GtkWidget *font_dialog = NULL; |
| |
360 #if 0 |
| |
361 const char *font = NULL; |
| |
362 #endif |
| |
363 |
| |
364 font_dialog = gtk_font_selection_dialog_new(_("Select Interface Font")); |
| |
365 g_signal_connect(G_OBJECT(font_dialog), "response", |
| |
366 G_CALLBACK(gaimrc_font_response_special), NULL); |
| |
367 |
| |
368 #if 0 |
| |
369 /* |
| |
370 * TODO Figure out a way to test for the presence of a value in the |
| |
371 * actual pref |
| |
372 */ |
| |
373 font = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name"); |
| |
374 printf("font - %s.\n", font); |
| |
375 if (font != NULL && font != "") { |
| |
376 gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(font_dialog)->fontsel), gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name")); |
| |
377 } |
| |
378 #endif |
| |
379 |
| |
380 gtk_window_present(GTK_WINDOW(font_dialog)); |
| |
381 } |
| |
382 |
| |
383 static gboolean |
| |
384 gaimrc_plugin_load(GaimPlugin *plugin) |
| |
385 { |
| |
386 gaimrc_make_changes(); |
| |
387 |
| |
388 pref_callback = gaim_prefs_connect_callback(plugin, "/plugins/gtk/gaimrc", |
| |
389 gaimrc_pref_changed_cb, NULL); |
| |
390 |
| |
391 return TRUE; |
| |
392 } |
| |
393 |
| |
394 static gboolean |
| |
395 gaimrc_plugin_unload(GaimPlugin *plugin) |
| |
396 { |
| |
397 gaim_prefs_disconnect_callback(pref_callback); |
| |
398 |
| |
399 return TRUE; |
| |
400 } |
| |
401 |
| |
402 static GtkWidget * |
| |
403 gaimrc_get_config_frame(GaimPlugin *plugin) |
| |
404 { |
| |
405 /* Note: Intentionally not using the size group argument to the |
| |
406 * gaim_gtk_prefs_labeled_* functions they only add the text label to |
| |
407 * the size group not the whole thing, which isn't what I want. */ |
| |
408 int i; |
| |
409 char *tmp; |
| |
410 GtkWidget *check = NULL, *widget = NULL; |
| |
411 GtkSizeGroup *labelsg = NULL, *widgetsg = NULL; |
| |
412 GtkWidget *ret = NULL, *frame = NULL, *hbox = NULL, *vbox = NULL; |
| |
413 |
| |
414 ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
415 gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); |
| |
416 |
| |
417 labelsg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| |
418 widgetsg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| |
419 |
| |
420 frame = gaim_gtk_make_frame(ret, _("General")); |
| |
421 /* interface font */ |
| |
422 hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
423 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| |
424 |
| |
425 check = gaim_gtk_prefs_checkbox(_("GTK+ Interface Font"), |
| |
426 "/plugins/gtk/gaimrc/set/gtk-font-name", |
| |
427 hbox); |
| |
428 gtk_size_group_add_widget(labelsg, check); |
| |
429 |
| |
430 widget = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, |
| |
431 GAIM_BUTTON_HORIZONTAL); |
| |
432 gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); |
| |
433 gtk_size_group_add_widget(widgetsg, widget); |
| |
434 gtk_widget_set_sensitive(widget, |
| |
435 gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-font-name")); |
| |
436 g_signal_connect(G_OBJECT(check), "toggled", |
| |
437 G_CALLBACK(gaim_gtk_toggle_sensitive), widget); |
| |
438 g_signal_connect(G_OBJECT(widget), "clicked", |
| |
439 G_CALLBACK(gaimrc_set_font_special), NULL); |
| |
440 |
| |
441 /* key theme name */ |
| |
442 hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
443 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| |
444 |
| |
445 check = gaim_gtk_prefs_checkbox(_("GTK+ Text Shortcut Theme"), |
| |
446 "/plugins/gtk/gaimrc/set/gtk-key-theme-name", |
| |
447 hbox); |
| |
448 gtk_size_group_add_widget(labelsg, check); |
| |
449 |
| |
450 widget = gaim_gtk_prefs_labeled_entry(hbox, "", |
| |
451 "/plugins/gtk/gaimrc/gtk-key-theme-name", |
| |
452 NULL); |
| |
453 /* |
| |
454 gtk_size_group_add_widget(widgetsg, widget); |
| |
455 */ |
| |
456 gtk_widget_set_sensitive(widget, |
| |
457 gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")); |
| |
458 g_signal_connect(G_OBJECT(check), "toggled", |
| |
459 G_CALLBACK(gaim_gtk_toggle_sensitive), widget); |
| |
460 |
| |
461 for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { |
| |
462 hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
463 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| |
464 |
| |
465 check = gaim_gtk_prefs_checkbox(_(widget_bool_names[i]), |
| |
466 widget_bool_prefs_set[i], hbox); |
| |
467 gtk_size_group_add_widget(labelsg, check); |
| |
468 |
| |
469 widget_bool_widgets[i] = gaim_gtk_prefs_checkbox("", widget_bool_prefs[i], hbox); |
| |
470 /* |
| |
471 gtk_size_group_add_widget(widgetsb, widget_bool_widgets[i]); |
| |
472 */ |
| |
473 gtk_widget_set_sensitive(widget_bool_widgets[i], |
| |
474 gaim_prefs_get_bool(widget_bool_prefs_set[i])); |
| |
475 g_signal_connect(G_OBJECT(check), "toggled", |
| |
476 G_CALLBACK(gaim_gtk_toggle_sensitive), |
| |
477 widget_bool_widgets[i]); |
| |
478 } |
| |
479 |
| |
480 frame = gaim_gtk_make_frame(ret, _("Interface colors")); |
| |
481 /* imhtml stuff */ |
| |
482 for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { |
| |
483 hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
484 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| |
485 |
| |
486 check = gaim_gtk_prefs_checkbox(_(color_names[i]), |
| |
487 color_prefs_set[i], hbox); |
| |
488 gtk_size_group_add_widget(labelsg, check); |
| |
489 |
| |
490 color_widgets[i] = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_COLOR, GAIM_BUTTON_HORIZONTAL); |
| |
491 gtk_size_group_add_widget(widgetsg, color_widgets[i]); |
| |
492 gtk_box_pack_start(GTK_BOX(hbox), color_widgets[i], FALSE, |
| |
493 FALSE, 0); |
| |
494 gtk_widget_set_sensitive(color_widgets[i], |
| |
495 gaim_prefs_get_bool(color_prefs_set[i])); |
| |
496 g_signal_connect(G_OBJECT(check), "toggled", |
| |
497 G_CALLBACK(gaim_gtk_toggle_sensitive), |
| |
498 color_widgets[i]); |
| |
499 g_signal_connect(G_OBJECT(color_widgets[i]), "clicked", |
| |
500 G_CALLBACK(gaimrc_set_color), |
| |
501 GINT_TO_POINTER(i)); |
| |
502 } |
| |
503 |
| |
504 frame = gaim_gtk_make_frame(ret, _("Widget Sizes")); |
| |
505 /* widget size stuff */ |
| |
506 for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { |
| |
507 hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
508 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| |
509 |
| |
510 check = gaim_gtk_prefs_checkbox(_(widget_size_names[i]), |
| |
511 widget_size_prefs_set[i], hbox); |
| |
512 gtk_size_group_add_widget(labelsg, check); |
| |
513 |
| |
514 widget_size_widgets[i] = gaim_gtk_prefs_labeled_spin_button(hbox, "", widget_size_prefs[i], 0, 50, NULL); |
| |
515 /* |
| |
516 gtk_size_group_add_widget(widgetsg, widget_size_widgets[i]); |
| |
517 */ |
| |
518 gtk_widget_set_sensitive(widget_size_widgets[i], |
| |
519 gaim_prefs_get_bool(widget_size_prefs_set[i])); |
| |
520 g_signal_connect(G_OBJECT(check), "toggled", |
| |
521 G_CALLBACK(gaim_gtk_toggle_sensitive), |
| |
522 widget_size_widgets[i]); |
| |
523 } |
| |
524 |
| |
525 frame = gaim_gtk_make_frame(ret, _("Fonts")); |
| |
526 /* imhtml font stuff */ |
| |
527 for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { |
| |
528 hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
529 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| |
530 |
| |
531 check = gaim_gtk_prefs_checkbox(_(font_names[i]), |
| |
532 font_prefs_set[i], hbox); |
| |
533 gtk_size_group_add_widget(labelsg, check); |
| |
534 |
| |
535 font_widgets[i] = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, GAIM_BUTTON_HORIZONTAL); |
| |
536 gtk_size_group_add_widget(widgetsg, font_widgets[i]); |
| |
537 gtk_box_pack_start(GTK_BOX(hbox), font_widgets[i], FALSE, |
| |
538 FALSE, 0); |
| |
539 gtk_widget_set_sensitive(font_widgets[i], |
| |
540 gaim_prefs_get_bool(font_prefs_set[i])); |
| |
541 g_signal_connect(G_OBJECT(check), "toggled", |
| |
542 G_CALLBACK(gaim_gtk_toggle_sensitive), |
| |
543 font_widgets[i]); |
| |
544 g_signal_connect(G_OBJECT(font_widgets[i]), "clicked", |
| |
545 G_CALLBACK(gaimrc_set_font), GINT_TO_POINTER(i)); |
| |
546 } |
| |
547 |
| |
548 frame = gaim_gtk_make_frame(ret, _("Tools")); |
| |
549 |
| |
550 vbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| |
551 gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0); |
| |
552 |
| |
553 tmp = g_strdup_printf(_("Write settings to %s%sgtkrc-2.0"), gaim_user_dir(), G_DIR_SEPARATOR_S); |
| |
554 check = gtk_button_new_with_label(tmp); |
| |
555 g_free(tmp); |
| |
556 gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); |
| |
557 gtk_size_group_add_widget(labelsg, check); |
| |
558 g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(gaimrc_write), |
| |
559 NULL); |
| |
560 |
| |
561 check = gtk_button_new_with_label(_("Re-read gtkrc files")); |
| |
562 gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); |
| |
563 gtk_size_group_add_widget(labelsg, check); |
| |
564 g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(gaimrc_reread), |
| |
565 NULL); |
| |
566 |
| |
567 gtk_widget_show_all(ret); |
| |
568 return ret; |
| |
569 } |
| |
570 |
| |
571 static GaimGtkPluginUiInfo gaimrc_ui_info = |
| |
572 { |
| |
573 gaimrc_get_config_frame, |
| |
574 0 /* page_num (Reserved) */ |
| |
575 }; |
| |
576 |
| |
577 static GaimPluginInfo gaimrc_info = |
| |
578 { |
| |
579 GAIM_PLUGIN_MAGIC, |
| |
580 GAIM_MAJOR_VERSION, |
| |
581 GAIM_MINOR_VERSION, |
| |
582 GAIM_PLUGIN_STANDARD, |
| |
583 GAIM_GTK_PLUGIN_TYPE, |
| |
584 0, |
| |
585 NULL, |
| |
586 GAIM_PRIORITY_DEFAULT, |
| |
587 "gaimrc", |
| |
588 N_("Gaim GTK+ Theme Control"), |
| |
589 VERSION, |
| |
590 N_("Provides access to commonly used gtkrc settings."), |
| |
591 N_("Provides access to commonly used gtkrc settings."), |
| |
592 "Etan Reisner <deryni@eden.rutgers.edu>", |
| |
593 GAIM_WEBSITE, |
| |
594 gaimrc_plugin_load, |
| |
595 gaimrc_plugin_unload, |
| |
596 NULL, |
| |
597 &gaimrc_ui_info, |
| |
598 NULL, |
| |
599 NULL, |
| |
600 NULL |
| |
601 }; |
| |
602 |
| |
603 static void |
| |
604 gaimrc_init(GaimPlugin *plugin) |
| |
605 { |
| |
606 int i; |
| |
607 |
| |
608 gaim_prefs_add_none("/plugins"); |
| |
609 gaim_prefs_add_none("/plugins/gtk"); |
| |
610 gaim_prefs_add_none("/plugins/gtk/gaimrc"); |
| |
611 gaim_prefs_add_none("/plugins/gtk/gaimrc/set"); |
| |
612 |
| |
613 gaim_prefs_add_string("/plugins/gtk/gaimrc/gtk-font-name", ""); |
| |
614 gaim_prefs_add_bool("/plugins/gtk/gaimrc/set/gtk-font-name", FALSE); |
| |
615 |
| |
616 gaim_prefs_add_string("/plugins/gtk/gaimrc/gtk-key-theme-name", ""); |
| |
617 gaim_prefs_add_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name", FALSE); |
| |
618 |
| |
619 gaim_prefs_add_none("/plugins/gtk/gaimrc/color"); |
| |
620 gaim_prefs_add_none("/plugins/gtk/gaimrc/set/color"); |
| |
621 for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { |
| |
622 gaim_prefs_add_string(color_prefs[i], ""); |
| |
623 gaim_prefs_add_bool(color_prefs_set[i], FALSE); |
| |
624 } |
| |
625 |
| |
626 gaim_prefs_add_none("/plugins/gtk/gaimrc/size"); |
| |
627 gaim_prefs_add_none("/plugins/gtk/gaimrc/set/size"); |
| |
628 for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { |
| |
629 gaim_prefs_add_int(widget_size_prefs[i], 0); |
| |
630 gaim_prefs_add_bool(widget_size_prefs_set[i], FALSE); |
| |
631 } |
| |
632 |
| |
633 gaim_prefs_add_none("/plugins/gtk/gaimrc/font"); |
| |
634 gaim_prefs_add_none("/plugins/gtk/gaimrc/set/font"); |
| |
635 for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { |
| |
636 gaim_prefs_add_string(font_prefs[i], ""); |
| |
637 gaim_prefs_add_bool(font_prefs_set[i], FALSE); |
| |
638 } |
| |
639 |
| |
640 gaim_prefs_add_none("/plugins/gtk/gaimrc/bool"); |
| |
641 gaim_prefs_add_none("/plugins/gtk/gaimrc/set/bool"); |
| |
642 for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { |
| |
643 gaim_prefs_add_bool(widget_bool_prefs[i], TRUE); |
| |
644 gaim_prefs_add_bool(widget_bool_prefs_set[i], FALSE); |
| |
645 } |
| |
646 } |
| |
647 |
| |
648 GAIM_INIT_PLUGIN(gaimrc, gaimrc_init, gaimrc_info) |