[gnome-settings-daemon] power: Add an initial power plugin that just handles the lid actions



commit d77d3bc857230596f3d8a3963212c52236f7aed4
Author: Richard Hughes <richard hughsie com>
Date:   Fri Jun 17 17:50:39 2011 +0100

    power: Add an initial power plugin that just handles the lid actions
    
    There's a whole lot more functionality coming...

 ...settings-daemon.plugins.power.gschema.xml.in.in |    2 +-
 plugins/Makefile.am                                |    1 +
 plugins/power/Makefile.am                          |   56 +++
 plugins/power/gsd-power-manager.c                  |  354 ++++++++++++++++++++
 plugins/power/gsd-power-manager.h                  |   57 ++++
 plugins/power/gsd-power-plugin.c                   |  110 ++++++
 plugins/power/gsd-power-plugin.h                   |   59 ++++
 plugins/power/power.gnome-settings-plugin.in       |    8 +
 po/POTFILES.in                                     |    2 +
 9 files changed, 648 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in.in b/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in.in
index f0719d8..ba1dca7 100644
--- a/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in.in
+++ b/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in.in
@@ -1,7 +1,7 @@
 <schemalist>
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.plugins.power" path="/org/gnome/settings-daemon/plugins/power/">
     <key name="active" type="b">
-      <default>false</default><!-- g-p-m is not a GSD plugin, yet -->
+      <default>true</default>
       <_summary>Activation of this plugin</_summary>
       <_description>Whether this plugin would be activated by gnome-settings-daemon or not</_description>
     </key>
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 082f051..5e26811 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -10,6 +10,7 @@ enabled_plugins =	\
 	cursor		\
 	datetime	\
 	dummy		\
+	power		\
 	housekeeping    \
 	keybindings	\
 	keyboard	\
