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