Mercurial > pidgin
annotate plugins/notify.c @ 10863:f289e9f76053
[gaim-migrate @ 12546]
Better status for Gadu-Gadu. I know this fixes the bug where enabled gg
accounts would not sign-on when you start Gaim. It probably fixes other,
related problems.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 24 Apr 2005 20:49:55 +0000 |
parents | 9c4dca2deb99 |
children | 57e3e958ff49 |
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 */ |
172 if (((gaim_conversation_get_type(conv) == GAIM_CONV_IM) && | |
9298 | 173 !gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_im")) || |
174 ((gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) && | |
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") || |
9298 | 182 (has_focus && gaim_conv_window_get_active_conversation(gaimwin) != conv) || |
183 !has_focus) { | |
6977 | 184 if (increment) { |
185 count = GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")); | |
186 count++; | |
187 gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(count)); | |
188 } | |
6302 | 189 |
9298 | 190 notify_win(gaimwin); |
6977 | 191 } |
6302 | 192 |
193 return 0; | |
194 } | |
195 | |
9298 | 196 static void |
197 notify_win(GaimConvWindow *gaimwin) | |
198 { | |
199 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_count")) | |
200 handle_count(gaimwin); | |
201 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_string")) | |
202 handle_string(gaimwin); | |
203 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent")) | |
204 handle_urgent(gaimwin, TRUE); | |
10492 | 205 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_raise")) |
206 handle_raise(gaimwin); | |
9298 | 207 } |
208 | |
209 static void | |
210 unnotify(GaimConversation *conv, gboolean reset) | |
211 { | |
212 GaimConversation *active_conv = NULL; | |
213 GaimConvWindow *gaimwin = NULL; | |
214 | |
215 g_return_if_fail(conv != NULL); | |
216 | |
217 gaimwin = gaim_conversation_get_window(conv); | |
218 active_conv = gaim_conv_window_get_active_conversation(gaimwin); | |
219 | |
220 /* reset the conversation window title */ | |
221 gaim_conversation_autoset_title(active_conv); | |
222 | |
223 if (reset) { | |
224 /* Only need to actually remove the urgent hinting here, since removing it | |
225 * just to have it readded in re-notify is an unnecessary couple extra RTs | |
226 * to the server */ | |
227 handle_urgent(gaimwin, FALSE); | |
228 gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); | |
229 } | |
230 | |
231 return; | |
232 } | |
233 | |
234 static int | |
235 unnotify_cb(GtkWidget *widget, gpointer data, GaimConversation *conv) | |
236 { | |
237 if (GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")) != 0) | |
238 unnotify(conv, TRUE); | |
239 | |
240 return 0; | |
241 } | |
242 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
243 static gboolean |
9298 | 244 im_recv_im(GaimAccount *account, char *sender, char *message, |
10104 | 245 GaimConversation *conv, int *flags) |
6977 | 246 { |
247 notify(conv, TRUE); | |
3710 | 248 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
249 return FALSE; |
3710 | 250 } |
251 | |
9298 | 252 static gboolean |
253 chat_recv_im(GaimAccount *account, char *sender, char *message, | |
10104 | 254 GaimConversation *conv, int *flags) |
9298 | 255 { |
10345 | 256 if (gaim_conv_chat_is_user_ignored(GAIM_CONV_CHAT(conv), sender)) |
257 return FALSE; | |
258 | |
9298 | 259 notify(conv, TRUE); |
260 | |
261 return FALSE; | |
262 } | |
263 | |
6977 | 264 static void |
9298 | 265 im_sent_im(GaimAccount *account, char *receiver, const char *message) { |
266 GaimConversation *conv = NULL; | |
267 | |
268 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) { | |
10246 | 269 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, receiver, account); |
9298 | 270 unnotify(conv, TRUE); |
271 } | |
272 } | |
273 | |
274 static void | |
275 chat_sent_im(GaimAccount *account, const char *message, int id) | |
6977 | 276 { |
277 GaimConversation *conv = NULL; | |
278 | |
279 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) { | |
280 conv = gaim_find_chat(gaim_account_get_connection(account), id); | |
281 unnotify(conv, TRUE); | |
282 } | |
3710 | 283 } |
284 | |
6977 | 285 static int |
286 attach_signals(GaimConversation *conv) | |
287 { | |
288 GaimGtkConversation *gtkconv = NULL; | |
289 GaimGtkWindow *gtkwin = NULL; | |
290 GSList *window_ids = NULL, *imhtml_ids = NULL, *entry_ids = NULL; | |
291 guint id; | |
292 | |
293 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
294 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
295 |
6977 | 296 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_focus")) { |
9298 | 297 /* TODO should really find a way to make this work no matter where the |
298 * focus is inside the conv window, without having to bind to | |
299 * focus-in-event on the g(d|t)kwindow */ | |
300 /* try setting the signal on the focus-in-event for | |
301 * gtkwin->notebook->container? */ | |
302 id = g_signal_connect(G_OBJECT(gtkconv->entry), "focus-in-event", | |
303 G_CALLBACK(unnotify_cb), conv); | |
304 window_ids = g_slist_append(window_ids, GUINT_TO_POINTER(id)); | |
305 | |
306 id = g_signal_connect(G_OBJECT(gtkconv->imhtml), "focus-in-event", | |
307 G_CALLBACK(unnotify_cb), conv); | |
6977 | 308 window_ids = g_slist_append(window_ids, GUINT_TO_POINTER(id)); |
309 } | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
310 |
6977 | 311 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_click")) { |
9298 | 312 /* TODO similarly should really find a way to allow for clicking in other |
313 * places of the window */ | |
314 id = g_signal_connect(G_OBJECT(gtkconv->imhtml), "button-press-event", | |
315 G_CALLBACK(unnotify_cb), conv); | |
6977 | 316 imhtml_ids = g_slist_append(imhtml_ids, GUINT_TO_POINTER(id)); |
317 | |
9298 | 318 id = g_signal_connect(G_OBJECT(gtkconv->entry), "button-press-event", |
319 G_CALLBACK(unnotify_cb), conv); | |
6977 | 320 entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id)); |
3374 | 321 } |
3710 | 322 |
6977 | 323 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_type")) { |
9298 | 324 id = g_signal_connect(G_OBJECT(gtkconv->entry), "key-press-event", |
325 G_CALLBACK(unnotify_cb), conv); | |
6977 | 326 entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id)); |
3374 | 327 } |
328 | |
6977 | 329 gaim_conversation_set_data(conv, "notify-window-signals", window_ids); |
330 gaim_conversation_set_data(conv, "notify-imhtml-signals", imhtml_ids); | |
331 gaim_conversation_set_data(conv, "notify-entry-signals", entry_ids); | |
4035 | 332 |
3428 | 333 return 0; |
191 | 334 } |
335 | |
6977 | 336 static void |
337 detach_signals(GaimConversation *conv) | |
338 { | |
339 GaimGtkConversation *gtkconv = NULL; | |
340 GaimGtkWindow *gtkwin = NULL; | |
341 GSList *ids = NULL; | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
342 |
6977 | 343 gtkconv = GAIM_GTK_CONVERSATION(conv); |
344 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
345 |
6977 | 346 ids = gaim_conversation_get_data(conv, "notify-window-signals"); |
347 for (; ids != NULL; ids = ids->next) | |
348 g_signal_handler_disconnect(gtkwin->window, GPOINTER_TO_INT(ids->data)); | |
6302 | 349 |
6977 | 350 ids = gaim_conversation_get_data(conv, "notify-imhtml-signals"); |
351 for (; ids != NULL; ids = ids->next) | |
352 g_signal_handler_disconnect(gtkconv->imhtml, GPOINTER_TO_INT(ids->data)); | |
6302 | 353 |
6977 | 354 ids = gaim_conversation_get_data(conv, "notify-entry-signals"); |
355 for (; ids != NULL; ids = ids->next) | |
356 g_signal_handler_disconnect(gtkconv->entry, GPOINTER_TO_INT(ids->data)); | |
3710 | 357 |
9298 | 358 gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); |
3710 | 359 |
6977 | 360 gaim_conversation_set_data(conv, "notify-window-signals", NULL); |
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 { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
368 GaimConvWindow *gaimwin = NULL; |
6977 | 369 GaimGtkWindow *gtkwin = NULL; |
6302 | 370 |
6977 | 371 gaimwin = gaim_conversation_get_window(conv); |
6302 | 372 |
6977 | 373 if (gaimwin == NULL) |
6302 | 374 return; |
3374 | 375 |
6977 | 376 gtkwin = GAIM_GTK_WINDOW(gaimwin); |
377 | |
9298 | 378 gaim_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0)); |
6302 | 379 |
6977 | 380 /* always attach the signals, notify() will take care of conversation type |
381 * checking */ | |
382 attach_signals(conv); | |
3374 | 383 } |
384 | |
9303 | 385 #if 0 |
6977 | 386 static void |
387 conv_switched(GaimConversation *old_conv, GaimConversation *new_conv) | |
388 { | |
9298 | 389 GaimConvWindow *gaimwin = gaim_conversation_get_window(new_conv); |
6302 | 390 |
9298 | 391 printf("conv_switched - %p - %p\n", old_conv, new_conv); |
392 printf("count - %d\n", count_messages(gaimwin)); | |
393 if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_switch")) | |
394 unnotify(new_conv, FALSE); | |
395 else { | |
396 /* if we don't have notification on the window then we don't want to | |
397 * re-notify it */ | |
398 if (count_messages(gaimwin)) | |
399 notify_win(gaimwin); | |
400 } | |
6977 | 401 } |
9303 | 402 #endif |
6302 | 403 |
6977 | 404 static void |
405 deleting_conv(GaimConversation *conv) | |
406 { | |
9298 | 407 GaimConvWindow *gaimwin = NULL; |
408 | |
6977 | 409 detach_signals(conv); |
3392 | 410 |
9298 | 411 unnotify(conv, TRUE); |
6977 | 412 |
9298 | 413 gaimwin = gaim_conversation_get_window(conv); |
414 if (count_messages(gaimwin)) | |
415 notify_win(gaimwin); | |
6977 | 416 } |
417 | |
9303 | 418 #if 0 |
6977 | 419 static void |
9298 | 420 conversation_drag_ended(GaimConversation *active_conv, |
421 GaimConvWindow *old_gaimwin, | |
422 GaimConvWindow *new_gaimwin) | |
6977 | 423 { |
9298 | 424 if (old_gaimwin != new_gaimwin) { |
425 if (old_gaimwin == NULL) { | |
426 /* | |
427 gaim_conversation_autoset_title(active_conv); | |
428 handle_urgent(new_gaimwin, FALSE); | |
429 */ | |
430 | |
431 if (count_messages(new_gaimwin)) | |
432 notify_win(new_gaimwin); | |
433 } else { | |
434 printf("if else count = %d\n", count_messages(new_gaimwin)); | |
435 printf("if else count = %d\n", count_messages(old_gaimwin)); | |
436 /* | |
437 GaimConversation *old_active_conv = NULL; | |
438 old_active_conv = gaim_conv_window_get_active_conversation(new_gaimwin); | |
439 | |
440 gaim_conversation_autoset_title(old_active_conv); | |
441 handle_urgent(old_gaimwin, FALSE); | |
6302 | 442 |
9298 | 443 if (count_messages(old_gaimwin)) |
444 notify_win(old_gaimwin); | |
445 | |
446 gaim_conversation_autoset_title(active_conv); | |
447 handle_urgent(new_gaimwin, FALSE); | |
448 | |
449 if (count_messages(new_gaimwin)) | |
450 notify_win(new_gaimwin); | |
451 */ | |
452 } | |
453 } else { | |
454 printf("else count = %d\n", count_messages(new_gaimwin)); | |
455 printf("else count = %d\n", count_messages(old_gaimwin)); | |
456 /* | |
457 gaim_conversation_autoset_title(active_conv); | |
458 handle_urgent(old_gaimwin, FALSE); | |
459 | |
460 if (count_messages(old_gaimwin)) | |
461 notify_win(old_gaimwin); | |
462 */ | |
463 } | |
4035 | 464 } |
9303 | 465 #endif |
4035 | 466 |
6977 | 467 static void |
9298 | 468 handle_string(GaimConvWindow *gaimwin) |
469 { | |
470 GtkWindow *window = NULL; | |
471 gchar newtitle[256]; | |
472 | |
473 g_return_if_fail(gaimwin != NULL); | |
474 | |
475 window = GTK_WINDOW(GAIM_GTK_WINDOW(gaimwin)->window); | |
476 g_return_if_fail(window != NULL); | |
477 | |
478 g_snprintf(newtitle, sizeof(newtitle), "%s%s", | |
479 gaim_prefs_get_string("/plugins/gtk/X11/notify/title_string"), | |
480 gtk_window_get_title(window)); | |
481 gtk_window_set_title(window, newtitle); | |
482 } | |
483 | |
484 static void | |
485 handle_count(GaimConvWindow *gaimwin) | |
486 { | |
487 GtkWindow *window; | |
488 char newtitle[256]; | |
489 | |
490 g_return_if_fail(gaimwin != NULL); | |
491 | |
492 window = GTK_WINDOW(GAIM_GTK_WINDOW(gaimwin)->window); | |
493 g_return_if_fail(window != NULL); | |
494 | |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
495 g_snprintf(newtitle, sizeof(newtitle), "[%d] %s", |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
496 count_messages(gaimwin), gtk_window_get_title(window)); |
9298 | 497 gtk_window_set_title(window, newtitle); |
498 } | |
499 | |
500 static void | |
501 handle_urgent(GaimConvWindow *gaimwin, gboolean add) | |
6977 | 502 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
503 XWMHints *hints; |
9298 | 504 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(gaimwin); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
505 |
9298 | 506 g_return_if_fail(gtkwin != NULL); |
507 g_return_if_fail(gtkwin->window != NULL); | |
508 g_return_if_fail(gtkwin->window->window != NULL); | |
509 | |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
510 hints = XGetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
511 GDK_WINDOW_XWINDOW(gtkwin->window->window)); |
6977 | 512 if (add) |
513 hints->flags |= XUrgencyHint; | |
514 else | |
515 hints->flags &= ~XUrgencyHint; | |
9298 | 516 XSetWMHints(GDK_WINDOW_XDISPLAY(gtkwin->window->window), |
517 GDK_WINDOW_XWINDOW(gtkwin->window->window), hints); | |
4218 | 518 XFree(hints); |
4035 | 519 } |
520 | |
6977 | 521 static void |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
522 handle_raise(GaimConvWindow *gaimwin) |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
523 { |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
524 gaim_conv_window_raise(gaimwin); |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
525 } |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
526 |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
527 static void |
6977 | 528 type_toggle_cb(GtkWidget *widget, gpointer data) |
529 { | |
530 gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
531 gchar pref[256]; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
532 |
6977 | 533 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
|
534 |
6977 | 535 gaim_prefs_set_bool(pref, on); |
3374 | 536 } |
537 | |
6977 | 538 static void |
539 method_toggle_cb(GtkWidget *widget, gpointer data) | |
540 { | |
541 gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
542 gchar pref[256]; | |
543 | |
544 g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", (char *)data); | |
3374 | 545 |
6977 | 546 gaim_prefs_set_bool(pref, on); |
547 | |
548 if (!strcmp(data, "method_string")) { | |
549 GtkWidget *entry = g_object_get_data(G_OBJECT(widget), "title-entry"); | |
550 gtk_widget_set_sensitive(entry, on); | |
551 | |
552 gaim_prefs_set_string("/plugins/gtk/X11/notify/title_string", gtk_entry_get_text(GTK_ENTRY(entry))); | |
553 } | |
554 | |
555 apply_method(); | |
3374 | 556 } |
557 | |
6977 | 558 static void |
559 notify_toggle_cb(GtkWidget *widget, gpointer data) | |
560 { | |
561 gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
562 gchar pref[256]; | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
563 |
6977 | 564 g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", (char *)data); |
3374 | 565 |
6977 | 566 gaim_prefs_set_bool(pref, on); |
567 | |
568 apply_notify(); | |
3374 | 569 } |
570 | |
6977 | 571 static gboolean |
572 options_entry_cb(GtkWidget *widget, GdkEventFocus *evt, gpointer data) | |
573 { | |
574 if (data == NULL) | |
6982 | 575 return FALSE; |
6302 | 576 |
6977 | 577 if (!strcmp(data, "method_string")) { |
578 gaim_prefs_set_string("/plugins/gtk/X11/notify/title_string", gtk_entry_get_text(GTK_ENTRY(widget))); | |
3374 | 579 } |
6302 | 580 |
6977 | 581 apply_method(); |
6302 | 582 |
583 return FALSE; | |
584 } | |
585 | |
6977 | 586 static void |
587 apply_method() { | |
588 GList *convs = gaim_get_conversations(); | |
9298 | 589 GaimConvWindow *gaimwin = NULL; |
6977 | 590 |
9298 | 591 for (convs = gaim_get_conversations(); convs != NULL; convs = convs->next) { |
6977 | 592 GaimConversation *conv = (GaimConversation *)convs->data; |
6302 | 593 |
6977 | 594 /* remove notifications */ |
9298 | 595 unnotify(conv, FALSE); |
596 | |
597 gaimwin = gaim_conversation_get_window(conv); | |
598 if (GPOINTER_TO_INT(gaim_conversation_get_data(conv, "notify-message-count")) != 0) | |
6977 | 599 /* reattach appropriate notifications */ |
600 notify(conv, FALSE); | |
601 } | |
3374 | 602 } |
603 | |
6977 | 604 static void |
605 apply_notify() | |
606 { | |
607 GList *convs = gaim_get_conversations(); | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
608 |
6977 | 609 while (convs) { |
610 GaimConversation *conv = (GaimConversation *)convs->data; | |
4203
ec6d0c5e5c23
[gaim-migrate @ 4439]
Christian Hammond <chipx86@chipx86.com>
parents:
4202
diff
changeset
|
611 |
6977 | 612 /* detach signals */ |
613 detach_signals(conv); | |
614 /* reattach appropriate signals */ | |
615 attach_signals(conv); | |
4035 | 616 |
6977 | 617 convs = convs->next; |
4035 | 618 } |
619 } | |
620 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
621 static GtkWidget * |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
622 get_config_frame(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
623 { |
6977 | 624 GtkWidget *ret = NULL, *frame = NULL; |
625 GtkWidget *vbox = NULL, *hbox = NULL; | |
626 GtkWidget *toggle = NULL, *entry = NULL; | |
6302 | 627 |
3565 | 628 ret = gtk_vbox_new(FALSE, 18); |
6302 | 629 gtk_container_set_border_width(GTK_CONTAINER (ret), 12); |
3392 | 630 |
6302 | 631 /*---------- "Notify For" ----------*/ |
632 frame = gaim_gtk_make_frame(ret, _("Notify For")); | |
633 vbox = gtk_vbox_new(FALSE, 5); | |
634 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
635 | |
3710 | 636 toggle = gtk_check_button_new_with_mnemonic(_("_IM windows")); |
637 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
6977 | 638 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
9298 | 639 gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_im")); |
6977 | 640 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 641 G_CALLBACK(type_toggle_cb), "type_im"); |
3710 | 642 |
6977 | 643 toggle = gtk_check_button_new_with_mnemonic(_("C_hat windows")); |
3710 | 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_chat")); |
6977 | 647 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 648 G_CALLBACK(type_toggle_cb), "type_chat"); |
6977 | 649 |
650 toggle = gtk_check_button_new_with_mnemonic(_("_Focused windows")); | |
651 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
652 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 653 gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_focused")); |
6977 | 654 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 655 G_CALLBACK(type_toggle_cb), "type_focused"); |
3710 | 656 |
6302 | 657 /*---------- "Notification Methods" ----------*/ |
658 frame = gaim_gtk_make_frame(ret, _("Notification Methods")); | |
659 vbox = gtk_vbox_new(FALSE, 5); | |
660 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
661 | |
6977 | 662 /* String method button */ |
3565 | 663 hbox = gtk_hbox_new(FALSE, 18); |
664 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
6302 | 665 toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:")); |
6977 | 666 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
9298 | 667 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_string")); |
3565 | 668 gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); |
6977 | 669 |
6302 | 670 entry = gtk_entry_new(); |
671 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
672 gtk_entry_set_max_length(GTK_ENTRY(entry), 10); | |
6977 | 673 gtk_widget_set_sensitive(GTK_WIDGET(entry), |
9298 | 674 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_string")); |
6977 | 675 gtk_entry_set_text(GTK_ENTRY(entry), |
9298 | 676 gaim_prefs_get_string("/plugins/gtk/X11/notify/title_string")); |
6977 | 677 g_object_set_data(G_OBJECT(toggle), "title-entry", entry); |
678 g_signal_connect(G_OBJECT(toggle), "toggled", | |
9298 | 679 G_CALLBACK(method_toggle_cb), "method_string"); |
6977 | 680 g_signal_connect(G_OBJECT(entry), "focus-out-event", |
9298 | 681 G_CALLBACK(options_entry_cb), "method_string"); |
3374 | 682 |
6977 | 683 /* Count method button */ |
684 toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title")); | |
685 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 686 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_count")); |
6977 | 687 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
688 g_signal_connect(G_OBJECT(toggle), "toggled", | |
9298 | 689 G_CALLBACK(method_toggle_cb), "method_count"); |
4035 | 690 |
6977 | 691 /* Urgent method button */ |
692 toggle = gtk_check_button_new_with_mnemonic(_("Set window manager \"_URGENT\" hint")); | |
693 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
694 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 695 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent")); |
696 g_signal_connect(G_OBJECT(toggle), "toggled", | |
697 G_CALLBACK(method_toggle_cb), "method_urgent"); | |
3710 | 698 |
10606
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
699 /* Raise window method button */ |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
700 toggle = gtk_check_button_new_with_mnemonic(_("R_aise conversation window")); |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
701 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
702 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
703 gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_raise")); |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
704 g_signal_connect(G_OBJECT(toggle), "toggled", |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
705 G_CALLBACK(method_toggle_cb), "method_raise"); |
1a65fc2d7978
[gaim-migrate @ 12039]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10492
diff
changeset
|
706 |
6977 | 707 /*---------- "Notification Removals" ----------*/ |
6302 | 708 frame = gaim_gtk_make_frame(ret, _("Notification Removal")); |
709 vbox = gtk_vbox_new(FALSE, 5); | |
710 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
3374 | 711 |
6977 | 712 /* Remove on focus button */ |
713 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _gains focus")); | |
714 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
715 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 716 gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_focus")); |
6977 | 717 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(notify_toggle_cb), "notify_focus"); |
718 | |
719 /* Remove on click button */ | |
720 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click")); | |
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_click")); |
6977 | 724 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 725 G_CALLBACK(notify_toggle_cb), "notify_click"); |
3710 | 726 |
6977 | 727 /* Remove on type button */ |
728 toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); | |
729 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
730 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 731 gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_type")); |
6977 | 732 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 733 G_CALLBACK(notify_toggle_cb), "notify_type"); |
4035 | 734 |
6977 | 735 /* Remove on message send button */ |
736 toggle = gtk_check_button_new_with_mnemonic(_("Remove when a _message gets sent")); | |
737 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
738 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 739 gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")); |
6977 | 740 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 741 G_CALLBACK(notify_toggle_cb), "notify_send"); |
3565 | 742 |
6977 | 743 #if 0 |
744 /* Remove on conversation switch button */ | |
9298 | 745 toggle = gtk_check_button_new_with_mnemonic(_("Remove on switch to conversation ta_b")); |
6977 | 746 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
747 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
9298 | 748 gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_switch")); |
6977 | 749 g_signal_connect(G_OBJECT(toggle), "toggled", |
9298 | 750 G_CALLBACK(notify_toggle_cb), "notify_switch"); |
6977 | 751 #endif |
752 | |
753 gtk_widget_show_all(ret); | |
754 return ret; | |
3374 | 755 } |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
756 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
757 static gboolean |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
758 plugin_load(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
759 { |
6977 | 760 GList *convs = gaim_get_conversations(); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
761 void *conv_handle = gaim_conversations_get_handle(); |
9298 | 762 /* |
763 void *gtk_conv_handle = gaim_gtk_conversations_get_handle(); | |
764 */ | |
6302 | 765 |
766 my_plugin = plugin; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
767 |
6977 | 768 gaim_signal_connect(conv_handle, "received-im-msg", plugin, |
9298 | 769 GAIM_CALLBACK(im_recv_im), NULL); |
6977 | 770 gaim_signal_connect(conv_handle, "received-chat-msg", plugin, |
9298 | 771 GAIM_CALLBACK(chat_recv_im), NULL); |
6977 | 772 gaim_signal_connect(conv_handle, "sent-im-msg", plugin, |
9298 | 773 GAIM_CALLBACK(im_sent_im), NULL); |
6977 | 774 gaim_signal_connect(conv_handle, "sent-chat-msg", plugin, |
9298 | 775 GAIM_CALLBACK(chat_sent_im), NULL); |
6977 | 776 gaim_signal_connect(conv_handle, "conversation-created", plugin, |
9298 | 777 GAIM_CALLBACK(conv_created), NULL); |
6977 | 778 gaim_signal_connect(conv_handle, "chat-joined", plugin, |
9298 | 779 GAIM_CALLBACK(conv_created), NULL); |
6977 | 780 gaim_signal_connect(conv_handle, "deleting-conversation", plugin, |
9298 | 781 GAIM_CALLBACK(deleting_conv), NULL); |
9303 | 782 #if 0 |
6977 | 783 gaim_signal_connect(conv_handle, "conversation-switched", plugin, |
9298 | 784 GAIM_CALLBACK(conv_switched), NULL); |
785 gaim_signal_connect(gtk_conv_handle, "conversation-drag-ended", plugin, | |
786 GAIM_CALLBACK(conversation_drag_ended), NULL); | |
9303 | 787 #endif |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
788 |
6977 | 789 while (convs) { |
790 GaimConversation *conv = (GaimConversation *)convs->data; | |
6302 | 791 |
792 /* attach signals */ | |
6977 | 793 attach_signals(conv); |
6302 | 794 |
6977 | 795 convs = convs->next; |
6302 | 796 } |
797 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
798 return TRUE; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
799 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
800 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
801 static gboolean |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
802 plugin_unload(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
803 { |
6977 | 804 GList *convs = gaim_get_conversations(); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
805 |
6977 | 806 while (convs) { |
807 GaimConversation *conv = (GaimConversation *)convs->data; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
808 |
6302 | 809 /* kill signals */ |
6977 | 810 detach_signals(conv); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
811 |
6977 | 812 convs = convs->next; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
813 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
814 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
815 return TRUE; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
816 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
817 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
818 static GaimGtkPluginUiInfo ui_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
819 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
820 get_config_frame |
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 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
823 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
824 { |
9943 | 825 GAIM_PLUGIN_MAGIC, |
826 GAIM_MAJOR_VERSION, | |
827 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
828 GAIM_PLUGIN_STANDARD, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
829 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
830 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
831 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
832 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
833 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
834 NOTIFY_PLUGIN_ID, /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
835 N_("Message Notification"), /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
836 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
837 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
838 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
|
839 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
840 N_("Provides a variety of ways of notifying you of unread messages."), |
9298 | 841 "Etan Reisner <deryni@eden.rutgers.edu>\n\t\t\tBrian Tarricone <bjt23@cornell.edu>", |
6302 | 842 /**< author */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
843 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
844 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
845 plugin_load, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
846 plugin_unload, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
847 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
848 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
849 &ui_info, /**< ui_info */ |
8993 | 850 NULL, /**< extra_info */ |
851 NULL, | |
852 NULL | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
853 }; |
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 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
856 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
857 { |
6302 | 858 gaim_prefs_add_none("/plugins/gtk"); |
859 gaim_prefs_add_none("/plugins/gtk/X11"); | |
860 gaim_prefs_add_none("/plugins/gtk/X11/notify"); | |
861 | |
6464 | 862 gaim_prefs_add_bool("/plugins/gtk/X11/notify/type_im", TRUE); |
863 gaim_prefs_add_bool("/plugins/gtk/X11/notify/type_chat", FALSE); | |
864 gaim_prefs_add_bool("/plugins/gtk/X11/notify/type_focused", FALSE); | |
6302 | 865 gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_string", FALSE); |
866 gaim_prefs_add_string("/plugins/gtk/X11/notify/title_string", "(*)"); | |
867 gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_urgent", FALSE); | |
868 gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_count", FALSE); | |
10492 | 869 gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_raise", FALSE); |
6302 | 870 gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_focus", FALSE); |
871 gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_click", FALSE); | |
872 gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_type", TRUE); | |
6464 | 873 gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_send", TRUE); |
874 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
|
875 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
876 |
6063 | 877 GAIM_INIT_PLUGIN(notify, init_plugin, info) |