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