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