comparison plugins/notify.c @ 4043:e25edee01c33

[gaim-migrate @ 4251] (20:35:19) deryni: LSchiere: http://deryni.perlmonk.org/notify.diff <- fixes the Urgent option crash, and fixes applying changes committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 04 Dec 2002 01:36:43 +0000
parents 4cea75cf291d
children 0fccde7ed9b8
comparison
equal deleted inserted replaced
4042:a3ec0146c73e 4043:e25edee01c33
50 gchar *title_string = "(*) "; 50 gchar *title_string = "(*) ";
51 51
52 /* predefine some functions, less warnings */ 52 /* predefine some functions, less warnings */
53 void options(GtkWidget *widget, gpointer data); 53 void options(GtkWidget *widget, gpointer data);
54 void un_star(GtkWidget *widget, gpointer data); 54 void un_star(GtkWidget *widget, gpointer data);
55 int un_star_window(GtkWidget *widget, gpointer data); 55 void un_star_window(GtkWidget *widget, gpointer data);
56 int counter (char *buf, int *length); 56 int counter (char *buf, int *length);
57 /*string functions */ 57 /*string functions */
58 void string_add(GtkWidget *widget); 58 void string_add(GtkWidget *widget);
59 gboolean string_remove(GtkWidget *widget); 59 gboolean string_remove(GtkWidget *widget);
60 /* count functions */ 60 /* count functions */
101 return 0; 101 return 0;
102 } 102 }
103 103
104 guint unnotify(struct conversation *c, gboolean clean) { 104 guint unnotify(struct conversation *c, gboolean clean) {
105 guint option = 0; 105 guint option = 0;
106 /* The top level ifs check whether we are either cleaning all methods,
107 * or whether we have that method is currently selected.
108 * If we do then they are cleaned
109 *
110 * The second level ifs check if we removed something,
111 * and if that method is currently selected.
112 * If we did and it is then set option so that it can be re-added */
106 if (clean || (method & METHOD_QUOTE)) 113 if (clean || (method & METHOD_QUOTE))
107 if(quote_remove(c->window)) 114 if (quote_remove(c->window) && (method & METHOD_QUOTE))
108 option ^= METHOD_QUOTE; 115 option ^= METHOD_QUOTE;
109 if (clean || (method & METHOD_COUNT)) 116 if (clean || (method & METHOD_COUNT))
110 if (count_remove(c->window)) 117 if (count_remove(c->window) && (method & METHOD_COUNT))
111 option ^= METHOD_COUNT; 118 option ^= METHOD_COUNT;
112 if (clean || (method & METHOD_STRING)) 119 if (clean || (method & METHOD_STRING))
113 if (string_remove(c->window)) 120 if (string_remove(c->window) && (method & METHOD_STRING))
114 option ^= METHOD_STRING; 121 option ^= METHOD_STRING;
115 if (clean || (method & METHOD_URGENT)) 122 if (clean || (method & METHOD_URGENT))
116 if (urgent_remove(c)) 123 if (urgent_remove(c) && (method & METHOD_URGENT))
117 option ^= METHOD_URGENT; 124 option ^= METHOD_URGENT;
118 return option; 125 return option;
119 } 126 }
120 127
121 void chat_recv_im(struct gaim_connection *gc, int id, char **who, char **text) { 128 void chat_recv_im(struct gaim_connection *gc, int id, char **who, char **text) {
165 172
166 if (choice & NOTIFY_TYPE) { 173 if (choice & NOTIFY_TYPE) {
167 g_signal_connect(G_OBJECT(c->entry), "key-press-event", G_CALLBACK(un_star_window), NULL); 174 g_signal_connect(G_OBJECT(c->entry), "key-press-event", G_CALLBACK(un_star_window), NULL);
168 } 175 }
169 176
177 g_object_set_data(G_OBJECT(c->window), "user_data", c);
170 g_object_set_data(G_OBJECT(c->window), "notify_data", GUINT_TO_POINTER(choice)); 178 g_object_set_data(G_OBJECT(c->window), "notify_data", GUINT_TO_POINTER(choice));
171 return 0; 179 return 0;
172 } 180 }
173 181
174 void new_conv(char *who) { 182 void new_conv(char *who) {
180 } 188 }
181 189
182 void chat_join(struct gaim_connection *gc, int id, char *room) { 190 void chat_join(struct gaim_connection *gc, int id, char *room) {
183 struct conversation *c = find_chat(gc, id); 191 struct conversation *c = find_chat(gc, id);
184 192
185 if (type & TYPE_CHAT) 193 if (c && (type & TYPE_CHAT))
186 attach_signals(c); 194 attach_signals(c);
187 return; 195 return;
188 } 196 }
189 197
190 void un_star(GtkWidget *widget, gpointer data) { 198 void un_star(GtkWidget *widget, gpointer data) {
191 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(widget)); 199 struct conversation *c = g_object_get_data(G_OBJECT(widget), "user_data");
192 200
193 if (method & METHOD_QUOTE) 201 if (method & METHOD_QUOTE)
194 quote_remove(widget); 202 quote_remove(widget);
195 if (method & METHOD_COUNT) 203 if (method & METHOD_COUNT)
196 count_remove(widget); 204 count_remove(widget);
197 if (method & METHOD_STRING) 205 if (method & METHOD_STRING)
198 string_remove(widget); 206 string_remove(widget);
199 if (method & METHOD_URGENT) 207 if (c && method & METHOD_URGENT)
200 urgent_remove(c); 208 urgent_remove(c);
201 return; 209 return;
202 } 210 }
203 211
204 int un_star_window(GtkWidget *widget, gpointer data) { 212 void un_star_window(GtkWidget *widget, gpointer data) {
205 GtkWidget *parent = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW); 213 GtkWidget *parent = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
206 gtk_object_set_user_data(GTK_OBJECT(parent), gtk_object_get_user_data(GTK_OBJECT(widget)));
207 un_star(parent, data); 214 un_star(parent, data);
208 return 0; 215 return;
209 } 216 }
210 217
211 /* This function returns the number in [ ]'s or 0 */ 218 /* This function returns the number in [ ]'s or 0 */
212 int counter (char *buf, int *length) { 219 int counter (char *buf, int *length) {
213 char temp[256]; 220 char temp[256];
421 } 428 }
422 429
423 if (options & NOTIFY_TYPE) 430 if (options & NOTIFY_TYPE)
424 g_signal_handlers_disconnect_by_func(G_OBJECT(c->entry), un_star_window, NULL); 431 g_signal_handlers_disconnect_by_func(G_OBJECT(c->entry), un_star_window, NULL);
425 432
426 /* needs rethinking to get the order of events to work 433 /* works except for count, always get reset to [1] */
427 * correctly, so that correct methods can get restored */
428 /* clean off all notification markings */ 434 /* clean off all notification markings */
429 notification = unnotify(c, TRUE); 435 notification = unnotify(c, TRUE);
430 /* re-add appropriate notification methods cleaned above */ 436 /* re-add appropriate notification methods cleaned above */
437 if (notification & METHOD_STRING) /* re-add string */
438 string_add(c->window);
431 if (notification & METHOD_QUOTE) /* re-add quote */ 439 if (notification & METHOD_QUOTE) /* re-add quote */
432 quote_add(c->window); 440 quote_add(c->window);
433 if (notification & METHOD_COUNT) /* re-add count */ 441 if (notification & METHOD_COUNT) /* re-add count */
434 count_add(c->window); 442 count_add(c->window);
435 if (notification & METHOD_STRING) /* re-add string */
436 string_add(c->window);
437 if (notification & METHOD_URGENT) /* re-add urgent */ 443 if (notification & METHOD_URGENT) /* re-add urgent */
438 urgent_add(c); 444 urgent_add(c);
439 /* attach new unnotification signals */ 445 /* attach new unnotification signals */
440 attach_signals(c); 446 attach_signals(c);
441 447