diff options
author | William Jon McCann <mccann@jhu.edu> | 2007-09-05 16:02:32 +0000 |
---|---|---|
committer | William Jon McCann <mccann@src.gnome.org> | 2007-09-05 16:02:32 +0000 |
commit | 4aa2a5879396a3884c56006426c91960a6fc830d (patch) | |
tree | 8966dc090bc5ac6bcf302934ce4607722c760cef /libgreeter | |
parent | 8cb6adfa111708779a65513d000fe7d77971c30c (diff) | |
download | gdm-4aa2a5879396a3884c56006426c91960a6fc830d.tar.gz |
Add SelectHostname, Disconnected, and GetDisplayId methods to the greeter
2007-09-05 William Jon McCann <mccann@jhu.edu>
* daemon/gdm-factory-slave.c: (run_greeter):
* daemon/gdm-greeter-server.c: (handle_disconnect),
(handle_get_display_id), (greeter_handle_child_message),
(do_introspect), (_gdm_greeter_server_set_display_id),
(gdm_greeter_server_set_property),
(gdm_greeter_server_get_property), (gdm_greeter_server_class_init),
(gdm_greeter_server_new):
* daemon/gdm-greeter-server.h:
* daemon/gdm-simple-slave.c: (run_greeter),
(gdm_simple_slave_stop):
* daemon/gdm-slave.c: (gdm_slave_finalize):
* gui/simple-greeter/gdm-simple-greeter.c:
(suspend_button_clicked), (gdm_simple_greeter_new):
* gui/simple-greeter/gdm-simple-greeter.h:
* gui/simple-greeter/greeter-main.c: (on_select_hostname),
(on_disconnected), (get_display_id), (main):
* libgreeter/gdm-greeter.c: (gdm_greeter_display_is_local),
(gdm_greeter_emit_disconnected), (_gdm_greeter_set_display_id),
(gdm_greeter_set_property), (gdm_greeter_get_property),
(cache_display_values), (gdm_greeter_constructor),
(gdm_greeter_class_init), (gdm_greeter_finalize):
* libgreeter/gdm-greeter.h:
Add SelectHostname, Disconnected, and GetDisplayId methods
to the greeter server interface.
svn path=/branches/mccann-gobject/; revision=5228
Diffstat (limited to 'libgreeter')
-rw-r--r-- | libgreeter/gdm-greeter.c | 120 | ||||
-rw-r--r-- | libgreeter/gdm-greeter.h | 8 |
2 files changed, 127 insertions, 1 deletions
diff --git a/libgreeter/gdm-greeter.c b/libgreeter/gdm-greeter.c index bd6f89ea..3c2080eb 100644 --- a/libgreeter/gdm-greeter.c +++ b/libgreeter/gdm-greeter.c @@ -33,17 +33,26 @@ #include <glib/gi18n.h> #include <glib-object.h> +#define DBUS_API_SUBJECT_TO_CHANGE +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> + #include "gdm-greeter.h" #define GDM_GREETER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_GREETER, GdmGreeterPrivate)) +#define GDM_DBUS_NAME "org.gnome.DisplayManager" +#define GDM_DBUS_DISPLAY_INTERFACE "org.gnome.DisplayManager.Display" + struct GdmGreeterPrivate { - gpointer dummy; + char *display_id; + gboolean display_is_local; }; enum { PROP_0, + PROP_DISPLAY_ID, }; enum { @@ -51,6 +60,8 @@ enum { SESSION_SELECTED, LANGUAGE_SELECTED, USER_SELECTED, + HOSTNAME_SELECTED, + DISCONNECTED, CANCELLED, LAST_SIGNAL }; @@ -75,6 +86,14 @@ gdm_greeter_error_quark (void) return ret; } +gboolean +gdm_greeter_display_is_local (GdmGreeter *greeter) +{ + g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE); + + return greeter->priv->display_is_local; +} + static gboolean gdm_greeter_real_start (GdmGreeter *greeter) { @@ -301,6 +320,26 @@ gdm_greeter_emit_cancelled (GdmGreeter *greeter) return TRUE; } +gboolean +gdm_greeter_emit_disconnected (GdmGreeter *greeter) +{ + g_return_val_if_fail (GDM_IS_GREETER (greeter), FALSE); + + g_debug ("Disconnected"); + + g_signal_emit (greeter, signals[DISCONNECTED], 0); + + return TRUE; +} + +static void +_gdm_greeter_set_display_id (GdmGreeter *greeter, + const char *id) +{ + g_free (greeter->priv->display_id); + greeter->priv->display_id = g_strdup (id); +} + static void gdm_greeter_set_property (GObject *object, guint prop_id, @@ -312,6 +351,9 @@ gdm_greeter_set_property (GObject *object, self = GDM_GREETER (object); switch (prop_id) { + case PROP_DISPLAY_ID: + _gdm_greeter_set_display_id (self, g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -329,12 +371,56 @@ gdm_greeter_get_property (GObject *object, self = GDM_GREETER (object); switch (prop_id) { + case PROP_DISPLAY_ID: + g_value_set_string (value, self->priv->display_id); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } +static void +cache_display_values (GdmGreeter *greeter) +{ + DBusGProxy *display_proxy; + DBusGConnection *connection; + GError *error; + gboolean res; + + error = NULL; + connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); + if (connection == NULL) { + if (error != NULL) { + g_critical ("error getting system bus: %s", error->message); + g_error_free (error); + } + exit (1); + } + + g_debug ("Creating proxy for %s", greeter->priv->display_id); + display_proxy = dbus_g_proxy_new_for_name (connection, + GDM_DBUS_NAME, + greeter->priv->display_id, + GDM_DBUS_DISPLAY_INTERFACE); + /* cache some values up front */ + error = NULL; + res = dbus_g_proxy_call (display_proxy, + "IsLocal", + &error, + G_TYPE_INVALID, + G_TYPE_BOOLEAN, &greeter->priv->display_is_local, + G_TYPE_INVALID); + if (! res) { + if (error != NULL) { + g_warning ("Failed to get value: %s", error->message); + g_error_free (error); + } else { + g_warning ("Failed to get value"); + } + } +} + static GObject * gdm_greeter_constructor (GType type, guint n_construct_properties, @@ -349,6 +435,8 @@ gdm_greeter_constructor (GType type, n_construct_properties, construct_properties)); + cache_display_values (greeter); + return G_OBJECT (greeter); } @@ -425,6 +513,16 @@ gdm_greeter_class_init (GdmGreeterClass *klass) g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + signals [HOSTNAME_SELECTED] = + g_signal_new ("hostname-selected", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GdmGreeterClass, hostname_selected), + NULL, + NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, G_TYPE_STRING); signals [CANCELLED] = g_signal_new ("cancelled", G_TYPE_FROM_CLASS (object_class), @@ -435,6 +533,24 @@ gdm_greeter_class_init (GdmGreeterClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals [DISCONNECTED] = + g_signal_new ("disconnected", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GdmGreeterClass, disconnected), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + + g_object_class_install_property (object_class, + PROP_DISPLAY_ID, + g_param_spec_string ("display-id", + "id", + "id", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_type_class_add_private (klass, sizeof (GdmGreeterPrivate)); } @@ -459,5 +575,7 @@ gdm_greeter_finalize (GObject *object) g_return_if_fail (greeter->priv != NULL); + g_free (greeter->priv->display_id); + G_OBJECT_CLASS (gdm_greeter_parent_class)->finalize (object); } diff --git a/libgreeter/gdm-greeter.h b/libgreeter/gdm-greeter.h index c80bcb1f..755baed7 100644 --- a/libgreeter/gdm-greeter.h +++ b/libgreeter/gdm-greeter.h @@ -54,7 +54,10 @@ typedef struct const char *text); void (* user_selected) (GdmGreeter *greeter, const char *text); + void (* hostname_selected) (GdmGreeter *greeter, + const char *text); void (* cancelled) (GdmGreeter *greeter); + void (* disconnected) (GdmGreeter *greeter); /* methods */ gboolean (*start) (GdmGreeter *greeter); @@ -95,7 +98,10 @@ gboolean gdm_greeter_emit_select_language (GdmGreeter *gree const char *text); gboolean gdm_greeter_emit_select_user (GdmGreeter *greeter, const char *text); +gboolean gdm_greeter_emit_select_hostname (GdmGreeter *greeter, + const char *text); gboolean gdm_greeter_emit_cancelled (GdmGreeter *greeter); +gboolean gdm_greeter_emit_disconnected (GdmGreeter *greeter); /* actions */ gboolean gdm_greeter_info_query (GdmGreeter *greeter, @@ -106,6 +112,8 @@ gboolean gdm_greeter_info (GdmGreeter *gree const char *text); gboolean gdm_greeter_problem (GdmGreeter *greeter, const char *text); +/* misc */ +gboolean gdm_greeter_display_is_local (GdmGreeter *greeter); G_END_DECLS |