diff options
author | George Lebl <jirka@5z.com> | 2002-08-19 23:41:34 +0000 |
---|---|---|
committer | George Lebl <jirka@src.gnome.org> | 2002-08-19 23:41:34 +0000 |
commit | 10e32d109dfb62facb29d9024a404d8983ea7133 (patch) | |
tree | 09d9e2f02b907800abbc3556da66b956a21722f1 /gui | |
parent | b953c7bbea26bc8826747ea2a9b1ad8855152439 (diff) | |
download | gdm-10e32d109dfb62facb29d9024a404d8983ea7133.tar.gz |
whack the redundant queries for halt, reboot and suspend, we already have
Mon Aug 19 16:50:30 2002 George Lebl <jirka@5z.com>
* gui/greeter/greeter_system.c: whack the redundant queries for
halt, reboot and suspend, we already have a dialog the person
answers. Fixes #90971
* gui/greeter/greeter_item_capslock.c: include libgnome.h
* gui/gdmsetup.c: Listen for a property on the root window
_GDM_SETUP_INSENSITIVE and if non-zero make self insensitive
* daemon/slave.c: when restarting the greeter set the above property
to make the setup be insensitive for a bit. This makes sure the
user doesn't twiddle with the interface which could make things
weird looking, especially if the user twiddles greeter settings or
opens new windows.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/gdmsetup.c | 108 | ||||
-rw-r--r-- | gui/greeter/greeter_item_capslock.c | 1 | ||||
-rw-r--r-- | gui/greeter/greeter_system.c | 12 |
3 files changed, 114 insertions, 7 deletions
diff --git a/gui/gdmsetup.c b/gui/gdmsetup.c index e36cb825..00d1c63d 100644 --- a/gui/gdmsetup.c +++ b/gui/gdmsetup.c @@ -65,6 +65,27 @@ setup_cursor (GdkCursorType type) } static void +setup_window_cursor (GdkCursorType type) +{ + GdkCursor *cursor = gdk_cursor_new (type); + GtkWidget *setup_dialog = glade_helper_get + (xml, "setup_dialog", GTK_TYPE_WINDOW); + if (setup_dialog->window) + gdk_window_set_cursor (setup_dialog->window, cursor); + gdk_cursor_unref (cursor); +} + +static void +unsetup_window_cursor (void) +{ + GtkWidget *setup_dialog = glade_helper_get + (xml, "setup_dialog", GTK_TYPE_WINDOW); + if (setup_dialog->window) + gdk_window_set_cursor (setup_dialog->window, NULL); +} + + +static void update_greeters (void) { char *p, *ret; @@ -1874,6 +1895,88 @@ setup_gui (void) } static gboolean +get_sensitivity (void) +{ + static Atom atom = 0; + Display *disp = gdk_x11_get_default_xdisplay (); + Window root = gdk_x11_get_default_root_xwindow (); + gulong *data; + gulong nitems_return; + gulong bytes_after_return; + Atom type_returned; + int format_returned; + + if (atom == 0) + atom = XInternAtom (disp, "_GDM_SETUP_INSENSITIVE", False); + + if (XGetWindowProperty (disp, + root, + atom, + 0, 1, + False, + XA_CARDINAL, + &type_returned, &format_returned, + &nitems_return, + &bytes_after_return, + (unsigned char **)&data) != Success) + return TRUE; + + if (format_returned != 32 || + data[0] == 0) { + XFree (data); + return TRUE; + } else { + XFree (data); + return FALSE; + } +} + +static void +update_sensitivity (void) +{ + gboolean sensitive = get_sensitivity (); + GtkWidget *setup_dialog = glade_helper_get (xml, "setup_dialog", + GTK_TYPE_WINDOW); + gtk_widget_set_sensitive (setup_dialog, sensitive); + if (sensitive) + unsetup_window_cursor (); + else + setup_window_cursor (GDK_WATCH); +} + +static GdkFilterReturn +root_window_filter (GdkXEvent *gdk_xevent, + GdkEvent *event, + gpointer data) +{ + XEvent *xevent = (XEvent *)gdk_xevent; + + if (xevent->type == PropertyNotify) + update_sensitivity (); + + return GDK_FILTER_CONTINUE; +} + +static void +setup_disable_handler (void) +{ + XWindowAttributes attribs = { 0, }; + Display *disp = gdk_x11_get_default_xdisplay (); + Window root = gdk_x11_get_default_root_xwindow (); + + update_sensitivity (); + + /* set event mask for events on root window */ + XGetWindowAttributes (disp, root, &attribs); + XSelectInput (disp, root, + attribs.your_event_mask | + PropertyChangeMask); + + gdk_window_add_filter (gdk_get_default_root_window (), + root_window_filter, NULL); +} + +static gboolean gdm_event (GSignalInvocationHint *ihint, guint n_param_values, const GValue *param_values, @@ -1978,8 +2081,11 @@ main (int argc, char *argv[]) setup_gui (); - if (RUNNING_UNDER_GDM) + if (RUNNING_UNDER_GDM) { + setup_disable_handler (); + setup_cursor (GDK_LEFT_PTR); + } gtk_main (); diff --git a/gui/greeter/greeter_item_capslock.c b/gui/greeter/greeter_item_capslock.c index b59d83ce..a0297ad6 100644 --- a/gui/greeter/greeter_item_capslock.c +++ b/gui/greeter/greeter_item_capslock.c @@ -1,6 +1,7 @@ #include "config.h" #include <gtk/gtk.h> +#include <libgnome/libgnome.h> #include <gdk/gdkkeysyms.h> #include <string.h> #include <gdk/gdkx.h> diff --git a/gui/greeter/greeter_system.c b/gui/greeter/greeter_system.c index a72f1d71..ca0ae940 100644 --- a/gui/greeter/greeter_system.c +++ b/gui/greeter/greeter_system.c @@ -49,32 +49,32 @@ working_command_exists (const char *commands) static void greeter_reboot_handler (void) { - if (greeter_query (_("Are you sure you want to reboot the machine?"))) { + /*if (greeter_query (_("Are you sure you want to reboot the machine?"))) {*/ closelog(); _exit (DISPLAY_REBOOT); - } + /*}*/ } static void greeter_halt_handler (void) { - if (greeter_query (_("Are you sure you want to shut down the machine?"))) { + /* if (greeter_query (_("Are you sure you want to shut down the machine?"))) { */ closelog(); _exit (DISPLAY_HALT); - } + /* } */ } static void greeter_suspend_handler (void) { - if (greeter_query (_("Are you sure you want to suspend the machine?"))) { + /* if (greeter_query (_("Are you sure you want to suspend the machine?"))) { */ closelog(); _exit (DISPLAY_SUSPEND); - } + /* } */ } static void |