comparison src/away.c @ 1109:c73736fa0b7c

[gaim-migrate @ 1119] Auto-Away, courtesy BMiller. damn cool. i'm impressed. also minor touch-ups, mostly to indicate what all the FIXME's mean. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 20 Nov 2000 10:37:40 +0000
parents 77b6bc7288d3
children 282e6b7aef2c
comparison
equal deleted inserted replaced
1108:cb338aa38e78 1109:c73736fa0b7c
38 38
39 GtkWidget *imaway=NULL; 39 GtkWidget *imaway=NULL;
40 40
41 GtkWidget *awaymenu = NULL; 41 GtkWidget *awaymenu = NULL;
42 struct away_message *awaymessage = NULL; 42 struct away_message *awaymessage = NULL;
43 int default_away;
44 int auto_away;
43 45
44 static void destroy_im_away() 46 static void destroy_im_away()
45 { 47 {
46 if (imaway) 48 if (imaway)
47 gtk_widget_destroy(imaway); 49 gtk_widget_destroy(imaway);
54 applet_widget_unregister_callback(APPLET_WIDGET(applet),"away"); 56 applet_widget_unregister_callback(APPLET_WIDGET(applet),"away");
55 set_user_state(online); 57 set_user_state(online);
56 insert_applet_away(); 58 insert_applet_away();
57 #endif /* USE_APPLET */ 59 #endif /* USE_APPLET */
58 if (imaway) { 60 if (imaway) {
59 gtk_widget_destroy(imaway); 61 GtkWidget *tmp = imaway;
60 imaway=NULL; 62 imaway=NULL;
63 gtk_widget_destroy(tmp);
64 plugin_event(event_back, 0, 0, 0, 0);
61 } 65 }
62 66
63 serv_set_away(NULL); 67 serv_set_away(NULL);
64 awaymessage = NULL; 68 awaymessage = NULL;
65 plugin_event(event_back, 0, 0, 0, 0);
66 } 69 }
67 70
68 71
69 /* 72 /*
70 * rcg10312000 This could be more robust, but it works for my current 73 * rcg10312000 This could be more robust, but it works for my current
192 plugin_event(event_away, 0, 0, 0, 0); 195 plugin_event(event_away, 0, 0, 0, 0);
193 } 196 }
194 197
195 void rem_away_mess(GtkWidget *w, struct away_message *a) 198 void rem_away_mess(GtkWidget *w, struct away_message *a)
196 { 199 {
200 struct away_message *default_msg;
197 #ifdef USE_APPLET 201 #ifdef USE_APPLET
198 char *awayname; 202 char *awayname;
199 awayname = g_malloc(sizeof (*awayname) * (6 + strlen(a->name))); 203 awayname = g_malloc(sizeof (*awayname) * (6 + strlen(a->name)));
200 awayname[0] = '\0'; 204 awayname[0] = '\0';
201 strcat(awayname, "away/"); 205 strcat(awayname, "away/");
202 strcat(awayname, a->name); 206 strcat(awayname, a->name);
203 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname); 207 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname);
204 #endif 208 #endif
209 default_msg = g_slist_nth_data(away_messages, default_away);
205 away_messages = g_slist_remove(away_messages, a); 210 away_messages = g_slist_remove(away_messages, a);
211 default_away = g_slist_index(away_messages, default_msg);
212 if (default_away == -1)
213 default_away = 0;
206 g_free(a); 214 g_free(a);
207 do_away_menu(); 215 do_away_menu();
208 save_prefs(); 216 save_prefs();
209 } 217 }
210 218
252 } 260 }
253 if (away_messages != NULL) 261 if (away_messages != NULL)
254 gtk_list_select_item(GTK_LIST(prefs_away_list), 0); 262 gtk_list_select_item(GTK_LIST(prefs_away_list), 0);
255 } 263 }
256 264
257 if (!awaymenu) return; 265 if (awaymenu) {
258 l = gtk_container_children(GTK_CONTAINER(awaymenu)); 266 l = gtk_container_children(GTK_CONTAINER(awaymenu));
259 267
260 while(l) { 268 while(l) {
261 gtk_widget_destroy(GTK_WIDGET(l->data)); 269 gtk_widget_destroy(GTK_WIDGET(l->data));
262 l = l->next; 270 l = l->next;
263 } 271 }
264 272
265 273
266 remmenu = gtk_menu_new(); 274 remmenu = gtk_menu_new();
267 275
268 menuitem = gtk_menu_item_new_with_label(_("New Away Message")); 276 menuitem = gtk_menu_item_new_with_label(_("New Away Message"));
269 gtk_menu_append(GTK_MENU(awaymenu), menuitem);
270 gtk_widget_show(menuitem);
271 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(create_away_mess), NULL);
272
273 awy = away_messages;
274 while(awy) {
275 a = (struct away_message *)awy->data;
276
277 remitem = gtk_menu_item_new_with_label(a->name);
278 gtk_menu_append(GTK_MENU(remmenu), remitem);
279 gtk_widget_show(remitem);
280 gtk_signal_connect(GTK_OBJECT(remitem), "activate", GTK_SIGNAL_FUNC(rem_away_mess), a);
281
282 awy = g_slist_next(awy);
283
284 }
285
286 menuitem = gtk_menu_item_new_with_label(_("Remove Away Message"));
287 gtk_menu_append(GTK_MENU(awaymenu), menuitem);
288 gtk_widget_show(menuitem);
289 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), remmenu);
290 gtk_widget_show(remmenu);
291
292 sep = gtk_hseparator_new();
293 menuitem = gtk_menu_item_new();
294 gtk_menu_append(GTK_MENU(awaymenu), menuitem);
295 gtk_container_add(GTK_CONTAINER(menuitem), sep);
296 gtk_widget_set_sensitive(menuitem, FALSE);
297 gtk_widget_show(menuitem);
298 gtk_widget_show(sep);
299
300 awy = away_messages;
301
302 while(awy) {
303 a = (struct away_message *)awy->data;
304
305 menuitem = gtk_menu_item_new_with_label(a->name);
306 gtk_menu_append(GTK_MENU(awaymenu), menuitem); 277 gtk_menu_append(GTK_MENU(awaymenu), menuitem);
307 gtk_widget_show(menuitem); 278 gtk_widget_show(menuitem);
308 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(do_away_message), a); 279 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(create_away_mess), NULL);
309 280
310 awy = g_slist_next(awy); 281 awy = away_messages;
311 282 while(awy) {
312 } 283 a = (struct away_message *)awy->data;
313 284
314 } 285 remitem = gtk_menu_item_new_with_label(a->name);
315 286 gtk_menu_append(GTK_MENU(remmenu), remitem);
316 287 gtk_widget_show(remitem);
317 288 gtk_signal_connect(GTK_OBJECT(remitem), "activate", GTK_SIGNAL_FUNC(rem_away_mess), a);
318 289
319 290 awy = g_slist_next(awy);
320 291
292 }
293
294 menuitem = gtk_menu_item_new_with_label(_("Remove Away Message"));
295 gtk_menu_append(GTK_MENU(awaymenu), menuitem);
296 gtk_widget_show(menuitem);
297 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), remmenu);
298 gtk_widget_show(remmenu);
299
300 sep = gtk_hseparator_new();
301 menuitem = gtk_menu_item_new();
302 gtk_menu_append(GTK_MENU(awaymenu), menuitem);
303 gtk_container_add(GTK_CONTAINER(menuitem), sep);
304 gtk_widget_set_sensitive(menuitem, FALSE);
305 gtk_widget_show(menuitem);
306 gtk_widget_show(sep);
307
308 awy = away_messages;
309
310 while(awy) {
311 a = (struct away_message *)awy->data;
312
313 menuitem = gtk_menu_item_new_with_label(a->name);
314 gtk_menu_append(GTK_MENU(awaymenu), menuitem);
315 gtk_widget_show(menuitem);
316 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(do_away_message), a);
317
318 awy = g_slist_next(awy);
319
320 }
321 }
322 if (prefs_away_menu) {
323 l = gtk_container_children(GTK_CONTAINER(prefs_away_menu));
324 while(l) {
325 gtk_widget_destroy(GTK_WIDGET(l->data));
326 l = l->next;
327 }
328 gtk_widget_hide(GTK_WIDGET(prefs_away_menu));
329 default_away_menu_init(GTK_WIDGET(prefs_away_menu));
330 gtk_widget_show(prefs_away_menu);
331 }
332
333 }
334
335
336
337
338
339