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