[gnome-keyring/dbus-api] Move prompt tool into place, and show prompt text.
- From: Stefan Walter <stefw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-keyring/dbus-api] Move prompt tool into place, and show prompt text.
- Date: Thu, 5 Nov 2009 05:54:19 +0000 (UTC)
commit d595d6e5882c15ce7d38510ad8e1cd87ec0aa828
Author: Stef Walter <stef memberwebs com>
Date: Sun Nov 1 17:31:46 2009 +0000
Move prompt tool into place, and show prompt text.
Makefile.am | 1 -
configure.in | 1 -
daemon/.gitignore | 1 +
daemon/prompt/Makefile.am | 37 ++++++++-
.../prompt/gkd-prompt-tool.c | 90 +++++++++++++++++++-
ui/gku-prompt.ui => daemon/prompt/gkd-prompt.ui | 0
{ui => daemon/prompt}/test/test-data/prompt-empty | 0
{ui => daemon/prompt}/test/test-data/prompt-test | 0
ui/Makefile.am | 37 --------
9 files changed, 123 insertions(+), 44 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 9eaefde..beb34c7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,7 +20,6 @@ SUBDIRS = \
secrets \
daemon \
tool \
- ui \
$(TESTS_DIR) \
$(PAM_DIR) \
po \
diff --git a/configure.in b/configure.in
index 34373b7..bacc953 100644
--- a/configure.in
+++ b/configure.in
@@ -571,7 +571,6 @@ po/Makefile.in
secrets/Makefile
tests/Makefile
tool/Makefile
-ui/Makefile
library/gnome-keyring-1.pc
library/gnome-keyring-1-uninstalled.pc
])
diff --git a/daemon/.gitignore b/daemon/.gitignore
index f68cc1c..977c5e9 100644
--- a/daemon/.gitignore
+++ b/daemon/.gitignore
@@ -8,4 +8,5 @@ Makefile.in
/gnome-keyring-daemon.desktop
/gnome-keyring-daemon.desktop.in
*-marshal.[ch]
+gnome-keyring-prompt
diff --git a/daemon/prompt/Makefile.am b/daemon/prompt/Makefile.am
index 57036aa..a1a2379 100644
--- a/daemon/prompt/Makefile.am
+++ b/daemon/prompt/Makefile.am
@@ -1,11 +1,26 @@
-INCLUDES = \
+INCLUDES= \
+ -DPREFIX=\""$(prefix)"\" \
+ -DBINDIR=\""$(bindir)"\" \
+ -DLIBEXECDIR=\""$(libexecdir)"\" \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(top_srcdir) \
-I$(top_builddir) \
- -DLIBEXECDIR=\""$(libexecdir)"\" \
$(GOBJECT_CFLAGS) \
$(GLIB_CFLAGS)
+# ------------------------------------------------------------------
+# UI BUILDER
+#
+
+uidir = $(datadir)/gnome-keyring/ui/
+
+ui_DATA = \
+ gkd-prompt.ui
+
+# ------------------------------------------------------------------
+# DAEMON CODE
+
noinst_LTLIBRARIES = libgkd-prompt.la
BUILT_SOURCES = \
@@ -27,3 +42,21 @@ gkd-prompt-marshal.c: gkd-prompt-marshal.list $(GLIB_GENMARSHAL)
$(GLIB_GENMARSHAL) $< --body --prefix=gkd_prompt_marshal >> $@
EXTRA_DIST = gkd-prompt-marshal.list
+
+# ------------------------------------------------------------------
+# PROMPT TOOL
+#
+
+libexec_PROGRAMS= \
+ gnome-keyring-prompt
+
+gnome_keyring_prompt_SOURCES = \
+ gkd-prompt-tool.c
+
+gnome_keyring_prompt_LDADD = \
+ $(top_builddir)/egg/libegg.la \
+ $(GTK_LIBS)
+
+gnome_keyring_prompt_CFLAGS = \
+ -DUIDIR=\""$(uidir)"\" \
+ $(GTK_CFLAGS)
diff --git a/ui/gku-prompt-tool.c b/daemon/prompt/gkd-prompt-tool.c
similarity index 79%
rename from ui/gku-prompt-tool.c
rename to daemon/prompt/gkd-prompt-tool.c
index d762e21..d1d0b7e 100644
--- a/ui/gku-prompt-tool.c
+++ b/daemon/prompt/gkd-prompt-tool.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* gku-prompt-tool.c - Handles gui authentication for the keyring daemon.
+/* gkd-prompt-tool.c - Handles gui authentication for the keyring daemon.
Copyright (C) 2009 Stefan Walter
@@ -37,11 +37,60 @@
static GKeyFile *input_data = NULL;
static GKeyFile *output_data = NULL;
+static gboolean keyboard_grabbed = FALSE;
#define LOG_ERRORS 1
/* ------------------------------------------------------------------------------ */
+static gchar*
+create_markup (const gchar *primary, const gchar *secondary)
+{
+ return g_markup_printf_escaped ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
+ primary, secondary ? secondary : "");
+
+}
+
+static gboolean
+grab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
+{
+ GdkGrabStatus status;
+ if (!keyboard_grabbed) {
+ status = gdk_keyboard_grab (win->window, FALSE, gdk_event_get_time (event));
+ if (status == GDK_GRAB_SUCCESS) {
+ keyboard_grabbed = TRUE;
+ } else {
+ g_message ("could not grab keyboard: %d", (int)status);
+ }
+ }
+ return FALSE;
+}
+
+static gboolean
+ungrab_keyboard (GtkWidget *win, GdkEvent *event, gpointer data)
+{
+ if (keyboard_grabbed)
+ gdk_keyboard_ungrab (gdk_event_get_time (event));
+ keyboard_grabbed = FALSE;
+ return FALSE;
+}
+
+static gboolean
+window_state_changed (GtkWidget *win, GdkEventWindowState *event, gpointer data)
+{
+ GdkWindowState state = gdk_window_get_state (win->window);
+
+ if (state & GDK_WINDOW_STATE_WITHDRAWN ||
+ state & GDK_WINDOW_STATE_ICONIFIED ||
+ state & GDK_WINDOW_STATE_FULLSCREEN ||
+ state & GDK_WINDOW_STATE_MAXIMIZED)
+ ungrab_keyboard (win, (GdkEvent*)event, data);
+ else
+ grab_keyboard (win, (GdkEvent*)event, data);
+
+ return FALSE;
+}
+
static void
prepare_visibility (GtkBuilder *builder, GtkDialog *dialog)
{
@@ -83,6 +132,27 @@ prepare_titlebar (GtkBuilder *builder, GtkDialog *dialog)
}
static void
+prepare_prompt (GtkBuilder *builder, GtkDialog *dialog)
+{
+ gchar *primary, *secondary, *markup;
+ GtkLabel *label;
+
+ primary = g_key_file_get_value (input_data, "prompt", "primary", NULL);
+ g_return_if_fail (primary);
+ secondary = g_key_file_get_value (input_data, "prompt", "secondary", NULL);
+
+ markup = create_markup (primary, secondary);
+ g_free (primary);
+ g_free (secondary);
+
+ label = GTK_LABEL (gtk_builder_get_object (builder, "prompt_label"));
+ g_return_if_fail (label);
+
+ gtk_label_set_markup (label, markup);
+ g_free (markup);
+}
+
+static void
prepare_buttons (GtkBuilder *builder, GtkDialog *dialog)
{
gchar *ok_text;
@@ -105,13 +175,25 @@ prepare_buttons (GtkBuilder *builder, GtkDialog *dialog)
g_free (other_text);
}
+static void
+prepare_security (GtkBuilder *builder, GtkDialog *dialog)
+{
+ /*
+ * When passwords are involved we grab the keyboard so that people
+ * don't accidentally type their passwords in other windows.
+ */
+ g_signal_connect (dialog, "map-event", G_CALLBACK (grab_keyboard), NULL);
+ g_signal_connect (dialog, "unmap-event", G_CALLBACK (ungrab_keyboard), NULL);
+ g_signal_connect (dialog, "window-state-event", G_CALLBACK (window_state_changed), NULL);
+}
+
static GtkDialog*
prepare_dialog (GtkBuilder *builder)
{
GError *error = NULL;
GtkDialog *dialog;
- if (!gtk_builder_add_from_file (builder, UIDIR "gku-prompt.ui", &error)) {
+ if (!gtk_builder_add_from_file (builder, UIDIR "gkd-prompt.ui", &error)) {
g_warning ("couldn't load prompt ui file: %s",
error && error->message ? error->message : "");
g_clear_error (&error);
@@ -122,8 +204,10 @@ prepare_dialog (GtkBuilder *builder)
g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
prepare_titlebar (builder, dialog);
+ prepare_prompt (builder, dialog);
prepare_visibility (builder, dialog);
prepare_buttons (builder, dialog);
+ prepare_security (builder, dialog);
return dialog;
}
@@ -398,7 +482,7 @@ main (int argc, char *argv[])
g_key_file_free (output_data);
if (!data)
- fatal ("couldn't format auth dialog response: %s", err ? err->message : "");
+ fatal ("couldn't format auth dialog response: %s", err ? err->message : "");
write_all_output (data, length);
g_free (data);
diff --git a/ui/gku-prompt.ui b/daemon/prompt/gkd-prompt.ui
similarity index 100%
rename from ui/gku-prompt.ui
rename to daemon/prompt/gkd-prompt.ui
diff --git a/ui/test/test-data/prompt-empty b/daemon/prompt/test/test-data/prompt-empty
similarity index 100%
rename from ui/test/test-data/prompt-empty
rename to daemon/prompt/test/test-data/prompt-empty
diff --git a/ui/test/test-data/prompt-test b/daemon/prompt/test/test-data/prompt-test
similarity index 100%
rename from ui/test/test-data/prompt-test
rename to daemon/prompt/test/test-data/prompt-test
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]