[evince] window: Show password dialog again
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] window: Show password dialog again
- Date: Wed, 9 Jun 2021 02:25:41 +0000 (UTC)
commit 1f250861fa2ec6a7117f183459e62ac285d85db6
Author: Marek Kasik <mkasik redhat com>
Date: Tue Mar 2 18:40:56 2021 +0100
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(-)
---
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,21 @@ 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)
+{
+ ev_application_unregister_uri (application, application->uri);
+ 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
};
typedef struct {
@@ -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_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 (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;
} EvWindowPrivate;
#define GET_PRIVATE(o) ev_window_get_instance_private (o)
@@ -1804,6 +1806,7 @@ ev_window_password_view_unlock (EvWindow *ev_window)
password = ev_password_view_get_password (EV_PASSWORD_VIEW (priv->password_view));
ev_job_load_set_password (EV_JOB_LOAD (priv->load_job), password);
ev_job_scheduler_push_job (priv->load_job, EV_JOB_PRIORITY_NONE);
+ 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 = GET_PRIVATE (ev_window);
+
+ 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 (priv->uri &&
- g_ascii_strcasecmp (priv->uri, uri) == 0) {
+ g_ascii_strcasecmp (priv->uri, uri) == 0 &&
+ !priv->password_view_cancelled) {
if (ev_window_check_document_modified (ev_window, EV_WINDOW_ACTION_RELOAD))
return;
ev_window_reload_document (ev_window, dest);
@@ -7643,11 +7659,16 @@ ev_window_init (EvWindow *ev_window)
allow_links_change_zoom);
ev_view_set_model (EV_VIEW (priv->view), priv->model);
+ priv->password_view_cancelled = FALSE;
priv->password_view = ev_password_view_new (GTK_WINDOW (ev_window));
g_signal_connect_swapped (priv->password_view,
"unlock",
G_CALLBACK (ev_window_password_view_unlock),
ev_window);
+ g_signal_connect_swapped (priv->password_view,
+ "cancelled",
+ G_CALLBACK (ev_window_password_view_cancelled),
+ ev_window);
g_signal_connect_object (priv->view, "focus_in_event",
G_CALLBACK (view_actions_focus_in_cb),
ev_window, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]