]> www.fi.muni.cz Git - evince.git/commitdiff
Fix loading encrypted documents since I broke it with the jobs rework.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Wed, 6 Aug 2008 17:35:22 +0000 (17:35 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Wed, 6 Aug 2008 17:35:22 +0000 (17:35 +0000)
2008-08-06  Carlos Garcia Campos  <carlosgc@gnome.org>

* shell/ev-jobs.[ch]: (ev_job_load_dispose), (ev_job_load_run),
(ev_job_load_set_password):
* shell/ev-password.[ch]: (ev_password_dialog_get_password):
* shell/ev-window.c: (password_dialog_response),
(ev_window_load_job_cb):

Fix loading encrypted documents since I broke it with the jobs
rework.

svn path=/trunk/; revision=3099

ChangeLog
shell/ev-jobs.c
shell/ev-jobs.h
shell/ev-password.c
shell/ev-password.h
shell/ev-window.c

index 46d9d50a7a845883d13773ec3c19d9e7bc92a55e..32410fdf348f721627ffe29d219c91e09044722c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,17 @@
        
        Update for release 2.23.6.
 
+2008-08-06  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * shell/ev-jobs.[ch]: (ev_job_load_dispose), (ev_job_load_run),
+       (ev_job_load_set_password):
+       * shell/ev-password.[ch]: (ev_password_dialog_get_password):
+       * shell/ev-window.c: (password_dialog_response),
+       (ev_window_load_job_cb):
+
+       Fix loading encrypted documents since I broke it with the jobs
+       rework.
+       
 2008-08-05  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * NEWS:
index 7371dd1a0eb69a15f78ecc83cc53531209dc837f..dd8fb097246b14070f706ff7cb1ffe0ab5f2c3d1 100644 (file)
@@ -30,7 +30,7 @@
 #include "ev-document-misc.h"
 #include "ev-file-helpers.h"
 #include "ev-document-fonts.h"
-#include "ev-async-renderer.h"
+#include "ev-document-security.h"
 #include "ev-debug.h"
 
 #include <errno.h>
@@ -716,6 +716,11 @@ ev_job_load_dispose (GObject *object)
                job->uri = NULL;
        }
 
+       if (job->password) {
+               g_free (job->password);
+               job->password = NULL;
+       }
+
        if (job->dest) {
                g_object_unref (job->dest);
                job->dest = NULL;
@@ -740,11 +745,19 @@ ev_job_load_run (EvJob *job)
        
        ev_document_fc_mutex_lock ();
 
-       /* TODO: reuse the job!!! */
        /* This job may already have a document even if the job didn't complete
           because, e.g., a password is required - if so, just reload rather than
           creating a new instance */
        if (job->document) {
+               if (job_load->password) {
+                       ev_document_security_set_password (EV_DOCUMENT_SECURITY (job->document),
+                                                          job_load->password);
+               }
+               
+               job->failed = FALSE;
+               job->finished = FALSE;
+               g_clear_error (&job->error);
+               
                ev_document_load (job->document,
                                  job_load->uri,
                                  &error);
@@ -805,6 +818,16 @@ ev_job_load_set_uri (EvJobLoad *job, const gchar *uri)
        job->uri = g_strdup (uri);
 }
 
+void
+ev_job_load_set_password (EvJobLoad *job, const gchar *password)
+{
+       ev_debug_message (DEBUG_JOBS, NULL);
+
+       if (job->password)
+               g_free (job->password);
+       job->password = password ? g_strdup (password) : NULL;
+}
+
 /* EvJobSave */
 static void
 ev_job_save_init (EvJobSave *job)
index 336567b40e21c928c51da1986300246cdf0d5944..95c7f7da8d57839ac6f48819117849803d77271d 100644 (file)
@@ -226,6 +226,7 @@ struct _EvJobLoad
        EvWindowRunMode mode;
        gchar *search_string;
        gchar *uri;
+       gchar *password;
 };
 
 struct _EvJobLoadClass
@@ -323,6 +324,8 @@ EvJob              *ev_job_load_new           (const gchar     *uri,
                                           const gchar     *search_string);
 void            ev_job_load_set_uri       (EvJobLoad       *load,
                                           const gchar     *uri);
+void            ev_job_load_set_password  (EvJobLoad       *job,
+                                          const gchar     *password);
 
 /* EvJobSave */
 GType           ev_job_save_get_type      (void) G_GNUC_CONST;
index ae317f029c4a4417d8b95d558f6001b367831669..a191b9f131c6b91be5362b68d2a3ff80bc4b63d5 100644 (file)
@@ -334,10 +334,10 @@ ev_password_search_in_keyring (EvPasswordDialog *dialog, const gchar *uri)
        return;
 }
 
