]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-password.c
Add EvPage so that we can hold a reference to the backend page. Form
[evince.git] / shell / ev-password.c
index b6298f38493b22763e9ef561a5ad3367822ceff3..ae317f029c4a4417d8b95d558f6001b367831669 100644 (file)
 #endif
 
 #include <glib/gi18n.h>
+#include <gio/gio.h>
 #include <gtk/gtk.h>
 #include <glade/glade.h>
+
+#ifdef WITH_KEYRING
 #include <gnome-keyring.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#else
+#define gnome_keyring_is_available()   FALSE
+#endif
 
 #include "ev-password.h"
 
@@ -70,15 +75,15 @@ ev_password_dialog_set_property (GObject      *object,
        char *format;
        char *markup;
        char *base_name;
-       char *file_name;
+       GFile *file;
 
-       switch (prop_id)
-       {
+       switch (prop_id) {
        case PROP_URI:
                dialog->priv->uri = g_strdup (g_value_get_string (value));
+               
+               file = g_file_new_for_uri (dialog->priv->uri);
 
-               file_name = gnome_vfs_format_uri_for_display (dialog->priv->uri);
-               base_name = g_path_get_basename (file_name);
+               base_name = g_file_get_basename (file);
                format = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>\n\n%s",
                                          _("Password required"),
                                          _("The document ā€œ%sā€ is locked and requires a password before it can be opened."));
@@ -87,9 +92,9 @@ ev_password_dialog_set_property (GObject      *object,
                gtk_label_set_markup (GTK_LABEL (dialog->priv->label), markup);
 
                g_free (base_name);
-               g_free (file_name);
                g_free (format);
                g_free (markup);
+               g_object_unref (file);
 
                ev_password_search_in_keyring (dialog, dialog->priv->uri);
                break;
@@ -173,7 +178,7 @@ ev_password_dialog_init (EvPasswordDialog *dialog)
        g_signal_connect (dialog->priv->entry, "activate", G_CALLBACK (ev_password_dialog_entry_activated_cb), dialog);
 
        ev_password_set_bad_password_label (dialog, " ");
-       
+
        if (!gnome_keyring_is_available ()) {
                gtk_widget_hide (dialog->priv->check_default);
                gtk_widget_hide (dialog->priv->check_session);
@@ -219,6 +224,7 @@ ev_password_dialog_entry_activated_cb (GtkEntry *entry,
        gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 }
 
+#ifdef WITH_KEYRING
 static void
 ev_password_item_created_callback (GnomeKeyringResult result,
                                   guint32            val,
@@ -226,11 +232,13 @@ ev_password_item_created_callback (GnomeKeyringResult result,
 {
        /* Nothing yet */
        return;
-}                                 
+}
+#endif
 
 void
 ev_password_dialog_save_password (EvPasswordDialog *dialog)
 {
+#ifdef WITH_KEYRING
        GnomeKeyringAttributeList *attributes;
        GnomeKeyringAttribute attribute;
        gchar *name;
@@ -248,7 +256,7 @@ ev_password_dialog_save_password (EvPasswordDialog *dialog)
        attribute.value.string = g_strdup (dialog->priv->uri);
        g_array_append_val (attributes, attribute);
        
-       unescaped_uri = gnome_vfs_unescape_string_for_display (dialog->priv->uri);
+       unescaped_uri = g_uri_unescape_string (dialog->priv->uri, NULL);
        name = g_strdup_printf (_("Password for document %s"), unescaped_uri);  
 
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->check_default))) {
@@ -274,10 +282,12 @@ ev_password_dialog_save_password (EvPasswordDialog *dialog)
        gnome_keyring_attribute_list_free (attributes);
        g_free (name);
        g_free (unescaped_uri);
-       
+
+#endif /* WITH_KEYRING */
        return;
 }
 
+#ifdef WITH_KEYRING
 static void 
 ev_password_keyring_found_cb (GnomeKeyringResult result,
                              GList             *list,
@@ -293,10 +303,12 @@ ev_password_keyring_found_cb (GnomeKeyringResult result,
        found = list->data;
        gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry), found->secret);
 }                        
+#endif /* WITH_KEYRING */
 
 static void
 ev_password_search_in_keyring (EvPasswordDialog *dialog, const gchar *uri)
 {
+#ifdef WITH_KEYRING
        GnomeKeyringAttributeList *attributes;
        GnomeKeyringAttribute attribute;
        
@@ -318,6 +330,7 @@ ev_password_search_in_keyring (EvPasswordDialog *dialog, const gchar *uri)
                                   g_object_ref (dialog),
                                   g_object_unref);
        gnome_keyring_attribute_list_free (attributes);
+#endif /* WITH_KEYRING */
        return;
 }