comparison plugins/gaimrc.c @ 11940:8dc2e512038f

[gaim-migrate @ 14231] These are likely to be somewhat useful additions to this plugin. But I don't realy use it, someone who does should comment. (Sean?) committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Wed, 02 Nov 2005 03:23:02 +0000
parents f8cd06753755
children bfb56404a9b6
comparison
equal deleted inserted replaced
11939:85c25a32bb48 11940:8dc2e512038f
20 20
21 #include "internal.h" 21 #include "internal.h"
22 #include "gtkplugin.h" 22 #include "gtkplugin.h"
23 #include "gtkprefs.h" 23 #include "gtkprefs.h"
24 #include "gtkutils.h" 24 #include "gtkutils.h"
25 #include "util.c"
25 #include "version.h" 26 #include "version.h"
26 27
27 static guint pref_callback; 28 static guint pref_callback;
28 29
29 static const char *color_prefs[] = { 30 static const char *color_prefs[] = {
134 } 135 }
135 136
136 gtk_rc_parse_string(style_string->str); 137 gtk_rc_parse_string(style_string->str);
137 138
138 g_string_free(style_string, TRUE); 139 g_string_free(style_string, TRUE);
140 }
141
142 static void
143 gaimrc_write(GtkWidget *widget, gpointer data)
144 {
145 int i;
146 GString *style_string = g_string_new("");
147 char *prefbase = NULL;
148
149 if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-font-name")) {
150 const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name");
151 g_string_append_printf(style_string, "gtk-font-name = \"%s\"\n", pref);
152 }
153
154 if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")) {
155 const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-key-theme-name");
156 g_string_append_printf(style_string, "gtk-key-theme-name = \"%s\"\n", pref);
157 }
158
159 g_string_append(style_string, "style \"gaimrc_style\" {\n");
160
161 for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) {
162 if (gaim_prefs_get_bool(color_prefs_set[i])) {
163 prefbase = g_path_get_basename(color_prefs[i]);
164 g_string_append_printf(style_string,
165 "%s = \"%s\"\n", prefbase,
166 gaim_prefs_get_string(color_prefs[i]));
167 g_free(prefbase);
168 }
169 }
170
171 for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) {
172 if (gaim_prefs_get_bool(widget_size_prefs_set[i])) {
173 prefbase = g_path_get_basename(widget_size_prefs[i]);
174 g_string_append_printf(style_string,
175 "%s = %d\n", prefbase,
176 gaim_prefs_get_int(widget_size_prefs[i]));
177 g_free(prefbase);
178 }
179 }
180
181 g_string_append(style_string, "}");
182 g_string_append(style_string, "widget_class \"*\" style \"gaimrc_style\"\n");
183
184 for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) {
185 if (gaim_prefs_get_bool(font_prefs_set[i])) {
186 prefbase = g_path_get_basename(font_prefs[i]);
187 g_string_append_printf(style_string,
188 "style \"%s_style\"\n"
189 "{font_name = \"%s\"}\n"
190 "widget \"%s\""
191 "style \"%s_style\"\n", prefbase,
192 gaim_prefs_get_string(font_prefs[i]),
193 prefbase, prefbase);
194 g_free(prefbase);
195 }
196 }
197
198 gaim_util_write_data_to_file(".gtkrc-2.0", style_string->str, -1);
199
200 g_string_free(style_string, TRUE);
201 }
202
203 static void
204 gaimrc_reread(GtkWidget *widget, gpointer data)
205 {
206 gtk_rc_reparse_all();
207 /* I don't know if this is necessary but it shouldn't hurt. */
208 gaimrc_make_changes();
139 } 209 }
140 210
141 static void 211 static void
142 gaimrc_pref_changed_cb(const char *name, GaimPrefType type, gpointer value, 212 gaimrc_pref_changed_cb(const char *name, GaimPrefType type, gpointer value,
143 gpointer data) 213 gpointer data)
318 } 388 }
319 389
320 static GtkWidget * 390 static GtkWidget *
321 gaimrc_get_config_frame(GaimPlugin *plugin) 391 gaimrc_get_config_frame(GaimPlugin *plugin)
322 { 392 {
323 GtkWidget *ret = NULL, *frame = NULL, *hbox = NULL; 393 GtkWidget *ret = NULL, *frame = NULL, *hbox = NULL, *vbox = NULL;
324 /* 394 /*
325 GtkWidget *check = NULL, *widget = NULL, *label = NULL; 395 GtkWidget *check = NULL, *widget = NULL, *label = NULL;
326 */ 396 */
327 GtkWidget *check = NULL, *widget = NULL; 397 GtkWidget *check = NULL, *widget = NULL;
328 GtkSizeGroup *sg = NULL; 398 GtkSizeGroup *sg = NULL;
329 /* 399 /*
330 char sample[7] = "Sample"; 400 char sample[7] = "Sample";
331 */ 401 */
332 int i; 402 int i;
333 403
334 ret = gtk_vbox_new(FALSE, 18); 404 ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE);
335 gtk_container_set_border_width(GTK_CONTAINER(ret), 12); 405 gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER);
336 406
337 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); 407 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
338 408
339 frame = gaim_gtk_make_frame(ret, "General"); 409 frame = gaim_gtk_make_frame(ret, "General");
340 /* interface font */ 410 /* interface font */
341 hbox = gtk_hbox_new(FALSE, 18); 411 hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE);
342 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); 412 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0);
343 413
344 check = gaim_gtk_prefs_checkbox(_("GTK+ Interface Font"), 414 check = gaim_gtk_prefs_checkbox(_("GTK+ Interface Font"),
345 "/plugins/gtk/gaimrc/set/gtk-font-name", 415 "/plugins/gtk/gaimrc/set/gtk-font-name",
346 hbox); 416 hbox);
355 G_CALLBACK(gaim_gtk_toggle_sensitive), widget); 425 G_CALLBACK(gaim_gtk_toggle_sensitive), widget);
356 g_signal_connect(G_OBJECT(widget), "clicked", 426 g_signal_connect(G_OBJECT(widget), "clicked",
357 G_CALLBACK(gaimrc_set_font_special), NULL); 427 G_CALLBACK(gaimrc_set_font_special), NULL);
358 428
359 /* key theme name */ 429 /* key theme name */
360 hbox = gtk_hbox_new(FALSE, 18); 430 hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE);
361 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); 431 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0);
362 432
363 check = gaim_gtk_prefs_checkbox(_("GTK+ Text Shortcut Theme"), 433 check = gaim_gtk_prefs_checkbox(_("GTK+ Text Shortcut Theme"),
364 "/plugins/gtk/gaimrc/set/gtk-key-theme-name", 434 "/plugins/gtk/gaimrc/set/gtk-key-theme-name",
365 hbox); 435 hbox);
374 G_CALLBACK(gaim_gtk_toggle_sensitive), widget); 444 G_CALLBACK(gaim_gtk_toggle_sensitive), widget);
375 445
376 frame = gaim_gtk_make_frame(ret, "Interface colors"); 446 frame = gaim_gtk_make_frame(ret, "Interface colors");
377 /* imhtml stuff */ 447 /* imhtml stuff */
378 for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { 448 for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) {
379 hbox = gtk_hbox_new(FALSE, 18); 449 hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE);
380 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); 450 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0);
381 451
382 check = gaim_gtk_prefs_checkbox(_(color_names[i]), 452 check = gaim_gtk_prefs_checkbox(_(color_names[i]),
383 color_prefs_set[i], hbox); 453 color_prefs_set[i], hbox);
384 gtk_size_group_add_widget(sg, check); 454 gtk_size_group_add_widget(sg, check);
398 } 468 }
399 469
400 frame = gaim_gtk_make_frame(ret, "Widget Sizes"); 470 frame = gaim_gtk_make_frame(ret, "Widget Sizes");
401 /* widget size stuff */ 471 /* widget size stuff */
402 for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { 472 for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) {
403 hbox = gtk_hbox_new(FALSE, 18); 473 hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE);
404 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); 474 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0);
405 475
406 check = gaim_gtk_prefs_checkbox(_(widget_size_names[i]), 476 check = gaim_gtk_prefs_checkbox(_(widget_size_names[i]),
407 widget_size_prefs_set[i], hbox); 477 widget_size_prefs_set[i], hbox);
408 gtk_size_group_add_widget(sg, check); 478 gtk_size_group_add_widget(sg, check);
416 } 486 }
417 487
418 frame = gaim_gtk_make_frame(ret, "Fonts"); 488 frame = gaim_gtk_make_frame(ret, "Fonts");
419 /* imhtml font stuff */ 489 /* imhtml font stuff */
420 for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { 490 for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) {
421 hbox = gtk_hbox_new(FALSE, 18); 491 hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE);
422 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); 492 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0);
423 493
424 check = gaim_gtk_prefs_checkbox(_(font_names[i]), 494 check = gaim_gtk_prefs_checkbox(_(font_names[i]),
425 font_prefs_set[i], hbox); 495 font_prefs_set[i], hbox);
426 gtk_size_group_add_widget(sg, check); 496 gtk_size_group_add_widget(sg, check);
435 G_CALLBACK(gaim_gtk_toggle_sensitive), 505 G_CALLBACK(gaim_gtk_toggle_sensitive),
436 font_widgets[i]); 506 font_widgets[i]);
437 g_signal_connect(G_OBJECT(font_widgets[i]), "clicked", 507 g_signal_connect(G_OBJECT(font_widgets[i]), "clicked",
438 G_CALLBACK(gaimrc_set_font), GINT_TO_POINTER(i)); 508 G_CALLBACK(gaimrc_set_font), GINT_TO_POINTER(i));
439 } 509 }
510
511 frame = gaim_gtk_make_frame(ret, "General");
512
513 vbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE);
514 gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0);
515
516 check = gtk_button_new_with_label(_("Write a gtkrc file with these settings"));
517 gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
518 gtk_size_group_add_widget(sg, check);
519 g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(gaimrc_write),
520 NULL);
521
522 check = gtk_button_new_with_label(_("Re-read gtkrc files"));
523 gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
524 gtk_size_group_add_widget(sg, check);
525 g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(gaimrc_reread),
526 NULL);
440 527
441 gtk_widget_show_all(ret); 528 gtk_widget_show_all(ret);
442 return ret; 529 return ret;
443 } 530 }
444 531