comparison src/prefs.c @ 4064:b188b93ebf48

[gaim-migrate @ 4274] (23:01:14) LSchiere: okay, this patch fixes at least some of the problems saving sound, away, and font preferences. it makes spin buttons and entry widgets save prefs on loss of focus or dialog close instead of on change. (23:01:17) LSchiere: anything else it does? (23:01:44) faceprint: it makes nothing save unless you hit close. however, everything saves when you hit close. (23:02:06) LSchiere: they still apply before close? (23:02:09) faceprint: it should right most of the wrongs of prefs (23:02:25) faceprint: they apply before close, but aren't written to disk every time you check or uncheck a checkbox or something (23:02:27) Paco-Paco: it looks OK committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 12 Dec 2002 04:03:53 +0000
parents fe0cf4c9115d
children 3ccbdf8e7f8d
comparison
equal deleted inserted replaced
4063:f8090a166e57 4064:b188b93ebf48
80 * PROTOTYPES 80 * PROTOTYPES
81 */ 81 */
82 GtkTreeIter *prefs_notebook_add_page(char*, GdkPixbuf*, GtkWidget*, GtkTreeIter*, GtkTreeIter*, int); 82 GtkTreeIter *prefs_notebook_add_page(char*, GdkPixbuf*, GtkWidget*, GtkTreeIter*, GtkTreeIter*, int);
83 83
84 void delete_prefs(GtkWidget *asdf, void *gdsa) { 84 void delete_prefs(GtkWidget *asdf, void *gdsa) {
85 save_prefs();
85 prefs = NULL; 86 prefs = NULL;
86 tree_v = NULL; 87 tree_v = NULL;
87 sound_entry = NULL; 88 sound_entry = NULL;
88 browser_entry = NULL; 89 browser_entry = NULL;
89 debugbutton = NULL; 90 debugbutton = NULL;
1534 { 1535 {
1535 if (debugbutton) 1536 if (debugbutton)
1536 gtk_button_clicked(GTK_BUTTON(debugbutton)); 1537 gtk_button_clicked(GTK_BUTTON(debugbutton));
1537 if (misc_options & OPT_MISC_DEBUG) { 1538 if (misc_options & OPT_MISC_DEBUG) {
1538 misc_options ^= OPT_MISC_DEBUG; 1539 misc_options ^= OPT_MISC_DEBUG;
1539 save_prefs();
1540 } 1540 }
1541 g_free(dw); 1541 g_free(dw);
1542 dw = NULL; 1542 dw = NULL;
1543 return FALSE; 1543 return FALSE;
1544 1544
1627 { 1627 {
1628 misc_options ^= option; 1628 misc_options ^= option;
1629 1629
1630 if (option == OPT_MISC_DEBUG) 1630 if (option == OPT_MISC_DEBUG)
1631 show_debug(); 1631 show_debug();
1632
1633 save_prefs();
1634 } 1632 }
1635 1633
1636 static void set_logging_option(GtkWidget *w, int option) 1634 static void set_logging_option(GtkWidget *w, int option)
1637 { 1635 {
1638 logging_options ^= option; 1636 logging_options ^= option;
1639 1637
1640 if (option == OPT_LOG_CONVOS || option == OPT_LOG_CHATS) 1638 if (option == OPT_LOG_CONVOS || option == OPT_LOG_CHATS)
1641 update_log_convs(); 1639 update_log_convs();
1642
1643 save_prefs();
1644 } 1640 }
1645 1641
1646 static void set_blist_option(GtkWidget *w, int option) 1642 static void set_blist_option(GtkWidget *w, int option)
1647 { 1643 {
1648 blist_options ^= option; 1644 blist_options ^= option;
1649
1650 save_prefs();
1651 1645
1652 if (!blist) 1646 if (!blist)
1653 return; 1647 return;
1654 1648
1655 if (option == OPT_BLIST_NO_BUTTONS) 1649 if (option == OPT_BLIST_NO_BUTTONS)
1682 if (option == OPT_CONVO_SHOW_TIME) 1676 if (option == OPT_CONVO_SHOW_TIME)
1683 toggle_timestamps(); 1677 toggle_timestamps();
1684 1678
1685 if (option == OPT_CONVO_CHECK_SPELLING) 1679 if (option == OPT_CONVO_CHECK_SPELLING)
1686 toggle_spellchk(); 1680 toggle_spellchk();
1687
1688 save_prefs();
1689 } 1681 }
1690 1682
1691 static void set_im_option(GtkWidget *w, int option) 1683 static void set_im_option(GtkWidget *w, int option)
1692 { 1684 {
1693 im_options ^= option; 1685 im_options ^= option;
1702 set_convo_titles(); 1694 set_convo_titles();
1703 } 1695 }
1704 1696
1705 if (option == OPT_IM_NO_ANIMATION) 1697 if (option == OPT_IM_NO_ANIMATION)
1706 set_anim(); 1698 set_anim();
1707
1708 save_prefs();
1709 } 1699 }
1710 1700
1711 static void set_chat_option(GtkWidget *w, int option) 1701 static void set_chat_option(GtkWidget *w, int option)
1712 { 1702 {
1713 chat_options ^= option; 1703 chat_options ^= option;
1714 1704
1715 if (option == OPT_CHAT_ONE_WINDOW) 1705 if (option == OPT_CHAT_ONE_WINDOW)
1716 chat_tabize(); 1706 chat_tabize();
1717
1718 save_prefs();
1719 } 1707 }
1720 1708
1721 void set_sound_option(GtkWidget *w, int option) 1709 void set_sound_option(GtkWidget *w, int option)
1722 { 1710 {
1723 sound_options ^= option; 1711 sound_options ^= option;
1724
1725 save_prefs();
1726 } 1712 }
1727 1713
1728 static void set_font_option(GtkWidget *w, int option) 1714 static void set_font_option(GtkWidget *w, int option)
1729 { 1715 {
1730 font_options ^= option; 1716 font_options ^= option;
1731 1717
1732 update_font_buttons(); 1718 update_font_buttons();
1733
1734 save_prefs();
1735 } 1719 }
1736 1720
1737 static void set_away_option(GtkWidget *w, int option) 1721 static void set_away_option(GtkWidget *w, int option)
1738 { 1722 {
1739 away_options ^= option; 1723 away_options ^= option;
1740 1724
1741 if (option == OPT_AWAY_QUEUE) 1725 if (option == OPT_AWAY_QUEUE)
1742 toggle_away_queue(); 1726 toggle_away_queue();
1743
1744 save_prefs();
1745 } 1727 }
1746 1728
1747 GtkWidget *gaim_button(const char *text, guint *options, int option, GtkWidget *page) 1729 GtkWidget *gaim_button(const char *text, guint *options, int option, GtkWidget *page)
1748 { 1730 {
1749 GtkWidget *button; 1731 GtkWidget *button;
1750 button = gtk_check_button_new_with_mnemonic(text); 1732 button = gtk_check_button_new_with_mnemonic(text);
1751 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (*options & option)); 1733 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (*options & option));
1752 gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0); 1734 gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0);
1753 gtk_object_set_user_data(GTK_OBJECT(button), options); 1735 gtk_object_set_user_data(GTK_OBJECT(button), options);
1754 1736
1755 if (options == &misc_options) 1737 if (options == &misc_options) {
1756 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_misc_option), 1738 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_misc_option),
1757 (int *)option); 1739 (int *)option);
1758 if (options == &logging_options) 1740 } else if (options == &logging_options) {
1759 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_logging_option), 1741 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_logging_option),
1760 (int *)option); 1742 (int *)option);
1761 if (options == &blist_options) 1743 } else if (options == &blist_options) {
1762 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_blist_option), 1744 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_blist_option),
1763 (int *)option); 1745 (int *)option);
1764 if (options == &convo_options) 1746 } else if (options == &convo_options) {
1765 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_convo_option), 1747 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_convo_option),
1766 (int *)option); 1748 (int *)option);
1767 if (options == &im_options) 1749 } else if (options == &im_options) {
1768 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_im_option), 1750 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_im_option),
1769 (int *)option); 1751 (int *)option);
1770 if (options == &chat_options) 1752 } else if (options == &chat_options) {
1771 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_chat_option), 1753 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_chat_option),
1772 (int *)option); 1754 (int *)option);
1773 if (options == &font_options) 1755 } else if (options == &font_options) {
1774 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_font_option), 1756 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_font_option),
1775 (int *)option); 1757 (int *)option);
1776 if (options == &sound_options) 1758 } else if (options == &sound_options) {
1777 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_sound_option), 1759 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_sound_option),
1778 (int *)option); 1760 (int *)option);
1761 } else if (options == &away_options) {
1762 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_away_option),
1763 (int *)option);
1764 } else {
1765 debug_printf("gaim_button: \"%s\" has no signal handler attached to it!\n", text);
1766 }
1779 gtk_widget_show(button); 1767 gtk_widget_show(button);
1780 1768
1781 return button; 1769 return button;
1782 } 1770 }
1783 1771
1871 style = gtk_style_new(); 1859 style = gtk_style_new();
1872 style->bg[0] = c; 1860 style->bg[0] = c;
1873 gtk_widget_set_style(pic, style); 1861 gtk_widget_set_style(pic, style);
1874 gtk_style_unref(style); 1862 gtk_style_unref(style);
1875 } 1863 }
1864
1876 void set_default_away(GtkWidget *w, gpointer i) 1865 void set_default_away(GtkWidget *w, gpointer i)
1877 { 1866 {
1878 1867
1879 int length = g_slist_length(away_messages); 1868 int length = g_slist_length(away_messages);
1880 1869
1889 static void update_spin_value(GtkWidget *w, GtkWidget *spin) 1878 static void update_spin_value(GtkWidget *w, GtkWidget *spin)
1890 { 1879 {
1891 int *value = gtk_object_get_user_data(GTK_OBJECT(spin)); 1880 int *value = gtk_object_get_user_data(GTK_OBJECT(spin));
1892 *value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin)); 1881 *value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
1893 } 1882 }
1883
1894 GtkWidget *gaim_labeled_spin_button(GtkWidget *box, const gchar *title, int *val, int min, int max, GtkSizeGroup *sg) 1884 GtkWidget *gaim_labeled_spin_button(GtkWidget *box, const gchar *title, int *val, int min, int max, GtkSizeGroup *sg)
1895 { 1885 {
1896 GtkWidget *hbox; 1886 GtkWidget *hbox;
1897 GtkWidget *label; 1887 GtkWidget *label;
1898 GtkWidget *spin; 1888 GtkWidget *spin;
1910 spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); 1900 spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0);
1911 gtk_object_set_user_data(GTK_OBJECT(spin), val); 1901 gtk_object_set_user_data(GTK_OBJECT(spin), val);
1912 gtk_widget_set_usize(spin, 50, -1); 1902 gtk_widget_set_usize(spin, 50, -1);
1913 gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0); 1903 gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0);
1914 gtk_signal_connect(GTK_OBJECT(adjust), "value-changed", 1904 gtk_signal_connect(GTK_OBJECT(adjust), "value-changed",
1915 GTK_SIGNAL_FUNC(update_spin_value), GTK_WIDGET(spin)); 1905 GTK_SIGNAL_FUNC(update_spin_value), GTK_WIDGET(spin));
1916 gtk_widget_show(spin); 1906 gtk_widget_show(spin);
1917 1907
1918 gtk_label_set_mnemonic_widget(GTK_LABEL(label), spin); 1908 gtk_label_set_mnemonic_widget(GTK_LABEL(label), spin);
1919 1909
1920 if (sg) { 1910 if (sg) {
1964 else if (clear == (OPT_CHAT_BUTTON_TEXT | OPT_CHAT_BUTTON_XPM)) 1954 else if (clear == (OPT_CHAT_BUTTON_TEXT | OPT_CHAT_BUTTON_XPM))
1965 update_im_button_pix(); 1955 update_im_button_pix();
1966 } else if (option == (int*)&blist_options) { 1956 } else if (option == (int*)&blist_options) {
1967 set_blist_tab(); 1957 set_blist_tab();
1968 } 1958 }
1969
1970 } 1959 }
1971 1960
1972 static GtkWidget *gaim_dropdown(GtkWidget *box, const gchar *title, int *option, int clear, ...) 1961 static GtkWidget *gaim_dropdown(GtkWidget *box, const gchar *title, int *option, int clear, ...)
1973 { 1962 {
1974 va_list menuitems; 1963 va_list menuitems;
2061 gtk_widget_set_usize(GTK_WIDGET(swid), 40, -1); 2050 gtk_widget_set_usize(GTK_WIDGET(swid), 40, -1);
2062 gtk_box_pack_start(GTK_BOX(box), swid, FALSE, FALSE, 5); 2051 gtk_box_pack_start(GTK_BOX(box), swid, FALSE, FALSE, 5);
2063 gtk_widget_show(swid); 2052 gtk_widget_show(swid);
2064 return swid; 2053 return swid;
2065 } 2054 }
2055
2066 void apply_font_dlg(GtkWidget *w, GtkWidget *f) 2056 void apply_font_dlg(GtkWidget *w, GtkWidget *f)
2067 { 2057 {
2068 int i = 0; 2058 int i = 0;
2069 char *fontname; 2059 char *fontname;
2070 2060