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