Mercurial > pidgin
annotate plugins/notify.c @ 3551:cd938f18f3f8
[gaim-migrate @ 3626]
In the interest of continued progress, I pulled what's usable out of my
development tree and am committing it.
Here, we have gotten rid of the plugins dialog and perl menu under Tools and
put them both in preferences. Perl scripts now work like plugins--you have
to load them explicitly (it will probe $prefix/lib/gaim and $HOME/.gaim for
them) and you can unload them (although right now, this is entirely unreliable)
Oh, and I broke all your perl scripts. Sorry about that. Don't try fixing
them yet, though--I'm gonna make unloading single scripts more reliable
tommorow.
I should also finish Phase Two tommorow as well.
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Thu, 26 Sep 2002 07:37:52 +0000 |
| parents | 7e1c6c16dd41 |
| children | 333551497ff8 |
| 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 | |
| 3392 | 6 * |
| 7 * Thanks to Carles Pina i Estany <carles@pinux.info> | |
| 8 * for count of new messages option | |
| 9 */ | |
| 10 | |
| 11 /* if my flash messages patch gets merged in can use cnv->local | |
| 12 * to notify on new messages also | |
| 3374 | 13 */ |
| 14 | |
| 191 | 15 #define GAIM_PLUGINS |
| 16 #include "gaim.h" | |
| 17 | |
| 3428 | 18 #include <string.h> |
| 19 #include <ctype.h> | |
| 20 #include <stdlib.h> | |
| 191 | 21 #include <gtk/gtk.h> |
| 3385 | 22 #include <X11/Xlib.h> |
| 3374 | 23 #include <X11/Xutil.h> |
| 3392 | 24 #include <X11/Xatom.h> |
| 3374 | 25 #include <gdk/gdkx.h> |
| 26 | |
| 3392 | 27 guint choice = 1; |
| 28 #define NOTIFY_FOCUS 0x00000001 | |
| 29 #define NOTIFY_TYPE 0x00000002 | |
| 30 #define NOTIFY_IN_FOCUS 0x00000004 | |
| 3374 | 31 |
| 3392 | 32 guint method = 1; |
| 33 #define METHOD_STRING 0x00000001 | |
| 34 #define METHOD_QUOTE 0x00000002 | |
| 35 #define METHOD_URGENT 0x00000004 | |
| 36 #define METHOD_COUNT 0x00000008 | |
| 191 | 37 |
| 38 void *handle; | |
| 3392 | 39 /* I really don't like this but I was having trouble getting any |
| 40 * other way of removing the signal callbacks to work and not crash gaim | |
| 41 */ | |
| 42 GtkWidget *really_evil_hack; | |
| 43 /* GHashTable *hash = NULL; */ | |
| 3374 | 44 GtkWidget *Dialog = NULL; |
| 3392 | 45 GtkWidget *Click, *Focus, *Type, *InFocus; |
| 46 GtkWidget *String, *Count, *Quote, *Urgent, *Entry; | |
| 47 gchar *title_string = "(*) "; | |
| 191 | 48 |
| 3374 | 49 /* predefine some functions, less warnings */ |
| 50 void options(GtkWidget *widget, gpointer data); | |
| 51 void un_star(GtkWidget *widget, gpointer data); | |
| 3511 | 52 int un_star_window(GtkWidget *widget, gpointer data); |
| 3374 | 53 void string_remove(GtkWidget *widget); |
| 3392 | 54 void count_remove(GtkWidget *widget); |
| 3374 | 55 void quote_remove(GtkWidget *widget); |
| 56 void urgent_remove(struct conversation *c); | |
| 3428 | 57 int counter (char *buf, int *length); |
| 3374 | 58 |
| 59 int received_im(struct gaim_connection *gc, char **who, char **what, void *m) { | |
| 191 | 60 char buf[256]; |
| 61 struct conversation *cnv = find_conversation(*who); | |
| 62 GtkWindow *win; | |
|
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
63 char *me = g_strdup(normalize(gc->username)); |
| 3374 | 64 int revert_to_return; |
| 65 Window focus_return; | |
| 3392 | 66 int c, length; |
|
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
67 |
|
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
68 if (!strcmp(me, normalize(*who))) { |
|
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
69 g_free(me); |
| 3374 | 70 return 0; |
|
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
71 } |
|
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
72 g_free(me); |
| 191 | 73 |
| 74 if (cnv == NULL) | |
| 3374 | 75 { |
| 76 if (away_options & OPT_AWAY_QUEUE) | |
| 77 return 0; | |
| 1835 | 78 |
| 3374 | 79 cnv = new_conversation(*who); |
| 80 } | |
| 191 | 81 |
| 82 win = (GtkWindow *)cnv->window; | |
| 83 | |
| 3374 | 84 XGetInputFocus(GDK_WINDOW_XDISPLAY(cnv->window->window), &focus_return, &revert_to_return); |
| 85 | |
| 3392 | 86 if ((choice & NOTIFY_IN_FOCUS) || focus_return != GDK_WINDOW_XWINDOW(cnv->window->window)) { |
| 3374 | 87 if (method & METHOD_STRING) { |
| 3392 | 88 strncpy(buf, win->title, sizeof(buf)); |
| 3374 | 89 if (!strstr(buf, title_string)) { |
| 3392 | 90 g_snprintf(buf, sizeof(buf), "%s%s", title_string, win->title); |
| 3374 | 91 gtk_window_set_title(win, buf); |
| 92 } | |
| 93 } | |
| 3392 | 94 if (method & METHOD_COUNT) { |
| 95 strncpy(buf, win->title, sizeof(buf)); | |
| 96 c = counter(buf, &length); | |
| 97 if (!c) { | |
| 98 g_snprintf(buf, sizeof(buf), "[1] %s", win->title); | |
| 99 } | |
| 100 else if (!g_strncasecmp(buf, "[", 1)) { | |
| 101 g_snprintf(buf, sizeof(buf), "[%d] %s", c+1, &win->title[3+length]); | |
| 102 } | |
| 103 gtk_window_set_title(win, buf); | |
| 104 } | |
| 3374 | 105 if (method & METHOD_QUOTE) { |
| 3392 | 106 strncpy(buf, win->title, sizeof(buf)); |
| 3374 | 107 if (g_strncasecmp(buf, "\"", 1)) { |
| 108 g_snprintf(buf, sizeof(buf), "\"%s\"", win->title); | |
| 109 gtk_window_set_title(win, buf); | |
| 110 } | |
| 111 } | |
| 112 if (method & METHOD_URGENT) { | |
| 3392 | 113 /* do it the gdk way for windows compatibility(?) if I can figure it out */ |
| 114 /* Sean says this is a bad thing, and I should try using gtk_property_get first */ | |
| 115 /* I'll want to pay attention to note on dev.gnome.org though */ | |
| 3374 | 116 /* gdk_property_change(win->window, WM_HINTS, WM_HINTS, 32, GDK_PROP_MODE_REPLACE, XUrgencyHint, 1); */ |
| 117 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(cnv->window->window), GDK_WINDOW_XWINDOW(cnv->window->window)); | |
| 118 hints->flags |= XUrgencyHint; | |
| 119 XSetWMHints(GDK_WINDOW_XDISPLAY(cnv->window->window), GDK_WINDOW_XWINDOW(cnv->window->window), hints); | |
| 120 } | |
| 121 } | |
| 122 | |
| 123 return 0; | |
| 124 } | |
| 125 | |
| 126 int sent_im(struct gaim_connection *gc, char *who, char **what, void *m) { | |
| 3428 | 127 /* char buf[256]; */ |
| 3374 | 128 struct conversation *c = find_conversation(who); |
| 129 | |
| 130 if (method & METHOD_QUOTE) | |
| 3392 | 131 quote_remove(c->window); |
| 132 if (method & METHOD_COUNT) | |
| 133 count_remove(c->window); | |
| 3374 | 134 if (method & METHOD_STRING) |
| 3392 | 135 string_remove(c->window); |
| 3374 | 136 if (method & METHOD_URGENT) |
| 137 urgent_remove(c); | |
| 138 return 0; | |
| 139 } | |
| 140 | |
| 141 int new_conv(char *who) { | |
| 142 struct conversation *c = find_conversation(who); | |
| 143 | |
| 3392 | 144 /* g_hash_table_insert(hash, who, GINT_TO_POINTER(choice)); */ |
| 145 | |
| 146 if (choice & NOTIFY_FOCUS) { | |
| 147 gtk_signal_connect_while_alive(GTK_OBJECT(c->window), "focus-in-event", GTK_SIGNAL_FUNC(un_star), NULL, GTK_OBJECT(really_evil_hack)); | |
| 3374 | 148 gtk_object_set_user_data(GTK_OBJECT(c->window), c); |
| 149 } | |
| 150 else { | |
| 3392 | 151 gtk_signal_connect_while_alive(GTK_OBJECT(c->window), "button_press_event", GTK_SIGNAL_FUNC(un_star), NULL, GTK_OBJECT(really_evil_hack)); |
| 3374 | 152 gtk_object_set_user_data(GTK_OBJECT(c->window), c); |
| 3392 | 153 gtk_signal_connect_while_alive(GTK_OBJECT(c->text), "button_press_event", GTK_SIGNAL_FUNC(un_star_window), NULL, GTK_OBJECT(really_evil_hack)); |
| 3374 | 154 gtk_object_set_user_data(GTK_OBJECT(c->text), c); |
| 3392 | 155 gtk_signal_connect_while_alive(GTK_OBJECT(c->entry), "button_press_event", GTK_SIGNAL_FUNC(un_star_window), NULL, GTK_OBJECT(really_evil_hack)); |
| 3374 | 156 gtk_object_set_user_data(GTK_OBJECT(c->entry), c); |
| 157 } | |
| 158 | |
| 3392 | 159 if (choice & NOTIFY_TYPE) { |
| 160 gtk_signal_connect_while_alive(GTK_OBJECT(c->entry), "key-press-event", GTK_SIGNAL_FUNC(un_star_window), NULL, GTK_OBJECT(really_evil_hack)); | |
| 3374 | 161 gtk_object_set_user_data(GTK_OBJECT(c->entry), (gpointer) c); |
| 191 | 162 } |
| 3428 | 163 return 0; |
| 191 | 164 } |
| 165 | |
| 3374 | 166 void un_star(GtkWidget *widget, gpointer data) { |
| 167 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(widget)); | |
| 168 | |
| 169 if (method & METHOD_QUOTE) | |
| 170 quote_remove(widget); | |
| 3392 | 171 if (method & METHOD_COUNT) |
| 172 count_remove(widget); | |
| 3374 | 173 if (method & METHOD_STRING) |
| 174 string_remove(widget); | |
| 175 if (method & METHOD_URGENT) | |
| 176 urgent_remove(c); | |
| 177 return; | |
| 178 } | |
| 179 | |
| 3511 | 180 int un_star_window(GtkWidget *widget, gpointer data) { |
| 3374 | 181 GtkWidget *parent = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW); |
| 182 gtk_object_set_user_data(GTK_OBJECT(parent), gtk_object_get_user_data(GTK_OBJECT(widget))); | |
| 183 un_star(parent, data); | |
| 3511 | 184 return 0; |
| 3374 | 185 } |
| 186 | |
| 3392 | 187 /* This function returns the number in [ ]'s or 0 */ |
| 188 int counter (char *buf, int *length) { | |
| 189 char temp[256]; | |
| 190 int i = 1; | |
| 191 *length = 0; | |
| 192 | |
| 193 /* if (buf[0] != '[') */ | |
| 194 /* return (0); */ | |
| 195 | |
| 196 while (isdigit(buf[i]) && i<sizeof(buf)) { | |
| 197 temp[i-1] = buf[i]; | |
| 198 (*length)++; | |
| 199 i++; | |
| 200 } | |
| 201 temp[i] = '\0'; | |
| 202 | |
| 203 if (buf[i] != ']') { | |
| 204 *length = 0; | |
| 205 return (0); | |
| 206 } | |
| 207 | |
| 208 return (atoi(temp)); | |
| 209 } | |
| 210 | |
| 3374 | 211 void string_remove(GtkWidget *widget) { |
| 191 | 212 char buf[256]; |
| 3374 | 213 GtkWindow *win = GTK_WINDOW(widget); |
| 214 | |
| 3392 | 215 strncpy(buf, win->title, sizeof(buf)); |
| 3374 | 216 if (strstr(buf, title_string)) { |
| 217 g_snprintf(buf, sizeof(buf), "%s", &win->title[strlen(title_string)]); | |
| 218 gtk_window_set_title(win, buf); | |
| 219 } | |
| 220 return; | |
| 221 } | |
| 222 | |
| 3392 | 223 void count_remove(GtkWidget *widget) { |
| 224 char buf[256]; | |
| 225 GtkWindow *win = GTK_WINDOW(widget); | |
| 226 int length; | |
| 227 | |
| 228 strncpy(buf, win->title, sizeof(buf)); | |
| 229 if (!g_strncasecmp(buf, "[", 1)) { | |
| 230 counter(buf, &length); | |
| 231 g_snprintf(buf, sizeof(buf), "%s", &win->title[3+length]); | |
| 232 gtk_window_set_title(win, buf); | |
| 233 } | |
| 234 return; | |
| 235 } | |
| 236 | |
| 3374 | 237 void quote_remove(GtkWidget *widget) { |
| 238 char buf[256]; | |
| 239 GtkWindow *win = GTK_WINDOW(widget); | |
| 191 | 240 |
| 3392 | 241 strncpy(buf, win->title, sizeof(buf)); |
| 3374 | 242 if (!g_strncasecmp(buf, "\"", 1)) { |
| 243 g_snprintf(buf, strlen(buf) - 1, "%s", &win->title[1]); | |
| 191 | 244 gtk_window_set_title(win, buf); |
| 245 } | |
| 3374 | 246 return; |
| 247 } | |
| 248 | |
| 249 void urgent_remove(struct conversation *c) { | |
| 250 GdkWindow *win = c->window->window; | |
| 251 | |
| 3428 | 252 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win)); |
| 3374 | 253 hints->flags &= ~XUrgencyHint; |
| 3428 | 254 XSetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win), hints); |
| 3374 | 255 return; |
| 256 } | |
| 257 | |
| 258 void save_notify_prefs() { | |
| 3392 | 259 gchar buf[1000]; |
| 3374 | 260 FILE *fp; |
| 261 | |
| 262 snprintf(buf, 1000, "%s/.gaim/.notify", getenv("HOME")); | |
| 263 if (!(fp = fopen(buf, "w"))) { | |
| 3551 | 264 do_eror_dialog(_("Unable to write to config file"), _("Notify plugin"), GAIM_ERROR); |
| 3374 | 265 return; |
| 266 } | |
| 267 | |
| 3392 | 268 fprintf(fp, "%d=CHOICE\n", choice); |
| 269 fprintf(fp, "%d=METHOD\n", method); | |
| 270 fprintf(fp, "%s=STRING\n", title_string); | |
| 3374 | 271 fclose(fp); |
| 272 } | |
| 273 | |
| 274 void load_notify_prefs() { | |
| 275 gchar buf[1000]; | |
| 276 gchar **parsed; | |
| 277 FILE *fp; | |
| 278 | |
| 279 g_snprintf(buf, sizeof(buf), "%s/.gaim/.notify", getenv("HOME")); | |
| 280 if (!(fp = fopen(buf, "r"))) | |
| 281 return; | |
| 282 | |
| 283 while (fgets(buf, 1000, fp) != NULL) { | |
| 284 parsed = g_strsplit(g_strchomp(buf), "=", 2); | |
| 285 if (parsed[0] && parsed[1]) { | |
| 3392 | 286 if (!strcmp(parsed[1], "CHOICE")) |
| 287 choice = atoi(parsed[0]); | |
| 288 if (!strcmp(parsed[1], "METHOD")) | |
| 289 method = atoi(parsed[0]); | |
| 290 if (!strcmp(parsed[1], "STRING")) | |
| 291 if (title_string != NULL) g_free(title_string); | |
| 292 title_string = g_strdup(parsed[0]); | |
| 3374 | 293 } |
| 3392 | 294 g_strfreev(parsed); |
| 3374 | 295 } |
| 296 fclose(fp); | |
| 297 return; | |
| 298 } | |
| 299 | |
| 300 void options(GtkWidget *widget, gpointer data) { | |
| 301 gint option = GPOINTER_TO_INT(data); | |
| 302 | |
| 303 if (option == 0) | |
| 3392 | 304 choice ^= NOTIFY_FOCUS; |
| 3374 | 305 else if (option == 1) |
| 3392 | 306 choice ^= NOTIFY_TYPE; |
| 3374 | 307 else if (option == 2) { |
| 308 method ^= METHOD_STRING; | |
| 309 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) | |
| 310 gtk_widget_set_sensitive(Entry, TRUE); | |
| 311 else | |
| 312 gtk_widget_set_sensitive(Entry, FALSE); | |
| 313 } | |
| 314 else if (option == 3) | |
| 315 method ^= METHOD_QUOTE; | |
| 316 else if (option == 4) | |
| 317 method ^= METHOD_URGENT; | |
| 3392 | 318 else if (option == 5) |
| 319 choice ^= NOTIFY_IN_FOCUS; | |
| 320 else if (option == 6) | |
| 321 method ^= METHOD_COUNT; | |
| 3374 | 322 } |
| 323 | |
| 324 void setup_buttons() { | |
| 3392 | 325 if (choice & NOTIFY_FOCUS) |
| 3374 | 326 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Focus), TRUE); |
| 327 else | |
| 328 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Click), TRUE); | |
| 3392 | 329 if (choice & NOTIFY_TYPE) |
| 3374 | 330 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Type), TRUE); |
| 331 else | |
| 332 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Type), FALSE); | |
| 333 | |
| 334 if (method & METHOD_STRING) | |
| 335 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(String), TRUE); | |
| 336 else | |
| 337 gtk_widget_set_sensitive(Entry, FALSE); | |
| 338 | |
| 339 if (method & METHOD_QUOTE) | |
| 340 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Quote), TRUE); | |
| 341 | |
| 342 if (method & METHOD_URGENT) | |
| 343 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Urgent), TRUE); | |
| 344 | |
| 3392 | 345 if (choice & NOTIFY_IN_FOCUS) |
| 346 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(InFocus), TRUE); | |
| 347 | |
| 348 if (method & METHOD_COUNT) | |
| 349 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Count), TRUE); | |
| 350 | |
| 3374 | 351 return; |
| 352 } | |
| 353 | |
| 354 void close_dialog(GtkWidget *widget, gpointer data) { | |
| 355 gint option = GPOINTER_TO_INT(data); | |
| 356 | |
| 357 if (option > 0) { | |
| 358 title_string = g_strdup(gtk_entry_get_text(GTK_ENTRY(Entry))); | |
| 359 save_notify_prefs(); | |
| 360 } | |
| 361 else if (option < 0) | |
| 362 load_notify_prefs(); | |
| 363 | |
| 364 if (Dialog) | |
| 365 gtk_widget_destroy(Dialog); | |
| 366 Dialog = NULL; | |
| 191 | 367 } |
| 368 | |
|
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
369 char *gaim_plugin_init(GModule *hndl) { |
| 191 | 370 handle = hndl; |
| 371 | |
| 3392 | 372 really_evil_hack = gtk_label_new(""); |
| 373 /* hash = g_hash_table_new(g_str_hash, g_int_equal); */ | |
| 374 | |
| 3374 | 375 load_notify_prefs(); |
| 376 | |
| 191 | 377 gaim_signal_connect(handle, event_im_recv, received_im, NULL); |
| 378 gaim_signal_connect(handle, event_im_send, sent_im, NULL); | |
| 3374 | 379 gaim_signal_connect(handle, event_new_conversation, new_conv, NULL); |
|
1052
25f121faa75e
[gaim-migrate @ 1062]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
380 |
|
25f121faa75e
[gaim-migrate @ 1062]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
381 return NULL; |
| 191 | 382 } |
| 383 | |
| 3392 | 384 void gaim_plugin_remove() { |
| 385 GList *c = conversations; | |
| 3428 | 386 /* guint options; */ |
| 3392 | 387 |
| 388 gtk_widget_destroy(really_evil_hack); | |
| 389 | |
| 390 while (c) { | |
| 391 struct conversation *cnv = (struct conversation *)c->data; | |
| 392 /* if (options = GPOINTER_TO_INT(g_hash_table_lookup(hash, cnv->name))) { */ | |
| 393 un_star(cnv->window, NULL); | |
| 394 /* if (options & REMOVE_FOCUS) */ | |
| 395 /* gtk_signal_disconnect_by_func(GTK_OBJECT(cnv->window), GTK_SIGNAL_FUNC(un_star), NULL); */ | |
| 396 /* else { */ | |
| 397 /* gtk_signal_disconnect_by_func(GTK_OBJECT(cnv->window), GTK_SIGNAL_FUNC(un_star), NULL); */ | |
| 398 /* gtk_signal_disconnect_by_func(GTK_OBJECT(cnv->text), GTK_SIGNAL_FUNC(un_star_window), NULL); */ | |
| 399 /* gtk_signal_disconnect_by_func(GTK_OBJECT(cnv->entry), GTK_SIGNAL_FUNC(un_star_window), NULL); */ | |
| 400 /* } */ | |
| 401 /* if (options & REMOVE_TYPE) */ | |
| 402 /* gtk_signal_disconnect_by_func(GTK_OBJECT(cnv->entry), GTK_SIGNAL_FUNC(un_star_window), NULL); */ | |
| 403 /* } */ | |
| 404 c = c->next; | |
| 405 } | |
| 406 } | |
| 407 | |
| 3551 | 408 struct gaim_plugin_description desc; |
| 409 struct gaim_plugin_description *gaim_plugin_desc() { | |
| 410 desc.api_version = PLUGIN_API_VERSION; | |
| 411 desc.name = g_strdup("Message Notification"); | |
| 412 desc.version = g_strdup(VERSION); | |
| 413 desc.description = g_strdup("Provides a variety of ways of notifying you of unread messages."); | |
| 414 desc.authors = g_strdup("Etan Reisner <deryni@eden.rutgers.edu>"); | |
| 415 desc.url = g_strdup(WEBSITE); | |
| 416 return &desc; | |
| 417 } | |
| 418 | |
| 191 | 419 char *name() { |
| 420 return "Visual Notification"; | |
| 421 } | |
| 422 | |
| 423 char *description() { | |
| 424 return "Puts an asterisk in the title bar of all conversations" | |
| 425 " where you have not responded to a message yet."; | |
| 426 } | |
| 3374 | 427 |
| 428 void gaim_plugin_config() { | |
| 429 GtkWidget *dialog_vbox; | |
| 430 GtkWidget *button, *label; | |
| 3392 | 431 GtkWidget *box, *box2, *box3, *box4, *frame; |
| 3374 | 432 |
| 433 if (Dialog) | |
| 434 return; | |
| 435 | |
| 436 /* main config dialog */ | |
| 437 Dialog = gtk_dialog_new(); | |
| 438 gtk_window_set_title(GTK_WINDOW(Dialog), "Notify plugin configuration"); | |
| 439 gtk_window_set_policy(GTK_WINDOW(Dialog), FALSE, FALSE, TRUE); | |
| 440 gtk_signal_connect(GTK_OBJECT(Dialog), "destroy", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(-1)); | |
| 441 | |
| 442 dialog_vbox = GTK_DIALOG(Dialog)->vbox; | |
| 443 | |
| 444 /* Ok and Cancel buttons */ | |
| 445 box = gtk_hbox_new(FALSE, 8); | |
| 446 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(Dialog)->action_area), box); | |
| 447 | |
| 448 button = gtk_button_new_with_label(_("Cancel")); | |
| 449 gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); | |
| 450 gtk_widget_set_usize(button, 80, -2); | |
| 451 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(0)); | |
| 452 | |
| 453 button = gtk_button_new_with_label(_("Ok")); | |
| 454 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); | |
| 455 gtk_widget_set_usize(button, 80, -2); | |
| 456 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(1)); | |
| 457 | |
| 3392 | 458 /* warning label */ |
| 459 label = gtk_label_new(_("Changes in notification removal options take effect only on new conversation windows")); | |
| 460 gtk_box_pack_start(GTK_BOX(dialog_vbox), label, FALSE, FALSE, 1); | |
| 461 | |
| 3374 | 462 /* main hbox */ |
| 463 box = gtk_hbox_new(FALSE, 0); | |
| 464 gtk_box_pack_start(GTK_BOX(dialog_vbox), box, FALSE, FALSE, 0); | |
| 465 | |
| 3392 | 466 box4 = gtk_vbox_new(FALSE, 0); |
| 467 gtk_box_pack_start(GTK_BOX(box), box4, FALSE, FALSE, 0); | |
| 468 | |
| 3374 | 469 /* un-notify choices */ |
| 470 frame = gtk_frame_new(_("Remove notification when:")); | |
| 3392 | 471 gtk_box_pack_start(GTK_BOX(box4), frame, FALSE, FALSE, 0); |
| 3374 | 472 |
| 473 box2 = gtk_vbox_new(FALSE, 0); | |
| 474 gtk_container_add(GTK_CONTAINER(frame), box2); | |
| 475 | |
| 476 Focus = gtk_radio_button_new_with_label(NULL, _("Conversation window gains focus.")); | |
| 477 gtk_box_pack_start(GTK_BOX(box2), Focus, FALSE, FALSE, 2); | |
| 478 | |
| 479 Click = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(Focus), _("Conversation window gets clicked.")); | |
| 480 gtk_box_pack_start(GTK_BOX(box2), Click, FALSE, FALSE, 2); | |
| 481 | |
| 482 Type = gtk_check_button_new_with_label(_("Type in conversation window")); | |
| 483 gtk_box_pack_start(GTK_BOX(box2), Type, FALSE, FALSE, 2); | |
| 484 | |
| 485 /* notification method choices */ | |
| 486 /* do I need/want any other notification methods? */ | |
| 487 frame = gtk_frame_new(_("Notification method:")); | |
| 488 gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 0); | |
| 489 | |
| 490 box2 = gtk_vbox_new(FALSE, 0); | |
| 491 gtk_container_add(GTK_CONTAINER(frame), box2); | |
| 492 | |
| 493 box3 = gtk_hbox_new(FALSE, 0); | |
| 494 gtk_box_pack_start(GTK_BOX(box2), box3, FALSE, FALSE, 0); | |
| 495 | |
| 496 String = gtk_check_button_new_with_label(_("Insert string into window title:")); | |
| 497 gtk_box_pack_start(GTK_BOX(box3), String, FALSE, FALSE, 0); | |
| 498 | |
| 499 Entry = gtk_entry_new_with_max_length(7); | |
| 500 gtk_box_pack_start(GTK_BOX(box3), Entry, FALSE, FALSE, 0); | |
| 3392 | 501 gtk_entry_set_text(GTK_ENTRY(Entry), title_string); |
| 3374 | 502 |
| 503 Quote = gtk_check_button_new_with_label(_("Quote window title.")); | |
| 504 gtk_box_pack_start(GTK_BOX(box2), Quote, FALSE, FALSE, 0); | |
| 505 | |
| 506 Urgent = gtk_check_button_new_with_label(_("Send URGENT to window manager.")); | |
| 507 gtk_box_pack_start(GTK_BOX(box2), Urgent, FALSE, FALSE, 0); | |
| 508 | |
| 3392 | 509 label = gtk_label_new(_("Function oddly with tabs:")); |
| 510 gtk_box_pack_start(GTK_BOX(box2), label, FALSE, FALSE, 0); | |
| 511 | |
| 512 Count = gtk_check_button_new_with_label(_("Insert count of new messages into window title")); | |
| 513 gtk_box_pack_start(GTK_BOX(box2), Count, FALSE, FALSE, 0); | |
| 514 | |
| 515 /* general options */ | |
| 516 frame = gtk_frame_new(_("General Options")); | |
| 517 gtk_box_pack_start(GTK_BOX(box4), frame, FALSE, FALSE, 0); | |
| 518 | |
| 519 box = gtk_vbox_new(FALSE, 0); | |
| 520 gtk_container_add(GTK_CONTAINER(frame), box); | |
| 521 | |
| 522 InFocus = gtk_check_button_new_with_label(_("Notify even when window is in focus")); | |
| 523 gtk_box_pack_start(GTK_BOX(box), InFocus, FALSE, FALSE, 0); | |
| 524 | |
| 3374 | 525 /* setup buttons, then attach signals */ |
| 526 setup_buttons(); | |
| 527 gtk_signal_connect(GTK_OBJECT(Focus), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(0)); | |
| 528 gtk_signal_connect(GTK_OBJECT(Type), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(1)); | |
| 529 gtk_signal_connect(GTK_OBJECT(String), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(2)); | |
| 530 gtk_signal_connect(GTK_OBJECT(Quote), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(3)); | |
| 531 gtk_signal_connect(GTK_OBJECT(Urgent), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(4)); | |
| 3392 | 532 gtk_signal_connect(GTK_OBJECT(InFocus), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(5)); |
| 533 gtk_signal_connect(GTK_OBJECT(Count), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(6)); | |
| 3374 | 534 |
| 535 gtk_widget_show_all(Dialog); | |
| 536 } |
