comparison 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
comparison
equal deleted inserted replaced
3391:412d1035d666 3392:5a5df7968b6e
1 /* Reworked by Etan Reisner 1 /* Rewritten by Etan Reisner <deryni@eden.rutgers.edu>
2 * 2 *
3 * Added config dialog 3 * Added config dialog
4 * Added control over notification method 4 * Added control over notification method
5 * Added control over when to release notification 5 * Added control over when to release notification
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
6 */ 13 */
7 14
8 #define GAIM_PLUGINS 15 #define GAIM_PLUGINS
9 #include "gaim.h" 16 #include "gaim.h"
10 17
11 #include <gtk/gtk.h> 18 #include <gtk/gtk.h>
12 #include <string.h> 19 #include <string.h>
13 #include <X11/Xlib.h> 20 #include <X11/Xlib.h>
14 #include <X11/Xutil.h> 21 #include <X11/Xutil.h>
15 #include <X11/Xatom.h> 22 #include <X11/Xatom.h>
16 #include <gdk/gdkx.h> 23 #include <gdk/gdkx.h>
17 24
18 guint choice; 25 guint choice = 1;
19 #define REMOVE_FOCUS 0x00000001 26 #define NOTIFY_FOCUS 0x00000001
20 #define REMOVE_TYPE 0x00000002 27 #define NOTIFY_TYPE 0x00000002
21 28 #define NOTIFY_IN_FOCUS 0x00000004
22 guint method; 29
23 #define METHOD_STRING 0x00000001 30 guint method = 1;
24 #define METHOD_QUOTE 0x00000002 31 #define METHOD_STRING 0x00000001
25 #define METHOD_URGENT 0x00000004 32 #define METHOD_QUOTE 0x00000002
33 #define METHOD_URGENT 0x00000004
34 #define METHOD_COUNT 0x00000008
26 35
27 void *handle; 36 void *handle;
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; */
28 GtkWidget *Dialog = NULL; 42 GtkWidget *Dialog = NULL;
29 GtkWidget *Click, *Focus, *Type; 43 GtkWidget *Click, *Focus, *Type, *InFocus;
30 GtkWidget *String, *Quote, *Urgent, *Entry; 44 GtkWidget *String, *Count, *Quote, *Urgent, *Entry;
31 gchar *title_string; 45 gchar *title_string = "(*) ";
32 46
33 /* predefine some functions, less warnings */ 47 /* predefine some functions, less warnings */
34 void options(GtkWidget *widget, gpointer data); 48 void options(GtkWidget *widget, gpointer data);
35 void un_star(GtkWidget *widget, gpointer data); 49 void un_star(GtkWidget *widget, gpointer data);
36 void un_star_window(GtkWidget *widget, gpointer data); 50 void un_star_window(GtkWidget *widget, gpointer data);
37 void string_remove(GtkWidget *widget); 51 void string_remove(GtkWidget *widget);
52 void count_remove(GtkWidget *widget);
38 void quote_remove(GtkWidget *widget); 53 void quote_remove(GtkWidget *widget);
39 void urgent_remove(struct conversation *c); 54 void urgent_remove(struct conversation *c);
40 55
41 int received_im(struct gaim_connection *gc, char **who, char **what, void *m) { 56 int received_im(struct gaim_connection *gc, char **who, char **what, void *m) {
42 char buf[256]; 57 char buf[256];
43 struct conversation *cnv = find_conversation(*who); 58 struct conversation *cnv = find_conversation(*who);
44 GtkWindow *win; 59 GtkWindow *win;
45 char *me = g_strdup(normalize(gc->username)); 60 char *me = g_strdup(normalize(gc->username));
46 int revert_to_return; 61 int revert_to_return;
47 Window focus_return; 62 Window focus_return;
63 int c, length;
48 64
49 if (!strcmp(me, normalize(*who))) { 65 if (!strcmp(me, normalize(*who))) {
50 g_free(me); 66 g_free(me);
51 return 0; 67 return 0;
52 } 68 }
62 78
63 win = (GtkWindow *)cnv->window; 79 win = (GtkWindow *)cnv->window;
64 80
65 XGetInputFocus(GDK_WINDOW_XDISPLAY(cnv->window->window), &focus_return, &revert_to_return); 81 XGetInputFocus(GDK_WINDOW_XDISPLAY(cnv->window->window), &focus_return, &revert_to_return);
66 82
67 if (focus_return != GDK_WINDOW_XWINDOW(cnv->window->window)) { 83 if ((choice & NOTIFY_IN_FOCUS) || focus_return != GDK_WINDOW_XWINDOW(cnv->window->window)) {
68 if (method & METHOD_STRING) { 84 if (method & METHOD_STRING) {
69 g_snprintf(buf, sizeof(buf), "%s", win->title); 85 strncpy(buf, win->title, sizeof(buf));
70 if (!strstr(buf, title_string)) { 86 if (!strstr(buf, title_string)) {
71 g_snprintf(buf, sizeof(buf), "%s %s", title_string, win->title); 87 g_snprintf(buf, sizeof(buf), "%s%s", title_string, win->title);
72 gtk_window_set_title(win, buf); 88 gtk_window_set_title(win, buf);
73 } 89 }
74 } 90 }
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 }
75 if (method & METHOD_QUOTE) { 102 if (method & METHOD_QUOTE) {
76 g_snprintf(buf, sizeof(buf), "%s", win->title); 103 strncpy(buf, win->title, sizeof(buf));
77 if (g_strncasecmp(buf, "\"", 1)) { 104 if (g_strncasecmp(buf, "\"", 1)) {
78 g_snprintf(buf, sizeof(buf), "\"%s\"", win->title); 105 g_snprintf(buf, sizeof(buf), "\"%s\"", win->title);
79 gtk_window_set_title(win, buf); 106 gtk_window_set_title(win, buf);
80 } 107 }
81 } 108 }
82 if (method & METHOD_URGENT) { 109 if (method & METHOD_URGENT) {
83 /* do it the gdk way for windows compatibility(?) if I can figure it out */ 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 */
84 /* gdk_property_change(win->window, WM_HINTS, WM_HINTS, 32, GDK_PROP_MODE_REPLACE, XUrgencyHint, 1); */ 113 /* gdk_property_change(win->window, WM_HINTS, WM_HINTS, 32, GDK_PROP_MODE_REPLACE, XUrgencyHint, 1); */
85 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(cnv->window->window), GDK_WINDOW_XWINDOW(cnv->window->window)); 114 XWMHints *hints = XGetWMHints(GDK_WINDOW_XDISPLAY(cnv->window->window), GDK_WINDOW_XWINDOW(cnv->window->window));
86 hints->flags |= XUrgencyHint; 115 hints->flags |= XUrgencyHint;
87 XSetWMHints(GDK_WINDOW_XDISPLAY(cnv->window->window), GDK_WINDOW_XWINDOW(cnv->window->window), hints); 116 XSetWMHints(GDK_WINDOW_XDISPLAY(cnv->window->window), GDK_WINDOW_XWINDOW(cnv->window->window), hints);
88 } 117 }
94 int sent_im(struct gaim_connection *gc, char *who, char **what, void *m) { 123 int sent_im(struct gaim_connection *gc, char *who, char **what, void *m) {
95 char buf[256]; 124 char buf[256];
96 struct conversation *c = find_conversation(who); 125 struct conversation *c = find_conversation(who);
97 126
98 if (method & METHOD_QUOTE) 127 if (method & METHOD_QUOTE)
128 quote_remove(c->window);
129 if (method & METHOD_COUNT)
130 count_remove(c->window);
131 if (method & METHOD_STRING)
99 string_remove(c->window); 132 string_remove(c->window);
100 if (method & METHOD_STRING)
101 quote_remove(c->window);
102 if (method & METHOD_URGENT) 133 if (method & METHOD_URGENT)
103 urgent_remove(c); 134 urgent_remove(c);
104 return 0; 135 return 0;
105 } 136 }
106 137
107 int new_conv(char *who) { 138 int new_conv(char *who) {
108 struct conversation *c = find_conversation(who); 139 struct conversation *c = find_conversation(who);
109 140
110 if (choice & REMOVE_FOCUS) { 141 /* g_hash_table_insert(hash, who, GINT_TO_POINTER(choice)); */
111 gtk_signal_connect(GTK_OBJECT(c->window), "focus-in-event", GTK_SIGNAL_FUNC(un_star), NULL); 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));
112 gtk_object_set_user_data(GTK_OBJECT(c->window), c); 145 gtk_object_set_user_data(GTK_OBJECT(c->window), c);
113 } 146 }
114 else { 147 else {
115 gtk_signal_connect(GTK_OBJECT(c->window), "button_press_event", GTK_SIGNAL_FUNC(un_star), NULL); 148 gtk_signal_connect_while_alive(GTK_OBJECT(c->window), "button_press_event", GTK_SIGNAL_FUNC(un_star), NULL, GTK_OBJECT(really_evil_hack));
116 gtk_object_set_user_data(GTK_OBJECT(c->window), c); 149 gtk_object_set_user_data(GTK_OBJECT(c->window), c);
117 gtk_signal_connect(GTK_OBJECT(c->text), "button_press_event", GTK_SIGNAL_FUNC(un_star_window), NULL); 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));
118 gtk_object_set_user_data(GTK_OBJECT(c->text), c); 151 gtk_object_set_user_data(GTK_OBJECT(c->text), c);
119 gtk_signal_connect(GTK_OBJECT(c->entry), "button_press_event", GTK_SIGNAL_FUNC(un_star_window), NULL); 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));
120 gtk_object_set_user_data(GTK_OBJECT(c->entry), c); 153 gtk_object_set_user_data(GTK_OBJECT(c->entry), c);
121 /* gtk_signal_connect(GTK_OBJECT(c->text), "button_press_event", GTK_SIGNAL_FUNC(un_star_window), c); */ 154 }
122 /* gtk_signal_connect(GTK_OBJECT(c->entry), "button_press_event", GTK_SIGNAL_FUNC(un_star_window), c); */ 155
123 } 156 if (choice & NOTIFY_TYPE) {
124 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));
125 if (choice & REMOVE_TYPE) {
126 gtk_signal_connect(GTK_OBJECT(c->entry), "key-press-event", GTK_SIGNAL_FUNC(un_star_window), NULL);
127 gtk_object_set_user_data(GTK_OBJECT(c->entry), (gpointer) c); 158 gtk_object_set_user_data(GTK_OBJECT(c->entry), (gpointer) c);
128 /* gtk_signal_connect(GTK_OBJECT(c->entry), "key-press-event", GTK_SIGNAL_FUNC(un_star_window), c); */
129 } 159 }
130 } 160 }
131 161
132 void un_star(GtkWidget *widget, gpointer data) { 162 void un_star(GtkWidget *widget, gpointer data) {
133 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(widget)); 163 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(widget));
134 /* struct conversation *c = data; */
135 164
136 if (method & METHOD_QUOTE) 165 if (method & METHOD_QUOTE)
137 quote_remove(widget); 166 quote_remove(widget);
167 if (method & METHOD_COUNT)
168 count_remove(widget);
138 if (method & METHOD_STRING) 169 if (method & METHOD_STRING)
139 string_remove(widget); 170 string_remove(widget);
140 if (method & METHOD_URGENT) 171 if (method & METHOD_URGENT)
141 urgent_remove(c); 172 urgent_remove(c);
142 return; 173 return;
146 GtkWidget *parent = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW); 177 GtkWidget *parent = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
147 gtk_object_set_user_data(GTK_OBJECT(parent), gtk_object_get_user_data(GTK_OBJECT(widget))); 178 gtk_object_set_user_data(GTK_OBJECT(parent), gtk_object_get_user_data(GTK_OBJECT(widget)));
148 un_star(parent, data); 179 un_star(parent, data);
149 } 180 }
150 181
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
151 void string_remove(GtkWidget *widget) { 206 void string_remove(GtkWidget *widget) {
152 char buf[256]; 207 char buf[256];
153 GtkWindow *win = GTK_WINDOW(widget); 208 GtkWindow *win = GTK_WINDOW(widget);
154 209
155 g_snprintf(buf, sizeof(buf), "%s", win->title); 210 strncpy(buf, win->title, sizeof(buf));
156 if (strstr(buf, title_string)) { 211 if (strstr(buf, title_string)) {
157 g_snprintf(buf, sizeof(buf), "%s", &win->title[strlen(title_string)]); 212 g_snprintf(buf, sizeof(buf), "%s", &win->title[strlen(title_string)]);
158 gtk_window_set_title(win, buf); 213 gtk_window_set_title(win, buf);
159 } 214 }
160 return; 215 return;
161 } 216 }
162 217
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
163 void quote_remove(GtkWidget *widget) { 232 void quote_remove(GtkWidget *widget) {
164 char buf[256]; 233 char buf[256];
165 GtkWindow *win = GTK_WINDOW(widget); 234 GtkWindow *win = GTK_WINDOW(widget);
166 235
167 g_snprintf(buf, sizeof(buf), "%s", win->title); 236 strncpy(buf, win->title, sizeof(buf));
168 if (!g_strncasecmp(buf, "\"", 1)) { 237 if (!g_strncasecmp(buf, "\"", 1)) {
169 g_snprintf(buf, strlen(buf) - 1, "%s", &win->title[1]); 238 g_snprintf(buf, strlen(buf) - 1, "%s", &win->title[1]);
170 gtk_window_set_title(win, buf); 239 gtk_window_set_title(win, buf);
171 } 240 }
172 return; 241 return;
181 XSetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window), hints); 250 XSetWMHints(GDK_WINDOW_XDISPLAY(c->window->window), GDK_WINDOW_XWINDOW(c->window->window), hints);
182 return; 251 return;
183 } 252 }
184 253
185 void save_notify_prefs() { 254 void save_notify_prefs() {
186 char *buf; 255 gchar buf[1000];
187 FILE *fp; 256 FILE *fp;
188 257
189 buf = malloc(1000);
190 snprintf(buf, 1000, "%s/.gaim/.notify", getenv("HOME")); 258 snprintf(buf, 1000, "%s/.gaim/.notify", getenv("HOME"));
191 if (!(fp = fopen(buf, "w"))) { 259 if (!(fp = fopen(buf, "w"))) {
192 do_error_dialog(_("Unable to write to config file"), _("Notify plugin")); 260 do_error_dialog(_("Unable to write to config file"), _("Notify plugin"));
193 return; 261 return;
194 } 262 }
195 free(buf); 263
196 264 fprintf(fp, "%d=CHOICE\n", choice);
197 fprintf(fp, "CHOICE=%d\n", choice); 265 fprintf(fp, "%d=METHOD\n", method);
198 fprintf(fp, "METHOD=%d\n", method); 266 fprintf(fp, "%s=STRING\n", title_string);
199 fprintf(fp, "STRING=%s\n", title_string);
200 fclose(fp); 267 fclose(fp);
201 } 268 }
202 269
203 void load_notify_prefs() { 270 void load_notify_prefs() {
204 gchar buf[1000]; 271 gchar buf[1000];
210 return; 277 return;
211 278
212 while (fgets(buf, 1000, fp) != NULL) { 279 while (fgets(buf, 1000, fp) != NULL) {
213 parsed = g_strsplit(g_strchomp(buf), "=", 2); 280 parsed = g_strsplit(g_strchomp(buf), "=", 2);
214 if (parsed[0] && parsed[1]) { 281 if (parsed[0] && parsed[1]) {
215 if (!strcmp(parsed[0], "CHOICE")) 282 if (!strcmp(parsed[1], "CHOICE"))
216 choice = atoi(parsed[1]); 283 choice = atoi(parsed[0]);
217 if (!strcmp(parsed[0], "METHOD")) 284 if (!strcmp(parsed[1], "METHOD"))
218 method = atoi(parsed[1]); 285 method = atoi(parsed[0]);
219 if (!strcmp(parsed[0], "STRING")) 286 if (!strcmp(parsed[1], "STRING"))
220 title_string = parsed[1]; 287 if (title_string != NULL) g_free(title_string);
288 title_string = g_strdup(parsed[0]);
221 } 289 }
290 g_strfreev(parsed);
222 } 291 }
223 fclose(fp); 292 fclose(fp);
224 return; 293 return;
225 } 294 }
226 295
227 void options(GtkWidget *widget, gpointer data) { 296 void options(GtkWidget *widget, gpointer data) {
228 gint option = GPOINTER_TO_INT(data); 297 gint option = GPOINTER_TO_INT(data);
229 298
230 if (option == 0) 299 if (option == 0)
231 choice ^= REMOVE_FOCUS; 300 choice ^= NOTIFY_FOCUS;
232 else if (option == 1) 301 else if (option == 1)
233 choice ^= REMOVE_TYPE; 302 choice ^= NOTIFY_TYPE;
234 else if (option == 2) { 303 else if (option == 2) {
235 method ^= METHOD_STRING; 304 method ^= METHOD_STRING;
236 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) 305 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
237 gtk_widget_set_sensitive(Entry, TRUE); 306 gtk_widget_set_sensitive(Entry, TRUE);
238 else 307 else
240 } 309 }
241 else if (option == 3) 310 else if (option == 3)
242 method ^= METHOD_QUOTE; 311 method ^= METHOD_QUOTE;
243 else if (option == 4) 312 else if (option == 4)
244 method ^= METHOD_URGENT; 313 method ^= METHOD_URGENT;
314 else if (option == 5)
315 choice ^= NOTIFY_IN_FOCUS;
316 else if (option == 6)
317 method ^= METHOD_COUNT;
245 } 318 }
246 319
247 void setup_buttons() { 320 void setup_buttons() {
248 if (choice & REMOVE_FOCUS) 321 if (choice & NOTIFY_FOCUS)
249 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Focus), TRUE); 322 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Focus), TRUE);
250 else 323 else
251 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Click), TRUE); 324 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Click), TRUE);
252 if (choice & REMOVE_TYPE) 325 if (choice & NOTIFY_TYPE)
253 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Type), TRUE); 326 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Type), TRUE);
254 else 327 else
255 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Type), FALSE); 328 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Type), FALSE);
256 329
257 if (method & METHOD_STRING) 330 if (method & METHOD_STRING)
263 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Quote), TRUE); 336 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Quote), TRUE);
264 337
265 if (method & METHOD_URGENT) 338 if (method & METHOD_URGENT)
266 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Urgent), TRUE); 339 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Urgent), TRUE);
267 340
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
268 return; 347 return;
269 } 348 }
270 349
271 void close_dialog(GtkWidget *widget, gpointer data) { 350 void close_dialog(GtkWidget *widget, gpointer data) {
272 gint option = GPOINTER_TO_INT(data); 351 gint option = GPOINTER_TO_INT(data);
284 } 363 }
285 364
286 char *gaim_plugin_init(GModule *hndl) { 365 char *gaim_plugin_init(GModule *hndl) {
287 handle = hndl; 366 handle = hndl;
288 367
368 really_evil_hack = gtk_label_new("");
369 /* hash = g_hash_table_new(g_str_hash, g_int_equal); */
370
289 load_notify_prefs(); 371 load_notify_prefs();
290 372
291 gaim_signal_connect(handle, event_im_recv, received_im, NULL); 373 gaim_signal_connect(handle, event_im_recv, received_im, NULL);
292 gaim_signal_connect(handle, event_im_send, sent_im, NULL); 374 gaim_signal_connect(handle, event_im_send, sent_im, NULL);
293 gaim_signal_connect(handle, event_new_conversation, new_conv, NULL); 375 gaim_signal_connect(handle, event_new_conversation, new_conv, NULL);
294 376
295 return NULL; 377 return NULL;
296 } 378 }
297 379
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
298 char *name() { 404 char *name() {
299 return "Visual Notification"; 405 return "Visual Notification";
300 } 406 }
301 407
302 char *description() { 408 char *description() {
305 } 411 }
306 412
307 void gaim_plugin_config() { 413 void gaim_plugin_config() {
308 GtkWidget *dialog_vbox; 414 GtkWidget *dialog_vbox;
309 GtkWidget *button, *label; 415 GtkWidget *button, *label;
310 GtkWidget *box, *box2, *box3, *frame; 416 GtkWidget *box, *box2, *box3, *box4, *frame;
311 417
312 if (Dialog) 418 if (Dialog)
313 return; 419 return;
314 420
315 /* main config dialog */ 421 /* main config dialog */
316 Dialog = gtk_dialog_new(); 422 Dialog = gtk_dialog_new();
317 /* gtk_widget_set_usize(Dialog, 275, -1); */
318 gtk_window_set_title(GTK_WINDOW(Dialog), "Notify plugin configuration"); 423 gtk_window_set_title(GTK_WINDOW(Dialog), "Notify plugin configuration");
319 gtk_window_set_policy(GTK_WINDOW(Dialog), FALSE, FALSE, TRUE); 424 gtk_window_set_policy(GTK_WINDOW(Dialog), FALSE, FALSE, TRUE);
320 gtk_signal_connect(GTK_OBJECT(Dialog), "destroy", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(-1)); 425 gtk_signal_connect(GTK_OBJECT(Dialog), "destroy", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(-1));
321 426
322 dialog_vbox = GTK_DIALOG(Dialog)->vbox; 427 dialog_vbox = GTK_DIALOG(Dialog)->vbox;
333 button = gtk_button_new_with_label(_("Ok")); 438 button = gtk_button_new_with_label(_("Ok"));
334 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); 439 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
335 gtk_widget_set_usize(button, 80, -2); 440 gtk_widget_set_usize(button, 80, -2);
336 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(1)); 441 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(1));
337 442
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
338 /* main hbox */ 447 /* main hbox */
339 box = gtk_hbox_new(FALSE, 0); 448 box = gtk_hbox_new(FALSE, 0);
340 gtk_box_pack_start(GTK_BOX(dialog_vbox), box, FALSE, FALSE, 0); 449 gtk_box_pack_start(GTK_BOX(dialog_vbox), box, FALSE, FALSE, 0);
341 450
451 box4 = gtk_vbox_new(FALSE, 0);
452 gtk_box_pack_start(GTK_BOX(box), box4, FALSE, FALSE, 0);
453
342 /* un-notify choices */ 454 /* un-notify choices */
343 frame = gtk_frame_new(_("Remove notification when:")); 455 frame = gtk_frame_new(_("Remove notification when:"));
344 gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 0); 456 gtk_box_pack_start(GTK_BOX(box4), frame, FALSE, FALSE, 0);
345 457
346 box2 = gtk_vbox_new(FALSE, 0); 458 box2 = gtk_vbox_new(FALSE, 0);
347 gtk_container_add(GTK_CONTAINER(frame), box2); 459 gtk_container_add(GTK_CONTAINER(frame), box2);
348 460
349 Focus = gtk_radio_button_new_with_label(NULL, _("Conversation window gains focus.")); 461 Focus = gtk_radio_button_new_with_label(NULL, _("Conversation window gains focus."));
369 String = gtk_check_button_new_with_label(_("Insert string into window title:")); 481 String = gtk_check_button_new_with_label(_("Insert string into window title:"));
370 gtk_box_pack_start(GTK_BOX(box3), String, FALSE, FALSE, 0); 482 gtk_box_pack_start(GTK_BOX(box3), String, FALSE, FALSE, 0);
371 483
372 Entry = gtk_entry_new_with_max_length(7); 484 Entry = gtk_entry_new_with_max_length(7);
373 gtk_box_pack_start(GTK_BOX(box3), Entry, FALSE, FALSE, 0); 485 gtk_box_pack_start(GTK_BOX(box3), Entry, FALSE, FALSE, 0);
374 if (!title_string) 486 gtk_entry_set_text(GTK_ENTRY(Entry), title_string);
375 gtk_entry_set_text(GTK_ENTRY(Entry), "(*) ");
376 else
377 gtk_entry_set_text(GTK_ENTRY(Entry), title_string);
378 487
379 Quote = gtk_check_button_new_with_label(_("Quote window title.")); 488 Quote = gtk_check_button_new_with_label(_("Quote window title."));
380 gtk_box_pack_start(GTK_BOX(box2), Quote, FALSE, FALSE, 0); 489 gtk_box_pack_start(GTK_BOX(box2), Quote, FALSE, FALSE, 0);
381 490
382 Urgent = gtk_check_button_new_with_label(_("Send URGENT to window manager.")); 491 Urgent = gtk_check_button_new_with_label(_("Send URGENT to window manager."));
383 gtk_box_pack_start(GTK_BOX(box2), Urgent, FALSE, FALSE, 0); 492 gtk_box_pack_start(GTK_BOX(box2), Urgent, FALSE, FALSE, 0);
493
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);
384 509
385 /* setup buttons, then attach signals */ 510 /* setup buttons, then attach signals */
386 setup_buttons(); 511 setup_buttons();
387 gtk_signal_connect(GTK_OBJECT(Focus), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(0)); 512 gtk_signal_connect(GTK_OBJECT(Focus), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(0));
388 gtk_signal_connect(GTK_OBJECT(Type), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(1)); 513 gtk_signal_connect(GTK_OBJECT(Type), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(1));
389 gtk_signal_connect(GTK_OBJECT(String), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(2)); 514 gtk_signal_connect(GTK_OBJECT(String), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(2));
390 gtk_signal_connect(GTK_OBJECT(Quote), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(3)); 515 gtk_signal_connect(GTK_OBJECT(Quote), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(3));
391 gtk_signal_connect(GTK_OBJECT(Urgent), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(4)); 516 gtk_signal_connect(GTK_OBJECT(Urgent), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(4));
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));
392 519
393 gtk_widget_show_all(Dialog); 520 gtk_widget_show_all(Dialog);
394 } 521 }