Wed, 05 Aug 2015 12:24:06 -0500
Add a note for translators
This is being done in response to a question received on Transifex.
| 6302 | 1 | /* |
| 15884 | 2 | * Purple buddy notification plugin. |
| 6302 | 3 | * |
| 4 | * Copyright (C) 2000-2001, Eric Warmenhoven (original code) | |
| 5 | * Copyright (C) 2002, Etan Reisner <deryni@eden.rutgers.edu> (rewritten code) | |
| 6 | * Copyright (C) 2003, Christian Hammond (update for changed API) | |
|
6322
35fdae8a156f
[gaim-migrate @ 6821]
Mark Doliner <markdoliner@pidgin.im>
parents:
6302
diff
changeset
|
7 | * Copyright (C) 2003, Brian Tarricone <bjt23@cornell.edu> (mostly rewritten) |
| 6302 | 8 | * Copyright (C) 2003, Mark Doliner (minor cleanup) |
| 6977 | 9 | * Copyright (C) 2003, Etan Reisner (largely rewritten again) |
| 6302 | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 3374 | 20 | * |
| 6302 | 21 | * You should have received a copy of the GNU General Public License |
| 22 | * 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:
19717
diff
changeset
|
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 6302 | 24 | * |
| 25 | */ | |
| 26 | ||
| 10606 | 27 | /* TODO |
| 28 | * 22:22:17 <seanegan> deryni: speaking of notify.c... you know what else | |
| 29 | * might be a neat feature? | |
| 30 | * 22:22:30 <seanegan> Changing the window icon. | |
| 31 | * 22:23:25 <deryni> seanegan: To what? | |
| 32 | * 22:23:42 <seanegan> deryni: I dunno. Flash it between the regular icon and | |
| 33 | * blank or something. | |
| 15884 | 34 | * 22:23:53 <deryni> Also I think purple might re-set that sort of frequently, |
| 10606 | 35 | * but I'd have to look. |
| 11581 | 36 | * 22:25:16 <seanegan> deryni: I keep my conversations in one workspace and am |
| 10606 | 37 | * frequently in an another, and the icon flashing in the pager would be a |
| 38 | * neat visual clue. | |
| 39 | */ | |
| 40 | ||
| 6302 | 41 | /* |
| 42 | * From Etan, 2002: | |
| 43 | * -Added config dialog | |
| 44 | * -Added control over notification method | |
| 45 | * -Added control over when to release notification | |
| 46 | * | |
| 47 | * -Added option to get notification for chats also | |
| 48 | * -Cleaned up code | |
| 49 | * -Added option to notify on click as it's own option | |
| 50 | * rather then as what happens when on focus isn't clicked | |
| 51 | * -Added apply button to change the denotification methods for | |
| 52 | * open conversation windows | |
| 53 | * -Fixed apply to conversations, count now keeps count across applies | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
54 | * -Fixed(?) memory leak, and in the process fixed some stupidities |
| 6302 | 55 | * -Hit enter when done editing the title string entry box to save it |
| 3392 | 56 | * |
| 57 | * Thanks to Carles Pina i Estany <carles@pinux.info> | |
| 58 | * for count of new messages option | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
59 | * |
| 6302 | 60 | * From Brian, 20 July 2003: |
| 61 | * -Use new xml prefs | |
| 62 | * -Better handling of notification states tracking | |
| 63 | * -Better pref change handling | |
| 64 | * -Fixed a possible memleak and possible crash (rare) | |
| 65 | * -Use gtk_window_get_title() rather than gtkwin->title | |
| 66 | * -Other random fixes and cleanups | |
| 6977 | 67 | * |
| 9298 | 68 | * Etan again, 12 August 2003: |
| 6977 | 69 | * -Better use of the new xml prefs |
| 70 | * -Removed all bitmask stuff | |
| 71 | * -Even better pref change handling | |
| 72 | * -Removed unnecessary functions | |
| 73 | * -Reworking of notification/unnotification stuff | |
| 74 | * -Header file include cleanup | |
| 75 | * -General code cleanup | |
| 9298 | 76 | * |
| 77 | * Etan yet again, 04 April 2004: | |
| 78 | * -Re-added Urgent option | |
| 79 | * -Re-added unnotify on focus option (still needs work, as it will only | |
| 80 | * react to focus-in events when the entry or history widgets are focused) | |
| 10492 | 81 | * |
| 82 | * Sean, 08 January, 2005: | |
| 15884 | 83 | * -Added Raise option, formally in Purple proper |
| 3392 | 84 | */ |
| 85 | ||
| 9791 | 86 | #include "internal.h" |
| 15577 | 87 | #include "pidgin.h" |
| 10492 | 88 | #include "gtkprefs.h" |
| 6302 | 89 | |
|
12604
893fbf89317c
[gaim-migrate @ 14939]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
90 | #include "conversation.h" |
| 6302 | 91 | #include "prefs.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
92 | #include "signals.h" |
| 9943 | 93 | #include "version.h" |
| 11581 | 94 | #include "debug.h" |
|
4202
8b92de3b1c07
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
diff
changeset
|
95 | |
| 6302 | 96 | #include "gtkplugin.h" |
| 97 | #include "gtkutils.h" | |
| 98 | ||
| 99 | #define NOTIFY_PLUGIN_ID "gtk-x11-notify" | |
| 3710 | 100 | |
| 15884 | 101 | static PurplePlugin *my_plugin = NULL; |
|
33472
24393ecae82e
Make this plugin a bit more friendly with Quartz-enabled GTK+ in MacPorts.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30706
diff
changeset
|
102 | #ifdef HAVE_X11 |
| 14389 | 103 | static GdkAtom _Cardinal = GDK_NONE; |
| 15884 | 104 | static GdkAtom _PurpleUnseenCount = GDK_NONE; |
| 15527 | 105 | #endif |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
106 | |
| 6302 | 107 | /* notification set/unset */ |
| 15884 | 108 | static int notify(PurpleConversation *conv, gboolean increment); |
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
109 | static void notify_win(PidginWindow *purplewin, PurpleConversation *conv); |
| 15884 | 110 | static void unnotify(PurpleConversation *conv, gboolean reset); |
| 14389 | 111 | static int unnotify_cb(GtkWidget *widget, gpointer data, |
| 15884 | 112 | PurpleConversation *conv); |
| 6302 | 113 | |
| 114 | /* gtk widget callbacks for prefs panel */ | |
| 6977 | 115 | static void type_toggle_cb(GtkWidget *widget, gpointer data); |
| 116 | static void method_toggle_cb(GtkWidget *widget, gpointer data); | |
| 117 | static void notify_toggle_cb(GtkWidget *widget, gpointer data); | |
| 14389 | 118 | static gboolean options_entry_cb(GtkWidget *widget, GdkEventFocus *event, |
| 119 | gpointer data); | |
|
12397
aa64ec827fdf
[gaim-migrate @ 14704]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
120 | static void apply_method(void); |
|
aa64ec827fdf
[gaim-migrate @ 14704]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
121 | static void apply_notify(void); |
| 191 | 122 | |
| 6977 | 123 | /* string function */ |
| 15884 | 124 | static void handle_string(PidginWindow *purplewin); |
| 6302 | 125 | |
| 14389 | 126 | /* count_title function */ |
| 15884 | 127 | static void handle_count_title(PidginWindow *purplewin); |
| 14389 | 128 | |
| 129 | /* count_xprop function */ | |
| 15884 | 130 | static void handle_count_xprop(PidginWindow *purplewin); |
| 6302 | 131 | |
| 6977 | 132 | /* urgent function */ |
| 15884 | 133 | static void handle_urgent(PidginWindow *purplewin, gboolean set); |
| 10606 | 134 | |
| 135 | /* raise function */ | |
| 15884 | 136 | static void handle_raise(PidginWindow *purplewin); |
| 3710 | 137 | |
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
138 | /* present function */ |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
139 | static void handle_present(PurpleConversation *conv); |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
140 | |
| 6302 | 141 | /****************************************/ |
| 142 | /* Begin doing stuff below this line... */ | |
| 143 | /****************************************/ | |
| 14389 | 144 | static guint |
| 15884 | 145 | count_messages(PidginWindow *purplewin) |
| 9298 | 146 | { |
| 14389 | 147 | guint count = 0; |
| 14385 | 148 | GList *convs = NULL, *l; |
| 9298 | 149 | |
| 15884 | 150 | for (convs = purplewin->gtkconvs; convs != NULL; convs = convs->next) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
151 | PidginConversation *conv = convs->data; |
| 14385 | 152 | for (l = conv->convs; l != NULL; l = l->next) { |
| 15884 | 153 | count += GPOINTER_TO_INT(purple_conversation_get_data(l->data, "notify-message-count")); |
| 14385 | 154 | } |
| 9298 | 155 | } |
| 156 | ||
| 157 | return count; | |
| 158 | } | |
| 6302 | 159 | |
| 6977 | 160 | static int |
| 15884 | 161 | notify(PurpleConversation *conv, gboolean increment) |
| 6977 | 162 | { |
| 14385 | 163 | gint count; |
| 14326 | 164 | gboolean has_focus; |
| 15884 | 165 | PidginWindow *purplewin = NULL; |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
166 | |
|
19717
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
167 | if (conv == NULL || PIDGIN_CONVERSATION(conv) == NULL) |
| 6302 | 168 | return 0; |
| 169 | ||
| 6977 | 170 | /* We want to remove the notifications, but not reset the counter */ |
| 171 | unnotify(conv, FALSE); | |
| 172 | ||
| 15884 | 173 | purplewin = PIDGIN_CONVERSATION(conv)->win; |
| 5021 | 174 | |
| 6977 | 175 | /* If we aren't doing notifications for this type of conversation, return */ |
| 15884 | 176 | if (((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) && |
| 177 | !purple_prefs_get_bool("/plugins/gtk/X11/notify/type_im")) || | |
| 178 | ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) && | |
| 179 | !purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat"))) | |
| 6977 | 180 | return 0; |
| 4203 | 181 | |
| 15884 | 182 | g_object_get(G_OBJECT(purplewin->window), |
| 9298 | 183 | "has-toplevel-focus", &has_focus, NULL); |
| 3374 | 184 | |
| 15884 | 185 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/type_focused") || |
|
10984
8d8c654bf34d
[gaim-migrate @ 12819]
Mark Doliner <markdoliner@pidgin.im>
parents:
10971
diff
changeset
|
186 | !has_focus) { |
| 14385 | 187 | if (increment) { |
| 15884 | 188 | count = GPOINTER_TO_INT(purple_conversation_get_data(conv, "notify-message-count")); |
| 14385 | 189 | count++; |
| 15884 | 190 | purple_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(count)); |
| 14385 | 191 | } |
| 192 | ||
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
193 | notify_win(purplewin, conv); |
| 6977 | 194 | } |
| 6302 | 195 | |
| 196 | return 0; | |
| 197 | } | |
| 198 | ||
| 9298 | 199 | static void |
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
200 | notify_win(PidginWindow *purplewin, PurpleConversation *conv) |
| 9298 | 201 | { |
| 15884 | 202 | if (count_messages(purplewin) <= 0) |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
203 | return; |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
204 | |
| 15884 | 205 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_count")) |
| 206 | handle_count_title(purplewin); | |
| 207 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_count_xprop")) | |
| 208 | handle_count_xprop(purplewin); | |
| 209 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_string")) | |
| 210 | handle_string(purplewin); | |
| 211 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent")) | |
| 212 | handle_urgent(purplewin, TRUE); | |
| 213 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_raise")) | |
| 214 | handle_raise(purplewin); | |
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
215 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_present")) |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
216 | handle_present(conv); |
| 9298 | 217 | } |
| 218 | ||
| 219 | static void | |
| 15884 | 220 | unnotify(PurpleConversation *conv, gboolean reset) |
| 9298 | 221 | { |
| 15884 | 222 | PurpleConversation *active_conv = NULL; |
| 223 | PidginWindow *purplewin = NULL; | |
| 9298 | 224 | |
| 225 | g_return_if_fail(conv != NULL); | |
|
19717
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
226 | if (PIDGIN_CONVERSATION(conv) == NULL) |
|
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
227 | return; |
| 9298 | 228 | |
| 15884 | 229 | purplewin = PIDGIN_CONVERSATION(conv)->win; |
| 230 | active_conv = pidgin_conv_window_get_active_conversation(purplewin); | |
| 9298 | 231 | |
| 232 | /* reset the conversation window title */ | |
| 15884 | 233 | purple_conversation_autoset_title(active_conv); |
| 9298 | 234 | |
| 235 | if (reset) { | |
| 14389 | 236 | /* Only need to actually remove the urgent hinting here, since |
| 237 | * removing it just to have it readded in re-notify is an | |
| 238 | * unnecessary couple extra RTs to the server */ | |
| 15884 | 239 | handle_urgent(purplewin, FALSE); |
| 240 | purple_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); | |
| 14389 | 241 | /* Same logic as for the urgent hint, xprops are also a RT. |
| 242 | * This needs to go here so that it gets the updated message | |
| 243 | * count. */ | |
| 15884 | 244 | handle_count_xprop(purplewin); |
| 9298 | 245 | } |
| 246 | ||
| 247 | return; | |
| 248 | } | |
| 249 | ||
| 250 | static int | |
| 15884 | 251 | unnotify_cb(GtkWidget *widget, gpointer data, PurpleConversation *conv) |
| 9298 | 252 | { |
| 15884 | 253 | if (GPOINTER_TO_INT(purple_conversation_get_data(conv, "notify-message-count")) != 0) |
| 9298 | 254 | unnotify(conv, TRUE); |
| 255 | ||
| 256 | return 0; | |
| 257 | } | |
| 258 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
259 | static gboolean |
| 15884 | 260 | message_displayed_cb(PurpleAccount *account, const char *who, char *message, |
| 261 | PurpleConversation *conv, PurpleMessageFlags flags) | |
| 6977 | 262 | { |
|
37190
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
263 | PurpleConversationType ct = purple_conversation_get_type(conv); |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
264 | |
|
37190
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
265 | /* Ignore anything that's not a received message or a system message */ |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
266 | if (!(flags & (PURPLE_MESSAGE_RECV|PURPLE_MESSAGE_SYSTEM))) |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
267 | return FALSE; |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
268 | /* Don't highlight for delayed messages */ |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
269 | if ((flags & PURPLE_MESSAGE_RECV) && (flags & PURPLE_MESSAGE_DELAYED)) |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
270 | return FALSE; |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
271 | /* Check whether to highlight for system message for either chat or IM */ |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
272 | if (flags & PURPLE_MESSAGE_SYSTEM) { |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
273 | switch (ct) { |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
274 | case PURPLE_CONV_TYPE_CHAT: |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
275 | if (!purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat_sys")) |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
276 | return FALSE; |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
277 | break; |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
278 | case PURPLE_CONV_TYPE_IM: |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
279 | if (!purple_prefs_get_bool("/plugins/gtk/X11/notify/type_im_sys")) |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
280 | return FALSE; |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
281 | break; |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
282 | default: |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
283 | /* System message not from chat or IM, ignore */ |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
284 | return FALSE; |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
285 | } |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
286 | } |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
287 | /* If it's a chat, check if we should only highlight when nick is mentioned */ |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
288 | if (ct == PURPLE_CONV_TYPE_CHAT && |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
289 | purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat_nick") && |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
290 | !(flags & PURPLE_MESSAGE_NICK)) |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
291 | return FALSE; |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
292 | |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
293 | /* Nothing speaks against notifying, do so */ |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
294 | notify(conv, TRUE); |
| 9298 | 295 | |
| 296 | return FALSE; | |
| 297 | } | |
| 298 | ||
| 6977 | 299 | static void |
| 15884 | 300 | im_sent_im(PurpleAccount *account, const char *receiver, const char *message) |
| 14389 | 301 | { |
| 15884 | 302 | PurpleConversation *conv = NULL; |
| 9298 | 303 | |
| 15884 | 304 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) { |
| 305 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, receiver, account); | |
| 9298 | 306 | unnotify(conv, TRUE); |
| 307 | } | |
| 308 | } | |
| 309 | ||
| 310 | static void | |
| 15884 | 311 | chat_sent_im(PurpleAccount *account, const char *message, int id) |
| 6977 | 312 | { |
| 15884 | 313 | PurpleConversation *conv = NULL; |
| 6977 | 314 | |
| 15884 | 315 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) { |
| 316 | conv = purple_find_chat(purple_account_get_connection(account), id); | |
| 6977 | 317 | unnotify(conv, TRUE); |
| 318 | } | |
| 3710 | 319 | } |
| 320 | ||
| 6977 | 321 | static int |
| 15884 | 322 | attach_signals(PurpleConversation *conv) |
| 6977 | 323 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
324 | PidginConversation *gtkconv = NULL; |
| 11728 | 325 | GSList *imhtml_ids = NULL, *entry_ids = NULL; |
| 6977 | 326 | guint id; |
| 327 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
328 | gtkconv = PIDGIN_CONVERSATION(conv); |
| 11581 | 329 | if (!gtkconv) { |
| 15884 | 330 | purple_debug_misc("notify", "Failed to find gtkconv\n"); |
| 11581 | 331 | return 0; |
| 332 | } | |
| 333 | ||
| 15884 | 334 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_focus")) { |
| 14389 | 335 | /* TODO should really find a way to make this work no matter |
| 336 | * where the focus is inside the conv window, without having | |
| 337 | * to bind to focus-in-event on the g(d|t)kwindow */ | |
| 9298 | 338 | /* try setting the signal on the focus-in-event for |
| 339 | * gtkwin->notebook->container? */ | |
| 340 | id = g_signal_connect(G_OBJECT(gtkconv->entry), "focus-in-event", | |
| 341 | G_CALLBACK(unnotify_cb), conv); | |
| 11728 | 342 | entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id)); |
| 9298 | 343 | |
| 344 | id = g_signal_connect(G_OBJECT(gtkconv->imhtml), "focus-in-event", | |
| 345 | G_CALLBACK(unnotify_cb), conv); | |
| 11728 | 346 | imhtml_ids = g_slist_append(imhtml_ids, GUINT_TO_POINTER(id)); |
| 6977 | 347 | } |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
348 | |
| 15884 | 349 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_click")) { |
| 14389 | 350 | /* TODO similarly should really find a way to allow for |
| 351 | * clicking in other places of the window */ | |
| 9298 | 352 | id = g_signal_connect(G_OBJECT(gtkconv->entry), "button-press-event", |
| 353 | G_CALLBACK(unnotify_cb), conv); | |
| 6977 | 354 | entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id)); |
| 12286 | 355 | |
| 356 | id = g_signal_connect(G_OBJECT(gtkconv->imhtml), "button-press-event", | |
| 357 | G_CALLBACK(unnotify_cb), conv); | |
| 358 | imhtml_ids = g_slist_append(imhtml_ids, GUINT_TO_POINTER(id)); | |
| 3374 | 359 | } |
| 3710 | 360 | |
| 15884 | 361 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_type")) { |
| 9298 | 362 | id = g_signal_connect(G_OBJECT(gtkconv->entry), "key-press-event", |
| 363 | G_CALLBACK(unnotify_cb), conv); | |
| 6977 | 364 | entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id)); |
| 3374 | 365 | } |
| 366 | ||
| 15884 | 367 | purple_conversation_set_data(conv, "notify-imhtml-signals", imhtml_ids); |
| 368 | purple_conversation_set_data(conv, "notify-entry-signals", entry_ids); | |
| 4035 | 369 | |
| 3428 | 370 | return 0; |
| 191 | 371 | } |
| 372 | ||
| 6977 | 373 | static void |
| 15884 | 374 | detach_signals(PurpleConversation *conv) |
| 6977 | 375 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
376 | PidginConversation *gtkconv = NULL; |
| 11606 | 377 | GSList *ids = NULL, *l; |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
378 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
379 | gtkconv = PIDGIN_CONVERSATION(conv); |
| 11581 | 380 | if (!gtkconv) |
| 381 | return; | |
| 4203 | 382 | |
| 15884 | 383 | ids = purple_conversation_get_data(conv, "notify-imhtml-signals"); |
| 11606 | 384 | for (l = ids; l != NULL; l = l->next) |
| 385 | g_signal_handler_disconnect(gtkconv->imhtml, GPOINTER_TO_INT(l->data)); | |
| 386 | g_slist_free(ids); | |
| 6302 | 387 | |
| 15884 | 388 | ids = purple_conversation_get_data(conv, "notify-entry-signals"); |
| 11606 | 389 | for (l = ids; l != NULL; l = l->next) |
| 390 | g_signal_handler_disconnect(gtkconv->entry, GPOINTER_TO_INT(l->data)); | |
| 391 | g_slist_free(ids); | |
| 3710 | 392 | |
| 15884 | 393 | purple_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); |
| 14385 | 394 | |
| 15884 | 395 | purple_conversation_set_data(conv, "notify-imhtml-signals", NULL); |
| 396 | purple_conversation_set_data(conv, "notify-entry-signals", NULL); | |
| 3710 | 397 | } |
| 398 | ||
| 6977 | 399 | static void |
| 15884 | 400 | conv_created(PurpleConversation *conv) |
| 6977 | 401 | { |
| 15884 | 402 | purple_conversation_set_data(conv, "notify-message-count", |
| 14389 | 403 | GINT_TO_POINTER(0)); |
| 14385 | 404 | |
| 14389 | 405 | /* always attach the signals, notify() will take care of conversation |
| 406 | * type checking */ | |
| 6977 | 407 | attach_signals(conv); |
| 3374 | 408 | } |
| 409 | ||
| 6977 | 410 | static void |
| 15884 | 411 | conv_switched(PurpleConversation *conv) |
| 6977 | 412 | { |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
413 | #if 0 |
| 15884 | 414 | PidginWindow *purplewin = purple_conversation_get_window(new_conv); |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
415 | #endif |
| 6302 | 416 | |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
417 | /* |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
418 | * If the conversation was switched, then make sure we re-notify |
| 15884 | 419 | * because Purple will have overwritten our custom window title. |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
420 | */ |
| 14385 | 421 | notify(conv, FALSE); |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
422 | |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
423 | #if 0 |
| 9298 | 424 | printf("conv_switched - %p - %p\n", old_conv, new_conv); |
| 15884 | 425 | printf("count - %d\n", count_messages(purplewin)); |
| 426 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_switch")) | |
| 9298 | 427 | unnotify(new_conv, FALSE); |
| 428 | else { | |
| 429 | /* if we don't have notification on the window then we don't want to | |
| 430 | * re-notify it */ | |
| 15884 | 431 | if (count_messages(purplewin)) |
| 432 | notify_win(purplewin); | |
| 9298 | 433 | } |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
434 | #endif |
| 6977 | 435 | } |
| 6302 | 436 | |
| 6977 | 437 | static void |
| 15884 | 438 | deleting_conv(PurpleConversation *conv) |
| 6977 | 439 | { |
| 15884 | 440 | PidginWindow *purplewin = NULL; |
|
19717
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
441 | PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
|
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
442 | |
|
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
443 | if (gtkconv == NULL) |
|
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
444 | return; |
| 9298 | 445 | |
| 6977 | 446 | detach_signals(conv); |
| 3392 | 447 | |
|
19717
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
448 | purplewin = gtkconv->win; |
| 11606 | 449 | |
| 15884 | 450 | handle_urgent(purplewin, FALSE); |
| 451 | purple_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); | |
| 11606 | 452 | |
| 453 | return; | |
| 454 | ||
| 11581 | 455 | #if 0 |
| 456 | /* i think this line crashes */ | |
| 15884 | 457 | if (count_messages(purplewin)) |
| 458 | notify_win(purplewin); | |
| 11581 | 459 | #endif |
| 6977 | 460 | } |
| 461 | ||
|
9303
e257ad08c77c
[gaim-migrate @ 10107]
Mark Doliner <markdoliner@pidgin.im>
parents:
9298
diff
changeset
|
462 | #if 0 |
| 6977 | 463 | static void |
| 15884 | 464 | conversation_dragging(PurpleConversation *active_conv, |
| 465 | PidginWindow *old_purplewin, | |
| 466 | PidginWindow *new_purplewin) | |
| 6977 | 467 | { |
| 15884 | 468 | if (old_purplewin != new_purplewin) { |
| 469 | if (old_purplewin == NULL) { | |
| 9298 | 470 | /* |
| 15884 | 471 | purple_conversation_autoset_title(active_conv); |
| 472 | handle_urgent(new_purplewin, FALSE); | |
| 9298 | 473 | */ |
| 474 | ||
| 15884 | 475 | if (count_messages(new_purplewin)) |
| 476 | notify_win(new_purplewin); | |
| 9298 | 477 | } else { |
| 15884 | 478 | printf("if else count = %d\n", count_messages(new_purplewin)); |
| 479 | printf("if else count = %d\n", count_messages(old_purplewin)); | |
| 9298 | 480 | /* |
| 15884 | 481 | PurpleConversation *old_active_conv = NULL; |
| 482 | old_active_conv = purple_conv_window_get_active_conversation(new_purplewin); | |
| 9298 | 483 | |
| 15884 | 484 | purple_conversation_autoset_title(old_active_conv); |
| 485 | handle_urgent(old_purplewin, FALSE); | |
| 6302 | 486 | |
| 15884 | 487 | if (count_messages(old_purplewin)) |
| 488 | notify_win(old_purplewin); | |
| 9298 | 489 | |
| 15884 | 490 | purple_conversation_autoset_title(active_conv); |
| 491 | handle_urgent(new_purplewin, FALSE); | |
| 9298 | 492 | |
| 15884 | 493 | if (count_messages(new_purplewin)) |
| 494 | notify_win(new_purplewin); | |
| 9298 | 495 | */ |
| 496 | } | |
| 497 | } else { | |
| 15884 | 498 | printf("else count = %d\n", count_messages(new_purplewin)); |
| 499 | printf("else count = %d\n", count_messages(old_purplewin)); | |
| 9298 | 500 | /* |
| 15884 | 501 | purple_conversation_autoset_title(active_conv); |
| 502 | handle_urgent(old_purplewin, FALSE); | |
| 9298 | 503 | |
| 15884 | 504 | if (count_messages(old_purplewin)) |
| 505 | notify_win(old_purplewin); | |
| 9298 | 506 | */ |
| 507 | } | |
| 4035 | 508 | } |
|
9303
e257ad08c77c
[gaim-migrate @ 10107]
Mark Doliner <markdoliner@pidgin.im>
parents:
9298
diff
changeset
|
509 | #endif |
| 4035 | 510 | |
| 6977 | 511 | static void |
| 15884 | 512 | handle_string(PidginWindow *purplewin) |
| 9298 | 513 | { |
| 514 | GtkWindow *window = NULL; | |
| 515 | gchar newtitle[256]; | |
| 516 | ||
| 15884 | 517 | g_return_if_fail(purplewin != NULL); |
| 9298 | 518 | |
| 15884 | 519 | window = GTK_WINDOW(purplewin->window); |
| 9298 | 520 | g_return_if_fail(window != NULL); |
| 521 | ||
| 522 | g_snprintf(newtitle, sizeof(newtitle), "%s%s", | |
| 15884 | 523 | purple_prefs_get_string("/plugins/gtk/X11/notify/title_string"), |
| 9298 | 524 | gtk_window_get_title(window)); |
| 525 | gtk_window_set_title(window, newtitle); | |
| 526 | } | |
| 527 | ||
| 528 | static void | |
| 15884 | 529 | handle_count_title(PidginWindow *purplewin) |
| 9298 | 530 | { |
| 531 | GtkWindow *window; | |
| 532 | char newtitle[256]; | |
| 533 | ||
| 15884 | 534 | g_return_if_fail(purplewin != NULL); |
| 9298 | 535 | |
| 15884 | 536 | window = GTK_WINDOW(purplewin->window); |
| 9298 | 537 | g_return_if_fail(window != NULL); |
| 538 | ||
| 10606 | 539 | g_snprintf(newtitle, sizeof(newtitle), "[%d] %s", |
| 15884 | 540 | count_messages(purplewin), gtk_window_get_title(window)); |
| 9298 | 541 | gtk_window_set_title(window, newtitle); |
| 542 | } | |
| 543 | ||
| 544 | static void | |
| 15884 | 545 | handle_count_xprop(PidginWindow *purplewin) |
| 14389 | 546 | { |
|
33472
24393ecae82e
Make this plugin a bit more friendly with Quartz-enabled GTK+ in MacPorts.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30706
diff
changeset
|
547 | #ifdef HAVE_X11 |
| 14389 | 548 | guint count; |
| 549 | GtkWidget *window; | |
| 550 | GdkWindow *gdkwin; | |
| 551 | ||
| 15884 | 552 | window = purplewin->window; |
| 14389 | 553 | g_return_if_fail(window != NULL); |
| 554 | ||
| 15884 | 555 | if (_PurpleUnseenCount == GDK_NONE) { |
| 556 | _PurpleUnseenCount = gdk_atom_intern("_PIDGIN_UNSEEN_COUNT", FALSE); | |
| 14389 | 557 | } |
| 558 | ||
| 559 | if (_Cardinal == GDK_NONE) { | |
| 560 | _Cardinal = gdk_atom_intern("CARDINAL", FALSE); | |
| 561 | } | |
| 562 | ||
| 15884 | 563 | count = count_messages(purplewin); |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27858
diff
changeset
|
564 | #if GTK_CHECK_VERSION(2,14,0) |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27858
diff
changeset
|
565 | gdkwin = gtk_widget_get_window(window); |
|
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27858
diff
changeset
|
566 | #else |
| 14389 | 567 | gdkwin = window->window; |
|
30010
2b3e5bbd0492
Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27858
diff
changeset
|
568 | #endif |
| 14389 | 569 | |
| 15884 | 570 | gdk_property_change(gdkwin, _PurpleUnseenCount, _Cardinal, 32, |
| 14389 | 571 | GDK_PROP_MODE_REPLACE, (guchar *) &count, 1); |
| 572 | #endif | |
| 573 | } | |
| 574 | ||
| 575 | static void | |
|
25382
6a3ab0bc549d
Check that the PidginWindow we get in handle_urgent actually exists and has
Etan Reisner <deryni@pidgin.im>
parents:
24506
diff
changeset
|
576 | handle_urgent(PidginWindow *purplewin, gboolean set) |
| 6977 | 577 | { |
|
25382
6a3ab0bc549d
Check that the PidginWindow we get in handle_urgent actually exists and has
Etan Reisner <deryni@pidgin.im>
parents:
24506
diff
changeset
|
578 | g_return_if_fail(purplewin != NULL); |
|
6a3ab0bc549d
Check that the PidginWindow we get in handle_urgent actually exists and has
Etan Reisner <deryni@pidgin.im>
parents:
24506
diff
changeset
|
579 | g_return_if_fail(purplewin->window != NULL); |
|
6a3ab0bc549d
Check that the PidginWindow we get in handle_urgent actually exists and has
Etan Reisner <deryni@pidgin.im>
parents:
24506
diff
changeset
|
580 | |
|
6a3ab0bc549d
Check that the PidginWindow we get in handle_urgent actually exists and has
Etan Reisner <deryni@pidgin.im>
parents:
24506
diff
changeset
|
581 | pidgin_set_urgent(GTK_WINDOW(purplewin->window), set); |
| 4035 | 582 | } |
| 583 | ||
| 6977 | 584 | static void |
| 15884 | 585 | handle_raise(PidginWindow *purplewin) |
| 10606 | 586 | { |
| 15884 | 587 | pidgin_conv_window_raise(purplewin); |
| 10606 | 588 | } |
| 589 | ||
| 590 | static void | |
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
591 | handle_present(PurpleConversation *conv) |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
592 | { |
|
27858
3ade5991f52f
Fix a crash with the Message Notification plugin and the 'hidden' gtkconv
Paul Aurich <darkrain42@pidgin.im>
parents:
25382
diff
changeset
|
593 | if (pidgin_conv_is_hidden(PIDGIN_CONVERSATION(conv))) |
|
3ade5991f52f
Fix a crash with the Message Notification plugin and the 'hidden' gtkconv
Paul Aurich <darkrain42@pidgin.im>
parents:
25382
diff
changeset
|
594 | return; |
|
3ade5991f52f
Fix a crash with the Message Notification plugin and the 'hidden' gtkconv
Paul Aurich <darkrain42@pidgin.im>
parents:
25382
diff
changeset
|
595 | |
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
596 | purple_conversation_present(conv); |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
597 | } |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
598 | |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
599 | static void |
| 6977 | 600 | type_toggle_cb(GtkWidget *widget, gpointer data) |
| 601 | { | |
| 602 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 603 | gchar pref[256]; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
604 | |
| 14389 | 605 | g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", |
| 606 | (char *)data); | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
607 | |
| 15884 | 608 | purple_prefs_set_bool(pref, on); |
| 3374 | 609 | } |
| 610 | ||
| 6977 | 611 | static void |
| 612 | method_toggle_cb(GtkWidget *widget, gpointer data) | |
| 613 | { | |
| 614 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 615 | gchar pref[256]; | |
| 616 | ||
| 14389 | 617 | g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", |
| 618 | (char *)data); | |
| 3374 | 619 | |
| 15884 | 620 | purple_prefs_set_bool(pref, on); |
| 6977 | 621 | |
| 622 | if (!strcmp(data, "method_string")) { | |
| 623 | GtkWidget *entry = g_object_get_data(G_OBJECT(widget), "title-entry"); | |
| 624 | gtk_widget_set_sensitive(entry, on); | |
| 625 | ||
| 15884 | 626 | purple_prefs_set_string("/plugins/gtk/X11/notify/title_string", |
| 14448 | 627 | gtk_entry_get_text(GTK_ENTRY(entry))); |
| 6977 | 628 | } |
| 629 | ||
| 630 | apply_method(); | |
| 3374 | 631 | } |
| 632 | ||
| 6977 | 633 | static void |
| 634 | notify_toggle_cb(GtkWidget *widget, gpointer data) | |
| 635 | { | |
| 636 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 637 | gchar pref[256]; | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
638 | |
| 14389 | 639 | g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", |
| 640 | (char *)data); | |
| 3374 | 641 | |
| 15884 | 642 | purple_prefs_set_bool(pref, on); |
| 6977 | 643 | |
| 644 | apply_notify(); | |
| 3374 | 645 | } |
| 646 | ||
| 6977 | 647 | static gboolean |
| 648 | options_entry_cb(GtkWidget *widget, GdkEventFocus *evt, gpointer data) | |
| 649 | { | |
| 650 | if (data == NULL) | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6977
diff
changeset
|
651 | return FALSE; |
| 6302 | 652 | |
| 6977 | 653 | if (!strcmp(data, "method_string")) { |
| 15884 | 654 | purple_prefs_set_string("/plugins/gtk/X11/notify/title_string", |
| 14389 | 655 | gtk_entry_get_text(GTK_ENTRY(widget))); |
| 3374 | 656 | } |
| 6302 | 657 | |
| 6977 | 658 | apply_method(); |
| 6302 | 659 | |
| 660 | return FALSE; | |
| 661 | } | |
| 662 | ||
| 6977 | 663 | static void |
| 14389 | 664 | apply_method() |
| 665 | { | |
|
13664
fdc3b588f248
[gaim-migrate @ 16065]
Richard Laager <rlaager@pidgin.im>
parents:
13550
diff
changeset
|
666 | GList *convs; |
| 6977 | 667 | |
| 15884 | 668 | for (convs = purple_get_conversations(); convs != NULL; |
| 14389 | 669 | convs = convs->next) { |
| 15884 | 670 | PurpleConversation *conv = (PurpleConversation *)convs->data; |
| 6302 | 671 | |
| 6977 | 672 | /* remove notifications */ |
| 9298 | 673 | unnotify(conv, FALSE); |
| 674 | ||
| 15884 | 675 | if (GPOINTER_TO_INT(purple_conversation_get_data(conv, "notify-message-count")) != 0) |
| 6977 | 676 | /* reattach appropriate notifications */ |
| 14385 | 677 | notify(conv, FALSE); |
| 6977 | 678 | } |
| 3374 | 679 | } |
| 680 | ||
| 6977 | 681 | static void |
| 682 | apply_notify() | |
| 683 | { | |
| 15884 | 684 | GList *convs = purple_get_conversations(); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
685 | |
| 6977 | 686 | while (convs) { |
| 15884 | 687 | PurpleConversation *conv = (PurpleConversation *)convs->data; |
| 4203 | 688 | |
| 6977 | 689 | /* detach signals */ |
| 690 | detach_signals(conv); | |
| 691 | /* reattach appropriate signals */ | |
| 692 | attach_signals(conv); | |
| 4035 | 693 | |
| 6977 | 694 | convs = convs->next; |
| 4035 | 695 | } |
| 696 | } | |
| 697 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
698 | static GtkWidget * |
| 15884 | 699 | get_config_frame(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
700 | { |
| 6977 | 701 | GtkWidget *ret = NULL, *frame = NULL; |
| 702 | GtkWidget *vbox = NULL, *hbox = NULL; | |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
703 | GtkWidget *toggle = NULL, *entry = NULL, *ref; |
| 6302 | 704 | |
| 3565 | 705 | ret = gtk_vbox_new(FALSE, 18); |
| 6302 | 706 | gtk_container_set_border_width(GTK_CONTAINER (ret), 12); |
| 3392 | 707 | |
| 6302 | 708 | /*---------- "Notify For" ----------*/ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
709 | frame = pidgin_make_frame(ret, _("Notify For")); |
| 6302 | 710 | vbox = gtk_vbox_new(FALSE, 5); |
| 711 | gtk_container_add(GTK_CONTAINER(frame), vbox); | |
| 712 | ||
| 3710 | 713 | toggle = gtk_check_button_new_with_mnemonic(_("_IM windows")); |
| 714 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 6977 | 715 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
| 15884 | 716 | purple_prefs_get_bool("/plugins/gtk/X11/notify/type_im")); |
| 6977 | 717 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 718 | G_CALLBACK(type_toggle_cb), "type_im"); |
| 3710 | 719 | |
|
37190
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
720 | ref = toggle; |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
721 | toggle = gtk_check_button_new_with_mnemonic(_("\t_Notify for System messages")); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
722 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
723 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
724 | purple_prefs_get_bool("/plugins/gtk/X11/notify/type_im_sys")); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
725 | g_signal_connect(G_OBJECT(toggle), "toggled", |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
726 | G_CALLBACK(type_toggle_cb), "type_im_sys"); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
727 | gtk_widget_set_sensitive(toggle, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ref))); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
728 | g_signal_connect(G_OBJECT(ref), "toggled", |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
729 | G_CALLBACK(pidgin_toggle_sensitive), toggle); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
730 | |
| 6977 | 731 | toggle = gtk_check_button_new_with_mnemonic(_("C_hat windows")); |
| 3710 | 732 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 6977 | 733 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
| 15884 | 734 | purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat")); |
| 6977 | 735 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 736 | G_CALLBACK(type_toggle_cb), "type_chat"); |
| 6977 | 737 | |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
738 | ref = toggle; |
|
22942
2bf494f8e2a4
Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <markdoliner@pidgin.im>
parents:
22782
diff
changeset
|
739 | toggle = gtk_check_button_new_with_mnemonic(_("\t_Only when someone says your username")); |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
740 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
741 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
| 15884 | 742 | purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat_nick")); |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
743 | g_signal_connect(G_OBJECT(toggle), "toggled", |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
744 | G_CALLBACK(type_toggle_cb), "type_chat_nick"); |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
745 | gtk_widget_set_sensitive(toggle, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ref))); |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
746 | g_signal_connect(G_OBJECT(ref), "toggled", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
747 | G_CALLBACK(pidgin_toggle_sensitive), toggle); |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
748 | |
|
37190
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
749 | toggle = gtk_check_button_new_with_mnemonic(_("\tNotify for _System messages")); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
750 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
751 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
752 | purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat_sys")); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
753 | g_signal_connect(G_OBJECT(toggle), "toggled", |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
754 | G_CALLBACK(type_toggle_cb), "type_chat_sys"); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
755 | gtk_widget_set_sensitive(toggle, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ref))); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
756 | g_signal_connect(G_OBJECT(ref), "toggled", |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
757 | G_CALLBACK(pidgin_toggle_sensitive), toggle); |
|
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
758 | |
| 6977 | 759 | toggle = gtk_check_button_new_with_mnemonic(_("_Focused windows")); |
| 760 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 761 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 762 | purple_prefs_get_bool("/plugins/gtk/X11/notify/type_focused")); |
| 6977 | 763 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 764 | G_CALLBACK(type_toggle_cb), "type_focused"); |
| 3710 | 765 | |
| 6302 | 766 | /*---------- "Notification Methods" ----------*/ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
767 | frame = pidgin_make_frame(ret, _("Notification Methods")); |
| 6302 | 768 | vbox = gtk_vbox_new(FALSE, 5); |
| 769 | gtk_container_add(GTK_CONTAINER(frame), vbox); | |
| 770 | ||
| 6977 | 771 | /* String method button */ |
| 3565 | 772 | hbox = gtk_hbox_new(FALSE, 18); |
| 773 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
| 6302 | 774 | toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:")); |
| 6977 | 775 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
| 15884 | 776 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_string")); |
| 3565 | 777 | gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); |
| 6977 | 778 | |
| 6302 | 779 | entry = gtk_entry_new(); |
| 780 | gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
| 781 | gtk_entry_set_max_length(GTK_ENTRY(entry), 10); | |
| 6977 | 782 | gtk_widget_set_sensitive(GTK_WIDGET(entry), |
| 15884 | 783 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_string")); |
| 6977 | 784 | gtk_entry_set_text(GTK_ENTRY(entry), |
| 15884 | 785 | purple_prefs_get_string("/plugins/gtk/X11/notify/title_string")); |
| 6977 | 786 | g_object_set_data(G_OBJECT(toggle), "title-entry", entry); |
| 787 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 9298 | 788 | G_CALLBACK(method_toggle_cb), "method_string"); |
| 6977 | 789 | g_signal_connect(G_OBJECT(entry), "focus-out-event", |
| 9298 | 790 | G_CALLBACK(options_entry_cb), "method_string"); |
| 3374 | 791 | |
| 6977 | 792 | /* Count method button */ |
| 793 | toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title")); | |
| 794 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 795 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_count")); |
| 6977 | 796 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 797 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 9298 | 798 | G_CALLBACK(method_toggle_cb), "method_count"); |
| 4035 | 799 | |
|
33472
24393ecae82e
Make this plugin a bit more friendly with Quartz-enabled GTK+ in MacPorts.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30706
diff
changeset
|
800 | #ifdef HAVE_X11 |
| 14389 | 801 | /* Count xprop method button */ |
| 802 | toggle = gtk_check_button_new_with_mnemonic(_("Insert count of new message into _X property")); | |
| 803 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 804 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 805 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_count_xprop")); |
| 14389 | 806 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 807 | G_CALLBACK(method_toggle_cb), "method_count_xprop"); | |
| 808 | ||
| 6977 | 809 | /* Urgent method button */ |
| 810 | toggle = gtk_check_button_new_with_mnemonic(_("Set window manager \"_URGENT\" hint")); | |
|
24431
f4b9e73eec48
Allow the message notification plugin to flash windows on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
22945
diff
changeset
|
811 | #else |
|
24506
4d624cd775bd
Mark for translation now that we're unfrozen.
Daniel Atallah <datallah@pidgin.im>
parents:
24431
diff
changeset
|
812 | toggle = gtk_check_button_new_with_mnemonic(_("_Flash window")); |
|
24431
f4b9e73eec48
Allow the message notification plugin to flash windows on win32.
Daniel Atallah <datallah@pidgin.im>
parents:
22945
diff
changeset
|
813 | #endif |
| 6977 | 814 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 815 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 816 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent")); |
| 9298 | 817 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 818 | G_CALLBACK(method_toggle_cb), "method_urgent"); | |
| 3710 | 819 | |
| 10606 | 820 | /* Raise window method button */ |
| 821 | toggle = gtk_check_button_new_with_mnemonic(_("R_aise conversation window")); | |
| 822 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 823 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 824 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_raise")); |
| 10606 | 825 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 826 | G_CALLBACK(method_toggle_cb), "method_raise"); | |
| 827 | ||
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
828 | /* Present conversation method button */ |
|
37220
5b46f15834d9
Add a note for translators
Richard Laager <rlaager@pidgin.im>
parents:
37190
diff
changeset
|
829 | /* Translators: "Present" as used here is a verb. The plugin presents |
|
5b46f15834d9
Add a note for translators
Richard Laager <rlaager@pidgin.im>
parents:
37190
diff
changeset
|
830 | * the window to the user. */ |
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
831 | toggle = gtk_check_button_new_with_mnemonic(_("_Present conversation window")); |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
832 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
833 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
834 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_present")); |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
835 | g_signal_connect(G_OBJECT(toggle), "toggled", |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
836 | G_CALLBACK(method_toggle_cb), "method_present"); |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
837 | |
| 6977 | 838 | /*---------- "Notification Removals" ----------*/ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
839 | frame = pidgin_make_frame(ret, _("Notification Removal")); |
| 6302 | 840 | vbox = gtk_vbox_new(FALSE, 5); |
| 841 | gtk_container_add(GTK_CONTAINER(frame), vbox); | |
| 3374 | 842 | |
| 6977 | 843 | /* Remove on focus button */ |
| 844 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _gains focus")); | |
| 845 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 846 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 847 | purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_focus")); |
| 6977 | 848 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(notify_toggle_cb), "notify_focus"); |
| 849 | ||
| 850 | /* Remove on click button */ | |
| 851 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click")); | |
| 852 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 853 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 854 | purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_click")); |
| 6977 | 855 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 856 | G_CALLBACK(notify_toggle_cb), "notify_click"); |
| 3710 | 857 | |
| 6977 | 858 | /* Remove on type button */ |
| 859 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); | |
| 860 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 861 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 862 | purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_type")); |
| 6977 | 863 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 864 | G_CALLBACK(notify_toggle_cb), "notify_type"); |
| 4035 | 865 | |
| 6977 | 866 | /* Remove on message send button */ |
| 867 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when a _message gets sent")); | |
| 868 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 869 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 870 | purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")); |
| 6977 | 871 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 872 | G_CALLBACK(notify_toggle_cb), "notify_send"); |
| 3565 | 873 | |
| 6977 | 874 | #if 0 |
| 875 | /* Remove on conversation switch button */ | |
| 9298 | 876 | toggle = gtk_check_button_new_with_mnemonic(_("Remove on switch to conversation ta_b")); |
| 6977 | 877 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 878 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 879 | purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_switch")); |
| 6977 | 880 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 881 | G_CALLBACK(notify_toggle_cb), "notify_switch"); |
| 6977 | 882 | #endif |
| 883 | ||
| 884 | gtk_widget_show_all(ret); | |
| 885 | return ret; | |
| 3374 | 886 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
887 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
888 | static gboolean |
| 15884 | 889 | plugin_load(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
890 | { |
| 15884 | 891 | GList *convs = purple_get_conversations(); |
| 892 | void *conv_handle = purple_conversations_get_handle(); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
893 | void *gtk_conv_handle = pidgin_conversations_get_handle(); |
| 6302 | 894 | |
| 895 | my_plugin = plugin; | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
896 | |
| 15884 | 897 | purple_signal_connect(gtk_conv_handle, "displayed-im-msg", plugin, |
| 898 | PURPLE_CALLBACK(message_displayed_cb), NULL); | |
| 899 | purple_signal_connect(gtk_conv_handle, "displayed-chat-msg", plugin, | |
| 900 | PURPLE_CALLBACK(message_displayed_cb), NULL); | |
| 901 | purple_signal_connect(gtk_conv_handle, "conversation-switched", plugin, | |
| 902 | PURPLE_CALLBACK(conv_switched), NULL); | |
| 903 | purple_signal_connect(conv_handle, "sent-im-msg", plugin, | |
| 904 | PURPLE_CALLBACK(im_sent_im), NULL); | |
| 905 | purple_signal_connect(conv_handle, "sent-chat-msg", plugin, | |
| 906 | PURPLE_CALLBACK(chat_sent_im), NULL); | |
| 907 | purple_signal_connect(conv_handle, "conversation-created", plugin, | |
| 908 | PURPLE_CALLBACK(conv_created), NULL); | |
| 909 | purple_signal_connect(conv_handle, "deleting-conversation", plugin, | |
| 910 | PURPLE_CALLBACK(deleting_conv), NULL); | |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
911 | #if 0 |
| 15884 | 912 | purple_signal_connect(gtk_conv_handle, "conversation-dragging", plugin, |
| 913 | PURPLE_CALLBACK(conversation_dragging), NULL); | |
|
9303
e257ad08c77c
[gaim-migrate @ 10107]
Mark Doliner <markdoliner@pidgin.im>
parents:
9298
diff
changeset
|
914 | #endif |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
915 | |
| 6977 | 916 | while (convs) { |
| 15884 | 917 | PurpleConversation *conv = (PurpleConversation *)convs->data; |
| 6302 | 918 | |
| 919 | /* attach signals */ | |
| 6977 | 920 | attach_signals(conv); |
| 6302 | 921 | |
| 6977 | 922 | convs = convs->next; |
| 6302 | 923 | } |
| 924 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
925 | return TRUE; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
926 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
927 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
928 | static gboolean |
| 15884 | 929 | plugin_unload(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
930 | { |
| 15884 | 931 | GList *convs = purple_get_conversations(); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
932 | |
| 6977 | 933 | while (convs) { |
| 15884 | 934 | PurpleConversation *conv = (PurpleConversation *)convs->data; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
935 | |
| 6302 | 936 | /* kill signals */ |
| 6977 | 937 | detach_signals(conv); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
938 | |
| 6977 | 939 | convs = convs->next; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
940 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
941 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
942 | return TRUE; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
943 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
944 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
945 | static PidginPluginUiInfo ui_info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
946 | { |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12397
diff
changeset
|
947 | get_config_frame, |
|
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
|
948 | 0, /* page_num (Reserved) */ |
|
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
|
949 | |
|
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
|
950 | /* 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
|
951 | 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
|
952 | 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
|
953 | 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
|
954 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
955 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
956 | |
| 15884 | 957 | static PurplePluginInfo info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
958 | { |
| 15884 | 959 | PURPLE_PLUGIN_MAGIC, |
| 960 | PURPLE_MAJOR_VERSION, | |
| 961 | PURPLE_MINOR_VERSION, | |
| 962 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
963 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
964 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
965 | NULL, /**< dependencies */ |
| 15884 | 966 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
967 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
968 | NOTIFY_PLUGIN_ID, /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
969 | N_("Message Notification"), /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
970 | DISPLAY_VERSION, /**< version */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
971 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
972 | N_("Provides a variety of ways of notifying you of unread messages."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
973 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
974 | N_("Provides a variety of ways of notifying you of unread messages."), |
| 14389 | 975 | /**< author */ |
|
22782
c465a8b48510
Massage some plugin metadata to look better with the fixed up description pane.
Will Thompson <resiak@pidgin.im>
parents:
22539
diff
changeset
|
976 | "Etan Reisner <deryni@eden.rutgers.edu>,\nBrian Tarricone <bjt23@cornell.edu>", |
| 15884 | 977 | PURPLE_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
978 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
979 | plugin_load, /**< load */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
980 | plugin_unload, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
981 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
982 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
983 | &ui_info, /**< ui_info */ |
| 8993 | 984 | NULL, /**< extra_info */ |
| 985 | NULL, | |
|
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
|
986 | 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
|
987 | |
|
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
|
988 | /* 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
|
989 | 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
|
990 | 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
|
991 | NULL, |
| 8993 | 992 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
993 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
994 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
995 | static void |
| 15884 | 996 | init_plugin(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
997 | { |
| 15884 | 998 | purple_prefs_add_none("/plugins/gtk"); |
| 999 | purple_prefs_add_none("/plugins/gtk/X11"); | |
| 1000 | purple_prefs_add_none("/plugins/gtk/X11/notify"); | |
| 6302 | 1001 | |
| 15884 | 1002 | purple_prefs_add_bool("/plugins/gtk/X11/notify/type_im", TRUE); |
|
37190
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
1003 | purple_prefs_add_bool("/plugins/gtk/X11/notify/type_im_sys", FALSE); |
| 15884 | 1004 | purple_prefs_add_bool("/plugins/gtk/X11/notify/type_chat", FALSE); |
| 1005 | purple_prefs_add_bool("/plugins/gtk/X11/notify/type_chat_nick", FALSE); | |
|
37190
7e315013fb73
notify: Add support for notifications for system messages
Sebastian Schmidt <yath@yath.de>
parents:
33476
diff
changeset
|
1006 | purple_prefs_add_bool("/plugins/gtk/X11/notify/type_chat_sys", FALSE); |
| 15884 | 1007 | purple_prefs_add_bool("/plugins/gtk/X11/notify/type_focused", FALSE); |
| 1008 | purple_prefs_add_bool("/plugins/gtk/X11/notify/method_string", FALSE); | |
| 1009 | purple_prefs_add_string("/plugins/gtk/X11/notify/title_string", "(*)"); | |
| 1010 | purple_prefs_add_bool("/plugins/gtk/X11/notify/method_urgent", FALSE); | |
| 1011 | purple_prefs_add_bool("/plugins/gtk/X11/notify/method_count", FALSE); | |
| 1012 | purple_prefs_add_bool("/plugins/gtk/X11/notify/method_count_xprop", FALSE); | |
| 1013 | purple_prefs_add_bool("/plugins/gtk/X11/notify/method_raise", FALSE); | |
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
1014 | purple_prefs_add_bool("/plugins/gtk/X11/notify/method_present", FALSE); |
| 15884 | 1015 | purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_focus", TRUE); |
| 1016 | purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_click", FALSE); | |
| 1017 | purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_type", TRUE); | |
| 1018 | purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_send", TRUE); | |
| 1019 | purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_switch", TRUE); | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
1020 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
1021 | |
| 15884 | 1022 | PURPLE_INIT_PLUGIN(notify, init_plugin, info) |