Mercurial > pidgin
comparison src/gtkprefs.c @ 5684:b61520e71679
[gaim-migrate @ 6104]
sound is now really core/ui split.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 03 Jun 2003 03:33:20 +0000 |
parents | 46d7ad0dfa26 |
children | 52f301dbfeaa |
comparison
equal
deleted
inserted
replaced
5683:9befba33f7c8 | 5684:b61520e71679 |
---|---|
45 #include "gtkprefs.h" | 45 #include "gtkprefs.h" |
46 #include "prpl.h" | 46 #include "prpl.h" |
47 #include "prefs.h" | 47 #include "prefs.h" |
48 #include "proxy.h" | 48 #include "proxy.h" |
49 #include "sound.h" | 49 #include "sound.h" |
50 #include "gtksound.h" | |
50 #include "notify.h" | 51 #include "notify.h" |
51 | 52 |
52 #ifdef _WIN32 | 53 #ifdef _WIN32 |
53 #include "win32dep.h" | 54 #include "win32dep.h" |
54 #endif | 55 #endif |
1384 static GtkWidget *sndcmd = NULL; | 1385 static GtkWidget *sndcmd = NULL; |
1385 | 1386 |
1386 #ifndef _WIN32 | 1387 #ifndef _WIN32 |
1387 static gint sound_cmd_yeah(GtkEntry *entry, gpointer d) | 1388 static gint sound_cmd_yeah(GtkEntry *entry, gpointer d) |
1388 { | 1389 { |
1389 gaim_sound_set_command(gtk_entry_get_text(GTK_ENTRY(sndcmd))); | 1390 gaim_prefs_set_string("/gaim/gtk/sound/command", |
1391 gtk_entry_get_text(GTK_ENTRY(sndcmd))); | |
1390 return TRUE; | 1392 return TRUE; |
1391 } | 1393 } |
1392 #endif | 1394 #endif |
1393 | 1395 |
1394 GtkWidget *sound_page() { | 1396 GtkWidget *sound_page() { |
1397 GtkSizeGroup *sg; | 1399 GtkSizeGroup *sg; |
1398 #ifndef _WIN32 | 1400 #ifndef _WIN32 |
1399 GtkWidget *dd; | 1401 GtkWidget *dd; |
1400 GtkWidget *hbox; | 1402 GtkWidget *hbox; |
1401 GtkWidget *label; | 1403 GtkWidget *label; |
1402 char *cmd; | 1404 const char *cmd; |
1403 #endif | 1405 #endif |
1404 | 1406 |
1405 ret = gtk_vbox_new(FALSE, 18); | 1407 ret = gtk_vbox_new(FALSE, 18); |
1406 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); | 1408 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); |
1407 | 1409 |
1409 | 1411 |
1410 vbox = gaim_gtk_make_frame (ret, _("Sound Options")); | 1412 vbox = gaim_gtk_make_frame (ret, _("Sound Options")); |
1411 prefs_checkbox(_("_No sounds when you log in"), | 1413 prefs_checkbox(_("_No sounds when you log in"), |
1412 "/gaim/gtk/sound/silent_signon", vbox); | 1414 "/gaim/gtk/sound/silent_signon", vbox); |
1413 prefs_checkbox(_("_Sounds while away"), | 1415 prefs_checkbox(_("_Sounds while away"), |
1414 "/gaim/gtk/sound/while_away", vbox); | 1416 "/core/sound/while_away", vbox); |
1415 | 1417 |
1416 #ifndef _WIN32 | 1418 #ifndef _WIN32 |
1417 vbox = gaim_gtk_make_frame (ret, _("Sound Method")); | 1419 vbox = gaim_gtk_make_frame (ret, _("Sound Method")); |
1418 dd = prefs_dropdown(vbox, _("_Method"), GAIM_PREF_STRING, | 1420 dd = prefs_dropdown(vbox, _("_Method"), GAIM_PREF_STRING, |
1419 "/gaim/gtk/sound/sound_method", | 1421 "/gaim/gtk/sound/method", |
1420 _("Console beep"), "beep", | 1422 _("Console beep"), "beep", |
1421 #ifdef USE_AO | 1423 #ifdef USE_AO |
1422 _("Automatic"), "automatic", | 1424 _("Automatic"), "automatic", |
1423 "ESD", "esd", | 1425 "ESD", "esd", |
1424 "Arts", "arts", | 1426 "Arts", "arts", |
1425 #endif | 1427 #endif |
1426 #ifdef USE_NAS_AUDIO | 1428 #ifdef USE_NAS_AUDIO |
1427 "NAS", "nas", | 1429 "NAS", "nas", |
1428 #endif | 1430 #endif |
1429 _("Command"), "custom_command", | 1431 _("Command"), "custom", |
1430 NULL); | 1432 NULL); |
1431 gtk_size_group_add_widget(sg, dd); | 1433 gtk_size_group_add_widget(sg, dd); |
1432 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0); | 1434 gtk_misc_set_alignment(GTK_MISC(dd), 0, 0); |
1433 | 1435 |
1434 hbox = gtk_hbox_new(FALSE, 5); | 1436 hbox = gtk_hbox_new(FALSE, 5); |
1443 | 1445 |
1444 sndcmd = gtk_entry_new(); | 1446 sndcmd = gtk_entry_new(); |
1445 gtk_label_set_mnemonic_widget(GTK_LABEL(label), sndcmd); | 1447 gtk_label_set_mnemonic_widget(GTK_LABEL(label), sndcmd); |
1446 | 1448 |
1447 gtk_editable_set_editable(GTK_EDITABLE(sndcmd), TRUE); | 1449 gtk_editable_set_editable(GTK_EDITABLE(sndcmd), TRUE); |
1448 cmd = gaim_sound_get_command(); | 1450 cmd = gaim_prefs_get_string("/gaim/gtk/sound/command"); |
1449 if(cmd) | 1451 if(cmd) |
1450 gtk_entry_set_text(GTK_ENTRY(sndcmd), cmd); | 1452 gtk_entry_set_text(GTK_ENTRY(sndcmd), cmd); |
1451 gtk_widget_set_size_request(sndcmd, 75, -1); | 1453 gtk_widget_set_size_request(sndcmd, 75, -1); |
1452 | 1454 |
1453 gtk_widget_set_sensitive(sndcmd, | 1455 gtk_widget_set_sensitive(sndcmd, |
1454 !strcmp(gaim_prefs_get_string("/gaim/gtk/sound/sound_method"), | 1456 !strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), |
1455 "command")); | 1457 "command")); |
1456 | 1458 |
1457 gtk_box_pack_start(GTK_BOX(hbox), sndcmd, TRUE, TRUE, 5); | 1459 gtk_box_pack_start(GTK_BOX(hbox), sndcmd, TRUE, TRUE, 5); |
1458 g_signal_connect(G_OBJECT(sndcmd), "changed", | 1460 g_signal_connect(G_OBJECT(sndcmd), "changed", |
1459 G_CALLBACK(sound_cmd_yeah), NULL); | 1461 G_CALLBACK(sound_cmd_yeah), NULL); |
1852 gtk_tree_model_get_iter (model, &iter, path); | 1854 gtk_tree_model_get_iter (model, &iter, path); |
1853 gtk_tree_model_get (model, &iter, | 1855 gtk_tree_model_get (model, &iter, |
1854 2, &pref, | 1856 2, &pref, |
1855 -1); | 1857 -1); |
1856 | 1858 |
1857 gaim_prefs_set_bool(pref, gtk_cell_renderer_toggle_get_active(cell)); | 1859 gaim_prefs_set_bool(pref, !gtk_cell_renderer_toggle_get_active(cell)); |
1858 | 1860 |
1859 gtk_list_store_set(GTK_LIST_STORE (model), &iter, | 1861 gtk_list_store_set(GTK_LIST_STORE (model), &iter, |
1860 0, !gtk_cell_renderer_toggle_get_active(cell), | 1862 0, !gtk_cell_renderer_toggle_get_active(cell), |
1861 -1); | 1863 -1); |
1862 | 1864 |
1864 } | 1866 } |
1865 | 1867 |
1866 static void | 1868 static void |
1867 test_sound(GtkWidget *button, gpointer i_am_NULL) | 1869 test_sound(GtkWidget *button, gpointer i_am_NULL) |
1868 { | 1870 { |
1869 const char *pref; | 1871 char *pref; |
1870 gboolean temp_value1, temp_value2; | 1872 gboolean temp_value1, temp_value2; |
1871 | 1873 |
1872 pref = gaim_sound_get_event_option(sound_row_sel); | 1874 pref = g_strdup_printf("/gaim/gtk/sound/enabled/%s", |
1875 gaim_gtk_sound_get_event_option(sound_row_sel)); | |
1873 | 1876 |
1874 temp_value1 = gaim_prefs_get_bool("/gaim/gtk/sound/while_away"); | 1877 temp_value1 = gaim_prefs_get_bool("/gaim/gtk/sound/while_away"); |
1875 temp_value2 = gaim_prefs_get_bool(pref); | 1878 temp_value2 = gaim_prefs_get_bool(pref); |
1876 | 1879 |
1877 if (!temp_value1) gaim_prefs_set_bool("/gaim/gtk/sound/while_away", TRUE); | 1880 if (!temp_value1) gaim_prefs_set_bool("/gaim/gtk/sound/while_away", TRUE); |
1879 | 1882 |
1880 gaim_sound_play_event(sound_row_sel); | 1883 gaim_sound_play_event(sound_row_sel); |
1881 | 1884 |
1882 if (!temp_value1) gaim_prefs_set_bool("/gaim/gtk/sound/while_away", FALSE); | 1885 if (!temp_value1) gaim_prefs_set_bool("/gaim/gtk/sound/while_away", FALSE); |
1883 if (!temp_value2) gaim_prefs_set_bool(pref, FALSE); | 1886 if (!temp_value2) gaim_prefs_set_bool(pref, FALSE); |
1887 | |
1888 g_free(pref); | |
1884 } | 1889 } |
1885 | 1890 |
1886 static void | 1891 static void |
1887 reset_sound(GtkWidget *button, gpointer i_am_also_NULL) | 1892 reset_sound(GtkWidget *button, gpointer i_am_also_NULL) |
1888 { | 1893 { |
1894 char *pref = g_strdup_printf("/gaim/gtk/sound/file/%s", | |
1895 gaim_gtk_sound_get_event_option(sound_row_sel)); | |
1896 | |
1889 /* This just resets a sound file back to default */ | 1897 /* This just resets a sound file back to default */ |
1890 gaim_sound_set_event_file(sound_row_sel, NULL); | 1898 gaim_prefs_set_string(pref, ""); |
1899 g_free(pref); | |
1891 | 1900 |
1892 gtk_entry_set_text(GTK_ENTRY(sound_entry), "(default)"); | 1901 gtk_entry_set_text(GTK_ENTRY(sound_entry), "(default)"); |
1893 } | 1902 } |
1894 | 1903 |
1895 void close_sounddialog(GtkWidget *w, GtkWidget *w2) | 1904 void close_sounddialog(GtkWidget *w, GtkWidget *w2) |
1908 } | 1917 } |
1909 | 1918 |
1910 void do_select_sound(GtkWidget *w, int snd) | 1919 void do_select_sound(GtkWidget *w, int snd) |
1911 { | 1920 { |
1912 const char *file; | 1921 const char *file; |
1922 char *pref; | |
1913 | 1923 |
1914 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(sounddialog)); | 1924 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(sounddialog)); |
1915 | 1925 |
1916 /* If they type in a directory, change there */ | 1926 /* If they type in a directory, change there */ |
1917 if (file_is_dir(file, sounddialog)) | 1927 if (file_is_dir(file, sounddialog)) |
1918 return; | 1928 return; |
1919 | 1929 |
1920 /* Set it -- and forget it */ | 1930 /* Set it -- and forget it */ |
1921 gaim_sound_set_event_file(snd, file); | 1931 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", |
1932 gaim_gtk_sound_get_event_option(snd)); | |
1933 gaim_prefs_set_string(pref, file); | |
1934 g_free(pref); | |
1922 | 1935 |
1923 /* Set our text entry */ | 1936 /* Set our text entry */ |
1924 gtk_entry_set_text(GTK_ENTRY(sound_entry), file); | 1937 gtk_entry_set_text(GTK_ENTRY(sound_entry), file); |
1925 | 1938 |
1926 /* Close the window! It's getting cold in here! */ | 1939 /* Close the window! It's getting cold in here! */ |
1963 | 1976 |
1964 | 1977 |
1965 static void prefs_sound_sel (GtkTreeSelection *sel, GtkTreeModel *model) { | 1978 static void prefs_sound_sel (GtkTreeSelection *sel, GtkTreeModel *model) { |
1966 GtkTreeIter iter; | 1979 GtkTreeIter iter; |
1967 GValue val = { 0, }; | 1980 GValue val = { 0, }; |
1968 char *file; | 1981 const char *file; |
1982 char *pref; | |
1969 | 1983 |
1970 if (! gtk_tree_selection_get_selected (sel, &model, &iter)) | 1984 if (! gtk_tree_selection_get_selected (sel, &model, &iter)) |
1971 return; | 1985 return; |
1972 gtk_tree_model_get_value (model, &iter, 3, &val); | 1986 gtk_tree_model_get_value (model, &iter, 3, &val); |
1973 sound_row_sel = g_value_get_uint(&val); | 1987 sound_row_sel = g_value_get_uint(&val); |
1974 file = gaim_sound_get_event_file(sound_row_sel); | 1988 |
1989 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", | |
1990 gaim_gtk_sound_get_event_option(sound_row_sel)); | |
1991 file = gaim_prefs_get_string(pref); | |
1992 g_free(pref); | |
1975 if (sound_entry) | 1993 if (sound_entry) |
1976 gtk_entry_set_text(GTK_ENTRY(sound_entry), file ? file : "(default)"); | 1994 gtk_entry_set_text(GTK_ENTRY(sound_entry), file ? file : "(default)"); |
1977 g_value_unset (&val); | 1995 g_value_unset (&val); |
1978 if (sounddialog) | 1996 if (sounddialog) |
1979 gtk_widget_destroy(sounddialog); | 1997 gtk_widget_destroy(sounddialog); |
1990 GtkCellRenderer *rend; | 2008 GtkCellRenderer *rend; |
1991 GtkTreeViewColumn *col; | 2009 GtkTreeViewColumn *col; |
1992 GtkTreeSelection *sel; | 2010 GtkTreeSelection *sel; |
1993 GtkTreePath *path; | 2011 GtkTreePath *path; |
1994 int j; | 2012 int j; |
1995 char *file; | 2013 const char *file; |
2014 char *pref; | |
1996 | 2015 |
1997 ret = gtk_vbox_new(FALSE, 18); | 2016 ret = gtk_vbox_new(FALSE, 18); |
1998 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); | 2017 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); |
1999 | 2018 |
2000 sw = gtk_scrolled_window_new(NULL,NULL); | 2019 sw = gtk_scrolled_window_new(NULL,NULL); |
2003 | 2022 |
2004 gtk_box_pack_start(GTK_BOX(ret), sw, TRUE, TRUE, 0); | 2023 gtk_box_pack_start(GTK_BOX(ret), sw, TRUE, TRUE, 0); |
2005 event_store = gtk_list_store_new (4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); | 2024 event_store = gtk_list_store_new (4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); |
2006 | 2025 |
2007 for (j=0; j < GAIM_NUM_SOUNDS; j++) { | 2026 for (j=0; j < GAIM_NUM_SOUNDS; j++) { |
2008 const char *pref = gaim_sound_get_event_option(j); | 2027 char *pref = g_strdup_printf("/gaim/gtk/sound/enabled/%s", |
2009 | 2028 gaim_gtk_sound_get_event_option(j)); |
2010 if (pref == NULL) | 2029 const char *label = gaim_gtk_sound_get_event_label(j); |
2030 | |
2031 if (label == NULL) | |
2011 continue; | 2032 continue; |
2012 | 2033 |
2013 gtk_list_store_append (event_store, &iter); | 2034 gtk_list_store_append (event_store, &iter); |
2014 gtk_list_store_set(event_store, &iter, | 2035 gtk_list_store_set(event_store, &iter, |
2015 0, gaim_prefs_get_bool(pref), | 2036 0, gaim_prefs_get_bool(pref), |
2016 1, _(gaim_sound_get_event_label(j)), | 2037 1, _(label), |
2017 2, pref, | 2038 2, pref, |
2018 3, j, | 2039 3, j, |
2019 -1); | 2040 -1); |
2041 g_free(pref); | |
2020 } | 2042 } |
2021 | 2043 |
2022 event_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(event_store)); | 2044 event_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(event_store)); |
2023 | 2045 |
2024 rend = gtk_cell_renderer_toggle_new(); | 2046 rend = gtk_cell_renderer_toggle_new(); |
2048 gtk_container_add(GTK_CONTAINER(sw), event_view); | 2070 gtk_container_add(GTK_CONTAINER(sw), event_view); |
2049 | 2071 |
2050 hbox = gtk_hbox_new(FALSE, 6); | 2072 hbox = gtk_hbox_new(FALSE, 6); |
2051 gtk_box_pack_start(GTK_BOX(ret), hbox, FALSE, FALSE, 0); | 2073 gtk_box_pack_start(GTK_BOX(ret), hbox, FALSE, FALSE, 0); |
2052 sound_entry = gtk_entry_new(); | 2074 sound_entry = gtk_entry_new(); |
2053 file = gaim_sound_get_event_file(0); | 2075 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", |
2076 gaim_gtk_sound_get_event_option(0)); | |
2077 file = gaim_prefs_get_string(pref); | |
2078 g_free(pref); | |
2054 gtk_entry_set_text(GTK_ENTRY(sound_entry), file ? file : "(default)"); | 2079 gtk_entry_set_text(GTK_ENTRY(sound_entry), file ? file : "(default)"); |
2055 gtk_editable_set_editable(GTK_EDITABLE(sound_entry), FALSE); | 2080 gtk_editable_set_editable(GTK_EDITABLE(sound_entry), FALSE); |
2056 gtk_box_pack_start(GTK_BOX(hbox), sound_entry, FALSE, FALSE, 5); | 2081 gtk_box_pack_start(GTK_BOX(hbox), sound_entry, FALSE, FALSE, 5); |
2057 | 2082 |
2058 button = gtk_button_new_with_label(_("Test")); | 2083 button = gtk_button_new_with_label(_("Test")); |
2764 gaim_prefs_add_int("/gaim/gtk/blist/x", 0); | 2789 gaim_prefs_add_int("/gaim/gtk/blist/x", 0); |
2765 gaim_prefs_add_int("/gaim/gtk/blist/y", 0); | 2790 gaim_prefs_add_int("/gaim/gtk/blist/y", 0); |
2766 gaim_prefs_add_int("/gaim/gtk/blist/width", 0); | 2791 gaim_prefs_add_int("/gaim/gtk/blist/width", 0); |
2767 gaim_prefs_add_int("/gaim/gtk/blist/height", 0); | 2792 gaim_prefs_add_int("/gaim/gtk/blist/height", 0); |
2768 | 2793 |
2769 /* Debug window preferences. */ | |
2770 /* | |
2771 * NOTE: This must be set before prefs are loaded, and the callbacks | |
2772 * set after they are loaded, since prefs sets the enabled | |
2773 * preference here and that loads the window, which calls the | |
2774 * configure event, which overrrides the width and height! :P | |
2775 */ | |
2776 gaim_prefs_add_none("/gaim/gtk/debug"); | |
2777 gaim_prefs_add_bool("/gaim/gtk/debug/enabled", FALSE); | |
2778 gaim_prefs_add_bool("/gaim/gtk/debug/timestamps", FALSE); | |
2779 gaim_prefs_add_bool("/gaim/gtk/debug/toolbar", TRUE); | |
2780 gaim_prefs_add_int("/gaim/gtk/debug/width", 450); | |
2781 gaim_prefs_add_int("/gaim/gtk/debug/height", 250); | |
2782 | |
2783 /* Idle */ | 2794 /* Idle */ |
2784 gaim_prefs_add_none("/gaim/gtk/idle"); | 2795 gaim_prefs_add_none("/gaim/gtk/idle"); |
2785 gaim_prefs_add_string("/gaim/gtk/idle/reporting_method", "system"); | 2796 gaim_prefs_add_string("/gaim/gtk/idle/reporting_method", "system"); |
2786 | 2797 |
2787 /* Logging */ | 2798 /* Logging */ |
2797 | 2808 |
2798 /* Smiley Themes */ | 2809 /* Smiley Themes */ |
2799 gaim_prefs_add_none("/gaim/gtk/smileys"); | 2810 gaim_prefs_add_none("/gaim/gtk/smileys"); |
2800 gaim_prefs_add_string("/gaim/gtk/smileys/theme", ""); | 2811 gaim_prefs_add_string("/gaim/gtk/smileys/theme", ""); |
2801 | 2812 |
2802 /* Sound */ | 2813 } |
2803 gaim_prefs_add_none("/gaim/gtk/sound"); | 2814 |
2804 gaim_prefs_add_bool("/gaim/gtk/sound/login", TRUE); | |
2805 gaim_prefs_add_bool("/gaim/gtk/sound/logout", TRUE); | |
2806 gaim_prefs_add_bool("/gaim/gtk/sound/im_recv", TRUE); | |
2807 gaim_prefs_add_bool("/gaim/gtk/sound/first_im_recv", FALSE); | |
2808 gaim_prefs_add_bool("/gaim/gtk/sound/send_im", TRUE); | |
2809 gaim_prefs_add_bool("/gaim/gtk/sound/join_chat", FALSE); | |
2810 gaim_prefs_add_bool("/gaim/gtk/sound/left_chat", FALSE); | |
2811 gaim_prefs_add_bool("/gaim/gtk/sound/send_chat_msg", FALSE); | |
2812 gaim_prefs_add_bool("/gaim/gtk/sound/chat_msg_recv", FALSE); | |
2813 gaim_prefs_add_bool("/gaim/gtk/sound/nick_said", FALSE); | |
2814 gaim_prefs_add_bool("/gaim/gtk/sound/silent_signon", TRUE); | |
2815 gaim_prefs_add_bool("/gaim/gtk/sound/while_away", TRUE); | |
2816 gaim_prefs_add_string("/gaim/gtk/sound/command", ""); | |
2817 gaim_prefs_add_string("/gaim/gtk/sound/sound_method", "automatic"); | |
2818 } | |
2819 |