cb60d5
From 1f250861fa2ec6a7117f183459e62ac285d85db6 Mon Sep 17 00:00:00 2001
cb60d5
From: Marek Kasik <mkasik@redhat.com>
cb60d5
Date: Tue, 2 Mar 2021 18:40:56 +0100
cb60d5
Subject: [PATCH] window: Show password dialog again
cb60d5
cb60d5
Show password dialog when trying to open a document for which we've
cb60d5
cancelled a password dialog before in recent view.
cb60d5
cb60d5
This is achieved by adding a signal "cancelled" to EvPasswordView since
cb60d5
only successfull entering of password was signaled before by "unlock" signal.
cb60d5
cb60d5
We also need to unregister current document with EvApplication and clear its uri
cb60d5
there to be able to open other documents in current window.
cb60d5
---
cb60d5
 shell/ev-application.c   | 16 ++++++++++++++++
cb60d5
 shell/ev-application.h   |  1 +
cb60d5
 shell/ev-password-view.c | 14 ++++++++++++++
cb60d5
 shell/ev-password-view.h |  3 ++-
cb60d5
 shell/ev-window.c        | 23 ++++++++++++++++++++++-
cb60d5
 5 files changed, 55 insertions(+), 2 deletions(-)
cb60d5
cb60d5
cb60d5
cb60d5
From ef2d7ca9734c6a2e3ba0a80279d944352d355295 Mon Sep 17 00:00:00 2001
cb60d5
From: Tom Schoonjans <Tom.Schoonjans@rfi.ac.uk>
cb60d5
Date: Wed, 9 Jun 2021 06:39:48 +0100
cb60d5
Subject: [PATCH] ev-application: fix compilation error when DBus is disabled
cb60d5
cb60d5
---
cb60d5
 shell/ev-application.c | 2 ++
cb60d5
 1 file changed, 2 insertions(+)
cb60d5
cb60d5
diff --git a/shell/ev-application.c b/shell/ev-application.c
cb60d5
index 23871d9a..7a3b69ba 100644
cb60d5
--- a/shell/ev-application.c
cb60d5
+++ b/shell/ev-application.c
cb60d5
@@ -539,6 +539,7 @@ ev_application_unregister_uri (EvApplication *application,
cb60d5
 		g_error_free (error);
cb60d5
 	} else {
cb60d5
                 g_variant_unref (value);
cb60d5
+		application->doc_registered = FALSE;
cb60d5
 	}
cb60d5
 }
cb60d5
 #endif /* ENABLE_DBUS */
cb60d5
@@ -1166,6 +1167,23 @@ ev_application_get_uri (EvApplication *application)
cb60d5
 	return application->uri;
cb60d5
 }
cb60d5
 