diff --git a/plugins/power/Makefile.am b/plugins/power/Makefile.am
new file mode 100644
index 0000000..e0cc1ed
--- /dev/null
+++ b/plugins/power/Makefile.am
@@ -0,0 +1,56 @@
+plugin_name = power
+
+plugin_LTLIBRARIES =					\
+	libpower.la
+
+libpower_la_SOURCES = 					\
+	gsd-power-manager.c				\
+	gsd-power-manager.h				\
+	gsd-power-plugin.c				\
+	gsd-power-plugin.h
+
+libpower_la_CPPFLAGS = \
+	-I$(top_srcdir)/data/				\
+	-I$(top_srcdir)/gnome-settings-daemon		\
+	-I$(top_srcdir)/plugins/common			\
+	-DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
+	-DGTKBUILDERDIR=\""$(pkgdatadir)"\"		\
+	-DSBINDIR=\"$(sbindir)\"			\
+	$(AM_CPPFLAGS)
+
+libpower_la_CFLAGS = \
+	$(PLUGIN_CFLAGS)				\
+	$(KEYRING_CFLAGS)				\
+	$(PULSE_CFLAGS)					\
+	$(UPOWER_CFLAGS)				\
+	$(SETTINGS_PLUGIN_CFLAGS)			\
+	$(AM_CFLAGS)
+
+libpower_la_LDFLAGS = 					\
+	$(GSD_PLUGIN_LDFLAGS)
+
+libpower_la_LIBADD  = 					\
+	$(top_builddir)/plugins/common/libcommon.la	\
+	$(UPOWER_LIBS)					\
+	$(PULSE_LIBS)					\
+	$(KEYRING_LIBS)					\
+	$(SETTINGS_PLUGIN_LIBS)
+
+plugin_in_files = 					\
+	power.gnome-settings-plugin.in
+
+plugin_DATA = $(plugin_in_files:.gnome-settings-plugin.in=.gnome-settings-plugin)
+
+EXTRA_DIST = 						\
+	$(plugin_in_files)
+
+clean-local:
+	rm -f *~
+
+CLEANFILES = 						\
+	$(plugin_DATA)
+
+DISTCLEANFILES =					\
+	$(plugin_DATA)
+
+ GSD_INTLTOOL_PLUGIN_RULE@
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
new file mode 100644
index 0000000..4e0ac88
--- /dev/null
+++ b/plugins/power/gsd-power-manager.c
@@ -0,0 +1,354 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ * Copyright (C) 2011 Richard Hughes <richard hughsiec
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <canberra-gtk.h>
+#include <libupower-glib/upower.h>
+
+#include "gnome-settings-profile.h"
+#include "gsd-enums.h"
+#include "gsd-power-manager.h"
+
+#define GNOME_SESSION_DBUS_NAME                 "org.gnome.SessionManager"
+#define GNOME_SESSION_DBUS_PATH                 "/org/gnome/SessionManager"
+#define GNOME_SESSION_DBUS_INTERFACE            "org.gnome.SessionManager"
+
+#define CONSOLEKIT_DBUS_NAME                    "org.freedesktop.ConsoleKit"
+#define CONSOLEKIT_DBUS_PATH_MANAGER            "/org/freedesktop/ConsoleKit/Manager"
+#define CONSOLEKIT_DBUS_INTERFACE_MANAGER       "org.freedesktop.ConsoleKit.Manager"
+
+#define GSD_POWER_SETTINGS_SCHEMA               "org.gnome.settings-daemon.plugins.power"
+
+#define GSD_POWER_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_POWER_MANAGER, GsdPowerManagerPrivate))
+
+struct GsdPowerManagerPrivate
+{
+        gboolean                 lid_is_closed;
+        GSettings               *settings;
+        UpClient                *up_client;
+};
+
+enum {
+        PROP_0,
+};
+
+static void     gsd_power_manager_class_init  (GsdPowerManagerClass *klass);
+static void     gsd_power_manager_init        (GsdPowerManager      *power_manager);
+static void     gsd_power_manager_finalize    (GObject              *object);
+
+G_DEFINE_TYPE (GsdPowerManager, gsd_power_manager, G_TYPE_OBJECT)
+
+static gpointer manager_object = NULL;
+
+static void
+gnome_session_shutdown_cb (GObject *source_object,
+                           GAsyncResult *res,
+                           gpointer user_data)
+{
+        GVariant *result;
+        GError *error = NULL;
+
+        result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
+                                           res,
+                                           &error);
+        if (result == NULL) {
+                g_warning ("couldn't shutdown using gnome-session: %s",
+                           error->message);
+                g_error_free (error);
+        } else {
+                g_variant_unref (result);
+        }
+}
+
+static void
+gnome_session_shutdown (void)
+{
+        GError *error = NULL;
+        GDBusProxy *proxy;
+
+        /* ask gnome-session to show the shutdown dialog with a timeout */
+        proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                               G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+                                               NULL,
+                                               GNOME_SESSION_DBUS_NAME,
+                                               GNOME_SESSION_DBUS_PATH,
+                                               GNOME_SESSION_DBUS_INTERFACE,
+                                               NULL, &error);
+        if (proxy == NULL) {
+                g_warning ("cannot connect to gnome-session: %s",
+                           error->message);
+                g_error_free (error);
+                return;
+        }
+        g_dbus_proxy_call (proxy,
+                           "Shutdown",
+                           NULL,
+                           G_DBUS_CALL_FLAGS_NONE,
+                           -1, NULL,
+                           gnome_session_shutdown_cb, NULL);
+        g_object_unref (proxy);
+}
+
+static void
+consolekit_stop_cb (GObject *source_object,
+                    GAsyncResult *res,
+                    gpointer user_data)
+{
+        GVariant *result;
+        GError *error = NULL;
+
+        result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
+                                           res,
+                                           &error);
+        if (result == NULL) {
+                g_warning ("couldn't stop using ConsoleKit: %s",
+                           error->message);
+                g_error_free (error);
+        } else {
+                g_variant_unref (result);
+        }
+}
+
+static void
+consolekit_stop (void)
+{
+        GError *error = NULL;
+        GDBusProxy *proxy;
+
+        /* power down the machine in a safe way */
+        proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                               G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+                                               NULL,
+                                               CONSOLEKIT_DBUS_NAME,
+                                               CONSOLEKIT_DBUS_PATH_MANAGER,
+                                               CONSOLEKIT_DBUS_INTERFACE_MANAGER,
+                                               NULL, &error);
+        if (proxy == NULL) {
+                g_warning ("cannot connect to ConsoleKit: %s",
+                           error->message);
+                g_error_free (error);
+                return;
+        }
+        g_dbus_proxy_call (proxy,
+                           "Stop",
+                           NULL,
+                           G_DBUS_CALL_FLAGS_NONE,
+                           -1, NULL,
+                           consolekit_stop_cb, NULL);
+        g_object_unref (proxy);
+}
+
+static void
+do_power_action_type (GsdPowerManager *manager,
+                      GsdPowerActionType action_type)
+{
+        gboolean ret;
+        GError *error = NULL;
+
+        switch (action_type) {
+        case GSD_POWER_ACTION_SUSPEND:
+                ret = up_client_suspend_sync (manager->priv->up_client,
+                                              NULL, &error);
+                if (!ret) {
+                        g_warning ("failed to suspend: %s",
+                                   error->message);
+                        g_error_free (error);
+                }
+                break;
+        case GSD_POWER_ACTION_INTERACTIVE:
+                gnome_session_shutdown ();
+                break;
+        case GSD_POWER_ACTION_HIBERNATE:
+                ret = up_client_hibernate_sync (manager->priv->up_client,
+                                                NULL, &error);
+                if (!ret) {
+                        g_warning ("failed to suspend: %s",
+                                   error->message);
+                        g_error_free (error);
+                }
+                break;
+        case GSD_POWER_ACTION_SHUTDOWN:
+                /* this is only used on critically low battery where
+                 * hibernate is not available and is marginally better
+                 * than just powering down the computer mid-write */
+                consolekit_stop ();
+        case GSD_POWER_ACTION_BLANK:
+        case GSD_POWER_ACTION_NOTHING:
+                break;
+        }
+}
+
+static void
+do_lid_open_action (GsdPowerManager *manager)
+{
+        gint retval;
+        ca_context *context;
+
+        /* play a sound, using sounds from the naming spec */
+        context = ca_gtk_context_get_for_screen (gdk_screen_get_default ());
+        retval = ca_context_play (context, 0,
+                                  CA_PROP_EVENT_ID, "lid-open",
+                                  /* TRANSLATORS: this is the sound description */
+                                  CA_PROP_EVENT_DESCRIPTION, _("Lid has been opened"),
+                                  NULL);
+        if (retval < 0)
+                g_warning ("failed to play: %s", ca_strerror (retval));
+}
+
+static void
+do_lid_closed_action (GsdPowerManager *manager)
+{
+        gint retval;
+        ca_context *context;
+        GsdPowerActionType action_type;
+
+        /* play a sound, using sounds from the naming spec */
+        context = ca_gtk_context_get_for_screen (gdk_screen_get_default ());
+        retval = ca_context_play (context, 0,
+                                  CA_PROP_EVENT_ID, "lid-close",
+                                  /* TRANSLATORS: this is the sound description */
+                                  CA_PROP_EVENT_DESCRIPTION, _("Lid has been closed"),
+                                  NULL);
+        if (retval < 0)
+                g_warning ("failed to play: %s", ca_strerror (retval));
+
+        /* we have different settings depending on AC state */
+        if (up_client_get_on_battery (manager->priv->up_client)) {
+                action_type = g_settings_get_enum (manager->priv->settings,
+                                                   "lid-close-battery-action");
+        } else {
+                action_type = g_settings_get_enum (manager->priv->settings,
+                                                   "lid-close-ac-action");
+        }
+
+        /* check we won't melt when the lid is closed */
+        if (action_type != GSD_POWER_ACTION_SUSPEND &&
+            action_type != GSD_POWER_ACTION_HIBERNATE) {
+                if (up_client_get_lid_force_sleep (manager->priv->up_client)) {
+                        g_warning ("to prevent damage, now forcing suspend");
+                        do_power_action_type (manager, GSD_POWER_ACTION_SUSPEND);
+                        return;
+                }
+        }
+
+        /* are we docked? */
+        if (up_client_get_is_docked (manager->priv->up_client)) {
+                g_debug ("ignoring lid closed action because we are docked");
+                return;
+        }
+
+        /* perform policy action */
+        do_power_action_type (manager, action_type);
+}
+
+
+static void
+up_client_changed_cb (UpClient *client, GsdPowerManager *manager)
+{
+        gboolean tmp;
+
+        /* same state */
+        tmp = up_client_get_lid_is_closed (manager->priv->up_client);
+        if (manager->priv->lid_is_closed == tmp)
+                return;
+        manager->priv->lid_is_closed = tmp;
+
+        /* fake a keypress */
+        if (tmp)
+                do_lid_closed_action (manager);
+        else
+                do_lid_open_action (manager);
+}
+
+gboolean
+gsd_power_manager_start (GsdPowerManager *manager,
+                         GError **error)
+{
+        g_debug ("Starting power manager");
+        gnome_settings_profile_start (NULL);
+
+        gnome_settings_profile_end (NULL);
+        return TRUE;
+}
+
+void
+gsd_power_manager_stop (GsdPowerManager *manager)
+{
+        g_debug ("Stopping power manager");
+}
+
+static void
+gsd_power_manager_class_init (GsdPowerManagerClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->finalize = gsd_power_manager_finalize;
+
+        g_type_class_add_private (klass, sizeof (GsdPowerManagerPrivate));
+}
+
+static void
+gsd_power_manager_init (GsdPowerManager *manager)
+{
+        manager->priv = GSD_POWER_MANAGER_GET_PRIVATE (manager);
+
+        manager->priv->settings = g_settings_new (GSD_POWER_SETTINGS_SCHEMA);
+        manager->priv->up_client = up_client_new ();
+        manager->priv->lid_is_closed = up_client_get_lid_is_closed (manager->priv->up_client);
+        g_signal_connect (manager->priv->up_client, "changed",
+                          G_CALLBACK (up_client_changed_cb), manager);
+}
+
+static void
+gsd_power_manager_finalize (GObject *object)
+{
+        GsdPowerManager *manager;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSD_IS_POWER_MANAGER (object));
+
+        manager = GSD_POWER_MANAGER (object);
+
+        g_return_if_fail (manager->priv != NULL);
+
+        g_object_unref (manager->priv->settings);
+        g_object_unref (manager->priv->up_client);
+
+        G_OBJECT_CLASS (gsd_power_manager_parent_class)->finalize (object);
+}
+
+GsdPowerManager *
+gsd_power_manager_new (void)
+{
+        if (manager_object != NULL) {
+                g_object_ref (manager_object);
+        } else {
+                manager_object = g_object_new (GSD_TYPE_POWER_MANAGER, NULL);
+                g_object_add_weak_pointer (manager_object,
+                                           (gpointer *) &manager_object);
+        }
+        return GSD_POWER_MANAGER (manager_object);
+}
diff --git a/plugins/power/gsd-power-manager.h b/plugins/power/gsd-power-manager.h
new file mode 100644
index 0000000..aaf3647
--- /dev/null
+++ b/plugins/power/gsd-power-manager.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_POWER_MANAGER_H
+#define __GSD_POWER_MANAGER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_POWER_MANAGER         (gsd_power_manager_get_type ())
+#define GSD_POWER_MANAGER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_POWER_MANAGER, GsdPowerManager))
+#define GSD_POWER_MANAGER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_POWER_MANAGER, GsdPowerManagerClass))
+#define GSD_IS_POWER_MANAGER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_POWER_MANAGER))
+#define GSD_IS_POWER_MANAGER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_POWER_MANAGER))
+#define GSD_POWER_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_POWER_MANAGER, GsdPowerManagerClass))
+
+typedef struct GsdPowerManagerPrivate GsdPowerManagerPrivate;
+
+typedef struct
+{
+        GObject                     parent;
+        GsdPowerManagerPrivate *priv;
+} GsdPowerManager;
+
+typedef struct
+{
+        GObjectClass   parent_class;
+} GsdPowerManagerClass;
+
+GType                   gsd_power_manager_get_type            (void);
+
+GsdPowerManager *       gsd_power_manager_new                 (void);
+gboolean                gsd_power_manager_start               (GsdPowerManager *manager,
+                                                               GError         **error);
+void                    gsd_power_manager_stop                (GsdPowerManager *manager);
+
+G_END_DECLS
+
+#endif /* __GSD_POWER_MANAGER_H */
diff --git a/plugins/power/gsd-power-plugin.c b/plugins/power/gsd-power-plugin.c
new file mode 100644
index 0000000..e7976b6
--- /dev/null
+++ b/plugins/power/gsd-power-plugin.c
@@ -0,0 +1,110 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ *
+ * 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
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+
+#include "gnome-settings-plugin.h"
+#include "gsd-power-plugin.h"
+#include "gsd-power-manager.h"
+
+struct GsdPowerPluginPrivate {
+        GsdPowerManager *manager;
+};
+
+#define GSD_POWER_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_POWER_PLUGIN, GsdPowerPluginPrivate))
+
+GNOME_SETTINGS_PLUGIN_REGISTER (GsdPowerPlugin, gsd_power_plugin)
+
+static void
+gsd_power_plugin_init (GsdPowerPlugin *plugin)
+{
+        plugin->priv = GSD_POWER_PLUGIN_GET_PRIVATE (plugin);
+
+        g_debug ("GsdPowerPlugin initializing");
+
+        plugin->priv->manager = gsd_power_manager_new ();
+}
+
+static void
+gsd_power_plugin_finalize (GObject *object)
+{
+        GsdPowerPlugin *plugin;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSD_IS_POWER_PLUGIN (object));
+
+        g_debug ("GsdPowerPlugin finalizing");
+
+        plugin = GSD_POWER_PLUGIN (object);
+
+        g_return_if_fail (plugin->priv != NULL);
+
+        if (plugin->priv->manager != NULL) {
+                g_object_unref (plugin->priv->manager);
+        }
+
+        G_OBJECT_CLASS (gsd_power_plugin_parent_class)->finalize (object);
+}
+
+static void
+impl_activate (GnomeSettingsPlugin *plugin)
+{
+        gboolean res;
+        GError  *error;
+
+        g_debug ("Activating power plugin");
+
+        error = NULL;
+        res = gsd_power_manager_start (GSD_POWER_PLUGIN (plugin)->priv->manager, &error);
+        if (! res) {
+                g_warning ("Unable to start power manager: %s", error->message);
+                g_error_free (error);
+        }
+}
+
+static void
+impl_deactivate (GnomeSettingsPlugin *plugin)
+{
+        g_debug ("Deactivating power plugin");
+        gsd_power_manager_stop (GSD_POWER_PLUGIN (plugin)->priv->manager);
+}
+
+static void
+gsd_power_plugin_class_init (GsdPowerPluginClass *klass)
+{
+        GObjectClass           *object_class = G_OBJECT_CLASS (klass);
+        GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
+
+        object_class->finalize = gsd_power_plugin_finalize;
+
+        plugin_class->activate = impl_activate;
+        plugin_class->deactivate = impl_deactivate;
+
+        g_type_class_add_private (klass, sizeof (GsdPowerPluginPrivate));
+}
+
+static void
+gsd_power_plugin_class_finalize (GsdPowerPluginClass *klass)
+{
+}
+
diff --git a/plugins/power/gsd-power-plugin.h b/plugins/power/gsd-power-plugin.h
new file mode 100644
index 0000000..1fc3aef
--- /dev/null
+++ b/plugins/power/gsd-power-plugin.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ *
+ * 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
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_POWER_PLUGIN_H__
+#define __GSD_POWER_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+
+#include "gnome-settings-plugin.h"
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_POWER_PLUGIN                (gsd_power_plugin_get_type ())
+#define GSD_POWER_PLUGIN(o)                  (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_POWER_PLUGIN, GsdPowerPlugin))
+#define GSD_POWER_PLUGIN_CLASS(k)            (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_POWER_PLUGIN, GsdPowerPluginClass))
+#define GSD_IS_POWER_PLUGIN(o)               (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_POWER_PLUGIN))
+#define GSD_IS_POWER_PLUGIN_CLASS(k)         (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_POWER_PLUGIN))
+#define GSD_POWER_PLUGIN_GET_CLASS(o)        (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_POWER_PLUGIN, GsdPowerPluginClass))
+
+typedef struct GsdPowerPluginPrivate GsdPowerPluginPrivate;
+
+typedef struct
+{
+        GnomeSettingsPlugin    parent;
+        GsdPowerPluginPrivate *priv;
+} GsdPowerPlugin;
+
+typedef struct
+{
+        GnomeSettingsPluginClass parent_class;
+} GsdPowerPluginClass;
+
+GType   gsd_power_plugin_get_type            (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GSD_POWER_PLUGIN_H__ */
diff --git a/plugins/power/power.gnome-settings-plugin.in b/plugins/power/power.gnome-settings-plugin.in
new file mode 100644
index 0000000..8c39e7b
--- /dev/null
+++ b/plugins/power/power.gnome-settings-plugin.in
@@ -0,0 +1,8 @@
+[GNOME Settings Plugin]
+Module=power
+IAge=0
+_Name=Power
+_Description=Power plugin
+Authors=Richard Hughes
+Copyright=Copyright  2011 Richard Hughes
+Website=
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 01f4f72..53afdfa 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -29,6 +29,8 @@ plugins/automount/gsd-autorun.c
 [type: gettext/ini]plugins/color/color.gnome-settings-plugin.in
 plugins/color/gsd-color-manager.c
 [type: gettext/ini]plugins/dummy/dummy.gnome-settings-plugin.in
+[type: gettext/ini]plugins/power/power.gnome-settings-plugin.in
+plugins/power/gsd-power-manager.c
 plugins/housekeeping/gsd-disk-space.c
 plugins/housekeeping/gsd-ldsm-dialog.c
 plugins/keybindings/gsd-keybindings-manager.c



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