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