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