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