Fri, 11 Nov 2005 22:15:42 +0000
[gaim-migrate @ 14337]
Don't hardcode ~/.gaim. That wouldn't be right on Windows or if you're using -c. If anyone thinks this sucks, just revert it, I'm not attached to it.
| 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" | |
| 11940 | 25 | #include "util.c" |
| 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[] = { | |
| 48 | "/plugins/gtk/gaimrc/size/GtkTreeView::expander_size" | |
| 49 | }; | |
| 50 | static const char *widget_size_prefs_set[] = { | |
| 51 | "/plugins/gtk/gaimrc/set/size/GtkTreeView::expander_size" | |
| 52 | }; | |
| 53 | static const char *widget_size_names[] = { | |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
54 | N_("GtkTreeView Expander Size") |
| 10584 | 55 | }; |
| 56 | static GtkWidget *widget_size_widgets[G_N_ELEMENTS(widget_size_prefs)]; | |
| 57 | ||
| 58 | static const char *font_prefs[] = { | |
| 59 | "/plugins/gtk/gaimrc/font/*gaim_gtkconv_entry", | |
| 60 | "/plugins/gtk/gaimrc/font/*gaim_gtkconv_imhtml", | |
| 61 | "/plugins/gtk/gaimrc/font/*gaim_gtklog_imhtml", | |
| 62 | "/plugins/gtk/gaimrc/font/*gaim_gtkrequest_imhtml", | |
| 63 | "/plugins/gtk/gaimrc/font/*gaim_gtknotify_imhtml", | |
| 64 | }; | |
| 65 | static const char *font_prefs_set[] = { | |
| 66 | "/plugins/gtk/gaimrc/set/font/*gaim_gtkconv_entry", | |
| 67 | "/plugins/gtk/gaimrc/set/font/*gaim_gtkconv_imhtml", | |
| 68 | "/plugins/gtk/gaimrc/set/font/*gaim_gtklog_imhtml", | |
| 69 | "/plugins/gtk/gaimrc/set/font/*gaim_gtkrequest_imhtml", | |
| 70 | "/plugins/gtk/gaimrc/set/font/*gaim_gtknotify_imhtml", | |
| 71 | }; | |
| 72 | static const char *font_names[] = { | |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
73 | N_("Conversation Entry"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
74 | N_("Conversation History"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
75 | N_("Log Viewer"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
76 | N_("Request Dialog"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
77 | N_("Notify Dialog") |
| 10584 | 78 | }; |
| 79 | static GtkWidget *font_widgets[G_N_ELEMENTS(font_prefs)]; | |
| 80 | ||
| 81 | static void | |
| 82 | gaimrc_make_changes() | |
| 83 | { | |
| 84 | int i; | |
| 85 | GString *style_string = g_string_new(""); | |
| 86 | char *prefbase = NULL; | |
| 87 | ||
| 88 | if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-font-name")) { | |
| 89 | const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name"); | |
| 90 | g_string_append_printf(style_string, "gtk-font-name = \"%s\"\n", pref); | |
| 91 | } | |
| 92 | ||
| 93 | if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")) { | |
| 94 | const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-key-theme-name"); | |
| 95 | g_string_append_printf(style_string, "gtk-key-theme-name = \"%s\"\n", pref); | |
| 96 | } | |
| 97 | ||
| 98 | g_string_append(style_string, "style \"gaimrc_style\" {\n"); | |
| 99 | ||
| 100 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 101 | if (gaim_prefs_get_bool(color_prefs_set[i])) { | |
| 102 | prefbase = g_path_get_basename(color_prefs[i]); | |
| 103 | g_string_append_printf(style_string, | |
| 104 | "%s = \"%s\"\n", prefbase, | |
| 105 | gaim_prefs_get_string(color_prefs[i])); | |
| 106 | g_free(prefbase); | |
| 107 | } | |
| 108 | } | |
| 109 | ||
| 110 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { | |
| 111 | if (gaim_prefs_get_bool(widget_size_prefs_set[i])) { | |
| 112 | prefbase = g_path_get_basename(widget_size_prefs[i]); | |
| 113 | g_string_append_printf(style_string, | |
|
11862
5d4bc6d54688
[gaim-migrate @ 14153]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
114 | "%s = %d\n", prefbase, |
| 10584 | 115 | gaim_prefs_get_int(widget_size_prefs[i])); |
| 116 | g_free(prefbase); | |
| 117 | } | |
| 118 | } | |
| 119 | ||
| 120 | g_string_append(style_string, "}"); | |
| 121 | g_string_append(style_string, "widget_class \"*\" style \"gaimrc_style\"\n"); | |
| 122 | ||
| 123 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 124 | if (gaim_prefs_get_bool(font_prefs_set[i])) { | |
| 125 | prefbase = g_path_get_basename(font_prefs[i]); | |
| 126 | g_string_append_printf(style_string, | |
| 127 | "style \"%s_style\"\n" | |
| 128 | "{font_name = \"%s\"}\n" | |
| 129 | "widget \"%s\"" | |
| 130 | "style \"%s_style\"\n", prefbase, | |
| 131 | gaim_prefs_get_string(font_prefs[i]), | |
| 132 | prefbase, prefbase); | |
| 133 | g_free(prefbase); | |
| 134 | } | |
| 135 | } | |
| 136 | ||
| 137 | gtk_rc_parse_string(style_string->str); | |
| 138 | ||
| 139 | g_string_free(style_string, TRUE); | |
| 140 | } | |
| 141 | ||
| 142 | static void | |
| 11940 | 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(); | |
| 209 | } | |
| 210 | ||
| 211 | static void | |
| 10584 | 212 | gaimrc_pref_changed_cb(const char *name, GaimPrefType type, gpointer value, |
| 213 | gpointer data) | |
| 214 | { | |
| 215 | GString *style_string = g_string_new(""); | |
| 216 | char *prefbase = NULL; | |
| 217 | ||
| 218 | prefbase = g_path_get_basename(name); | |
| 219 | ||
| 220 | if (strncmp(name, "/plugins/gtk/gaimrc/color", 25) == 0) { | |
| 221 | g_string_printf(style_string, | |
| 222 | "style \"gaimrc_style\" { %s = \"%s\" }" | |
| 223 | "widget_class \"*\" style \"gaimrc_style\"", | |
| 224 | prefbase, (char *)value); | |
| 225 | } else if (strncmp(name, "/plugins/gtk/gaimrc/size", 24) == 0) { | |
| 226 | g_string_printf(style_string, | |
| 227 | "style \"gaimrc_style\" { %s = \"%d\" }" | |
| 228 | "widget_class \"*\" style \"gaimrc_style\"", | |
| 229 | prefbase, GPOINTER_TO_INT(value)); | |
| 230 | } else if (strncmp(name, "/plugins/gtk/gaimrc/font", 24) == 0) { | |
| 231 | g_string_printf(style_string, "style \"%s_style\"" | |
| 232 | "{ font_name = \"%s\" } widget \"%s\"" | |
| 233 | "style \"%s_style\"", | |
| 234 | prefbase, (char *)value, prefbase, prefbase); | |
| 235 | } else if (strncmp(name, "/plugins/gtk/gaimrc/set", 23) == 0) { | |
| 236 | if (value) | |
| 237 | gaimrc_make_changes(); | |
| 238 | g_string_free(style_string, TRUE); | |
|
11862
5d4bc6d54688
[gaim-migrate @ 14153]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
239 | g_free(prefbase); |
| 10584 | 240 | |
| 241 | return; | |
| 242 | } else { | |
| 243 | g_string_printf(style_string, "%s = \"%s\"", | |
| 244 | prefbase, (char *)value); | |
| 245 | } | |
| 246 | gtk_rc_parse_string(style_string->str); | |
| 247 | ||
| 248 | g_string_free(style_string, TRUE); | |
| 249 | g_free(prefbase); | |
| 250 | } | |
| 251 | ||
| 252 | static void | |
| 253 | gaimrc_color_response(GtkDialog *color_dialog, gint response, gpointer data) | |
| 254 | { | |
| 255 | int subscript = GPOINTER_TO_INT(data); | |
| 256 | ||
| 257 | if (response == GTK_RESPONSE_OK) { | |
| 258 | GtkWidget *colorsel = GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel; | |
| 259 | GdkColor color; | |
| 260 | char colorstr[8]; | |
| 261 | ||
| 262 | gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(colorsel), &color); | |
| 263 | ||
| 264 | g_snprintf(colorstr, sizeof(colorstr), "#%02X%02X%02X", | |
| 265 | color.red/256, color.green/256, color.blue/256); | |
| 266 | ||
| 267 | gaim_prefs_set_string(color_prefs[subscript], colorstr); | |
| 268 | } | |
| 269 | gtk_widget_destroy(GTK_WIDGET(color_dialog)); | |
| 270 | } | |
| 271 | ||
| 272 | static void | |
| 273 | gaimrc_set_color(GtkWidget *widget, gpointer data) | |
| 274 | { | |
| 275 | GtkWidget *color_dialog = NULL; | |
| 276 | GdkColor color; | |
| 277 | char title[128]; | |
| 278 | int subscript = GPOINTER_TO_INT(data); | |
| 279 | ||
| 280 | g_snprintf(title, sizeof(title), _("Select Color for %s"), | |
|
10586
fd1399d550fc
[gaim-migrate @ 11990]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10585
diff
changeset
|
281 | _(color_names[GPOINTER_TO_INT(data)])); |
| 10584 | 282 | color_dialog = gtk_color_selection_dialog_new(_("Select Color")); |
| 283 | g_signal_connect(G_OBJECT(color_dialog), "response", | |
| 284 | G_CALLBACK(gaimrc_color_response), data); | |
| 285 | ||
| 286 | if (gdk_color_parse(gaim_prefs_get_string(color_prefs[subscript]), | |
| 287 | &color)) { | |
| 288 | gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel), &color); | |
| 289 | } | |
| 290 | ||
| 291 | gtk_window_present(GTK_WINDOW(color_dialog)); | |
| 292 | } | |
| 293 | ||
| 294 | static void | |
| 295 | gaimrc_font_response(GtkDialog *font_dialog, gint response, gpointer data) | |
| 296 | { | |
| 297 | int subscript = GPOINTER_TO_INT(data); | |
| 298 | ||
| 299 | if (response == GTK_RESPONSE_OK) { | |
| 300 | char *fontname = NULL; | |
| 301 | ||
| 302 | fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog)); | |
| 303 | ||
| 304 | gaim_prefs_set_string(font_prefs[subscript], fontname); | |
| 305 | g_free(fontname); | |
| 306 | } | |
| 307 | gtk_widget_destroy(GTK_WIDGET(font_dialog)); | |
| 308 | } | |
| 309 | ||
| 310 | static void | |
| 311 | gaimrc_set_font(GtkWidget *widget, gpointer data) | |
| 312 | { | |
| 313 | GtkWidget *font_dialog = NULL; | |
| 314 | char title[128]; | |
| 315 | int subscript = GPOINTER_TO_INT(data); | |
| 316 | ||
| 317 | g_snprintf(title, sizeof(title), _("Select Font for %s"), | |
|
10586
fd1399d550fc
[gaim-migrate @ 11990]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10585
diff
changeset
|
318 | _(font_names[subscript])); |
| 10584 | 319 | font_dialog = gtk_font_selection_dialog_new(title); |
| 320 | g_signal_connect(G_OBJECT(font_dialog), "response", | |
| 321 | G_CALLBACK(gaimrc_font_response), data); | |
| 322 | ||
| 323 | /* TODO Figure out a way to test for the presence of a value in the | |
| 324 | * actual pref | |
| 325 | if (gaim_prefs_get_bool(font_prefs[subscript])) { | |
| 326 | gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(font_dialog)->fontsel), gaim_prefs_get_string(font_prefs[subscript])); | |
| 327 | } | |
| 328 | */ | |
| 329 | ||
| 330 | gtk_window_present(GTK_WINDOW(font_dialog)); | |
| 331 | } | |
| 332 | ||
| 333 | static void | |
| 334 | gaimrc_font_response_special(GtkDialog *font_dialog, gint response, | |
| 335 | gpointer data) | |
| 336 | { | |
| 337 | if (response == GTK_RESPONSE_OK) { | |
| 338 | char *fontname = NULL; | |
| 339 | ||
| 340 | fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog)); | |
| 341 | ||
| 342 | gaim_prefs_set_string("/plugins/gtk/gaimrc/gtk-font-name", | |
| 343 | fontname); | |
| 344 | g_free(fontname); | |
| 345 | } | |
| 346 | gtk_widget_destroy(GTK_WIDGET(font_dialog)); | |
| 347 | } | |
| 348 | ||
| 349 | static void | |
| 350 | gaimrc_set_font_special(GtkWidget *widget, gpointer data) | |
| 351 | { | |
| 352 | GtkWidget *font_dialog = NULL; | |
| 353 | const char *font = NULL; | |
| 354 | ||
| 355 | font_dialog = gtk_font_selection_dialog_new(_("Select Interface Font")); | |
| 356 | g_signal_connect(G_OBJECT(font_dialog), "response", | |
| 357 | G_CALLBACK(gaimrc_font_response_special), NULL); | |
| 358 | ||
| 359 | font = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name"); | |
| 360 | /* TODO Figure out a way to test for the presence of a value in the | |
| 361 | * actual pref | |
| 362 | printf("font - %s.\n", font); | |
| 363 | if (font != NULL && font != "") { | |
| 364 | 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")); | |
| 365 | } | |
| 366 | */ | |
| 367 | ||
| 368 | gtk_window_present(GTK_WINDOW(font_dialog)); | |
| 369 | } | |
| 370 | ||
| 371 | static gboolean | |
| 372 | gaimrc_plugin_load(GaimPlugin *plugin) | |
| 373 | { | |
| 374 | gaimrc_make_changes(); | |
| 375 | ||
| 10587 | 376 | pref_callback = gaim_prefs_connect_callback(plugin, "/plugins/gtk/gaimrc", |
| 377 | gaimrc_pref_changed_cb, NULL); | |
| 10584 | 378 | |
| 379 | return TRUE; | |
| 380 | } | |
| 381 | ||
| 382 | static gboolean | |
| 383 | gaimrc_plugin_unload(GaimPlugin *plugin) | |
| 384 | { | |
| 385 | gaim_prefs_disconnect_callback(pref_callback); | |
| 386 | ||
| 387 | return TRUE; | |
| 388 | } | |
| 389 | ||
| 390 | static GtkWidget * | |
| 391 | gaimrc_get_config_frame(GaimPlugin *plugin) | |
| 392 | { | |
| 11940 | 393 | GtkWidget *ret = NULL, *frame = NULL, *hbox = NULL, *vbox = NULL; |
| 10584 | 394 | /* |
| 395 | GtkWidget *check = NULL, *widget = NULL, *label = NULL; | |
| 396 | */ | |
| 397 | GtkWidget *check = NULL, *widget = NULL; | |
| 398 | GtkSizeGroup *sg = NULL; | |
| 399 | /* | |
| 400 | char sample[7] = "Sample"; | |
| 401 | */ | |
| 402 | int i; | |
|
12042
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
403 | char *tmp; |
| 10584 | 404 | |
| 11940 | 405 | ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 406 | gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); | |
| 10584 | 407 | |
| 408 | sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 409 | ||
| 410 | frame = gaim_gtk_make_frame(ret, "General"); | |
| 411 | /* interface font */ | |
| 11940 | 412 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 413 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 414 | ||
|
10814
7e17cb56b019
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10587
diff
changeset
|
415 | check = gaim_gtk_prefs_checkbox(_("GTK+ Interface Font"), |
| 10584 | 416 | "/plugins/gtk/gaimrc/set/gtk-font-name", |
| 417 | hbox); | |
| 418 | gtk_size_group_add_widget(sg, check); | |
| 419 | ||
| 420 | widget = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, | |
| 421 | GAIM_BUTTON_HORIZONTAL); | |
| 422 | gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); | |
| 423 | gtk_widget_set_sensitive(widget, | |
| 424 | gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-font-name")); | |
| 425 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 426 | G_CALLBACK(gaim_gtk_toggle_sensitive), widget); | |
| 427 | g_signal_connect(G_OBJECT(widget), "clicked", | |
| 428 | G_CALLBACK(gaimrc_set_font_special), NULL); | |
| 429 | ||
| 430 | /* key theme name */ | |
| 11940 | 431 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 432 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 433 | ||
|
10814
7e17cb56b019
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10587
diff
changeset
|
434 | check = gaim_gtk_prefs_checkbox(_("GTK+ Text Shortcut Theme"), |
| 10584 | 435 | "/plugins/gtk/gaimrc/set/gtk-key-theme-name", |
| 436 | hbox); | |
| 437 | gtk_size_group_add_widget(sg, check); | |
| 438 | ||
| 439 | widget = gaim_gtk_prefs_labeled_entry(hbox, "", | |
| 440 | "/plugins/gtk/gaimrc/gtk-key-theme-name", | |
| 441 | NULL); | |
| 442 | gtk_widget_set_sensitive(widget, | |
| 443 | gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")); | |
| 444 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 445 | G_CALLBACK(gaim_gtk_toggle_sensitive), widget); | |
| 446 | ||
| 447 | frame = gaim_gtk_make_frame(ret, "Interface colors"); | |
| 448 | /* imhtml stuff */ | |
| 449 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 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 | ||
| 453 | check = gaim_gtk_prefs_checkbox(_(color_names[i]), | |
| 454 | color_prefs_set[i], hbox); | |
| 455 | gtk_size_group_add_widget(sg, check); | |
| 456 | ||
| 457 | color_widgets[i] = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_COLOR, GAIM_BUTTON_HORIZONTAL); | |
| 458 | gtk_size_group_add_widget(sg, color_widgets[i]); | |
| 459 | gtk_box_pack_start(GTK_BOX(hbox), color_widgets[i], FALSE, | |
| 460 | FALSE, 0); | |
| 461 | gtk_widget_set_sensitive(color_widgets[i], | |
| 462 | gaim_prefs_get_bool(color_prefs_set[i])); | |
| 463 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 464 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 465 | color_widgets[i]); | |
| 466 | g_signal_connect(G_OBJECT(color_widgets[i]), "clicked", | |
| 467 | G_CALLBACK(gaimrc_set_color), | |
| 468 | GINT_TO_POINTER(i)); | |
| 469 | } | |
| 470 | ||
| 471 | frame = gaim_gtk_make_frame(ret, "Widget Sizes"); | |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
472 | /* widget size stuff */ |
| 10584 | 473 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { |
| 11940 | 474 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 475 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 476 | ||
| 477 | check = gaim_gtk_prefs_checkbox(_(widget_size_names[i]), | |
| 478 | widget_size_prefs_set[i], hbox); | |
| 479 | gtk_size_group_add_widget(sg, check); | |
| 480 | ||
| 481 | widget_size_widgets[i] = gaim_gtk_prefs_labeled_spin_button(hbox, "", widget_size_prefs[i], 0, 50, sg); | |
| 482 | gtk_widget_set_sensitive(widget_size_widgets[i], | |
| 483 | gaim_prefs_get_bool(widget_size_prefs_set[i])); | |
| 484 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 485 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 486 | widget_size_widgets[i]); | |
| 487 | } | |
| 488 | ||
| 489 | frame = gaim_gtk_make_frame(ret, "Fonts"); | |
| 490 | /* imhtml font stuff */ | |
| 491 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 11940 | 492 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 493 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 494 | ||
| 495 | check = gaim_gtk_prefs_checkbox(_(font_names[i]), | |
| 496 | font_prefs_set[i], hbox); | |
| 497 | gtk_size_group_add_widget(sg, check); | |
| 498 | ||
| 499 | font_widgets[i] = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, GAIM_BUTTON_HORIZONTAL); | |
| 500 | gtk_size_group_add_widget(sg, font_widgets[i]); | |
| 501 | gtk_box_pack_start(GTK_BOX(hbox), font_widgets[i], FALSE, | |
| 502 | FALSE, 0); | |
| 503 | gtk_widget_set_sensitive(font_widgets[i], | |
| 504 | gaim_prefs_get_bool(font_prefs_set[i])); | |
| 505 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 506 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 507 | font_widgets[i]); | |
| 508 | g_signal_connect(G_OBJECT(font_widgets[i]), "clicked", | |
| 509 | G_CALLBACK(gaimrc_set_font), GINT_TO_POINTER(i)); | |
| 510 | } | |
| 511 | ||
| 11940 | 512 | frame = gaim_gtk_make_frame(ret, "General"); |
| 513 | ||
| 514 | vbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); | |
| 515 | gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0); | |
| 516 | ||
|
12042
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
517 | tmp = g_strdup_printf(_("Write a gtkrc file with these settings to: %s"), gaim_user_dir()); |
|
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
518 | check = gtk_button_new_with_label(tmp); |
|
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
519 | g_free(tmp); |
| 11940 | 520 | gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); |
| 521 | gtk_size_group_add_widget(sg, check); | |
| 522 | g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(gaimrc_write), | |
| 523 | NULL); | |
| 524 | ||
| 525 | check = gtk_button_new_with_label(_("Re-read gtkrc files")); | |
| 526 | gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); | |
| 527 | gtk_size_group_add_widget(sg, check); | |
| 528 | g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(gaimrc_reread), | |
| 529 | NULL); | |
| 530 | ||
| 10584 | 531 | gtk_widget_show_all(ret); |
| 532 | return ret; | |
| 533 | } | |
| 534 | ||
| 535 | static GaimGtkPluginUiInfo gaimrc_ui_info = | |
| 536 | { | |
| 537 | gaimrc_get_config_frame | |
| 538 | }; | |
| 539 | ||
| 540 | static GaimPluginInfo gaimrc_info = | |
| 541 | { | |
| 542 | GAIM_PLUGIN_MAGIC, | |
| 543 | GAIM_MAJOR_VERSION, | |
| 544 | GAIM_MINOR_VERSION, | |
| 545 | GAIM_PLUGIN_STANDARD, | |
| 546 | GAIM_GTK_PLUGIN_TYPE, | |
| 547 | 0, | |
| 548 | NULL, | |
| 549 | GAIM_PRIORITY_DEFAULT, | |
| 550 | "gaimrc", | |
| 551 | N_("Gaim GTK+ Theme Control"), | |
| 552 | VERSION, | |
| 553 | N_("Provides access to commonly used gtkrc settings."), | |
| 554 | N_("Provides access to commonly used gtkrc settings."), | |
| 555 | "Etan Reisner <deryni@eden.rutgers.edu>", | |
| 556 | GAIM_WEBSITE, | |
| 557 | gaimrc_plugin_load, | |
| 558 | gaimrc_plugin_unload, | |
| 559 | NULL, | |
| 560 | &gaimrc_ui_info, | |
| 561 | NULL, | |
| 562 | NULL, | |
| 563 | NULL | |
| 564 | }; | |
| 565 | ||
| 566 | static void | |
| 567 | gaimrc_init(GaimPlugin *plugin) | |
| 568 | { | |
| 569 | int i; | |
| 570 | ||
| 571 | gaim_prefs_add_none("/plugins"); | |
| 572 | gaim_prefs_add_none("/plugins/gtk"); | |
| 573 | gaim_prefs_add_none("/plugins/gtk/gaimrc"); | |
| 574 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set"); | |
| 575 | ||
| 576 | gaim_prefs_add_string("/plugins/gtk/gaimrc/gtk-font-name", ""); | |
| 577 | gaim_prefs_add_bool("/plugins/gtk/gaimrc/set/gtk-font-name", FALSE); | |
| 578 | ||
| 579 | gaim_prefs_add_string("/plugins/gtk/gaimrc/gtk-key-theme-name", ""); | |
| 580 | gaim_prefs_add_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name", FALSE); | |
| 581 | ||
| 582 | gaim_prefs_add_none("/plugins/gtk/gaimrc/color"); | |
| 583 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/color"); | |
| 584 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 585 | gaim_prefs_add_string(color_prefs[i], ""); | |
| 586 | gaim_prefs_add_bool(color_prefs_set[i], FALSE); | |
| 587 | } | |
| 588 | ||
| 589 | gaim_prefs_add_none("/plugins/gtk/gaimrc/size"); | |
| 590 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/size"); | |
| 591 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { | |
| 592 | gaim_prefs_add_int(widget_size_prefs[i], 0); | |
| 593 | gaim_prefs_add_bool(widget_size_prefs_set[i], FALSE); | |
| 594 | } | |
| 595 | ||
| 596 | gaim_prefs_add_none("/plugins/gtk/gaimrc/font"); | |
| 597 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/font"); | |
| 598 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 599 | gaim_prefs_add_string(font_prefs[i], ""); | |
| 600 | gaim_prefs_add_bool(font_prefs_set[i], FALSE); | |
| 601 | } | |
| 602 | } | |
| 603 | ||
| 604 | GAIM_INIT_PLUGIN(gaimrc, gaimrc_init, gaimrc_info) |