Mercurial > pidgin
annotate plugins/notify.c @ 4043:e25edee01c33
[gaim-migrate @ 4251]
(20:35:19) deryni: LSchiere: http://deryni.perlmonk.org/notify.diff <- fixes the Urgent option crash, and fixes applying changes
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Wed, 04 Dec 2002 01:36:43 +0000 |
| parents | 4cea75cf291d |
| children | 0fccde7ed9b8 |
| rev | line source |
|---|---|
| 3392 | 1 /* Rewritten by Etan Reisner <deryni@eden.rutgers.edu> |
| 3374 | 2 * |
| 3 * Added config dialog | |
| 4 * Added control over notification method | |
| 5 * Added control over when to release notification | |
| 4035 | 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 | |
| 3392 | 13 * |
| 14 * Thanks to Carles Pina i Estany <carles@pinux.info> | |
| 15 * for count of new messages option | |
| 16 */ | |
| 17 | |
| 3710 | 18 #ifndef GAIM_PLUGINS |
| 19 #define GAIM_PLUGINS | |
| 20 #endif | |
| 3374 | 21 |
| 191 | 22 #include "gaim.h" |
| 3428 | 23 #include <string.h> |
| 24 #include <ctype.h> | |
| 25 #include <stdlib.h> | |
| 191 | 26 #include <gtk/gtk.h> |
| 3385 | 27 #include <X11/Xlib.h> |
| 3374 | 28 #include <X11/Xutil.h> |
| 3392 | 29 #include <X11/Xatom.h> |
| 3374 | 30 #include <gdk/gdkx.h> |
| 31 | |
| 3710 | 32 guint type = 1; |
| 33 #define TYPE_IM 0x00000001 | |
| 34 #define TYPE_CHAT 0x00000002 | |
| 35 | |
| 3392 | 36 guint choice = 1; |
| 37 #define NOTIFY_FOCUS 0x00000001 | |
| 38 #define NOTIFY_TYPE 0x00000002 | |
| 39 #define NOTIFY_IN_FOCUS 0x00000004 | |
| 3710 | 40 #define NOTIFY_CLICK 0x00000008 |
| 3374 | 41 |
| 3392 | 42 guint method = 1; |
| 43 #define METHOD_STRING 0x00000001 | |
| 44 #define METHOD_QUOTE 0x00000002 | |
| 45 #define METHOD_URGENT 0x00000004 | |
| 46 #define METHOD_COUNT 0x00000008 | |
| 191 | 47 |
| 48 void *handle; | |
| 3565 | 49 GtkWidget *Entry; |
| 3392 | 50 gchar *title_string = "(*) "; |
| 191 | 51 |
| 3374 | 52 /* predefine some functions, less warnings */ |
| 53 void options(GtkWidget *widget, gpointer data); | |
| 54 void un_star(GtkWidget *widget, gpointer data); | |
| 4043 | 55 void un_star_window(GtkWidget *widget, gpointer data); |
| 3428 | 56 int counter (char *buf, int *length); |
| 4035 | 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); | |
| 3374 | 69 |
| 3710 | 70 struct conversation *find_chat(struct gaim_connection *gc, int id) { |
| 71 GList *cnv = chats; | |
| 72 struct conversation *c; | |
| 73 | |
| 74 while (cnv) { | |
| 75 c = (struct conversation *) cnv->data; | |
| 76 | |
| 77 if (c && (c->gc == gc) && c->is_chat && (c->id == id)) | |
| 78 return c; | |
|
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
79 |
| 3710 | 80 cnv = cnv->next; |
|
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
81 } |
| 3710 | 82 return NULL; |
| 83 } | |
| 191 | 84 |
| 3710 | 85 int notify(struct conversation *cnv) { |
| 86 Window focus_return; | |
| 4035 | 87 int revert_to_return; |
| 191 | 88 |
| 3374 | 89 XGetInputFocus(GDK_WINDOW_XDISPLAY(cnv->window->window), &focus_return, &revert_to_return); |
| 90 | |
| 3392 | 91 if ((choice & NOTIFY_IN_FOCUS) || focus_return != GDK_WINDOW_XWINDOW(cnv->window->window)) { |
| 4035 | 92 if (method & METHOD_STRING) |
| 93 string_add(cnv->window); | |
| 94 if (method & METHOD_COUNT) | |
| 95 count_add(cnv->window); | |
| 96 if (method & METHOD_QUOTE) | |
| 97 quote_add(cnv->window); | |
| 98 if (method & METHOD_URGENT) | |
| 99 urgent_add(cnv); | |
| 3374 | 100 } |
| 101 return 0; | |
| 102 } | |
| 103 | |
| 4035 | 104 guint unnotify(struct conversation *c, gboolean clean) { |
| 105 guint option = 0; | |
| 4043 | 106 /* The top level ifs check whether we are either cleaning all methods, |
| 107 * or whether we have that method is currently selected. | |
| 108 * If we do then they are cleaned | |
| 109 * | |
| 110 * The second level ifs check if we removed something, | |
| 111 * and if that method is currently selected. | |
| 112 * If we did and it is then set option so that it can be re-added */ | |
| 4035 | 113 if (clean || (method & METHOD_QUOTE)) |
| 4043 | 114 if (quote_remove(c->window) && (method & METHOD_QUOTE)) |
| 4035 | 115 option ^= METHOD_QUOTE; |
| 116 if (clean || (method & METHOD_COUNT)) | |
| 4043 | 117 if (count_remove(c->window) && (method & METHOD_COUNT)) |
| 4035 | 118 option ^= METHOD_COUNT; |
| 119 if (clean || (method & METHOD_STRING)) | |
| 4043 | 120 if (string_remove(c->window) && (method & METHOD_STRING)) |
| 4035 | 121 option ^= METHOD_STRING; |
| 122 if (clean || (method & METHOD_URGENT)) | |
| 4043 | 123 if (urgent_remove(c) && (method & METHOD_URGENT)) |
| 4035 | 124 option ^= METHOD_URGENT; |
| 125 return option; | |
| 3374 | 126 } |
| 127 | |
| 3710 | 128 void chat_recv_im(struct gaim_connection *gc, int id, char **who, char **text) { |
| 129 struct conversation *c = find_chat(gc, id); | |
| 130 | |
| 131 if (c && (type & TYPE_CHAT)) | |
| 132 notify(c); | |
| 133 return; | |
| 134 } | |
| 135 | |
| 136 void chat_sent_im(struct gaim_connection *gc, int id, char **text) { | |
| 137 struct conversation *c = find_chat(gc, id); | |
| 138 | |
| 139 if (c && (type & TYPE_CHAT)) | |
| 4035 | 140 unnotify(c, FALSE); |
| 3710 | 141 return; |
| 142 } | |
| 143 | |
| 144 int im_recv_im(struct gaim_connection *gc, char **who, char **what, void *m) { | |
| 145 struct conversation *c = find_conversation(*who); | |
| 146 | |
| 147 if (c && (type & TYPE_IM)) | |
| 148 notify(c); | |
| 149 return 0; | |
| 150 } | |
| 151 | |
| 152 int im_sent_im(struct gaim_connection *gc, char *who, char **what, void *m) { | |
| 3374 | 153 struct conversation *c = find_conversation(who); |
| 154 | |
| 3710 | 155 if (c && (type & TYPE_IM)) |
| 4035 | 156 unnotify(c, FALSE); |
| 3710 | 157 return 0; |
| 158 } | |
| 3392 | 159 |
| 3710 | 160 int attach_signals(struct conversation *c) { |
| 3392 | 161 if (choice & NOTIFY_FOCUS) { |
| 4035 | 162 g_signal_connect(G_OBJECT(c->window), "focus-in-event", G_CALLBACK(un_star), NULL); |
| 3374 | 163 } |
| 3710 | 164 |
| 165 if (choice & NOTIFY_CLICK) { | |
| 4035 | 166 g_signal_connect(G_OBJECT(c->window), "button_press_event", G_CALLBACK(un_star), NULL); |
| 167 | |
| 168 g_signal_connect(G_OBJECT(c->text), "button_press_event", G_CALLBACK(un_star_window), NULL); | |
| 169 | |
| 170 g_signal_connect(G_OBJECT(c->entry), "button_press_event", G_CALLBACK(un_star_window), NULL); | |
| 3374 | 171 } |
| 172 | |
| 3392 | 173 if (choice & NOTIFY_TYPE) { |
| 4035 | 174 g_signal_connect(G_OBJECT(c->entry), "key-press-event", G_CALLBACK(un_star_window), NULL); |
| 191 | 175 } |
| 4035 | 176 |
| 4043 | 177 g_object_set_data(G_OBJECT(c->window), "user_data", c); |
| 4035 | 178 g_object_set_data(G_OBJECT(c->window), "notify_data", GUINT_TO_POINTER(choice)); |
| 3428 | 179 return 0; |
| 191 | 180 } |
| 181 | |
| 3710 | 182 void new_conv(char *who) { |
| 4035 | 183 struct conversation *c = find_conversation(who); |
| 3710 | 184 |
| 4035 | 185 if (c && (type & TYPE_IM)) |
| 3710 | 186 attach_signals(c); |
| 187 return; | |
| 188 } | |
| 189 | |
| 190 void chat_join(struct gaim_connection *gc, int id, char *room) { | |
| 191 struct conversation *c = find_chat(gc, id); | |
| 192 | |
| 4043 | 193 if (c && (type & TYPE_CHAT)) |
| 3710 | 194 attach_signals(c); |
| 195 return; | |
| 196 } | |
| 197 | |
| 3374 | 198 void un_star(GtkWidget *widget, gpointer data) { |
| 4043 | 199 struct conversation *c = g_object_get_data(G_OBJECT(widget), "user_data"); |
| 3374 | 200 |
| 201 if (method & METHOD_QUOTE) | |
| 202 quote_remove(widget); | |
| 3392 | 203 if (method & METHOD_COUNT) |
| 204 count_remove(widget); | |
| 3374 | 205 if (method & METHOD_STRING) |
| 206 string_remove(widget); | |
| 4043 | 207 if (c && method & METHOD_URGENT) |
| 3374 | 208 urgent_remove(c); |
| 209 return; | |
| 210 } | |
| 211 | |
| 4043 | 212 void un_star_window(GtkWidget *widget, gpointer data) { |
| 3374 | 213 GtkWidget *parent = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW); |
| 214 un_star(parent, data); | |
| 4043 | 215 return; |
| 3374 | 216 } |
| 217 | |
| 3392 | 218 /* This function returns the number in [ ]'s or 0 */ |
| 219 int counter (char *buf, int *length) { | |
| 220 char temp[256]; | |
| 221 int i = 1; | |
| 222 *length = 0; | |
| 223 | |
| 224 while (isdigit(buf[i]) && i<sizeof(buf)) { | |
| 225 temp[i-1] = buf[i]; | |
| 226 (*length)++; | |
| 227 i++; | |
| 228 } | |
| 229 temp[i] = '\0'; | |
| 4035 | 230 |
| 3392 | 231 if (buf[i] != ']') { |
| 232 *length = 0; | |
| 233 return (0); | |
| 234 } | |
| 235 | |
| 236 return (atoi(temp)); | |
| 237 } | |
| 238 | |
| 4035 | 239 void string_add(GtkWidget *widget) { |
| 240 char buf[256]; | |
| 241 GtkWindow *win = GTK_WINDOW(widget); | |
| 242 | |
| 243 strncpy(buf, win->title, sizeof(buf)); | |
| 244 if (!strstr(buf, title_string)) { | |
| 245 g_snprintf(buf, sizeof(buf), "%s%s", title_string, win->title); | |
| 246 gtk_window_set_title(win, buf); | |
| 247 } | |
| 248 } | |
| 249 | |
| 250 gboolean string_remove(GtkWidget *widget) { | |
| 191 | 251 char buf[256]; |
| 3374 | 252 GtkWindow *win = GTK_WINDOW(widget); |
| 253 | |
| 3392 | 254 strncpy(buf, win->title, sizeof(buf)); |
| 3374 | 255 if (strstr(buf, title_string)) { |
| 256 g_snprintf(buf, sizeof(buf), "%s", &win->title[strlen(title_string)]); | |
| 257 gtk_window_set_title(win, buf); | |
| 4035 | 258 return TRUE; |
| 3374 | 259 } |
| 4035 | 260 return FALSE; |
| 3374 | 261 } |
| 262 | |
| 4035 | 263 void count_add(GtkWidget *widget) { |
| 264 char buf[256]; | |
| 265 int c, length; | |
| 266 GtkWindow *win = GTK_WINDOW(widget); | |
| 267 | |
| 268 strncpy(buf, win->title, sizeof(buf)); | |
| 269 c = counter(buf, &length); | |
| 270 if (!c) { | |
| 271 g_snprintf(buf, sizeof(buf), "[1] %s", win->title); | |
| 272 } | |
| 273 else if (!g_strncasecmp(buf, "[", 1)) { | |
| 274 g_snprintf(buf, sizeof(buf), "[%d] %s", c+1, &win->title[3+length]); | |
| 275 } | |
| 276 gtk_window_set_title(win, buf); | |
| 277 } | |
| 278 | |
| 279 gboolean count_remove(GtkWidget *widget) { | |
| 3392 | 280 char buf[256]; |
| 281 GtkWindow *win = GTK_WINDOW(widget); | |
| 282 int length; | |
| 283 | |
| 284 strncpy(buf, win->title, sizeof(buf)); | |
| 285 if (!g_strncasecmp(buf, "[", 1)) { | |
| 286 counter(buf, &length); | |
| 287 g_snprintf(buf, sizeof(buf), "%s", &win->title[3+length]); | |
| 288 gtk_window_set_title(win, buf); | |
| 4035 | 289 return TRUE; |
| 3392 | 290 } |
| 4035 | 291 return FALSE; |
| 3392 | 292 } |
| 293 | |
| 4035 | 294 void quote_add(GtkWidget *widget) { |
| 295 char buf[256]; | |
| 296 GtkWindow *win = GTK_WINDOW(widget); | |
| 297 | |
| 298 strncpy(buf, win->title, sizeof(buf)); | |
| 299 if (g_strncasecmp(buf, "\"", 1)) { | |
| 300 g_snprintf(buf, sizeof(buf), "\"%s\"", win->title); | |
| 301 gtk_window_set_title(win, buf); | |
| 302 } | |
| 303 } | |
| 304 | |
| 305 gboolean quote_remove(GtkWidget *widget) { | |
| 3374 | 306 char buf[256]; |
| 307 GtkWindow *win = GTK_WINDOW(widget); | |
| 191 | 308 |
| 3392 | 309 strncpy(buf, win->title, sizeof(buf)); |
| 3374 | 310 if (!g_strncasecmp(buf, "\"", 1)) { |
| 311 g_snprintf(buf, strlen(buf) - 1, "%s", &win->title[1]); | |
| 191 | 312 gtk_window_set_title(win, buf); |
| 4035 | 313 return TRUE; |
| 191 | 314 } |
| 4035 | 315 return FALSE; |
| 3374 | 316 } |
| 317 | |
| 4035 | 318 void urgent_add(struct conversation *c) { |
| 319 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window)); | |
| 320 hints->flags |= XUrgencyHint; | |
| 321 XSetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window), hints); | |
| 322 } | |
| 323 | |
| 324 gboolean urgent_remove(struct conversation *c) { | |
| 3374 | 325 GdkWindow *win = c->window->window; |
| 326 | |
| 3428 | 327 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win)); |
| 4035 | 328 if (hints->flags & XUrgencyHint) { |
| 329 hints->flags &= ~XUrgencyHint; | |
| 330 XSetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win), hints); | |
| 331 return TRUE; | |
| 332 } | |
| 333 return FALSE; | |
| 3374 | 334 } |
| 335 | |
| 336 void save_notify_prefs() { | |
| 3392 | 337 gchar buf[1000]; |
| 3374 | 338 FILE *fp; |
| 339 | |
| 340 snprintf(buf, 1000, "%s/.gaim/.notify", getenv("HOME")); | |
| 341 if (!(fp = fopen(buf, "w"))) { | |
| 3561 | 342 do_error_dialog(_("Unable to write to config file"), _("Notify plugin"), GAIM_ERROR); |
| 3374 | 343 return; |
| 344 } | |
| 345 | |
| 3710 | 346 fprintf(fp, "%d=TYPE\n", type); |
| 3392 | 347 fprintf(fp, "%d=CHOICE\n", choice); |
| 348 fprintf(fp, "%d=METHOD\n", method); | |
| 349 fprintf(fp, "%s=STRING\n", title_string); | |
| 3374 | 350 fclose(fp); |
| 351 } | |
| 352 | |
| 353 void load_notify_prefs() { | |
| 354 gchar buf[1000]; | |
| 355 gchar **parsed; | |
| 356 FILE *fp; | |
| 357 | |
| 358 g_snprintf(buf, sizeof(buf), "%s/.gaim/.notify", getenv("HOME")); | |
| 359 if (!(fp = fopen(buf, "r"))) | |
| 360 return; | |
| 361 | |
| 362 while (fgets(buf, 1000, fp) != NULL) { | |
| 363 parsed = g_strsplit(g_strchomp(buf), "=", 2); | |
| 364 if (parsed[0] && parsed[1]) { | |
| 3710 | 365 if (!strcmp(parsed[1], "TYPE")) |
| 366 type = atoi(parsed[0]); | |
| 3392 | 367 if (!strcmp(parsed[1], "CHOICE")) |
| 368 choice = atoi(parsed[0]); | |
| 369 if (!strcmp(parsed[1], "METHOD")) | |
| 370 method = atoi(parsed[0]); | |
| 371 if (!strcmp(parsed[1], "STRING")) | |
| 372 if (title_string != NULL) g_free(title_string); | |
| 3710 | 373 title_string = g_strdup(parsed[0]); |
| 3374 | 374 } |
| 3392 | 375 g_strfreev(parsed); |
| 3374 | 376 } |
| 377 fclose(fp); | |
| 378 return; | |
| 379 } | |
| 380 | |
| 381 void options(GtkWidget *widget, gpointer data) { | |
| 4035 | 382 gint option = GPOINTER_TO_INT(data); |
| 3374 | 383 |
| 384 if (option == 0) | |
| 3392 | 385 choice ^= NOTIFY_FOCUS; |
| 3374 | 386 else if (option == 1) |
| 3710 | 387 choice ^= NOTIFY_CLICK; |
| 388 else if (option == 2) | |
| 3392 | 389 choice ^= NOTIFY_TYPE; |
| 3710 | 390 else if (option == 3) { |
| 3374 | 391 method ^= METHOD_STRING; |
| 392 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) | |
| 393 gtk_widget_set_sensitive(Entry, TRUE); | |
| 394 else | |
| 395 gtk_widget_set_sensitive(Entry, FALSE); | |
| 396 } | |
| 3710 | 397 else if (option == 4) |
| 3374 | 398 method ^= METHOD_QUOTE; |
| 3710 | 399 else if (option == 5) |
| 3374 | 400 method ^= METHOD_URGENT; |
| 3710 | 401 else if (option == 6) |
| 3392 | 402 choice ^= NOTIFY_IN_FOCUS; |
| 3710 | 403 else if (option == 7) |
| 3392 | 404 method ^= METHOD_COUNT; |
| 3710 | 405 else if (option == 8) |
| 406 type ^= TYPE_IM; | |
| 407 else if (option == 9) | |
| 408 type ^= TYPE_CHAT; | |
| 409 | |
| 410 save_notify_prefs(); | |
| 3374 | 411 } |
| 412 | |
| 4035 | 413 void apply_options(GtkWidget *widget, gpointer data) { |
| 414 GList *cnv = conversations; | |
| 415 | |
| 416 while (cnv) { | |
| 417 guint notification; | |
| 418 struct conversation *c = (struct conversation *) cnv->data; | |
| 419 guint options = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(c->window), "notify_data")); | |
| 420 | |
| 421 if (options & NOTIFY_FOCUS) | |
| 422 g_signal_handlers_disconnect_by_func(G_OBJECT(c->window), un_star, NULL); | |
| 423 | |
| 424 if (options & NOTIFY_CLICK) { | |
| 425 g_signal_handlers_disconnect_by_func(G_OBJECT(c->window), un_star, NULL); | |
| 426 g_signal_handlers_disconnect_by_func(G_OBJECT(c->text), un_star_window, NULL); | |
| 427 g_signal_handlers_disconnect_by_func(G_OBJECT(c->entry), un_star_window, NULL); | |
| 428 } | |
| 429 | |
| 430 if (options & NOTIFY_TYPE) | |
| 431 g_signal_handlers_disconnect_by_func(G_OBJECT(c->entry), un_star_window, NULL); | |
| 432 | |
| 4043 | 433 /* works except for count, always get reset to [1] */ |
| 4035 | 434 /* clean off all notification markings */ |
| 435 notification = unnotify(c, TRUE); | |
| 436 /* re-add appropriate notification methods cleaned above */ | |
| 4043 | 437 if (notification & METHOD_STRING) /* re-add string */ |
| 438 string_add(c->window); | |
| 4035 | 439 if (notification & METHOD_QUOTE) /* re-add quote */ |
| 440 quote_add(c->window); | |
| 441 if (notification & METHOD_COUNT) /* re-add count */ | |
| 442 count_add(c->window); | |
| 443 if (notification & METHOD_URGENT) /* re-add urgent */ | |
| 444 urgent_add(c); | |
| 445 /* attach new unnotification signals */ | |
| 446 attach_signals(c); | |
| 447 | |
| 448 cnv = cnv->next; | |
| 449 } | |
| 450 | |
| 451 return; | |
| 452 } | |
| 453 | |
|
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
454 char *gaim_plugin_init(GModule *hndl) { |
| 191 | 455 handle = hndl; |
| 456 | |
| 3374 | 457 load_notify_prefs(); |
| 458 | |
| 3710 | 459 gaim_signal_connect(handle, event_im_recv, im_recv_im, NULL); |
| 460 gaim_signal_connect(handle, event_chat_recv, chat_recv_im, NULL); | |
| 461 gaim_signal_connect(handle, event_im_send, im_sent_im, NULL); | |
| 462 gaim_signal_connect(handle, event_chat_send, chat_sent_im, NULL); | |
| 3374 | 463 gaim_signal_connect(handle, event_new_conversation, new_conv, NULL); |
| 3710 | 464 gaim_signal_connect(handle, event_chat_join, chat_join, NULL); |
|
1052
25f121faa75e
[gaim-migrate @ 1062]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
465 return NULL; |
| 191 | 466 } |
| 467 | |
| 3392 | 468 void gaim_plugin_remove() { |
| 469 GList *c = conversations; | |
| 470 | |
| 471 while (c) { | |
| 472 struct conversation *cnv = (struct conversation *)c->data; | |
| 3710 | 473 un_star(cnv->window, NULL); |
| 474 c = c->next; | |
| 3392 | 475 } |
| 476 } | |
| 477 | |
| 3551 | 478 struct gaim_plugin_description desc; |
| 479 struct gaim_plugin_description *gaim_plugin_desc() { | |
| 480 desc.api_version = PLUGIN_API_VERSION; | |
| 481 desc.name = g_strdup("Message Notification"); | |
| 482 desc.version = g_strdup(VERSION); | |
| 483 desc.description = g_strdup("Provides a variety of ways of notifying you of unread messages."); | |
| 484 desc.authors = g_strdup("Etan Reisner <deryni@eden.rutgers.edu>"); | |
| 485 desc.url = g_strdup(WEBSITE); | |
| 486 return &desc; | |
| 487 } | |
| 488 | |
| 191 | 489 char *name() { |
| 490 return "Visual Notification"; | |
| 491 } | |
| 492 | |
| 493 char *description() { | |
| 494 return "Puts an asterisk in the title bar of all conversations" | |
| 495 " where you have not responded to a message yet."; | |
| 496 } | |
| 3374 | 497 |
| 3565 | 498 GtkWidget *gaim_plugin_config_gtk() { |
| 499 GtkWidget *ret; | |
| 500 GtkWidget *vbox, *hbox; | |
| 4035 | 501 GtkWidget *toggle, *button; |
| 3565 | 502 ret = gtk_vbox_new(FALSE, 18); |
| 503 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); | |
| 3392 | 504 |
| 3710 | 505 vbox = make_frame(ret, _("Notify For")); |
| 506 toggle = gtk_check_button_new_with_mnemonic(_("_IM windows")); | |
| 507 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 508 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), type & TYPE_IM); | |
| 509 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(7)); | |
| 510 | |
| 511 toggle = gtk_check_button_new_with_mnemonic(_("_Chat windows")); | |
| 512 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 513 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), type & TYPE_CHAT); | |
| 514 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(8)); | |
| 515 | |
| 516 /*--------------*/ | |
| 3565 | 517 vbox = make_frame(ret, _("Notification Methods")); |
| 518 hbox = gtk_hbox_new(FALSE, 18); | |
| 519 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
| 520 toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:")); | |
| 521 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_STRING); | |
| 4035 | 522 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(3)); |
| 3565 | 523 gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); |
| 3374 | 524 Entry = gtk_entry_new_with_max_length(7); |
| 3565 | 525 gtk_widget_set_sensitive(GTK_WIDGET(Entry), method & METHOD_STRING); |
| 526 gtk_box_pack_start(GTK_BOX(hbox), Entry, FALSE, FALSE, 0); | |
| 3392 | 527 gtk_entry_set_text(GTK_ENTRY(Entry), title_string); |
| 3374 | 528 |
| 3710 | 529 toggle = gtk_check_button_new_with_mnemonic(_("_Quote window title")); |
| 3565 | 530 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 531 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_QUOTE); | |
| 4035 | 532 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(4)); |
| 3374 | 533 |
| 3565 | 534 toggle = gtk_check_button_new_with_mnemonic(_("Set Window Manager \"_URGENT\" Hint")); |
| 535 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 536 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_URGENT); | |
| 4035 | 537 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(5)); |
| 538 | |
| 3710 | 539 toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title")); |
| 3565 | 540 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_COUNT); |
| 541 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 4035 | 542 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(7)); |
| 3710 | 543 |
| 544 toggle = gtk_check_button_new_with_mnemonic(_("_Notify even if conversation is in focus")); | |
| 545 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_IN_FOCUS); | |
| 546 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 4035 | 547 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(6)); |
| 3392 | 548 |
| 3565 | 549 /*--------------*/ |
| 550 vbox = make_frame(ret, _("Notification Removal")); | |
| 3710 | 551 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window gains _focus")); |
| 3565 | 552 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 553 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_FOCUS); | |
| 4035 | 554 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(0)); |
| 3374 | 555 |
| 3710 | 556 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click")); |
| 557 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 558 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_CLICK); | |
| 4035 | 559 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(1)); |
| 3710 | 560 |
| 3565 | 561 toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); |
| 562 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 563 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_TYPE); | |
| 4035 | 564 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(2)); |
| 565 | |
| 566 button = gtk_button_new_with_mnemonic(_("Appl_y")); | |
| 567 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 5); | |
| 568 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(apply_options), NULL); | |
| 3565 | 569 |
| 570 gtk_widget_show_all(ret); | |
| 571 return ret; | |
| 3374 | 572 } |
