Fri, 30 Aug 2002 03:39:00 +0000
[gaim-migrate @ 3528]
- gdk_pixbuf_unref(icon);
| 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); | |
| 52 | void un_star_window(GtkWidget *widget, gpointer data); | |
| 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
783f8520d9a0
[gaim-migrate @ 1057]
Eric Warmenhoven <warmenhoven@yahoo.com>
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
783f8520d9a0
[gaim-migrate @ 1057]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1000
diff
changeset
|
67 | |
|
783f8520d9a0
[gaim-migrate @ 1057]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1000
diff
changeset
|
68 | if (!strcmp(me, normalize(*who))) { |
|
783f8520d9a0
[gaim-migrate @ 1057]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1000
diff
changeset
|
69 | g_free(me); |
| 3374 | 70 | return 0; |
|
1047
783f8520d9a0
[gaim-migrate @ 1057]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1000
diff
changeset
|
71 | } |
|
783f8520d9a0
[gaim-migrate @ 1057]
Eric Warmenhoven <warmenhoven@yahoo.com>
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 | ||
| 180 | void un_star_window(GtkWidget *widget, gpointer data) { | |
| 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); | |
| 184 | } | |
| 185 | ||
| 3392 | 186 | /* This function returns the number in [ ]'s or 0 */ |
| 187 | int counter (char *buf, int *length) { | |
| 188 | char temp[256]; | |
| 189 | int i = 1; | |
| 190 | *length = 0; | |
| 191 | ||
| 192 | /* if (buf[0] != '[') */ | |
| 193 | /* return (0); */ | |
| 194 | ||
| 195 | while (isdigit(buf[i]) && i<sizeof(buf)) { | |
| 196 | temp[i-1] = buf[i]; | |
| 197 | (*length)++; | |
| 198 | i++; | |
| 199 | } | |
| 200 | temp[i] = '\0'; | |
| 201 | ||
| 202 | if (buf[i] != ']') { | |
| 203 | *length = 0; | |
| 204 | return (0); | |
| 205 | } | |
| 206 | ||
| 207 | return (atoi(temp)); | |
| 208 | } | |
| 209 | ||
| 3374 | 210 | void string_remove(GtkWidget *widget) { |
| 191 | 211 | char buf[256]; |
| 3374 | 212 | GtkWindow *win = GTK_WINDOW(widget); |
| 213 | ||
| 3392 | 214 | strncpy(buf, win->title, sizeof(buf)); |
| 3374 | 215 | if (strstr(buf, title_string)) { |
| 216 | g_snprintf(buf, sizeof(buf), "%s", &win->title[strlen(title_string)]); | |
| 217 | gtk_window_set_title(win, buf); | |
| 218 | } | |
| 219 | return; | |
| 220 | } | |
| 221 | ||
| 3392 | 222 | void count_remove(GtkWidget *widget) { |
| 223 | char buf[256]; | |
| 224 | GtkWindow *win = GTK_WINDOW(widget); | |
| 225 | int length; | |
| 226 | ||
| 227 | strncpy(buf, win->title, sizeof(buf)); | |
| 228 | if (!g_strncasecmp(buf, "[", 1)) { | |
| 229 | counter(buf, &length); | |
| 230 | g_snprintf(buf, sizeof(buf), "%s", &win->title[3+length]); | |
| 231 | gtk_window_set_title(win, buf); | |
| 232 | } | |
| 233 | return; | |
| 234 | } | |
| 235 | ||
| 3374 | 236 | void quote_remove(GtkWidget *widget) { |
| 237 | char buf[256]; | |
| 238 | GtkWindow *win = GTK_WINDOW(widget); | |
| 191 | 239 | |
| 3392 | 240 | strncpy(buf, win->title, sizeof(buf)); |
| 3374 | 241 | if (!g_strncasecmp(buf, "\"", 1)) { |
| 242 | g_snprintf(buf, strlen(buf) - 1, "%s", &win->title[1]); | |
| 191 | 243 | gtk_window_set_title(win, buf); |
| 244 | } | |
| 3374 | 245 | return; |
| 246 | } | |
| 247 | ||
| 248 | void urgent_remove(struct conversation *c) { | |
| 249 | GdkWindow *win = c->window->window; | |
| 250 | ||
| 3428 | 251 | XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win)); |
| 3374 | 252 | hints->flags &= ~XUrgencyHint; |
| 3428 | 253 | XSetWMHints(GDK_WINDOW_XDISPLAY(win), GDK_WINDOW_XWINDOW(win), hints); |
| 3374 | 254 | return; |
| 255 | } | |
| 256 | ||
| 257 | void save_notify_prefs() { | |
| 3392 | 258 | gchar buf[1000]; |
| 3374 | 259 | FILE *fp; |
| 260 | ||
| 261 | snprintf(buf, 1000, "%s/.gaim/.notify", getenv("HOME")); | |
| 262 | if (!(fp = fopen(buf, "w"))) { | |
| 3428 | 263 | do_error_dialog(_("Unable to write to config file"), _("Notify plugin"), GAIM_ERROR); |
| 3374 | 264 | return; |
| 265 | } | |
| 266 | ||
| 3392 | 267 | fprintf(fp, "%d=CHOICE\n", choice); |
| 268 | fprintf(fp, "%d=METHOD\n", method); | |
| 269 | fprintf(fp, "%s=STRING\n", title_string); | |
| 3374 | 270 | fclose(fp); |
| 271 | } | |
| 272 | ||
| 273 | void load_notify_prefs() { | |
| 274 | gchar buf[1000]; | |
| 275 | gchar **parsed; | |
| 276 | FILE *fp; | |
| 277 | ||
| 278 | g_snprintf(buf, sizeof(buf), "%s/.gaim/.notify", getenv("HOME")); | |
| 279 | if (!(fp = fopen(buf, "r"))) | |
| 280 | return; | |
| 281 | ||
| 282 | while (fgets(buf, 1000, fp) != NULL) { | |
| 283 | parsed = g_strsplit(g_strchomp(buf), "=", 2); | |
| 284 | if (parsed[0] && parsed[1]) { | |
| 3392 | 285 | if (!strcmp(parsed[1], "CHOICE")) |
| 286 | choice = atoi(parsed[0]); | |
| 287 | if (!strcmp(parsed[1], "METHOD")) | |
| 288 | method = atoi(parsed[0]); | |
| 289 | if (!strcmp(parsed[1], "STRING")) | |
| 290 | if (title_string != NULL) g_free(title_string); | |
| 291 | title_string = g_strdup(parsed[0]); | |
| 3374 | 292 | } |
| 3392 | 293 | g_strfreev(parsed); |
| 3374 | 294 | } |
| 295 | fclose(fp); | |
| 296 | return; | |
| 297 | } | |
| 298 | ||
| 299 | void options(GtkWidget *widget, gpointer data) { | |
| 300 | gint option = GPOINTER_TO_INT(data); | |
| 301 | ||
| 302 | if (option == 0) | |
| 3392 | 303 | choice ^= NOTIFY_FOCUS; |
| 3374 | 304 | else if (option == 1) |
| 3392 | 305 | choice ^= NOTIFY_TYPE; |
| 3374 | 306 | else if (option == 2) { |
| 307 | method ^= METHOD_STRING; | |
| 308 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) | |
| 309 | gtk_widget_set_sensitive(Entry, TRUE); | |
| 310 | else | |
| 311 | gtk_widget_set_sensitive(Entry, FALSE); | |
| 312 | } | |
| 313 | else if (option == 3) | |
| 314 | method ^= METHOD_QUOTE; | |
| 315 | else if (option == 4) | |
| 316 | method ^= METHOD_URGENT; | |
| 3392 | 317 | else if (option == 5) |
| 318 | choice ^= NOTIFY_IN_FOCUS; | |
| 319 | else if (option == 6) | |
| 320 | method ^= METHOD_COUNT; | |
| 3374 | 321 | } |
| 322 | ||
| 323 | void setup_buttons() { | |
| 3392 | 324 | if (choice & NOTIFY_FOCUS) |
| 3374 | 325 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Focus), TRUE); |
| 326 | else | |
| 327 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Click), TRUE); | |
| 3392 | 328 | if (choice & NOTIFY_TYPE) |
| 3374 | 329 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Type), TRUE); |
| 330 | else | |
| 331 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Type), FALSE); | |
| 332 | ||
| 333 | if (method & METHOD_STRING) | |
| 334 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(String), TRUE); | |
| 335 | else | |
| 336 | gtk_widget_set_sensitive(Entry, FALSE); | |
| 337 | ||
| 338 | if (method & METHOD_QUOTE) | |
| 339 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Quote), TRUE); | |
| 340 | ||
| 341 | if (method & METHOD_URGENT) | |
| 342 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Urgent), TRUE); | |
| 343 | ||
| 3392 | 344 | if (choice & NOTIFY_IN_FOCUS) |
| 345 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(InFocus), TRUE); | |
| 346 | ||
| 347 | if (method & METHOD_COUNT) | |
| 348 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Count), TRUE); | |
| 349 | ||
| 3374 | 350 | return; |
| 351 | } | |
| 352 | ||
| 353 | void close_dialog(GtkWidget *widget, gpointer data) { | |
| 354 | gint option = GPOINTER_TO_INT(data); | |
| 355 | ||
| 356 | if (option > 0) { | |
| 357 | title_string = g_strdup(gtk_entry_get_text(GTK_ENTRY(Entry))); | |
| 358 | save_notify_prefs(); | |
| 359 | } | |
| 360 | else if (option < 0) | |
| 361 | load_notify_prefs(); | |
| 362 | ||
| 363 | if (Dialog) | |
| 364 | gtk_widget_destroy(Dialog); | |
| 365 | Dialog = NULL; | |
| 191 | 366 | } |
| 367 | ||
|
1047
783f8520d9a0
[gaim-migrate @ 1057]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1000
diff
changeset
|
368 | char *gaim_plugin_init(GModule *hndl) { |
| 191 | 369 | handle = hndl; |
| 370 | ||
| 3392 | 371 | really_evil_hack = gtk_label_new(""); |
| 372 | /* hash = g_hash_table_new(g_str_hash, g_int_equal); */ | |
| 373 | ||
| 3374 | 374 | load_notify_prefs(); |
| 375 | ||
| 191 | 376 | gaim_signal_connect(handle, event_im_recv, received_im, NULL); |
| 377 | gaim_signal_connect(handle, event_im_send, sent_im, NULL); | |
| 3374 | 378 | gaim_signal_connect(handle, event_new_conversation, new_conv, NULL); |
|
1052
d02807295cf3
[gaim-migrate @ 1062]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1047
diff
changeset
|
379 | |
|
d02807295cf3
[gaim-migrate @ 1062]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1047
diff
changeset
|
380 | return NULL; |
| 191 | 381 | } |
| 382 | ||
| 3392 | 383 | void gaim_plugin_remove() { |
| 384 | GList *c = conversations; | |
| 3428 | 385 | /* guint options; */ |
| 3392 | 386 | |
| 387 | gtk_widget_destroy(really_evil_hack); | |
| 388 | ||
| 389 | while (c) { | |
| 390 | struct conversation *cnv = (struct conversation *)c->data; | |
| 391 | /* if (options = GPOINTER_TO_INT(g_hash_table_lookup(hash, cnv->name))) { */ | |
| 392 | un_star(cnv->window, NULL); | |
| 393 | /* if (options & REMOVE_FOCUS) */ | |
| 394 | /* gtk_signal_disconnect_by_func(GTK_OBJECT(cnv->window), GTK_SIGNAL_FUNC(un_star), NULL); */ | |
| 395 | /* else { */ | |
| 396 | /* gtk_signal_disconnect_by_func(GTK_OBJECT(cnv->window), GTK_SIGNAL_FUNC(un_star), NULL); */ | |
| 397 | /* gtk_signal_disconnect_by_func(GTK_OBJECT(cnv->text), GTK_SIGNAL_FUNC(un_star_window), NULL); */ | |
| 398 | /* gtk_signal_disconnect_by_func(GTK_OBJECT(cnv->entry), GTK_SIGNAL_FUNC(un_star_window), NULL); */ | |
| 399 | /* } */ | |
| 400 | /* if (options & REMOVE_TYPE) */ | |
| 401 | /* gtk_signal_disconnect_by_func(GTK_OBJECT(cnv->entry), GTK_SIGNAL_FUNC(un_star_window), NULL); */ | |
| 402 | /* } */ | |
| 403 | c = c->next; | |
| 404 | } | |
| 405 | } | |
| 406 | ||
| 191 | 407 | char *name() { |
| 408 | return "Visual Notification"; | |
| 409 | } | |
| 410 | ||
| 411 | char *description() { | |
| 412 | return "Puts an asterisk in the title bar of all conversations" | |
| 413 | " where you have not responded to a message yet."; | |
| 414 | } | |
| 3374 | 415 | |
| 416 | void gaim_plugin_config() { | |
| 417 | GtkWidget *dialog_vbox; | |
| 418 | GtkWidget *button, *label; | |
| 3392 | 419 | GtkWidget *box, *box2, *box3, *box4, *frame; |
| 3374 | 420 | |
| 421 | if (Dialog) | |
| 422 | return; | |
| 423 | ||
| 424 | /* main config dialog */ | |
| 425 | Dialog = gtk_dialog_new(); | |
| 426 | gtk_window_set_title(GTK_WINDOW(Dialog), "Notify plugin configuration"); | |
| 427 | gtk_window_set_policy(GTK_WINDOW(Dialog), FALSE, FALSE, TRUE); | |
| 428 | gtk_signal_connect(GTK_OBJECT(Dialog), "destroy", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(-1)); | |
| 429 | ||
| 430 | dialog_vbox = GTK_DIALOG(Dialog)->vbox; | |
| 431 | ||
| 432 | /* Ok and Cancel buttons */ | |
| 433 | box = gtk_hbox_new(FALSE, 8); | |
| 434 | gtk_container_add(GTK_CONTAINER(GTK_DIALOG(Dialog)->action_area), box); | |
| 435 | ||
| 436 | button = gtk_button_new_with_label(_("Cancel")); | |
| 437 | gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); | |
| 438 | gtk_widget_set_usize(button, 80, -2); | |
| 439 | gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(0)); | |
| 440 | ||
| 441 | button = gtk_button_new_with_label(_("Ok")); | |
| 442 | gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); | |
| 443 | gtk_widget_set_usize(button, 80, -2); | |
| 444 | gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(1)); | |
| 445 | ||
| 3392 | 446 | /* warning label */ |
| 447 | label = gtk_label_new(_("Changes in notification removal options take effect only on new conversation windows")); | |
| 448 | gtk_box_pack_start(GTK_BOX(dialog_vbox), label, FALSE, FALSE, 1); | |
| 449 | ||
| 3374 | 450 | /* main hbox */ |
| 451 | box = gtk_hbox_new(FALSE, 0); | |
| 452 | gtk_box_pack_start(GTK_BOX(dialog_vbox), box, FALSE, FALSE, 0); | |
| 453 | ||
| 3392 | 454 | box4 = gtk_vbox_new(FALSE, 0); |
| 455 | gtk_box_pack_start(GTK_BOX(box), box4, FALSE, FALSE, 0); | |
| 456 | ||
| 3374 | 457 | /* un-notify choices */ |
| 458 | frame = gtk_frame_new(_("Remove notification when:")); | |
| 3392 | 459 | gtk_box_pack_start(GTK_BOX(box4), frame, FALSE, FALSE, 0); |
| 3374 | 460 | |
| 461 | box2 = gtk_vbox_new(FALSE, 0); | |
| 462 | gtk_container_add(GTK_CONTAINER(frame), box2); | |
| 463 | ||
| 464 | Focus = gtk_radio_button_new_with_label(NULL, _("Conversation window gains focus.")); | |
| 465 | gtk_box_pack_start(GTK_BOX(box2), Focus, FALSE, FALSE, 2); | |
| 466 | ||
| 467 | Click = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(Focus), _("Conversation window gets clicked.")); | |
| 468 | gtk_box_pack_start(GTK_BOX(box2), Click, FALSE, FALSE, 2); | |
| 469 | ||
| 470 | Type = gtk_check_button_new_with_label(_("Type in conversation window")); | |
| 471 | gtk_box_pack_start(GTK_BOX(box2), Type, FALSE, FALSE, 2); | |
| 472 | ||
| 473 | /* notification method choices */ | |
| 474 | /* do I need/want any other notification methods? */ | |
| 475 | frame = gtk_frame_new(_("Notification method:")); | |
| 476 | gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 0); | |
| 477 | ||
| 478 | box2 = gtk_vbox_new(FALSE, 0); | |
| 479 | gtk_container_add(GTK_CONTAINER(frame), box2); | |
| 480 | ||
| 481 | box3 = gtk_hbox_new(FALSE, 0); | |
| 482 | gtk_box_pack_start(GTK_BOX(box2), box3, FALSE, FALSE, 0); | |
| 483 | ||
| 484 | String = gtk_check_button_new_with_label(_("Insert string into window title:")); | |
| 485 | gtk_box_pack_start(GTK_BOX(box3), String, FALSE, FALSE, 0); | |
| 486 | ||
| 487 | Entry = gtk_entry_new_with_max_length(7); | |
| 488 | gtk_box_pack_start(GTK_BOX(box3), Entry, FALSE, FALSE, 0); | |
| 3392 | 489 | gtk_entry_set_text(GTK_ENTRY(Entry), title_string); |
| 3374 | 490 | |
| 491 | Quote = gtk_check_button_new_with_label(_("Quote window title.")); | |
| 492 | gtk_box_pack_start(GTK_BOX(box2), Quote, FALSE, FALSE, 0); | |
| 493 | ||
| 494 | Urgent = gtk_check_button_new_with_label(_("Send URGENT to window manager.")); | |
| 495 | gtk_box_pack_start(GTK_BOX(box2), Urgent, FALSE, FALSE, 0); | |
| 496 | ||
| 3392 | 497 | label = gtk_label_new(_("Function oddly with tabs:")); |
| 498 | gtk_box_pack_start(GTK_BOX(box2), label, FALSE, FALSE, 0); | |
| 499 | ||
| 500 | Count = gtk_check_button_new_with_label(_("Insert count of new messages into window title")); | |
| 501 | gtk_box_pack_start(GTK_BOX(box2), Count, FALSE, FALSE, 0); | |
| 502 | ||
| 503 | /* general options */ | |
| 504 | frame = gtk_frame_new(_("General Options")); | |
| 505 | gtk_box_pack_start(GTK_BOX(box4), frame, FALSE, FALSE, 0); | |
| 506 | ||
| 507 | box = gtk_vbox_new(FALSE, 0); | |
| 508 | gtk_container_add(GTK_CONTAINER(frame), box); | |
| 509 | ||
| 510 | InFocus = gtk_check_button_new_with_label(_("Notify even when window is in focus")); | |
| 511 | gtk_box_pack_start(GTK_BOX(box), InFocus, FALSE, FALSE, 0); | |
| 512 | ||
| 3374 | 513 | /* setup buttons, then attach signals */ |
| 514 | setup_buttons(); | |
| 515 | gtk_signal_connect(GTK_OBJECT(Focus), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(0)); | |
| 516 | gtk_signal_connect(GTK_OBJECT(Type), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(1)); | |
| 517 | gtk_signal_connect(GTK_OBJECT(String), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(2)); | |
| 518 | gtk_signal_connect(GTK_OBJECT(Quote), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(3)); | |
| 519 | gtk_signal_connect(GTK_OBJECT(Urgent), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(4)); | |
| 3392 | 520 | gtk_signal_connect(GTK_OBJECT(InFocus), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(5)); |
| 521 | gtk_signal_connect(GTK_OBJECT(Count), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(6)); | |
| 3374 | 522 | |
| 523 | gtk_widget_show_all(Dialog); | |
| 524 | } |