policykit-gnome r22 - in trunk: . data po src



Author: davidz
Date: Mon May 12 18:35:07 2008
New Revision: 22
URL: http://svn.gnome.org/viewvc/policykit-gnome?rev=22&view=rev

Log:
don't grab the pointer when popping up the auth dialog

Patch from Federico Mena Quintero <federico gnu org>. Resolves
http://bugzilla.gnome.org/show_bug.cgi?id=531609

Signed-off-by: Federico Mena Quintero <federico gnu org>



Added:
   trunk/data/polkit-gnome.schemas.in
Modified:
   trunk/configure.ac
   trunk/data/Makefile.am
   trunk/po/POTFILES.in
   trunk/src/polkit-gnome-manager.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Mon May 12 18:35:07 2008
@@ -167,6 +167,18 @@
     fi
 fi
 
+dnl ==============================================
+dnl Special GConf section 
+dnl ==============================================
+
+AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
+
+if test x"$GCONFTOOL" = xno; then
+  AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
+fi
+
+AM_GCONF_SOURCE_2
+
 # ********************
 # Internationalisation
 # ********************

Modified: trunk/data/Makefile.am
==============================================================================
--- trunk/data/Makefile.am	(original)
+++ trunk/data/Makefile.am	Mon May 12 18:35:07 2008
@@ -1,3 +1,18 @@
+schema_in_files =  polkit-gnome.schemas.in
+schemadir   = $(GCONF_SCHEMA_FILE_DIR)
+schema_DATA = $(schema_in_files:.schemas.in=.schemas)
+
+ INTLTOOL_SCHEMAS_RULE@
+
+# don't do this if we are building in eg. rpm
+if GCONF_SCHEMAS_INSTALL
+install-data-local:
+	if test -z "$(DESTDIR)" ; then \
+		for p in $(schema_DATA) ; do \
+			GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $$p; \
+		done \
+	fi
+endif
 
 @INTLTOOL_DESKTOP_RULE@
 desktopdir = $(datadir)/applications
@@ -24,7 +39,11 @@
 
 DISTCLEANFILES = $(service_DATA) $(desktop_DATA) $(pkgconfig_DATA)
 
-EXTRA_DIST = $(service_in_files) $(desktop_in_files) polkit-gnome.pc.in
+EXTRA_DIST =			\
+	$(service_in_files)	\
+	$(desktop_in_files)	\
+	$(schema_in_files)	\
+	polkit-gnome.pc.in
 
 clean-local :
-	rm -f *~ $(service_DATA) $(pkgconfig_DATA)
+	rm -f *~ $(service_DATA) $(pkgconfig_DATA) $(schema_DATA)

Added: trunk/data/polkit-gnome.schemas.in
==============================================================================
--- (empty file)
+++ trunk/data/polkit-gnome.schemas.in	Mon May 12 18:35:07 2008
@@ -0,0 +1,22 @@
+<gconfschemafile>
+  <schemalist>
+
+    <schema>
+      <key>/schemas/desktop/gnome/policykit/auth_dialog_grab_keyboard</key>
+      <applyto>/desktop/gnome/policykit/auth_dialog_grab_keyboard</applyto>
+      <owner>policykit-gnome</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+         <short>Whether the authentication dialog should grab the keyboard</short>
+         <long>
+          If set to true, the authentication dialog from PolicyKit-gnome will grab the keyboard,
+          so that you will not be able to type in other programs while the dialog is active.
+	  Use this if your window manager does not focus the authentication dialog automatically,
+	  and you want to avoid accidentally typing passwords in other programs.
+         </long>
+      </locale>
+    </schema>
+
+  </schemalist>
+</gconfschemafile>

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Mon May 12 18:35:07 2008
@@ -2,6 +2,7 @@
 # Please keep this file sorted alphabetically.
 [encoding: UTF-8]
 data/polkit-gnome-authorization.desktop.in
+data/polkit-gnome.schemas.in
 examples/polkit-gnome-example.c
 examples/org.gnome.policykit.examples.policy.in
 polkit-gnome/polkit-gnome-action.c

Modified: trunk/src/polkit-gnome-manager.c
==============================================================================
--- trunk/src/polkit-gnome-manager.c	(original)
+++ trunk/src/polkit-gnome-manager.c	Mon May 12 18:35:07 2008
@@ -33,6 +33,7 @@
 #include <glib/gi18n-lib.h>
 #include <glib-object.h>
 #include <gdk/gdkx.h>
+#include <gconf/gconf-client.h>
 
 #define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbus/dbus-glib.h>
@@ -47,6 +48,8 @@
 
 #include "polkit-gnome-auth-dialog.h"
 
+#define KEY_AUTH_DIALOG_GRAB_KEYBOARD "/desktop/gnome/policykit/auth_dialog_grab_keyboard"
+
 static void do_cancel_auth (void);
 
 
@@ -516,6 +519,8 @@
         char **admin_users;
 
         char *admin_user_selected;
+
+        gboolean got_keyboard_grab;
 } UserData;
 
 static void
@@ -571,26 +576,25 @@
 static void
 _do_grab (GtkWidget *widget, GdkEvent *event, gpointer user_data)
 {
-        GdkGrabStatus ret;
+        UserData *ud = user_data;
+        GConfClient *client;
 
-        ret = gdk_pointer_grab (widget->window, 
-                                TRUE,
-                                GDK_POINTER_MOTION_MASK|GDK_BUTTON_MOTION_MASK,
-                                NULL,
-                                NULL,
-                                GDK_CURRENT_TIME);
-        if (ret != GDK_GRAB_SUCCESS) {
-                g_warning ("Couldn't grab the pointer; ret = %d", ret);
-        }
-
-        ret = gdk_keyboard_grab (widget->window, 
-                                FALSE,
-                                GDK_CURRENT_TIME);
-        if (ret != GDK_GRAB_SUCCESS) {
-                g_warning ("Couldn't grab the pointer; ret = %d", ret);
-        }
+        ud->got_keyboard_grab = FALSE;
 
-        g_debug ("Grabbed pointer and keyboard");
+        client = gconf_client_get_default ();
+        if (gconf_client_get_bool (client, KEY_AUTH_DIALOG_GRAB_KEYBOARD, NULL)) { /* NULL-GError */
+                GdkGrabStatus ret;
+
+                ret = gdk_keyboard_grab (widget->window, 
+                                         FALSE,
+                                         GDK_CURRENT_TIME); /* FIXME: ideally we need a real timestamp */
+                if (ret != GDK_GRAB_SUCCESS) {
+                        g_warning ("Couldn't grab the keyboard; ret = %d", ret);
+                } else {
+                        g_debug ("Grabbed keyboard");
+                        ud->got_keyboard_grab = TRUE;
+                }
+        }
 }
 
 /*--------------------------------------------------------------------------------------------------------------*/
@@ -1082,9 +1086,10 @@
 error:
 
         /* Ungrab keyboard and pointer */
-        gdk_keyboard_ungrab (GDK_CURRENT_TIME);
-        gdk_pointer_ungrab (GDK_CURRENT_TIME);
-        g_debug ("Ungrabbed pointer and keyboard");
+        if (ud->got_keyboard_grab) {
+                gdk_keyboard_ungrab (GDK_CURRENT_TIME);
+                g_debug ("Ungrabbed keyboard");
+        }
 
         if (ud->dialog != NULL) {
                 gtk_widget_destroy (ud->dialog);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]