Mercurial > pidgin
comparison src/gtkprefs.c @ 9508:0123d883616c
[gaim-migrate @ 10335]
Another victory for the request API. 3.14 penguin points for Chip!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 11 Jul 2004 18:29:47 +0000 |
parents | d4e3356e7bbc |
children | 9b2f1444811f |
comparison
equal
deleted
inserted
replaced
9507:7c28878de23a | 9508:0123d883616c |
---|---|
28 #include "debug.h" | 28 #include "debug.h" |
29 #include "notify.h" | 29 #include "notify.h" |
30 #include "prefs.h" | 30 #include "prefs.h" |
31 #include "proxy.h" | 31 #include "proxy.h" |
32 #include "prpl.h" | 32 #include "prpl.h" |
33 #include "request.h" | |
33 #include "sound.h" | 34 #include "sound.h" |
34 #include "util.h" | 35 #include "util.h" |
35 #include "network.h" | 36 #include "network.h" |
36 | 37 |
37 #include "gtkblist.h" | 38 #include "gtkblist.h" |
59 | 60 |
60 static GtkWidget *tree_v = NULL; | 61 static GtkWidget *tree_v = NULL; |
61 | 62 |
62 | 63 |
63 static int sound_row_sel = 0; | 64 static int sound_row_sel = 0; |
64 static char *last_sound_dir = NULL; | |
65 static GtkWidget *preflabel; | 65 static GtkWidget *preflabel; |
66 static GtkWidget *prefsnotebook; | 66 static GtkWidget *prefsnotebook; |
67 static GtkTreeStore *prefstree; | 67 static GtkTreeStore *prefstree; |
68 | 68 |
69 | 69 |
70 static GtkWidget *sounddialog = NULL; | |
71 static GtkWidget *sound_entry = NULL; | 70 static GtkWidget *sound_entry = NULL; |
72 static GtkWidget *away_text = NULL; | 71 static GtkWidget *away_text = NULL; |
73 static GtkListStore *smiley_theme_store = NULL; | 72 static GtkListStore *smiley_theme_store = NULL; |
74 static GtkWidget *prefs_proxy_frame = NULL; | 73 static GtkWidget *prefs_proxy_frame = NULL; |
75 | 74 |
361 delete_prefs(GtkWidget *asdf, void *gdsa) | 360 delete_prefs(GtkWidget *asdf, void *gdsa) |
362 { | 361 { |
363 GList *l; | 362 GList *l; |
364 GaimPlugin *plug; | 363 GaimPlugin *plug; |
365 | 364 |
365 /* Close any "select sound" request dialogs */ | |
366 gaim_request_close_with_handle(prefs); | |
367 | |
366 gaim_plugins_unregister_probe_notify_cb(update_plugin_list); | 368 gaim_plugins_unregister_probe_notify_cb(update_plugin_list); |
367 | 369 |
368 prefs = NULL; | 370 prefs = NULL; |
369 tree_v = NULL; | 371 tree_v = NULL; |
370 sound_entry = NULL; | 372 sound_entry = NULL; |
371 debugbutton = NULL; | 373 debugbutton = NULL; |
372 prefs_away_menu = NULL; | 374 prefs_away_menu = NULL; |
373 notebook_page = 0; | 375 notebook_page = 0; |
374 smiley_theme_store = NULL; | 376 smiley_theme_store = NULL; |
375 if(sounddialog) | |
376 gtk_widget_destroy(sounddialog); | |
377 g_object_unref(G_OBJECT(prefs_away_store)); | 377 g_object_unref(G_OBJECT(prefs_away_store)); |
378 prefs_away_store = NULL; | 378 prefs_away_store = NULL; |
379 | 379 |
380 /* Unregister callbacks. */ | 380 /* Unregister callbacks. */ |
381 gaim_prefs_disconnect_callback(browser_pref1_id); | 381 gaim_prefs_disconnect_callback(browser_pref1_id); |
1536 if (!temp_value2) gaim_prefs_set_bool(pref, FALSE); | 1536 if (!temp_value2) gaim_prefs_set_bool(pref, FALSE); |
1537 | 1537 |
1538 g_free(pref); | 1538 g_free(pref); |
1539 } | 1539 } |
1540 | 1540 |
1541 /* | |
1542 * Resets a sound file back to default. | |
1543 */ | |
1541 static void | 1544 static void |
1542 reset_sound(GtkWidget *button, gpointer i_am_also_NULL) | 1545 reset_sound(GtkWidget *button, gpointer i_am_also_NULL) |
1543 { | 1546 { |
1544 char *pref = g_strdup_printf("/gaim/gtk/sound/file/%s", | 1547 gchar *pref; |
1545 gaim_gtk_sound_get_event_option(sound_row_sel)); | 1548 |
1546 | 1549 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", |
1547 /* This just resets a sound file back to default */ | 1550 gaim_gtk_sound_get_event_option(sound_row_sel)); |
1548 gaim_prefs_set_string(pref, ""); | 1551 gaim_prefs_set_string(pref, ""); |
1549 g_free(pref); | 1552 g_free(pref); |
1550 | 1553 |
1551 gtk_entry_set_text(GTK_ENTRY(sound_entry), "(default)"); | 1554 gtk_entry_set_text(GTK_ENTRY(sound_entry), "(default)"); |
1552 } | 1555 } |
1553 | 1556 |
1554 void close_sounddialog(GtkWidget *w, GtkWidget *w2) | 1557 static void |
1555 { | 1558 sound_chosen_cb(void *user_data, const char *filename) |
1556 | 1559 { |
1557 GtkWidget *dest; | 1560 gchar *pref; |
1558 | 1561 int sound; |
1559 if (!GTK_IS_WIDGET(w2)) | 1562 |
1560 dest = w; | 1563 sound = GPOINTER_TO_INT(user_data); |
1561 else | |
1562 dest = w2; | |
1563 | |
1564 sounddialog = NULL; | |
1565 | |
1566 gtk_widget_destroy(dest); | |
1567 } | |
1568 | |
1569 void do_select_sound(GtkWidget *w, gpointer data) | |
1570 { | |
1571 const char *file; | |
1572 char *pref; | |
1573 int snd; | |
1574 | |
1575 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(sounddialog)); | |
1576 snd = GPOINTER_TO_INT(data); | |
1577 | |
1578 /* If they type in a directory, change there */ | |
1579 if (gaim_gtk_check_if_dir(file, GTK_FILE_SELECTION(sounddialog))) | |
1580 return; | |
1581 | 1564 |
1582 /* Set it -- and forget it */ | 1565 /* Set it -- and forget it */ |
1583 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", | 1566 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", |
1584 gaim_gtk_sound_get_event_option(snd)); | 1567 gaim_gtk_sound_get_event_option(sound)); |
1585 gaim_prefs_set_string(pref, file); | 1568 gaim_prefs_set_string(pref, filename); |
1586 g_free(pref); | 1569 g_free(pref); |
1587 | 1570 |
1588 /* Set our text entry */ | 1571 /* |
1589 gtk_entry_set_text(GTK_ENTRY(sound_entry), file); | 1572 * If the sound we just changed is still the currently selected |
1590 | 1573 * sound, then update the box showing the file name. |
1591 /* Close the window! It's getting cold in here! */ | 1574 */ |
1592 close_sounddialog(NULL, sounddialog); | 1575 if (sound == sound_row_sel) |
1593 | 1576 gtk_entry_set_text(GTK_ENTRY(sound_entry), filename); |
1594 if (last_sound_dir) | 1577 } |
1595 g_free(last_sound_dir); | 1578 |
1596 last_sound_dir = g_path_get_dirname(file); | 1579 static void select_sound(GtkWidget *button, gpointer being_NULL_is_fun) |
1597 } | 1580 { |
1598 | 1581 gchar *pref; |
1599 static void sel_sound(GtkWidget *button, gpointer being_NULL_is_fun) | 1582 const char *filename; |
1600 { | 1583 |
1601 char *buf = g_malloc(BUF_LEN); | 1584 pref = g_strdup_printf("/gaim/gtk/sound/file/%s", |
1602 | 1585 gaim_gtk_sound_get_event_option(sound_row_sel)); |
1603 if (!sounddialog) { | 1586 filename = gaim_prefs_get_string(pref); |
1604 sounddialog = gtk_file_selection_new(_("Sound Selection")); | 1587 g_free(pref); |
1605 | 1588 |
1606 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(sounddialog)); | 1589 if (*filename == '\0') |
1607 | 1590 filename = NULL; |
1608 g_snprintf(buf, BUF_LEN - 1, "%s" G_DIR_SEPARATOR_S, last_sound_dir ? last_sound_dir : gaim_home_dir()); | 1591 |
1609 | 1592 gaim_request_file(prefs, _("Sound Selection"), filename, FALSE, |
1610 gtk_file_selection_set_filename(GTK_FILE_SELECTION(sounddialog), buf); | 1593 G_CALLBACK(sound_chosen_cb), NULL, GINT_TO_POINTER(sound_row_sel)); |
1611 | 1594 } |
1612 g_signal_connect(G_OBJECT(sounddialog), "destroy", | 1595 |
1613 G_CALLBACK(close_sounddialog), sounddialog); | 1596 static void prefs_sound_sel(GtkTreeSelection *sel, GtkTreeModel *model) { |
1614 | |
1615 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(sounddialog)->ok_button), | |
1616 "clicked", | |
1617 G_CALLBACK(do_select_sound), GINT_TO_POINTER(sound_row_sel)); | |
1618 | |
1619 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(sounddialog)->cancel_button), | |
1620 "clicked", | |
1621 G_CALLBACK(close_sounddialog), sounddialog); | |
1622 } | |
1623 | |
1624 g_free(buf); | |
1625 gtk_widget_show(sounddialog); | |
1626 gdk_window_raise(sounddialog->window); | |
1627 } | |
1628 | |
1629 | |
1630 static void prefs_sound_sel (GtkTreeSelection *sel, GtkTreeModel *model) { | |
1631 GtkTreeIter iter; | 1597 GtkTreeIter iter; |
1632 GValue val = { 0, }; | 1598 GValue val = { 0, }; |
1633 const char *file; | 1599 const char *file; |
1634 char *pref; | 1600 char *pref; |
1635 | 1601 |
1643 file = gaim_prefs_get_string(pref); | 1609 file = gaim_prefs_get_string(pref); |
1644 g_free(pref); | 1610 g_free(pref); |
1645 if (sound_entry) | 1611 if (sound_entry) |
1646 gtk_entry_set_text(GTK_ENTRY(sound_entry), (file && *file != '\0') ? file : "(default)"); | 1612 gtk_entry_set_text(GTK_ENTRY(sound_entry), (file && *file != '\0') ? file : "(default)"); |
1647 g_value_unset (&val); | 1613 g_value_unset (&val); |
1648 if (sounddialog) | |
1649 gtk_widget_destroy(sounddialog); | |
1650 } | 1614 } |
1651 | 1615 |
1652 GtkWidget *sound_page() { | 1616 GtkWidget *sound_page() { |
1653 GtkWidget *ret; | 1617 GtkWidget *ret; |
1654 GtkWidget *vbox, *sw, *button; | 1618 GtkWidget *vbox, *sw, *button; |
1814 button = gtk_button_new_with_label(_("Reset")); | 1778 button = gtk_button_new_with_label(_("Reset")); |
1815 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_sound), NULL); | 1779 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_sound), NULL); |
1816 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1); | 1780 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1); |
1817 | 1781 |
1818 button = gtk_button_new_with_label(_("Choose...")); | 1782 button = gtk_button_new_with_label(_("Choose...")); |
1819 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(sel_sound), NULL); | 1783 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(select_sound), NULL); |
1820 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1); | 1784 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1); |
1821 gtk_widget_show_all(ret); | 1785 gtk_widget_show_all(ret); |
1822 | 1786 |
1823 return ret; | 1787 return ret; |
1824 } | 1788 } |