Mercurial > pidgin
annotate 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 |
| 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); | |
| 3511 | 55 int 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; | |
| 106 if (clean || (method & METHOD_QUOTE)) | |
| 107 if(quote_remove(c->window)) | |
| 108 option ^= METHOD_QUOTE; | |
| 109 if (clean || (method & METHOD_COUNT)) | |
| 110 if (count_remove(c->window)) | |
| 111 option ^= METHOD_COUNT; | |
| 112 if (clean || (method & METHOD_STRING)) | |
| 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; | |
| 3374 | 119 } |
| 120 | |
| 3710 | 121 void chat_recv_im(struct gaim_connection *gc, int id, char **who, char **text) { |
| 122 struct conversation *c = find_chat(gc, id); | |
| 123 | |
| 124 if (c && (type & TYPE_CHAT)) | |
| 125 notify(c); | |
| 126 return; | |
| 127 } | |
| 128 | |
| 129 void chat_sent_im(struct gaim_connection *gc, int id, char **text) { | |
| 130 struct conversation *c = find_chat(gc, id); | |
| 131 | |
| 132 if (c && (type & TYPE_CHAT)) | |
| 4035 | 133 unnotify(c, FALSE); |
| 3710 | 134 return; |
| 135 } | |
| 136 | |
| 137 int im_recv_im(struct gaim_connection *gc, char **who, char **what, void *m) { | |
| 138 struct conversation *c = find_conversation(*who); | |
| 139 | |
| 140 if (c && (type & TYPE_IM)) | |
| 141 notify(c); | |
| 142 return 0; | |
| 143 } | |
| 144 | |
| 145 int im_sent_im(struct gaim_connection *gc, char *who, char **what, void *m) { | |
| 3374 | 146 struct conversation *c = find_conversation(who); |
| 147 | |
| 3710 | 148 if (c && (type & TYPE_IM)) |
| 4035 | 149 unnotify(c, FALSE); |
| 3710 | 150 return 0; |
| 151 } | |
| 3392 | 152 |
| 3710 | 153 int attach_signals(struct conversation *c) { |
| 3392 | 154 if (choice & NOTIFY_FOCUS) { |
| 4035 | 155 g_signal_connect(G_OBJECT(c->window), "focus-in-event", G_CALLBACK(un_star), NULL); |
| 3374 | 156 } |
| 3710 | 157 |
| 158 if (choice & NOTIFY_CLICK) { | |
| 4035 | 159 g_signal_connect(G_OBJECT(c->window), "button_press_event", G_CALLBACK(un_star), NULL); |
| 160 | |
| 161 g_signal_connect(G_OBJECT(c->text), "button_press_event", G_CALLBACK(un_star_window), NULL); | |
| 162 | |
| 163 g_signal_connect(G_OBJECT(c->entry), "button_press_event", G_CALLBACK(un_star_window), NULL); | |
| 3374 | 164 } |
| 165 | |
| 3392 | 166 if (choice & NOTIFY_TYPE) { |
| 4035 | 167 g_signal_connect(G_OBJECT(c->entry), "key-press-event", G_CALLBACK(un_star_window), NULL); |
| 191 | 168 } |
| 4035 | 169 |
| 170 g_object_set_data(G_OBJECT(c->window), "notify_data", GUINT_TO_POINTER(choice)); | |
| 3428 | 171 return 0; |
| 191 | 172 } |
| 173 | |
| 3710 | 174 void new_conv(char *who) { |
| 4035 | 175 struct conversation *c = find_conversation(who); |
| 3710 | 176 |
| 4035 | 177 if (c && (type & TYPE_IM)) |
| 3710 | 178 attach_signals(c); |
| 179 return; | |
| 180 } | |
| 181 | |
| 182 void chat_join(struct gaim_connection *gc, int id, char *room) { | |
| 183 struct conversation *c = find_chat(gc, id); | |
| 184 | |
| 185 if (type & TYPE_CHAT) | |
| 186 attach_signals(c); | |
| 187 return; | |
| 188 } | |
| 189 | |
| 3374 | 190 void un_star(GtkWidget *widget, gpointer data) { |
| 191 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(widget)); | |
| 192 | |
| 193 if (method & METHOD_QUOTE) | |
| 194 quote_remove(widget); | |
| 3392 | 195 if (method & METHOD_COUNT) |
| 196 count_remove(widget); | |
| 3374 | 197 if (method & METHOD_STRING) |
| 198 string_remove(widget); | |
| 199 if (method & METHOD_URGENT) | |
| 200 urgent_remove(c); | |
| 201 return; | |
| 202 } | |
| 203 | |
| 3511 | 204 int un_star_window(GtkWidget *widget, gpointer data) { |
| 3374 | 205 GtkWidget *parent = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW); |
| 206 gtk_object_set_user_data(GTK_OBJECT(parent), gtk_object_get_user_data(GTK_OBJECT(widget))); | |
| 207 un_star(parent, data); | |
| 3511 | 208 return 0; |
| 3374 | 209 } |
| 210 | |
| 3392 | 211 /* This function returns the number in [ ]'s or 0 */ |
| 212 int counter (char *buf, int *length) { | |
| 213 char temp[256]; | |
| 214 int i = 1; | |
| 215 *length = 0; | |
| 216 | |
| 217 while (isdigit(buf[i]) && i<sizeof(buf)) { | |
| 218 temp[i-1] = buf[i]; | |
| 219 (*length)++; | |
| 220 i++; | |
| 221 } | |
| 222 temp[i] = '\0'; | |
| 4035 | 223 |
| 3392 | 224 if (buf[i] != ']') { |
| 225 *length = 0; | |
| 226 return (0); | |
| 227 } | |
| 228 | |
| 229 return (atoi(temp)); | |
| 230 } | |
| 231 | |
| 4035 | 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) { | |
| 191 | 244 char buf[256]; |
| 3374 | 245 GtkWindow *win = GTK_WINDOW(widget); |
| 246 | |
| 3392 | 247 strncpy(buf, win->title, sizeof(buf)); |
| 3374 | 248 if (strstr(buf, title_string)) { |
| 249 g_snprintf(buf, sizeof(buf), "%s", &win->title[strlen(title_string)]); | |
| 250 gtk_window_set_title(win, buf); | |
| 4035 | 251 return TRUE; |
| 3374 | 252 } |
| 4035 | 253 return FALSE; |
| 3374 | 254 } |
| 255 | |
| 4035 | 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) { | |
| 3392 | 273 char buf[256]; |
| 274 GtkWindow *win = GTK_WINDOW(widget); | |
| 275 int length; | |
| 276 | |
| 277 strncpy(buf, win->title, sizeof(buf)); | |
| 278 if (!g_strncasecmp(buf, "[", 1)) { | |
| 279 counter(buf, &length); | |
| 280 g_snprintf(buf, sizeof(buf), "%s", &win->title[3+length]); | |
| 281 gtk_window_set_title(win, buf); | |
| 4035 | 282 return TRUE; |
| 3392 | 283 } |
| 4035 | 284 return FALSE; |
| 3392 | 285 } |
| 286 | |
| 4035 | 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) { | |
| 3374 | 299 char buf[256]; |
| 300 GtkWindow *win = GTK_WINDOW(widget); | |
| 191 | 301 |
| 3392 | 302 strncpy(buf, win->title, sizeof(buf)); |
| 3374 | 303 if (!g_strncasecmp(buf, "\"", 1)) { |
| 304 g_snprintf(buf, strlen(buf) - 1, "%s", &win->title[1]); | |
| 191 | 305 gtk_window_set_title(win, buf); |
| 4035 | 306 return TRUE; |
| 191 | 307 } |
| 4035 | 308 return FALSE; |
| 3374 | 309 } |
| 310 | |
| 4035 | 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) { | |
| 3374 | 318 GdkWindow *win = c->window->window; |
| 319 | |
| 3428 | 320 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win)); |
| 4035 | 321 if (hints->flags & XUrgencyHint) { |
| 322 hints->flags &= ~XUrgencyHint; | |
| 323 XSetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win), hints); | |
| 324 return TRUE; | |
| 325 } | |
| 326 return FALSE; | |
| 3374 | 327 } |
| 328 | |
| 329 void save_notify_prefs() { | |
| 3392 | 330 gchar buf[1000]; |
| 3374 | 331 FILE *fp; |
| 332 | |
| 333 snprintf(buf, 1000, "%s/.gaim/.notify", getenv("HOME")); | |
| 334 if (!(fp = fopen(buf, "w"))) { | |
| 3561 | 335 do_error_dialog(_("Unable to write to config file"), _("Notify plugin"), GAIM_ERROR); |
| 3374 | 336 return; |
| 337 } | |
| 338 | |
| 3710 | 339 fprintf(fp, "%d=TYPE\n", type); |
| 3392 | 340 fprintf(fp, "%d=CHOICE\n", choice); |
| 341 fprintf(fp, "%d=METHOD\n", method); | |
| 342 fprintf(fp, "%s=STRING\n", title_string); | |
| 3374 | 343 fclose(fp); |
| 344 } | |
| 345 | |
| 346 void load_notify_prefs() { | |
| 347 gchar buf[1000]; | |
| 348 gchar **parsed; | |
| 349 FILE *fp; | |
| 350 | |
| 351 g_snprintf(buf, sizeof(buf), "%s/.gaim/.notify", getenv("HOME")); | |
| 352 if (!(fp = fopen(buf, "r"))) | |
| 353 return; | |
| 354 | |
| 355 while (fgets(buf, 1000, fp) != NULL) { | |
| 356 parsed = g_strsplit(g_strchomp(buf), "=", 2); | |
| 357 if (parsed[0] && parsed[1]) { | |
| 3710 | 358 if (!strcmp(parsed[1], "TYPE")) |
| 359 type = atoi(parsed[0]); | |
| 3392 | 360 if (!strcmp(parsed[1], "CHOICE")) |
| 361 choice = atoi(parsed[0]); | |
| 362 if (!strcmp(parsed[1], "METHOD")) | |
| 363 method = atoi(parsed[0]); | |
| 364 if (!strcmp(parsed[1], "STRING")) | |
| 365 if (title_string != NULL) g_free(title_string); | |
| 3710 | 366 title_string = g_strdup(parsed[0]); |
| 3374 | 367 } |
| 3392 | 368 g_strfreev(parsed); |
| 3374 | 369 } |
| 370 fclose(fp); | |
| 371 return; | |
| 372 } | |
| 373 | |
| 374 void options(GtkWidget *widget, gpointer data) { | |
| 4035 | 375 gint option = GPOINTER_TO_INT(data); |
| 3374 | 376 |
| 377 if (option == 0) | |
| 3392 | 378 choice ^= NOTIFY_FOCUS; |
| 3374 | 379 else if (option == 1) |
| 3710 | 380 choice ^= NOTIFY_CLICK; |
| 381 else if (option == 2) | |
| 3392 | 382 choice ^= NOTIFY_TYPE; |
| 3710 | 383 else if (option == 3) { |
| 3374 | 384 method ^= METHOD_STRING; |
| 385 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) | |
| 386 gtk_widget_set_sensitive(Entry, TRUE); | |
| 387 else | |
| 388 gtk_widget_set_sensitive(Entry, FALSE); | |
| 389 } | |
| 3710 | 390 else if (option == 4) |
| 3374 | 391 method ^= METHOD_QUOTE; |
| 3710 | 392 else if (option == 5) |
| 3374 | 393 method ^= METHOD_URGENT; |
| 3710 | 394 else if (option == 6) |
| 3392 | 395 choice ^= NOTIFY_IN_FOCUS; |
| 3710 | 396 else if (option == 7) |
| 3392 | 397 method ^= METHOD_COUNT; |
| 3710 | 398 else if (option == 8) |
| 399 type ^= TYPE_IM; | |
| 400 else if (option == 9) | |
| 401 type ^= TYPE_CHAT; | |
| 402 | |
| 403 save_notify_prefs(); | |
| 3374 | 404 } |
| 405 | |
| 4035 | 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 | |
|
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
448 char *gaim_plugin_init(GModule *hndl) { |
| 191 | 449 handle = hndl; |
| 450 | |
| 3374 | 451 load_notify_prefs(); |
| 452 | |
| 3710 | 453 gaim_signal_connect(handle, event_im_recv, im_recv_im, NULL); |
| 454 gaim_signal_connect(handle, event_chat_recv, chat_recv_im, NULL); | |
| 455 gaim_signal_connect(handle, event_im_send, im_sent_im, NULL); | |
| 456 gaim_signal_connect(handle, event_chat_send, chat_sent_im, NULL); | |
| 3374 | 457 gaim_signal_connect(handle, event_new_conversation, new_conv, NULL); |
| 3710 | 458 gaim_signal_connect(handle, event_chat_join, chat_join, NULL); |
|
1052
25f121faa75e
[gaim-migrate @ 1062]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
459 return NULL; |
| 191 | 460 } |
| 461 | |
| 3392 | 462 void gaim_plugin_remove() { |
| 463 GList *c = conversations; | |
| 464 | |
| 465 while (c) { | |
| 466 struct conversation *cnv = (struct conversation *)c->data; | |
| 3710 | 467 un_star(cnv->window, NULL); |
| 468 c = c->next; | |
| 3392 | 469 } |
| 470 } | |
| 471 | |
| 3551 | 472 struct gaim_plugin_description desc; |
| 473 struct gaim_plugin_description *gaim_plugin_desc() { | |
| 474 desc.api_version = PLUGIN_API_VERSION; | |
| 475 desc.name = g_strdup("Message Notification"); | |
| 476 desc.version = g_strdup(VERSION); | |
| 477 desc.description = g_strdup("Provides a variety of ways of notifying you of unread messages."); | |
| 478 desc.authors = g_strdup("Etan Reisner <deryni@eden.rutgers.edu>"); | |
| 479 desc.url = g_strdup(WEBSITE); | |
| 480 return &desc; | |
| 481 } | |
| 482 | |
| 191 | 483 char *name() { |
| 484 return "Visual Notification"; | |
| 485 } | |
| 486 | |
| 487 char *description() { | |
| 488 return "Puts an asterisk in the title bar of all conversations" | |
| 489 " where you have not responded to a message yet."; | |
| 490 } | |
| 3374 | 491 |
| 3565 | 492 GtkWidget *gaim_plugin_config_gtk() { |
| 493 GtkWidget *ret; | |
| 494 GtkWidget *vbox, *hbox; | |
| 4035 | 495 GtkWidget *toggle, *button; |
| 3565 | 496 ret = gtk_vbox_new(FALSE, 18); |
| 497 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); | |
| 3392 | 498 |
| 3710 | 499 vbox = make_frame(ret, _("Notify For")); |
| 500 toggle = gtk_check_button_new_with_mnemonic(_("_IM windows")); | |
| 501 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 502 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), type & TYPE_IM); | |
| 503 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(7)); | |
| 504 | |
| 505 toggle = gtk_check_button_new_with_mnemonic(_("_Chat windows")); | |
| 506 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 507 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), type & TYPE_CHAT); | |
| 508 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(8)); | |
| 509 | |
| 510 /*--------------*/ | |
| 3565 | 511 vbox = make_frame(ret, _("Notification Methods")); |
| 512 hbox = gtk_hbox_new(FALSE, 18); | |
| 513 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
| 514 toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:")); | |
| 515 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_STRING); | |
| 4035 | 516 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(3)); |
| 3565 | 517 gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); |
| 3374 | 518 Entry = gtk_entry_new_with_max_length(7); |
| 3565 | 519 gtk_widget_set_sensitive(GTK_WIDGET(Entry), method & METHOD_STRING); |
| 520 gtk_box_pack_start(GTK_BOX(hbox), Entry, FALSE, FALSE, 0); | |
| 3392 | 521 gtk_entry_set_text(GTK_ENTRY(Entry), title_string); |
| 3374 | 522 |
| 3710 | 523 toggle = gtk_check_button_new_with_mnemonic(_("_Quote window title")); |
| 3565 | 524 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 525 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_QUOTE); | |
| 4035 | 526 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(4)); |
| 3374 | 527 |
| 3565 | 528 toggle = gtk_check_button_new_with_mnemonic(_("Set Window Manager \"_URGENT\" Hint")); |
| 529 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 530 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_URGENT); | |
| 4035 | 531 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(5)); |
| 532 | |
| 3710 | 533 toggle = gtk_check_button_new_with_mnemonic(_("Insert c_ount of new messages into window title")); |
| 3565 | 534 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_COUNT); |
| 535 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 4035 | 536 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(7)); |
| 3710 | 537 |
| 538 toggle = gtk_check_button_new_with_mnemonic(_("_Notify even if conversation is in focus")); | |
| 539 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_IN_FOCUS); | |
| 540 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 4035 | 541 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(6)); |
| 3392 | 542 |
| 3565 | 543 /*--------------*/ |
| 544 vbox = make_frame(ret, _("Notification Removal")); | |
| 3710 | 545 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window gains _focus")); |
| 3565 | 546 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 547 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_FOCUS); | |
| 4035 | 548 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(0)); |
| 3374 | 549 |
| 3710 | 550 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window _receives click")); |
| 551 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 552 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_CLICK); | |
| 4035 | 553 g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(options), GINT_TO_POINTER(1)); |
| 3710 | 554 |
| 3565 | 555 toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); |
| 556 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 557 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_TYPE); | |
| 4035 | 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); | |
| 3565 | 563 |
| 564 gtk_widget_show_all(ret); | |
| 565 return ret; | |
| 3374 | 566 } |
