Mon, 19 Mar 2007 07:01:17 +0000
sed -ie 's/gaim/purple/g'
| 10584 | 1 | /** |
| 15884 | 2 | * @file purplerc.c Purple gtk resource control plugin. |
| 10584 | 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[] = { | |
| 15884 | 31 | "/plugins/gtk/purplerc/color/GtkWidget::cursor-color", |
| 32 | "/plugins/gtk/purplerc/color/GtkWidget::secondary-cursor-color", | |
| 33 | "/plugins/gtk/purplerc/color/GtkIMHtml::hyperlink-color" | |
| 10584 | 34 | }; |
| 35 | static const char *color_prefs_set[] = { | |
| 15884 | 36 | "/plugins/gtk/purplerc/set/color/GtkWidget::cursor-color", |
| 37 | "/plugins/gtk/purplerc/set/color/GtkWidget::secondary-cursor-color", | |
| 38 | "/plugins/gtk/purplerc/set/color/GtkIMHtml::hyperlink-color" | |
| 10584 | 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[] = { | |
| 15884 | 48 | "/plugins/gtk/purplerc/size/GtkTreeView::expander_size", |
| 49 | "/plugins/gtk/purplerc/size/GtkTreeView::horizontal_separator" | |
| 10584 | 50 | }; |
| 51 | static const char *widget_size_prefs_set[] = { | |
| 15884 | 52 | "/plugins/gtk/purplerc/set/size/GtkTreeView::expander_size", |
| 53 | "/plugins/gtk/purplerc/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[] = { | |
| 15884 | 62 | "/plugins/gtk/purplerc/font/*pidgin_conv_entry", |
| 63 | "/plugins/gtk/purplerc/font/*pidgin_conv_imhtml", | |
| 64 | "/plugins/gtk/purplerc/font/*pidginlog_imhtml", | |
| 65 | "/plugins/gtk/purplerc/font/*pidginrequest_imhtml", | |
| 66 | "/plugins/gtk/purplerc/font/*pidginnotify_imhtml", | |
| 10584 | 67 | }; |
| 68 | static const char *font_prefs_set[] = { | |
| 15884 | 69 | "/plugins/gtk/purplerc/set/font/*pidgin_conv_entry", |
| 70 | "/plugins/gtk/purplerc/set/font/*pidgin_conv_imhtml", | |
| 71 | "/plugins/gtk/purplerc/set/font/*pidginlog_imhtml", | |
| 72 | "/plugins/gtk/purplerc/set/font/*pidginrequest_imhtml", | |
| 73 | "/plugins/gtk/purplerc/set/font/*pidginnotify_imhtml", | |
| 10584 | 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[] = { |
| 15884 | 85 | "/plugins/gtk/purplerc/bool/GtkTreeView::indent_expanders", |
| 12973 | 86 | }; |
| 87 | static const char *widget_bool_prefs_set[] = { | |
| 15884 | 88 | "/plugins/gtk/purplerc/set/bool/GtkTreeView::indent_expanders", |
| 12973 | 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 |
| 15884 | 96 | purplerc_make_changes() |
| 10584 | 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 | ||
| 15884 | 105 | if (purple_prefs_get_bool("/plugins/gtk/purplerc/set/gtk-font-name")) { |
| 106 | const char *pref = purple_prefs_get_string("/plugins/gtk/purplerc/gtk-font-name"); | |
| 14391 | 107 | |
| 108 | if (pref != NULL && strcmp(pref, "")) | |
| 109 | g_string_append_printf(style_string, "gtk-font-name = \"%s\"\n", pref); | |
| 10584 | 110 | } |
| 111 | ||
| 15884 | 112 | if (purple_prefs_get_bool("/plugins/gtk/purplerc/set/gtk-key-theme-name")) { |
| 113 | const char *pref = purple_prefs_get_string("/plugins/gtk/purplerc/gtk-key-theme-name"); | |
| 14391 | 114 | |
| 115 | if (pref != NULL && strcmp(pref, "")) | |
| 116 | g_string_append_printf(style_string, "gtk-key-theme-name = \"%s\"\n", pref); | |
| 10584 | 117 | } |
| 118 | ||
| 15884 | 119 | g_string_append(style_string, "style \"purplerc_style\" {\n"); |
| 10584 | 120 | |
| 121 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 15884 | 122 | if (purple_prefs_get_bool(color_prefs_set[i])) { |
| 14391 | 123 | const char *pref; |
| 124 | ||
| 10584 | 125 | prefbase = g_path_get_basename(color_prefs[i]); |
| 15884 | 126 | pref = purple_prefs_get_string(color_prefs[i]); |
| 14391 | 127 | |
| 128 | if (pref != NULL && strcmp(pref, "")) | |
| 129 | g_string_append_printf(style_string, | |
| 130 | "%s = \"%s\"\n", | |
| 131 | prefbase, pref); | |
| 10584 | 132 | g_free(prefbase); |
| 133 | } | |
| 134 | } | |
| 135 | ||
| 136 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { | |
| 15884 | 137 | if (purple_prefs_get_bool(widget_size_prefs_set[i])) { |
| 10584 | 138 | prefbase = g_path_get_basename(widget_size_prefs[i]); |
| 139 | g_string_append_printf(style_string, | |
|
11862
5d4bc6d54688
[gaim-migrate @ 14153]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
140 | "%s = %d\n", prefbase, |
| 15884 | 141 | purple_prefs_get_int(widget_size_prefs[i])); |
| 10584 | 142 | g_free(prefbase); |
| 143 | } | |
| 144 | } | |
| 145 | ||
| 12973 | 146 | for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { |
| 15884 | 147 | if (purple_prefs_get_bool(widget_bool_prefs_set[i])) { |
| 12973 | 148 | prefbase = g_path_get_basename(widget_bool_prefs[i]); |
| 149 | g_string_append_printf(style_string, | |
| 150 | "%s = %d\n", prefbase, | |
| 15884 | 151 | purple_prefs_get_bool(widget_bool_prefs[i])); |
| 12973 | 152 | g_free(prefbase); |
| 153 | } | |
| 154 | } | |
| 155 | ||
| 10584 | 156 | g_string_append(style_string, "}"); |
| 15884 | 157 | g_string_append(style_string, "widget_class \"*\" style \"purplerc_style\"\n"); |
| 10584 | 158 | |
| 159 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 15884 | 160 | if (purple_prefs_get_bool(font_prefs_set[i])) { |
| 14391 | 161 | const char *pref; |
| 162 | ||
| 10584 | 163 | prefbase = g_path_get_basename(font_prefs[i]); |
| 15884 | 164 | pref = purple_prefs_get_string(font_prefs[i]); |
| 14391 | 165 | |
| 166 | if (pref != NULL && strcmp(pref, "")) | |
| 167 | g_string_append_printf(style_string, | |
| 168 | "style \"%s_style\"\n" | |
| 169 | "{font_name = \"%s\"}\n" | |
| 170 | "widget \"%s\"" | |
| 171 | "style \"%s_style\"\n", | |
| 172 | prefbase, pref, | |
| 173 | prefbase, prefbase); | |
| 10584 | 174 | g_free(prefbase); |
| 175 | } | |
| 176 | } | |
| 177 | ||
| 178 | gtk_rc_parse_string(style_string->str); | |
| 12973 | 179 | g_string_free(style_string, TRUE); |
| 10584 | 180 | |
| 12973 | 181 | #if GTK_CHECK_VERSION(2,4,0) |
| 182 | setting = gtk_settings_get_default(); | |
| 183 | gtk_rc_reset_styles(setting); | |
| 184 | #endif | |
| 10584 | 185 | } |
| 186 | ||
| 187 | static void | |
| 15884 | 188 | purplerc_write(GtkWidget *widget, gpointer data) |
| 11940 | 189 | { |
| 190 | int i; | |
| 191 | GString *style_string = g_string_new(""); | |
| 192 | char *prefbase = NULL; | |
| 193 | ||
| 15884 | 194 | if (purple_prefs_get_bool("/plugins/gtk/purplerc/set/gtk-font-name")) { |
| 195 | const char *pref = purple_prefs_get_string("/plugins/gtk/purplerc/gtk-font-name"); | |
| 14391 | 196 | |
| 197 | if (pref != NULL && strcmp(pref, "")) | |
| 198 | g_string_append_printf(style_string, | |
| 199 | "gtk-font-name = \"%s\"\n", | |
| 200 | pref); | |
| 11940 | 201 | } |
| 202 | ||
| 15884 | 203 | if (purple_prefs_get_bool("/plugins/gtk/purplerc/set/gtk-key-theme-name")) { |
| 204 | const char *pref = purple_prefs_get_string("/plugins/gtk/purplerc/gtk-key-theme-name"); | |
| 14391 | 205 | |
| 206 | if (pref != NULL && strcmp(pref, "")) | |
| 207 | g_string_append_printf(style_string, | |
| 208 | "gtk-key-theme-name = \"%s\"\n", | |
| 209 | pref); | |
| 11940 | 210 | } |
| 211 | ||
| 15884 | 212 | g_string_append(style_string, "style \"purplerc_style\" {\n"); |
| 11940 | 213 | |
| 214 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 15884 | 215 | if (purple_prefs_get_bool(color_prefs_set[i])) { |
| 14391 | 216 | const char *pref; |
| 217 | ||
| 11940 | 218 | prefbase = g_path_get_basename(color_prefs[i]); |
| 15884 | 219 | pref = purple_prefs_get_string(color_prefs[i]); |
| 14391 | 220 | |
| 221 | if (pref != NULL && strcmp(pref, "")) | |
| 222 | g_string_append_printf(style_string, | |
| 223 | "%s = \"%s\"\n", | |
| 224 | prefbase, pref); | |
| 11940 | 225 | g_free(prefbase); |
| 226 | } | |
| 227 | } | |
| 228 | ||
| 229 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { | |
| 15884 | 230 | if (purple_prefs_get_bool(widget_size_prefs_set[i])) { |
| 11940 | 231 | prefbase = g_path_get_basename(widget_size_prefs[i]); |
| 232 | g_string_append_printf(style_string, | |
| 233 | "%s = %d\n", prefbase, | |
| 15884 | 234 | purple_prefs_get_int(widget_size_prefs[i])); |
| 11940 | 235 | g_free(prefbase); |
| 236 | } | |
| 237 | } | |
| 238 | ||
| 12973 | 239 | for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { |
| 15884 | 240 | if (purple_prefs_get_bool(widget_bool_prefs_set[i])) { |
| 12973 | 241 | prefbase = g_path_get_basename(widget_bool_prefs[i]); |
| 242 | g_string_append_printf(style_string, | |
| 243 | "%s = %d\n", prefbase, | |
| 15884 | 244 | purple_prefs_get_bool(widget_bool_prefs[i])); |
| 12973 | 245 | g_free(prefbase); |
| 246 | } | |
| 247 | } | |
| 248 | ||
| 11940 | 249 | g_string_append(style_string, "}"); |
| 15884 | 250 | g_string_append(style_string, "widget_class \"*\" style \"purplerc_style\"\n"); |
| 11940 | 251 | |
| 252 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 15884 | 253 | if (purple_prefs_get_bool(font_prefs_set[i])) { |
| 14391 | 254 | const char *pref; |
| 255 | ||
| 11940 | 256 | prefbase = g_path_get_basename(font_prefs[i]); |
| 15884 | 257 | pref = purple_prefs_get_string(font_prefs[i]); |
| 14391 | 258 | |
| 259 | if (pref != NULL && strcmp(pref, "")) | |
| 260 | g_string_append_printf(style_string, | |
| 261 | "style \"%s_style\"\n" | |
| 262 | "{font_name = \"%s\"}\n" | |
| 263 | "widget \"%s\"" | |
| 264 | "style \"%s_style\"\n", | |
| 265 | prefbase, pref, | |
| 266 | prefbase, prefbase); | |
| 11940 | 267 | g_free(prefbase); |
| 268 | } | |
| 269 | } | |
| 270 | ||
| 15884 | 271 | purple_util_write_data_to_file("gtkrc-2.0", style_string->str, -1); |
| 11940 | 272 | |
| 273 | g_string_free(style_string, TRUE); | |
| 274 | } | |
| 275 | ||
| 276 | static void | |
| 15884 | 277 | purplerc_reread(GtkWidget *widget, gpointer data) |
| 11940 | 278 | { |
| 279 | gtk_rc_reparse_all(); | |
| 12973 | 280 | /* I don't know if this is necessary but if not it shouldn't hurt. */ |
| 15884 | 281 | purplerc_make_changes(); |
| 11940 | 282 | } |
| 283 | ||
| 284 | static void | |
| 15884 | 285 | purplerc_pref_changed_cb(const char *name, PurplePrefType type, |
|
12816
5f93e09fa9a6
[gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents:
12600
diff
changeset
|
286 | gconstpointer value, gpointer data) |
| 10584 | 287 | { |
| 15884 | 288 | purplerc_make_changes(); |
| 10584 | 289 | } |
| 290 | ||
| 291 | static void | |
| 15884 | 292 | purplerc_color_response(GtkDialog *color_dialog, gint response, gpointer data) |
| 10584 | 293 | { |
| 294 | int subscript = GPOINTER_TO_INT(data); | |
| 295 | ||
| 296 | if (response == GTK_RESPONSE_OK) { | |
| 297 | GtkWidget *colorsel = GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel; | |
| 298 | GdkColor color; | |
| 299 | char colorstr[8]; | |
| 300 | ||
| 301 | gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(colorsel), &color); | |
| 302 | ||
| 303 | g_snprintf(colorstr, sizeof(colorstr), "#%02X%02X%02X", | |
| 304 | color.red/256, color.green/256, color.blue/256); | |
| 305 | ||
| 15884 | 306 | purple_prefs_set_string(color_prefs[subscript], colorstr); |
| 10584 | 307 | } |
| 308 | gtk_widget_destroy(GTK_WIDGET(color_dialog)); | |
| 309 | } | |
| 310 | ||
| 311 | static void | |
| 15884 | 312 | purplerc_set_color(GtkWidget *widget, gpointer data) |
| 10584 | 313 | { |
| 314 | GtkWidget *color_dialog = NULL; | |
| 315 | GdkColor color; | |
| 316 | char title[128]; | |
| 14391 | 317 | const char *pref = NULL; |
| 10584 | 318 | int subscript = GPOINTER_TO_INT(data); |
| 319 | ||
| 320 | g_snprintf(title, sizeof(title), _("Select Color for %s"), | |
|
10586
fd1399d550fc
[gaim-migrate @ 11990]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10585
diff
changeset
|
321 | _(color_names[GPOINTER_TO_INT(data)])); |
| 10584 | 322 | color_dialog = gtk_color_selection_dialog_new(_("Select Color")); |
| 323 | g_signal_connect(G_OBJECT(color_dialog), "response", | |
| 15884 | 324 | G_CALLBACK(purplerc_color_response), data); |
| 10584 | 325 | |
| 15884 | 326 | pref = purple_prefs_get_string(color_prefs[subscript]); |
| 14391 | 327 | |
| 328 | if (pref != NULL && strcmp(pref, "")) { | |
| 329 | if (gdk_color_parse(pref, &color)) { | |
| 330 | gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel), &color); | |
| 331 | } | |
| 10584 | 332 | } |
| 333 | ||
| 334 | gtk_window_present(GTK_WINDOW(color_dialog)); | |
| 335 | } | |
| 336 | ||
| 337 | static void | |
| 15884 | 338 | purplerc_font_response(GtkDialog *font_dialog, gint response, gpointer data) |
| 10584 | 339 | { |
| 340 | int subscript = GPOINTER_TO_INT(data); | |
| 341 | ||
| 342 | if (response == GTK_RESPONSE_OK) { | |
| 343 | char *fontname = NULL; | |
| 344 | ||
| 345 | fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog)); | |
| 346 | ||
| 15884 | 347 | purple_prefs_set_string(font_prefs[subscript], fontname); |
| 10584 | 348 | g_free(fontname); |
| 349 | } | |
| 350 | gtk_widget_destroy(GTK_WIDGET(font_dialog)); | |
| 351 | } | |
| 352 | ||
| 353 | static void | |
| 15884 | 354 | purplerc_set_font(GtkWidget *widget, gpointer data) |
| 10584 | 355 | { |
| 356 | GtkWidget *font_dialog = NULL; | |
| 357 | char title[128]; | |
| 14391 | 358 | const char *pref = NULL; |
| 10584 | 359 | int subscript = GPOINTER_TO_INT(data); |
| 360 | ||
| 361 | g_snprintf(title, sizeof(title), _("Select Font for %s"), | |
|
10586
fd1399d550fc
[gaim-migrate @ 11990]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10585
diff
changeset
|
362 | _(font_names[subscript])); |
| 10584 | 363 | font_dialog = gtk_font_selection_dialog_new(title); |
| 364 | g_signal_connect(G_OBJECT(font_dialog), "response", | |
| 15884 | 365 | G_CALLBACK(purplerc_font_response), data); |
| 10584 | 366 | |
| 15884 | 367 | pref = purple_prefs_get_string(font_prefs[subscript]); |
| 14391 | 368 | |
| 369 | if (pref != NULL && strcmp(pref, "")) { | |
| 370 | gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(font_dialog)->fontsel), pref); | |
| 10584 | 371 | } |
| 372 | ||
| 373 | gtk_window_present(GTK_WINDOW(font_dialog)); | |
| 374 | } | |
| 375 | ||
| 376 | static void | |
| 15884 | 377 | purplerc_font_response_special(GtkDialog *font_dialog, gint response, |
| 10584 | 378 | gpointer data) |
| 379 | { | |
| 380 | if (response == GTK_RESPONSE_OK) { | |
| 381 | char *fontname = NULL; | |
| 382 | ||
| 383 | fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(font_dialog)); | |
| 384 | ||
| 15884 | 385 | purple_prefs_set_string("/plugins/gtk/purplerc/gtk-font-name", |
| 10584 | 386 | fontname); |
| 387 | g_free(fontname); | |
| 388 | } | |
| 389 | gtk_widget_destroy(GTK_WIDGET(font_dialog)); | |
| 390 | } | |
| 391 | ||
| 392 | static void | |
| 15884 | 393 | purplerc_set_font_special(GtkWidget *widget, gpointer data) |
| 10584 | 394 | { |
| 395 | GtkWidget *font_dialog = NULL; | |
| 14391 | 396 | const char *pref = NULL; |
| 10584 | 397 | |
| 398 | font_dialog = gtk_font_selection_dialog_new(_("Select Interface Font")); | |
| 399 | g_signal_connect(G_OBJECT(font_dialog), "response", | |
| 15884 | 400 | G_CALLBACK(purplerc_font_response_special), NULL); |
| 10584 | 401 | |
| 15884 | 402 | pref = purple_prefs_get_string("/plugins/gtk/purplerc/gtk-font-name"); |
| 14391 | 403 | |
| 404 | if (pref != NULL && strcmp(pref, "")) { | |
| 405 | gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(font_dialog)->fontsel), pref); | |
| 10584 | 406 | } |
| 407 | ||
| 408 | gtk_window_present(GTK_WINDOW(font_dialog)); | |
| 409 | } | |
| 410 | ||
| 411 | static gboolean | |
| 15884 | 412 | purplerc_plugin_load(PurplePlugin *plugin) |
| 10584 | 413 | { |
| 15884 | 414 | purplerc_make_changes(); |
| 10584 | 415 | |
| 15884 | 416 | pref_callback = purple_prefs_connect_callback(plugin, "/plugins/gtk/purplerc", |
| 417 | purplerc_pref_changed_cb, NULL); | |
| 10584 | 418 | |
| 419 | return TRUE; | |
| 420 | } | |
| 421 | ||
| 422 | static gboolean | |
| 15884 | 423 | purplerc_plugin_unload(PurplePlugin *plugin) |
| 10584 | 424 | { |
| 15884 | 425 | purple_prefs_disconnect_callback(pref_callback); |
| 10584 | 426 | |
| 427 | return TRUE; | |
| 428 | } | |
| 429 | ||
| 430 | static GtkWidget * | |
| 15884 | 431 | purplerc_get_config_frame(PurplePlugin *plugin) |
| 10584 | 432 | { |
| 12546 | 433 | /* Note: Intentionally not using the size group argument to the |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
434 | * pidgin_prefs_labeled_* functions they only add the text label to |
| 12546 | 435 | * the size group not the whole thing, which isn't what I want. */ |
| 10584 | 436 | int i; |
|
12042
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
437 | char *tmp; |
| 12546 | 438 | GtkWidget *check = NULL, *widget = NULL; |
| 439 | GtkSizeGroup *labelsg = NULL, *widgetsg = NULL; | |
| 440 | GtkWidget *ret = NULL, *frame = NULL, *hbox = NULL, *vbox = NULL; | |
| 10584 | 441 | |
| 15882 | 442 | ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); |
| 443 | gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER); | |
| 10584 | 444 | |
| 12546 | 445 | labelsg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| 446 | widgetsg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 10584 | 447 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
448 | frame = pidgin_make_frame(ret, _("General")); |
| 10584 | 449 | /* interface font */ |
| 15882 | 450 | hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); |
| 10584 | 451 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 452 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
453 | check = pidgin_prefs_checkbox(_("GTK+ Interface Font"), |
| 15884 | 454 | "/plugins/gtk/purplerc/set/gtk-font-name", |
| 10584 | 455 | hbox); |
| 12546 | 456 | gtk_size_group_add_widget(labelsg, check); |
| 10584 | 457 | |
| 15568 | 458 | widget = pidgin_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, |
| 459 | PIDGIN_BUTTON_HORIZONTAL); | |
| 10584 | 460 | gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); |
| 12546 | 461 | gtk_size_group_add_widget(widgetsg, widget); |
| 10584 | 462 | gtk_widget_set_sensitive(widget, |
| 15884 | 463 | purple_prefs_get_bool("/plugins/gtk/purplerc/set/gtk-font-name")); |
| 10584 | 464 | g_signal_connect(G_OBJECT(check), "toggled", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
465 | G_CALLBACK(pidgin_toggle_sensitive), widget); |
| 10584 | 466 | g_signal_connect(G_OBJECT(widget), "clicked", |
| 15884 | 467 | G_CALLBACK(purplerc_set_font_special), NULL); |
| 10584 | 468 | |
| 469 | /* key theme name */ | |
| 15882 | 470 | hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); |
| 10584 | 471 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 472 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
473 | check = pidgin_prefs_checkbox(_("GTK+ Text Shortcut Theme"), |
| 15884 | 474 | "/plugins/gtk/purplerc/set/gtk-key-theme-name", |
| 10584 | 475 | hbox); |
| 12546 | 476 | gtk_size_group_add_widget(labelsg, check); |
| 10584 | 477 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
478 | widget = pidgin_prefs_labeled_entry(hbox, "", |
| 15884 | 479 | "/plugins/gtk/purplerc/gtk-key-theme-name", |
| 10584 | 480 | NULL); |
| 12546 | 481 | /* |
| 482 | gtk_size_group_add_widget(widgetsg, widget); | |
| 483 | */ | |
| 10584 | 484 | gtk_widget_set_sensitive(widget, |
| 15884 | 485 | purple_prefs_get_bool("/plugins/gtk/purplerc/set/gtk-key-theme-name")); |
| 10584 | 486 | g_signal_connect(G_OBJECT(check), "toggled", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
487 | G_CALLBACK(pidgin_toggle_sensitive), widget); |
| 10584 | 488 | |
| 12973 | 489 | for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { |
| 15882 | 490 | hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); |
| 12973 | 491 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 492 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
493 | check = pidgin_prefs_checkbox(_(widget_bool_names[i]), |
| 12973 | 494 | widget_bool_prefs_set[i], hbox); |
| 495 | gtk_size_group_add_widget(labelsg, check); | |
| 496 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
497 | widget_bool_widgets[i] = pidgin_prefs_checkbox("", widget_bool_prefs[i], hbox); |
| 12973 | 498 | /* |
| 499 | gtk_size_group_add_widget(widgetsb, widget_bool_widgets[i]); | |
| 500 | */ | |
| 501 | gtk_widget_set_sensitive(widget_bool_widgets[i], | |
| 15884 | 502 | purple_prefs_get_bool(widget_bool_prefs_set[i])); |
| 12973 | 503 | g_signal_connect(G_OBJECT(check), "toggled", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
504 | G_CALLBACK(pidgin_toggle_sensitive), |
| 12973 | 505 | widget_bool_widgets[i]); |
| 506 | } | |
| 507 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
508 | frame = pidgin_make_frame(ret, _("Interface colors")); |
| 10584 | 509 | /* imhtml stuff */ |
| 510 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { | |
| 15882 | 511 | hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); |
| 10584 | 512 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 513 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
514 | check = pidgin_prefs_checkbox(_(color_names[i]), |
| 10584 | 515 | color_prefs_set[i], hbox); |
| 12546 | 516 | gtk_size_group_add_widget(labelsg, check); |
| 10584 | 517 | |
| 15568 | 518 | color_widgets[i] = pidgin_pixbuf_button_from_stock("", GTK_STOCK_SELECT_COLOR, PIDGIN_BUTTON_HORIZONTAL); |
| 12546 | 519 | gtk_size_group_add_widget(widgetsg, color_widgets[i]); |
| 10584 | 520 | gtk_box_pack_start(GTK_BOX(hbox), color_widgets[i], FALSE, |
| 521 | FALSE, 0); | |
| 522 | gtk_widget_set_sensitive(color_widgets[i], | |
| 15884 | 523 | purple_prefs_get_bool(color_prefs_set[i])); |
| 10584 | 524 | g_signal_connect(G_OBJECT(check), "toggled", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
525 | G_CALLBACK(pidgin_toggle_sensitive), |
| 10584 | 526 | color_widgets[i]); |
| 527 | g_signal_connect(G_OBJECT(color_widgets[i]), "clicked", | |
| 15884 | 528 | G_CALLBACK(purplerc_set_color), |
| 10584 | 529 | GINT_TO_POINTER(i)); |
| 530 | } | |
| 531 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
532 | frame = pidgin_make_frame(ret, _("Widget Sizes")); |
|
10585
42d99375d8d0
[gaim-migrate @ 11989]
Nathan Fredrickson <nathan@silverorange.com>
parents:
10584
diff
changeset
|
533 | /* widget size stuff */ |
| 10584 | 534 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { |
| 15882 | 535 | hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); |
| 10584 | 536 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 537 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
538 | check = pidgin_prefs_checkbox(_(widget_size_names[i]), |
| 10584 | 539 | widget_size_prefs_set[i], hbox); |
| 12546 | 540 | gtk_size_group_add_widget(labelsg, check); |
| 10584 | 541 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
542 | widget_size_widgets[i] = pidgin_prefs_labeled_spin_button(hbox, "", widget_size_prefs[i], 0, 50, NULL); |
| 12546 | 543 | /* |
| 544 | gtk_size_group_add_widget(widgetsg, widget_size_widgets[i]); | |
| 545 | */ | |
| 10584 | 546 | gtk_widget_set_sensitive(widget_size_widgets[i], |
| 15884 | 547 | purple_prefs_get_bool(widget_size_prefs_set[i])); |
| 10584 | 548 | g_signal_connect(G_OBJECT(check), "toggled", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
549 | G_CALLBACK(pidgin_toggle_sensitive), |
| 10584 | 550 | widget_size_widgets[i]); |
| 551 | } | |
| 552 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
553 | frame = pidgin_make_frame(ret, _("Fonts")); |
| 10584 | 554 | /* imhtml font stuff */ |
| 555 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { | |
| 15882 | 556 | hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); |
| 10584 | 557 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); |
| 558 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
559 | check = pidgin_prefs_checkbox(_(font_names[i]), |
| 10584 | 560 | font_prefs_set[i], hbox); |
| 12546 | 561 | gtk_size_group_add_widget(labelsg, check); |
| 10584 | 562 | |
| 15568 | 563 | font_widgets[i] = pidgin_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, PIDGIN_BUTTON_HORIZONTAL); |
| 12546 | 564 | gtk_size_group_add_widget(widgetsg, font_widgets[i]); |
| 10584 | 565 | gtk_box_pack_start(GTK_BOX(hbox), font_widgets[i], FALSE, |
| 566 | FALSE, 0); | |
| 567 | gtk_widget_set_sensitive(font_widgets[i], | |
| 15884 | 568 | purple_prefs_get_bool(font_prefs_set[i])); |
| 10584 | 569 | g_signal_connect(G_OBJECT(check), "toggled", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
570 | G_CALLBACK(pidgin_toggle_sensitive), |
| 10584 | 571 | font_widgets[i]); |
| 572 | g_signal_connect(G_OBJECT(font_widgets[i]), "clicked", | |
| 15884 | 573 | G_CALLBACK(purplerc_set_font), GINT_TO_POINTER(i)); |
| 10584 | 574 | } |
| 575 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
576 | frame = pidgin_make_frame(ret, _("Tools")); |
| 11940 | 577 | |
| 15882 | 578 | vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); |
| 11940 | 579 | gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0); |
| 580 | ||
| 15884 | 581 | tmp = g_strdup_printf(_("Write settings to %s%sgtkrc-2.0"), purple_user_dir(), G_DIR_SEPARATOR_S); |
|
12042
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
582 | check = gtk_button_new_with_label(tmp); |
|
b90399880391
[gaim-migrate @ 14337]
Richard Laager <rlaager@pidgin.im>
parents:
11941
diff
changeset
|
583 | g_free(tmp); |
| 11940 | 584 | gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); |
| 12546 | 585 | gtk_size_group_add_widget(labelsg, check); |
| 15884 | 586 | g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(purplerc_write), |
| 11940 | 587 | NULL); |
| 588 | ||
| 589 | check = gtk_button_new_with_label(_("Re-read gtkrc files")); | |
| 590 | gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); | |
| 12546 | 591 | gtk_size_group_add_widget(labelsg, check); |
| 15884 | 592 | g_signal_connect(G_OBJECT(check), "clicked", G_CALLBACK(purplerc_reread), |
| 11940 | 593 | NULL); |
| 594 | ||
| 10584 | 595 | gtk_widget_show_all(ret); |
| 596 | return ret; | |
| 597 | } | |
| 598 | ||
| 15884 | 599 | static PidginPluginUiInfo purplerc_ui_info = |
| 10584 | 600 | { |
| 15884 | 601 | purplerc_get_config_frame, |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12567
diff
changeset
|
602 | 0 /* page_num (Reserved) */ |
| 10584 | 603 | }; |
| 604 | ||
| 15884 | 605 | static PurplePluginInfo purplerc_info = |
| 10584 | 606 | { |
| 15884 | 607 | PURPLE_PLUGIN_MAGIC, |
| 608 | PURPLE_MAJOR_VERSION, | |
| 609 | PURPLE_MINOR_VERSION, | |
| 610 | PURPLE_PLUGIN_STANDARD, | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
611 | PIDGIN_PLUGIN_TYPE, |
| 10584 | 612 | 0, |
| 613 | NULL, | |
| 15884 | 614 | PURPLE_PRIORITY_DEFAULT, |
| 615 | "purplerc", | |
|
15442
2ff7f5308727
I think this is all the instances of 'Gaim' within pidgin/
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
616 | N_(PIDGIN_NAME " GTK+ Theme Control"), |
| 10584 | 617 | VERSION, |
| 618 | N_("Provides access to commonly used gtkrc settings."), | |
| 619 | N_("Provides access to commonly used gtkrc settings."), | |
| 620 | "Etan Reisner <deryni@eden.rutgers.edu>", | |
| 15884 | 621 | PURPLE_WEBSITE, |
| 622 | purplerc_plugin_load, | |
| 623 | purplerc_plugin_unload, | |
| 10584 | 624 | NULL, |
| 15884 | 625 | &purplerc_ui_info, |
| 10584 | 626 | NULL, |
| 627 | NULL, | |
| 628 | NULL | |
| 629 | }; | |
| 630 | ||
| 631 | static void | |
| 15884 | 632 | purplerc_init(PurplePlugin *plugin) |
| 10584 | 633 | { |
| 634 | int i; | |
| 635 | ||
| 15884 | 636 | purple_prefs_add_none("/plugins"); |
| 637 | purple_prefs_add_none("/plugins/gtk"); | |
| 638 | purple_prefs_add_none("/plugins/gtk/purplerc"); | |
| 639 | purple_prefs_add_none("/plugins/gtk/purplerc/set"); | |
| 10584 | 640 | |
| 15884 | 641 | purple_prefs_add_string("/plugins/gtk/purplerc/gtk-font-name", ""); |
| 642 | purple_prefs_add_bool("/plugins/gtk/purplerc/set/gtk-font-name", FALSE); | |
| 10584 | 643 | |
| 15884 | 644 | purple_prefs_add_string("/plugins/gtk/purplerc/gtk-key-theme-name", ""); |
| 645 | purple_prefs_add_bool("/plugins/gtk/purplerc/set/gtk-key-theme-name", FALSE); | |
| 10584 | 646 | |
| 15884 | 647 | purple_prefs_add_none("/plugins/gtk/purplerc/color"); |
| 648 | purple_prefs_add_none("/plugins/gtk/purplerc/set/color"); | |
| 10584 | 649 | for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { |
| 15884 | 650 | purple_prefs_add_string(color_prefs[i], ""); |
| 651 | purple_prefs_add_bool(color_prefs_set[i], FALSE); | |
| 10584 | 652 | } |
| 653 | ||
| 15884 | 654 | purple_prefs_add_none("/plugins/gtk/purplerc/size"); |
| 655 | purple_prefs_add_none("/plugins/gtk/purplerc/set/size"); | |
| 10584 | 656 | for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { |
| 15884 | 657 | purple_prefs_add_int(widget_size_prefs[i], 0); |
| 658 | purple_prefs_add_bool(widget_size_prefs_set[i], FALSE); | |
| 10584 | 659 | } |
| 660 | ||
| 15884 | 661 | purple_prefs_add_none("/plugins/gtk/purplerc/font"); |
| 662 | purple_prefs_add_none("/plugins/gtk/purplerc/set/font"); | |
| 10584 | 663 | for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { |
| 15884 | 664 | purple_prefs_add_string(font_prefs[i], ""); |
| 665 | purple_prefs_add_bool(font_prefs_set[i], FALSE); | |
| 10584 | 666 | } |
| 12973 | 667 | |
| 15884 | 668 | purple_prefs_add_none("/plugins/gtk/purplerc/bool"); |
| 669 | purple_prefs_add_none("/plugins/gtk/purplerc/set/bool"); | |
| 12973 | 670 | for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { |
| 15884 | 671 | purple_prefs_add_bool(widget_bool_prefs[i], TRUE); |
| 672 | purple_prefs_add_bool(widget_bool_prefs_set[i], FALSE); | |
| 12973 | 673 | } |
| 10584 | 674 | } |
| 675 | ||
| 15884 | 676 | PURPLE_INIT_PLUGIN(purplerc, purplerc_init, purplerc_info) |