Mon, 12 Dec 2005 07:35:43 +0000
[gaim-migrate @ 14773]
SF Patch #1377719 from Evan Schoenberg
"A recent reorganization of how the chat_add_users() conversation UI op is
sent removed passing to the UI of whether the additions are new arrivals
or not. This information lets the UI make decisions about how to handle
the new people, what if anything to display, etc."
committer: Richard Laager <rlaager@pidgin.im>
| 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 | { | |
| 11940 | 399 | GtkWidget *ret = NULL, *frame = NULL, *hbox = NULL, *vbox = NULL; |
| 10584 | 400 | /* |
| 401 | GtkWidget *check = NULL, *widget = NULL, *label = NULL; | |
| 402 | */ | |
| 403 | GtkWidget *check = NULL, *widget = NULL; | |
| 404 | GtkSizeGroup *sg = NULL; | |
| 405 | /* | |
| 406 | char sample[7] = "Sample"; | |
| 407 | */ | |
| 408 | int i; | |
|
12042
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
409 | char *tmp; |
| 10584 | 410 | |
| 11940 | 411 | ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 412 | gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); | |
| 10584 | 413 | |
| 414 | sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 415 | ||
| 416 | frame = gaim_gtk_make_frame(ret, "General"); | |
| 417 | /* interface font */ | |
| 11940 | 418 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 419 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 420 | ||
|
10814
7e17cb56b019
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10587
diff
changeset
|
421 | check = gaim_gtk_prefs_checkbox(_("GTK+ Interface Font"), |
| 10584 | 422 | "/plugins/gtk/gaimrc/set/gtk-font-name", |
| 423 | hbox); | |
| 424 | gtk_size_group_add_widget(sg, check); | |
| 425 | ||
| 426 | widget = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, | |
| 427 | GAIM_BUTTON_HORIZONTAL); | |
| 428 | gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); | |
| 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); | |
| 443 | gtk_size_group_add_widget(sg, check); | |
| 444 | ||
| 445 | widget = gaim_gtk_prefs_labeled_entry(hbox, "", | |
| 446 | "/plugins/gtk/gaimrc/gtk-key-theme-name", | |
| 447 | NULL); | |
| 448 | gtk_widget_set_sensitive(widget, | |
| 449 | gaim_prefs_get_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name")); | |
| 450 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 451 | G_CALLBACK(gaim_gtk_toggle_sensitive), widget); | |
| 452 | ||
| 453 | frame = gaim_gtk_make_frame(ret, "Interface colors"); | |
| 454 | /* imhtml stuff */ | |
| 455 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 11940 | 456 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 457 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 458 | ||
| 459 | check = gaim_gtk_prefs_checkbox(_(color_names[i]), | |
| 460 | color_prefs_set[i], hbox); | |
| 461 | gtk_size_group_add_widget(sg, check); | |
| 462 | ||
| 463 | color_widgets[i] = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_COLOR, GAIM_BUTTON_HORIZONTAL); | |
| 464 | gtk_size_group_add_widget(sg, color_widgets[i]); | |
| 465 | gtk_box_pack_start(GTK_BOX(hbox), color_widgets[i], FALSE, | |
| 466 | FALSE, 0); | |
| 467 | gtk_widget_set_sensitive(color_widgets[i], | |
| 468 | gaim_prefs_get_bool(color_prefs_set[i])); | |
| 469 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 470 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 471 | color_widgets[i]); | |
| 472 | g_signal_connect(G_OBJECT(color_widgets[i]), "clicked", | |
| 473 | G_CALLBACK(gaimrc_set_color), | |
| 474 | GINT_TO_POINTER(i)); | |
| 475 | } | |
| 476 | ||
| 477 | frame = gaim_gtk_make_frame(ret, "Widget Sizes"); | |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
478 | /* widget size stuff */ |
| 10584 | 479 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { |
| 11940 | 480 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 481 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 482 | ||
| 483 | check = gaim_gtk_prefs_checkbox(_(widget_size_names[i]), | |
| 484 | widget_size_prefs_set[i], hbox); | |
| 485 | gtk_size_group_add_widget(sg, check); | |
| 486 | ||
| 487 | widget_size_widgets[i] = gaim_gtk_prefs_labeled_spin_button(hbox, "", widget_size_prefs[i], 0, 50, sg); | |
| 488 | gtk_widget_set_sensitive(widget_size_widgets[i], | |
| 489 | gaim_prefs_get_bool(widget_size_prefs_set[i])); | |
| 490 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 491 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 492 | widget_size_widgets[i]); | |
| 493 | } | |
| 494 | ||
| 495 | frame = gaim_gtk_make_frame(ret, "Fonts"); | |
| 496 | /* imhtml font stuff */ | |
| 497 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 11940 | 498 | hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); |
| 10584 | 499 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 500 | ||
| 501 | check = gaim_gtk_prefs_checkbox(_(font_names[i]), | |
| 502 | font_prefs_set[i], hbox); | |
| 503 | gtk_size_group_add_widget(sg, check); | |
| 504 | ||
| 505 | font_widgets[i] = gaim_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, GAIM_BUTTON_HORIZONTAL); | |
| 506 | gtk_size_group_add_widget(sg, font_widgets[i]); | |
| 507 | gtk_box_pack_start(GTK_BOX(hbox), font_widgets[i], FALSE, | |
| 508 | FALSE, 0); | |
| 509 | gtk_widget_set_sensitive(font_widgets[i], | |
| 510 | gaim_prefs_get_bool(font_prefs_set[i])); | |
| 511 | g_signal_connect(G_OBJECT(check), "toggled", | |
| 512 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 513 | font_widgets[i]); | |
| 514 | g_signal_connect(G_OBJECT(font_widgets[i]), "clicked", | |
| 515 | G_CALLBACK(gaimrc_set_font), GINT_TO_POINTER(i)); | |
| 516 | } | |
| 517 | ||
| 11940 | 518 | frame = gaim_gtk_make_frame(ret, "General"); |
| 519 | ||
| 520 | vbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); | |
| 521 | gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0); | |
| 522 | ||
|
12048
a68cc826b6e7
[gaim-migrate @ 14343]
Mark Doliner <markdoliner@pidgin.im>
parents:
12044
diff
changeset
|
523 | tmp = g_strdup_printf(_("Write a gtkrc file with these settings to %s"), gaim_user_dir()); |
|
12042
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
524 | check = gtk_button_new_with_label(tmp); |
|
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
525 | g_free(tmp); |
| 11940 | 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_write), | |
| 529 | NULL); | |
| 530 | ||
| 531 | check = gtk_button_new_with_label(_("Re-read gtkrc files")); | |
| 532 | gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); | |
| 533 | gtk_size_group_add_widget(sg, check); | |
| 534 | g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(gaimrc_reread), | |
| 535 | NULL); | |
| 536 | ||
| 10584 | 537 | gtk_widget_show_all(ret); |
| 538 | return ret; | |
| 539 | } | |
| 540 | ||
| 541 | static GaimGtkPluginUiInfo gaimrc_ui_info = | |
| 542 | { | |
| 543 | gaimrc_get_config_frame | |
| 544 | }; | |
| 545 | ||
| 546 | static GaimPluginInfo gaimrc_info = | |
| 547 | { | |
| 548 | GAIM_PLUGIN_MAGIC, | |
| 549 | GAIM_MAJOR_VERSION, | |
| 550 | GAIM_MINOR_VERSION, | |
| 551 | GAIM_PLUGIN_STANDARD, | |
| 552 | GAIM_GTK_PLUGIN_TYPE, | |
| 553 | 0, | |
| 554 | NULL, | |
| 555 | GAIM_PRIORITY_DEFAULT, | |
| 556 | "gaimrc", | |
| 557 | N_("Gaim GTK+ Theme Control"), | |
| 558 | VERSION, | |
| 559 | N_("Provides access to commonly used gtkrc settings."), | |
| 560 | N_("Provides access to commonly used gtkrc settings."), | |
| 561 | "Etan Reisner <deryni@eden.rutgers.edu>", | |
| 562 | GAIM_WEBSITE, | |
| 563 | gaimrc_plugin_load, | |
| 564 | gaimrc_plugin_unload, | |
| 565 | NULL, | |
| 566 | &gaimrc_ui_info, | |
| 567 | NULL, | |
| 568 | NULL, | |
| 569 | NULL | |
| 570 | }; | |
| 571 | ||
| 572 | static void | |
| 573 | gaimrc_init(GaimPlugin *plugin) | |
| 574 | { | |
| 575 | int i; | |
| 576 | ||
| 577 | gaim_prefs_add_none("/plugins"); | |
| 578 | gaim_prefs_add_none("/plugins/gtk"); | |
| 579 | gaim_prefs_add_none("/plugins/gtk/gaimrc"); | |
| 580 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set"); | |
| 581 | ||
| 582 | gaim_prefs_add_string("/plugins/gtk/gaimrc/gtk-font-name", ""); | |
| 583 | gaim_prefs_add_bool("/plugins/gtk/gaimrc/set/gtk-font-name", FALSE); | |
| 584 | ||
| 585 | gaim_prefs_add_string("/plugins/gtk/gaimrc/gtk-key-theme-name", ""); | |
| 586 | gaim_prefs_add_bool("/plugins/gtk/gaimrc/set/gtk-key-theme-name", FALSE); | |
| 587 | ||
| 588 | gaim_prefs_add_none("/plugins/gtk/gaimrc/color"); | |
| 589 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/color"); | |
| 590 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 591 | gaim_prefs_add_string(color_prefs[i], ""); | |
| 592 | gaim_prefs_add_bool(color_prefs_set[i], FALSE); | |
| 593 | } | |
| 594 | ||
| 595 | gaim_prefs_add_none("/plugins/gtk/gaimrc/size"); | |
| 596 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/size"); | |
| 597 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { | |
| 598 | gaim_prefs_add_int(widget_size_prefs[i], 0); | |
| 599 | gaim_prefs_add_bool(widget_size_prefs_set[i], FALSE); | |
| 600 | } | |
| 601 | ||
| 602 | gaim_prefs_add_none("/plugins/gtk/gaimrc/font"); | |
| 603 | gaim_prefs_add_none("/plugins/gtk/gaimrc/set/font"); | |
| 604 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 605 | gaim_prefs_add_string(font_prefs[i], ""); | |
| 606 | gaim_prefs_add_bool(font_prefs_set[i], FALSE); | |
| 607 | } | |
| 608 | } | |
| 609 | ||
| 610 | GAIM_INIT_PLUGIN(gaimrc, gaimrc_init, gaimrc_info) |