Sat, 03 Feb 2007 07:23:11 +0000
gaim_gtk to pidgin. I hope
| 10584 | 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" | |
|
12044
e49179a1496a
[gaim-migrate @ 14339]
Richard Laager <rlaager@pidgin.im>
parents:
12042
diff
changeset
|
25 | #include "util.h" |
| 10584 | 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[] = { | |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
41 | N_("Cursor Color"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
42 | N_("Secondary Cursor Color"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
43 | N_("Hyperlink Color") |
| 10584 | 44 | }; |
| 45 | static GtkWidget *color_widgets[G_N_ELEMENTS(color_prefs)]; | |
| 46 | ||
| 47 | static const char *widget_size_prefs[] = { | |
| 12201 | 48 | "/plugins/gtk/gaimrc/size/GtkTreeView::expander_size", |
| 49 | "/plugins/gtk/gaimrc/size/GtkTreeView::horizontal_separator" | |
| 10584 | 50 | }; |
| 51 | static const char *widget_size_prefs_set[] = { | |
| 12201 | 52 | "/plugins/gtk/gaimrc/set/size/GtkTreeView::expander_size", |
| 53 | "/plugins/gtk/gaimrc/set/size/GtkTreeView::horizontal_separator" | |
| 10584 | 54 | }; |
| 55 | static const char *widget_size_names[] = { | |
| 12201 | 56 | N_("GtkTreeView Expander Size"), |
| 57 | N_("GtkTreeView Horizontal Separation") | |
| 10584 | 58 | }; |
| 59 | static GtkWidget *widget_size_widgets[G_N_ELEMENTS(widget_size_prefs)]; | |
| 60 | ||
| 61 | static const char *font_prefs[] = { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
62 | "/plugins/gtk/gaimrc/font/*pidginconv_entry", |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
63 | "/plugins/gtk/gaimrc/font/*pidginconv_imhtml", |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
64 | "/plugins/gtk/gaimrc/font/*pidginlog_imhtml", |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
65 | "/plugins/gtk/gaimrc/font/*pidginrequest_imhtml", |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
66 | "/plugins/gtk/gaimrc/font/*pidginnotify_imhtml", |
| 10584 | 67 | }; |
| 68 | static const char *font_prefs_set[] = { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
69 | "/plugins/gtk/gaimrc/set/font/*pidginconv_entry", |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
70 | "/plugins/gtk/gaimrc/set/font/*pidginconv_imhtml", |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
71 | "/plugins/gtk/gaimrc/set/font/*pidginlog_imhtml", |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
72 | "/plugins/gtk/gaimrc/set/font/*pidginrequest_imhtml", |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
73 | "/plugins/gtk/gaimrc/set/font/*pidginnotify_imhtml", |
| 10584 | 74 | }; |
| 75 | static const char *font_names[] = { | |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
76 | N_("Conversation Entry"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
77 | N_("Conversation History"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
78 | N_("Log Viewer"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
79 | N_("Request Dialog"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
80 | N_("Notify Dialog") |
| 10584 | 81 | }; |
| 82 | static GtkWidget *font_widgets[G_N_ELEMENTS(font_prefs)]; | |
| 83 | ||
| 12973 | 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 | ||
| 10584 | 95 | static void |
| 96 | gaimrc_make_changes() | |
| 97 | { | |
| 98 | int i; | |
| 12973 | 99 | char *prefbase = NULL; |
| 100 | #if GTK_CHECK_VERSION(2,4,0) | |
| 101 | GtkSettings *setting = NULL; | |
| 102 | #endif | |
| 10584 | 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"); | |
| 14391 | 107 | |
| 108 | if (pref != NULL && strcmp(pref, "")) | |
| 109 | g_string_append_printf(style_string, "gtk-font-name = \"%s\"\n", pref); | |
| 10584 | 110 | } |
| 111 | ||
| 112 | if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")) { | |
| 113 | const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-key-theme-name"); | |
| 14391 | 114 | |
| 115 | if (pref != NULL && strcmp(pref, "")) | |
| 116 | g_string_append_printf(style_string, "gtk-key-theme-name = \"%s\"\n", pref); | |
| 10584 | 117 | } |
| 118 | ||
| 119 | g_string_append(style_string, "style \"gaimrc_style\" {\n"); | |
| 120 | ||
| 121 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 122 | if (gaim_prefs_get_bool(color_prefs_set[i])) { | |
| 14391 | 123 | const char *pref; |
| 124 | ||
| 10584 | 125 | prefbase = g_path_get_basename(color_prefs[i]); |
| 14391 | 126 | pref = gaim_prefs_get_string(color_prefs[i]); |
| 127 | ||
| 128 | if (pref != NULL && strcmp(pref, "")) | |
| 129 | g_string_append_printf(style_string, | |
| 130 | "%s = \"%s\"\n", | |
| 131 | prefbase, pref); | |
| 10584 | 132 | g_free(prefbase); |
| 133 | } | |
| 134 | } | |
| 135 | ||
| 136 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { | |
| 137 | if (gaim_prefs_get_bool(widget_size_prefs_set[i])) { | |
| 138 | prefbase = g_path_get_basename(widget_size_prefs[i]); | |
| 139 | g_string_append_printf(style_string, | |
|
11862
5d4bc6d54688
[gaim-migrate @ 14153]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
140 | "%s = %d\n", prefbase, |
| 10584 | 141 | gaim_prefs_get_int(widget_size_prefs[i])); |
| 142 | g_free(prefbase); | |
| 143 | } | |
| 144 | } | |
| 145 | ||
| 12973 | 146 | for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { |
| 147 | if (gaim_prefs_get_bool(widget_bool_prefs_set[i])) { | |
| 148 | prefbase = g_path_get_basename(widget_bool_prefs[i]); | |
| 149 | g_string_append_printf(style_string, | |
| 150 | "%s = %d\n", prefbase, | |
| 151 | gaim_prefs_get_bool(widget_bool_prefs[i])); | |
| 152 | g_free(prefbase); | |
| 153 | } | |
| 154 | } | |
| 155 | ||
| 10584 | 156 | g_string_append(style_string, "}"); |
| 157 | g_string_append(style_string, "widget_class \"*\" style \"gaimrc_style\"\n"); | |
| 158 | ||
| 159 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 160 | if (gaim_prefs_get_bool(font_prefs_set[i])) { | |
| 14391 | 161 | const char *pref; |
| 162 | ||
| 10584 | 163 | prefbase = g_path_get_basename(font_prefs[i]); |
| 14391 | 164 | pref = gaim_prefs_get_string(font_prefs[i]); |
| 165 | ||
| 166 | if (pref != NULL && strcmp(pref, "")) | |
| 167 | g_string_append_printf(style_string, | |
| 168 | "style \"%s_style\"\n" | |
| 169 | "{font_name = \"%s\"}\n" | |
| 170 | "widget \"%s\"" | |
| 171 | "style \"%s_style\"\n", | |
| 172 | prefbase, pref, | |
| 173 | prefbase, prefbase); | |
| 10584 | 174 | g_free(prefbase); |
| 175 | } | |
| 176 | } | |
| 177 | ||
| 178 | gtk_rc_parse_string(style_string->str); | |
| 12973 | 179 | g_string_free(style_string, TRUE); |
| 10584 | 180 | |
| 12973 | 181 | #if GTK_CHECK_VERSION(2,4,0) |
| 182 | setting = gtk_settings_get_default(); | |
| 183 | gtk_rc_reset_styles(setting); | |
| 184 | #endif | |
| 10584 | 185 | } |
| 186 | ||
| 187 | static void | |
| 11940 | 188 | gaimrc_write(GtkWidget *widget, gpointer data) |
| 189 | { | |
| 190 | int i; | |
| 191 | GString *style_string = g_string_new(""); | |
| 192 | char *prefbase = NULL; | |
| 193 | ||
| 194 | if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-font-name")) { | |
| 195 | const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name"); | |
| 14391 | 196 | |
| 197 | if (pref != NULL && strcmp(pref, "")) | |
| 198 | g_string_append_printf(style_string, | |
| 199 | "gtk-font-name = \"%s\"\n", | |
| 200 | pref); | |
| 11940 | 201 | } |
| 202 | ||
| 203 | if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")) { | |
| 204 | const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-key-theme-name"); | |
| 14391 | 205 | |
| 206 | if (pref != NULL && strcmp(pref, "")) | |
| 207 | g_string_append_printf(style_string, | |
| 208 | "gtk-key-theme-name = \"%s\"\n", | |
| 209 | pref); | |
| 11940 | 210 | } |
| 211 | ||
| 212 | g_string_append(style_string, "style \"gaimrc_style\" {\n"); | |
| 213 | ||
| 214 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 215 | if (gaim_prefs_get_bool(color_prefs_set[i])) { | |
| 14391 | 216 | const char *pref; |
| 217 | ||
| 11940 | 218 | prefbase = g_path_get_basename(color_prefs[i]); |
| 14391 | 219 | pref = gaim_prefs_get_string(color_prefs[i]); |
| 220 | ||
| 221 | if (pref != NULL && strcmp(pref, "")) | |
| 222 | g_string_append_printf(style_string, | |
| 223 | "%s = \"%s\"\n", | |
| 224 | prefbase, pref); | |
| 11940 | 225 | g_free(prefbase); |
| 226 | } | |
| 227 | } | |
| 228 | ||
| 229 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { | |
| 230 | if (gaim_prefs_get_bool(widget_size_prefs_set[i])) { | |
| 231 | prefbase = g_path_get_basename(widget_size_prefs[i]); | |
| 232 | g_string_append_printf(style_string, | |
| 233 | "%s = %d\n", prefbase, | |
| 234 | gaim_prefs_get_int(widget_size_prefs[i])); | |
| 235 | g_free(prefbase); | |
| 236 | } | |
| 237 | } | |
| 238 | ||
| 12973 | 239 | for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { |
| 240 | if (gaim_prefs_get_bool(widget_bool_prefs_set[i])) { | |
| 241 | prefbase = g_path_get_basename(widget_bool_prefs[i]); | |
| 242 | g_string_append_printf(style_string, | |
| 243 | "%s = %d\n", prefbase, | |
| 244 | gaim_prefs_get_bool(widget_bool_prefs[i])); | |
| 245 | g_free(prefbase); | |
| 246 | } | |
| 247 | } | |
| 248 | ||
| 11940 | 249 | g_string_append(style_string, "}"); |
| 250 | g_string_append(style_string, "widget_class \"*\" style \"gaimrc_style\"\n"); | |
| 251 | ||
| 252 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 253 | if (gaim_prefs_get_bool(font_prefs_set[i])) { | |
| 14391 | 254 | const char *pref; |
| 255 | ||
| 11940 | 256 | prefbase = g_path_get_basename(font_prefs[i]); |
| 14391 | 257 | pref = gaim_prefs_get_string(font_prefs[i]); |
| 258 | ||
| 259 | if (pref != NULL && strcmp(pref, "")) | |
| 260 | g_string_append_printf(style_string, | |
| 261 | "style \"%s_style\"\n" | |
| 262 | "{font_name = \"%s\"}\n" | |
| 263 | "widget \"%s\"" | |
| 264 | "style \"%s_style\"\n", | |
| 265 | prefbase, pref, | |
| 266 | prefbase, prefbase); | |
| 11940 | 267 | g_free(prefbase); |
| 268 | } | |
| 269 | } | |
| 270 | ||
| 12202 | 271 | gaim_util_write_data_to_file("gtkrc-2.0", style_string->str, -1); |
| 11940 | 272 | |
| 273 | g_string_free(style_string, TRUE); | |
| 274 | } | |
| 275 | ||
| 276 | static void | |
| 277 | gaimrc_reread(GtkWidget *widget, gpointer data) | |
| 278 | { | |
| 279 | gtk_rc_reparse_all(); | |
| 12973 | 280 | /* I don't know if this is necessary but if not it shouldn't hurt. */ |
| 11940 | 281 | gaimrc_make_changes(); |
| 282 | } | |
| 283 | ||
| 284 | static void | |
|
12816
5f93e09fa9a6
[gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents:
12600
diff
changeset
|
285 | gaimrc_pref_changed_cb(const char *name, GaimPrefType type, |
|
5f93e09fa9a6
[gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents:
12600
diff
changeset
|
286 | gconstpointer value, gpointer data) |
| 10584 | 287 | { |
| 12973 | 288 | gaimrc_make_changes(); |
| 10584 | 289 | } |
| 290 | ||
| 291 | static void | |
| 292 | gaimrc_color_response(GtkDialog *color_dialog, gint response, gpointer data) | |
| 293 | { | |
| 294 | int subscript = GPOINTER_TO_INT(data); | |
| 295 | ||
| 296 | if (response == GTK_RESPONSE_OK) { | |
| 297 | GtkWidget *colorsel = GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel; | |
| 298 | GdkColor color; | |
| 299 | char colorstr[8]; | |
| 300 | ||
| 301 | gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(colorsel), &color); | |
| 302 | ||
| 303 | g_snprintf(colorstr, sizeof(colorstr), "#%02X%02X%02X", | |
| 304 | color.red/256, color.green/256, color.blue/256); | |
| 305 | ||
| 306 | gaim_prefs_set_string(color_prefs[subscript], colorstr); | |
| 307 | } | |
| 308 | gtk_widget_destroy(GTK_WIDGET(color_dialog)); | |
| 309 | } | |
| 310 | ||
| 311 | static void | |
| 312 | gaimrc_set_color(GtkWidget *widget, gpointer data) | |
| 313 | { | |
| 314 | GtkWidget *color_dialog = NULL; | |
| 315 | GdkColor color; | |
| 316 | char title[128]; | |
| 14391 | 317 | const char *pref = NULL; |
| 10584 | 318 | int subscript = GPOINTER_TO_INT(data); |
| 319 | ||
| 320 | g_snprintf(title, sizeof(title), _("Select Color for %s"), | |
|
10586
fd1399d550fc
[gaim-migrate @ 11990]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10585
diff
changeset
|
321 | _(color_names[GPOINTER_TO_INT(data)])); |
| 10584 | 322 | color_dialog = gtk_color_selection_dialog_new(_("Select Color")); |
| 323 | g_signal_connect(G_OBJECT(color_dialog), "response", | |
| 324 | G_CALLBACK(gaimrc_color_response), data); | |
| 325 | ||
| 14391 | 326 | pref = gaim_prefs_get_string(color_prefs[subscript]); |
| 327 | ||
| 328 | if (pref != NULL && strcmp(pref, "")) { | |
| 329 | if (gdk_color_parse(pref, &color)) { | |
| 330 | gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel), &color); | |
| 331 | } | |
| 10584 | 332 | } |
| 333 | ||
| 334 | gtk_window_present(GTK_WINDOW(color_dialog)); | |
| 335 | } | |
| 336 | ||
| 337 | static void | |
| 338 | gaimrc_font_response(GtkDialog *font_dialog, gint response, gpointer data) | |
| 339 | { | |
| 340 | int subscript = GPOINTER_TO_INT(data); | |
| 341 | ||
| 342 | if (response == GTK_RESPONSE_OK) { | |
| 343 | char *fontname = NULL; | |
| 344 | ||
| 345 | fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog)); | |
| 346 | ||
| 347 | gaim_prefs_set_string(font_prefs[subscript], fontname); | |
| 348 | g_free(fontname); | |
| 349 | } | |
| 350 | gtk_widget_destroy(GTK_WIDGET(font_dialog)); | |
| 351 | } | |
| 352 | ||
| 353 | static void | |
| 354 | gaimrc_set_font(GtkWidget *widget, gpointer data) | |
| 355 | { | |
| 356 | GtkWidget *font_dialog = NULL; | |
| 357 | char title[128]; | |
| 14391 | 358 | const char *pref = NULL; |
| 10584 | 359 | int subscript = GPOINTER_TO_INT(data); |
| 360 | ||
| 361 | g_snprintf(title, sizeof(title), _("Select Font for %s"), | |
|
10586
fd1399d550fc
[gaim-migrate @ 11990]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10585
diff
changeset
|
362 | _(font_names[subscript])); |
| 10584 | 363 | font_dialog = gtk_font_selection_dialog_new(title); |
| 364 | g_signal_connect(G_OBJECT(font_dialog), "response", | |
| 365 | G_CALLBACK(gaimrc_font_response), data); | |
| 366 | ||
| 14391 | 367 | pref = gaim_prefs_get_string(font_prefs[subscript]); |
| 368 | ||
| 369 | if (pref != NULL && strcmp(pref, "")) { | |
| 370 | gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(font_dialog)->fontsel), pref); | |
| 10584 | 371 | } |
| 372 | ||
| 373 | gtk_window_present(GTK_WINDOW(font_dialog)); | |
| 374 | } | |
| 375 | ||
| 376 | static void | |
| 377 | gaimrc_font_response_special(GtkDialog *font_dialog, gint response, | |
| 378 | gpointer data) | |
| 379 | { | |
| 380 | if (response == GTK_RESPONSE_OK) { | |
| 381 | char *fontname = NULL; | |
| 382 | ||
| 383 | fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog)); | |
| 384 | ||
| 385 | gaim_prefs_set_string("/plugins/gtk/gaimrc/gtk-font-name", | |
| 386 | fontname); | |
| 387 | g_free(fontname); | |
| 388 | } | |
| 389 | gtk_widget_destroy(GTK_WIDGET(font_dialog)); | |
| 390 | } | |
| 391 | ||
| 392 | static void | |
| 393 | gaimrc_set_font_special(GtkWidget *widget, gpointer data) | |
| 394 | { | |
| 395 | GtkWidget *font_dialog = NULL; | |
| 14391 | 396 | const char *pref = NULL; |
| 10584 | 397 | |
| 398 | font_dialog = gtk_font_selection_dialog_new(_("Select Interface Font")); | |
| 399 | g_signal_connect(G_OBJECT(font_dialog), "response", | |
| 400 | G_CALLBACK(gaimrc_font_response_special), NULL); | |
| 401 | ||
| 14391 | 402 | pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name"); |
| 403 | ||
| 404 | if (pref != NULL && strcmp(pref, "")) { | |
| 405 | gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(font_dialog)->fontsel), pref); | |
| 10584 | 406 | } |
| 407 | ||
| 408 | gtk_window_present(GTK_WINDOW(font_dialog)); | |
| 409 | } | |
| 410 | ||
| 411 | static gboolean | |
| 412 | gaimrc_plugin_load(GaimPlugin *plugin) | |
| 413 | { | |
| 414 | gaimrc_make_changes(); | |
| 415 | ||
| 10587 | 416 | pref_callback = gaim_prefs_connect_callback(plugin, "/plugins/gtk/gaimrc", |
| 417 | gaimrc_pref_changed_cb, NULL); | |
| 10584 | 418 | |
| 419 | return TRUE; | |
| 420 | } | |
| 421 | ||
| 422 | static gboolean | |
| 423 | gaimrc_plugin_unload(GaimPlugin *plugin) | |
| 424 | { | |
| 425 | gaim_prefs_disconnect_callback(pref_callback); | |
| 426 | ||
| 427 | return TRUE; | |
| 428 | } | |
| 429 | ||
| 430 | static GtkWidget * | |
| 431 | gaimrc_get_config_frame(GaimPlugin *plugin) | |
| 432 | { | |
| 12546 | 433 | /* Note: Intentionally not using the size group argument to the |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
434 | * pidgin_prefs_labeled_* functions they only add the text label to |
| 12546 | 435 | * the size group not the whole thing, which isn't what I want. */ |
| 10584 | 436 | int i; |
|
12042
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
437 | char *tmp; |
| 12546 | 438 | GtkWidget *check = NULL, *widget = NULL; |
| 439 | GtkSizeGroup *labelsg = NULL, *widgetsg = NULL; | |
| 440 | GtkWidget *ret = NULL, *frame = NULL, *hbox = NULL, *vbox = NULL; | |
| 10584 | 441 | |
| 11940 | 442 | ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 443 | gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); | |
| 10584 | 444 | |
| 12546 | 445 | labelsg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| 446 | widgetsg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 10584 | 447 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
448 | frame = pidgin_make_frame(ret, _("General")); |
| 10584 | 449 | /* interface font */ |
| 11940 | 450 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 451 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 452 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
453 | check = pidgin_prefs_checkbox(_("GTK+ Interface Font"), |
| 10584 | 454 | "/plugins/gtk/gaimrc/set/gtk-font-name", |
| 455 | hbox); | |
| 12546 | 456 | gtk_size_group_add_widget(labelsg, check); |
| 10584 | 457 | |
| 458 | widget = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, | |
| 459 | GAIM_BUTTON_HORIZONTAL); | |
| 460 | gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); | |
| 12546 | 461 | gtk_size_group_add_widget(widgetsg, widget); |
| 10584 | 462 | gtk_widget_set_sensitive(widget, |
| 463 | gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-font-name")); | |
| 464 | g_signal_connect(G_OBJECT(check), "toggled", | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
465 | G_CALLBACK(pidgin_toggle_sensitive), widget); |
| 10584 | 466 | g_signal_connect(G_OBJECT(widget), "clicked", |
| 467 | G_CALLBACK(gaimrc_set_font_special), NULL); | |
| 468 | ||
| 469 | /* key theme name */ | |
| 11940 | 470 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 471 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 472 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
473 | check = pidgin_prefs_checkbox(_("GTK+ Text Shortcut Theme"), |
| 10584 | 474 | "/plugins/gtk/gaimrc/set/gtk-key-theme-name", |
| 475 | hbox); | |
| 12546 | 476 | gtk_size_group_add_widget(labelsg, check); |
| 10584 | 477 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
478 | widget = pidgin_prefs_labeled_entry(hbox, "", |
| 10584 | 479 | "/plugins/gtk/gaimrc/gtk-key-theme-name", |
| 480 | NULL); | |
| 12546 | 481 | /* |
| 482 | gtk_size_group_add_widget(widgetsg, widget); | |
| 483 | */ | |
| 10584 | 484 | gtk_widget_set_sensitive(widget, |
| 485 | gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")); | |
| 486 | g_signal_connect(G_OBJECT(check), "toggled", | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
487 | G_CALLBACK(pidgin_toggle_sensitive), widget); |
| 10584 | 488 | |
| 12973 | 489 | for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { |
| 490 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); | |
| 491 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
| 492 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
493 | check = pidgin_prefs_checkbox(_(widget_bool_names[i]), |
| 12973 | 494 | widget_bool_prefs_set[i], hbox); |
| 495 | gtk_size_group_add_widget(labelsg, check); | |
| 496 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
497 | widget_bool_widgets[i] = pidgin_prefs_checkbox("", widget_bool_prefs[i], hbox); |
| 12973 | 498 | /* |
| 499 | gtk_size_group_add_widget(widgetsb, widget_bool_widgets[i]); | |
| 500 | */ | |
| 501 | gtk_widget_set_sensitive(widget_bool_widgets[i], | |
| 502 | gaim_prefs_get_bool(widget_bool_prefs_set[i])); | |
| 503 | g_signal_connect(G_OBJECT(check), "toggled", | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
504 | G_CALLBACK(pidgin_toggle_sensitive), |
| 12973 | 505 | widget_bool_widgets[i]); |
| 506 | } | |
| 507 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
508 | frame = pidgin_make_frame(ret, _("Interface colors")); |
| 10584 | 509 | /* imhtml stuff */ |
| 510 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 11940 | 511 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 512 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 513 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
514 | check = pidgin_prefs_checkbox(_(color_names[i]), |
| 10584 | 515 | color_prefs_set[i], hbox); |
| 12546 | 516 | gtk_size_group_add_widget(labelsg, check); |
| 10584 | 517 | |
| 518 | color_widgets[i] = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_COLOR, GAIM_BUTTON_HORIZONTAL); | |
| 12546 | 519 | gtk_size_group_add_widget(widgetsg, color_widgets[i]); |
| 10584 | 520 | gtk_box_pack_start(GTK_BOX(hbox), color_widgets[i], FALSE, |
| 521 | FALSE, 0); | |
| 522 | gtk_widget_set_sensitive(color_widgets[i], | |
| 523 | gaim_prefs_get_bool(color_prefs_set[i])); | |
| 524 | g_signal_connect(G_OBJECT(check), "toggled", | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
525 | G_CALLBACK(pidgin_toggle_sensitive), |
| 10584 | 526 | color_widgets[i]); |
| 527 | g_signal_connect(G_OBJECT(color_widgets[i]), "clicked", | |
| 528 | G_CALLBACK(gaimrc_set_color), | |
| 529 | GINT_TO_POINTER(i)); | |
| 530 | } | |
| 531 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
532 | frame = pidgin_make_frame(ret, _("Widget Sizes")); |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
533 | /* widget size stuff */ |
| 10584 | 534 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { |
| 11940 | 535 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 536 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 537 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
538 | check = pidgin_prefs_checkbox(_(widget_size_names[i]), |
| 10584 | 539 | widget_size_prefs_set[i], hbox); |
| 12546 | 540 | gtk_size_group_add_widget(labelsg, check); |
| 10584 | 541 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
542 | widget_size_widgets[i] = pidgin_prefs_labeled_spin_button(hbox, "", widget_size_prefs[i], 0, 50, NULL); |
| 12546 | 543 | /* |
| 544 | gtk_size_group_add_widget(widgetsg, widget_size_widgets[i]); | |
| 545 | */ | |
| 10584 | 546 | gtk_widget_set_sensitive(widget_size_widgets[i], |
| 547 | gaim_prefs_get_bool(widget_size_prefs_set[i])); | |
| 548 | g_signal_connect(G_OBJECT(check), "toggled", | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
549 | G_CALLBACK(pidgin_toggle_sensitive), |
| 10584 | 550 | widget_size_widgets[i]); |
| 551 | } | |
| 552 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
553 | frame = pidgin_make_frame(ret, _("Fonts")); |
| 10584 | 554 | /* imhtml font stuff */ |
| 555 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 11940 | 556 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 557 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 558 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
559 | check = pidgin_prefs_checkbox(_(font_names[i]), |
| 10584 | 560 | font_prefs_set[i], hbox); |
| 12546 | 561 | gtk_size_group_add_widget(labelsg, check); |
| 10584 | 562 | |
| 563 | font_widgets[i] = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, GAIM_BUTTON_HORIZONTAL); | |
| 12546 | 564 | gtk_size_group_add_widget(widgetsg, font_widgets[i]); |
| 10584 | 565 | gtk_box_pack_start(GTK_BOX(hbox), font_widgets[i], FALSE, |
| 566 | FALSE, 0); | |
| 567 | gtk_widget_set_sensitive(font_widgets[i], | |
| 568 | gaim_prefs_get_bool(font_prefs_set[i])); | |
| 569 | g_signal_connect(G_OBJECT(check), "toggled", | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
570 | G_CALLBACK(pidgin_toggle_sensitive), |
| 10584 | 571 | font_widgets[i]); |
| 572 | g_signal_connect(G_OBJECT(font_widgets[i]), "clicked", | |
| 573 | G_CALLBACK(gaimrc_set_font), GINT_TO_POINTER(i)); | |
| 574 | } | |
| 575 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
576 | frame = pidgin_make_frame(ret, _("Tools")); |
| 11940 | 577 | |
| 578 | vbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); | |
| 579 | gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0); | |
| 580 | ||
| 12567 | 581 | tmp = g_strdup_printf(_("Write settings to %s%sgtkrc-2.0"), gaim_user_dir(), G_DIR_SEPARATOR_S); |
|
12042
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
582 | check = gtk_button_new_with_label(tmp); |
|
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
583 | g_free(tmp); |
| 11940 | 584 | gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); |
| 12546 | 585 | gtk_size_group_add_widget(labelsg, check); |
| 11940 | 586 | g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(gaimrc_write), |
| 587 | NULL); | |
| 588 | ||
| 589 | check = gtk_button_new_with_label(_("Re-read gtkrc files")); | |
| 590 | gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); | |
| 12546 | 591 | gtk_size_group_add_widget(labelsg, check); |
| 11940 | 592 | g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(gaimrc_reread), |
| 593 | NULL); | |
| 594 | ||
| 10584 | 595 | gtk_widget_show_all(ret); |
| 596 | return ret; | |
| 597 | } | |
| 598 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
599 | static PidginPluginUiInfo gaimrc_ui_info = |
| 10584 | 600 | { |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12567
diff
changeset
|
601 | gaimrc_get_config_frame, |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12567
diff
changeset
|
602 | 0 /* page_num (Reserved) */ |
| 10584 | 603 | }; |
| 604 | ||
| 605 | static GaimPluginInfo gaimrc_info = | |
| 606 | { | |
| 607 | GAIM_PLUGIN_MAGIC, | |
| 608 | GAIM_MAJOR_VERSION, | |
| 609 | GAIM_MINOR_VERSION, | |
| 610 | GAIM_PLUGIN_STANDARD, | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
611 | PIDGIN_PLUGIN_TYPE, |
| 10584 | 612 | 0, |
| 613 | NULL, | |
| 614 | GAIM_PRIORITY_DEFAULT, | |
| 615 | "gaimrc", | |
|
15442
2ff7f5308727
I think this is all the instances of 'Gaim' within pidgin/
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
616 | N_(PIDGIN_NAME " GTK+ Theme Control"), |
| 10584 | 617 | VERSION, |
| 618 | N_("Provides access to commonly used gtkrc settings."), | |
| 619 | N_("Provides access to commonly used gtkrc settings."), | |
| 620 | "Etan Reisner <deryni@eden.rutgers.edu>", | |
| 621 | GAIM_WEBSITE, | |
| 622 | gaimrc_plugin_load, | |
| 623 | gaimrc_plugin_unload, | |
| 624 | NULL, | |
| 625 | &gaimrc_ui_info, | |
| 626 | NULL, | |
| 627 | NULL, | |
| 628 | NULL | |
| 629 | }; | |
| 630 | ||
| 631 | static void | |
| 632 | gaimrc_init(GaimPlugin *plugin) | |
| 633 | { | |
| 634 | int i; | |
| 635 | ||
| 636 | gaim_prefs_add_none("/plugins"); | |
| 637 | gaim_prefs_add_none("/plugins/gtk"); | |
| 638 | gaim_prefs_add_none("/plugins/gtk/gaimrc"); | |
| 639 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set"); | |
| 640 | ||
| 641 | gaim_prefs_add_string("/plugins/gtk/gaimrc/gtk-font-name", ""); | |
| 642 | gaim_prefs_add_bool("/plugins/gtk/gaimrc/set/gtk-font-name", FALSE); | |
| 643 | ||
| 644 | gaim_prefs_add_string("/plugins/gtk/gaimrc/gtk-key-theme-name", ""); | |
| 645 | gaim_prefs_add_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name", FALSE); | |
| 646 | ||
| 647 | gaim_prefs_add_none("/plugins/gtk/gaimrc/color"); | |
| 648 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/color"); | |
| 649 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 650 | gaim_prefs_add_string(color_prefs[i], ""); | |
| 651 | gaim_prefs_add_bool(color_prefs_set[i], FALSE); | |
| 652 | } | |
| 653 | ||
| 654 | gaim_prefs_add_none("/plugins/gtk/gaimrc/size"); | |
| 655 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/size"); | |
| 656 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { | |
| 657 | gaim_prefs_add_int(widget_size_prefs[i], 0); | |
| 658 | gaim_prefs_add_bool(widget_size_prefs_set[i], FALSE); | |
| 659 | } | |
| 660 | ||
| 661 | gaim_prefs_add_none("/plugins/gtk/gaimrc/font"); | |
| 662 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/font"); | |
| 663 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 664 | gaim_prefs_add_string(font_prefs[i], ""); | |
| 665 | gaim_prefs_add_bool(font_prefs_set[i], FALSE); | |
| 666 | } | |
| 12973 | 667 | |
| 668 | gaim_prefs_add_none("/plugins/gtk/gaimrc/bool"); | |
| 669 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/bool"); | |
| 670 | for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { | |
| 671 | gaim_prefs_add_bool(widget_bool_prefs[i], TRUE); | |
| 672 | gaim_prefs_add_bool(widget_bool_prefs_set[i], FALSE); | |
| 673 | } | |
| 10584 | 674 | } |
| 675 | ||
| 676 | GAIM_INIT_PLUGIN(gaimrc, gaimrc_init, gaimrc_info) |