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