cb60d5
+/**
cb60d5
+ * ev_application_clear_uri:
cb60d5
+ * @application: The instance of the application.
cb60d5
+ *
cb60d5
+ * This unregisters current uri and clears it so that another document
cb60d5
+ * can be opened in this instance. E.g. after cancelled password dialog
cb60d5
+ * in recent view.
cb60d5
+ */
cb60d5
+void
cb60d5
+ev_application_clear_uri (EvApplication *application)
cb60d5
+{
cb60d5
+#ifdef ENABLE_DBUS
cb60d5
+	ev_application_unregister_uri (application, application->uri);
cb60d5
+#endif
cb60d5
+	g_clear_pointer (&application->uri, g_free);
cb60d5
+}
cb60d5
+
cb60d5
 /**
cb60d5
  * ev_application_get_media_keys:
cb60d5
  * @application: The instance of the application.
cb60d5
diff --git a/shell/ev-application.h b/shell/ev-application.h
cb60d5
index 00a7a18b..f9b43ab3 100644
cb60d5
--- a/shell/ev-application.h
cb60d5
+++ b/shell/ev-application.h
cb60d5
@@ -66,6 +66,7 @@ void	          ev_application_open_uri_list       (EvApplication   *application,
cb60d5
 gboolean	  ev_application_has_window	     (EvApplication   *application);
cb60d5
 guint             ev_application_get_n_windows       (EvApplication   *application);
cb60d5
 const gchar *     ev_application_get_uri             (EvApplication   *application);
cb60d5
+void              ev_application_clear_uri           (EvApplication   *application);
cb60d5
 GObject		 *ev_application_get_media_keys	     (EvApplication   *application);
cb60d5
 
cb60d5
 const gchar      *ev_application_get_dot_dir         (EvApplication   *application,
cb60d5
diff --git a/shell/ev-password-view.c b/shell/ev-password-view.c
cb60d5
index 9a916d55..0dab3c51 100644
cb60d5
--- a/shell/ev-password-view.c
cb60d5
+++ b/shell/ev-password-view.c
cb60d5
@@ -38,6 +38,7 @@
cb60d5
 
cb60d5
 enum {
cb60d5
 	UNLOCK,
cb60d5
+	CANCELLED,
cb60d5
 	LAST_SIGNAL
cb60d5
 };
cb60d5
 struct _EvPasswordViewPrivate {
cb60d5
@@ -91,6 +92,15 @@ ev_password_view_class_init (EvPasswordViewClass *class)
cb60d5
 			      g_cclosure_marshal_VOID__VOID,
cb60d5
 			      G_TYPE_NONE, 0);
cb60d5
 
cb60d5
+	password_view_signals[CANCELLED] =
cb60d5
+		g_signal_new ("cancelled",
cb60d5
+			      G_TYPE_FROM_CLASS (g_object_class),
cb60d5
+			      G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
cb60d5
+			      G_STRUCT_OFFSET (EvPasswordViewClass, cancelled),
cb60d5
+			      NULL, NULL,
cb60d5
+			      g_cclosure_marshal_VOID__VOID,
cb60d5
+			      G_TYPE_NONE, 0);
cb60d5
+
cb60d5
 	g_type_class_add_private (g_object_class, sizeof (EvPasswordViewPrivate));
cb60d5
 
cb60d5
 	g_object_class->finalize = ev_password_view_finalize;
cb60d5
@@ -183,6 +193,10 @@ ev_password_dialog_got_response (GtkDialog      *dialog,
cb60d5
 			g_strdup (gtk_entry_get_text (GTK_ENTRY (password_view->priv->password_entry)));
cb60d5
 		
cb60d5
 		g_signal_emit (password_view, password_view_signals[UNLOCK], 0);
cb60d5
+	} else if (response_id == GTK_RESPONSE_CANCEL ||
cb60d5
+		   response_id == GTK_RESPONSE_CLOSE ||
cb60d5
+		   response_id == GTK_RESPONSE_DELETE_EVENT) {
cb60d5
+		g_signal_emit (password_view, password_view_signals[CANCELLED], 0);
cb60d5
 	}
cb60d5
 	
cb60d5
 	gtk_widget_destroy (GTK_WIDGET (dialog));
cb60d5
diff --git a/shell/ev-password-view.h b/shell/ev-password-view.h
cb60d5
index c3fc5bbc..e279c612 100644
cb60d5
--- a/shell/ev-password-view.h
cb60d5
+++ b/shell/ev-password-view.h
cb60d5
@@ -40,7 +40,8 @@ struct _EvPasswordViewClass {
cb60d5
 	GtkViewportClass parent_class;
cb60d5
 
cb60d5
 	/* signals */
cb60d5
-	void (*unlock) (EvPasswordView	*self);
cb60d5
+	void (*unlock)    (EvPasswordView	*self);
cb60d5
+	void (*cancelled) (EvPasswordView	*self);
cb60d5
 };
cb60d5
 
cb60d5
 GType	      ev_password_view_get_type                (void) G_GNUC_CONST;
