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