Mercurial > pidgin
comparison plugins/notify.c @ 4035:4cea75cf291d
[gaim-migrate @ 4241]
(22:03:26) deryni: and yeah, this notify.diff isn't in yet (adds an apply to open conv button, and gtk2ifies things a bit)
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Tue, 03 Dec 2002 03:04:04 +0000 |
| parents | 03ba413ca20b |
| children | e25edee01c33 |
comparison
equal
deleted
inserted
replaced
| 4034:c14b687f4601 | 4035:4cea75cf291d |
|---|---|
| 1 /* Rewritten by Etan Reisner <deryni@eden.rutgers.edu> | 1 /* Rewritten by Etan Reisner <deryni@eden.rutgers.edu> |
| 2 * | 2 * |
| 3 * Added config dialog | 3 * Added config dialog |
| 4 * Added control over notification method | 4 * Added control over notification method |
| 5 * Added control over when to release notification | 5 * Added control over when to release notification |
| 6 * | |
| 7 * Added option to get notification for chats also | |
| 8 * Cleaned up code | |
| 9 * Added option to notify on click as it's own option | |
| 10 * rather then as what happens when on focus isn't clicked | |
| 11 * Added apply button to change the denotification methods for | |
| 12 * open conversation windows | |
| 6 * | 13 * |
| 7 * Thanks to Carles Pina i Estany <carles@pinux.info> | 14 * Thanks to Carles Pina i Estany <carles@pinux.info> |
| 8 * for count of new messages option | 15 * for count of new messages option |
| 9 */ | 16 */ |
| 10 | 17 |
| 37 #define METHOD_QUOTE 0x00000002 | 44 #define METHOD_QUOTE 0x00000002 |
| 38 #define METHOD_URGENT 0x00000004 | 45 #define METHOD_URGENT 0x00000004 |
| 39 #define METHOD_COUNT 0x00000008 | 46 #define METHOD_COUNT 0x00000008 |
| 40 | 47 |
| 41 void *handle; | 48 void *handle; |
| 42 /* I really don't like this but I was having trouble getting any | |
| 43 * other way of removing the signal callbacks to work and not crash gaim | |
| 44 */ | |
| 45 GtkWidget *really_evil_hack; | |
| 46 GtkWidget *Entry; | 49 GtkWidget *Entry; |
| 47 gchar *title_string = "(*) "; | 50 gchar *title_string = "(*) "; |
| 48 | 51 |
| 49 /* predefine some functions, less warnings */ | 52 /* predefine some functions, less warnings */ |
| 50 void options(GtkWidget *widget, gpointer data); | 53 void options(GtkWidget *widget, gpointer data); |
| 51 void un_star(GtkWidget *widget, gpointer data); | 54 void un_star(GtkWidget *widget, gpointer data); |
| 52 int un_star_window(GtkWidget *widget, gpointer data); | 55 int un_star_window(GtkWidget *widget, gpointer data); |
| 53 void string_remove(GtkWidget *widget); | |
| 54 void count_remove(GtkWidget *widget); | |
| 55 void quote_remove(GtkWidget *widget); | |
| 56 void urgent_remove(struct conversation *c); | |
| 57 int counter (char *buf, int *length); | 56 int counter (char *buf, int *length); |
| 57 /*string functions */ | |
| 58 void string_add(GtkWidget *widget); | |
| 59 gboolean string_remove(GtkWidget *widget); | |
| 60 /* count functions */ | |
| 61 void count_add(GtkWidget *widget); | |
| 62 gboolean count_remove(GtkWidget *widget); | |
| 63 /* quote functions */ | |
| 64 void quote_add(GtkWidget *widget); | |
| 65 gboolean quote_remove(GtkWidget *widget); | |
| 66 /* urgent functions */ | |
| 67 void urgent_add(struct conversation *c); | |
| 68 gboolean urgent_remove(struct conversation *c); | |
| 58 | 69 |
| 59 struct conversation *find_chat(struct gaim_connection *gc, int id) { | 70 struct conversation *find_chat(struct gaim_connection *gc, int id) { |
| 60 GList *cnv = chats; | 71 GList *cnv = chats; |
| 61 struct conversation *c; | 72 struct conversation *c; |
| 62 | 73 |
| 70 } | 81 } |
| 71 return NULL; | 82 return NULL; |
| 72 } | 83 } |
| 73 | 84 |
| 74 int notify(struct conversation *cnv) { | 85 int notify(struct conversation *cnv) { |
| 75 char buf[256]; | |
| 76 GtkWindow *win; | |
| 77 Window focus_return; | 86 Window focus_return; |
| 78 int revert_to_return, c, length; | 87 int revert_to_return; |
| 79 | |
| 80 win = (GtkWindow *)cnv->window; | |
| 81 | 88 |
| 82 XGetInputFocus(GDK_WINDOW_XDISPLAY(cnv->window->window), &focus_return, &revert_to_return); | 89 XGetInputFocus(GDK_WINDOW_XDISPLAY(cnv->window->window), &focus_return, &revert_to_return); |
| 83 | 90 |
| 84 if ((choice & NOTIFY_IN_FOCUS) || focus_return != GDK_WINDOW_XWINDOW(cnv->window->window)) { | 91 if ((choice & NOTIFY_IN_FOCUS) || focus_return != GDK_WINDOW_XWINDOW(cnv->window->window)) { |
| 85 if (method & METHOD_STRING) { | 92 if (method & METHOD_STRING) |
| 86 strncpy(buf, win->title, sizeof(buf)); | 93 string_add(cnv->window); |
| 87 if (!strstr(buf, title_string)) { | 94 if (method & METHOD_COUNT) |
| 88 g_snprintf(buf, sizeof(buf), "%s%s", title_string, win->title); | 95 count_add(cnv->window); |
| 89 gtk_window_set_title(win, buf); | 96 if (method & METHOD_QUOTE) |
| 90 } | 97 quote_add(cnv->window); |
| 91 } | 98 if (method & METHOD_URGENT) |
| 92 if (method & METHOD_COUNT) { | 99 urgent_add(cnv); |
| 93 strncpy(buf, win->title, sizeof(buf)); | |
| 94 c = counter(buf, &length); | |
| 95 if (!c) { | |
| 96 g_snprintf(buf, sizeof(buf), "[1] %s", win->title); | |
| 97 } | |
| 98 else if (!g_strncasecmp(buf, "[", 1)) { | |
| 99 g_snprintf(buf, sizeof(buf), "[%d] %s", c+1, &win->title[3+length]); | |
| 100 } | |
| 101 gtk_window_set_title(win, buf); | |
| 102 } | |
| 103 if (method & METHOD_QUOTE) { | |
| 104 strncpy(buf, win->title, sizeof(buf)); | |
| 105 if (g_strncasecmp(buf, "\"", 1)) { | |
| 106 g_snprintf(buf, sizeof(buf), "\"%s\"", win->title); | |
| 107 gtk_window_set_title(win, buf); | |
| 108 } | |
| 109 } | |
| 110 if (method & METHOD_URGENT) { | |
| 111 /* do it the gdk way for windows compatibility(?) if I can figure it out */ | |
| 112 /* Sean says this is a bad thing, and I should try using gtk_property_get first */ | |
| 113 /* I'll want to pay attention to note on dev.gnome.org though */ | |
| 114 /* gdk_property_change(win->window, WM_HINTS, WM_HINTS, 32, GDK_PROP_MODE_REPLACE, XUrgencyHint, 1); */ | |
| 115 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(cnv->window->window), GDK_WINDOW_XWINDOW(cnv->window->window)); | |
| 116 hints->flags |= XUrgencyHint; | |
| 117 XSetWMHints(GDK_WINDOW_XDISPLAY(cnv->window->window), GDK_WINDOW_XWINDOW(cnv->window->window), hints); | |
| 118 } | |
| 119 } | 100 } |
| 120 return 0; | 101 return 0; |
| 121 } | 102 } |
| 122 | 103 |
| 123 int unnotify(struct conversation *c) { | 104 guint unnotify(struct conversation *c, gboolean clean) { |
| 124 if (method & METHOD_QUOTE) | 105 guint option = 0; |
| 125 quote_remove(c->window); | 106 if (clean || (method & METHOD_QUOTE)) |
| 126 if (method & METHOD_COUNT) | 107 if(quote_remove(c->window)) |
| 127 count_remove(c->window); | 108 option ^= METHOD_QUOTE; |
| 128 if (method & METHOD_STRING) | 109 if (clean || (method & METHOD_COUNT)) |
| 129 string_remove(c->window); | 110 if (count_remove(c->window)) |
| 130 if (method & METHOD_URGENT) | 111 option ^= METHOD_COUNT; |
| 131 urgent_remove(c); | 112 if (clean || (method & METHOD_STRING)) |
| 132 return 0; | 113 if (string_remove(c->window)) |
| 114 option ^= METHOD_STRING; | |
| 115 if (clean || (method & METHOD_URGENT)) | |
| 116 if (urgent_remove(c)) | |
| 117 option ^= METHOD_URGENT; | |
| 118 return option; | |
| 133 } | 119 } |
| 134 | 120 |
| 135 void chat_recv_im(struct gaim_connection *gc, int id, char **who, char **text) { | 121 void chat_recv_im(struct gaim_connection *gc, int id, char **who, char **text) { |
| 136 struct conversation *c = find_chat(gc, id); | 122 struct conversation *c = find_chat(gc, id); |
| 137 | 123 |
| 142 | 128 |
| 143 void chat_sent_im(struct gaim_connection *gc, int id, char **text) { | 129 void chat_sent_im(struct gaim_connection *gc, int id, char **text) { |
| 144 struct conversation *c = find_chat(gc, id); | 130 struct conversation *c = find_chat(gc, id); |
| 145 | 131 |
| 146 if (c && (type & TYPE_CHAT)) | 132 if (c && (type & TYPE_CHAT)) |
| 147 unnotify(c); | 133 unnotify(c, FALSE); |
| 148 return; | 134 return; |
| 149 } | 135 } |
| 150 | 136 |
| 151 int im_recv_im(struct gaim_connection *gc, char **who, char **what, void *m) { | 137 int im_recv_im(struct gaim_connection *gc, char **who, char **what, void *m) { |
| 152 struct conversation *c = find_conversation(*who); | 138 struct conversation *c = find_conversation(*who); |
| 158 | 144 |
| 159 int im_sent_im(struct gaim_connection *gc, char *who, char **what, void *m) { | 145 int im_sent_im(struct gaim_connection *gc, char *who, char **what, void *m) { |
| 160 struct conversation *c = find_conversation(who); | 146 struct conversation *c = find_conversation(who); |
| 161 | 147 |
| 162 if (c && (type & TYPE_IM)) | 148 if (c && (type & TYPE_IM)) |
| 163 unnotify(c); | 149 unnotify(c, FALSE); |
| 164 return 0; | 150 return 0; |
| 165 } | 151 } |
| 166 | 152 |
| 167 int attach_signals(struct conversation *c) { | 153 int attach_signals(struct conversation *c) { |
| 168 if (choice & NOTIFY_FOCUS) { | 154 if (choice & NOTIFY_FOCUS) { |
| 169 gtk_signal_connect_while_alive(GTK_OBJECT(c->window), "focus-in-event", GTK_SIGNAL_FUNC(un_star), NULL, GTK_OBJECT(really_evil_hack)); | 155 g_signal_connect(G_OBJECT(c->window), "focus-in-event", G_CALLBACK(un_star), NULL); |
| 170 gtk_object_set_user_data(GTK_OBJECT(c->window), c); | |
| 171 } | 156 } |
| 172 | 157 |
| 173 if (choice & NOTIFY_CLICK) { | 158 if (choice & NOTIFY_CLICK) { |
| 174 gtk_signal_connect_while_alive(GTK_OBJECT(c->window), "button_press_event", GTK_SIGNAL_FUNC(un_star), NULL, GTK_OBJECT(really_evil_hack)); | 159 g_signal_connect(G_OBJECT(c->window), "button_press_event", G_CALLBACK(un_star), NULL); |
| 175 gtk_object_set_user_data(GTK_OBJECT(c->window), c); | 160 |
| 176 gtk_signal_connect_while_alive(GTK_OBJECT(c->text), "button_press_event", GTK_SIGNAL_FUNC(un_star_window), NULL, GTK_OBJECT(really_evil_hack)); | 161 g_signal_connect(G_OBJECT(c->text), "button_press_event", G_CALLBACK(un_star_window), NULL); |
| 177 gtk_object_set_user_data(GTK_OBJECT(c->text), c); | 162 |
| 178 gtk_signal_connect_while_alive(GTK_OBJECT(c->entry), "button_press_event", GTK_SIGNAL_FUNC(un_star_window), NULL, GTK_OBJECT(really_evil_hack)); | 163 g_signal_connect(G_OBJECT(c->entry), "button_press_event", G_CALLBACK(un_star_window), NULL); |
| 179 gtk_object_set_user_data(GTK_OBJECT(c->entry), c); | |
| 180 } | 164 } |
| 181 | 165 |
| 182 if (choice & NOTIFY_TYPE) { | 166 if (choice & NOTIFY_TYPE) { |
| 183 gtk_signal_connect_while_alive(GTK_OBJECT(c->entry), "key-press-event", GTK_SIGNAL_FUNC(un_star_window), NULL, GTK_OBJECT(really_evil_hack)); | 167 g_signal_connect(G_OBJECT(c->entry), "key-press-event", G_CALLBACK(un_star_window), NULL); |
| 184 gtk_object_set_user_data(GTK_OBJECT(c->entry), (gpointer) c); | 168 } |
| 185 } | 169 |
| 170 g_object_set_data(G_OBJECT(c->window), "notify_data", GUINT_TO_POINTER(choice)); | |
| 186 return 0; | 171 return 0; |
| 187 } | 172 } |
| 188 | 173 |
| 189 void new_conv(char *who) { | 174 void new_conv(char *who) { |
| 190 struct conversation *c = find_conversation(who); | 175 struct conversation *c = find_conversation(who); |
| 191 | 176 |
| 192 if (c && (type & TYPE_IM)) | 177 if (c && (type & TYPE_IM)) |
| 193 attach_signals(c); | 178 attach_signals(c); |
| 194 return; | 179 return; |
| 195 } | 180 } |
| 196 | 181 |
| 197 void chat_join(struct gaim_connection *gc, int id, char *room) { | 182 void chat_join(struct gaim_connection *gc, int id, char *room) { |
| 233 temp[i-1] = buf[i]; | 218 temp[i-1] = buf[i]; |
| 234 (*length)++; | 219 (*length)++; |
| 235 i++; | 220 i++; |
| 236 } | 221 } |
| 237 temp[i] = '\0'; | 222 temp[i] = '\0'; |
| 238 | 223 |
| 239 if (buf[i] != ']') { | 224 if (buf[i] != ']') { |
| 240 *length = 0; | 225 *length = 0; |
| 241 return (0); | 226 return (0); |
| 242 } | 227 } |
| 243 | 228 |
| 244 return (atoi(temp)); | 229 return (atoi(temp)); |
| 245 } | 230 } |
| 246 | 231 |
| 247 void string_remove(GtkWidget *widget) { | 232 void string_add(GtkWidget *widget) { |
| 233 char buf[256]; | |
| 234 GtkWindow *win = GTK_WINDOW(widget); | |
| 235 | |
| 236 strncpy(buf, win->title, sizeof(buf)); | |
| 237 if (!strstr(buf, title_string)) { | |
| 238 g_snprintf(buf, sizeof(buf), "%s%s", title_string, win->title); | |
| 239 gtk_window_set_title(win, buf); | |
| 240 } | |
| 241 } | |
| 242 | |
| 243 gboolean string_remove(GtkWidget *widget) { | |
| 248 char buf[256]; | 244 char buf[256]; |
| 249 GtkWindow *win = GTK_WINDOW(widget); | 245 GtkWindow *win = GTK_WINDOW(widget); |
| 250 | 246 |
| 251 strncpy(buf, win->title, sizeof(buf)); | 247 strncpy(buf, win->title, sizeof(buf)); |
| 252 if (strstr(buf, title_string)) { | 248 if (strstr(buf, title_string)) { |
| 253 g_snprintf(buf, sizeof(buf), "%s", &win->title[strlen(title_string)]); | 249 g_snprintf(buf, sizeof(buf), "%s", &win->title[strlen(title_string)]); |
| 254 gtk_window_set_title(win, buf); | 250 gtk_window_set_title(win, buf); |
| 255 } | 251 return TRUE; |
| 256 return; | 252 } |
| 257 } | 253 return FALSE; |
| 258 | 254 } |
| 259 void count_remove(GtkWidget *widget) { | 255 |
| 256 void count_add(GtkWidget *widget) { | |
| 257 char buf[256]; | |
| 258 int c, length; | |
| 259 GtkWindow *win = GTK_WINDOW(widget); | |
| 260 | |
| 261 strncpy(buf, win->title, sizeof(buf)); | |
| 262 c = counter(buf, &length); | |
| 263 if (!c) { | |
| 264 g_snprintf(buf, sizeof(buf), "[1] %s", win->title); | |
| 265 } | |
| 266 else if (!g_strncasecmp(buf, "[", 1)) { | |
| 267 g_snprintf(buf, sizeof(buf), "[%d] %s", c+1, &win->title[3+length]); | |
| 268 } | |
| 269 gtk_window_set_title(win, buf); | |
| 270 } | |
| 271 | |
| 272 gboolean count_remove(GtkWidget *widget) { | |
| 260 char buf[256]; | 273 char buf[256]; |
| 261 GtkWindow *win = GTK_WINDOW(widget); | 274 GtkWindow *win = GTK_WINDOW(widget); |
| 262 int length; | 275 int length; |
| 263 | 276 |
| 264 strncpy(buf, win->title, sizeof(buf)); | 277 strncpy(buf, win->title, sizeof(buf)); |
| 265 if (!g_strncasecmp(buf, "[", 1)) { | 278 if (!g_strncasecmp(buf, "[", 1)) { |
| 266 counter(buf, &length); | 279 counter(buf, &length); |
| 267 g_snprintf(buf, sizeof(buf), "%s", &win->title[3+length]); | 280 g_snprintf(buf, sizeof(buf), "%s", &win->title[3+length]); |
| 268 gtk_window_set_title(win, buf); | 281 gtk_window_set_title(win, buf); |
| 269 } | 282 return TRUE; |
| 270 return; | 283 } |
| 271 } | 284 return FALSE; |
| 272 | 285 } |
| 273 void quote_remove(GtkWidget *widget) { | 286 |
| 287 void quote_add(GtkWidget *widget) { | |
| 288 char buf[256]; | |
| 289 GtkWindow *win = GTK_WINDOW(widget); | |
| 290 | |
| 291 strncpy(buf, win->title, sizeof(buf)); | |
| 292 if (g_strncasecmp(buf, "\"", 1)) { | |
| 293 g_snprintf(buf, sizeof(buf), "\"%s\"", win->title); | |
| 294 gtk_window_set_title(win, buf); | |
| 295 } | |
| 296 } | |
| 297 | |
| 298 gboolean quote_remove(GtkWidget *widget) { | |
| 274 char buf[256]; | 299 char buf[256]; |
| 275 GtkWindow *win = GTK_WINDOW(widget); | 300 GtkWindow *win = GTK_WINDOW(widget); |
| 276 | 301 |
| 277 strncpy(buf, win->title, sizeof(buf)); | 302 strncpy(buf, win->title, sizeof(buf)); |
| 278 if (!g_strncasecmp(buf, "\"", 1)) { | 303 if (!g_strncasecmp(buf, "\"", 1)) { |
| 279 g_snprintf(buf, strlen(buf) - 1, "%s", &win->title[1]); | 304 g_snprintf(buf, strlen(buf) - 1, "%s", &win->title[1]); |
| 280 gtk_window_set_title(win, buf); | 305 gtk_window_set_title(win, buf); |
| 281 } | 306 return TRUE; |
| 282 return; | 307 } |
| 283 } | 308 return FALSE; |
| 284 | 309 } |
| 285 void urgent_remove(struct conversation *c) { | 310 |
| 311 void urgent_add(struct conversation *c) { | |
| 312 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window)); | |
| 313 hints->flags |= XUrgencyHint; | |
| 314 XSetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window), hints); | |
| 315 } | |
| 316 | |
| 317 gboolean urgent_remove(struct conversation *c) { | |
| 286 GdkWindow *win = c->window->window; | 318 GdkWindow *win = c->window->window; |
| 287 | 319 |
| 288 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win)); | 320 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win)); |
| 289 hints->flags &= ~XUrgencyHint; | 321 if (hints->flags & XUrgencyHint) { |
| 290 XSetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win), hints); | 322 hints->flags &= ~XUrgencyHint; |
| 291 return; | 323 XSetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win), hints); |
| 324 return TRUE; | |
| 325 } | |
| 326 return FALSE; | |
| 292 } | 327 } |
| 293 | 328 |
| 294 void save_notify_prefs() { | 329 void save_notify_prefs() { |
| 295 gchar buf[1000]; | 330 gchar buf[1000]; |
| 296 FILE *fp; | 331 FILE *fp; |
| 335 fclose(fp); | 370 fclose(fp); |
| 336 return; | 371 return; |
| 337 } | 372 } |
| 338 | 373 |
| 339 void options(GtkWidget *widget, gpointer data) { | 374 void options(GtkWidget *widget, gpointer data) { |
| 340 gint option = GPOINTER_TO_INT(data); | 375 gint option = GPOINTER_TO_INT(data); |
| 341 | 376 |
| 342 if (option == 0) | 377 if (option == 0) |
| 343 choice ^= NOTIFY_FOCUS; | 378 choice ^= NOTIFY_FOCUS; |
| 344 else if (option == 1) | 379 else if (option == 1) |
| 345 choice ^= NOTIFY_CLICK; | 380 choice ^= NOTIFY_CLICK; |
| 366 type ^= TYPE_CHAT; | 401 type ^= TYPE_CHAT; |
| 367 | 402 |
| 368 save_notify_prefs(); | 403 save_notify_prefs(); |
| 369 } | 404 } |
| 370 | 405 |
| 406 void apply_options(GtkWidget *widget, gpointer data) { | |
| 407 GList *cnv = conversations; | |
| 408 | |
| 409 while (cnv) { | |
| 410 guint notification; | |
| 411 struct conversation *c = (struct conversation *) cnv->data; | |
| 412 guint options = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(c->window), "notify_data")); | |
| 413 | |
| 414 if (options & NOTIFY_FOCUS) | |
| 415 g_signal_handlers_disconnect_by_func(G_OBJECT(c->window), un_star, NULL); | |
| 416 | |
| 417 if (options & NOTIFY_CLICK) { | |
| 418 g_signal_handlers_disconnect_by_func(G_OBJECT(c->window), un_star, NULL); | |
| 419 g_signal_handlers_disconnect_by_func(G_OBJECT(c->text), un_star_window, NULL); | |
| 420 g_signal_handlers_disconnect_by_func(G_OBJECT(c->entry), un_star_window, NULL); | |
| 421 } | |
| 422 | |
| 423 if (options & NOTIFY_TYPE) | |
| 424 g_signal_handlers_disconnect_by_func(G_OBJECT(c->entry), un_star_window, NULL); | |
| 425 | |
| 426 /* needs rethinking to get the order of events to work | |
| 427 * correctly, so that correct methods can get restored */ | |
| 428 /* clean off all notification markings */ | |
| 429 notification = unnotify(c, TRUE); | |
| 430 /* re-add appropriate notification methods cleaned above */ | |
| 431 if (notification & METHOD_QUOTE) /* re-add quote */ | |
| 432 quote_add(c->window); | |
| 433 if (notification & METHOD_COUNT) /* re-add count */ | |
| 434 count_add(c->window); | |
| 435 if (notification & METHOD_STRING) /* re-add string */ | |
| 436 string_add(c->window); | |
| 437 if (notification & METHOD_URGENT) /* re-add urgent */ | |
| 438 urgent_add(c); | |
| 439 /* attach new unnotification signals */ | |
| 440 attach_signals(c); | |
| 441 | |
| 442 cnv = cnv->next; | |
| 443 } | |
| 444 | |
| 445 return; | |
| 446 } | |
| 447 | |
| 371 char *gaim_plugin_init(GModule *hndl) { | 448 char *gaim_plugin_init(GModule *hndl) { |
| 372 handle = hndl; | 449 handle = hndl; |
| 373 | |
| 374 really_evil_hack = gtk_label_new(""); | |
| 375 | 450 |
| 376 load_notify_prefs(); | 451 load_notify_prefs(); |
| 377 | 452 |
| 378 gaim_signal_connect(handle, event_im_recv, im_recv_im, NULL); | 453 gaim_signal_connect(handle, event_im_recv, im_recv_im, NULL); |
| 379 gaim_signal_connect(handle, event_chat_recv, chat_recv_im, NULL); | 454 gaim_signal_connect(handle, event_chat_recv, chat_recv_im, NULL); |
| 385 } | 460 } |
| 386 | 461 |
| 387 void gaim_plugin_remove() { | 462 void gaim_plugin_remove() { |
| 388 GList *c = conversations; | 463 GList *c = conversations; |
| 389 | 464 |
| 390 gtk_widget_destroy(really_evil_hack); | |
| 391 | |
| 392 while (c) { | 465 while (c) { |
| 393 struct conversation *cnv = (struct conversation *)c->data; | 466 struct conversation *cnv = (struct conversation *)c->data; |
| 394 | |
| 395 un_star(cnv->window, NULL); | 467 un_star(cnv->window, NULL); |
| 396 | |
| 397 c = c->next; | 468 c = c->next; |
| 398 } | 469 } |
| 399 } | 470 } |
| 400 | 471 |
| 401 struct gaim_plugin_description desc; | 472 struct gaim_plugin_description desc; |
| 419 } | 490 } |
| 420 | 491 |
| 421 GtkWidget *gaim_plugin_config_gtk() { | 492 GtkWidget *gaim_plugin_config_gtk() { |
| 422 GtkWidget *ret; | 493 GtkWidget *ret; |
| 423 GtkWidget *vbox, *hbox; | 494 GtkWidget *vbox, *hbox; |
| 424 GtkWidget *toggle; | 495 GtkWidget *toggle, *button; |
| 425 ret = gtk_vbox_new(FALSE, 18); | 496 ret = gtk_vbox_new(FALSE, 18); |
| 426 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); | 497 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); |
| 427 | 498 |
| 428 vbox = make_frame(ret, _("Notify For")); | 499 vbox = make_frame(ret, _("Notify For")); |
| 429 toggle = gtk_check_button_new_with_mnemonic(_("_IM windows")); | 500 toggle = gtk_check_button_new_with_mnemonic(_("_IM windows")); |
| 440 vbox = make_frame(ret, _("Notification Methods")); | 511 vbox = make_frame(ret, _("Notification Methods")); |
| 441 hbox = gtk_hbox_new(FALSE, 18); | 512 hbox = gtk_hbox_new(FALSE, 18); |
| 442 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 513 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 443 toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:")); | 514 toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:")); |
| 444 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_STRING); | 515 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_STRING); |
| 445 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(3)); | 516 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(3)); |
| 446 gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); | 517 gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); |
| 447 Entry = gtk_entry_new_with_max_length(7); | 518 Entry = gtk_entry_new_with_max_length(7); |
| 448 gtk_widget_set_sensitive(GTK_WIDGET(Entry), method & METHOD_STRING); | 519 gtk_widget_set_sensitive(GTK_WIDGET(Entry), method & METHOD_STRING); |
| 449 gtk_box_pack_start(GTK_BOX(hbox), Entry, FALSE, FALSE, 0); | 520 gtk_box_pack_start(GTK_BOX(hbox), Entry, FALSE, FALSE, 0); |
| 450 gtk_entry_set_text(GTK_ENTRY(Entry), title_string); | 521 gtk_entry_set_text(GTK_ENTRY(Entry), title_string); |
| 451 | 522 |
| 452 toggle = gtk_check_button_new_with_mnemonic(_("_Quote window title")); | 523 toggle = gtk_check_button_new_with_mnemonic(_("_Quote window title")); |
| 453 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | 524 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 454 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_QUOTE); | 525 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_QUOTE); |
| 455 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(4)); | 526 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(4)); |
| 456 | 527 |
| 457 toggle = gtk_check_button_new_with_mnemonic(_("Set Window Manager \"_URGENT\" Hint")); | 528 toggle = gtk_check_button_new_with_mnemonic(_("Set Window Manager \"_URGENT\" Hint")); |
| 458 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | 529 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 459 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_URGENT); | 530 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_URGENT); |
| 460 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(5)); | 531 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(5)); |
| 461 | 532 |
| 462 toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title")); | 533 toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title")); |
| 463 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_COUNT); | 534 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_COUNT); |
| 464 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | 535 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 465 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(7)); | 536 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(7)); |
| 466 | 537 |
| 467 toggle = gtk_check_button_new_with_mnemonic(_("_Notify even if conversation is in focus")); | 538 toggle = gtk_check_button_new_with_mnemonic(_("_Notify even if conversation is in focus")); |
| 468 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_IN_FOCUS); | 539 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_IN_FOCUS); |
| 469 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | 540 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 470 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(6)); | 541 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(6)); |
| 471 | 542 |
| 472 /*--------------*/ | 543 /*--------------*/ |
| 473 vbox = make_frame(ret, _("Notification Removal")); | 544 vbox = make_frame(ret, _("Notification Removal")); |
| 474 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window gains _focus")); | 545 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window gains _focus")); |
| 475 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | 546 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 476 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_FOCUS); | 547 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_FOCUS); |
| 477 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(0)); | 548 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(0)); |
| 478 | 549 |
| 479 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click")); | 550 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click")); |
| 480 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | 551 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 481 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_CLICK); | 552 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_CLICK); |
| 482 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(1)); | 553 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(1)); |
| 483 | 554 |
| 484 toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); | 555 toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); |
| 485 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | 556 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 486 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_TYPE); | 557 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_TYPE); |
| 487 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(2)); | 558 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(2)); |
| 559 | |
| 560 button = gtk_button_new_with_mnemonic(_("Appl_y")); | |
| 561 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 5); | |
| 562 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(apply_options), NULL); | |
| 488 | 563 |
| 489 gtk_widget_show_all(ret); | 564 gtk_widget_show_all(ret); |
| 490 return ret; | 565 return ret; |
| 491 } | 566 } |
