# HG changeset patch # User Etan Reisner # Date 1130901782 0 # Node ID 8dc2e512038f5e373a893b81c38e088952d41fc5 # Parent 85c25a32bb48b5bbe09160db5e1b995e485d113f [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 diff -r 85c25a32bb48 -r 8dc2e512038f plugins/gaimrc.c --- a/plugins/gaimrc.c Wed Nov 02 02:21:43 2005 +0000 +++ b/plugins/gaimrc.c Wed Nov 02 03:23:02 2005 +0000 @@ -22,6 +22,7 @@ #include "gtkplugin.h" #include "gtkprefs.h" #include "gtkutils.h" +#include "util.c" #include "version.h" static guint pref_callback; @@ -139,6 +140,75 @@ } static void +gaimrc_write(GtkWidget *widget, gpointer data) +{ + int i; + GString *style_string = g_string_new(""); + char *prefbase = NULL; + + if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-font-name")) { + const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name"); + g_string_append_printf(style_string, "gtk-font-name = \"%s\"\n", pref); + } + + if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")) { + const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-key-theme-name"); + g_string_append_printf(style_string, "gtk-key-theme-name = \"%s\"\n", pref); + } + + g_string_append(style_string, "style \"gaimrc_style\" {\n"); + + for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { + if (gaim_prefs_get_bool(color_prefs_set[i])) { + prefbase = g_path_get_basename(color_prefs[i]); + g_string_append_printf(style_string, + "%s = \"%s\"\n", prefbase, + gaim_prefs_get_string(color_prefs[i])); + g_free(prefbase); + } + } + + for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { + if (gaim_prefs_get_bool(widget_size_prefs_set[i])) { + prefbase = g_path_get_basename(widget_size_prefs[i]); + g_string_append_printf(style_string, + "%s = %d\n", prefbase, + gaim_prefs_get_int(widget_size_prefs[i])); + g_free(prefbase); + } + } + + g_string_append(style_string, "}"); + g_string_append(style_string, "widget_class \"*\" style \"gaimrc_style\"\n"); + + for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { + if (gaim_prefs_get_bool(font_prefs_set[i])) { + prefbase = g_path_get_basename(font_prefs[i]); + g_string_append_printf(style_string, + "style \"%s_style\"\n" + "{font_name = \"%s\"}\n" + "widget \"%s\"" + "style \"%s_style\"\n", prefbase, + gaim_prefs_get_string(font_prefs[i]), + prefbase, prefbase); + g_free(prefbase); + } + } + + gaim_util_write_data_to_file(".gtkrc-2.0", style_string->str, -1); + + g_string_free(style_string, TRUE); +} + +static void +gaimrc_reread(GtkWidget *widget, gpointer data) +{ + gtk_rc_reparse_all(); + /* I don't know if this is necessary but it shouldn't hurt. */ + gaimrc_make_changes(); +} + +static void gaimrc_pref_changed_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) { @@ -320,7 +390,7 @@ static GtkWidget * gaimrc_get_config_frame(GaimPlugin *plugin) { - GtkWidget *ret = NULL, *frame = NULL, *hbox = NULL; + GtkWidget *ret = NULL, *frame = NULL, *hbox = NULL, *vbox = NULL; /* GtkWidget *check = NULL, *widget = NULL, *label = NULL; */ @@ -331,14 +401,14 @@ */ int i; - ret = gtk_vbox_new(FALSE, 18); - gtk_container_set_border_width(GTK_CONTAINER(ret), 12); + ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); frame = gaim_gtk_make_frame(ret, "General"); /* interface font */ - hbox = gtk_hbox_new(FALSE, 18); + hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); check = gaim_gtk_prefs_checkbox(_("GTK+ Interface Font"), @@ -357,7 +427,7 @@ G_CALLBACK(gaimrc_set_font_special), NULL); /* key theme name */ - hbox = gtk_hbox_new(FALSE, 18); + hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); check = gaim_gtk_prefs_checkbox(_("GTK+ Text Shortcut Theme"), @@ -376,7 +446,7 @@ frame = gaim_gtk_make_frame(ret, "Interface colors"); /* imhtml stuff */ for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { - hbox = gtk_hbox_new(FALSE, 18); + hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); check = gaim_gtk_prefs_checkbox(_(color_names[i]), @@ -400,7 +470,7 @@ frame = gaim_gtk_make_frame(ret, "Widget Sizes"); /* widget size stuff */ for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { - hbox = gtk_hbox_new(FALSE, 18); + hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); check = gaim_gtk_prefs_checkbox(_(widget_size_names[i]), @@ -418,7 +488,7 @@ frame = gaim_gtk_make_frame(ret, "Fonts"); /* imhtml font stuff */ for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { - hbox = gtk_hbox_new(FALSE, 18); + hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); check = gaim_gtk_prefs_checkbox(_(font_names[i]), @@ -438,6 +508,23 @@ G_CALLBACK(gaimrc_set_font), GINT_TO_POINTER(i)); } + frame = gaim_gtk_make_frame(ret, "General"); + + vbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); + gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0); + + check = gtk_button_new_with_label(_("Write a gtkrc file with these settings")); + gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); + gtk_size_group_add_widget(sg, check); + g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(gaimrc_write), + NULL); + + check = gtk_button_new_with_label(_("Re-read gtkrc files")); + gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); + gtk_size_group_add_widget(sg, check); + g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(gaimrc_reread), + NULL); + gtk_widget_show_all(ret); return ret; }