pidgin/gtkprefs.c

branch
soc.2008.masterpassword
changeset 34018
303ae52b5882
parent 24533
37232ecf7246
parent 34000
2a6830e7ceb4
child 34021
25c14927f826
equal deleted inserted replaced
25341:8d1a98b45f9d 34018:303ae52b5882
35 #include "request.h" 35 #include "request.h"
36 #include "savedstatuses.h" 36 #include "savedstatuses.h"
37 #include "sound.h" 37 #include "sound.h"
38 #include "util.h" 38 #include "util.h"
39 #include "network.h" 39 #include "network.h"
40 #include "keyring.h"
40 41
41 #include "gtkblist.h" 42 #include "gtkblist.h"
42 #include "gtkconv.h" 43 #include "gtkconv.h"
43 #include "gtkdebug.h" 44 #include "gtkdebug.h"
44 #include "gtkdialogs.h" 45 #include "gtkdialogs.h"
1629 gtk_widget_show_all(ret); 1630 gtk_widget_show_all(ret);
1630 1631
1631 return ret; 1632 return ret;
1632 } 1633 }
1633 1634
1635 static void
1636 change_master_password_cb(GtkWidget * button, gpointer ptr)
1637 {
1638 purple_keyring_change_master(NULL, NULL);
1639 }
1640
1641 static void
1642 keyring_page_pref_changed(const char *name, PurplePrefType type, gconstpointer val, gpointer data)
1643 {
1644 GtkWidget * button = data;
1645 PurpleKeyring * keyring;
1646
1647 g_return_if_fail(type == PURPLE_PREF_STRING);
1648 g_return_if_fail(g_strcmp0(name,"/purple/keyring/active") == 0);
1649
1650 /**
1651 * This part is annoying.
1652 * Since we do not know if purple_keyring_inuse was changed yet,
1653 * as we do not know the order the callbacks are called in, we
1654 * have to rely on the prefs system, and find the keyring that
1655 * is (or will be) used, from there.
1656 */
1657
1658 keyring = purple_keyring_get_keyring_by_id(val);
1659
1660 if (purple_keyring_get_change_master(keyring))
1661 gtk_widget_set_sensitive(button,TRUE);
1662 else
1663 gtk_widget_set_sensitive(button,FALSE);
1664 }
1665
1666
1667 static GtkWidget *
1668 keyring_page(void)
1669 {
1670 GtkWidget *ret;
1671 GtkWidget *vbox;
1672 GtkWidget * button;
1673 GList *names;
1674 void * prefs;
1675 const char * keyring_id;
1676 PurpleKeyring * keyring;
1677
1678 keyring_id = purple_prefs_get_string("/purple/keyring/active");
1679 keyring = purple_keyring_get_keyring_by_id(keyring_id);
1680
1681 prefs = purple_prefs_get_handle();
1682
1683 ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
1684 gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
1685
1686 /* Keyring selection */
1687 vbox = pidgin_make_frame (ret, _("Keyring"));
1688 names = purple_keyring_get_options();
1689 pidgin_prefs_dropdown_from_list(vbox, _("Keyring :"), PURPLE_PREF_STRING,
1690 "/purple/keyring/active", names);
1691 g_list_free(names);
1692
1693 /* Change master password */
1694 button = gtk_button_new_with_mnemonic(_("_Change master password."));
1695
1696 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(change_master_password_cb), NULL);
1697 purple_prefs_connect_callback (prefs, "/purple/keyring/active", keyring_page_pref_changed, button);
1698
1699 if (purple_keyring_get_change_master(keyring))
1700 gtk_widget_set_sensitive(button,TRUE);
1701 else
1702 gtk_widget_set_sensitive(button,FALSE);
1703
1704 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 1);
1705 gtk_widget_show_all(ret);
1706 return ret;
1707 }
1708
1634 #ifndef _WIN32 1709 #ifndef _WIN32
1635 static gint sound_cmd_yeah(GtkEntry *entry, gpointer d) 1710 static gint sound_cmd_yeah(GtkEntry *entry, gpointer d)
1636 { 1711 {
1637 purple_prefs_set_path(PIDGIN_PREFS_ROOT "/sound/command", 1712 purple_prefs_set_path(PIDGIN_PREFS_ROOT "/sound/command",
1638 gtk_entry_get_text(GTK_ENTRY(entry))); 1713 gtk_entry_get_text(GTK_ENTRY(entry)));
2174 if ((purple_running_gnome() == FALSE) && (purple_running_osx() == FALSE)) { 2249 if ((purple_running_gnome() == FALSE) && (purple_running_osx() == FALSE)) {
2175 prefs_notebook_add_page(_("Browser"), browser_page(), notebook_page++); 2250 prefs_notebook_add_page(_("Browser"), browser_page(), notebook_page++);
2176 } 2251 }
2177 #endif 2252 #endif
2178 prefs_notebook_add_page(_("Logging"), logging_page(), notebook_page++); 2253 prefs_notebook_add_page(_("Logging"), logging_page(), notebook_page++);
2254 prefs_notebook_add_page(_("Password Storage"), keyring_page(), notebook_page++);
2179 prefs_notebook_add_page(_("Status / Idle"), away_page(), notebook_page++); 2255 prefs_notebook_add_page(_("Status / Idle"), away_page(), notebook_page++);
2180 } 2256 }
2181 2257
2182 void pidgin_prefs_show(void) 2258 void pidgin_prefs_show(void)
2183 { 2259 {

mercurial