diff options
author | William Jon McCann <jmccann@redhat.com> | 2008-02-20 18:41:49 +0000 |
---|---|---|
committer | William Jon McCann <mccann@src.gnome.org> | 2008-02-20 18:41:49 +0000 |
commit | 9400160560215c509759efca6fb365f12e4a8bc5 (patch) | |
tree | 3653a68ebba12afe5864ddc8737fd1f491bda275 /gui/simple-greeter | |
parent | 7ded9b2049a472b9fb5f6f2f70e270e14fcee656 (diff) | |
download | gdm-9400160560215c509759efca6fb365f12e4a8bc5.tar.gz |
Add initial support for timed login.
2008-02-20 William Jon McCann <jmccann@redhat.com>
* common/gdm-settings-client.c: (gdm_settings_client_get_string):
* common/gdm-settings-keys.h:
* daemon/gdm-factory-slave.c: (on_greeter_begin_verification),
(on_greeter_begin_verification_for_user):
* daemon/gdm-greeter-server.c: (handle_begin_timed_login),
(greeter_handle_child_message), (do_introspect),
(gdm_greeter_server_class_init):
* daemon/gdm-greeter-server.h:
* daemon/gdm-product-slave.c: (on_relay_setup),
(on_relay_setup_for_user):
* daemon/gdm-session-direct.c: (gdm_session_direct_init),
(send_setup), (send_setup_for_user), (gdm_session_direct_setup),
(gdm_session_direct_setup_for_user),
(gdm_session_direct_set_property),
(gdm_session_direct_get_property), (gdm_session_direct_dispose),
(gdm_session_direct_class_init):
* daemon/gdm-session-relay.c: (send_dbus_string_string_signal),
(gdm_session_relay_setup), (gdm_session_relay_setup_for_user),
(do_introspect):
* daemon/gdm-session.c: (gdm_session_setup),
(gdm_session_setup_for_user):
* daemon/gdm-session.h:
* daemon/gdm-simple-slave.c: (on_greeter_begin_verification),
(on_greeter_begin_timed_login),
(on_greeter_begin_verification_for_user), (run_greeter):
* daemon/simple-slave-main.c: (main):
* daemon/test-session.c: (on_open):
* gui/simple-greeter/gdm-greeter-client.c:
(emit_string_signal_for_message),
(gdm_greeter_client_call_begin_timed_login):
* gui/simple-greeter/gdm-greeter-client.h:
* gui/simple-greeter/gdm-greeter-login-window.c:
(remove_timed_login_timeout), (timed_login_timer),
(restart_timed_login_timeout),
(on_login_button_clicked_answer_query),
(on_login_button_clicked_timed_login), (set_log_in_button_mode),
(switch_mode), (do_cancel), (reset_dialog),
(gdm_greeter_login_window_info_query),
(gdm_greeter_login_window_secret_info_query), (on_user_chosen),
(load_theme), (read_configuration),
(gdm_greeter_login_window_constructor),
(gdm_greeter_login_window_class_init),
(gdm_greeter_login_window_init):
* gui/simple-greeter/gdm-greeter-login-window.h:
* gui/simple-greeter/gdm-greeter-session.c: (on_begin_timed_login),
(toggle_login_window):
* gui/simple-greeter/gdm-user-chooser-dialog.c:
(gdm_user_chooser_dialog_set_show_other_user),
(gdm_user_chooser_dialog_set_show_guest_user),
(gdm_user_chooser_dialog_set_show_auto_user),
(gdm_user_chooser_dialog_init):
* gui/simple-greeter/gdm-user-chooser-dialog.h:
* gui/simple-greeter/gdm-user-chooser-widget.c: (add_user_other),
(add_user_guest), (add_user_auto), (remove_user_other),
(remove_user_guest), (remove_user_auto),
(gdm_user_chooser_widget_set_show_other_user),
(gdm_user_chooser_widget_set_show_guest_user),
(gdm_user_chooser_widget_set_show_auto_user),
(gdm_user_chooser_widget_constructor),
(gdm_user_chooser_widget_init):
* gui/simple-greeter/gdm-user-chooser-widget.h:
* gui/simple-greeter/greeter-main.c: (main):
* gui/simple-greeter/test-greeter-login-window.c: (main):
* gui/simple-greeter/test-user-chooser.c: (main):
Add initial support for timed login.
svn path=/trunk/; revision=5820
Diffstat (limited to 'gui/simple-greeter')
-rw-r--r-- | gui/simple-greeter/gdm-greeter-client.c | 9 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-greeter-client.h | 1 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-greeter-login-window.c | 210 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-greeter-login-window.h | 2 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-greeter-session.c | 11 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-user-chooser-dialog.c | 30 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-user-chooser-dialog.h | 9 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-user-chooser-widget.c | 118 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-user-chooser-widget.h | 7 | ||||
-rw-r--r-- | gui/simple-greeter/greeter-main.c | 1 | ||||
-rw-r--r-- | gui/simple-greeter/test-greeter-login-window.c | 5 | ||||
-rw-r--r-- | gui/simple-greeter/test-user-chooser.c | 2 |
12 files changed, 346 insertions, 59 deletions
diff --git a/gui/simple-greeter/gdm-greeter-client.c b/gui/simple-greeter/gdm-greeter-client.c index 4794b83f..f2565e78 100644 --- a/gui/simple-greeter/gdm-greeter-client.c +++ b/gui/simple-greeter/gdm-greeter-client.c @@ -115,7 +115,7 @@ emit_string_signal_for_message (GdmGreeterClient *client, DBUS_TYPE_INVALID); if (res) { - g_debug ("GdmGreeterClient: Recieved %s (%s)", name, text); + g_debug ("GdmGreeterClient: Received %s (%s)", name, text); g_signal_emit (client, gdm_greeter_client_signals[signal], @@ -291,6 +291,13 @@ send_dbus_void_method (DBusConnection *connection, } void +gdm_greeter_client_call_begin_timed_login (GdmGreeterClient *client) +{ + send_dbus_void_method (client->priv->connection, + "BeginTimedLogin"); +} + +void gdm_greeter_client_call_begin_verification (GdmGreeterClient *client) { send_dbus_void_method (client->priv->connection, diff --git a/gui/simple-greeter/gdm-greeter-client.h b/gui/simple-greeter/gdm-greeter-client.h index ed9f91a2..bf88d9a2 100644 --- a/gui/simple-greeter/gdm-greeter-client.h +++ b/gui/simple-greeter/gdm-greeter-client.h @@ -86,6 +86,7 @@ gboolean gdm_greeter_client_get_display_is_local (GdmGreeter char * gdm_greeter_client_call_get_display_id (GdmGreeterClient *client); +void gdm_greeter_client_call_begin_timed_login (GdmGreeterClient *client); void gdm_greeter_client_call_begin_verification (GdmGreeterClient *client); void gdm_greeter_client_call_begin_verification_for_user (GdmGreeterClient *client, const char *username); diff --git a/gui/simple-greeter/gdm-greeter-login-window.c b/gui/simple-greeter/gdm-greeter-login-window.c index 3cff65c8..6468ba3d 100644 --- a/gui/simple-greeter/gdm-greeter-login-window.c +++ b/gui/simple-greeter/gdm-greeter-login-window.c @@ -60,6 +60,9 @@ #include <polkit-gnome/polkit-gnome.h> #endif +#include "gdm-settings-client.h" +#include "gdm-settings-keys.h" + #include "gdm-greeter-login-window.h" #include "gdm-user-chooser-widget.h" @@ -86,6 +89,7 @@ #define GLADE_XML_FILE "gdm-greeter-login-window.glade" #define LOGO_KEY "/apps/gdm/simple-greeter/logo-icon-name" +#define TIMED_LOGIN_TIMEOUT_SEC 60 #define GDM_GREETER_LOGIN_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_GREETER_LOGIN_WINDOW, GdmGreeterLoginWindowPrivate)) @@ -94,6 +98,12 @@ enum { MODE_AUTHENTICATION }; +enum { + LOGIN_BUTTON_HIDDEN = 0, + LOGIN_BUTTON_ANSWER_QUERY, + LOGIN_BUTTON_TIMED_LOGIN +}; + struct GdmGreeterLoginWindowPrivate { GladeXML *xml; @@ -101,7 +111,13 @@ struct GdmGreeterLoginWindowPrivate gboolean display_is_local; char *timeformat; + gboolean timed_login_enabled; + guint timed_login_delay; + guint timed_login_timeout_id; + guint animation_timeout_id; + + guint login_button_handler_id; }; enum { @@ -110,6 +126,7 @@ enum { }; enum { + BEGIN_TIMED_LOGIN, BEGIN_VERIFICATION, BEGIN_VERIFICATION_FOR_USER, QUERY_ANSWER, @@ -174,7 +191,6 @@ set_focus (GdmGreeterLoginWindow *login_window) } } - static void set_message (GdmGreeterLoginWindow *login_window, const char *text) @@ -186,6 +202,40 @@ set_message (GdmGreeterLoginWindow *login_window, } static void +remove_timed_login_timeout (GdmGreeterLoginWindow *login_window) +{ + if (login_window->priv->timed_login_timeout_id > 0) { + g_source_remove (login_window->priv->timed_login_timeout_id); + login_window->priv->timed_login_timeout_id = 0; + } +} + +static gboolean +timed_login_timer (GdmGreeterLoginWindow *login_window) +{ + set_sensitive (login_window, FALSE); + set_message (login_window, _("Automatically logging in...")); + + g_debug ("GdmGreeterLoginWindow: emitting begin-timed_login"); + g_signal_emit (login_window, signals[BEGIN_TIMED_LOGIN], 0); + login_window->priv->timed_login_timeout_id = 0; + + return FALSE; +} + +static void +restart_timed_login_timeout (GdmGreeterLoginWindow *login_window) +{ + remove_timed_login_timeout (login_window); + + if (login_window->priv->timed_login_enabled) { + login_window->priv->timed_login_timeout_id = g_timeout_add_seconds (login_window->priv->timed_login_delay, + (GSourceFunc)timed_login_timer, + login_window); + } +} + +static void show_widget (GdmGreeterLoginWindow *login_window, const char *name, gboolean visible) @@ -228,6 +278,65 @@ get_show_restart_buttons (GdmGreeterLoginWindow *login_window) } static void +on_login_button_clicked_answer_query (GtkButton *button, + GdmGreeterLoginWindow *login_window) +{ + GtkWidget *entry; + const char *text; + + set_busy (login_window); + set_sensitive (login_window, FALSE); + + entry = glade_xml_get_widget (login_window->priv->xml, "auth-prompt-entry"); + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + g_signal_emit (login_window, signals[QUERY_ANSWER], 0, text); +} + +static void +on_login_button_clicked_timed_login (GtkButton *button, + GdmGreeterLoginWindow *login_window) +{ + set_busy (login_window); + set_sensitive (login_window, FALSE); + + g_signal_emit (login_window, signals[BEGIN_TIMED_LOGIN], 0); +} + +static void +set_log_in_button_mode (GdmGreeterLoginWindow *login_window, + int mode) +{ + GtkWidget *button; + + button = glade_xml_get_widget (login_window->priv->xml, "log-in-button"); + gtk_widget_grab_default (button); + + /* disconnect any signals */ + if (login_window->priv->login_button_handler_id > 0) { + g_signal_handler_disconnect (button, login_window->priv->login_button_handler_id); + login_window->priv->login_button_handler_id = 0; + } + + switch (mode) { + case LOGIN_BUTTON_HIDDEN: + gtk_widget_hide (button); + break; + case LOGIN_BUTTON_ANSWER_QUERY: + login_window->priv->login_button_handler_id = g_signal_connect (button, "clicked", G_CALLBACK (on_login_button_clicked_answer_query), login_window); + gtk_widget_show (button); + break; + case LOGIN_BUTTON_TIMED_LOGIN: + login_window->priv->login_button_handler_id = g_signal_connect (button, "clicked", G_CALLBACK (on_login_button_clicked_timed_login), login_window); + gtk_widget_show (button); + break; + default: + g_assert_not_reached (); + break; + } +} + +static void switch_mode (GdmGreeterLoginWindow *login_window, int number) { @@ -239,11 +348,14 @@ switch_mode (GdmGreeterLoginWindow *login_window, /* FIXME: do animation */ default_name = NULL; + restart_timed_login_timeout (login_window); + show_restart_shutdown = get_show_restart_buttons (login_window); switch (number) { case MODE_SELECTION: - show_widget (login_window, "log-in-button", FALSE); + set_log_in_button_mode (login_window, LOGIN_BUTTON_HIDDEN); + show_widget (login_window, "cancel-button", FALSE); show_widget (login_window, "shutdown-button", login_window->priv->display_is_local && show_restart_shutdown); @@ -255,7 +367,6 @@ switch_mode (GdmGreeterLoginWindow *login_window, default_name = NULL; break; case MODE_AUTHENTICATION: - show_widget (login_window, "log-in-button", TRUE); show_widget (login_window, "cancel-button", TRUE); show_widget (login_window, "shutdown-button", FALSE); show_widget (login_window, "restart-button", FALSE); @@ -349,6 +460,7 @@ do_cancel (GdmGreeterLoginWindow *login_window) switch_mode (login_window, MODE_SELECTION); set_busy (login_window); set_sensitive (login_window, FALSE); + set_message (login_window, ""); g_signal_emit (login_window, signals[CANCELLED], 0); @@ -366,6 +478,7 @@ reset_dialog (GdmGreeterLoginWindow *login_window) entry = glade_xml_get_widget (GDM_GREETER_LOGIN_WINDOW (login_window)->priv->xml, "auth-prompt-entry"); gtk_entry_set_text (GTK_ENTRY (entry), ""); gtk_entry_set_visibility (GTK_ENTRY (entry), TRUE); + set_message (login_window, ""); label = glade_xml_get_widget (GDM_GREETER_LOGIN_WINDOW (login_window)->priv->xml, "auth-prompt-label"); gtk_label_set_text (GTK_LABEL (label), ""); @@ -379,6 +492,8 @@ reset_dialog (GdmGreeterLoginWindow *login_window) set_sensitive (login_window, TRUE); set_ready (login_window); set_focus (GDM_GREETER_LOGIN_WINDOW (login_window)); + + restart_timed_login_timeout (login_window); } gboolean @@ -443,6 +558,7 @@ gdm_greeter_login_window_info_query (GdmGreeterLoginWindow *login_window, entry = glade_xml_get_widget (GDM_GREETER_LOGIN_WINDOW (login_window)->priv->xml, "auth-prompt-entry"); gtk_entry_set_text (GTK_ENTRY (entry), ""); gtk_entry_set_visibility (GTK_ENTRY (entry), TRUE); + set_log_in_button_mode (login_window, LOGIN_BUTTON_ANSWER_QUERY); label = glade_xml_get_widget (GDM_GREETER_LOGIN_WINDOW (login_window)->priv->xml, "auth-prompt-label"); gtk_label_set_text (GTK_LABEL (label), text); @@ -467,6 +583,7 @@ gdm_greeter_login_window_secret_info_query (GdmGreeterLoginWindow *login_window, entry = glade_xml_get_widget (GDM_GREETER_LOGIN_WINDOW (login_window)->priv->xml, "auth-prompt-entry"); gtk_entry_set_text (GTK_ENTRY (entry), ""); gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE); + set_log_in_button_mode (login_window, LOGIN_BUTTON_ANSWER_QUERY); label = glade_xml_get_widget (GDM_GREETER_LOGIN_WINDOW (login_window)->priv->xml, "auth-prompt-label"); gtk_label_set_text (GTK_LABEL (label), text); @@ -527,22 +644,6 @@ gdm_greeter_login_window_get_property (GObject *object, } static void -log_in_button_clicked (GtkButton *button, - GdmGreeterLoginWindow *login_window) -{ - GtkWidget *entry; - const char *text; - - set_busy (login_window); - set_sensitive (login_window, FALSE); - - entry = glade_xml_get_widget (login_window->priv->xml, "auth-prompt-entry"); - text = gtk_entry_get_text (GTK_ENTRY (entry)); - - g_signal_emit (login_window, signals[QUERY_ANSWER], 0, text); -} - -static void suspend_button_clicked (GtkButton *button, GdmGreeterLoginWindow *login_window) { @@ -841,6 +942,10 @@ on_user_chosen (GdmUserChooserWidget *user_chooser, g_signal_emit (login_window, signals[BEGIN_VERIFICATION], 0); } else if (strcmp (user_name, GDM_USER_CHOOSER_USER_GUEST) == 0) { /* FIXME: handle guest account stuff */ + } else if (strcmp (user_name, GDM_USER_CHOOSER_USER_AUTO) == 0) { + /* just wait for the user to select language and stuff */ + set_log_in_button_mode (login_window, LOGIN_BUTTON_TIMED_LOGIN); + set_message (login_window, _("Select language and click Log In")); } else { g_signal_emit (login_window, signals[BEGIN_VERIFICATION_FOR_USER], 0, user_name); } @@ -1058,9 +1163,9 @@ load_theme (GdmGreeterLoginWindow *login_window) gdm_user_chooser_widget_set_show_only_chosen (GDM_USER_CHOOSER_WIDGET (login_window->priv->user_chooser), TRUE); - /* FIXME: set from gconf */ - gdm_user_chooser_widget_set_show_other_user (GDM_USER_CHOOSER_WIDGET (login_window->priv->user_chooser), TRUE); - gdm_user_chooser_widget_set_show_guest_user (GDM_USER_CHOOSER_WIDGET (login_window->priv->user_chooser), TRUE); + if (login_window->priv->timed_login_enabled) { + gdm_user_chooser_widget_set_show_auto_user (GDM_USER_CHOOSER_WIDGET (login_window->priv->user_chooser), TRUE); + } g_signal_connect (login_window->priv->user_chooser, "activated", @@ -1076,10 +1181,6 @@ load_theme (GdmGreeterLoginWindow *login_window) button = glade_xml_get_widget (login_window->priv->xml, "suspend-button"); g_signal_connect (button, "clicked", G_CALLBACK (suspend_button_clicked), login_window); - button = glade_xml_get_widget (login_window->priv->xml, "log-in-button"); - gtk_widget_grab_default (button); - g_signal_connect (button, "clicked", G_CALLBACK (log_in_button_clicked), login_window); - button = glade_xml_get_widget (login_window->priv->xml, "cancel-button"); g_signal_connect (button, "clicked", G_CALLBACK (cancel_button_clicked), login_window); @@ -1215,6 +1316,49 @@ gdm_greeter_login_window_size_allocate (GtkWidget *widget, GTK_WIDGET_CLASS (gdm_greeter_login_window_parent_class)->size_allocate (widget, allocation); } +static void +read_configuration (GdmGreeterLoginWindow *login_window) +{ + gboolean res; + int delay; + char *username; + + g_debug ("GdmGreeterLoginWindow: reading system configuration"); + + res = gdm_settings_client_get_boolean (GDM_KEY_TIMED_LOGIN_ENABLE, + &login_window->priv->timed_login_enabled); + if (! res) { + g_warning ("Unable to read configuration for %s", GDM_KEY_TIMED_LOGIN_ENABLE); + } + g_debug ("GdmGreeterLoginWindow: TimedLoginEnable=%s", + login_window->priv->timed_login_enabled ? "true" : "false"); + + /* treat failures here as disabling */ + username = NULL; + res = gdm_settings_client_get_string (GDM_KEY_TIMED_LOGIN_USER, &username); + if (! res) { + g_warning ("Unable to read configuration for %s", GDM_KEY_TIMED_LOGIN_USER); + login_window->priv->timed_login_enabled = FALSE; + } else { + if (username == NULL) { + login_window->priv->timed_login_enabled = FALSE; + } + } + g_debug ("GdmGreeterLoginWindow: TimedLogin=%s", username); + g_free (username); + + delay = -1; + res = gdm_settings_client_get_int (GDM_KEY_TIMED_LOGIN_DELAY, &delay); + if (! res) { + g_warning ("Unable to read configuration for %s", GDM_KEY_TIMED_LOGIN_DELAY); + } else { + if (delay >= 0) { + login_window->priv->timed_login_delay = delay; + } + } + g_debug ("GdmGreeterLoginWindow: TimedLoginDelay=%d", delay); +} + static GObject * gdm_greeter_login_window_constructor (GType type, guint n_construct_properties, @@ -1227,6 +1371,7 @@ gdm_greeter_login_window_constructor (GType type, construct_properties)); + read_configuration (login_window); load_theme (login_window); return G_OBJECT (login_window); @@ -1247,6 +1392,16 @@ gdm_greeter_login_window_class_init (GdmGreeterLoginWindowClass *klass) widget_class->size_request = gdm_greeter_login_window_size_request; widget_class->size_allocate = gdm_greeter_login_window_size_allocate; + signals [BEGIN_TIMED_LOGIN] = + g_signal_new ("begin-timed_login", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GdmGreeterLoginWindowClass, begin_timed_login), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); signals [BEGIN_VERIFICATION] = g_signal_new ("begin-verification", G_TYPE_FROM_CLASS (object_class), @@ -1323,6 +1478,9 @@ gdm_greeter_login_window_init (GdmGreeterLoginWindow *login_window) { login_window->priv = GDM_GREETER_LOGIN_WINDOW_GET_PRIVATE (login_window); + login_window->priv->timed_login_enabled = FALSE; + login_window->priv->timed_login_delay = TIMED_LOGIN_TIMEOUT_SEC; + gtk_window_set_title (GTK_WINDOW (login_window), _("Login Window")); gtk_window_set_opacity (GTK_WINDOW (login_window), 0.85); gtk_window_set_position (GTK_WINDOW (login_window), GTK_WIN_POS_CENTER_ALWAYS); diff --git a/gui/simple-greeter/gdm-greeter-login-window.h b/gui/simple-greeter/gdm-greeter-login-window.h index e06095df..94d969ee 100644 --- a/gui/simple-greeter/gdm-greeter-login-window.h +++ b/gui/simple-greeter/gdm-greeter-login-window.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu> + * Copyright (C) 2008 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,6 +46,7 @@ typedef struct GtkWindowClass parent_class; /* signals */ + void (* begin_timed_login) (GdmGreeterLoginWindow *login_window); void (* begin_verification) (GdmGreeterLoginWindow *login_window); void (* begin_verification_for_user) (GdmGreeterLoginWindow *login_window, const char *username); diff --git a/gui/simple-greeter/gdm-greeter-session.c b/gui/simple-greeter/gdm-greeter-session.c index 63ebc191..c285c61d 100644 --- a/gui/simple-greeter/gdm-greeter-session.c +++ b/gui/simple-greeter/gdm-greeter-session.c @@ -158,6 +158,13 @@ on_secret_info_query (GdmGreeterClient *client, } static void +on_begin_timed_login (GdmGreeterLoginWindow *login_window, + GdmGreeterSession *session) +{ + gdm_greeter_client_call_begin_timed_login (session->priv->client); +} + +static void on_begin_verification (GdmGreeterLoginWindow *login_window, GdmGreeterSession *session) { @@ -261,6 +268,10 @@ toggle_login_window (GdmSessionManager *manager, session->priv->login_window = gdm_greeter_login_window_new (is_local); g_signal_connect (session->priv->login_window, + "begin-timed-login", + G_CALLBACK (on_begin_timed_login), + session); + g_signal_connect (session->priv->login_window, "begin-verification", G_CALLBACK (on_begin_verification), session); diff --git a/gui/simple-greeter/gdm-user-chooser-dialog.c b/gui/simple-greeter/gdm-user-chooser-dialog.c index 48d90ca9..11459c2b 100644 --- a/gui/simple-greeter/gdm-user-chooser-dialog.c +++ b/gui/simple-greeter/gdm-user-chooser-dialog.c @@ -62,6 +62,33 @@ gdm_user_chooser_dialog_get_chosen_user_name (GdmUserChooserDialog *dialog) return user_name; } +void +gdm_user_chooser_dialog_set_show_other_user (GdmUserChooserDialog *dialog, + gboolean show_user) +{ + g_return_if_fail (GDM_IS_USER_CHOOSER_DIALOG (dialog)); + + gdm_user_chooser_widget_set_show_other_user (GDM_USER_CHOOSER_WIDGET (dialog->priv->chooser_widget), show_user); +} + +void +gdm_user_chooser_dialog_set_show_guest_user (GdmUserChooserDialog *dialog, + gboolean show_user) +{ + g_return_if_fail (GDM_IS_USER_CHOOSER_DIALOG (dialog)); + + gdm_user_chooser_widget_set_show_guest_user (GDM_USER_CHOOSER_WIDGET (dialog->priv->chooser_widget), show_user); +} + +void +gdm_user_chooser_dialog_set_show_auto_user (GdmUserChooserDialog *dialog, + gboolean show_user) +{ + g_return_if_fail (GDM_IS_USER_CHOOSER_DIALOG (dialog)); + + gdm_user_chooser_widget_set_show_auto_user (GDM_USER_CHOOSER_WIDGET (dialog->priv->chooser_widget), show_user); +} + static void gdm_user_chooser_dialog_set_property (GObject *object, guint prop_id, @@ -139,8 +166,7 @@ gdm_user_chooser_dialog_init (GdmUserChooserDialog *dialog) dialog->priv = GDM_USER_CHOOSER_DIALOG_GET_PRIVATE (dialog); dialog->priv->chooser_widget = gdm_user_chooser_widget_new (); - gdm_user_chooser_widget_set_show_other_user (GDM_USER_CHOOSER_WIDGET (dialog->priv->chooser_widget), TRUE); - gdm_user_chooser_widget_set_show_guest_user (GDM_USER_CHOOSER_WIDGET (dialog->priv->chooser_widget), TRUE); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->priv->chooser_widget); gtk_dialog_add_buttons (GTK_DIALOG (dialog), diff --git a/gui/simple-greeter/gdm-user-chooser-dialog.h b/gui/simple-greeter/gdm-user-chooser-dialog.h index a38dfa5c..a70e1023 100644 --- a/gui/simple-greeter/gdm-user-chooser-dialog.h +++ b/gui/simple-greeter/gdm-user-chooser-dialog.h @@ -37,7 +37,7 @@ typedef struct GdmUserChooserDialogPrivate GdmUserChooserDialogPrivate; typedef struct { - GtkDialog parent; + GtkDialog parent; GdmUserChooserDialogPrivate *priv; } GdmUserChooserDialog; @@ -51,7 +51,12 @@ GType gdm_user_chooser_dialog_get_type (void) GtkWidget * gdm_user_chooser_dialog_new (void); char * gdm_user_chooser_dialog_get_chosen_user_name (GdmUserChooserDialog *dialog); - +void gdm_user_chooser_dialog_set_show_other_user (GdmUserChooserDialog *dialog, + gboolean show); +void gdm_user_chooser_dialog_set_show_guest_user (GdmUserChooserDialog *dialog, + gboolean show); +void gdm_user_chooser_dialog_set_show_auto_user (GdmUserChooserDialog *dialog, + gboolean show); G_END_DECLS #endif /* __GDM_USER_CHOOSER_DIALOG_H */ diff --git a/gui/simple-greeter/gdm-user-chooser-widget.c b/gui/simple-greeter/gdm-user-chooser-widget.c index c9c31591..46884118 100644 --- a/gui/simple-greeter/gdm-user-chooser-widget.c +++ b/gui/simple-greeter/gdm-user-chooser-widget.c @@ -58,6 +58,7 @@ struct GdmUserChooserWidgetPrivate guint show_other_user : 1; guint show_guest_user : 1; + guint show_auto_user : 1; }; enum { @@ -70,6 +71,66 @@ static void gdm_user_chooser_widget_finalize (GObject * G_DEFINE_TYPE (GdmUserChooserWidget, gdm_user_chooser_widget, GDM_TYPE_CHOOSER_WIDGET) +static void +add_user_other (GdmUserChooserWidget *widget) +{ + gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget), + GDM_USER_CHOOSER_USER_OTHER, + widget->priv->stock_person_pixbuf, + _("Other..."), + _("Choose a different account"), + 0, + FALSE, + TRUE); +} + +static void +add_user_guest (GdmUserChooserWidget *widget) +{ + gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget), + GDM_USER_CHOOSER_USER_GUEST, + widget->priv->stock_person_pixbuf, + _("Guest"), + _("Login as a temporary guest"), + 0, + FALSE, + TRUE); +} + +static void +add_user_auto (GdmUserChooserWidget *widget) +{ + gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget), + GDM_USER_CHOOSER_USER_AUTO, + widget->priv->stock_person_pixbuf, + _("Automatic Login"), + _("Automatically login to the system after selecting options"), + 0, + FALSE, + TRUE); +} + +static void +remove_user_other (GdmUserChooserWidget *widget) +{ + gdm_chooser_widget_remove_item (GDM_CHOOSER_WIDGET (widget), + GDM_USER_CHOOSER_USER_OTHER); +} + +static void +remove_user_guest (GdmUserChooserWidget *widget) +{ + gdm_chooser_widget_remove_item (GDM_CHOOSER_WIDGET (widget), + GDM_USER_CHOOSER_USER_GUEST); +} + +static void +remove_user_auto (GdmUserChooserWidget *widget) +{ + gdm_chooser_widget_remove_item (GDM_CHOOSER_WIDGET (widget), + GDM_USER_CHOOSER_USER_AUTO); +} + void gdm_user_chooser_widget_set_show_other_user (GdmUserChooserWidget *widget, gboolean show_user) @@ -78,6 +139,11 @@ gdm_user_chooser_widget_set_show_other_user (GdmUserChooserWidget *widget, if (widget->priv->show_other_user != show_user) { widget->priv->show_other_user = show_user; + if (show_user) { + add_user_other (widget); + } else { + remove_user_other (widget); + } } } @@ -89,6 +155,27 @@ gdm_user_chooser_widget_set_show_guest_user (GdmUserChooserWidget *widget, if (widget->priv->show_guest_user != show_user) { widget->priv->show_guest_user = show_user; + if (show_user) { + add_user_guest (widget); + } else { + remove_user_guest (widget); + } + } +} + +void +gdm_user_chooser_widget_set_show_auto_user (GdmUserChooserWidget *widget, + gboolean show_user) +{ + g_return_if_fail (GDM_IS_USER_CHOOSER_WIDGET (widget)); + + if (widget->priv->show_auto_user != show_user) { + widget->priv->show_auto_user = show_user; + if (show_user) { + add_user_auto (widget); + } else { + remove_user_auto (widget); + } } } @@ -155,6 +242,11 @@ gdm_user_chooser_widget_constructor (GType type, n_construct_properties, construct_properties)); + /* FIXME: make these construct properties */ + gdm_user_chooser_widget_set_show_guest_user (user_chooser_widget, FALSE); + gdm_user_chooser_widget_set_show_auto_user (user_chooser_widget, FALSE); + gdm_user_chooser_widget_set_show_other_user (user_chooser_widget, TRUE); + return G_OBJECT (user_chooser_widget); } @@ -294,31 +386,6 @@ setup_icons (GdmUserChooserWidget *widget) load_icons (widget); } -static gboolean -add_special_users (GdmUserChooserWidget *widget) -{ - - gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget), - GDM_USER_CHOOSER_USER_OTHER, - widget->priv->stock_person_pixbuf, - _("Other..."), - _("Choose a different account"), - 0, - FALSE, - TRUE); -#if 0 - gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget), - GDM_USER_CHOOSER_USER_GUEST, - widget->priv->stock_person_pixbuf, - _("Guest"), - _("Login as a temporary guest"), - 0, - FALSE, - TRUE); -#endif - return FALSE; -} - static void on_user_added (GdmUserManager *manager, GdmUser *user, @@ -438,7 +505,6 @@ gdm_user_chooser_widget_init (GdmUserChooserWidget *widget) widget); setup_icons (widget); - add_special_users (widget); } static void diff --git a/gui/simple-greeter/gdm-user-chooser-widget.h b/gui/simple-greeter/gdm-user-chooser-widget.h index a117fb33..0795eb1f 100644 --- a/gui/simple-greeter/gdm-user-chooser-widget.h +++ b/gui/simple-greeter/gdm-user-chooser-widget.h @@ -49,6 +49,7 @@ typedef struct #define GDM_USER_CHOOSER_USER_OTHER "__other" #define GDM_USER_CHOOSER_USER_GUEST "__guest" +#define GDM_USER_CHOOSER_USER_AUTO "__auto" GType gdm_user_chooser_widget_get_type (void); GtkWidget * gdm_user_chooser_widget_new (void); @@ -59,9 +60,11 @@ void gdm_user_chooser_widget_set_chosen_user_name (GdmUs void gdm_user_chooser_widget_set_show_only_chosen (GdmUserChooserWidget *widget, gboolean show_only); void gdm_user_chooser_widget_set_show_other_user (GdmUserChooserWidget *widget, - gboolean show_other); + gboolean show); void gdm_user_chooser_widget_set_show_guest_user (GdmUserChooserWidget *widget, - gboolean show_other); + gboolean show); +void gdm_user_chooser_widget_set_show_auto_user (GdmUserChooserWidget *widget, + gboolean show); G_END_DECLS #endif /* __GDM_USER_CHOOSER_WIDGET_H */ diff --git a/gui/simple-greeter/greeter-main.c b/gui/simple-greeter/greeter-main.c index d2ffbe56..d782f59c 100644 --- a/gui/simple-greeter/greeter-main.c +++ b/gui/simple-greeter/greeter-main.c @@ -236,6 +236,7 @@ main (int argc, char *argv[]) g_type_init (); if (! gdm_settings_client_init (GDMCONFDIR "/gdm.schemas", "/")) { + g_critical ("Unable to initialize settings client"); exit (1); } diff --git a/gui/simple-greeter/test-greeter-login-window.c b/gui/simple-greeter/test-greeter-login-window.c index 60204ce4..cfd98619 100644 --- a/gui/simple-greeter/test-greeter-login-window.c +++ b/gui/simple-greeter/test-greeter-login-window.c @@ -45,6 +45,11 @@ main (int argc, char *argv[]) gtk_init (&argc, &argv); + if (! gdm_settings_client_init (GDMCONFDIR "/gdm.schemas", "/")) { + g_critical ("Unable to initialize settings client"); + exit (1); + } + login_window = gdm_greeter_login_window_new (TRUE); gtk_widget_show (login_window); diff --git a/gui/simple-greeter/test-user-chooser.c b/gui/simple-greeter/test-user-chooser.c index 79d9c903..360cd244 100644 --- a/gui/simple-greeter/test-user-chooser.c +++ b/gui/simple-greeter/test-user-chooser.c @@ -47,6 +47,8 @@ main (int argc, char *argv[]) dialog = gdm_user_chooser_dialog_new (); /*gtk_widget_set_size_request (dialog, 480, 128);*/ + gdm_user_chooser_dialog_set_show_guest_user (GDM_USER_CHOOSER_DIALOG (dialog), TRUE); + gdm_user_chooser_dialog_set_show_auto_user (GDM_USER_CHOOSER_DIALOG (dialog), TRUE); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { char *name; |