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