[gnome-settings-daemon] main: Remove libsystemd-login specific code



commit f7928b54cccc909ab47bf90b917711f9d195da84
Author: Colin Walters <walters verbum org>
Date:   Tue Nov 6 17:47:05 2012 -0500

    main: Remove libsystemd-login specific code
    
    After porting both users of the helper code (the power and
    color plugins) to use gnome-session's SessionIsActive property,
    remove the libsystemd-login dependent code.
    
    As originally intended, gnome-settings-daemon requires
    systemd for the power plugin to work at run-time, but does
    not hard depend on libsystemd-login itself at compile-time.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686650

 configure.ac                                   |    3 +-
 gnome-settings-daemon/gnome-settings-session.c |  233 ------------------------
 gnome-settings-daemon/gnome-settings-session.h |   32 ----
 3 files changed, 1 insertions(+), 267 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 462e3a6..d4b8531 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,7 +63,6 @@ PKG_CHECK_MODULES(SETTINGS_DAEMON,
         gmodule-2.0
         gthread-2.0
 	gsettings-desktop-schemas >= 3.5.90
-	libsystemd-login
 )
 
 PKG_CHECK_MODULES(SETTINGS_PLUGIN,
@@ -222,7 +221,7 @@ PKG_CHECK_MODULES(SOUND, [libpulse >= $PA_REQUIRED_VERSION $GUDEV_PKG libpulse-m
 # ---------------------------------------------------------------------------
 # Power
 # ---------------------------------------------------------------------------
-PKG_CHECK_MODULES(POWER, upower-glib >= $UPOWER_REQUIRED_VERSION gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION libcanberra-gtk3 libnotify x11 xext)
+PKG_CHECK_MODULES(POWER, libsystemd-login upower-glib >= $UPOWER_REQUIRED_VERSION gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION libcanberra-gtk3 libnotify x11 xext)
 
 if test x$have_gudev != xno; then
 	PKG_CHECK_MODULES(BACKLIGHT_HELPER,
diff --git a/gnome-settings-daemon/gnome-settings-session.c b/gnome-settings-daemon/gnome-settings-session.c
index e404a34..226c12b 100644
--- a/gnome-settings-daemon/gnome-settings-session.c
+++ b/gnome-settings-daemon/gnome-settings-session.c
@@ -30,239 +30,6 @@
 
 #include "gnome-settings-session.h"
 
-typedef struct
-{
-  GSource source;
-  GPollFD pollfd;
-  sd_login_monitor *monitor;
-} SdSource;
-
-static gboolean
-sd_source_prepare (GSource *source,
-                   gint    *timeout)
-{
-  *timeout = -1;
-  return FALSE;
-}
-
-static gboolean
-sd_source_check (GSource *source)
-{
-  SdSource *sd_source = (SdSource *)source;
-
-  return sd_source->pollfd.revents != 0;
-}
-
-static gboolean
-sd_source_dispatch (GSource     *source,
-                    GSourceFunc  callback,
-                    gpointer     user_data)
-
-{
-  SdSource *sd_source = (SdSource *)source;
-  gboolean ret;
-
-  g_warn_if_fail (callback != NULL);
-
-  ret = (*callback) (user_data);
-
-  sd_login_monitor_flush (sd_source->monitor);
-  return ret;
-}
-
-static void
-sd_source_finalize (GSource *source)
-{
-  SdSource *sd_source = (SdSource*)source;
-
-  sd_login_monitor_unref (sd_source->monitor);
-}
-
-static GSourceFuncs sd_source_funcs = {
-  sd_source_prepare,
-  sd_source_check,
-  sd_source_dispatch,
-  sd_source_finalize
-};
-
-static GSource *
-sd_source_new (void)
-{
-  GSource *source;
-  SdSource *sd_source;
-  int ret;
-
-  source = g_source_new (&sd_source_funcs, sizeof (SdSource));
-  sd_source = (SdSource *)source;
-
-  if ((ret = sd_login_monitor_new (NULL, &sd_source->monitor)) < 0)
-    {
-      g_printerr ("Error getting login monitor: %d", ret);
-    }
-  else
-    {
-      sd_source->pollfd.fd = sd_login_monitor_get_fd (sd_source->monitor);
-      sd_source->pollfd.events = G_IO_IN;
-      g_source_add_poll (source, &sd_source->pollfd);
-    }
-
-  return source;
-}
-
-static void gnome_settings_session_finalize (GObject *object);
-
-#define GNOME_SETTINGS_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNOME_TYPE_SETTINGS_SESSION, GnomeSettingsSessionPrivate))
-
-struct GnomeSettingsSessionPrivate
-{
-        GSource                   *sd_source;
-	gchar                     *session_id;
-	GnomeSettingsSessionState  state;
-};
-
-enum {
-	PROP_0,
-	PROP_STATE,
-	PROP_LAST
-};
-
-G_DEFINE_TYPE (GnomeSettingsSession, gnome_settings_session, G_TYPE_OBJECT)
-
-GnomeSettingsSessionState
-gnome_settings_session_get_state (GnomeSettingsSession *session)
-{
-	g_return_val_if_fail (GNOME_IS_SETTINGS_SESSION (session),
-			      GNOME_SETTINGS_SESSION_STATE_UNKNOWN);
-	return session->priv->state;
-}
-
-static void
-gnome_settings_session_set_state (GnomeSettingsSession *session,
-				  gboolean active)
-{
-        GnomeSettingsSessionState  state;
-
-        state = active ? GNOME_SETTINGS_SESSION_STATE_ACTIVE
-                       : GNOME_SETTINGS_SESSION_STATE_INACTIVE;
-        if (session->priv->state != state) {
-                session->priv->state = state;
-                g_object_notify (G_OBJECT (session), "state");
-        }
-}
-
-static void
-gnome_settings_session_get_property (GObject *object,
-				     guint prop_id,
-				     GValue *value,
-				     GParamSpec *pspec)
-{
-	GnomeSettingsSession *session = GNOME_SETTINGS_SESSION (object);
-
-	switch (prop_id) {
-	case PROP_STATE:
-		g_value_set_enum (value, session->priv->state);
-		break;
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-		break;
-	}
-}
-
-GType
-gnome_settings_session_state_get_type (void)
-{
-	static GType etype = 0;
-	if (etype == 0) {
-		static const GEnumValue values[] = {
-			{ GNOME_SETTINGS_SESSION_STATE_UNKNOWN,
-			  "unknown", "Unknown" },
-			{ GNOME_SETTINGS_SESSION_STATE_ACTIVE,
-			  "active", "Active" },
-			{ GNOME_SETTINGS_SESSION_STATE_INACTIVE,
-			  "inactive", "Inactive" },
-			{ 0, NULL, NULL }
-			};
-		etype = g_enum_register_static ("GnomeSettingsSessionState", values);
-	}
-	return etype;
-}
-
-static void
-gnome_settings_session_class_init (GnomeSettingsSessionClass *klass)
-{
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	object_class->get_property = gnome_settings_session_get_property;
-	object_class->finalize = gnome_settings_session_finalize;
-	g_type_class_add_private (klass, sizeof (GnomeSettingsSessionPrivate));
-
-	g_object_class_install_property (object_class,
-					 PROP_STATE,
-					 g_param_spec_enum ("state",
-							    "The session state",
-							    NULL,
-							    GNOME_TYPE_SETTINGS_SESSION_STATE,
-							    GNOME_SETTINGS_SESSION_STATE_UNKNOWN,
-							    G_PARAM_READABLE));
-}
-
-static gboolean
-sessions_changed (gpointer user_data)
-{
-        GnomeSettingsSession *session = user_data;
-        gboolean active;
-
-        active = sd_session_is_active (session->priv->session_id);
-        gnome_settings_session_set_state (session, active);
-
-        return TRUE;
-}
-
-static void
-gnome_settings_session_init (GnomeSettingsSession *session)
-{
-	session->priv = GNOME_SETTINGS_SESSION_GET_PRIVATE (session);
-
-        sd_pid_get_session (getpid(), &session->priv->session_id);
-
-        session->priv->sd_source = sd_source_new ();
-        g_source_set_callback (session->priv->sd_source, sessions_changed, session, NULL);
-        g_source_attach (session->priv->sd_source, NULL);
-
-        sessions_changed (session);
-}
-
-static void
-gnome_settings_session_finalize (GObject *object)
-{
-	GnomeSettingsSession *session;
-
-	session = GNOME_SETTINGS_SESSION (object);
-
-        g_free (session->priv->session_id);
-
-        if (session->priv->sd_source != NULL) {
-                g_source_destroy (session->priv->sd_source);
-                g_source_unref (session->priv->sd_source);
-        }
-
-	G_OBJECT_CLASS (gnome_settings_session_parent_class)->finalize (object);
-}
-
-static GnomeSettingsSession *session;
-
-GnomeSettingsSession *
-gnome_settings_session_new (void)
-{
-        if (session != NULL) {
-                g_object_ref (session);
-        } else {
-                session = g_object_new (GNOME_TYPE_SETTINGS_SESSION, NULL);
-                g_object_add_weak_pointer ((GObject*)session, (gpointer*)&session);
-        }
-
-	return session;
-}
-
 #define GNOME_SESSION_DBUS_NAME      "org.gnome.SessionManager"
 #define GNOME_SESSION_DBUS_OBJECT    "/org/gnome/SessionManager"
 #define GNOME_SESSION_DBUS_INTERFACE "org.gnome.SessionManager"
diff --git a/gnome-settings-daemon/gnome-settings-session.h b/gnome-settings-daemon/gnome-settings-session.h
index 1f7580d..0c9a1b7 100644
--- a/gnome-settings-daemon/gnome-settings-session.h
+++ b/gnome-settings-daemon/gnome-settings-session.h
@@ -26,38 +26,6 @@
 
 G_BEGIN_DECLS
 
-#define GNOME_TYPE_SETTINGS_SESSION		(gnome_settings_session_get_type ())
-#define GNOME_SETTINGS_SESSION(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GNOME_TYPE_SETTINGS_SESSION, GnomeSettingsSession))
-#define GNOME_SETTINGS_SESSION_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GNOME_TYPE_SETTINGS_SESSION, GnomeSettingsSessionClass))
-#define GNOME_IS_SETTINGS_SESSION(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNOME_TYPE_SETTINGS_SESSION))
-#define GNOME_IS_SETTINGS_SESSION_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GNOME_TYPE_SETTINGS_SESSION))
-#define GNOME_SETTINGS_SESSION_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GNOME_TYPE_SETTINGS_SESSION, GnomeSettingsSessionClass))
-#define GNOME_TYPE_SETTINGS_SESSION_STATE	(gnome_settings_session_state_get_type())
-
-typedef struct GnomeSettingsSessionPrivate GnomeSettingsSessionPrivate;
-
-typedef struct
-{
-	 GObject			 parent;
-	 GnomeSettingsSessionPrivate	*priv;
-} GnomeSettingsSession;
-
-typedef struct
-{
-	GObjectClass	parent_class;
-} GnomeSettingsSessionClass;
-
-typedef enum {
-	GNOME_SETTINGS_SESSION_STATE_UNKNOWN,
-	GNOME_SETTINGS_SESSION_STATE_ACTIVE,
-	GNOME_SETTINGS_SESSION_STATE_INACTIVE,
-} GnomeSettingsSessionState;
-
-GType			 gnome_settings_session_get_type	(void);
-GType			 gnome_settings_session_state_get_type	(void);
-GnomeSettingsSession	*gnome_settings_session_new		(void);
-GnomeSettingsSessionState gnome_settings_session_get_state	(GnomeSettingsSession	*session);
-
 GDBusProxy              *gnome_settings_session_get_session_proxy  (void);
 
 G_END_DECLS



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