comparison src/gtkprefs.c @ 6216:dc42b27101c0

[gaim-migrate @ 6702] fix the saving and importing of the default away message committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 18 Jul 2003 14:34:08 +0000
parents 1440cfa8b1e1
children 8f94cce8faa5
comparison
equal deleted inserted replaced
6215:643c7d3a18c2 6216:dc42b27101c0
2527 } 2527 }
2528 2528
2529 void default_away_menu_init(GtkWidget *omenu) 2529 void default_away_menu_init(GtkWidget *omenu)
2530 { 2530 {
2531 GtkWidget *menu, *opt; 2531 GtkWidget *menu, *opt;
2532 int index = 0; 2532 int index = 0, default_index = 0;
2533 GSList *awy = away_messages; 2533 GSList *awy = away_messages;
2534 struct away_message *a; 2534 struct away_message *a;
2535 const char *default_name;
2535 2536
2536 menu = gtk_menu_new(); 2537 menu = gtk_menu_new();
2538
2539 default_name = gaim_prefs_get_string("/core/away/default_message");
2537 2540
2538 while (awy) { 2541 while (awy) {
2539 a = (struct away_message *)awy->data; 2542 a = (struct away_message *)awy->data;
2540 opt = gtk_menu_item_new_with_label(a->name); 2543 opt = gtk_menu_item_new_with_label(a->name);
2541 g_signal_connect(G_OBJECT(opt), "activate", 2544 g_signal_connect(G_OBJECT(opt), "activate",
2542 G_CALLBACK(set_default_away), (gpointer)index); 2545 G_CALLBACK(set_default_away), (gpointer)index);
2543 gtk_widget_show(opt); 2546 gtk_widget_show(opt);
2544 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); 2547 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt);
2545 2548
2549 if(!strcmp(default_name, a->name))
2550 default_index = index;
2551
2546 awy = awy->next; 2552 awy = awy->next;
2547 index++; 2553 index++;
2548 } 2554 }
2549 2555
2550 gtk_option_menu_remove_menu(GTK_OPTION_MENU(omenu)); 2556 gtk_option_menu_remove_menu(GTK_OPTION_MENU(omenu));
2551 gtk_option_menu_set_menu(GTK_OPTION_MENU(omenu), menu); 2557 gtk_option_menu_set_menu(GTK_OPTION_MENU(omenu), menu);
2552 gtk_option_menu_set_history(GTK_OPTION_MENU(omenu), g_slist_index(away_messages, default_away)); 2558 gtk_option_menu_set_history(GTK_OPTION_MENU(omenu), default_index);
2553 } 2559 }
2554 2560
2555 GtkWidget *pref_fg_picture = NULL; 2561 GtkWidget *pref_fg_picture = NULL;
2556 GtkWidget *pref_bg_picture = NULL; 2562 GtkWidget *pref_bg_picture = NULL;
2557 2563
2602 gaim_conversation_foreach(gaim_gtkconv_update_font_colors); 2608 gaim_conversation_foreach(gaim_gtkconv_update_font_colors);
2603 } 2609 }
2604 2610
2605 void set_default_away(GtkWidget *w, gpointer i) 2611 void set_default_away(GtkWidget *w, gpointer i)
2606 { 2612 {
2607 2613 struct away_message *default_away = NULL;
2608 int length = g_slist_length(away_messages); 2614 int length = g_slist_length(away_messages);
2609 2615
2610 if (away_messages == NULL) 2616 if (away_messages == NULL)
2611 default_away = NULL; 2617 default_away = NULL;
2612 else if ((int)i >= length) 2618 else if ((int)i >= length)
2613 default_away = g_slist_nth_data(away_messages, length - 1); 2619 default_away = g_slist_nth_data(away_messages, length - 1);
2614 else 2620 else
2615 default_away = g_slist_nth_data(away_messages, (int)i); 2621 default_away = g_slist_nth_data(away_messages, (int)i);
2622
2623 if(default_away)
2624 gaim_prefs_set_string("/core/away/default_message", default_away->name);
2625 else
2626 gaim_prefs_set_string("/core/away/default_message", "");
2616 } 2627 }
2617 2628
2618 static GtkWidget *show_color_pref(GtkWidget *box, gboolean fgc) 2629 static GtkWidget *show_color_pref(GtkWidget *box, gboolean fgc)
2619 { 2630 {
2620 /* more stuff stolen from X-Chat */ 2631 /* more stuff stolen from X-Chat */