Tue, 04 Nov 2014 22:18:30 -0800
Merge release-2.x.y branch into master. No overlapping files.
| 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 | |
|
35526
ed1be305c985
Fix gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35037
diff
changeset
|
96 | #include "gtk3compat.h" |
| 6302 | 97 | #include "gtkplugin.h" |
| 98 | #include "gtkutils.h" | |
| 99 | ||
| 100 | #define NOTIFY_PLUGIN_ID "gtk-x11-notify" | |
| 3710 | 101 | |
| 15884 | 102 | 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
|
103 | #ifdef HAVE_X11 |
| 14389 | 104 | static GdkAtom _Cardinal = GDK_NONE; |
| 15884 | 105 | static GdkAtom _PurpleUnseenCount = GDK_NONE; |
| 15527 | 106 | #endif |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
107 | |
| 6302 | 108 | /* notification set/unset */ |
| 15884 | 109 | static int notify(PurpleConversation *conv, gboolean increment); |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
110 | static void notify_win(PidginConvWindow *purplewin, PurpleConversation *conv); |
| 15884 | 111 | static void unnotify(PurpleConversation *conv, gboolean reset); |
| 14389 | 112 | static int unnotify_cb(GtkWidget *widget, gpointer data, |
| 15884 | 113 | PurpleConversation *conv); |
| 6302 | 114 | |
| 115 | /* gtk widget callbacks for prefs panel */ | |
| 6977 | 116 | static void type_toggle_cb(GtkWidget *widget, gpointer data); |
| 117 | static void method_toggle_cb(GtkWidget *widget, gpointer data); | |
| 118 | static void notify_toggle_cb(GtkWidget *widget, gpointer data); | |
| 14389 | 119 | static gboolean options_entry_cb(GtkWidget *widget, GdkEventFocus *event, |
| 120 | gpointer data); | |
|
12397
aa64ec827fdf
[gaim-migrate @ 14704]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
121 | static void apply_method(void); |
|
aa64ec827fdf
[gaim-migrate @ 14704]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
122 | static void apply_notify(void); |
| 191 | 123 | |
| 6977 | 124 | /* string function */ |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
125 | static void handle_string(PidginConvWindow *purplewin); |
| 6302 | 126 | |
| 14389 | 127 | /* count_title function */ |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
128 | static void handle_count_title(PidginConvWindow *purplewin); |
| 14389 | 129 | |
| 130 | /* count_xprop function */ | |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
131 | static void handle_count_xprop(PidginConvWindow *purplewin); |
| 6302 | 132 | |
| 6977 | 133 | /* urgent function */ |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
134 | static void handle_urgent(PidginConvWindow *purplewin, gboolean set); |
| 10606 | 135 | |
| 136 | /* raise function */ | |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
137 | static void handle_raise(PidginConvWindow *purplewin); |
| 3710 | 138 | |
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
139 | /* 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
|
140 | 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
|
141 | |
| 6302 | 142 | /****************************************/ |
| 143 | /* Begin doing stuff below this line... */ | |
| 144 | /****************************************/ | |
| 14389 | 145 | static guint |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
146 | count_messages(PidginConvWindow *purplewin) |
| 9298 | 147 | { |
| 14389 | 148 | guint count = 0; |
| 14385 | 149 | GList *convs = NULL, *l; |
| 9298 | 150 | |
| 15884 | 151 | 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
|
152 | PidginConversation *conv = convs->data; |
| 14385 | 153 | for (l = conv->convs; l != NULL; l = l->next) { |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
154 | count += GPOINTER_TO_INT(g_object_get_data(G_OBJECT(l->data), "notify-message-count")); |
| 14385 | 155 | } |
| 9298 | 156 | } |
| 157 | ||
| 158 | return count; | |
| 159 | } | |
| 6302 | 160 | |
| 6977 | 161 | static int |
| 15884 | 162 | notify(PurpleConversation *conv, gboolean increment) |
| 6977 | 163 | { |
| 14385 | 164 | gint count; |
| 14326 | 165 | gboolean has_focus; |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
166 | PidginConvWindow *purplewin = NULL; |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
167 | |
|
19717
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
168 | if (conv == NULL || PIDGIN_CONVERSATION(conv) == NULL) |
| 6302 | 169 | return 0; |
| 170 | ||
| 6977 | 171 | /* We want to remove the notifications, but not reset the counter */ |
| 172 | unnotify(conv, FALSE); | |
| 173 | ||
| 15884 | 174 | purplewin = PIDGIN_CONVERSATION(conv)->win; |
| 5021 | 175 | |
| 6977 | 176 | /* If we aren't doing notifications for this type of conversation, return */ |
|
34660
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34655
diff
changeset
|
177 | if ((PURPLE_IS_IM_CONVERSATION(conv) && |
| 15884 | 178 | !purple_prefs_get_bool("/plugins/gtk/X11/notify/type_im")) || |
|
34660
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34655
diff
changeset
|
179 | (PURPLE_IS_CHAT_CONVERSATION(conv) && |
| 15884 | 180 | !purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat"))) |
| 6977 | 181 | return 0; |
| 4203 | 182 | |
| 15884 | 183 | g_object_get(G_OBJECT(purplewin->window), |
| 9298 | 184 | "has-toplevel-focus", &has_focus, NULL); |
| 3374 | 185 | |
| 15884 | 186 | 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
|
187 | !has_focus) { |
| 14385 | 188 | if (increment) { |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
189 | count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "notify-message-count")); |
| 14385 | 190 | count++; |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
191 | g_object_set_data(G_OBJECT(conv), "notify-message-count", GINT_TO_POINTER(count)); |
| 14385 | 192 | } |
| 193 | ||
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
194 | notify_win(purplewin, conv); |
| 6977 | 195 | } |
| 6302 | 196 | |
| 197 | return 0; | |
| 198 | } | |
| 199 | ||
| 9298 | 200 | static void |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
201 | notify_win(PidginConvWindow *purplewin, PurpleConversation *conv) |
| 9298 | 202 | { |
| 15884 | 203 | if (count_messages(purplewin) <= 0) |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
204 | return; |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
205 | |
| 15884 | 206 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_count")) |
| 207 | handle_count_title(purplewin); | |
| 208 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_count_xprop")) | |
| 209 | handle_count_xprop(purplewin); | |
| 210 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_string")) | |
| 211 | handle_string(purplewin); | |
| 212 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent")) | |
| 213 | handle_urgent(purplewin, TRUE); | |
| 214 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_raise")) | |
| 215 | 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
|
216 | 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
|
217 | handle_present(conv); |
| 9298 | 218 | } |
| 219 | ||
| 220 | static void | |
| 15884 | 221 | unnotify(PurpleConversation *conv, gboolean reset) |
| 9298 | 222 | { |
| 15884 | 223 | PurpleConversation *active_conv = NULL; |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
224 | PidginConvWindow *purplewin = NULL; |
| 9298 | 225 | |
| 226 | g_return_if_fail(conv != NULL); | |
|
19717
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
227 | if (PIDGIN_CONVERSATION(conv) == NULL) |
|
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
228 | return; |
| 9298 | 229 | |
| 15884 | 230 | purplewin = PIDGIN_CONVERSATION(conv)->win; |
| 231 | active_conv = pidgin_conv_window_get_active_conversation(purplewin); | |
| 9298 | 232 | |
| 233 | /* reset the conversation window title */ | |
| 15884 | 234 | purple_conversation_autoset_title(active_conv); |
| 9298 | 235 | |
| 236 | if (reset) { | |
| 14389 | 237 | /* Only need to actually remove the urgent hinting here, since |
| 238 | * removing it just to have it readded in re-notify is an | |
| 239 | * unnecessary couple extra RTs to the server */ | |
| 15884 | 240 | handle_urgent(purplewin, FALSE); |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
241 | g_object_set_data(G_OBJECT(conv), "notify-message-count", GINT_TO_POINTER(0)); |
| 14389 | 242 | /* Same logic as for the urgent hint, xprops are also a RT. |
| 243 | * This needs to go here so that it gets the updated message | |
| 244 | * count. */ | |
| 15884 | 245 | handle_count_xprop(purplewin); |
| 9298 | 246 | } |
| 247 | ||
| 248 | return; | |
| 249 | } | |
| 250 | ||
| 251 | static int | |
| 15884 | 252 | unnotify_cb(GtkWidget *widget, gpointer data, PurpleConversation *conv) |
| 9298 | 253 | { |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
254 | if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "notify-message-count")) != 0) |
| 9298 | 255 | unnotify(conv, TRUE); |
| 256 | ||
| 257 | return 0; | |
| 258 | } | |
| 259 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
260 | static gboolean |
|
36110
63663622e327
Switch write_conv and (displaying|displayed)-(im|chat)-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36098
diff
changeset
|
261 | message_displayed_cb(PurpleConversation *conv, PurpleMessage *msg, gpointer _unused) |
| 6977 | 262 | { |
|
36110
63663622e327
Switch write_conv and (displaying|displayed)-(im|chat)-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36098
diff
changeset
|
263 | PurpleMessageFlags flags = purple_message_get_flags(msg); |
|
63663622e327
Switch write_conv and (displaying|displayed)-(im|chat)-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36098
diff
changeset
|
264 | |
|
34660
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34655
diff
changeset
|
265 | if ((PURPLE_IS_CHAT_CONVERSATION(conv) && |
| 15884 | 266 | purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat_nick") && |
| 267 | !(flags & PURPLE_MESSAGE_NICK))) | |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
268 | return FALSE; |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
269 | |
| 15884 | 270 | if ((flags & PURPLE_MESSAGE_RECV) && !(flags & PURPLE_MESSAGE_DELAYED)) |
| 14385 | 271 | notify(conv, TRUE); |
| 9298 | 272 | |
| 273 | return FALSE; | |
| 274 | } | |
| 275 | ||
| 6977 | 276 | static void |
|
36081
6764e037a308
Switch sent-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35610
diff
changeset
|
277 | im_sent_im(PurpleAccount *account, PurpleMessage *msg, gpointer _unused) |
| 14389 | 278 | { |
|
34660
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34655
diff
changeset
|
279 | PurpleIMConversation *im = NULL; |
| 9298 | 280 | |
| 15884 | 281 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) { |
|
36081
6764e037a308
Switch sent-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35610
diff
changeset
|
282 | im = purple_conversations_find_im_with_account( |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36082
diff
changeset
|
283 | purple_message_get_recipient(msg), account); |
|
34660
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34655
diff
changeset
|
284 | unnotify(PURPLE_CONVERSATION(im), TRUE); |
| 9298 | 285 | } |
| 286 | } | |
| 287 | ||
| 288 | static void | |
|
36082
247d94c903c3
Switch sent-chat-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36081
diff
changeset
|
289 | chat_sent_im(PurpleAccount *account, PurpleMessage *msg, int id) |
| 6977 | 290 | { |
|
34660
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34655
diff
changeset
|
291 | PurpleChatConversation *chat = NULL; |
| 6977 | 292 | |
| 15884 | 293 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) { |
|
34660
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34655
diff
changeset
|
294 | chat = purple_conversations_find_chat(purple_account_get_connection(account), id); |
|
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34655
diff
changeset
|
295 | unnotify(PURPLE_CONVERSATION(chat), TRUE); |
| 6977 | 296 | } |
| 3710 | 297 | } |
| 298 | ||
| 6977 | 299 | static int |
| 15884 | 300 | attach_signals(PurpleConversation *conv) |
| 6977 | 301 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
302 | PidginConversation *gtkconv = NULL; |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30706
diff
changeset
|
303 | GSList *webview_ids = NULL, *entry_ids = NULL; |
| 6977 | 304 | guint id; |
| 305 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
306 | gtkconv = PIDGIN_CONVERSATION(conv); |
| 11581 | 307 | if (!gtkconv) { |
| 15884 | 308 | purple_debug_misc("notify", "Failed to find gtkconv\n"); |
| 11581 | 309 | return 0; |
| 310 | } | |
| 311 | ||
| 15884 | 312 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_focus")) { |
| 14389 | 313 | /* TODO should really find a way to make this work no matter |
| 314 | * where the focus is inside the conv window, without having | |
| 315 | * to bind to focus-in-event on the g(d|t)kwindow */ | |
| 9298 | 316 | /* try setting the signal on the focus-in-event for |
| 317 | * gtkwin->notebook->container? */ | |
| 318 | id = g_signal_connect(G_OBJECT(gtkconv->entry), "focus-in-event", | |
| 319 | G_CALLBACK(unnotify_cb), conv); | |
| 11728 | 320 | entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id)); |
| 9298 | 321 | |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30706
diff
changeset
|
322 | id = g_signal_connect(G_OBJECT(gtkconv->webview), "focus-in-event", |
| 9298 | 323 | G_CALLBACK(unnotify_cb), conv); |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30706
diff
changeset
|
324 | webview_ids = g_slist_append(webview_ids, GUINT_TO_POINTER(id)); |
| 6977 | 325 | } |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
326 | |
| 15884 | 327 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_click")) { |
| 14389 | 328 | /* TODO similarly should really find a way to allow for |
| 329 | * clicking in other places of the window */ | |
| 9298 | 330 | id = g_signal_connect(G_OBJECT(gtkconv->entry), "button-press-event", |
| 331 | G_CALLBACK(unnotify_cb), conv); | |
| 6977 | 332 | entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id)); |
| 12286 | 333 | |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30706
diff
changeset
|
334 | id = g_signal_connect(G_OBJECT(gtkconv->webview), "button-press-event", |
| 12286 | 335 | G_CALLBACK(unnotify_cb), conv); |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30706
diff
changeset
|
336 | webview_ids = g_slist_append(webview_ids, GUINT_TO_POINTER(id)); |
| 3374 | 337 | } |
| 3710 | 338 | |
| 15884 | 339 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_type")) { |
| 9298 | 340 | id = g_signal_connect(G_OBJECT(gtkconv->entry), "key-press-event", |
| 341 | G_CALLBACK(unnotify_cb), conv); | |
| 6977 | 342 | entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id)); |
| 3374 | 343 | } |
| 344 | ||
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
345 | g_object_set_data(G_OBJECT(conv), "notify-webview-signals", webview_ids); |
|
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
346 | g_object_set_data(G_OBJECT(conv), "notify-entry-signals", entry_ids); |
| 4035 | 347 | |
| 3428 | 348 | return 0; |
| 191 | 349 | } |
| 350 | ||
| 6977 | 351 | static void |
| 15884 | 352 | detach_signals(PurpleConversation *conv) |
| 6977 | 353 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
354 | PidginConversation *gtkconv = NULL; |
| 11606 | 355 | GSList *ids = NULL, *l; |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
356 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
357 | gtkconv = PIDGIN_CONVERSATION(conv); |
| 11581 | 358 | if (!gtkconv) |
| 359 | return; | |
| 4203 | 360 | |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
361 | ids = g_object_get_data(G_OBJECT(conv), "notify-webview-signals"); |
| 11606 | 362 | for (l = ids; l != NULL; l = l->next) |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30706
diff
changeset
|
363 | g_signal_handler_disconnect(gtkconv->webview, GPOINTER_TO_INT(l->data)); |
| 11606 | 364 | g_slist_free(ids); |
| 6302 | 365 | |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
366 | ids = g_object_get_data(G_OBJECT(conv), "notify-entry-signals"); |
| 11606 | 367 | for (l = ids; l != NULL; l = l->next) |
| 368 | g_signal_handler_disconnect(gtkconv->entry, GPOINTER_TO_INT(l->data)); | |
| 369 | g_slist_free(ids); | |
| 3710 | 370 | |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
371 | g_object_set_data(G_OBJECT(conv), "notify-message-count", GINT_TO_POINTER(0)); |
| 14385 | 372 | |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
373 | g_object_set_data(G_OBJECT(conv), "notify-webview-signals", NULL); |
|
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
374 | g_object_set_data(G_OBJECT(conv), "notify-entry-signals", NULL); |
| 3710 | 375 | } |
| 376 | ||
| 6977 | 377 | static void |
| 15884 | 378 | conv_created(PurpleConversation *conv) |
| 6977 | 379 | { |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
380 | g_object_set_data(G_OBJECT(conv), "notify-message-count", |
| 14389 | 381 | GINT_TO_POINTER(0)); |
| 14385 | 382 | |
| 14389 | 383 | /* always attach the signals, notify() will take care of conversation |
| 384 | * type checking */ | |
| 6977 | 385 | attach_signals(conv); |
| 3374 | 386 | } |
| 387 | ||
| 6977 | 388 | static void |
| 15884 | 389 | conv_switched(PurpleConversation *conv) |
| 6977 | 390 | { |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
391 | #if 0 |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
392 | PidginConvWindow *purplewin = purple_conversation_get_window(new_conv); |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
393 | #endif |
| 6302 | 394 | |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
395 | /* |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
396 | * If the conversation was switched, then make sure we re-notify |
| 15884 | 397 | * because Purple will have overwritten our custom window title. |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
398 | */ |
| 14385 | 399 | notify(conv, FALSE); |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
400 | |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
401 | #if 0 |
| 9298 | 402 | printf("conv_switched - %p - %p\n", old_conv, new_conv); |
| 15884 | 403 | printf("count - %d\n", count_messages(purplewin)); |
| 404 | if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_switch")) | |
| 9298 | 405 | unnotify(new_conv, FALSE); |
| 406 | else { | |
| 407 | /* if we don't have notification on the window then we don't want to | |
| 408 | * re-notify it */ | |
| 15884 | 409 | if (count_messages(purplewin)) |
| 410 | notify_win(purplewin); | |
| 9298 | 411 | } |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
412 | #endif |
| 6977 | 413 | } |
| 6302 | 414 | |
| 6977 | 415 | static void |
| 15884 | 416 | deleting_conv(PurpleConversation *conv) |
| 6977 | 417 | { |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
418 | PidginConvWindow *purplewin = NULL; |
|
19717
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
419 | PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
|
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
420 | |
|
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
421 | if (gtkconv == NULL) |
|
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
422 | return; |
| 9298 | 423 | |
| 6977 | 424 | detach_signals(conv); |
| 3392 | 425 | |
|
19717
bfc9d0446b60
Do not crash on hidden conversations.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16749
diff
changeset
|
426 | purplewin = gtkconv->win; |
| 11606 | 427 | |
| 15884 | 428 | handle_urgent(purplewin, FALSE); |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
429 | g_object_set_data(G_OBJECT(conv), "notify-message-count", GINT_TO_POINTER(0)); |
| 11606 | 430 | |
| 431 | return; | |
| 432 | ||
| 11581 | 433 | #if 0 |
| 434 | /* i think this line crashes */ | |
| 15884 | 435 | if (count_messages(purplewin)) |
| 436 | notify_win(purplewin); | |
| 11581 | 437 | #endif |
| 6977 | 438 | } |
| 439 | ||
|
9303
e257ad08c77c
[gaim-migrate @ 10107]
Mark Doliner <markdoliner@pidgin.im>
parents:
9298
diff
changeset
|
440 | #if 0 |
| 6977 | 441 | static void |
| 15884 | 442 | conversation_dragging(PurpleConversation *active_conv, |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
443 | PidginConvWindow *old_purplewin, |
|
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
444 | PidginConvWindow *new_purplewin) |
| 6977 | 445 | { |
| 15884 | 446 | if (old_purplewin != new_purplewin) { |
| 447 | if (old_purplewin == NULL) { | |
| 9298 | 448 | /* |
| 15884 | 449 | purple_conversation_autoset_title(active_conv); |
| 450 | handle_urgent(new_purplewin, FALSE); | |
| 9298 | 451 | */ |
| 452 | ||
| 15884 | 453 | if (count_messages(new_purplewin)) |
| 454 | notify_win(new_purplewin); | |
| 9298 | 455 | } else { |
| 15884 | 456 | printf("if else count = %d\n", count_messages(new_purplewin)); |
| 457 | printf("if else count = %d\n", count_messages(old_purplewin)); | |
| 9298 | 458 | /* |
| 15884 | 459 | PurpleConversation *old_active_conv = NULL; |
|
34635
bbecf6e1daee
Replace purple_conv_ by purple_conversation_ calls
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
460 | old_active_conv = purple_conversation_window_get_active_conversation(new_purplewin); |
| 9298 | 461 | |
| 15884 | 462 | purple_conversation_autoset_title(old_active_conv); |
| 463 | handle_urgent(old_purplewin, FALSE); | |
| 6302 | 464 | |
| 15884 | 465 | if (count_messages(old_purplewin)) |
| 466 | notify_win(old_purplewin); | |
| 9298 | 467 | |
| 15884 | 468 | purple_conversation_autoset_title(active_conv); |
| 469 | handle_urgent(new_purplewin, FALSE); | |
| 9298 | 470 | |
| 15884 | 471 | if (count_messages(new_purplewin)) |
| 472 | notify_win(new_purplewin); | |
| 9298 | 473 | */ |
| 474 | } | |
| 475 | } else { | |
| 15884 | 476 | printf("else count = %d\n", count_messages(new_purplewin)); |
| 477 | printf("else count = %d\n", count_messages(old_purplewin)); | |
| 9298 | 478 | /* |
| 15884 | 479 | purple_conversation_autoset_title(active_conv); |
| 480 | handle_urgent(old_purplewin, FALSE); | |
| 9298 | 481 | |
| 15884 | 482 | if (count_messages(old_purplewin)) |
| 483 | notify_win(old_purplewin); | |
| 9298 | 484 | */ |
| 485 | } | |
| 4035 | 486 | } |
|
9303
e257ad08c77c
[gaim-migrate @ 10107]
Mark Doliner <markdoliner@pidgin.im>
parents:
9298
diff
changeset
|
487 | #endif |
| 4035 | 488 | |
| 6977 | 489 | static void |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
490 | handle_string(PidginConvWindow *purplewin) |
| 9298 | 491 | { |
| 492 | GtkWindow *window = NULL; | |
| 493 | gchar newtitle[256]; | |
| 494 | ||
| 15884 | 495 | g_return_if_fail(purplewin != NULL); |
| 9298 | 496 | |
| 15884 | 497 | window = GTK_WINDOW(purplewin->window); |
| 9298 | 498 | g_return_if_fail(window != NULL); |
| 499 | ||
| 500 | g_snprintf(newtitle, sizeof(newtitle), "%s%s", | |
| 15884 | 501 | purple_prefs_get_string("/plugins/gtk/X11/notify/title_string"), |
| 9298 | 502 | gtk_window_get_title(window)); |
| 503 | gtk_window_set_title(window, newtitle); | |
| 504 | } | |
| 505 | ||
| 506 | static void | |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
507 | handle_count_title(PidginConvWindow *purplewin) |
| 9298 | 508 | { |
| 509 | GtkWindow *window; | |
| 510 | char newtitle[256]; | |
| 511 | ||
| 15884 | 512 | g_return_if_fail(purplewin != NULL); |
| 9298 | 513 | |
| 15884 | 514 | window = GTK_WINDOW(purplewin->window); |
| 9298 | 515 | g_return_if_fail(window != NULL); |
| 516 | ||
| 10606 | 517 | g_snprintf(newtitle, sizeof(newtitle), "[%d] %s", |
| 15884 | 518 | count_messages(purplewin), gtk_window_get_title(window)); |
| 9298 | 519 | gtk_window_set_title(window, newtitle); |
| 520 | } | |
| 521 | ||
| 522 | static void | |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
523 | handle_count_xprop(PidginConvWindow *purplewin) |
| 14389 | 524 | { |
|
33472
24393ecae82e
Make this plugin a bit more friendly with Quartz-enabled GTK+ in MacPorts.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30706
diff
changeset
|
525 | #ifdef HAVE_X11 |
| 14389 | 526 | guint count; |
| 527 | GtkWidget *window; | |
| 528 | GdkWindow *gdkwin; | |
| 529 | ||
| 15884 | 530 | window = purplewin->window; |
| 14389 | 531 | g_return_if_fail(window != NULL); |
| 532 | ||
| 15884 | 533 | if (_PurpleUnseenCount == GDK_NONE) { |
| 534 | _PurpleUnseenCount = gdk_atom_intern("_PIDGIN_UNSEEN_COUNT", FALSE); | |
| 14389 | 535 | } |
| 536 | ||
| 537 | if (_Cardinal == GDK_NONE) { | |
| 538 | _Cardinal = gdk_atom_intern("CARDINAL", FALSE); | |
| 539 | } | |
| 540 | ||
| 15884 | 541 | 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
|
542 | gdkwin = gtk_widget_get_window(window); |
| 14389 | 543 | |
| 15884 | 544 | gdk_property_change(gdkwin, _PurpleUnseenCount, _Cardinal, 32, |
| 14389 | 545 | GDK_PROP_MODE_REPLACE, (guchar *) &count, 1); |
| 546 | #endif | |
| 547 | } | |
| 548 | ||
| 549 | static void | |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
550 | handle_urgent(PidginConvWindow *purplewin, gboolean set) |
| 6977 | 551 | { |
|
25382
6a3ab0bc549d
Check that the PidginWindow we get in handle_urgent actually exists and has
Etan Reisner <deryni@pidgin.im>
parents:
24506
diff
changeset
|
552 | 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
|
553 | 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
|
554 | |
|
6a3ab0bc549d
Check that the PidginWindow we get in handle_urgent actually exists and has
Etan Reisner <deryni@pidgin.im>
parents:
24506
diff
changeset
|
555 | pidgin_set_urgent(GTK_WINDOW(purplewin->window), set); |
| 4035 | 556 | } |
| 557 | ||
| 6977 | 558 | static void |
|
35610
24b06c5e7760
Renamed PidginWindow to PidginConvWindow so that introspection associates it with pidgin_conv_window_* API
Ankit Vani <a@nevitus.org>
parents:
35526
diff
changeset
|
559 | handle_raise(PidginConvWindow *purplewin) |
| 10606 | 560 | { |
| 15884 | 561 | pidgin_conv_window_raise(purplewin); |
| 10606 | 562 | } |
| 563 | ||
| 564 | 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
|
565 | 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
|
566 | { |
|
27858
3ade5991f52f
Fix a crash with the Message Notification plugin and the 'hidden' gtkconv
Paul Aurich <darkrain42@pidgin.im>
parents:
25382
diff
changeset
|
567 | 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
|
568 | return; |
|
3ade5991f52f
Fix a crash with the Message Notification plugin and the 'hidden' gtkconv
Paul Aurich <darkrain42@pidgin.im>
parents:
25382
diff
changeset
|
569 | |
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
570 | 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
|
571 | } |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
572 | |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
573 | static void |
| 6977 | 574 | type_toggle_cb(GtkWidget *widget, gpointer data) |
| 575 | { | |
| 576 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 577 | gchar pref[256]; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
578 | |
| 14389 | 579 | g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", |
| 580 | (char *)data); | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
581 | |
| 15884 | 582 | purple_prefs_set_bool(pref, on); |
| 3374 | 583 | } |
| 584 | ||
| 6977 | 585 | static void |
| 586 | method_toggle_cb(GtkWidget *widget, gpointer data) | |
| 587 | { | |
| 588 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 589 | gchar pref[256]; | |
| 590 | ||
| 14389 | 591 | g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", |
| 592 | (char *)data); | |
| 3374 | 593 | |
| 15884 | 594 | purple_prefs_set_bool(pref, on); |
| 6977 | 595 | |
| 596 | if (!strcmp(data, "method_string")) { | |
| 597 | GtkWidget *entry = g_object_get_data(G_OBJECT(widget), "title-entry"); | |
| 598 | gtk_widget_set_sensitive(entry, on); | |
| 599 | ||
| 15884 | 600 | purple_prefs_set_string("/plugins/gtk/X11/notify/title_string", |
| 14448 | 601 | gtk_entry_get_text(GTK_ENTRY(entry))); |
| 6977 | 602 | } |
| 603 | ||
| 604 | apply_method(); | |
| 3374 | 605 | } |
| 606 | ||
| 6977 | 607 | static void |
| 608 | notify_toggle_cb(GtkWidget *widget, gpointer data) | |
| 609 | { | |
| 610 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 611 | gchar pref[256]; | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
612 | |
| 14389 | 613 | g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", |
| 614 | (char *)data); | |
| 3374 | 615 | |
| 15884 | 616 | purple_prefs_set_bool(pref, on); |
| 6977 | 617 | |
| 618 | apply_notify(); | |
| 3374 | 619 | } |
| 620 | ||
| 6977 | 621 | static gboolean |
| 622 | options_entry_cb(GtkWidget *widget, GdkEventFocus *evt, gpointer data) | |
| 623 | { | |
| 624 | if (data == NULL) | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6977
diff
changeset
|
625 | return FALSE; |
| 6302 | 626 | |
| 6977 | 627 | if (!strcmp(data, "method_string")) { |
| 15884 | 628 | purple_prefs_set_string("/plugins/gtk/X11/notify/title_string", |
| 14389 | 629 | gtk_entry_get_text(GTK_ENTRY(widget))); |
| 3374 | 630 | } |
| 6302 | 631 | |
| 6977 | 632 | apply_method(); |
| 6302 | 633 | |
| 634 | return FALSE; | |
| 635 | } | |
| 636 | ||
| 6977 | 637 | static void |
| 14389 | 638 | apply_method() |
| 639 | { | |
|
13664
fdc3b588f248
[gaim-migrate @ 16065]
Richard Laager <rlaager@pidgin.im>
parents:
13550
diff
changeset
|
640 | GList *convs; |
| 6977 | 641 | |
|
34655
6a939719ea98
Replaced purple_conversations_get() with purple_conversations_get_all(), similar to other purple entities
Ankit Vani <a@nevitus.org>
parents:
34635
diff
changeset
|
642 | for (convs = purple_conversations_get_all(); convs != NULL; |
| 14389 | 643 | convs = convs->next) { |
| 15884 | 644 | PurpleConversation *conv = (PurpleConversation *)convs->data; |
| 6302 | 645 | |
| 6977 | 646 | /* remove notifications */ |
| 9298 | 647 | unnotify(conv, FALSE); |
| 648 | ||
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
649 | if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "notify-message-count")) != 0) |
| 6977 | 650 | /* reattach appropriate notifications */ |
| 14385 | 651 | notify(conv, FALSE); |
| 6977 | 652 | } |
| 3374 | 653 | } |
| 654 | ||
| 6977 | 655 | static void |
| 656 | apply_notify() | |
| 657 | { | |
|
34655
6a939719ea98
Replaced purple_conversations_get() with purple_conversations_get_all(), similar to other purple entities
Ankit Vani <a@nevitus.org>
parents:
34635
diff
changeset
|
658 | GList *convs = purple_conversations_get_all(); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
659 | |
| 6977 | 660 | while (convs) { |
| 15884 | 661 | PurpleConversation *conv = (PurpleConversation *)convs->data; |
| 4203 | 662 | |
| 6977 | 663 | /* detach signals */ |
| 664 | detach_signals(conv); | |
| 665 | /* reattach appropriate signals */ | |
| 666 | attach_signals(conv); | |
| 4035 | 667 | |
| 6977 | 668 | convs = convs->next; |
| 4035 | 669 | } |
| 670 | } | |
| 671 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
672 | static GtkWidget * |
| 15884 | 673 | get_config_frame(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
674 | { |
| 6977 | 675 | GtkWidget *ret = NULL, *frame = NULL; |
| 676 | GtkWidget *vbox = NULL, *hbox = NULL; | |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
677 | GtkWidget *toggle = NULL, *entry = NULL, *ref; |
| 6302 | 678 | |
|
35526
ed1be305c985
Fix gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35037
diff
changeset
|
679 | ret = gtk_box_new(GTK_ORIENTATION_VERTICAL, 18); |
| 6302 | 680 | gtk_container_set_border_width(GTK_CONTAINER (ret), 12); |
| 3392 | 681 | |
| 6302 | 682 | /*---------- "Notify For" ----------*/ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
683 | frame = pidgin_make_frame(ret, _("Notify For")); |
|
35526
ed1be305c985
Fix gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35037
diff
changeset
|
684 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
| 6302 | 685 | gtk_container_add(GTK_CONTAINER(frame), vbox); |
| 686 | ||
| 3710 | 687 | toggle = gtk_check_button_new_with_mnemonic(_("_IM windows")); |
| 688 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 6977 | 689 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
| 15884 | 690 | purple_prefs_get_bool("/plugins/gtk/X11/notify/type_im")); |
| 6977 | 691 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 692 | G_CALLBACK(type_toggle_cb), "type_im"); |
| 3710 | 693 | |
| 6977 | 694 | toggle = gtk_check_button_new_with_mnemonic(_("C_hat windows")); |
| 3710 | 695 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 6977 | 696 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
| 15884 | 697 | purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat")); |
| 6977 | 698 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 699 | G_CALLBACK(type_toggle_cb), "type_chat"); |
| 6977 | 700 | |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
701 | ref = toggle; |
|
22942
2bf494f8e2a4
Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <markdoliner@pidgin.im>
parents:
22782
diff
changeset
|
702 | 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
|
703 | 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
|
704 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
| 15884 | 705 | 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
|
706 | g_signal_connect(G_OBJECT(toggle), "toggled", |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
707 | G_CALLBACK(type_toggle_cb), "type_chat_nick"); |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
708 | 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
|
709 | g_signal_connect(G_OBJECT(ref), "toggled", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
710 | G_CALLBACK(pidgin_toggle_sensitive), toggle); |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
711 | |
| 6977 | 712 | toggle = gtk_check_button_new_with_mnemonic(_("_Focused windows")); |
| 713 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 714 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 715 | purple_prefs_get_bool("/plugins/gtk/X11/notify/type_focused")); |
| 6977 | 716 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 717 | G_CALLBACK(type_toggle_cb), "type_focused"); |
| 3710 | 718 | |
| 6302 | 719 | /*---------- "Notification Methods" ----------*/ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
720 | frame = pidgin_make_frame(ret, _("Notification Methods")); |
|
35526
ed1be305c985
Fix gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35037
diff
changeset
|
721 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
| 6302 | 722 | gtk_container_add(GTK_CONTAINER(frame), vbox); |
| 723 | ||
| 6977 | 724 | /* String method button */ |
|
35526
ed1be305c985
Fix gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35037
diff
changeset
|
725 | hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 18); |
| 3565 | 726 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 6302 | 727 | toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:")); |
| 6977 | 728 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
| 15884 | 729 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_string")); |
| 3565 | 730 | gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); |
| 6977 | 731 | |
| 6302 | 732 | entry = gtk_entry_new(); |
| 733 | gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
| 734 | gtk_entry_set_max_length(GTK_ENTRY(entry), 10); | |
| 6977 | 735 | gtk_widget_set_sensitive(GTK_WIDGET(entry), |
| 15884 | 736 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_string")); |
| 6977 | 737 | gtk_entry_set_text(GTK_ENTRY(entry), |
| 15884 | 738 | purple_prefs_get_string("/plugins/gtk/X11/notify/title_string")); |
| 6977 | 739 | g_object_set_data(G_OBJECT(toggle), "title-entry", entry); |
| 740 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 9298 | 741 | G_CALLBACK(method_toggle_cb), "method_string"); |
| 6977 | 742 | g_signal_connect(G_OBJECT(entry), "focus-out-event", |
| 9298 | 743 | G_CALLBACK(options_entry_cb), "method_string"); |
| 3374 | 744 | |
| 6977 | 745 | /* Count method button */ |
| 746 | toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title")); | |
| 747 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 748 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_count")); |
| 6977 | 749 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 750 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 9298 | 751 | G_CALLBACK(method_toggle_cb), "method_count"); |
| 4035 | 752 | |
|
33472
24393ecae82e
Make this plugin a bit more friendly with Quartz-enabled GTK+ in MacPorts.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30706
diff
changeset
|
753 | #ifdef HAVE_X11 |
| 14389 | 754 | /* Count xprop method button */ |
| 755 | toggle = gtk_check_button_new_with_mnemonic(_("Insert count of new message into _X property")); | |
| 756 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 757 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 758 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_count_xprop")); |
| 14389 | 759 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 760 | G_CALLBACK(method_toggle_cb), "method_count_xprop"); | |
| 761 | ||
| 6977 | 762 | /* Urgent method button */ |
| 763 | 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
|
764 | #else |
|
24506
4d624cd775bd
Mark for translation now that we're unfrozen.
Daniel Atallah <datallah@pidgin.im>
parents:
24431
diff
changeset
|
765 | 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
|
766 | #endif |
| 6977 | 767 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 768 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 769 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent")); |
| 9298 | 770 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 771 | G_CALLBACK(method_toggle_cb), "method_urgent"); | |
| 3710 | 772 | |
| 10606 | 773 | /* Raise window method button */ |
| 774 | toggle = gtk_check_button_new_with_mnemonic(_("R_aise conversation window")); | |
| 775 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 776 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 777 | purple_prefs_get_bool("/plugins/gtk/X11/notify/method_raise")); |
| 10606 | 778 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 779 | G_CALLBACK(method_toggle_cb), "method_raise"); | |
| 780 | ||
|
22909
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
781 | /* Present conversation method button */ |
|
de65ba1caca4
Finally get around to committing charkin's version of the patch from #2145.
Etan Reisner <deryni@pidgin.im>
parents:
22782
diff
changeset
|
782 | 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
|
783 | 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
|
784 | 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
|
785 | 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
|
786 | 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
|
787 | 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
|
788 | |
| 6977 | 789 | /*---------- "Notification Removals" ----------*/ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
790 | frame = pidgin_make_frame(ret, _("Notification Removal")); |
|
35526
ed1be305c985
Fix gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35037
diff
changeset
|
791 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
| 6302 | 792 | gtk_container_add(GTK_CONTAINER(frame), vbox); |
| 3374 | 793 | |
| 6977 | 794 | /* Remove on focus button */ |
| 795 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _gains focus")); | |
| 796 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 797 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 798 | purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_focus")); |
| 6977 | 799 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(notify_toggle_cb), "notify_focus"); |
| 800 | ||
| 801 | /* Remove on click button */ | |
| 802 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click")); | |
| 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/notify_click")); |
| 6977 | 806 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 807 | G_CALLBACK(notify_toggle_cb), "notify_click"); |
| 3710 | 808 | |
| 6977 | 809 | /* Remove on type button */ |
| 810 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); | |
| 811 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 812 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 813 | purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_type")); |
| 6977 | 814 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 815 | G_CALLBACK(notify_toggle_cb), "notify_type"); |
| 4035 | 816 | |
| 6977 | 817 | /* Remove on message send button */ |
| 818 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when a _message gets sent")); | |
| 819 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 820 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 821 | purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")); |
| 6977 | 822 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 823 | G_CALLBACK(notify_toggle_cb), "notify_send"); |
| 3565 | 824 | |
| 6977 | 825 | #if 0 |
| 826 | /* Remove on conversation switch button */ | |
| 9298 | 827 | toggle = gtk_check_button_new_with_mnemonic(_("Remove on switch to conversation ta_b")); |
| 6977 | 828 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 829 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 15884 | 830 | purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_switch")); |
| 6977 | 831 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 832 | G_CALLBACK(notify_toggle_cb), "notify_switch"); |
| 6977 | 833 | #endif |
| 834 | ||
| 835 | gtk_widget_show_all(ret); | |
| 836 | return ret; | |
| 3374 | 837 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
838 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
839 | static gboolean |
| 15884 | 840 | plugin_load(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
841 | { |
|
34655
6a939719ea98
Replaced purple_conversations_get() with purple_conversations_get_all(), similar to other purple entities
Ankit Vani <a@nevitus.org>
parents:
34635
diff
changeset
|
842 | GList *convs = purple_conversations_get_all(); |
| 15884 | 843 | void *conv_handle = purple_conversations_get_handle(); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
844 | void *gtk_conv_handle = pidgin_conversations_get_handle(); |
| 6302 | 845 | |
| 846 | my_plugin = plugin; | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
847 | |
| 15884 | 848 | purple_signal_connect(gtk_conv_handle, "displayed-im-msg", plugin, |
| 849 | PURPLE_CALLBACK(message_displayed_cb), NULL); | |
| 850 | purple_signal_connect(gtk_conv_handle, "displayed-chat-msg", plugin, | |
| 851 | PURPLE_CALLBACK(message_displayed_cb), NULL); | |
| 852 | purple_signal_connect(gtk_conv_handle, "conversation-switched", plugin, | |
| 853 | PURPLE_CALLBACK(conv_switched), NULL); | |
| 854 | purple_signal_connect(conv_handle, "sent-im-msg", plugin, | |
| 855 | PURPLE_CALLBACK(im_sent_im), NULL); | |
| 856 | purple_signal_connect(conv_handle, "sent-chat-msg", plugin, | |
| 857 | PURPLE_CALLBACK(chat_sent_im), NULL); | |
| 858 | purple_signal_connect(conv_handle, "conversation-created", plugin, | |
| 859 | PURPLE_CALLBACK(conv_created), NULL); | |
| 860 | purple_signal_connect(conv_handle, "deleting-conversation", plugin, | |
| 861 | PURPLE_CALLBACK(deleting_conv), NULL); | |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
862 | #if 0 |
| 15884 | 863 | purple_signal_connect(gtk_conv_handle, "conversation-dragging", plugin, |
| 864 | PURPLE_CALLBACK(conversation_dragging), NULL); | |
|
9303
e257ad08c77c
[gaim-migrate @ 10107]
Mark Doliner <markdoliner@pidgin.im>
parents:
9298
diff
changeset
|
865 | #endif |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
866 | |
| 6977 | 867 | while (convs) { |
| 15884 | 868 | PurpleConversation *conv = (PurpleConversation *)convs->data; |
| 6302 | 869 | |
| 870 | /* attach signals */ | |
| 6977 | 871 | attach_signals(conv); |
| 6302 | 872 | |
| 6977 | 873 | convs = convs->next; |
| 6302 | 874 | } |
| 875 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
876 | return TRUE; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
877 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
878 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
879 | static gboolean |
| 15884 | 880 | plugin_unload(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
881 | { |
|
34655
6a939719ea98
Replaced purple_conversations_get() with purple_conversations_get_all(), similar to other purple entities
Ankit Vani <a@nevitus.org>
parents:
34635
diff
changeset
|
882 | GList *convs = purple_conversations_get_all(); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
883 | |
| 6977 | 884 | while (convs) { |
| 15884 | 885 | PurpleConversation *conv = (PurpleConversation *)convs->data; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
886 | |
| 6302 | 887 | /* kill signals */ |
| 6977 | 888 | detach_signals(conv); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
889 | |
| 6977 | 890 | convs = convs->next; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
891 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
892 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
893 | return TRUE; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
894 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
895 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
896 | static PidginPluginUiInfo ui_info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
897 | { |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12397
diff
changeset
|
898 | 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
|
899 | |
|
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
|
900 | /* 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
|
901 | 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
|
902 | 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
|
903 | 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
|
904 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
905 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
906 | |
| 15884 | 907 | static PurplePluginInfo info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
908 | { |
| 15884 | 909 | PURPLE_PLUGIN_MAGIC, |
| 910 | PURPLE_MAJOR_VERSION, | |
| 911 | PURPLE_MINOR_VERSION, | |
| 912 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15527
diff
changeset
|
913 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
914 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
915 | NULL, /**< dependencies */ |
| 15884 | 916 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
917 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
918 | NOTIFY_PLUGIN_ID, /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
919 | N_("Message Notification"), /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
920 | DISPLAY_VERSION, /**< version */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
921 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
922 | 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
|
923 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
924 | N_("Provides a variety of ways of notifying you of unread messages."), |
| 14389 | 925 | /**< 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
|
926 | "Etan Reisner <deryni@eden.rutgers.edu>,\nBrian Tarricone <bjt23@cornell.edu>", |
| 15884 | 927 | PURPLE_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
928 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
929 | plugin_load, /**< load */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
930 | plugin_unload, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
931 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
932 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
933 | &ui_info, /**< ui_info */ |
| 8993 | 934 | NULL, /**< extra_info */ |
| 935 | 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
|
936 | 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
|
937 | |
|
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
|
938 | /* 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
|
939 | 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
|
940 | 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
|
941 | NULL, |
| 8993 | 942 | NULL |
|
5205
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 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
945 | static void |
| 15884 | 946 | init_plugin(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
947 | { |
| 15884 | 948 | purple_prefs_add_none("/plugins/gtk"); |
| 949 | purple_prefs_add_none("/plugins/gtk/X11"); | |
| 950 | purple_prefs_add_none("/plugins/gtk/X11/notify"); | |
| 6302 | 951 | |
| 15884 | 952 | purple_prefs_add_bool("/plugins/gtk/X11/notify/type_im", TRUE); |
| 953 | purple_prefs_add_bool("/plugins/gtk/X11/notify/type_chat", FALSE); | |
| 954 | purple_prefs_add_bool("/plugins/gtk/X11/notify/type_chat_nick", FALSE); | |
| 955 | purple_prefs_add_bool("/plugins/gtk/X11/notify/type_focused", FALSE); | |
| 956 | purple_prefs_add_bool("/plugins/gtk/X11/notify/method_string", FALSE); | |
| 957 | purple_prefs_add_string("/plugins/gtk/X11/notify/title_string", "(*)"); | |
| 958 | purple_prefs_add_bool("/plugins/gtk/X11/notify/method_urgent", FALSE); | |
| 959 | purple_prefs_add_bool("/plugins/gtk/X11/notify/method_count", FALSE); | |
| 960 | purple_prefs_add_bool("/plugins/gtk/X11/notify/method_count_xprop", FALSE); | |
| 961 | 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
|
962 | purple_prefs_add_bool("/plugins/gtk/X11/notify/method_present", FALSE); |
| 15884 | 963 | purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_focus", TRUE); |
| 964 | purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_click", FALSE); | |
| 965 | purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_type", TRUE); | |
| 966 | purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_send", TRUE); | |
| 967 | 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
|
968 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
969 | |
| 15884 | 970 | PURPLE_INIT_PLUGIN(notify, init_plugin, info) |