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