Mercurial > pidgin
annotate plugins/notify.c @ 11531:bf763a1b2454
[gaim-migrate @ 13780]
(13:57:11) rlaager: LSchiere2: Should we just change gaim_notify_userinfo
to take a screenname and eliminate all the duplication of "Buddy
Information" and "Info for %s"?
(13:57:18) LSchiere2: sounds good
This breaks perl, I could not figure out how to fix that.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 12 Sep 2005 18:46:15 +0000 |
parents | ef6e94bdda08 |
children | 9b3833da6840 |
rev | line source |
---|---|
6302 | 1 /* |
2 * Gaim buddy notification plugin. | |
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 | 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 | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
26 | |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
27 /* TODO conversations have an a_virgin member which seems to be used to detect |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
28 * when a conversation was created remotely as opposed to remotely, look at |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
29 * code for sounds on first message to see how it's used and use it to allow |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
30 * for notifying on first message I don't think this is going to work because |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
31 * the check for this in the source comes after all the conversation signals |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
32 * are fired. */ |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
33 |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
34 /* TODO |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
35 * 22:22:17 <seanegan> deryni: speaking of notify.c... you know what else |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
36 * might be a neat feature? |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
37 * 22:22:30 <seanegan> Changing the window icon. |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
38 * 22:23:25 <deryni> seanegan: To what? |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
39 * 22:23:42 <seanegan> deryni: I dunno. Flash it between the regular icon and |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
40 * blank or something. |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
41 * 22:23:53 <deryni> Also I think gaim might re-set that sort of frequently, |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
42 * but I'd have to look. |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
43 * 22:25:16 <seanegan> deryni: I keep my conversations in one workspace and am |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
44 * frequently in an another, and the icon flashing in the pager would be a |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
45 * neat visual clue. |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
46 */ |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
47 |
6302 | 48 /* |
49 * From Etan, 2002: | |
50 * -Added config dialog | |
51 * -Added control over notification method | |
52 * -Added control over when to release notification | |
53 * | |
54 * -Added option to get notification for chats also | |
55 * -Cleaned up code | |
56 * -Added option to notify on click as it's own option | |
57 * rather then as what happens when on focus isn't clicked | |
58 * -Added apply button to change the denotification methods for | |
59 * open conversation windows | |
60 * -Fixed apply to conversations, count now keeps count across applies | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
61 * -Fixed(?) memory leak, and in the process fixed some stupidities |
6302 | 62 * -Hit enter when done editing the title string entry box to save it |
3392 | 63 * |
64 * Thanks to Carles Pina i Estany <carles@pinux.info> | |
65 * for count of new messages option | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
66 * |
6302 | 67 * From Brian, 20 July 2003: |
68 * -Use new xml prefs | |
69 * -Better handling of notification states tracking | |
70 * -Better pref change handling | |
71 * -Fixed a possible memleak and possible crash (rare) | |
72 * -Use gtk_window_get_title() rather than gtkwin->title | |
73 * -Other random fixes and cleanups | |
6977 | 74 * |
9298 | 75 * Etan again, 12 August 2003: |
6977 | 76 * -Better use of the new xml prefs |
77 * -Removed all bitmask stuff | |
78 * -Even better pref change handling | |
79 * -Removed unnecessary functions | |
80 * -Reworking of notification/unnotification stuff | |
81 * -Header file include cleanup | |
82 * -General code cleanup | |
9298 | 83 * |
84 * Etan yet again, 04 April 2004: | |
85 * -Re-added Urgent option | |
86 * -Re-added unnotify on focus option (still needs work, as it will only | |
87 * react to focus-in events when the entry or history widgets are focused) | |
10492 | 88 * |
89 * Sean, 08 January, 2005: | |
90 * -Added Raise option, formally in Gaim proper | |
3392 | 91 */ |
92 | |
9791 | 93 #include "internal.h" |
94 #include "gtkgaim.h" | |
10492 | 95 #include "gtkprefs.h" |
6302 | 96 |
97 #include "prefs.h" | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
98 #include "signals.h" |
9943 | 99 #include "version.h" |
4202
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
diff
changeset
|
100 |
6302 | 101 #include "gtkplugin.h" |
102 #include "gtkutils.h" | |
103 | |
6977 | 104 #include <X11/Xatom.h> |
3385 | 105 #include <X11/Xlib.h> |
3374 | 106 #include <X11/Xutil.h> |
107 | |
6302 | 108 #define NOTIFY_PLUGIN_ID "gtk-x11-notify" |
3710 | 109 |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
110 static GaimPlugin *my_plugin = NULL; |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
111 |
6302 | 112 /* notification set/unset */ |
6977 | 113 static int notify(GaimConversation *conv, gboolean increment); |
9298 | 114 static void notify_win(GaimConvWindow *gaimwin); |
115 static void unnotify(GaimConversation *conv, gboolean reset); | |
116 static int unnotify_cb(GtkWidget *widget, gpointer data, GaimConversation *conv); | |
6302 | 117 |
118 /* gtk widget callbacks for prefs panel */ | |
6977 | 119 static void type_toggle_cb(GtkWidget *widget, gpointer data); |
120 static void method_toggle_cb(GtkWidget *widget, gpointer data); | |
121 static void notify_toggle_cb(GtkWidget *widget, gpointer data); | |
122 static gboolean options_entry_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data); | |
123 static void apply_method(); | |
124 static void apply_notify(); | |
191 | 125 |
6977 | 126 /* string function */ |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
127 static void handle_string(GaimConvWindow *gaimwin); |
6302 | 128 |
6977 | 129 /* count function */ |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
130 static void handle_count(GaimConvWindow *gaimwin); |
6302 | 131 |
6977 | 132 /* urgent function */ |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
133 static void handle_urgent(GaimConvWindow *gaimwin, gboolean add); |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
134 |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
135 /* raise function */ |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
136 static void handle_raise(GaimConvWindow *gaimwin); |
3710 | 137 |
6302 | 138 /****************************************/ |
139 /* Begin doing stuff below this line... */ | |
140 /****************************************/ | |
9298 | 141 static int |
142 count_messages(GaimConvWindow *gaimwin) | |
143 { | |
144 gint count = 0; | |
145 GList *convs = NULL; | |
146 | |
147 for (convs = gaim_conv_window_get_conversations(gaimwin); | |
148 convs != NULL; convs = convs->next) { | |
149 GaimConversation *conv = convs->data; | |
150 count += GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")); | |
151 } | |
152 | |
153 return count; | |
154 } | |
6302 | 155 |
6977 | 156 static int |
157 notify(GaimConversation *conv, gboolean increment) | |
158 { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
159 GaimConvWindow *gaimwin = NULL; |
6302 | 160 gint count; |
6977 | 161 gboolean has_focus; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
162 |
6977 | 163 if (conv == NULL) |
6302 | 164 return 0; |
165 | |
6977 | 166 /* We want to remove the notifications, but not reset the counter */ |
167 unnotify(conv, FALSE); | |
168 | |
169 gaimwin = gaim_conversation_get_window(conv); | |
5021 | 170 |
6977 | 171 /* If we aren't doing notifications for this type of conversation, return */ |
11338 | 172 if (((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
9298 | 173 !gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_im")) || |
11338 | 174 ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9298 | 175 !gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_chat"))) |
6977 | 176 return 0; |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
177 |
9298 | 178 g_object_get(G_OBJECT(GAIM_GTK_WINDOW(gaimwin)->window), |
179 "has-toplevel-focus", &has_focus, NULL); | |
3374 | 180 |
6977 | 181 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_focused") || |
10984 | 182 !has_focus) { |
6977 | 183 if (increment) { |
184 count = GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")); | |
185 count++; | |
186 gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(count)); | |
187 } | |
6302 | 188 |
9298 | 189 notify_win(gaimwin); |
6977 | 190 } |
6302 | 191 |
192 return 0; | |
193 } | |
194 | |
9298 | 195 static void |
196 notify_win(GaimConvWindow *gaimwin) | |
197 { | |
10971 | 198 if (count_messages(gaimwin) <= 0) |
199 return; | |
200 | |
9298 | 201 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_count")) |
202 handle_count(gaimwin); | |
203 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_string")) | |
204 handle_string(gaimwin); | |
205 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent")) | |
206 handle_urgent(gaimwin, TRUE); | |
10492 | 207 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_raise")) |
208 handle_raise(gaimwin); | |
9298 | 209 } |
210 | |
211 static void | |
212 unnotify(GaimConversation *conv, gboolean reset) | |
213 { | |
214 GaimConversation *active_conv = NULL; | |
215 GaimConvWindow *gaimwin = NULL; | |
216 | |
217 g_return_if_fail(conv != NULL); | |
218 | |
219 gaimwin = gaim_conversation_get_window(conv); | |
220 active_conv = gaim_conv_window_get_active_conversation(gaimwin); | |
221 | |
222 /* reset the conversation window title */ | |
223 gaim_conversation_autoset_title(active_conv); | |
224 | |
225 if (reset) { | |
226 /* Only need to actually remove the urgent hinting here, since removing it | |
227 * just to have it readded in re-notify is an unnecessary couple extra RTs | |
228 * to the server */ | |
229 handle_urgent(gaimwin, FALSE); | |
230 gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); | |
231 } | |
232 | |
233 return; | |
234 } | |
235 | |
236 static int | |
237 unnotify_cb(GtkWidget *widget, gpointer data, GaimConversation *conv) | |
238 { | |
239 if (GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")) != 0) | |
240 unnotify(conv, TRUE); | |
241 | |
242 return 0; | |
243 } | |
244 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
245 static gboolean |
9298 | 246 im_recv_im(GaimAccount *account, char *sender, char *message, |
10104 | 247 GaimConversation *conv, int *flags) |
6977 | 248 { |
249 notify(conv, TRUE); | |
3710 | 250 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
251 return FALSE; |
3710 | 252 } |
253 | |
9298 | 254 static gboolean |
255 chat_recv_im(GaimAccount *account, char *sender, char *message, | |
10104 | 256 GaimConversation *conv, int *flags) |
9298 | 257 { |
10345 | 258 if (gaim_conv_chat_is_user_ignored(GAIM_CONV_CHAT(conv), sender)) |
259 return FALSE; | |
260 | |
9298 | 261 notify(conv, TRUE); |
262 | |
263 return FALSE; | |
264 } | |
265 | |
6977 | 266 static void |
9298 | 267 im_sent_im(GaimAccount *account, char *receiver, const char *message) { |
268 GaimConversation *conv = NULL; | |
269 | |
270 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) { | |
11338 | 271 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, receiver, account); |
9298 | 272 unnotify(conv, TRUE); |
273 } | |
274 } | |
275 | |
276 static void | |
277 chat_sent_im(GaimAccount *account, const char *message, int id) | |
6977 | 278 { |
279 GaimConversation *conv = NULL; | |
280 | |
281 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) { | |
282 conv = gaim_find_chat(gaim_account_get_connection(account), id); | |
283 unnotify(conv, TRUE); | |
284 } | |
3710 | 285 } |
286 | |
6977 | 287 static int |
288 attach_signals(GaimConversation *conv) | |
289 { | |
290 GaimGtkConversation *gtkconv = NULL; | |
291 GaimGtkWindow *gtkwin = NULL; | |
292 GSList *window_ids = NULL, *imhtml_ids = NULL, *entry_ids = NULL; | |
293 guint id; | |
294 | |
295 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
296 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
297 |
6977 | 298 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_focus")) { |
9298 | 299 /* TODO should really find a way to make this work no matter where the |
300 * focus is inside the conv window, without having to bind to | |
301 * focus-in-event on the g(d|t)kwindow */ | |
302 /* try setting the signal on the focus-in-event for | |
303 * gtkwin->notebook->container? */ | |
304 id = g_signal_connect(G_OBJECT(gtkconv->entry), "focus-in-event", | |
305 G_CALLBACK(unnotify_cb), conv); | |
306 window_ids = g_slist_append(window_ids, GUINT_TO_POINTER(id)); | |
307 | |
308 id = g_signal_connect(G_OBJECT(gtkconv->imhtml), "focus-in-event", | |
309 G_CALLBACK(unnotify_cb), conv); | |
6977 | 310 window_ids = g_slist_append(window_ids, GUINT_TO_POINTER(id)); |
311 } | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
312 |
6977 | 313 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_click")) { |
9298 | 314 /* TODO similarly should really find a way to allow for clicking in other |
315 * places of the window */ | |
316 id = g_signal_connect(G_OBJECT(gtkconv->imhtml), "button-press-event", | |
317 G_CALLBACK(unnotify_cb), conv); | |
6977 | 318 imhtml_ids = g_slist_append(imhtml_ids, GUINT_TO_POINTER(id)); |
319 | |
9298 | 320 id = g_signal_connect(G_OBJECT(gtkconv->entry), "button-press-event", |
321 G_CALLBACK(unnotify_cb), conv); | |
6977 | 322 entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id)); |
3374 | 323 } |
3710 | 324 |
6977 | 325 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_type")) { |
9298 | 326 id = g_signal_connect(G_OBJECT(gtkconv->entry), "key-press-event", |
327 G_CALLBACK(unnotify_cb), conv); | |
6977 | 328 entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id)); |
3374 | 329 } |
330 | |
6977 | 331 gaim_conversation_set_data(conv, "notify-window-signals", window_ids); |
332 gaim_conversation_set_data(conv, "notify-imhtml-signals", imhtml_ids); | |
333 gaim_conversation_set_data(conv, "notify-entry-signals", entry_ids); | |
4035 | 334 |
3428 | 335 return 0; |
191 | 336 } |
337 | |
6977 | 338 static void |
339 detach_signals(GaimConversation *conv) | |
340 { | |
341 GaimGtkConversation *gtkconv = NULL; | |
342 GaimGtkWindow *gtkwin = NULL; | |
343 GSList *ids = NULL; | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
344 |
6977 | 345 gtkconv = GAIM_GTK_CONVERSATION(conv); |
346 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
347 |
6977 | 348 ids = gaim_conversation_get_data(conv, "notify-window-signals"); |
349 for (; ids != NULL; ids = ids->next) | |
350 g_signal_handler_disconnect(gtkwin->window, GPOINTER_TO_INT(ids->data)); | |
6302 | 351 |
6977 | 352 ids = gaim_conversation_get_data(conv, "notify-imhtml-signals"); |
353 for (; ids != NULL; ids = ids->next) | |
354 g_signal_handler_disconnect(gtkconv->imhtml, GPOINTER_TO_INT(ids->data)); | |
6302 | 355 |
6977 | 356 ids = gaim_conversation_get_data(conv, "notify-entry-signals"); |
357 for (; ids != NULL; ids = ids->next) | |
358 g_signal_handler_disconnect(gtkconv->entry, GPOINTER_TO_INT(ids->data)); | |
3710 | 359 |
9298 | 360 gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); |
3710 | 361 |
6977 | 362 gaim_conversation_set_data(conv, "notify-window-signals", NULL); |
363 gaim_conversation_set_data(conv, "notify-imhtml-signals", NULL); | |
364 gaim_conversation_set_data(conv, "notify-entry-signals", NULL); | |
3710 | 365 } |
366 | |
6977 | 367 static void |
368 conv_created(GaimConversation *conv) | |
369 { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
370 GaimConvWindow *gaimwin = NULL; |
6977 | 371 GaimGtkWindow *gtkwin = NULL; |
6302 | 372 |
6977 | 373 gaimwin = gaim_conversation_get_window(conv); |
6302 | 374 |
6977 | 375 if (gaimwin == NULL) |
6302 | 376 return; |
3374 | 377 |
6977 | 378 gtkwin = GAIM_GTK_WINDOW(gaimwin); |
379 | |
9298 | 380 gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); |
6302 | 381 |
6977 | 382 /* always attach the signals, notify() will take care of conversation type |
383 * checking */ | |
384 attach_signals(conv); | |
3374 | 385 } |
386 | |
6977 | 387 static void |
388 conv_switched(GaimConversation *old_conv, GaimConversation *new_conv) | |
389 { | |
10971 | 390 #if 0 |
9298 | 391 GaimConvWindow *gaimwin = gaim_conversation_get_window(new_conv); |
10971 | 392 #endif |
6302 | 393 |
10971 | 394 /* |
395 * If the conversation was switched, then make sure we re-notify | |
396 * because Gaim will have overwritten our custom window title. | |
397 */ | |
398 notify(new_conv, FALSE); | |
399 | |
400 #if 0 | |
9298 | 401 printf("conv_switched - %p - %p\n", old_conv, new_conv); |
402 printf("count - %d\n", count_messages(gaimwin)); | |
403 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_switch")) | |
404 unnotify(new_conv, FALSE); | |
405 else { | |
406 /* if we don't have notification on the window then we don't want to | |
407 * re-notify it */ | |
408 if (count_messages(gaimwin)) | |
409 notify_win(gaimwin); | |
410 } | |
10971 | 411 #endif |
6977 | 412 } |
6302 | 413 |
6977 | 414 static void |
415 deleting_conv(GaimConversation *conv) | |
416 { | |
9298 | 417 GaimConvWindow *gaimwin = NULL; |
418 | |
6977 | 419 detach_signals(conv); |
3392 | 420 |
9298 | 421 unnotify(conv, TRUE); |
6977 | 422 |
9298 | 423 gaimwin = gaim_conversation_get_window(conv); |
424 if (count_messages(gaimwin)) | |
425 notify_win(gaimwin); | |
6977 | 426 } |
427 | |
9303 | 428 #if 0 |
6977 | 429 static void |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
430 conversation_dragging(GaimConversation *active_conv, |
9298 | 431 GaimConvWindow *old_gaimwin, |
432 GaimConvWindow *new_gaimwin) | |
6977 | 433 { |
9298 | 434 if (old_gaimwin != new_gaimwin) { |
435 if (old_gaimwin == NULL) { | |
436 /* | |
437 gaim_conversation_autoset_title(active_conv); | |
438 handle_urgent(new_gaimwin, FALSE); | |
439 */ | |
440 | |
441 if (count_messages(new_gaimwin)) | |
442 notify_win(new_gaimwin); | |
443 } else { | |
444 printf("if else count = %d\n", count_messages(new_gaimwin)); | |
445 printf("if else count = %d\n", count_messages(old_gaimwin)); | |
446 /* | |
447 GaimConversation *old_active_conv = NULL; | |
448 old_active_conv = gaim_conv_window_get_active_conversation(new_gaimwin); | |
449 | |
450 gaim_conversation_autoset_title(old_active_conv); | |
451 handle_urgent(old_gaimwin, FALSE); | |
6302 | 452 |
9298 | 453 if (count_messages(old_gaimwin)) |
454 notify_win(old_gaimwin); | |
455 | |
456 gaim_conversation_autoset_title(active_conv); | |
457 handle_urgent(new_gaimwin, FALSE); | |
458 | |
459 if (count_messages(new_gaimwin)) | |
460 notify_win(new_gaimwin); | |
461 */ | |
462 } | |
463 } else { | |
464 printf("else count = %d\n", count_messages(new_gaimwin)); | |
465 printf("else count = %d\n", count_messages(old_gaimwin)); | |
466 /* | |
467 gaim_conversation_autoset_title(active_conv); | |
468 handle_urgent(old_gaimwin, FALSE); | |
469 | |
470 if (count_messages(old_gaimwin)) | |
471 notify_win(old_gaimwin); | |
472 */ | |
473 } | |
4035 | 474 } |
9303 | 475 #endif |
4035 | 476 |
6977 | 477 static void |
9298 | 478 handle_string(GaimConvWindow *gaimwin) |
479 { | |
480 GtkWindow *window = NULL; | |
481 gchar newtitle[256]; | |
482 | |
483 g_return_if_fail(gaimwin != NULL); | |
484 | |
485 window = GTK_WINDOW(GAIM_GTK_WINDOW(gaimwin)->window); | |
486 g_return_if_fail(window != NULL); | |
487 | |
488 g_snprintf(newtitle, sizeof(newtitle), "%s%s", | |
489 gaim_prefs_get_string("/plugins/gtk/X11/notify/title_string"), | |
490 gtk_window_get_title(window)); | |
491 gtk_window_set_title(window, newtitle); | |
492 } | |
493 | |
494 static void | |
495 handle_count(GaimConvWindow *gaimwin) | |
496 { | |
497 GtkWindow *window; | |
498 char newtitle[256]; | |
499 | |
500 g_return_if_fail(gaimwin != NULL); | |
501 | |
502 window = GTK_WINDOW(GAIM_GTK_WINDOW(gaimwin)->window); | |
503 g_return_if_fail(window != NULL); | |
504 | |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
505 g_snprintf(newtitle, sizeof(newtitle), "[%d] %s", |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
506 count_messages(gaimwin), gtk_window_get_title(window)); |
9298 | 507 gtk_window_set_title(window, newtitle); |
508 } | |
509 | |
510 static void | |
511 handle_urgent(GaimConvWindow *gaimwin, gboolean add) | |
6977 | 512 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
513 XWMHints *hints; |
9298 | 514 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(gaimwin); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
515 |
9298 | 516 g_return_if_fail(gtkwin != NULL); |
517 g_return_if_fail(gtkwin->window != NULL); | |
518 g_return_if_fail(gtkwin->window->window != NULL); | |
519 | |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
520 hints = XGetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
521 GDK_WINDOW_XWINDOW(gtkwin->window->window)); |
6977 | 522 if (add) |
523 hints->flags |= XUrgencyHint; | |
524 else | |
525 hints->flags &= ~XUrgencyHint; | |
9298 | 526 XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), |
527 GDK_WINDOW_XWINDOW(gtkwin->window->window), hints); | |
4218 | 528 XFree(hints); |
4035 | 529 } |
530 | |
6977 | 531 static void |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
532 handle_raise(GaimConvWindow *gaimwin) |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
533 { |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
534 gaim_conv_window_raise(gaimwin); |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
535 } |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
536 |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
537 static void |
6977 | 538 type_toggle_cb(GtkWidget *widget, gpointer data) |
539 { | |
540 gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
541 gchar pref[256]; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
542 |
6977 | 543 g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", (char *)data); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
544 |
6977 | 545 gaim_prefs_set_bool(pref, on); |
3374 | 546 } |
547 | |
6977 | 548 static void |
549 method_toggle_cb(GtkWidget *widget, gpointer data) | |
550 { | |
551 gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
552 gchar pref[256]; | |
553 | |
554 g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", (char *)data); | |
3374 | 555 |
6977 | 556 gaim_prefs_set_bool(pref, on); |
557 | |
558 if (!strcmp(data, "method_string")) { | |
559 GtkWidget *entry = g_object_get_data(G_OBJECT(widget), "title-entry"); | |
560 gtk_widget_set_sensitive(entry, on); | |
561 | |
562 gaim_prefs_set_string("/plugins/gtk/X11/notify/title_string", gtk_entry_get_text(GTK_ENTRY(entry))); | |
563 } | |
564 | |
565 apply_method(); | |
3374 | 566 } |
567 | |
6977 | 568 static void |
569 notify_toggle_cb(GtkWidget *widget, gpointer data) | |
570 { | |
571 gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
572 gchar pref[256]; | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
573 |
6977 | 574 g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", (char *)data); |
3374 | 575 |
6977 | 576 gaim_prefs_set_bool(pref, on); |
577 | |
578 apply_notify(); | |
3374 | 579 } |
580 | |
6977 | 581 static gboolean |
582 options_entry_cb(GtkWidget *widget, GdkEventFocus *evt, gpointer data) | |
583 { | |
584 if (data == NULL) | |
6982 | 585 return FALSE; |
6302 | 586 |
6977 | 587 if (!strcmp(data, "method_string")) { |
588 gaim_prefs_set_string("/plugins/gtk/X11/notify/title_string", gtk_entry_get_text(GTK_ENTRY(widget))); | |
3374 | 589 } |
6302 | 590 |
6977 | 591 apply_method(); |
6302 | 592 |
593 return FALSE; | |
594 } | |
595 | |
6977 | 596 static void |
597 apply_method() { | |
598 GList *convs = gaim_get_conversations(); | |
9298 | 599 GaimConvWindow *gaimwin = NULL; |
6977 | 600 |
9298 | 601 for (convs = gaim_get_conversations(); convs != NULL; convs = convs->next) { |
6977 | 602 GaimConversation *conv = (GaimConversation *)convs->data; |
6302 | 603 |
6977 | 604 /* remove notifications */ |
9298 | 605 unnotify(conv, FALSE); |
606 | |
607 gaimwin = gaim_conversation_get_window(conv); | |
608 if (GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")) != 0) | |
6977 | 609 /* reattach appropriate notifications */ |
610 notify(conv, FALSE); | |
611 } | |
3374 | 612 } |
613 | |
6977 | 614 static void |
615 apply_notify() | |
616 { | |
617 GList *convs = gaim_get_conversations(); | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
618 |
6977 | 619 while (convs) { |
620 GaimConversation *conv = (GaimConversation *)convs->data; | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
621 |
6977 | 622 /* detach signals */ |
623 detach_signals(conv); | |
624 /* reattach appropriate signals */ | |
625 attach_signals(conv); | |
4035 | 626 |
6977 | 627 convs = convs->next; |
4035 | 628 } |
629 } | |
630 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
631 static GtkWidget * |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
632 get_config_frame(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
633 { |
6977 | 634 GtkWidget *ret = NULL, *frame = NULL; |
635 GtkWidget *vbox = NULL, *hbox = NULL; | |
636 GtkWidget *toggle = NULL, *entry = NULL; | |
6302 | 637 |
3565 | 638 ret = gtk_vbox_new(FALSE, 18); |
6302 | 639 gtk_container_set_border_width(GTK_CONTAINER (ret), 12); |
3392 | 640 |
6302 | 641 /*---------- "Notify For" ----------*/ |
642 frame = gaim_gtk_make_frame(ret, _("Notify For")); | |
643 vbox = gtk_vbox_new(FALSE, 5); | |
644 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
645 | |
3710 | 646 toggle = gtk_check_button_new_with_mnemonic(_("_IM windows")); |
647 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
6977 | 648 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
9298 | 649 gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_im")); |
6977 | 650 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 651 G_CALLBACK(type_toggle_cb), "type_im"); |
3710 | 652 |
6977 | 653 toggle = gtk_check_button_new_with_mnemonic(_("C_hat windows")); |
3710 | 654 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
6977 | 655 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
9298 | 656 gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_chat")); |
6977 | 657 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 658 G_CALLBACK(type_toggle_cb), "type_chat"); |
6977 | 659 |
660 toggle = gtk_check_button_new_with_mnemonic(_("_Focused windows")); | |
661 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
662 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 663 gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_focused")); |
6977 | 664 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 665 G_CALLBACK(type_toggle_cb), "type_focused"); |
3710 | 666 |
6302 | 667 /*---------- "Notification Methods" ----------*/ |
668 frame = gaim_gtk_make_frame(ret, _("Notification Methods")); | |
669 vbox = gtk_vbox_new(FALSE, 5); | |
670 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
671 | |
6977 | 672 /* String method button */ |
3565 | 673 hbox = gtk_hbox_new(FALSE, 18); |
674 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
6302 | 675 toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:")); |
6977 | 676 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
9298 | 677 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_string")); |
3565 | 678 gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); |
6977 | 679 |
6302 | 680 entry = gtk_entry_new(); |
681 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
682 gtk_entry_set_max_length(GTK_ENTRY(entry), 10); | |
6977 | 683 gtk_widget_set_sensitive(GTK_WIDGET(entry), |
9298 | 684 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_string")); |
6977 | 685 gtk_entry_set_text(GTK_ENTRY(entry), |
9298 | 686 gaim_prefs_get_string("/plugins/gtk/X11/notify/title_string")); |
6977 | 687 g_object_set_data(G_OBJECT(toggle), "title-entry", entry); |
688 g_signal_connect(G_OBJECT(toggle), "toggled", | |
9298 | 689 G_CALLBACK(method_toggle_cb), "method_string"); |
6977 | 690 g_signal_connect(G_OBJECT(entry), "focus-out-event", |
9298 | 691 G_CALLBACK(options_entry_cb), "method_string"); |
3374 | 692 |
6977 | 693 /* Count method button */ |
694 toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title")); | |
695 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 696 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_count")); |
6977 | 697 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
698 g_signal_connect(G_OBJECT(toggle), "toggled", | |
9298 | 699 G_CALLBACK(method_toggle_cb), "method_count"); |
4035 | 700 |
6977 | 701 /* Urgent method button */ |
702 toggle = gtk_check_button_new_with_mnemonic(_("Set window manager \"_URGENT\" hint")); | |
703 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
704 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 705 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent")); |
706 g_signal_connect(G_OBJECT(toggle), "toggled", | |
707 G_CALLBACK(method_toggle_cb), "method_urgent"); | |
3710 | 708 |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
709 /* Raise window method button */ |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
710 toggle = gtk_check_button_new_with_mnemonic(_("R_aise conversation window")); |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
711 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
712 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
713 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_raise")); |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
714 g_signal_connect(G_OBJECT(toggle), "toggled", |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
715 G_CALLBACK(method_toggle_cb), "method_raise"); |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
716 |
6977 | 717 /*---------- "Notification Removals" ----------*/ |
6302 | 718 frame = gaim_gtk_make_frame(ret, _("Notification Removal")); |
719 vbox = gtk_vbox_new(FALSE, 5); | |
720 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
3374 | 721 |
6977 | 722 /* Remove on focus button */ |
723 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _gains focus")); | |
724 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
725 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 726 gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_focus")); |
6977 | 727 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(notify_toggle_cb), "notify_focus"); |
728 | |
729 /* Remove on click button */ | |
730 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click")); | |
731 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
732 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 733 gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_click")); |
6977 | 734 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 735 G_CALLBACK(notify_toggle_cb), "notify_click"); |
3710 | 736 |
6977 | 737 /* Remove on type button */ |
738 toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); | |
739 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
740 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 741 gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_type")); |
6977 | 742 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 743 G_CALLBACK(notify_toggle_cb), "notify_type"); |
4035 | 744 |
6977 | 745 /* Remove on message send button */ |
746 toggle = gtk_check_button_new_with_mnemonic(_("Remove when a _message gets sent")); | |
747 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
748 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 749 gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")); |
6977 | 750 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 751 G_CALLBACK(notify_toggle_cb), "notify_send"); |
3565 | 752 |
6977 | 753 #if 0 |
754 /* Remove on conversation switch button */ | |
9298 | 755 toggle = gtk_check_button_new_with_mnemonic(_("Remove on switch to conversation ta_b")); |
6977 | 756 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
757 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 758 gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_switch")); |
6977 | 759 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 760 G_CALLBACK(notify_toggle_cb), "notify_switch"); |
6977 | 761 #endif |
762 | |
763 gtk_widget_show_all(ret); | |
764 return ret; | |
3374 | 765 } |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
766 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
767 static gboolean |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
768 plugin_load(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
769 { |
6977 | 770 GList *convs = gaim_get_conversations(); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
771 void *conv_handle = gaim_conversations_get_handle(); |
9298 | 772 /* |
773 void *gtk_conv_handle = gaim_gtk_conversations_get_handle(); | |
774 */ | |
6302 | 775 |
776 my_plugin = plugin; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
777 |
6977 | 778 gaim_signal_connect(conv_handle, "received-im-msg", plugin, |
9298 | 779 GAIM_CALLBACK(im_recv_im), NULL); |
6977 | 780 gaim_signal_connect(conv_handle, "received-chat-msg", plugin, |
9298 | 781 GAIM_CALLBACK(chat_recv_im), NULL); |
6977 | 782 gaim_signal_connect(conv_handle, "sent-im-msg", plugin, |
9298 | 783 GAIM_CALLBACK(im_sent_im), NULL); |
6977 | 784 gaim_signal_connect(conv_handle, "sent-chat-msg", plugin, |
9298 | 785 GAIM_CALLBACK(chat_sent_im), NULL); |
6977 | 786 gaim_signal_connect(conv_handle, "conversation-created", plugin, |
9298 | 787 GAIM_CALLBACK(conv_created), NULL); |
6977 | 788 gaim_signal_connect(conv_handle, "chat-joined", plugin, |
9298 | 789 GAIM_CALLBACK(conv_created), NULL); |
6977 | 790 gaim_signal_connect(conv_handle, "deleting-conversation", plugin, |
9298 | 791 GAIM_CALLBACK(deleting_conv), NULL); |
6977 | 792 gaim_signal_connect(conv_handle, "conversation-switched", plugin, |
9298 | 793 GAIM_CALLBACK(conv_switched), NULL); |
10971 | 794 #if 0 |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
795 gaim_signal_connect(gtk_conv_handle, "conversation-dragging", plugin, |
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
796 GAIM_CALLBACK(conversation_dragging), NULL); |
9303 | 797 #endif |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
798 |
6977 | 799 while (convs) { |
800 GaimConversation *conv = (GaimConversation *)convs->data; | |
6302 | 801 |
802 /* attach signals */ | |
6977 | 803 attach_signals(conv); |
6302 | 804 |
6977 | 805 convs = convs->next; |
6302 | 806 } |
807 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
808 return TRUE; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
809 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
810 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
811 static gboolean |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
812 plugin_unload(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
813 { |
6977 | 814 GList *convs = gaim_get_conversations(); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
815 |
6977 | 816 while (convs) { |
817 GaimConversation *conv = (GaimConversation *)convs->data; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
818 |
6302 | 819 /* kill signals */ |
6977 | 820 detach_signals(conv); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
821 |
6977 | 822 convs = convs->next; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
823 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
824 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
825 return TRUE; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
826 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
827 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
828 static GaimGtkPluginUiInfo ui_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
829 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
830 get_config_frame |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
831 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
832 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
833 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
834 { |
9943 | 835 GAIM_PLUGIN_MAGIC, |
836 GAIM_MAJOR_VERSION, | |
837 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
838 GAIM_PLUGIN_STANDARD, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
839 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
840 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
841 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
842 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
843 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
844 NOTIFY_PLUGIN_ID, /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
845 N_("Message Notification"), /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
846 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
847 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
848 N_("Provides a variety of ways of notifying you of unread messages."), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
849 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
850 N_("Provides a variety of ways of notifying you of unread messages."), |
9298 | 851 "Etan Reisner <deryni@eden.rutgers.edu>\n\t\t\tBrian Tarricone <bjt23@cornell.edu>", |
6302 | 852 /**< author */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
853 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
854 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
855 plugin_load, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
856 plugin_unload, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
857 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
858 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
859 &ui_info, /**< ui_info */ |
8993 | 860 NULL, /**< extra_info */ |
861 NULL, | |
862 NULL | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
863 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
864 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
865 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
866 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
867 { |
6302 | 868 gaim_prefs_add_none("/plugins/gtk"); |
869 gaim_prefs_add_none("/plugins/gtk/X11"); | |
870 gaim_prefs_add_none("/plugins/gtk/X11/notify"); | |
871 | |
6464 | 872 gaim_prefs_add_bool("/plugins/gtk/X11/notify/type_im", TRUE); |
873 gaim_prefs_add_bool("/plugins/gtk/X11/notify/type_chat", FALSE); | |
874 gaim_prefs_add_bool("/plugins/gtk/X11/notify/type_focused", FALSE); | |
6302 | 875 gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_string", FALSE); |
876 gaim_prefs_add_string("/plugins/gtk/X11/notify/title_string", "(*)"); | |
877 gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_urgent", FALSE); | |
878 gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_count", FALSE); | |
10492 | 879 gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_raise", FALSE); |
6302 | 880 gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_focus", FALSE); |
881 gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_click", FALSE); | |
882 gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_type", TRUE); | |
6464 | 883 gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_send", TRUE); |
884 gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_switch", TRUE); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
885 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
886 |
6063 | 887 GAIM_INIT_PLUGIN(notify, init_plugin, info) |