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