cb60d5
diff --git a/shell/ev-window.c b/shell/ev-window.c
cb60d5
index 077d577d..f728fa77 100644
cb60d5
--- a/shell/ev-window.c
cb60d5
+++ b/shell/ev-window.c
cb60d5
@@ -239,6 +239,8 @@ typedef struct {
cb60d5
 
cb60d5
 	/* Send to */
cb60d5
 	gboolean has_mailto_handler;
cb60d5
+
cb60d5
+	gboolean password_view_cancelled;
cb60d5
 };
cb60d5
 
cb60d5
 #define EV_WINDOW_GET_PRIVATE(object) \
cb60d5
@@ -1804,6 +1806,7 @@ ev_window_password_view_unlock (EvWindow *ev_window)
cb60d5
 	password = ev_password_view_get_password (EV_PASSWORD_VIEW (ev_window->priv->password_view));
cb60d5
 	ev_job_load_set_password (EV_JOB_LOAD (ev_window->priv->load_job), password);
cb60d5
 	ev_job_scheduler_push_job (ev_window->priv->load_job, EV_JOB_PRIORITY_NONE);
cb60d5
+	ev_window->priv->password_view_cancelled = FALSE;
cb60d5
 }
cb60d5
 
cb60d5
 static void
cb60d5
@@ -1821,6 +1824,18 @@ ev_window_clear_load_job (EvWindow *ev_window)
cb60d5
 	}
cb60d5
 }
cb60d5
 
cb60d5
+static void
cb60d5
+ev_window_password_view_cancelled (EvWindow *ev_window)
cb60d5
+{
cb60d5
+	EvWindowPrivate *priv = ev_window->priv;
cb60d5
+
cb60d5
+	priv->password_view_cancelled = TRUE;
cb60d5
+	if (ev_window_is_recent_view (ev_window)) {
cb60d5
+		ev_window_clear_load_job (ev_window);
cb60d5
+		ev_application_clear_uri (EV_APP);
cb60d5
+	}
cb60d5
+}
cb60d5
+
cb60d5
 static void
cb60d5
 ev_window_clear_reload_job (EvWindow *ev_window)
cb60d5
 {
cb60d5
@@ -2395,7 +2410,8 @@ ev_window_open_uri (EvWindow       *ev_window,
cb60d5
 		g_strdup (search_string) : NULL;
cb60d5
 
cb60d5
 	if (ev_window->priv->uri &&
cb60d5
-	    g_ascii_strcasecmp (ev_window->priv->uri, uri) == 0) {
cb60d5
+	    g_ascii_strcasecmp (ev_window->priv->uri, uri) == 0 &&
cb60d5
+	    !ev_window->priv->password_view_cancelled) {
cb60d5
 		ev_window_reload_document (ev_window, dest);
cb60d5
 		return;
cb60d5
 	}
cb60d5
@@ -7643,11 +7659,16 @@ ev_window_init (EvWindow *ev_window)
cb60d5
 				     allow_links_change_zoom);
cb60d5
 	ev_view_set_model (EV_VIEW (ev_window->priv->view), ev_window->priv->model);
cb60d5
 
cb60d5
+	ev_window->priv->password_view_cancelled = FALSE;
cb60d5
 	ev_window->priv->password_view = ev_password_view_new (GTK_WINDOW (ev_window));
cb60d5
 	g_signal_connect_swapped (ev_window->priv->password_view,
cb60d5
 				  "unlock",
cb60d5
 				  G_CALLBACK (ev_window_password_view_unlock),
cb60d5
 				  ev_window);
cb60d5
+	g_signal_connect_swapped (ev_window->priv->password_view,
cb60d5
+				  "cancelled",
cb60d5
+				  G_CALLBACK (ev_window_password_view_cancelled),
cb60d5
+				  ev_window);
cb60d5
 	g_signal_connect_object (ev_window->priv->view, "focus_in_event",
cb60d5
 			         G_CALLBACK (view_actions_focus_in_cb),
cb60d5
 				 ev_window, 0);
cb60d5
-- 
cb60d5
2.31.1
cb60d5