Mon, 31 Oct 2005 06:06:14 +0000
[gaim-migrate @ 14218]
Better error handling for Howl when your mDNS daemon is not running
| 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" | |
| 25 | #include "version.h" | |
| 26 | ||
| 27 | static guint pref_callback; | |
| 28 | ||
| 29 | static const char *color_prefs[] = { | |
| 30 | "/plugins/gtk/gaimrc/color/GtkWidget::cursor-color", | |
| 31 | "/plugins/gtk/gaimrc/color/GtkWidget::secondary-cursor-color", | |
| 32 | "/plugins/gtk/gaimrc/color/GtkIMHtml::hyperlink-color" | |
| 33 | }; | |
| 34 | static const char *color_prefs_set[] = { | |
| 35 | "/plugins/gtk/gaimrc/set/color/GtkWidget::cursor-color", | |
| 36 | "/plugins/gtk/gaimrc/set/color/GtkWidget::secondary-cursor-color", | |
| 37 | "/plugins/gtk/gaimrc/set/color/GtkIMHtml::hyperlink-color" | |
| 38 | }; | |
| 39 | static const char *color_names[] = { | |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
40 | N_("Cursor Color"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
41 | N_("Secondary Cursor Color"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
42 | N_("Hyperlink Color") |
| 10584 | 43 | }; |
| 44 | static GtkWidget *color_widgets[G_N_ELEMENTS(color_prefs)]; | |
| 45 | ||
| 46 | static const char *widget_size_prefs[] = { | |
| 47 | "/plugins/gtk/gaimrc/size/GtkTreeView::expander_size" | |
| 48 | }; | |
| 49 | static const char *widget_size_prefs_set[] = { | |
| 50 | "/plugins/gtk/gaimrc/set/size/GtkTreeView::expander_size" | |
| 51 | }; | |
| 52 | static const char *widget_size_names[] = { | |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
53 | N_("GtkTreeView Expander Size") |
| 10584 | 54 | }; |
| 55 | static GtkWidget *widget_size_widgets[G_N_ELEMENTS(widget_size_prefs)]; | |
| 56 | ||
| 57 | static const char *font_prefs[] = { | |
| 58 | "/plugins/gtk/gaimrc/font/*gaim_gtkconv_entry", | |
| 59 | "/plugins/gtk/gaimrc/font/*gaim_gtkconv_imhtml", | |
| 60 | "/plugins/gtk/gaimrc/font/*gaim_gtklog_imhtml", | |
| 61 | "/plugins/gtk/gaimrc/font/*gaim_gtkrequest_imhtml", | |
| 62 | "/plugins/gtk/gaimrc/font/*gaim_gtknotify_imhtml", | |
| 63 | }; | |
| 64 | static const char *font_prefs_set[] = { | |
| 65 | "/plugins/gtk/gaimrc/set/font/*gaim_gtkconv_entry", | |
| 66 | "/plugins/gtk/gaimrc/set/font/*gaim_gtkconv_imhtml", | |
| 67 | "/plugins/gtk/gaimrc/set/font/*gaim_gtklog_imhtml", | |
| 68 | "/plugins/gtk/gaimrc/set/font/*gaim_gtkrequest_imhtml", | |
| 69 | "/plugins/gtk/gaimrc/set/font/*gaim_gtknotify_imhtml", | |
| 70 | }; | |
| 71 | static const char *font_names[] = { | |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
72 | N_("Conversation Entry"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
73 | N_("Conversation History"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
74 | N_("Log Viewer"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
75 | N_("Request Dialog"), |
|
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
76 | N_("Notify Dialog") |
| 10584 | 77 | }; |
| 78 | static GtkWidget *font_widgets[G_N_ELEMENTS(font_prefs)]; | |
| 79 | ||
| 80 | static void | |
| 81 | gaimrc_make_changes() | |
| 82 | { | |
| 83 | int i; | |
| 84 | GString *style_string = g_string_new(""); | |
| 85 | char *prefbase = NULL; | |
| 86 | ||
| 87 | if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-font-name")) { | |
| 88 | const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name"); | |
| 89 | g_string_append_printf(style_string, "gtk-font-name = \"%s\"\n", pref); | |
| 90 | } | |
| 91 | ||
| 92 | if (gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")) { | |
| 93 | const char *pref = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-key-theme-name"); | |
| 94 | g_string_append_printf(style_string, "gtk-key-theme-name = \"%s\"\n", pref); | |
| 95 | } | |
| 96 | ||
| 97 | g_string_append(style_string, "style \"gaimrc_style\" {\n"); | |
| 98 | ||
| 99 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 100 | if (gaim_prefs_get_bool(color_prefs_set[i])) { | |
| 101 | prefbase = g_path_get_basename(color_prefs[i]); | |
| 102 | g_string_append_printf(style_string, | |
| 103 | "%s = \"%s\"\n", prefbase, | |
| 104 | gaim_prefs_get_string(color_prefs[i])); | |
| 105 | g_free(prefbase); | |
| 106 | } | |
| 107 | } | |
| 108 | ||
| 109 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { | |
| 110 | if (gaim_prefs_get_bool(widget_size_prefs_set[i])) { | |
| 111 | prefbase = g_path_get_basename(widget_size_prefs[i]); | |
| 112 | g_string_append_printf(style_string, | |
|
11862
5d4bc6d54688
[gaim-migrate @ 14153]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
113 | "%s = %d\n", prefbase, |
| 10584 | 114 | gaim_prefs_get_int(widget_size_prefs[i])); |
| 115 | g_free(prefbase); | |
| 116 | } | |
| 117 | } | |
| 118 | ||
| 119 | g_string_append(style_string, "}"); | |
| 120 | g_string_append(style_string, "widget_class \"*\" style \"gaimrc_style\"\n"); | |
| 121 | ||
| 122 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 123 | if (gaim_prefs_get_bool(font_prefs_set[i])) { | |
| 124 | prefbase = g_path_get_basename(font_prefs[i]); | |
| 125 | g_string_append_printf(style_string, | |
| 126 | "style \"%s_style\"\n" | |
| 127 | "{font_name = \"%s\"}\n" | |
| 128 | "widget \"%s\"" | |
| 129 | "style \"%s_style\"\n", prefbase, | |
| 130 | gaim_prefs_get_string(font_prefs[i]), | |
| 131 | prefbase, prefbase); | |
| 132 | g_free(prefbase); | |
| 133 | } | |
| 134 | } | |
| 135 | ||
| 136 | gtk_rc_parse_string(style_string->str); | |
| 137 | ||
| 138 | g_string_free(style_string, TRUE); | |
| 139 | } | |
| 140 | ||
| 141 | static void | |
| 142 | gaimrc_pref_changed_cb(const char *name, GaimPrefType type, gpointer value, | |
| 143 | gpointer data) | |
| 144 | { | |
| 145 | GString *style_string = g_string_new(""); | |
| 146 | char *prefbase = NULL; | |
| 147 | ||
| 148 | prefbase = g_path_get_basename(name); | |
| 149 | ||
| 150 | if (strncmp(name, "/plugins/gtk/gaimrc/color", 25) == 0) { | |
| 151 | g_string_printf(style_string, | |
| 152 | "style \"gaimrc_style\" { %s = \"%s\" }" | |
| 153 | "widget_class \"*\" style \"gaimrc_style\"", | |
| 154 | prefbase, (char *)value); | |
| 155 | } else if (strncmp(name, "/plugins/gtk/gaimrc/size", 24) == 0) { | |
| 156 | g_string_printf(style_string, | |
| 157 | "style \"gaimrc_style\" { %s = \"%d\" }" | |
| 158 | "widget_class \"*\" style \"gaimrc_style\"", | |
| 159 | prefbase, GPOINTER_TO_INT(value)); | |
| 160 | } else if (strncmp(name, "/plugins/gtk/gaimrc/font", 24) == 0) { | |
| 161 | g_string_printf(style_string, "style \"%s_style\"" | |
| 162 | "{ font_name = \"%s\" } widget \"%s\"" | |
| 163 | "style \"%s_style\"", | |
| 164 | prefbase, (char *)value, prefbase, prefbase); | |
| 165 | } else if (strncmp(name, "/plugins/gtk/gaimrc/set", 23) == 0) { | |
| 166 | if (value) | |
| 167 | gaimrc_make_changes(); | |
| 168 | g_string_free(style_string, TRUE); | |
|
11862
5d4bc6d54688
[gaim-migrate @ 14153]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
169 | g_free(prefbase); |
| 10584 | 170 | |
| 171 | return; | |
| 172 | } else { | |
| 173 | g_string_printf(style_string, "%s = \"%s\"", | |
| 174 | prefbase, (char *)value); | |
| 175 | } | |
| 176 | gtk_rc_parse_string(style_string->str); | |
| 177 | ||
| 178 | g_string_free(style_string, TRUE); | |
| 179 | g_free(prefbase); | |
| 180 | } | |
| 181 | ||
| 182 | static void | |
| 183 | gaimrc_color_response(GtkDialog *color_dialog, gint response, gpointer data) | |
| 184 | { | |
| 185 | int subscript = GPOINTER_TO_INT(data); | |
| 186 | ||
| 187 | if (response == GTK_RESPONSE_OK) { | |
| 188 | GtkWidget *colorsel = GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel; | |
| 189 | GdkColor color; | |
| 190 | char colorstr[8]; | |
| 191 | ||
| 192 | gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(colorsel), &color); | |
| 193 | ||
| 194 | g_snprintf(colorstr, sizeof(colorstr), "#%02X%02X%02X", | |
| 195 | color.red/256, color.green/256, color.blue/256); | |
| 196 | ||
| 197 | gaim_prefs_set_string(color_prefs[subscript], colorstr); | |
| 198 | } | |
| 199 | gtk_widget_destroy(GTK_WIDGET(color_dialog)); | |
| 200 | } | |
| 201 | ||
| 202 | static void | |
| 203 | gaimrc_set_color(GtkWidget *widget, gpointer data) | |
| 204 | { | |
| 205 | GtkWidget *color_dialog = NULL; | |
| 206 | GdkColor color; | |
| 207 | char title[128]; | |
| 208 | int subscript = GPOINTER_TO_INT(data); | |
| 209 | ||
| 210 | g_snprintf(title, sizeof(title), _("Select Color for %s"), | |
|
10586
fd1399d550fc
[gaim-migrate @ 11990]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10585
diff
changeset
|
211 | _(color_names[GPOINTER_TO_INT(data)])); |
| 10584 | 212 | color_dialog = gtk_color_selection_dialog_new(_("Select Color")); |
| 213 | g_signal_connect(G_OBJECT(color_dialog), "response", | |
| 214 | G_CALLBACK(gaimrc_color_response), data); | |
| 215 | ||
| 216 | if (gdk_color_parse(gaim_prefs_get_string(color_prefs[subscript]), | |
| 217 | &color)) { | |
| 218 | gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel), &color); | |
| 219 | } | |
| 220 | ||
| 221 | gtk_window_present(GTK_WINDOW(color_dialog)); | |
| 222 | } | |
| 223 | ||
| 224 | static void | |
| 225 | gaimrc_font_response(GtkDialog *font_dialog, gint response, gpointer data) | |
| 226 | { | |
| 227 | int subscript = GPOINTER_TO_INT(data); | |
| 228 | ||
| 229 | if (response == GTK_RESPONSE_OK) { | |
| 230 | char *fontname = NULL; | |
| 231 | ||
| 232 | fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog)); | |
| 233 | ||
| 234 | gaim_prefs_set_string(font_prefs[subscript], fontname); | |
| 235 | g_free(fontname); | |
| 236 | } | |
| 237 | gtk_widget_destroy(GTK_WIDGET(font_dialog)); | |
| 238 | } | |
| 239 | ||
| 240 | static void | |
| 241 | gaimrc_set_font(GtkWidget *widget, gpointer data) | |
| 242 | { | |
| 243 | GtkWidget *font_dialog = NULL; | |
| 244 | char title[128]; | |
| 245 | int subscript = GPOINTER_TO_INT(data); | |
| 246 | ||
| 247 | g_snprintf(title, sizeof(title), _("Select Font for %s"), | |
|
10586
fd1399d550fc
[gaim-migrate @ 11990]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10585
diff
changeset
|
248 | _(font_names[subscript])); |
| 10584 | 249 | font_dialog = gtk_font_selection_dialog_new(title); |
| 250 | g_signal_connect(G_OBJECT(font_dialog), "response", | |
| 251 | G_CALLBACK(gaimrc_font_response), data); | |
| 252 | ||
| 253 | /* TODO Figure out a way to test for the presence of a value in the | |
| 254 | * actual pref | |
| 255 | if (gaim_prefs_get_bool(font_prefs[subscript])) { | |
| 256 | gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(font_dialog)->fontsel), gaim_prefs_get_string(font_prefs[subscript])); | |
| 257 | } | |
| 258 | */ | |
| 259 | ||
| 260 | gtk_window_present(GTK_WINDOW(font_dialog)); | |
| 261 | } | |
| 262 | ||
| 263 | static void | |
| 264 | gaimrc_font_response_special(GtkDialog *font_dialog, gint response, | |
| 265 | gpointer data) | |
| 266 | { | |
| 267 | if (response == GTK_RESPONSE_OK) { | |
| 268 | char *fontname = NULL; | |
| 269 | ||
| 270 | fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog)); | |
| 271 | ||
| 272 | gaim_prefs_set_string("/plugins/gtk/gaimrc/gtk-font-name", | |
| 273 | fontname); | |
| 274 | g_free(fontname); | |
| 275 | } | |
| 276 | gtk_widget_destroy(GTK_WIDGET(font_dialog)); | |
| 277 | } | |
| 278 | ||
| 279 | static void | |
| 280 | gaimrc_set_font_special(GtkWidget *widget, gpointer data) | |
| 281 | { | |
| 282 | GtkWidget *font_dialog = NULL; | |
| 283 | const char *font = NULL; | |
| 284 | ||
| 285 | font_dialog = gtk_font_selection_dialog_new(_("Select Interface Font")); | |
| 286 | g_signal_connect(G_OBJECT(font_dialog), "response", | |
| 287 | G_CALLBACK(gaimrc_font_response_special), NULL); | |
| 288 | ||
| 289 | font = gaim_prefs_get_string("/plugins/gtk/gaimrc/gtk-font-name"); | |
| 290 | /* TODO Figure out a way to test for the presence of a value in the | |
| 291 | * actual pref | |
| 292 | printf("font - %s.\n", font); | |
| 293 | if (font != NULL && font != "") { | |
| 294 | 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")); | |
| 295 | } | |
| 296 | */ | |
| 297 | ||
| 298 | gtk_window_present(GTK_WINDOW(font_dialog)); | |
| 299 | } | |
| 300 | ||
| 301 | static gboolean | |
| 302 | gaimrc_plugin_load(GaimPlugin *plugin) | |
| 303 | { | |
| 304 | gaimrc_make_changes(); | |
| 305 | ||
| 10587 | 306 | pref_callback = gaim_prefs_connect_callback(plugin, "/plugins/gtk/gaimrc", |
| 307 | gaimrc_pref_changed_cb, NULL); | |
| 10584 | 308 | |
| 309 | return TRUE; | |
| 310 | } | |
| 311 | ||
| 312 | static gboolean | |
| 313 | gaimrc_plugin_unload(GaimPlugin *plugin) | |
| 314 | { | |
| 315 | gaim_prefs_disconnect_callback(pref_callback); | |
| 316 | ||
| 317 | return TRUE; | |
| 318 | } | |
| 319 | ||
| 320 | static GtkWidget * | |
| 321 | gaimrc_get_config_frame(GaimPlugin *plugin) | |
| 322 | { | |
| 323 | GtkWidget *ret = NULL, *frame = NULL, *hbox = NULL; | |
| 324 | /* | |
| 325 | GtkWidget *check = NULL, *widget = NULL, *label = NULL; | |
| 326 | */ | |
| 327 | GtkWidget *check = NULL, *widget = NULL; | |
| 328 | GtkSizeGroup *sg = NULL; | |
| 329 | /* | |
| 330 | char sample[7] = "Sample"; | |
| 331 | */ | |
| 332 | int i; | |
| 333 | ||
| 334 | ret = gtk_vbox_new(FALSE, 18); | |
| 335 | gtk_container_set_border_width(GTK_CONTAINER(ret), 12); | |
| 336 | ||
| 337 | sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 338 | ||
| 339 | frame = gaim_gtk_make_frame(ret, "General"); | |
| 340 | /* interface font */ | |
| 341 | hbox = gtk_hbox_new(FALSE, 18); | |
| 342 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
| 343 | ||
|
10814
7e17cb56b019
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10587
diff
changeset
|
344 | check = gaim_gtk_prefs_checkbox(_("GTK+ Interface Font"), |
| 10584 | 345 | "/plugins/gtk/gaimrc/set/gtk-font-name", |
| 346 | hbox); | |
| 347 | gtk_size_group_add_widget(sg, check); | |
| 348 | ||
| 349 | widget = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, | |
| 350 | GAIM_BUTTON_HORIZONTAL); | |
| 351 | gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); | |
| 352 | gtk_widget_set_sensitive(widget, | |
| 353 | gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-font-name")); | |
| 354 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 355 | G_CALLBACK(gaim_gtk_toggle_sensitive), widget); | |
| 356 | g_signal_connect(G_OBJECT(widget), "clicked", | |
| 357 | G_CALLBACK(gaimrc_set_font_special), NULL); | |
| 358 | ||
| 359 | /* key theme name */ | |
| 360 | hbox = gtk_hbox_new(FALSE, 18); | |
| 361 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
| 362 | ||
|
10814
7e17cb56b019
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10587
diff
changeset
|
363 | check = gaim_gtk_prefs_checkbox(_("GTK+ Text Shortcut Theme"), |
| 10584 | 364 | "/plugins/gtk/gaimrc/set/gtk-key-theme-name", |
| 365 | hbox); | |
| 366 | gtk_size_group_add_widget(sg, check); | |
| 367 | ||
| 368 | widget = gaim_gtk_prefs_labeled_entry(hbox, "", | |
| 369 | "/plugins/gtk/gaimrc/gtk-key-theme-name", | |
| 370 | NULL); | |
| 371 | gtk_widget_set_sensitive(widget, | |
| 372 | gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")); | |
| 373 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 374 | G_CALLBACK(gaim_gtk_toggle_sensitive), widget); | |
| 375 | ||
| 376 | frame = gaim_gtk_make_frame(ret, "Interface colors"); | |
| 377 | /* imhtml stuff */ | |
| 378 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 379 | hbox = gtk_hbox_new(FALSE, 18); | |
| 380 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
| 381 | ||
| 382 | check = gaim_gtk_prefs_checkbox(_(color_names[i]), | |
| 383 | color_prefs_set[i], hbox); | |
| 384 | gtk_size_group_add_widget(sg, check); | |
| 385 | ||
| 386 | color_widgets[i] = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_COLOR, GAIM_BUTTON_HORIZONTAL); | |
| 387 | gtk_size_group_add_widget(sg, color_widgets[i]); | |
| 388 | gtk_box_pack_start(GTK_BOX(hbox), color_widgets[i], FALSE, | |
| 389 | FALSE, 0); | |
| 390 | gtk_widget_set_sensitive(color_widgets[i], | |
| 391 | gaim_prefs_get_bool(color_prefs_set[i])); | |
| 392 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 393 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 394 | color_widgets[i]); | |
| 395 | g_signal_connect(G_OBJECT(color_widgets[i]), "clicked", | |
| 396 | G_CALLBACK(gaimrc_set_color), | |
| 397 | GINT_TO_POINTER(i)); | |
| 398 | } | |
| 399 | ||
| 400 | frame = gaim_gtk_make_frame(ret, "Widget Sizes"); | |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
401 | /* widget size stuff */ |
| 10584 | 402 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { |
| 403 | hbox = gtk_hbox_new(FALSE, 18); | |
| 404 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
| 405 | ||
| 406 | check = gaim_gtk_prefs_checkbox(_(widget_size_names[i]), | |
| 407 | widget_size_prefs_set[i], hbox); | |
| 408 | gtk_size_group_add_widget(sg, check); | |
| 409 | ||
| 410 | widget_size_widgets[i] = gaim_gtk_prefs_labeled_spin_button(hbox, "", widget_size_prefs[i], 0, 50, sg); | |
| 411 | gtk_widget_set_sensitive(widget_size_widgets[i], | |
| 412 | gaim_prefs_get_bool(widget_size_prefs_set[i])); | |
| 413 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 414 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 415 | widget_size_widgets[i]); | |
| 416 | } | |
| 417 | ||
| 418 | frame = gaim_gtk_make_frame(ret, "Fonts"); | |
| 419 | /* imhtml font stuff */ | |
| 420 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 421 | hbox = gtk_hbox_new(FALSE, 18); | |
| 422 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
| 423 | ||
| 424 | check = gaim_gtk_prefs_checkbox(_(font_names[i]), | |
| 425 | font_prefs_set[i], hbox); | |
| 426 | gtk_size_group_add_widget(sg, check); | |
| 427 | ||
| 428 | font_widgets[i] = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, GAIM_BUTTON_HORIZONTAL); | |
| 429 | gtk_size_group_add_widget(sg, font_widgets[i]); | |
| 430 | gtk_box_pack_start(GTK_BOX(hbox), font_widgets[i], FALSE, | |
| 431 | FALSE, 0); | |
| 432 | gtk_widget_set_sensitive(font_widgets[i], | |
| 433 | gaim_prefs_get_bool(font_prefs_set[i])); | |
| 434 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 435 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 436 | font_widgets[i]); | |
| 437 | g_signal_connect(G_OBJECT(font_widgets[i]), "clicked", | |
| 438 | G_CALLBACK(gaimrc_set_font), GINT_TO_POINTER(i)); | |
| 439 | } | |
| 440 | ||
| 441 | gtk_widget_show_all(ret); | |
| 442 | return ret; | |
| 443 | } | |
| 444 | ||
| 445 | static GaimGtkPluginUiInfo gaimrc_ui_info = | |
| 446 | { | |
| 447 | gaimrc_get_config_frame | |
| 448 | }; | |
| 449 | ||
| 450 | static GaimPluginInfo gaimrc_info = | |
| 451 | { | |
| 452 | GAIM_PLUGIN_MAGIC, | |
| 453 | GAIM_MAJOR_VERSION, | |
| 454 | GAIM_MINOR_VERSION, | |
| 455 | GAIM_PLUGIN_STANDARD, | |
| 456 | GAIM_GTK_PLUGIN_TYPE, | |
| 457 | 0, | |
| 458 | NULL, | |
| 459 | GAIM_PRIORITY_DEFAULT, | |
| 460 | "gaimrc", | |
| 461 | N_("Gaim GTK+ Theme Control"), | |
| 462 | VERSION, | |
| 463 | N_("Provides access to commonly used gtkrc settings."), | |
| 464 | N_("Provides access to commonly used gtkrc settings."), | |
| 465 | "Etan Reisner <deryni@eden.rutgers.edu>", | |
| 466 | GAIM_WEBSITE, | |
| 467 | gaimrc_plugin_load, | |
| 468 | gaimrc_plugin_unload, | |
| 469 | NULL, | |
| 470 | &gaimrc_ui_info, | |
| 471 | NULL, | |
| 472 | NULL, | |
| 473 | NULL | |
| 474 | }; | |
| 475 | ||
| 476 | static void | |
| 477 | gaimrc_init(GaimPlugin *plugin) | |
| 478 | { | |
| 479 | int i; | |
| 480 | ||
| 481 | gaim_prefs_add_none("/plugins"); | |
| 482 | gaim_prefs_add_none("/plugins/gtk"); | |
| 483 | gaim_prefs_add_none("/plugins/gtk/gaimrc"); | |
| 484 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set"); | |
| 485 | ||
| 486 | gaim_prefs_add_string("/plugins/gtk/gaimrc/gtk-font-name", ""); | |
| 487 | gaim_prefs_add_bool("/plugins/gtk/gaimrc/set/gtk-font-name", FALSE); | |
| 488 | ||
| 489 | gaim_prefs_add_string("/plugins/gtk/gaimrc/gtk-key-theme-name", ""); | |
| 490 | gaim_prefs_add_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name", FALSE); | |
| 491 | ||
| 492 | gaim_prefs_add_none("/plugins/gtk/gaimrc/color"); | |
| 493 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/color"); | |
| 494 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 495 | gaim_prefs_add_string(color_prefs[i], ""); | |
| 496 | gaim_prefs_add_bool(color_prefs_set[i], FALSE); | |
| 497 | } | |
| 498 | ||
| 499 | gaim_prefs_add_none("/plugins/gtk/gaimrc/size"); | |
| 500 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/size"); | |
| 501 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { | |
| 502 | gaim_prefs_add_int(widget_size_prefs[i], 0); | |
| 503 | gaim_prefs_add_bool(widget_size_prefs_set[i], FALSE); | |
| 504 | } | |
| 505 | ||
| 506 | gaim_prefs_add_none("/plugins/gtk/gaimrc/font"); | |
| 507 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/font"); | |
| 508 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 509 | gaim_prefs_add_string(font_prefs[i], ""); | |
| 510 | gaim_prefs_add_bool(font_prefs_set[i], FALSE); | |
| 511 | } | |
| 512 | } | |
| 513 | ||
| 514 | GAIM_INIT_PLUGIN(gaimrc, gaimrc_init, gaimrc_info) |