summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2019-12-03 08:38:50 +0100
committerNiels De Graef <nielsdegraef@gmail.com>2021-01-13 22:00:15 +0000
commit2eaf6753bd08b2eead62b12002c26da2401dcdb3 (patch)
tree870d1abcb10b836eecda425d18fe2feac8fa9945
parent5aa74c851419cf72da85ac5394f41ed86e6f8461 (diff)
downloadgcr-2eaf6753bd08b2eead62b12002c26da2401dcdb3.tar.gz
prompt: Guard GDK-X11 code with the necessary #ifdefs
This allows us to lose the hard dependency on `gtk-x11`.
-rw-r--r--configure.ac2
-rw-r--r--ui/frob-prompt.c20
-rw-r--r--ui/frob-system-prompt.c6
-rw-r--r--ui/gcr-prompt-dialog.c6
-rw-r--r--ui/gcr-prompter-tool.c2
5 files changed, 20 insertions, 16 deletions
diff --git a/configure.ac b/configure.ac
index 2f6db65..9b7c5d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,7 +119,7 @@ AC_ARG_WITH(gtk, [
AM_CONDITIONAL(WITH_GTK, test "$with_gtk" != "no")
if test "x$with_gtk" != "xno"; then
- PKG_CHECK_MODULES(GTK, gtk+-3.0 >= $GTK_REQ gtk+-x11-3.0 >= $GTK_REQ)
+ PKG_CHECK_MODULES(GTK, gtk+-3.0 >= $GTK_REQ)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
fi
diff --git a/ui/frob-prompt.c b/ui/frob-prompt.c
index 20462f6..53955be 100644
--- a/ui/frob-prompt.c
+++ b/ui/frob-prompt.c
@@ -63,7 +63,7 @@ prompt_perform (GtkWidget *parent)
file = g_key_file_new ();
if (!g_key_file_load_from_file (file, file_name, G_KEY_FILE_NONE, &error))
- errx (1, "couldn't load prompt info: %s", error->message);
+ g_error ("couldn't load prompt info: %s", error->message);
if (!prompt_type || g_str_equal (prompt_type, "dialog"))
prompt = g_object_new (GCR_TYPE_PROMPT_DIALOG, NULL);
@@ -72,10 +72,10 @@ prompt_perform (GtkWidget *parent)
else if (g_str_equal (prompt_type, "private"))
prompt = gcr_system_prompt_open_for_prompter ("org.gnome.keyring.PrivatePrompter", 5, NULL, &error);
else
- errx (2, "invalid type: %s", prompt_type);
+ g_error ("invalid type: %s", prompt_type);
if (error != NULL)
- errx (1, "couldn't create prompt: %s", error->message);
+ g_error ("couldn't create prompt: %s", error->message);
if (parent) {
caller_id = g_strdup_printf ("%lu", (gulong)GDK_WINDOW_XID (gtk_widget_get_window (parent)));
@@ -99,7 +99,7 @@ prompt_perform (GtkWidget *parent)
continue;
spec = g_object_class_find_property (G_OBJECT_GET_CLASS (prompt), key);
if (spec == NULL)
- errx (1, "couldn't find property %s on prompt %s",
+ g_error ("couldn't find property %s on prompt %s",
key, G_OBJECT_TYPE_NAME (prompt));
g_value_init (&value, spec->value_type);
switch (spec->value_type) {
@@ -113,7 +113,7 @@ prompt_perform (GtkWidget *parent)
g_value_set_boolean (&value, g_key_file_get_boolean (file, groups[i], key, NULL));
break;
default:
- errx (1, "unsupported type %s for property %s",
+ g_error ("unsupported type %s for property %s",
g_type_name (spec->value_type), key);
break;
}
@@ -128,18 +128,18 @@ prompt_perform (GtkWidget *parent)
if (g_strcmp0 (type, "password") == 0) {
password = gcr_prompt_password_run (prompt, NULL, &error);
if (error != NULL)
- errx (1, "couldn't prompt for password: %s", error->message);
+ g_error ("couldn't prompt for password: %s", error->message);
g_print ("prompt password: %s\n", password);
g_print ("password strength: %d\n", gcr_prompt_get_password_strength (prompt));
cont = (password != NULL);
} else if (g_strcmp0 (type, "confirm") == 0) {
reply = gcr_prompt_confirm_run (prompt, NULL, &error);
if (error != NULL)
- errx (1, "couldn't prompt for confirm: %s", error->message);
+ g_error ("couldn't prompt for confirm: %s", error->message);
g_print ("prompt confirm: %d\n", reply);
cont = (reply != GCR_PROMPT_REPLY_CANCEL);
} else {
- errx (1, "unsupported prompt type: %s", type);
+ g_error ("unsupported prompt type: %s", type);
}
g_free (type);
@@ -199,12 +199,12 @@ main (int argc, char *argv[])
g_option_context_add_group (context, gtk_get_option_group (TRUE));
if (!g_option_context_parse (context, &argc, &argv, &error))
- errx (2, "%s", error->message);
+ g_error ("%s", error->message);
g_option_context_free (context);
if (argc < 2)
- errx (2, "specify file");
+ g_error ("specify file");
file_name = argv[1];
if (prompt_window) {
diff --git a/ui/frob-system-prompt.c b/ui/frob-system-prompt.c
index e08114f..02bdc28 100644
--- a/ui/frob-system-prompt.c
+++ b/ui/frob-system-prompt.c
@@ -23,10 +23,10 @@
#include "gcr/gcr.h"
-#include "egg/egg-testing.h"
-
#include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
+#endif
#include <unistd.h>
#include <string.h>
@@ -54,9 +54,11 @@ on_prompt_clicked (GtkToolButton *button,
gcr_prompt_set_message (GCR_PROMPT (prompt), "This is the message");
gcr_prompt_set_description (GCR_PROMPT (prompt), "This is the description");
+#ifdef GDK_WINDOWING_X11
caller_id = g_strdup_printf ("%lu", (gulong)GDK_WINDOW_XID (gtk_widget_get_window (parent)));
gcr_prompt_set_caller_window (GCR_PROMPT (prompt), caller_id);
g_free (caller_id);
+#endif
password = gcr_prompt_password_run (GCR_PROMPT (prompt), NULL, &error);
if (error != NULL) {
diff --git a/ui/gcr-prompt-dialog.c b/ui/gcr-prompt-dialog.c
index 1b6de93..11297d5 100644
--- a/ui/gcr-prompt-dialog.c
+++ b/ui/gcr-prompt-dialog.c
@@ -27,7 +27,9 @@
#include "gcr-secure-entry-buffer.h"
#include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
+#endif
#include <glib/gi18n.h>
/**
@@ -132,7 +134,7 @@ static void
update_transient_for (GcrPromptDialog *self)
{
GdkDisplay *display;
- GdkWindow *transient_for;
+ GdkWindow *transient_for = NULL;
GdkWindow *window;
gint64 handle;
gchar *end;
@@ -146,6 +148,7 @@ update_transient_for (GcrPromptDialog *self)
if (window == NULL)
return;
+#ifdef GDK_WINDOWING_X11
handle = g_ascii_strtoll (self->pv->caller_window, &end, 10);
if (!end || *end != '\0') {
g_warning ("couldn't parse caller-window property: %s", self->pv->caller_window);
@@ -161,6 +164,7 @@ update_transient_for (GcrPromptDialog *self)
gdk_window_set_transient_for (window, transient_for);
g_object_unref (transient_for);
}
+#endif
gtk_window_set_modal (GTK_WINDOW (self), TRUE);
}
diff --git a/ui/gcr-prompter-tool.c b/ui/gcr-prompter-tool.c
index cd1cc56..2d3f71e 100644
--- a/ui/gcr-prompter-tool.c
+++ b/ui/gcr-prompter-tool.c
@@ -27,8 +27,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <gdk/gdkx.h>
-#include <pango/pango.h>
#include <locale.h>
#include <stdlib.h>