Mon, 21 Aug 2006 07:44:31 +0000
[gaim-migrate @ 16948]
* Initial commit of the Contact Availability Prediction plugin
* Located in trunk/gtk/plugins/cap
* Check README for further information and requirements for build
| 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
35fdae8a156f
[gaim-migrate @ 6821]
Mark Doliner <markdoliner@pidgin.im>
parents:
6302
diff
changeset
|
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 | 27 | /* TODO |
| 28 | * 22:22:17 <seanegan> deryni: speaking of notify.c... you know what else | |
| 29 | * might be a neat feature? | |
| 30 | * 22:22:30 <seanegan> Changing the window icon. | |
| 31 | * 22:23:25 <deryni> seanegan: To what? | |
| 32 | * 22:23:42 <seanegan> deryni: I dunno. Flash it between the regular icon and | |
| 33 | * blank or something. | |
| 34 | * 22:23:53 <deryni> Also I think gaim might re-set that sort of frequently, | |
| 35 | * but I'd have to look. | |
| 11581 | 36 | * 22:25:16 <seanegan> deryni: I keep my conversations in one workspace and am |
| 10606 | 37 | * frequently in an another, and the icon flashing in the pager would be a |
| 38 | * neat visual clue. | |
| 39 | */ | |
| 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
3c7ba18e32f1
[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
3c7ba18e32f1
[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
893fbf89317c
[gaim-migrate @ 14939]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
90 | #include "conversation.h" |
| 6302 | 91 | #include "prefs.h" |
|
6485
3c7ba18e32f1
[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
8b92de3b1c07
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
diff
changeset
|
95 | |
| 6302 | 96 | #include "gtkplugin.h" |
| 97 | #include "gtkutils.h" | |
| 98 | ||
| 12959 | 99 | #ifndef _WIN32 |
| 6977 | 100 | #include <X11/Xatom.h> |
| 3385 | 101 | #include <X11/Xlib.h> |
| 3374 | 102 | #include <X11/Xutil.h> |
| 12959 | 103 | #endif |
| 3374 | 104 | |
| 6302 | 105 | #define NOTIFY_PLUGIN_ID "gtk-x11-notify" |
| 3710 | 106 | |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
107 | static GaimPlugin *my_plugin = NULL; |
|
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
108 | |
| 6302 | 109 | /* notification set/unset */ |
| 14326 | 110 | static int notify(GaimConversation *conv); |
| 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
aa64ec827fdf
[gaim-migrate @ 14704]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
120 | static void apply_method(void); |
|
aa64ec827fdf
[gaim-migrate @ 14704]
Richard Laager <rlaager@pidgin.im>
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 | 131 | |
| 132 | /* raise function */ | |
| 11581 | 133 | static void handle_raise(GaimGtkWindow *gaimwin); |
| 3710 | 134 | |
| 6302 | 135 | /****************************************/ |
| 136 | /* Begin doing stuff below this line... */ | |
| 137 | /****************************************/ | |
| 14326 | 138 | static guint |
| 11581 | 139 | count_messages(GaimGtkWindow *gaimwin) |
| 9298 | 140 | { |
| 14326 | 141 | guint count = 0; |
| 142 | GList *gtkconvs = NULL; | |
| 9298 | 143 | |
| 14326 | 144 | for (gtkconvs = gaimwin->gtkconvs; gtkconvs != NULL; |
| 145 | gtkconvs = gtkconvs->next) { | |
| 146 | GaimGtkConversation *gtkconv = gtkconvs->data; | |
| 147 | count += gtkconv->unseen_count; | |
| 9298 | 148 | } |
| 149 | ||
| 150 | return count; | |
| 151 | } | |
| 6302 | 152 | |
| 6977 | 153 | static int |
| 14326 | 154 | notify(GaimConversation *conv) |
| 6977 | 155 | { |
| 14326 | 156 | gboolean has_focus; |
| 11581 | 157 | GaimGtkWindow *gaimwin = NULL; |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
158 | |
| 6977 | 159 | if (conv == NULL) |
| 6302 | 160 | return 0; |
| 161 | ||
| 6977 | 162 | /* We want to remove the notifications, but not reset the counter */ |
| 163 | unnotify(conv, FALSE); | |
| 164 | ||
| 11581 | 165 | gaimwin = GAIM_GTK_CONVERSATION(conv)->win; |
| 5021 | 166 | |
| 6977 | 167 | /* If we aren't doing notifications for this type of conversation, return */ |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
10984
diff
changeset
|
168 | if (((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
| 9298 | 169 | !gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_im")) || |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
10984
diff
changeset
|
170 | ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
| 9298 | 171 | !gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_chat"))) |
| 6977 | 172 | return 0; |
| 4203 | 173 | |
| 11581 | 174 | g_object_get(G_OBJECT(gaimwin->window), |
| 9298 | 175 | "has-toplevel-focus", &has_focus, NULL); |
| 3374 | 176 | |
| 6977 | 177 | if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_focused") || |
|
10984
8d8c654bf34d
[gaim-migrate @ 12819]
Mark Doliner <markdoliner@pidgin.im>
parents:
10971
diff
changeset
|
178 | !has_focus) { |
| 9298 | 179 | notify_win(gaimwin); |
| 6977 | 180 | } |
| 6302 | 181 | |
| 182 | return 0; | |
| 183 | } | |
| 184 | ||
| 9298 | 185 | static void |
| 11581 | 186 | notify_win(GaimGtkWindow *gaimwin) |
| 9298 | 187 | { |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
188 | if (count_messages(gaimwin) <= 0) |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
189 | return; |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
190 | |
| 9298 | 191 | if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_count")) |
| 192 | handle_count(gaimwin); | |
| 193 | if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_string")) | |
| 194 | handle_string(gaimwin); | |
| 195 | if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent")) | |
| 196 | handle_urgent(gaimwin, TRUE); | |
| 10492 | 197 | if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_raise")) |
| 198 | handle_raise(gaimwin); | |
| 9298 | 199 | } |
| 200 | ||
| 201 | static void | |
| 202 | unnotify(GaimConversation *conv, gboolean reset) | |
| 203 | { | |
| 204 | GaimConversation *active_conv = NULL; | |
| 11581 | 205 | GaimGtkWindow *gaimwin = NULL; |
| 9298 | 206 | |
| 207 | g_return_if_fail(conv != NULL); | |
| 208 | ||
| 11581 | 209 | gaimwin = GAIM_GTK_CONVERSATION(conv)->win; |
| 210 | active_conv = gaim_gtk_conv_window_get_active_conversation(gaimwin); | |
| 9298 | 211 | |
| 212 | /* reset the conversation window title */ | |
| 213 | gaim_conversation_autoset_title(active_conv); | |
| 214 | ||
| 215 | if (reset) { | |
| 216 | /* Only need to actually remove the urgent hinting here, since removing it | |
| 217 | * just to have it readded in re-notify is an unnecessary couple extra RTs | |
| 218 | * to the server */ | |
| 219 | handle_urgent(gaimwin, FALSE); | |
| 220 | } | |
| 221 | ||
| 222 | return; | |
| 223 | } | |
| 224 | ||
| 225 | static int | |
| 226 | unnotify_cb(GtkWidget *widget, gpointer data, GaimConversation *conv) | |
| 227 | { | |
| 14326 | 228 | GaimGtkConversation *gtkconv = NULL; |
| 229 | ||
| 230 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 231 | ||
| 232 | if (gtkconv->unseen_count > 0) | |
| 9298 | 233 | unnotify(conv, TRUE); |
| 234 | ||
| 235 | return 0; | |
| 236 | } | |
| 237 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
238 | static gboolean |
|
13234
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12968
diff
changeset
|
239 | message_displayed_cb(GaimAccount *account, const char *who, char *message, |
|
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12968
diff
changeset
|
240 | GaimConversation *conv, GaimMessageFlags flags) |
| 6977 | 241 | { |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
242 | if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
243 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_chat_nick") && |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
244 | !(flags & GAIM_MESSAGE_NICK))) |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
245 | return FALSE; |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
246 | |
|
12604
893fbf89317c
[gaim-migrate @ 14939]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
247 | if ((flags & GAIM_MESSAGE_RECV) && !(flags & GAIM_MESSAGE_DELAYED)) |
| 14326 | 248 | notify(conv); |
| 9298 | 249 | |
| 250 | return FALSE; | |
| 251 | } | |
| 252 | ||
| 6977 | 253 | static void |
| 12968 | 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
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
10984
diff
changeset
|
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 | 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
cf899ee07d1d
[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 | 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 | 302 | imhtml_ids = g_slist_append(imhtml_ids, GUINT_TO_POINTER(id)); |
| 6977 | 303 | } |
|
4359
cf899ee07d1d
[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 | 311 | |
| 312 | id = g_signal_connect(G_OBJECT(gtkconv->imhtml), "button-press-event", | |
| 313 | G_CALLBACK(unnotify_cb), conv); | |
| 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
3c7ba18e32f1
[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 | 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 | |
| 6977 | 351 | gaim_conversation_set_data(conv, "notify-imhtml-signals", NULL); |
| 352 | gaim_conversation_set_data(conv, "notify-entry-signals", NULL); | |
| 3710 | 353 | } |
| 354 | ||
| 6977 | 355 | static void |
| 356 | conv_created(GaimConversation *conv) | |
| 357 | { | |
| 358 | /* always attach the signals, notify() will take care of conversation type | |
| 359 | * checking */ | |
| 360 | attach_signals(conv); | |
| 3374 | 361 | } |
| 362 | ||
| 6977 | 363 | static void |
| 12968 | 364 | conv_switched(GaimConversation *conv) |
| 6977 | 365 | { |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
366 | #if 0 |
| 11581 | 367 | GaimGtkWindow *gaimwin = gaim_conversation_get_window(new_conv); |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
368 | #endif |
| 6302 | 369 | |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
370 | /* |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
371 | * If the conversation was switched, then make sure we re-notify |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
372 | * because Gaim will have overwritten our custom window title. |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
373 | */ |
| 14326 | 374 | notify(conv); |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
375 | |
|
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
376 | #if 0 |
| 9298 | 377 | printf("conv_switched - %p - %p\n", old_conv, new_conv); |
| 378 | printf("count - %d\n", count_messages(gaimwin)); | |
| 379 | if (gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_switch")) | |
| 380 | unnotify(new_conv, FALSE); | |
| 381 | else { | |
| 382 | /* if we don't have notification on the window then we don't want to | |
| 383 | * re-notify it */ | |
| 384 | if (count_messages(gaimwin)) | |
| 385 | notify_win(gaimwin); | |
| 386 | } | |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
387 | #endif |
| 6977 | 388 | } |
| 6302 | 389 | |
| 6977 | 390 | static void |
| 391 | deleting_conv(GaimConversation *conv) | |
| 392 | { | |
| 11581 | 393 | GaimGtkWindow *gaimwin = NULL; |
| 9298 | 394 | |
| 6977 | 395 | detach_signals(conv); |
| 3392 | 396 | |
| 11606 | 397 | gaimwin = GAIM_GTK_CONVERSATION(conv)->win; |
| 398 | ||
| 399 | handle_urgent(gaimwin, FALSE); | |
| 400 | ||
| 401 | return; | |
| 402 | ||
| 11581 | 403 | #if 0 |
| 404 | /* i think this line crashes */ | |
| 9298 | 405 | if (count_messages(gaimwin)) |
| 406 | notify_win(gaimwin); | |
| 11581 | 407 | #endif |
| 6977 | 408 | } |
| 409 | ||
|
9303
e257ad08c77c
[gaim-migrate @ 10107]
Mark Doliner <markdoliner@pidgin.im>
parents:
9298
diff
changeset
|
410 | #if 0 |
| 6977 | 411 | static void |
|
11447
23594a754163
[gaim-migrate @ 13686]
Daniel Atallah <datallah@pidgin.im>
parents:
11338
diff
changeset
|
412 | conversation_dragging(GaimConversation *active_conv, |
| 11581 | 413 | GaimGtkWindow *old_gaimwin, |
| 414 | GaimGtkWindow *new_gaimwin) | |
| 6977 | 415 | { |
| 9298 | 416 | if (old_gaimwin != new_gaimwin) { |
| 417 | if (old_gaimwin == NULL) { | |
| 418 | /* | |
| 419 | gaim_conversation_autoset_title(active_conv); | |
| 420 | handle_urgent(new_gaimwin, FALSE); | |
| 421 | */ | |
| 422 | ||
| 423 | if (count_messages(new_gaimwin)) | |
| 424 | notify_win(new_gaimwin); | |
| 425 | } else { | |
| 426 | printf("if else count = %d\n", count_messages(new_gaimwin)); | |
| 427 | printf("if else count = %d\n", count_messages(old_gaimwin)); | |
| 428 | /* | |
| 429 | GaimConversation *old_active_conv = NULL; | |
| 430 | old_active_conv = gaim_conv_window_get_active_conversation(new_gaimwin); | |
| 431 | ||
| 432 | gaim_conversation_autoset_title(old_active_conv); | |
| 433 | handle_urgent(old_gaimwin, FALSE); | |
| 6302 | 434 | |
| 9298 | 435 | if (count_messages(old_gaimwin)) |
| 436 | notify_win(old_gaimwin); | |
| 437 | ||
| 438 | gaim_conversation_autoset_title(active_conv); | |
| 439 | handle_urgent(new_gaimwin, FALSE); | |
| 440 | ||
| 441 | if (count_messages(new_gaimwin)) | |
| 442 | notify_win(new_gaimwin); | |
| 443 | */ | |
| 444 | } | |
| 445 | } else { | |
| 446 | printf("else count = %d\n", count_messages(new_gaimwin)); | |
| 447 | printf("else count = %d\n", count_messages(old_gaimwin)); | |
| 448 | /* | |
| 449 | gaim_conversation_autoset_title(active_conv); | |
| 450 | handle_urgent(old_gaimwin, FALSE); | |
| 451 | ||
| 452 | if (count_messages(old_gaimwin)) | |
| 453 | notify_win(old_gaimwin); | |
| 454 | */ | |
| 455 | } | |
| 4035 | 456 | } |
|
9303
e257ad08c77c
[gaim-migrate @ 10107]
Mark Doliner <markdoliner@pidgin.im>
parents:
9298
diff
changeset
|
457 | #endif |
| 4035 | 458 | |
| 6977 | 459 | static void |
| 11581 | 460 | handle_string(GaimGtkWindow *gaimwin) |
| 9298 | 461 | { |
| 462 | GtkWindow *window = NULL; | |
| 463 | gchar newtitle[256]; | |
| 464 | ||
| 465 | g_return_if_fail(gaimwin != NULL); | |
| 466 | ||
| 11581 | 467 | window = GTK_WINDOW(gaimwin->window); |
| 9298 | 468 | g_return_if_fail(window != NULL); |
| 469 | ||
| 470 | g_snprintf(newtitle, sizeof(newtitle), "%s%s", | |
| 471 | gaim_prefs_get_string("/plugins/gtk/X11/notify/title_string"), | |
| 472 | gtk_window_get_title(window)); | |
| 473 | gtk_window_set_title(window, newtitle); | |
| 474 | } | |
| 475 | ||
| 476 | static void | |
| 11581 | 477 | handle_count(GaimGtkWindow *gaimwin) |
| 9298 | 478 | { |
| 479 | GtkWindow *window; | |
| 480 | char newtitle[256]; | |
| 481 | ||
| 482 | g_return_if_fail(gaimwin != NULL); | |
| 483 | ||
| 11581 | 484 | window = GTK_WINDOW(gaimwin->window); |
| 9298 | 485 | g_return_if_fail(window != NULL); |
| 486 | ||
| 10606 | 487 | g_snprintf(newtitle, sizeof(newtitle), "[%d] %s", |
| 488 | count_messages(gaimwin), gtk_window_get_title(window)); | |
| 9298 | 489 | gtk_window_set_title(window, newtitle); |
| 490 | } | |
| 491 | ||
| 492 | static void | |
| 11581 | 493 | handle_urgent(GaimGtkWindow *win, gboolean add) |
| 6977 | 494 | { |
| 12959 | 495 | #ifndef _WIN32 |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
496 | XWMHints *hints; |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
497 | |
| 11581 | 498 | g_return_if_fail(win != NULL); |
| 499 | g_return_if_fail(win->window != NULL); | |
| 500 | g_return_if_fail(win->window->window != NULL); | |
| 9298 | 501 | |
| 11581 | 502 | hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win->window->window), |
| 503 | GDK_WINDOW_XWINDOW(win->window->window)); | |
|
12184
168ebf98a1c8
[gaim-migrate @ 14486]
Casey Harkins <charkins@pidgin.im>
parents:
11728
diff
changeset
|
504 | if(!hints) |
|
168ebf98a1c8
[gaim-migrate @ 14486]
Casey Harkins <charkins@pidgin.im>
parents:
11728
diff
changeset
|
505 | hints = XAllocWMHints(); |
| 12286 | 506 | |
| 6977 | 507 | if (add) |
| 508 | hints->flags |= XUrgencyHint; | |
| 509 | else | |
| 510 | hints->flags &= ~XUrgencyHint; | |
| 11581 | 511 | XSetWMHints(GDK_WINDOW_XDISPLAY(win->window->window), |
| 512 | GDK_WINDOW_XWINDOW(win->window->window), hints); | |
| 4218 | 513 | XFree(hints); |
| 12959 | 514 | #endif |
| 4035 | 515 | } |
| 516 | ||
| 6977 | 517 | static void |
| 11581 | 518 | handle_raise(GaimGtkWindow *gaimwin) |
| 10606 | 519 | { |
| 11581 | 520 | gaim_gtk_conv_window_raise(gaimwin); |
| 10606 | 521 | } |
| 522 | ||
| 523 | static void | |
| 6977 | 524 | type_toggle_cb(GtkWidget *widget, gpointer data) |
| 525 | { | |
| 526 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 527 | gchar pref[256]; | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
528 | |
| 6977 | 529 | g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", (char *)data); |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4218
diff
changeset
|
530 | |
| 6977 | 531 | gaim_prefs_set_bool(pref, on); |
| 3374 | 532 | } |
| 533 | ||
| 6977 | 534 | static void |
| 535 | method_toggle_cb(GtkWidget *widget, gpointer data) | |
| 536 | { | |
| 537 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 538 | gchar pref[256]; | |
| 539 | ||
| 540 | g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", (char *)data); | |
| 3374 | 541 | |
| 6977 | 542 | gaim_prefs_set_bool(pref, on); |
| 543 | ||
| 544 | if (!strcmp(data, "method_string")) { | |
| 545 | GtkWidget *entry = g_object_get_data(G_OBJECT(widget), "title-entry"); | |
| 546 | gtk_widget_set_sensitive(entry, on); | |
| 547 | ||
| 548 | gaim_prefs_set_string("/plugins/gtk/X11/notify/title_string", gtk_entry_get_text(GTK_ENTRY(entry))); | |
| 549 | } | |
| 550 | ||
| 551 | apply_method(); | |
| 3374 | 552 | } |
| 553 | ||
| 6977 | 554 | static void |
| 555 | notify_toggle_cb(GtkWidget *widget, gpointer data) | |
| 556 | { | |
| 557 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 558 | gchar pref[256]; | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
559 | |
| 6977 | 560 | g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s", (char *)data); |
| 3374 | 561 | |
| 6977 | 562 | gaim_prefs_set_bool(pref, on); |
| 563 | ||
| 564 | apply_notify(); | |
| 3374 | 565 | } |
| 566 | ||
| 6977 | 567 | static gboolean |
| 568 | options_entry_cb(GtkWidget *widget, GdkEventFocus *evt, gpointer data) | |
| 569 | { | |
| 570 | if (data == NULL) | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6977
diff
changeset
|
571 | return FALSE; |
| 6302 | 572 | |
| 6977 | 573 | if (!strcmp(data, "method_string")) { |
| 574 | gaim_prefs_set_string("/plugins/gtk/X11/notify/title_string", gtk_entry_get_text(GTK_ENTRY(widget))); | |
| 3374 | 575 | } |
| 6302 | 576 | |
| 6977 | 577 | apply_method(); |
| 6302 | 578 | |
| 579 | return FALSE; | |
| 580 | } | |
| 581 | ||
| 6977 | 582 | static void |
| 583 | apply_method() { | |
|
13664
fdc3b588f248
[gaim-migrate @ 16065]
Richard Laager <rlaager@pidgin.im>
parents:
13550
diff
changeset
|
584 | GList *convs; |
| 6977 | 585 | |
| 9298 | 586 | for (convs = gaim_get_conversations(); convs != NULL; convs = convs->next) { |
| 14326 | 587 | GaimConversation *conv = NULL; |
| 588 | GaimGtkConversation *gtkconv = NULL; | |
| 589 | ||
| 590 | conv = (GaimConversation *) convs->data; | |
| 591 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 6302 | 592 | |
| 6977 | 593 | /* remove notifications */ |
| 9298 | 594 | unnotify(conv, FALSE); |
| 595 | ||
| 14326 | 596 | if (gtkconv->unseen_count > 0) { |
| 6977 | 597 | /* reattach appropriate notifications */ |
| 14326 | 598 | notify(conv); |
| 599 | } | |
| 6977 | 600 | } |
| 3374 | 601 | } |
| 602 | ||
| 6977 | 603 | static void |
| 604 | apply_notify() | |
| 605 | { | |
| 606 | GList *convs = gaim_get_conversations(); | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
607 | |
| 6977 | 608 | while (convs) { |
| 609 | GaimConversation *conv = (GaimConversation *)convs->data; | |
| 4203 | 610 | |
| 6977 | 611 | /* detach signals */ |
| 612 | detach_signals(conv); | |
| 613 | /* reattach appropriate signals */ | |
| 614 | attach_signals(conv); | |
| 4035 | 615 | |
| 6977 | 616 | convs = convs->next; |
| 4035 | 617 | } |
| 618 | } | |
| 619 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
620 | static GtkWidget * |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
621 | get_config_frame(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
622 | { |
| 6977 | 623 | GtkWidget *ret = NULL, *frame = NULL; |
| 624 | GtkWidget *vbox = NULL, *hbox = NULL; | |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
625 | GtkWidget *toggle = NULL, *entry = NULL, *ref; |
| 6302 | 626 | |
| 3565 | 627 | ret = gtk_vbox_new(FALSE, 18); |
| 6302 | 628 | gtk_container_set_border_width(GTK_CONTAINER (ret), 12); |
| 3392 | 629 | |
| 6302 | 630 | /*---------- "Notify For" ----------*/ |
| 631 | frame = gaim_gtk_make_frame(ret, _("Notify For")); | |
| 632 | vbox = gtk_vbox_new(FALSE, 5); | |
| 633 | gtk_container_add(GTK_CONTAINER(frame), vbox); | |
| 634 | ||
| 3710 | 635 | toggle = gtk_check_button_new_with_mnemonic(_("_IM windows")); |
| 636 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 6977 | 637 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
| 9298 | 638 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_im")); |
| 6977 | 639 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 640 | G_CALLBACK(type_toggle_cb), "type_im"); |
| 3710 | 641 | |
| 6977 | 642 | toggle = gtk_check_button_new_with_mnemonic(_("C_hat windows")); |
| 3710 | 643 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 6977 | 644 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
| 9298 | 645 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_chat")); |
| 6977 | 646 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 647 | G_CALLBACK(type_toggle_cb), "type_chat"); |
| 6977 | 648 | |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
649 | ref = toggle; |
|
13550
55c77cece2d0
[gaim-migrate @ 15926]
Richard Laager <rlaager@pidgin.im>
parents:
13237
diff
changeset
|
650 | toggle = gtk_check_button_new_with_mnemonic(_("\t_Only when someone says your screen name")); |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
651 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
652 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
653 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_chat_nick")); |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
654 | g_signal_connect(G_OBJECT(toggle), "toggled", |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
655 | G_CALLBACK(type_toggle_cb), "type_chat_nick"); |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
656 | gtk_widget_set_sensitive(toggle, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ref))); |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
657 | g_signal_connect(G_OBJECT(ref), "toggled", |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
658 | G_CALLBACK(gaim_gtk_toggle_sensitive), toggle); |
|
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
659 | |
| 6977 | 660 | toggle = gtk_check_button_new_with_mnemonic(_("_Focused windows")); |
| 661 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 662 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 9298 | 663 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/type_focused")); |
| 6977 | 664 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 665 | G_CALLBACK(type_toggle_cb), "type_focused"); |
| 3710 | 666 | |
| 6302 | 667 | /*---------- "Notification Methods" ----------*/ |
| 668 | frame = gaim_gtk_make_frame(ret, _("Notification Methods")); | |
| 669 | vbox = gtk_vbox_new(FALSE, 5); | |
| 670 | gtk_container_add(GTK_CONTAINER(frame), vbox); | |
| 671 | ||
| 6977 | 672 | /* String method button */ |
| 3565 | 673 | hbox = gtk_hbox_new(FALSE, 18); |
| 674 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
| 6302 | 675 | toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:")); |
| 6977 | 676 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), |
| 9298 | 677 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_string")); |
| 3565 | 678 | gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); |
| 6977 | 679 | |
| 6302 | 680 | entry = gtk_entry_new(); |
| 681 | gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
| 682 | gtk_entry_set_max_length(GTK_ENTRY(entry), 10); | |
| 6977 | 683 | gtk_widget_set_sensitive(GTK_WIDGET(entry), |
| 9298 | 684 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_string")); |
| 6977 | 685 | gtk_entry_set_text(GTK_ENTRY(entry), |
| 9298 | 686 | gaim_prefs_get_string("/plugins/gtk/X11/notify/title_string")); |
| 6977 | 687 | g_object_set_data(G_OBJECT(toggle), "title-entry", entry); |
| 688 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 9298 | 689 | G_CALLBACK(method_toggle_cb), "method_string"); |
| 6977 | 690 | g_signal_connect(G_OBJECT(entry), "focus-out-event", |
| 9298 | 691 | G_CALLBACK(options_entry_cb), "method_string"); |
| 3374 | 692 | |
| 6977 | 693 | /* Count method button */ |
| 694 | toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title")); | |
| 695 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 9298 | 696 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_count")); |
| 6977 | 697 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 698 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 9298 | 699 | G_CALLBACK(method_toggle_cb), "method_count"); |
| 4035 | 700 | |
| 12959 | 701 | #ifndef _WIN32 |
| 6977 | 702 | /* Urgent method button */ |
| 703 | toggle = gtk_check_button_new_with_mnemonic(_("Set window manager \"_URGENT\" hint")); | |
| 704 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 705 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 9298 | 706 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_urgent")); |
| 707 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 708 | G_CALLBACK(method_toggle_cb), "method_urgent"); | |
| 12959 | 709 | #endif |
| 3710 | 710 | |
| 10606 | 711 | /* Raise window method button */ |
| 712 | toggle = gtk_check_button_new_with_mnemonic(_("R_aise conversation window")); | |
| 713 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 714 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 715 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/method_raise")); | |
| 716 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 717 | G_CALLBACK(method_toggle_cb), "method_raise"); | |
| 718 | ||
| 6977 | 719 | /*---------- "Notification Removals" ----------*/ |
| 6302 | 720 | frame = gaim_gtk_make_frame(ret, _("Notification Removal")); |
| 721 | vbox = gtk_vbox_new(FALSE, 5); | |
| 722 | gtk_container_add(GTK_CONTAINER(frame), vbox); | |
| 3374 | 723 | |
| 6977 | 724 | /* Remove on focus button */ |
| 725 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _gains focus")); | |
| 726 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 727 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 9298 | 728 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_focus")); |
| 6977 | 729 | g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(notify_toggle_cb), "notify_focus"); |
| 730 | ||
| 731 | /* Remove on click button */ | |
| 732 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click")); | |
| 733 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 734 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 9298 | 735 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_click")); |
| 6977 | 736 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 737 | G_CALLBACK(notify_toggle_cb), "notify_click"); |
| 3710 | 738 | |
| 6977 | 739 | /* Remove on type button */ |
| 740 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); | |
| 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_type")); |
| 6977 | 744 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 745 | G_CALLBACK(notify_toggle_cb), "notify_type"); |
| 4035 | 746 | |
| 6977 | 747 | /* Remove on message send button */ |
| 748 | toggle = gtk_check_button_new_with_mnemonic(_("Remove when a _message gets sent")); | |
| 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_send")); |
| 6977 | 752 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 753 | G_CALLBACK(notify_toggle_cb), "notify_send"); |
| 3565 | 754 | |
| 6977 | 755 | #if 0 |
| 756 | /* Remove on conversation switch button */ | |
| 9298 | 757 | toggle = gtk_check_button_new_with_mnemonic(_("Remove on switch to conversation ta_b")); |
| 6977 | 758 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 759 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 9298 | 760 | gaim_prefs_get_bool("/plugins/gtk/X11/notify/notify_switch")); |
| 6977 | 761 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 9298 | 762 | G_CALLBACK(notify_toggle_cb), "notify_switch"); |
| 6977 | 763 | #endif |
| 764 | ||
| 765 | gtk_widget_show_all(ret); | |
| 766 | return ret; | |
| 3374 | 767 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
768 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
769 | static gboolean |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
770 | plugin_load(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
771 | { |
| 6977 | 772 | GList *convs = gaim_get_conversations(); |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
773 | void *conv_handle = gaim_conversations_get_handle(); |
| 9298 | 774 | void *gtk_conv_handle = gaim_gtk_conversations_get_handle(); |
| 6302 | 775 | |
| 776 | my_plugin = plugin; | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
777 | |
|
12604
893fbf89317c
[gaim-migrate @ 14939]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
778 | gaim_signal_connect(gtk_conv_handle, "displayed-im-msg", plugin, |
| 12968 | 779 | GAIM_CALLBACK(message_displayed_cb), NULL); |
|
12604
893fbf89317c
[gaim-migrate @ 14939]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
780 | gaim_signal_connect(gtk_conv_handle, "displayed-chat-msg", plugin, |
| 12968 | 781 | GAIM_CALLBACK(message_displayed_cb), NULL); |
| 782 | gaim_signal_connect(gtk_conv_handle, "conversation-switched", plugin, | |
| 783 | GAIM_CALLBACK(conv_switched), NULL); | |
| 6977 | 784 | gaim_signal_connect(conv_handle, "sent-im-msg", plugin, |
| 9298 | 785 | GAIM_CALLBACK(im_sent_im), NULL); |
| 6977 | 786 | gaim_signal_connect(conv_handle, "sent-chat-msg", plugin, |
| 9298 | 787 | GAIM_CALLBACK(chat_sent_im), NULL); |
| 6977 | 788 | gaim_signal_connect(conv_handle, "conversation-created", plugin, |
| 9298 | 789 | GAIM_CALLBACK(conv_created), NULL); |
| 6977 | 790 | gaim_signal_connect(conv_handle, "chat-joined", plugin, |
| 9298 | 791 | GAIM_CALLBACK(conv_created), NULL); |
| 6977 | 792 | gaim_signal_connect(conv_handle, "deleting-conversation", plugin, |
| 9298 | 793 | GAIM_CALLBACK(deleting_conv), NULL); |
|
10971
4c823ffab27a
[gaim-migrate @ 12796]
Mark Doliner <markdoliner@pidgin.im>
parents:
10841
diff
changeset
|
794 | #if 0 |
|
11447
23594a754163
[gaim-migrate @ 13686]
Daniel Atallah <datallah@pidgin.im>
parents:
11338
diff
changeset
|
795 | gaim_signal_connect(gtk_conv_handle, "conversation-dragging", plugin, |
|
23594a754163
[gaim-migrate @ 13686]
Daniel Atallah <datallah@pidgin.im>
parents:
11338
diff
changeset
|
796 | GAIM_CALLBACK(conversation_dragging), NULL); |
|
9303
e257ad08c77c
[gaim-migrate @ 10107]
Mark Doliner <markdoliner@pidgin.im>
parents:
9298
diff
changeset
|
797 | #endif |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
798 | |
| 6977 | 799 | while (convs) { |
| 800 | GaimConversation *conv = (GaimConversation *)convs->data; | |
| 6302 | 801 | |
| 802 | /* attach signals */ | |
| 6977 | 803 | attach_signals(conv); |
| 6302 | 804 | |
| 6977 | 805 | convs = convs->next; |
| 6302 | 806 | } |
| 807 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
808 | return TRUE; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
809 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
810 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
811 | static gboolean |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
812 | plugin_unload(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
813 | { |
| 6977 | 814 | GList *convs = gaim_get_conversations(); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
815 | |
| 6977 | 816 | while (convs) { |
| 817 | GaimConversation *conv = (GaimConversation *)convs->data; | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
818 | |
| 6302 | 819 | /* kill signals */ |
| 6977 | 820 | detach_signals(conv); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
821 | |
| 6977 | 822 | convs = convs->next; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
823 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
824 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
825 | return TRUE; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
826 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
827 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
828 | static GaimGtkPluginUiInfo ui_info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
829 | { |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12397
diff
changeset
|
830 | get_config_frame, |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12397
diff
changeset
|
831 | 0 /* page_num (Reserved) */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
832 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
833 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
834 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
835 | { |
| 9943 | 836 | GAIM_PLUGIN_MAGIC, |
| 837 | GAIM_MAJOR_VERSION, | |
| 838 | GAIM_MINOR_VERSION, | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
839 | GAIM_PLUGIN_STANDARD, /**< type */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
840 | GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
841 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
842 | NULL, /**< dependencies */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
843 | GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
844 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
845 | NOTIFY_PLUGIN_ID, /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
846 | N_("Message Notification"), /**< name */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
847 | VERSION, /**< version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
848 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
849 | N_("Provides a variety of ways of notifying you of unread messages."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
850 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
851 | N_("Provides a variety of ways of notifying you of unread messages."), |
| 9298 | 852 | "Etan Reisner <deryni@eden.rutgers.edu>\n\t\t\tBrian Tarricone <bjt23@cornell.edu>", |
| 6302 | 853 | /**< author */ |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6464
diff
changeset
|
854 | GAIM_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
855 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
856 | plugin_load, /**< load */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
857 | plugin_unload, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
858 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
859 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
860 | &ui_info, /**< ui_info */ |
| 8993 | 861 | NULL, /**< extra_info */ |
| 862 | NULL, | |
| 863 | NULL | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
864 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
865 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
866 | static void |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
867 | init_plugin(GaimPlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
868 | { |
| 6302 | 869 | gaim_prefs_add_none("/plugins/gtk"); |
| 870 | gaim_prefs_add_none("/plugins/gtk/X11"); | |
| 871 | gaim_prefs_add_none("/plugins/gtk/X11/notify"); | |
| 872 | ||
| 6464 | 873 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/type_im", TRUE); |
| 874 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/type_chat", FALSE); | |
|
13237
9556cdf38196
[gaim-migrate @ 15602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13234
diff
changeset
|
875 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/type_chat_nick", FALSE); |
| 6464 | 876 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/type_focused", FALSE); |
| 6302 | 877 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_string", FALSE); |
| 878 | gaim_prefs_add_string("/plugins/gtk/X11/notify/title_string", "(*)"); | |
| 879 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_urgent", FALSE); | |
| 880 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_count", FALSE); | |
| 10492 | 881 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/method_raise", FALSE); |
| 6302 | 882 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_focus", FALSE); |
| 883 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_click", FALSE); | |
| 884 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_type", TRUE); | |
| 6464 | 885 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_send", TRUE); |
| 886 | gaim_prefs_add_bool("/plugins/gtk/X11/notify/notify_switch", TRUE); | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
887 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5021
diff
changeset
|
888 | |
| 6063 | 889 | GAIM_INIT_PLUGIN(notify, init_plugin, info) |