-char *
+const char *
 ev_password_dialog_get_password (EvPasswordDialog *dialog)
 {
-       return g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry)));
+       return gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry));
 }
 
 void
index af76d3d4ad3fb9b82a62da13a99523b3edda47cc..d092ccabf2573307597714f211a0cbbc2e8ce530 100644 (file)
@@ -47,11 +47,11 @@ struct _EvPasswordDialogClass
   GtkDialogClass parent_class;
 };
 
-GType     ev_password_dialog_get_type               (void) G_GNUC_CONST;
+GType       ev_password_dialog_get_type      (void) G_GNUC_CONST;
 
-char      *ev_password_dialog_get_password  (EvPasswordDialog *dialog);
-void       ev_password_dialog_set_bad_pass  (EvPasswordDialog *dialog);
-void      ev_password_dialog_save_password (EvPasswordDialog *dialog);
+const char *ev_password_dialog_get_password  (EvPasswordDialog *dialog);
+void        ev_password_dialog_set_bad_pass  (EvPasswordDialog *dialog);
+void       ev_password_dialog_save_password (EvPasswordDialog *dialog);
 
 G_END_DECLS
 
index cf65611a9aefaa154e7cf0ede3b579167581c228..02932295e6cc2e2f250f01dfdf844ff708e16561 100644 (file)
@@ -55,7 +55,6 @@
 #include "ev-document-fonts.h"
 #include "ev-document-images.h"
 #include "ev-document-links.h"
-#include "ev-document-security.h"
 #include "ev-document-thumbnails.h"
 #include "ev-file-exporter.h"
 #include "ev-file-helpers.h"
@@ -1219,18 +1218,9 @@ password_dialog_response (GtkWidget *password_dialog,
                          gint       response_id,
                          EvWindow  *ev_window)
 {
-       char *password;
-       
        if (response_id == GTK_RESPONSE_OK) {
-
-               password = ev_password_dialog_get_password (EV_PASSWORD_DIALOG (password_dialog));
-               if (password) {
-                       ev_document_doc_mutex_lock ();
-                       ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->load_job->document),
-                                                          password);
-                       ev_document_doc_mutex_unlock ();
-               }
-               g_free (password);
+               ev_job_load_set_password (EV_JOB_LOAD (ev_window->priv->load_job),
+                                         ev_password_dialog_get_password (EV_PASSWORD_DIALOG (password_dialog)));
 
                ev_password_dialog_save_password (EV_PASSWORD_DIALOG (password_dialog));
 
@@ -1351,8 +1341,8 @@ ev_window_clear_temp_file (EvWindow *ev_window)
  * function should _not_ necessarily expect those to exist after being
  * called. */
 static void
-ev_window_load_job_cb  (EvJob *job,
-                       gpointer data)
+ev_window_load_job_cb (EvJob *job,
+                      gpointer data)
 {
        EvWindow *ev_window = EV_WINDOW (data);
        EvDocument *document = EV_JOB (job)->document;
@@ -1398,16 +1388,7 @@ ev_window_load_job_cb  (EvJob *job,
                                break;
                }
 
-               /* Restart the search after reloading */
-               if (ev_window->priv->in_reload) {
-                       GtkWidget *widget;
-                       
-                       widget = gtk_window_get_focus (GTK_WINDOW (ev_window));
-                       if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
-                               find_bar_search_changed_cb (EGG_FIND_BAR (ev_window->priv->find_bar),
-                                                           NULL, ev_window);
-                       }
-               } else if (job_load->search_string && EV_IS_DOCUMENT_FIND (document)) {
+               if (job_load->search_string && EV_IS_DOCUMENT_FIND (document)) {
                        ev_window_cmd_edit_find (NULL, ev_window);
                        egg_find_bar_set_search_string (EGG_FIND_BAR (ev_window->priv->find_bar),
                                                        job_load->search_string);
@@ -1458,7 +1439,7 @@ ev_window_reload_job_cb (EvJob    *job,
                ev_window->priv->in_reload = FALSE;
                return;
        }
-
+       
        ev_window_set_document (ev_window, job->document);
 
        /* Restart the search after reloading */
@@ -1467,7 +1448,7 @@ ev_window_reload_job_cb (EvJob    *job,
                find_bar_search_changed_cb (EGG_FIND_BAR (ev_window->priv->find_bar),
                                            NULL, ev_window);
        }
-
+       
        ev_window_clear_reload_job (ev_window);
        ev_window->priv->in_reload = FALSE;
 }
@@ -4271,7 +4252,7 @@ ev_window_dispose (GObject *object)
                ev_window_clear_local_uri (window);
                priv->local_uri = NULL;
        }
-       
+
        ev_window_close_dialogs (window);
        ev_window_clear_print_job (window);