Sat, 29 Jun 2013 22:10:18 +0530
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Removed data from PurpleConversationPrivate.
| 15231 | 1 | /* |
| 2 | * Conversation Colors | |
| 3 | * Copyright (C) 2006 | |
| 4 | * | |
| 5 | * This program is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU General Public License as | |
| 7 | * published by the Free Software Foundation; either version 2 of the | |
| 8 | * License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This program is distributed in the hope that it will be useful, but | |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU General Public License | |
| 16 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16749
diff
changeset
|
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16749
diff
changeset
|
18 | * 02111-1301, USA. |
| 15231 | 19 | */ |
| 20 | #include "internal.h" | |
| 21 | ||
| 22 | #define PLUGIN_ID "gtk-plugin_pack-convcolors" | |
|
15418
bf287f742a5a
[gaim-migrate @ 18149]
Luke Schierer <lschiere@pidgin.im>
parents:
15231
diff
changeset
|
23 | #define PLUGIN_NAME N_("Conversation Colors") |
|
25633
feee0c7e503f
Fix some more mis-identified plugins, like 3b3526a0...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22178
diff
changeset
|
24 | #define PLUGIN_STATIC_NAME ConversationColors |
|
15418
bf287f742a5a
[gaim-migrate @ 18149]
Luke Schierer <lschiere@pidgin.im>
parents:
15231
diff
changeset
|
25 | #define PLUGIN_SUMMARY N_("Customize colors in the conversation window") |
|
bf287f742a5a
[gaim-migrate @ 18149]
Luke Schierer <lschiere@pidgin.im>
parents:
15231
diff
changeset
|
26 | #define PLUGIN_DESCRIPTION N_("Customize colors in the conversation window") |
| 15231 | 27 | #define PLUGIN_AUTHOR "Sadrul H Chowdhury <sadrul@users.sourceforge.net>" |
| 28 | ||
| 29 | /* System headers */ | |
| 30 | #include <gdk/gdk.h> | |
| 31 | #include <glib.h> | |
| 32 | #include <gtk/gtk.h> | |
| 33 | ||
| 15884 | 34 | /* Purple headers */ |
| 15231 | 35 | #include <gtkplugin.h> |
| 36 | #include <version.h> | |
| 37 | ||
| 38 | #include <conversation.h> | |
| 39 | #include <gtkconv.h> | |
| 40 | #include <gtkprefs.h> | |
| 41 | #include <gtkutils.h> | |
| 42 | ||
| 43 | #define PREF_PREFIX "/plugins/gtk/" PLUGIN_ID | |
| 44 | #define PREF_IGNORE PREF_PREFIX "/ignore_incoming" | |
| 45 | #define PREF_CHATS PREF_PREFIX "/chats" | |
| 46 | #define PREF_IMS PREF_PREFIX "/ims" | |
| 47 | ||
| 48 | #define PREF_SEND PREF_PREFIX "/send" | |
| 49 | #define PREF_SEND_C PREF_SEND "/color" | |
| 50 | #define PREF_SEND_F PREF_SEND "/format" | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
51 | #define PREF_SEND_E PREF_SEND "/enabled" |
| 15231 | 52 | |
| 53 | #define PREF_RECV PREF_PREFIX "/recv" | |
| 54 | #define PREF_RECV_C PREF_RECV "/color" | |
| 55 | #define PREF_RECV_F PREF_RECV "/format" | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
56 | #define PREF_RECV_E PREF_RECV "/enabled" |
| 15231 | 57 | |
| 58 | #define PREF_SYSTEM PREF_PREFIX "/system" | |
| 59 | #define PREF_SYSTEM_C PREF_SYSTEM "/color" | |
| 60 | #define PREF_SYSTEM_F PREF_SYSTEM "/format" | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
61 | #define PREF_SYSTEM_E PREF_SYSTEM "/enabled" |
| 15231 | 62 | |
| 63 | #define PREF_ERROR PREF_PREFIX "/error" | |
| 64 | #define PREF_ERROR_C PREF_ERROR "/color" | |
| 65 | #define PREF_ERROR_F PREF_ERROR "/format" | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
66 | #define PREF_ERROR_E PREF_ERROR "/enabled" |
| 15231 | 67 | |
| 68 | #define PREF_NICK PREF_PREFIX "/nick" | |
| 69 | #define PREF_NICK_C PREF_NICK "/color" | |
| 70 | #define PREF_NICK_F PREF_NICK "/format" | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
71 | #define PREF_NICK_E PREF_NICK "/enabled" |
| 15231 | 72 | |
| 73 | enum | |
| 74 | { | |
| 75 | FONT_BOLD = 1 << 0, | |
| 76 | FONT_ITALIC = 1 << 1, | |
| 77 | FONT_UNDERLINE = 1 << 2 | |
| 78 | }; | |
| 79 | ||
|
22178
02521e1b838e
Prpls seem to be sending '\n' (or '\r\n') for newlines, instead of '<br>' to the core. Fixes #4545.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21789
diff
changeset
|
80 | static struct |
| 15231 | 81 | { |
| 15884 | 82 | PurpleMessageFlags flag; |
| 15231 | 83 | char *prefix; |
| 84 | const char *text; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30010
diff
changeset
|
85 | } formats[] = |
| 15231 | 86 | { |
| 15884 | 87 | {PURPLE_MESSAGE_ERROR, PREF_ERROR, N_("Error Messages")}, |
| 88 | {PURPLE_MESSAGE_NICK, PREF_NICK, N_("Highlighted Messages")}, | |
| 89 | {PURPLE_MESSAGE_SYSTEM, PREF_SYSTEM, N_("System Messages")}, | |
| 90 | {PURPLE_MESSAGE_SEND, PREF_SEND, N_("Sent Messages")}, | |
| 91 | {PURPLE_MESSAGE_RECV, PREF_RECV, N_("Received Messages")}, | |
| 15231 | 92 | {0, NULL, NULL} |
| 93 | }; | |
| 94 | ||
| 95 | static gboolean | |
| 15884 | 96 | displaying_msg(PurpleAccount *account, const char *who, char **displaying, |
| 97 | PurpleConversation *conv, PurpleMessageFlags flags) | |
| 15231 | 98 | { |
| 99 | int i; | |
| 100 | char tmp[128], *t; | |
| 101 | gboolean bold, italic, underline; | |
| 102 | int f; | |
| 103 | const char *color; | |
|
27234
82035475de62
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25633
diff
changeset
|
104 | gboolean rtl = FALSE; |
| 15231 | 105 | |
| 106 | for (i = 0; formats[i].prefix; i++) | |
| 107 | if (flags & formats[i].flag) | |
| 108 | break; | |
| 109 | ||
| 110 | if (!formats[i].prefix) | |
| 111 | return FALSE; | |
| 112 | ||
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
113 | g_snprintf(tmp, sizeof(tmp), "%s/enabled", formats[i].prefix); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
114 | |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
115 | if (!purple_prefs_get_bool(tmp) || |
|
34660
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
33683
diff
changeset
|
116 | (PURPLE_IS_IM_CONVERSATION(conv) && !purple_prefs_get_bool(PREF_IMS)) || |
|
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
33683
diff
changeset
|
117 | (PURPLE_IS_CHAT_CONVERSATION(conv) && !purple_prefs_get_bool(PREF_CHATS))) |
| 15231 | 118 | return FALSE; |
| 119 | ||
| 120 | g_snprintf(tmp, sizeof(tmp), "%s/color", formats[i].prefix); | |
| 15884 | 121 | color = purple_prefs_get_string(tmp); |
| 15231 | 122 | |
| 123 | g_snprintf(tmp, sizeof(tmp), "%s/format", formats[i].prefix); | |
| 15884 | 124 | f = purple_prefs_get_int(tmp); |
| 15231 | 125 | bold = (f & FONT_BOLD); |
| 126 | italic = (f & FONT_ITALIC); | |
| 127 | underline = (f & FONT_UNDERLINE); | |
|
27234
82035475de62
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25633
diff
changeset
|
128 | rtl = purple_markup_is_rtl(*displaying); |
| 15231 | 129 | |
| 15884 | 130 | if (purple_prefs_get_bool(PREF_IGNORE)) |
| 15231 | 131 | { |
|
22178
02521e1b838e
Prpls seem to be sending '\n' (or '\r\n') for newlines, instead of '<br>' to the core. Fixes #4545.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21789
diff
changeset
|
132 | /* This seems to be necessary, especially for received messages. */ |
|
02521e1b838e
Prpls seem to be sending '\n' (or '\r\n') for newlines, instead of '<br>' to the core. Fixes #4545.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21789
diff
changeset
|
133 | t = *displaying; |
|
02521e1b838e
Prpls seem to be sending '\n' (or '\r\n') for newlines, instead of '<br>' to the core. Fixes #4545.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21789
diff
changeset
|
134 | *displaying = purple_strreplace(t, "\n", "<br>"); |
|
02521e1b838e
Prpls seem to be sending '\n' (or '\r\n') for newlines, instead of '<br>' to the core. Fixes #4545.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21789
diff
changeset
|
135 | g_free(t); |
|
02521e1b838e
Prpls seem to be sending '\n' (or '\r\n') for newlines, instead of '<br>' to the core. Fixes #4545.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21789
diff
changeset
|
136 | |
| 15231 | 137 | t = *displaying; |
| 15884 | 138 | *displaying = purple_markup_strip_html(t); |
| 15231 | 139 | g_free(t); |
|
15488
d3de0d1f569d
Fix bug #1645435. Thanks to Dennis Ristuccia (more commonly known as EvilDennisR) for helping me find the bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15481
diff
changeset
|
140 | |
|
d3de0d1f569d
Fix bug #1645435. Thanks to Dennis Ristuccia (more commonly known as EvilDennisR) for helping me find the bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15481
diff
changeset
|
141 | t = *displaying; |
|
d3de0d1f569d
Fix bug #1645435. Thanks to Dennis Ristuccia (more commonly known as EvilDennisR) for helping me find the bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15481
diff
changeset
|
142 | *displaying = g_markup_escape_text(t, -1); |
|
d3de0d1f569d
Fix bug #1645435. Thanks to Dennis Ristuccia (more commonly known as EvilDennisR) for helping me find the bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15481
diff
changeset
|
143 | g_free(t); |
|
d3de0d1f569d
Fix bug #1645435. Thanks to Dennis Ristuccia (more commonly known as EvilDennisR) for helping me find the bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15481
diff
changeset
|
144 | |
|
15481
6e9da7b5bd5c
Fix convcolors to not unlinkify the links.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15435
diff
changeset
|
145 | /* Restore the links */ |
|
6e9da7b5bd5c
Fix convcolors to not unlinkify the links.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15435
diff
changeset
|
146 | t = *displaying; |
| 15884 | 147 | *displaying = purple_markup_linkify(t); |
|
15481
6e9da7b5bd5c
Fix convcolors to not unlinkify the links.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15435
diff
changeset
|
148 | g_free(t); |
| 15231 | 149 | } |
| 150 | ||
| 151 | if (color && *color) | |
| 152 | { | |
| 153 | t = *displaying; | |
| 154 | *displaying = g_strdup_printf("<FONT COLOR=\"%s\">%s</FONT>", color, t); | |
| 155 | g_free(t); | |
| 156 | } | |
| 157 | ||
| 158 | t = *displaying; | |
|
27234
82035475de62
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25633
diff
changeset
|
159 | *displaying = g_strdup_printf("%s%s%s%s%s%s%s%s%s", |
| 15231 | 160 | bold ? "<B>" : "</B>", |
| 161 | italic ? "<I>" : "</I>", | |
| 162 | underline ? "<U>" : "</U>", | |
|
27234
82035475de62
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25633
diff
changeset
|
163 | rtl ? "<SPAN style=\"direction:rtl;text-align:right;\">" : "", |
|
82035475de62
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25633
diff
changeset
|
164 | t, |
|
82035475de62
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25633
diff
changeset
|
165 | rtl ? "</SPAN>" : "", |
| 15231 | 166 | bold ? "</B>" : "<B>", |
| 167 | italic ? "</I>" : "<I>", | |
| 168 | underline ? "</U>" : "<U>" | |
| 169 | ); | |
| 170 | g_free(t); | |
| 171 | ||
| 172 | return FALSE; | |
| 173 | } | |
| 174 | ||
| 175 | static gboolean | |
| 15884 | 176 | plugin_load(PurplePlugin *plugin) |
| 15231 | 177 | { |
| 15884 | 178 | purple_signal_connect(pidgin_conversations_get_handle(), |
| 15231 | 179 | "displaying-im-msg", plugin, |
| 15884 | 180 | PURPLE_CALLBACK(displaying_msg), NULL); |
| 181 | purple_signal_connect(pidgin_conversations_get_handle(), | |
| 15231 | 182 | "displaying-chat-msg", plugin, |
| 15884 | 183 | PURPLE_CALLBACK(displaying_msg), NULL); |
| 15231 | 184 | return TRUE; |
| 185 | } | |
| 186 | ||
| 187 | static gboolean | |
| 15884 | 188 | plugin_unload(PurplePlugin *plugin) |
| 15231 | 189 | { |
| 190 | return TRUE; | |
| 191 | } | |
| 192 | ||
| 15884 | 193 | /* Ripped from PurpleRC */ |
| 15231 | 194 | static void |
| 195 | color_response(GtkDialog *color_dialog, gint response, const char *data) | |
| 196 | { | |
| 197 | if (response == GTK_RESPONSE_OK) | |
| 198 | { | |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27234
diff
changeset
|
199 | GtkWidget *colorsel = |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27234
diff
changeset
|
200 | gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(color_dialog)); |
| 15231 | 201 | GdkColor color; |
| 202 | char colorstr[8]; | |
| 203 | char tmp[128]; | |
| 204 | ||
| 205 | gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(colorsel), &color); | |
| 206 | ||
| 207 | g_snprintf(colorstr, sizeof(colorstr), "#%02X%02X%02X", | |
| 208 | color.red/256, color.green/256, color.blue/256); | |
| 209 | ||
| 210 | g_snprintf(tmp, sizeof(tmp), "%s/color", data); | |
| 211 | ||
| 15884 | 212 | purple_prefs_set_string(tmp, colorstr); |
| 15231 | 213 | } |
| 214 | ||
| 215 | gtk_widget_destroy(GTK_WIDGET(color_dialog)); | |
| 216 | } | |
| 217 | ||
| 218 | static void | |
| 219 | set_color(GtkWidget *widget, const char *data) | |
| 220 | { | |
| 221 | GtkWidget *color_dialog = NULL; | |
| 222 | GdkColor color; | |
| 223 | char title[128]; | |
| 224 | char tmp[128]; | |
| 225 | ||
| 226 | g_snprintf(title, sizeof(title), _("Select Color for %s"), _(data)); | |
| 227 | color_dialog = gtk_color_selection_dialog_new(title); | |
| 228 | g_signal_connect(G_OBJECT(color_dialog), "response", | |
| 229 | G_CALLBACK(color_response), (gpointer)data); | |
| 230 | ||
| 231 | g_snprintf(tmp, sizeof(tmp), "%s/color", data); | |
| 15884 | 232 | if (gdk_color_parse(purple_prefs_get_string(tmp), &color)) |
| 15231 | 233 | { |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27234
diff
changeset
|
234 | gtk_color_selection_set_current_color(GTK_COLOR_SELECTION( |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27234
diff
changeset
|
235 | gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(color_dialog))), |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27234
diff
changeset
|
236 | &color); |
| 15231 | 237 | } |
| 238 | ||
| 239 | gtk_window_present(GTK_WINDOW(color_dialog)); | |
| 240 | } | |
| 241 | ||
| 242 | static void | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
243 | toggle_enabled(GtkWidget *widget, gpointer data) |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
244 | { |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
245 | const char *prefix = (char *)data; |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
246 | gboolean e; |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
247 | char tmp[128]; |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
248 | |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
249 | g_snprintf(tmp, sizeof(tmp), "%s/enabled", prefix); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
250 | e = purple_prefs_get_bool(tmp); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
251 | purple_prefs_set_bool(tmp, !e); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
252 | } |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
253 | |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
254 | static void |
| 15231 | 255 | toggle_something(const char *prefix, int format) |
| 256 | { | |
| 257 | int f; | |
| 258 | char tmp[128]; | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
259 | |
| 15231 | 260 | g_snprintf(tmp, sizeof(tmp), "%s/format", prefix); |
| 15884 | 261 | f = purple_prefs_get_int(tmp); |
| 15231 | 262 | f ^= format; |
| 15884 | 263 | purple_prefs_set_int(tmp, f); |
| 15231 | 264 | } |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
265 | |
| 15231 | 266 | static void |
| 267 | toggle_bold(GtkWidget *widget, gpointer data) | |
| 268 | { | |
| 269 | toggle_something(data, FONT_BOLD); | |
| 270 | } | |
| 271 | ||
| 272 | static void | |
| 273 | toggle_italic(GtkWidget *widget, gpointer data) | |
| 274 | { | |
| 275 | toggle_something(data, FONT_ITALIC); | |
| 276 | } | |
| 277 | ||
| 278 | static void | |
| 279 | toggle_underline(GtkWidget *widget, gpointer data) | |
| 280 | { | |
| 281 | toggle_something(data, FONT_UNDERLINE); | |
| 282 | } | |
| 283 | ||
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
284 | static void |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
285 | enable_toggled(const char *name, PurplePrefType type, gconstpointer val, gpointer data) |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
286 | { |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
287 | GtkWidget *widget = (GtkWidget *)data; |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
288 | |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
289 | gtk_widget_set_sensitive(widget, GPOINTER_TO_INT(val)); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
290 | } |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
291 | |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
292 | static void |
|
33133
9a31f084f259
Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
293 | disconnect_prefs_callbacks(GtkAdjustment *object, gpointer data) |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
294 | { |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
295 | PurplePlugin *plugin = (PurplePlugin *)data; |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
296 | |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
297 | purple_prefs_disconnect_by_handle(plugin); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
298 | } |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
299 | |
| 15231 | 300 | static GtkWidget * |
| 15884 | 301 | get_config_frame(PurplePlugin *plugin) |
| 15231 | 302 | { |
| 303 | GtkWidget *ret; | |
| 304 | GtkWidget *frame; | |
| 305 | int i; | |
| 306 | ||
| 15882 | 307 | ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); |
| 308 | gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER); | |
| 15231 | 309 | |
| 310 | for (i = 0; formats[i].prefix; i++) | |
| 311 | { | |
| 312 | char tmp[128]; | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
313 | char tmp2[128]; |
| 15231 | 314 | int f; |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
315 | gboolean e; |
| 15231 | 316 | GtkWidget *vbox, *hbox, *button; |
| 317 | ||
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
318 | g_snprintf(tmp2, sizeof(tmp2), "%s/enabled", formats[i].prefix); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
319 | e = purple_prefs_get_bool(tmp2); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
320 | |
| 15231 | 321 | g_snprintf(tmp, sizeof(tmp), "%s/format", formats[i].prefix); |
| 15884 | 322 | f = purple_prefs_get_int(tmp); |
| 15231 | 323 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15488
diff
changeset
|
324 | frame = pidgin_make_frame(ret, _(formats[i].text)); |
| 15882 | 325 | vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
| 15231 | 326 | gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0); |
| 327 | ||
| 15882 | 328 | hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
| 15231 | 329 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 330 | ||
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
331 | button = gtk_check_button_new_with_label(_("Enabled")); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
332 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
333 | if (e) |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
334 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
335 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(toggle_enabled), |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
336 | formats[i].prefix); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
337 | |
| 15568 | 338 | button = pidgin_pixbuf_button_from_stock(" Color", GTK_STOCK_SELECT_COLOR, |
| 339 | PIDGIN_BUTTON_HORIZONTAL); | |
| 15231 | 340 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
| 341 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_color), | |
| 342 | formats[i].prefix); | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
343 | gtk_widget_set_sensitive(button, e); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
344 | purple_prefs_connect_callback(plugin, tmp2, enable_toggled, button); |
| 15231 | 345 | |
| 346 | button = gtk_check_button_new_with_label(_("Bold")); | |
| 347 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 348 | if (f & FONT_BOLD) | |
| 349 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); | |
| 350 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(toggle_bold), | |
| 351 | formats[i].prefix); | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
352 | gtk_widget_set_sensitive(button, e); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
353 | purple_prefs_connect_callback(plugin, tmp2, enable_toggled, button); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
354 | |
| 15231 | 355 | button = gtk_check_button_new_with_label(_("Italic")); |
| 356 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 357 | if (f & FONT_ITALIC) | |
| 358 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); | |
| 359 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(toggle_italic), | |
| 360 | formats[i].prefix); | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
361 | gtk_widget_set_sensitive(button, e); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
362 | purple_prefs_connect_callback(plugin, tmp2, enable_toggled, button); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
363 | |
| 15231 | 364 | button = gtk_check_button_new_with_label(_("Underline")); |
| 365 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 366 | if (f & FONT_UNDERLINE) | |
| 367 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); | |
| 368 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 369 | G_CALLBACK(toggle_underline), formats[i].prefix); | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
370 | gtk_widget_set_sensitive(button, e); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
371 | purple_prefs_connect_callback(plugin, tmp2, enable_toggled, button); |
| 15231 | 372 | } |
| 373 | ||
|
33133
9a31f084f259
Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
374 | g_signal_connect(G_OBJECT(ret), "destroy", G_CALLBACK(disconnect_prefs_callbacks), plugin); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15488
diff
changeset
|
375 | frame = pidgin_make_frame(ret, _("General")); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15488
diff
changeset
|
376 | pidgin_prefs_checkbox(_("Ignore incoming format"), PREF_IGNORE, frame); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15488
diff
changeset
|
377 | pidgin_prefs_checkbox(_("Apply in Chats"), PREF_CHATS, frame); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15488
diff
changeset
|
378 | pidgin_prefs_checkbox(_("Apply in IMs"), PREF_IMS, frame); |
| 15231 | 379 | |
| 380 | gtk_widget_show_all(ret); | |
| 381 | return ret; | |
| 382 | } | |
| 383 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30010
diff
changeset
|
384 | static PidginPluginUiInfo ui_info = |
| 15231 | 385 | { |
| 386 | get_config_frame, | |
| 387 | 0, | |
|
16749
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
388 | |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
389 | /* padding */ |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
390 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
391 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
392 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
393 | NULL |
| 15231 | 394 | }; |
| 395 | ||
| 15884 | 396 | static PurplePluginInfo info = |
| 15231 | 397 | { |
| 15884 | 398 | PURPLE_PLUGIN_MAGIC, /* Magic */ |
| 399 | PURPLE_MAJOR_VERSION, /* Purple Major Version */ | |
| 400 | PURPLE_MINOR_VERSION, /* Purple Minor Version */ | |
| 401 | PURPLE_PLUGIN_STANDARD, /* plugin type */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15488
diff
changeset
|
402 | PIDGIN_PLUGIN_TYPE, /* ui requirement */ |
| 15231 | 403 | 0, /* flags */ |
| 404 | NULL, /* dependencies */ | |
| 15884 | 405 | PURPLE_PRIORITY_DEFAULT, /* priority */ |
| 15231 | 406 | |
| 407 | PLUGIN_ID, /* plugin id */ | |
|
15418
bf287f742a5a
[gaim-migrate @ 18149]
Luke Schierer <lschiere@pidgin.im>
parents:
15231
diff
changeset
|
408 | PLUGIN_NAME, /* name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
409 | DISPLAY_VERSION, /* version */ |
|
15418
bf287f742a5a
[gaim-migrate @ 18149]
Luke Schierer <lschiere@pidgin.im>
parents:
15231
diff
changeset
|
410 | PLUGIN_SUMMARY, /* summary */ |
|
bf287f742a5a
[gaim-migrate @ 18149]
Luke Schierer <lschiere@pidgin.im>
parents:
15231
diff
changeset
|
411 | PLUGIN_DESCRIPTION, /* description */ |
| 15231 | 412 | PLUGIN_AUTHOR, /* author */ |
| 15884 | 413 | PURPLE_WEBSITE, /* website */ |
| 15231 | 414 | |
| 415 | plugin_load, /* load */ | |
| 416 | plugin_unload, /* unload */ | |
| 417 | NULL, /* destroy */ | |
| 418 | ||
| 419 | &ui_info, /* ui_info */ | |
| 420 | NULL, /* extra_info */ | |
| 421 | NULL, /* prefs_info */ | |
|
16749
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
422 | NULL, /* actions */ |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
423 | |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
424 | /* padding */ |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
425 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
426 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
427 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
428 | NULL |
| 15231 | 429 | }; |
| 430 | ||
| 431 | static void | |
| 15884 | 432 | init_plugin(PurplePlugin *plugin) |
| 15231 | 433 | { |
| 15884 | 434 | purple_prefs_add_none(PREF_PREFIX); |
| 15231 | 435 | |
| 15884 | 436 | purple_prefs_add_bool(PREF_IGNORE, TRUE); |
| 437 | purple_prefs_add_bool(PREF_CHATS, TRUE); | |
| 438 | purple_prefs_add_bool(PREF_IMS, TRUE); | |
| 15231 | 439 | |
| 15884 | 440 | purple_prefs_add_none(PREF_SEND); |
| 441 | purple_prefs_add_none(PREF_RECV); | |
| 442 | purple_prefs_add_none(PREF_SYSTEM); | |
| 443 | purple_prefs_add_none(PREF_ERROR); | |
| 444 | purple_prefs_add_none(PREF_NICK); | |
| 15231 | 445 | |
| 15884 | 446 | purple_prefs_add_string(PREF_SEND_C, "#909090"); |
| 447 | purple_prefs_add_string(PREF_RECV_C, "#000000"); | |
| 448 | purple_prefs_add_string(PREF_SYSTEM_C, "#50a050"); | |
| 449 | purple_prefs_add_string(PREF_ERROR_C, "#ff0000"); | |
| 450 | purple_prefs_add_string(PREF_NICK_C, "#0000dd"); | |
| 15231 | 451 | |
| 15884 | 452 | purple_prefs_add_int(PREF_SEND_F, 0); |
| 453 | purple_prefs_add_int(PREF_RECV_F, 0); | |
| 454 | purple_prefs_add_int(PREF_SYSTEM_F, FONT_ITALIC); | |
| 455 | purple_prefs_add_int(PREF_ERROR_F, FONT_BOLD | FONT_UNDERLINE); | |
| 456 | purple_prefs_add_int(PREF_NICK_F, FONT_BOLD); | |
|
21789
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
457 | |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
458 | purple_prefs_add_bool(PREF_SEND_E, TRUE); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
459 | purple_prefs_add_bool(PREF_RECV_E, TRUE); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
460 | purple_prefs_add_bool(PREF_SYSTEM_E, TRUE); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
461 | purple_prefs_add_bool(PREF_ERROR_E, TRUE); |
|
1ba3811fdba4
Add an option per message type to enable (/disable) the overriding of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20288
diff
changeset
|
462 | purple_prefs_add_bool(PREF_NICK_E, TRUE); |
| 15231 | 463 | } |
| 464 | ||
| 15884 | 465 | PURPLE_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info) |