evince/SOURCES/evince-3.28.4-Show-password-dialog-again.patch

204 lines
6.9 KiB
Diff
Raw Normal View History

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