[gnome-power-manager: 1/3] Port the preferences dialog to libgnome-control-center
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-power-manager: 1/3] Port the preferences dialog to libgnome-control-center
- Date: Fri, 25 Jun 2010 12:04:11 +0000 (UTC)
commit 487fbd6d9aacc6a8e021e5d248fe39517c67ddc2
Author: Richard Hughes <richard hughsie com>
Date: Fri Jun 18 21:59:47 2010 +0100
Port the preferences dialog to libgnome-control-center
configure.ac | 6 +
data/gnome-power-preferences.desktop.in.in | 3 +-
data/gpm-prefs.ui | 19 -
man/Makefile.am | 9 +-
man/gnome-power-preferences.sgml | 136 --------
po/POTFILES.in | 3 +-
src/.gitignore | 3 +-
src/Makefile.am | 33 ++-
src/{gpm-prefs-core.c => cc-power-panel.c} | 498 ++++++++++++----------------
src/cc-power-panel.h | 54 +++
src/gpm-prefs-core.h | 57 ----
src/gpm-prefs.c | 118 -------
12 files changed, 298 insertions(+), 641 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8c30f3a..ebe99dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -146,6 +146,12 @@ if test x$has_libnotify = xyes; then
AC_DEFINE(HAVE_LIBNOTIFY,1,[Use session notifications])
fi
+dnl Required for the properties window
+PKG_CHECK_MODULES(CONTROL_CENTER, [
+ libgnome-control-center >= 2.31.3])
+PANELS_DIR="${libdir}/control-center-1/panels"
+AC_SUBST(PANELS_DIR)
+
dnl ---------------------------------------------------------------------------
dnl - Check XF86XK_Keys
dnl ---------------------------------------------------------------------------
diff --git a/data/gnome-power-preferences.desktop.in.in b/data/gnome-power-preferences.desktop.in.in
index f4c32d4..c3a5626 100644
--- a/data/gnome-power-preferences.desktop.in.in
+++ b/data/gnome-power-preferences.desktop.in.in
@@ -2,7 +2,7 @@
_Name=Power Management
_Comment=Configure power management
Icon=gnome-power-manager
-Exec=gnome-power-preferences
+Exec=gnome-control-center power
Terminal=false
Type=Application
Categories=Settings;HardwareSettings;
@@ -13,3 +13,4 @@ X-GNOME-Bugzilla-Product=gnome-power-manager
X-GNOME-Bugzilla-Component=gnome-power-preferences
X-GNOME-Bugzilla-Version= VERSION@
X-GNOME-Bugzilla-ExtraInfoScript=gnome-power-bugreport.sh
+X-GNOME-Settings-Panel=power
diff --git a/data/gpm-prefs.ui b/data/gpm-prefs.ui
index e3c3071..57dfbbe 100644
--- a/data/gpm-prefs.ui
+++ b/data/gpm-prefs.ui
@@ -1044,7 +1044,6 @@
</child>
</object>
<packing>
- <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -1083,23 +1082,6 @@
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="GtkButton" id="button_close">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="has_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes">Closes the program</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -1112,7 +1094,6 @@
<action-widgets>
<action-widget response="0">button_help</action-widget>
<action-widget response="0">button_defaults</action-widget>
- <action-widget response="0">button_close</action-widget>
</action-widgets>
</object>
</interface>
diff --git a/man/Makefile.am b/man/Makefile.am
index ad2f2a0..9c54a44 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -1,22 +1,17 @@
EXTRA_DIST = \
gnome-power-manager.sgml \
- gnome-power-statistics.sgml \
- gnome-power-preferences.sgml
+ gnome-power-statistics.sgml
if HAVE_DOCBOOK2MAN
man_MANS = \
gnome-power-manager.1 \
- gnome-power-statistics.1 \
- gnome-power-preferences.1
+ gnome-power-statistics.1
endif
if HAVE_DOCBOOK2MAN
gnome-power-manager.1: gnome-power-manager.sgml
docbook2man $? &> /dev/null
-gnome-power-preferences.1: gnome-power-preferences.sgml
- docbook2man $? &> /dev/null
-
gnome-power-statistics.1: gnome-power-statistics.sgml
docbook2man $? &> /dev/null
endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 90d6d45..6d99b88 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -13,6 +13,7 @@ data/gnome-power-statistics.desktop.in.in
[type: gettext/glade]data/gpm-statistics.ui
[type: gettext/glade]data/gpm-prefs.ui
policy/org.gnome.power.policy.in2
+src/cc-power-panel.c
src/gpm-backlight.c
src/gpm-backlight-helper.c
src/gpm-button.c
@@ -26,8 +27,6 @@ src/gpm-load.c
src/gpm-main.c
src/gpm-manager.c
src/gpm-networkmanager.c
-src/gpm-prefs.c
-src/gpm-prefs-core.c
src/gpm-screensaver.c
src/gpm-statistics.c
src/gpm-tray-icon.c
diff --git a/src/.gitignore b/src/.gitignore
index eff119e..24a8046 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,5 +1,7 @@
*.a
*.o
+*.la
+*.lo
.deps
gnome-power-manager
gnome-power-preferences
@@ -10,4 +12,3 @@ gpm-marshal.c
gpm-marshal.h
org.gnome.PowerManager.Backlight.h
org.gnome.PowerManager.h
-
diff --git a/src/Makefile.am b/src/Makefile.am
index 1d52bfa..9d64248 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,10 +17,11 @@ INCLUDES = \
$(LIBNOTIFY_CFLAGS) \
$(CANBERRA_CFLAGS) \
$(GSTREAMER_CFLAGS) \
+ $(CONTROL_CENTER_CFLAGS) \
-DI_KNOW_THE_DEVICEKIT_POWER_API_IS_SUBJECT_TO_CHANGE \
$(UPOWER_CFLAGS) \
-DBINDIR=\"$(bindir)\" \
- -DSBINDIR=\"$(sbindir)\" \
+ -DSBINDIR=\"$(sbindir)\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DDATADIR=\"$(datadir)\" \
-DPREFIX=\""$(prefix)"\" \
@@ -29,7 +30,7 @@ INCLUDES = \
-DVERSION="\"$(VERSION)\"" \
-DGPM_DATA=\"$(pkgdatadir)\" \
-DGTKBUILDERDIR=\"$(pkgdatadir)\" \
- -DUP_DISABLE_DEPRECATED \
+ -DUP_DISABLE_DEPRECATED \
-DEGG_LOG_FILE=\""/tmp/gpm.log"\" \
-DEGG_VERBOSE="\"GPM_VERBOSE\"" \
-DEGG_LOGGING="\"GPM_LOGGING\"" \
@@ -37,9 +38,11 @@ INCLUDES = \
-I$(top_srcdir) \
$(NULL)
+ccpanelsdir = $(PANELS_DIR)
+ccpanels_LTLIBRARIES = libpower.la
+
bin_PROGRAMS = \
gnome-power-manager \
- gnome-power-preferences \
gnome-power-statistics \
$(NULL)
@@ -116,15 +119,22 @@ gnome_power_statistics_CFLAGS = \
$(WARNINGFLAGS) \
$(NULL)
-gnome_power_preferences_SOURCES = \
- gpm-prefs.c \
- gpm-prefs-core.h \
- gpm-prefs-core.c \
+libpower_la_SOURCES = \
+ egg-console-kit.h \
+ egg-console-kit.c \
+ egg-debug.h \
+ egg-debug.c \
+ gpm-brightness.h \
+ gpm-brightness.c \
+ gpm-common.h \
+ gpm-common.c \
+ cc-power-panel.c \
+ cc-power-panel.h \
$(NULL)
-gnome_power_preferences_LDADD = \
- libgpmshared.a \
+libpower_la_LIBADD = \
$(GLIB_LIBS) \
+ $(CONTROL_CENTER_LIBS) \
$(X11_LIBS) \
$(GNOME_LIBS) \
$(DBUS_LIBS) \
@@ -132,9 +142,8 @@ gnome_power_preferences_LDADD = \
$(UPOWER_LIBS) \
-lm
-gnome_power_preferences_CFLAGS = \
- $(WARNINGFLAGS) \
- $(NULL)
+libpower_la_LDFLAGS = -avoid-version -module
+libpower_la_CFLAGS = $(WARNINGFLAGS)
gnome_power_manager_SOURCES = \
gpm-dpms.h \
diff --git a/src/gpm-prefs-core.c b/src/cc-power-panel.c
similarity index 56%
rename from src/gpm-prefs-core.c
rename to src/cc-power-panel.c
index 2404f17..6e832d8 100644
--- a/src/gpm-prefs-core.c
+++ b/src/cc-power-panel.c
@@ -1,8 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2005 Jaap Haitsma <jaap haitsma org>
- * Copyright (C) 2005 William Jon McCann <mccann jhu edu>
- * Copyright (C) 2005-2009 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -21,32 +19,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "config.h"
-
-#include <glib.h>
-#include <glib/gi18n.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include <dbus/dbus-glib.h>
-#include <math.h>
-#include <string.h>
#include <libupower-glib/upower.h>
#include "egg-debug.h"
#include "egg-console-kit.h"
-#include "gpm-tray-icon.h"
#include "gpm-common.h"
-#include "gpm-prefs-core.h"
-#include "gpm-stock-icons.h"
#include "gpm-brightness.h"
-static void gpm_prefs_finalize (GObject *object);
-
-#define GPM_PREFS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_PREFS, GpmPrefsPrivate))
+#include "cc-power-panel.h"
-struct GpmPrefsPrivate
-{
+struct _CcPowerPanelPrivate {
UpClient *client;
GtkBuilder *builder;
gboolean has_batteries;
@@ -61,105 +50,50 @@ struct GpmPrefsPrivate
EggConsoleKit *console;
};
-enum {
- ACTION_HELP,
- ACTION_CLOSE,
- LAST_SIGNAL
-};
+G_DEFINE_DYNAMIC_TYPE (CcPowerPanel, cc_power_panel, CC_TYPE_PANEL)
-static guint signals [LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (GpmPrefs, gpm_prefs, G_TYPE_OBJECT)
-
-/**
- * gpm_prefs_class_init:
- * @klass: This prefs class instance
- **/
-static void
-gpm_prefs_class_init (GpmPrefsClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gpm_prefs_finalize;
- g_type_class_add_private (klass, sizeof (GpmPrefsPrivate));
-
- signals [ACTION_HELP] =
- g_signal_new ("action-help",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GpmPrefsClass, action_help),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- signals [ACTION_CLOSE] =
- g_signal_new ("action-close",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GpmPrefsClass, action_close),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
+static void cc_power_panel_finalize (GObject *object);
-/**
- * gpm_prefs_activate_window:
- * @prefs: This prefs class instance
- *
- * Activates (shows) the window.
- **/
-void
-gpm_prefs_activate_window (GpmPrefs *prefs)
-{
- GtkWindow *window;
- window = GTK_WINDOW (gtk_builder_get_object (prefs->priv->builder, "dialog_preferences"));
- gtk_window_present (window);
-}
+#define CC_POWER_PREFS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_POWER_PANEL, CcPowerPanelPrivate))
/**
- * gpm_prefs_help_cb:
- * @widget: The GtkWidget object
- * @prefs: This prefs class instance
+ * cc_power_panel_help_cb:
**/
static void
-gpm_prefs_help_cb (GtkWidget *widget, GpmPrefs *prefs)
+cc_power_panel_help_cb (GtkWidget *widget, CcPowerPanel *panel)
{
- egg_debug ("emitting action-help");
- g_signal_emit (prefs, signals [ACTION_HELP], 0);
+ gpm_help_display ("preferences");
}
/**
- * gpm_prefs_icon_radio_cb:
- * @widget: The GtkWidget object
+ * cc_power_panel_icon_radio_cb:
**/
static void
-gpm_prefs_icon_radio_cb (GtkWidget *widget, GpmPrefs *prefs)
+cc_power_panel_icon_radio_cb (GtkWidget *widget, CcPowerPanel *panel)
{
const gchar *str;
gint policy;
policy = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "policy"));
str = gpm_icon_policy_to_string (policy);
- egg_debug ("Changing %s to %s", GPM_SETTINGS_ICON_POLICY, str);
- g_settings_set_string (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY, str);
+ g_debug ("Changing %s to %s", GPM_SETTINGS_ICON_POLICY, str);
+ g_settings_set_string (panel->priv->settings, GPM_SETTINGS_ICON_POLICY, str);
}
/**
- * gpm_prefs_format_percentage_cb:
- * @scale: The GtkScale object
- * @value: The value in %.
+ * cc_power_panel_format_percentage_cb:
**/
static gchar *
-gpm_prefs_format_percentage_cb (GtkScale *scale, gdouble value)
+cc_power_panel_format_percentage_cb (GtkScale *scale, gdouble value)
{
return g_strdup_printf ("%.0f%%", value * 100.0f);
}
/**
- * gpm_prefs_action_combo_changed_cb:
+ * cc_power_panel_action_combo_changed_cb:
**/
static void
-gpm_prefs_action_combo_changed_cb (GtkWidget *widget, GpmPrefs *prefs)
+cc_power_panel_action_combo_changed_cb (GtkWidget *widget, CcPowerPanel *panel)
{
GpmActionPolicy policy;
const GpmActionPolicy *actions;
@@ -173,15 +107,15 @@ gpm_prefs_action_combo_changed_cb (GtkWidget *widget, GpmPrefs *prefs)
active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
policy = actions[active];
action = gpm_action_policy_to_string (policy);
- egg_debug ("Changing %s to %s", gpm_pref_key, action);
- g_settings_set_string (prefs->priv->settings, gpm_pref_key, action);
+ g_debug ("Changing %s to %s", gpm_pref_key, action);
+ g_settings_set_string (panel->priv->settings, gpm_pref_key, action);
}
/**
- * gpm_prefs_action_time_changed_cb:
+ * cc_power_panel_action_time_changed_cb:
**/
static void
-gpm_prefs_action_time_changed_cb (GtkWidget *widget, GpmPrefs *prefs)
+cc_power_panel_action_time_changed_cb (GtkWidget *widget, CcPowerPanel *panel)
{
guint value;
const gint *values;
@@ -194,15 +128,15 @@ gpm_prefs_action_time_changed_cb (GtkWidget *widget, GpmPrefs *prefs)
active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
value = values[active];
- egg_debug ("Changing %s to %i", gpm_pref_key, value);
- g_settings_set_int (prefs->priv->settings, gpm_pref_key, value);
+ g_debug ("Changing %s to %i", gpm_pref_key, value);
+ g_settings_set_int (panel->priv->settings, gpm_pref_key, value);
}
/**
- * gpm_prefs_set_combo_simple_text:
+ * cc_power_panel_set_combo_simple_text:
**/
static void
-gpm_prefs_set_combo_simple_text (GtkWidget *combo_box)
+cc_power_panel_set_combo_simple_text (GtkWidget *combo_box)
{
GtkCellRenderer *cell;
GtkListStore *store;
@@ -219,23 +153,19 @@ gpm_prefs_set_combo_simple_text (GtkWidget *combo_box)
}
/**
- * gpm_prefs_actions_destroy_cb:
+ * cc_power_panel_actions_destroy_cb:
**/
static void
-gpm_prefs_actions_destroy_cb (GpmActionPolicy *array)
+cc_power_panel_actions_destroy_cb (GpmActionPolicy *array)
{
g_free (array);
}
/**
- * gpm_prefs_setup_action_combo:
- * @prefs: This prefs class instance
- * @widget_name: The GtkWidget name
- * @gpm_pref_key: The GConf key for this preference setting.
- * @actions: The actions to associate in an array.
+ * cc_power_panel_setup_action_combo:
**/
static void
-gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name,
+cc_power_panel_setup_action_combo (CcPowerPanel *panel, const gchar *widget_name,
const gchar *gpm_pref_key, const GpmActionPolicy *actions)
{
gchar *value_txt;
@@ -247,11 +177,11 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name,
GPtrArray *array;
GpmActionPolicy *actions_added;
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, widget_name));
- gpm_prefs_set_combo_simple_text (widget);
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, widget_name));
+ cc_power_panel_set_combo_simple_text (widget);
- value_txt = g_settings_get_string (prefs->priv->settings, gpm_pref_key);
- is_writable = g_settings_is_writable (prefs->priv->settings, gpm_pref_key);
+ value_txt = g_settings_get_string (panel->priv->settings, gpm_pref_key);
+ is_writable = g_settings_is_writable (panel->priv->settings, gpm_pref_key);
value = gpm_action_policy_from_string (value_txt);
gtk_widget_set_sensitive (widget, is_writable);
@@ -259,23 +189,23 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name,
array = g_ptr_array_new ();
g_object_set_data (G_OBJECT (widget), "settings_key", (gpointer) gpm_pref_key);
g_signal_connect (G_OBJECT (widget), "changed",
- G_CALLBACK (gpm_prefs_action_combo_changed_cb), prefs);
+ G_CALLBACK (cc_power_panel_action_combo_changed_cb), panel);
for (i=0; actions[i] != -1; i++) {
policy = actions[i];
- if (policy == GPM_ACTION_POLICY_SHUTDOWN && !prefs->priv->can_shutdown) {
- egg_debug ("Cannot add option, as cannot shutdown.");
- } else if (policy == GPM_ACTION_POLICY_SHUTDOWN && prefs->priv->can_shutdown) {
+ if (policy == GPM_ACTION_POLICY_SHUTDOWN && !panel->priv->can_shutdown) {
+ g_debug ("Cannot add option, as cannot shutdown.");
+ } else if (policy == GPM_ACTION_POLICY_SHUTDOWN && panel->priv->can_shutdown) {
gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Shutdown"));
g_ptr_array_add (array, GINT_TO_POINTER (policy));
- } else if (policy == GPM_ACTION_POLICY_SUSPEND && !prefs->priv->can_suspend) {
- egg_debug ("Cannot add option, as cannot suspend.");
- } else if (policy == GPM_ACTION_POLICY_HIBERNATE && !prefs->priv->can_hibernate) {
- egg_debug ("Cannot add option, as cannot hibernate.");
- } else if (policy == GPM_ACTION_POLICY_SUSPEND && prefs->priv->can_suspend) {
+ } else if (policy == GPM_ACTION_POLICY_SUSPEND && !panel->priv->can_suspend) {
+ g_debug ("Cannot add option, as cannot suspend.");
+ } else if (policy == GPM_ACTION_POLICY_HIBERNATE && !panel->priv->can_hibernate) {
+ g_debug ("Cannot add option, as cannot hibernate.");
+ } else if (policy == GPM_ACTION_POLICY_SUSPEND && panel->priv->can_suspend) {
gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Suspend"));
g_ptr_array_add (array, GINT_TO_POINTER (policy));
- } else if (policy == GPM_ACTION_POLICY_HIBERNATE && prefs->priv->can_hibernate) {
+ } else if (policy == GPM_ACTION_POLICY_HIBERNATE && panel->priv->can_hibernate) {
gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Hibernate"));
g_ptr_array_add (array, GINT_TO_POINTER (policy));
} else if (policy == GPM_ACTION_POLICY_BLANK) {
@@ -291,7 +221,7 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name,
g_ptr_array_add (array, GINT_TO_POINTER (policy));
}
} else {
- egg_warning ("Unknown action read from settings: %i", policy);
+ g_warning ("Unknown action read from settings: %i", policy);
}
}
@@ -301,12 +231,12 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name,
actions_added[i] = GPOINTER_TO_INT (g_ptr_array_index (array, i));
actions_added[i] = -1;
- g_object_set_data_full (G_OBJECT (widget), "actions", (gpointer) actions_added, (GDestroyNotify) gpm_prefs_actions_destroy_cb);
+ g_object_set_data_full (G_OBJECT (widget), "actions", (gpointer) actions_added, (GDestroyNotify) cc_power_panel_actions_destroy_cb);
/* set what we have in GConf */
for (i=0; actions_added[i] != -1; i++) {
policy = actions_added[i];
- egg_debug ("added: %s", gpm_action_policy_to_string (policy));
+ g_debug ("added: %s", gpm_action_policy_to_string (policy));
if (value == policy)
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), i);
}
@@ -316,14 +246,10 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name,
}
/**
- * gpm_prefs_setup_time_combo:
- * @prefs: This prefs class instance
- * @widget_name: The GtkWidget name
- * @gpm_pref_key: The GConf key for this preference setting.
- * @actions: The actions to associate in an array.
+ * cc_power_panel_setup_time_combo:
**/
static void
-gpm_prefs_setup_time_combo (GpmPrefs *prefs, const gchar *widget_name,
+cc_power_panel_setup_time_combo (CcPowerPanel *panel, const gchar *widget_name,
const gchar *gpm_pref_key, const gint *values)
{
guint value;
@@ -332,11 +258,11 @@ gpm_prefs_setup_time_combo (GpmPrefs *prefs, const gchar *widget_name,
gboolean is_writable;
GtkWidget *widget;
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, widget_name));
- gpm_prefs_set_combo_simple_text (widget);
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, widget_name));
+ cc_power_panel_set_combo_simple_text (widget);
- value = g_settings_get_int (prefs->priv->settings, gpm_pref_key);
- is_writable = g_settings_is_writable (prefs->priv->settings, gpm_pref_key);
+ value = g_settings_get_int (panel->priv->settings, gpm_pref_key);
+ is_writable = g_settings_is_writable (panel->priv->settings, gpm_pref_key);
gtk_widget_set_sensitive (widget, is_writable);
g_object_set_data (G_OBJECT (widget), "settings_key", (gpointer) gpm_pref_key);
@@ -361,34 +287,12 @@ gpm_prefs_setup_time_combo (GpmPrefs *prefs, const gchar *widget_name,
/* connect after set */
g_signal_connect (G_OBJECT (widget), "changed",
- G_CALLBACK (gpm_prefs_action_time_changed_cb), prefs);
-}
-
-/**
- * gpm_prefs_close_cb:
- * @widget: The GtkWidget object
- * @prefs: This prefs class instance
- **/
-static void
-gpm_prefs_close_cb (GtkWidget *widget, GpmPrefs *prefs)
-{
- egg_debug ("emitting action-close");
- g_signal_emit (prefs, signals [ACTION_CLOSE], 0);
-}
-
-/**
- * gpm_prefs_delete_event_cb:
- **/
-static gboolean
-gpm_prefs_delete_event_cb (GtkWidget *widget, GdkEvent *event, GpmPrefs *prefs)
-{
- gpm_prefs_close_cb (widget, prefs);
- return FALSE;
+ G_CALLBACK (cc_power_panel_action_time_changed_cb), panel);
}
/** setup the notification page */
static void
-prefs_setup_notification (GpmPrefs *prefs)
+cc_power_panel_setup_notification (CcPowerPanel *panel)
{
gchar *icon_policy_str;
gint icon_policy;
@@ -398,20 +302,20 @@ prefs_setup_notification (GpmPrefs *prefs)
GtkWidget *radiobutton_icon_never;
gboolean is_writable;
- icon_policy_str = g_settings_get_string (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY);
+ icon_policy_str = g_settings_get_string (panel->priv->settings, GPM_SETTINGS_ICON_POLICY);
icon_policy = gpm_icon_policy_from_string (icon_policy_str);
g_free (icon_policy_str);
- radiobutton_icon_present = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
+ radiobutton_icon_present = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
"radiobutton_notification_present"));
- radiobutton_icon_charge = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
+ radiobutton_icon_charge = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
"radiobutton_notification_charge"));
- radiobutton_icon_low = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
+ radiobutton_icon_low = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
"radiobutton_notification_low"));
- radiobutton_icon_never = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
+ radiobutton_icon_never = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
"radiobutton_notification_never"));
- is_writable = g_settings_is_writable (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY);
+ is_writable = g_settings_is_writable (panel->priv->settings, GPM_SETTINGS_ICON_POLICY);
gtk_widget_set_sensitive (radiobutton_icon_present, is_writable);
gtk_widget_set_sensitive (radiobutton_icon_charge, is_writable);
gtk_widget_set_sensitive (radiobutton_icon_low, is_writable);
@@ -438,17 +342,20 @@ prefs_setup_notification (GpmPrefs *prefs)
/* only connect the callbacks after we set the value, else the settings
* keys gets written to (for a split second), and the icon flickers. */
g_signal_connect (radiobutton_icon_present, "clicked",
- G_CALLBACK (gpm_prefs_icon_radio_cb), prefs);
+ G_CALLBACK (cc_power_panel_icon_radio_cb), panel);
g_signal_connect (radiobutton_icon_charge, "clicked",
- G_CALLBACK (gpm_prefs_icon_radio_cb), prefs);
+ G_CALLBACK (cc_power_panel_icon_radio_cb), panel);
g_signal_connect (radiobutton_icon_low, "clicked",
- G_CALLBACK (gpm_prefs_icon_radio_cb), prefs);
+ G_CALLBACK (cc_power_panel_icon_radio_cb), panel);
g_signal_connect (radiobutton_icon_never, "clicked",
- G_CALLBACK (gpm_prefs_icon_radio_cb), prefs);
+ G_CALLBACK (cc_power_panel_icon_radio_cb), panel);
}
+/**
+ * cc_power_panel_setup_ac:
+ **/
static void
-prefs_setup_ac (GpmPrefs *prefs)
+cc_power_panel_setup_ac (CcPowerPanel *panel)
{
GtkWidget *widget;
const GpmActionPolicy button_lid_actions[] =
@@ -475,49 +382,52 @@ prefs_setup_ac (GpmPrefs *prefs)
0, /* never */
-1};
- gpm_prefs_setup_time_combo (prefs, "combobox_ac_computer",
+ cc_power_panel_setup_time_combo (panel, "combobox_ac_computer",
GPM_SETTINGS_SLEEP_COMPUTER_AC,
computer_times);
- gpm_prefs_setup_time_combo (prefs, "combobox_ac_display",
+ cc_power_panel_setup_time_combo (panel, "combobox_ac_display",
GPM_SETTINGS_SLEEP_DISPLAY_AC,
display_times);
- gpm_prefs_setup_action_combo (prefs, "combobox_ac_lid",
+ cc_power_panel_setup_action_combo (panel, "combobox_ac_lid",
GPM_SETTINGS_BUTTON_LID_AC,
button_lid_actions);
/* setup brightness slider */
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "hscale_ac_brightness"));
- g_settings_bind (prefs->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC,
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "hscale_ac_brightness"));
+ g_settings_bind (panel->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC,
widget, "fill-level",
G_SETTINGS_BIND_DEFAULT);
g_signal_connect (G_OBJECT (widget), "format-value",
- G_CALLBACK (gpm_prefs_format_percentage_cb), NULL);
+ G_CALLBACK (cc_power_panel_format_percentage_cb), NULL);
/* set up the checkboxes */
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_ac_display_dim"));
- g_settings_bind (prefs->priv->settings, GPM_SETTINGS_IDLE_DIM_AC,
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "checkbutton_ac_display_dim"));
+ g_settings_bind (panel->priv->settings, GPM_SETTINGS_IDLE_DIM_AC,
widget, "active",
G_SETTINGS_BIND_DEFAULT);
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_ac_spindown"));
- g_settings_bind (prefs->priv->settings, GPM_SETTINGS_SPINDOWN_ENABLE_AC,
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "checkbutton_ac_spindown"));
+ g_settings_bind (panel->priv->settings, GPM_SETTINGS_SPINDOWN_ENABLE_AC,
widget, "active",
G_SETTINGS_BIND_DEFAULT);
- if (prefs->priv->has_button_lid == FALSE) {
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "hbox_ac_lid"));
+ if (panel->priv->has_button_lid == FALSE) {
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "hbox_ac_lid"));
gtk_widget_hide_all (widget);
}
- if (prefs->priv->has_lcd == FALSE) {
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "hbox_ac_brightness"));
+ if (panel->priv->has_lcd == FALSE) {
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "hbox_ac_brightness"));
gtk_widget_hide_all (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_ac_display_dim"));
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "checkbutton_ac_display_dim"));
gtk_widget_hide_all (widget);
}
}
+/**
+ * cc_power_panel_setup_battery:
+ **/
static void
-prefs_setup_battery (GpmPrefs *prefs)
+cc_power_panel_setup_battery (CcPowerPanel *panel)
{
GtkWidget *widget;
GtkNotebook *notebook;
@@ -553,54 +463,57 @@ prefs_setup_battery (GpmPrefs *prefs)
0, /* never */
-1};
- gpm_prefs_setup_time_combo (prefs, "combobox_battery_computer",
+ cc_power_panel_setup_time_combo (panel, "combobox_battery_computer",
GPM_SETTINGS_SLEEP_COMPUTER_BATT,
computer_times);
- gpm_prefs_setup_time_combo (prefs, "combobox_battery_display",
+ cc_power_panel_setup_time_combo (panel, "combobox_battery_display",
GPM_SETTINGS_SLEEP_DISPLAY_BATT,
display_times);
- if (prefs->priv->has_batteries == FALSE) {
- notebook = GTK_NOTEBOOK (gtk_builder_get_object (prefs->priv->builder, "notebook_preferences"));
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "vbox_battery"));
+ if (panel->priv->has_batteries == FALSE) {
+ notebook = GTK_NOTEBOOK (gtk_builder_get_object (panel->priv->builder, "notebook_preferences"));
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "vbox_battery"));
page = gtk_notebook_page_num (notebook, GTK_WIDGET (widget));
gtk_notebook_remove_page (notebook, page);
return;
}
- gpm_prefs_setup_action_combo (prefs, "combobox_battery_lid",
+ cc_power_panel_setup_action_combo (panel, "combobox_battery_lid",
GPM_SETTINGS_BUTTON_LID_BATT,
button_lid_actions);
- gpm_prefs_setup_action_combo (prefs, "combobox_battery_critical",
+ cc_power_panel_setup_action_combo (panel, "combobox_battery_critical",
GPM_SETTINGS_ACTION_CRITICAL_BATT,
battery_critical_actions);
/* set up the checkboxes */
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_battery_display_reduce"));
- g_settings_bind (prefs->priv->settings, GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE,
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "checkbutton_battery_display_reduce"));
+ g_settings_bind (panel->priv->settings, GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE,
widget, "active",
G_SETTINGS_BIND_DEFAULT);
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_battery_display_dim"));
- g_settings_bind (prefs->priv->settings, GPM_SETTINGS_IDLE_DIM_BATT,
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "checkbutton_battery_display_dim"));
+ g_settings_bind (panel->priv->settings, GPM_SETTINGS_IDLE_DIM_BATT,
widget, "active",
G_SETTINGS_BIND_DEFAULT);
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_battery_spindown"));
- g_settings_bind (prefs->priv->settings, GPM_SETTINGS_SPINDOWN_ENABLE_BATT,
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "checkbutton_battery_spindown"));
+ g_settings_bind (panel->priv->settings, GPM_SETTINGS_SPINDOWN_ENABLE_BATT,
widget, "active",
G_SETTINGS_BIND_DEFAULT);
- if (prefs->priv->has_button_lid == FALSE) {
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "hbox_battery_lid"));
+ if (panel->priv->has_button_lid == FALSE) {
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "hbox_battery_lid"));
gtk_widget_hide_all (widget);
}
- if (prefs->priv->has_lcd == FALSE) {
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "checkbutton_battery_display_dim"));
+ if (panel->priv->has_lcd == FALSE) {
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "checkbutton_battery_display_dim"));
gtk_widget_hide_all (widget);
}
}
+/**
+ * cc_power_panel_setup_ups:
+ **/
static void
-prefs_setup_ups (GpmPrefs *prefs)
+cc_power_panel_setup_ups (CcPowerPanel *panel)
{
GtkWidget *widget;
GtkNotebook *notebook;
@@ -628,31 +541,34 @@ prefs_setup_ups (GpmPrefs *prefs)
0, /* never */
-1};
- gpm_prefs_setup_time_combo (prefs, "combobox_ups_computer",
+ cc_power_panel_setup_time_combo (panel, "combobox_ups_computer",
GPM_SETTINGS_SLEEP_COMPUTER_UPS,
computer_times);
- gpm_prefs_setup_time_combo (prefs, "combobox_ups_display",
+ cc_power_panel_setup_time_combo (panel, "combobox_ups_display",
GPM_SETTINGS_SLEEP_DISPLAY_UPS,
display_times);
- if (prefs->priv->has_ups == FALSE) {
- notebook = GTK_NOTEBOOK (gtk_builder_get_object (prefs->priv->builder, "notebook_preferences"));
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "vbox_ups"));
+ if (panel->priv->has_ups == FALSE) {
+ notebook = GTK_NOTEBOOK (gtk_builder_get_object (panel->priv->builder, "notebook_preferences"));
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "vbox_ups"));
page = gtk_notebook_page_num (notebook, GTK_WIDGET (widget));
gtk_notebook_remove_page (notebook, page);
return;
}
- gpm_prefs_setup_action_combo (prefs, "combobox_ups_low",
+ cc_power_panel_setup_action_combo (panel, "combobox_ups_low",
GPM_SETTINGS_ACTION_LOW_UPS,
ups_low_actions);
- gpm_prefs_setup_action_combo (prefs, "combobox_ups_critical",
+ cc_power_panel_setup_action_combo (panel, "combobox_ups_critical",
GPM_SETTINGS_ACTION_CRITICAL_UPS,
ups_low_actions);
}
+/**
+ * cc_power_panel_setup_general:
+ **/
static void
-prefs_setup_general (GpmPrefs *prefs)
+cc_power_panel_setup_general (CcPowerPanel *panel)
{
GtkWidget *widget;
const GpmActionPolicy power_button_actions[] =
@@ -667,25 +583,25 @@ prefs_setup_general (GpmPrefs *prefs)
GPM_ACTION_POLICY_HIBERNATE,
-1};
- gpm_prefs_setup_action_combo (prefs, "combobox_general_power",
+ cc_power_panel_setup_action_combo (panel, "combobox_general_power",
GPM_SETTINGS_BUTTON_POWER,
power_button_actions);
- gpm_prefs_setup_action_combo (prefs, "combobox_general_suspend",
+ cc_power_panel_setup_action_combo (panel, "combobox_general_suspend",
GPM_SETTINGS_BUTTON_SUSPEND,
suspend_button_actions);
- if (prefs->priv->has_button_suspend == FALSE) {
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "hbox_general_suspend"));
+ if (panel->priv->has_button_suspend == FALSE) {
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "hbox_general_suspend"));
gtk_widget_hide_all (widget);
}
}
#ifdef HAVE_GCONF_DEFAULTS
/**
- * gpm_prefs_set_defaults_cb:
+ * cc_power_panel_set_defaults_cb:
**/
static void
-gpm_prefs_set_defaults_cb (GtkWidget *widget, GpmPrefs *prefs)
+cc_power_panel_set_defaults_cb (GtkWidget *widget, CcPowerPanel *panel)
{
DBusGProxy *proxy;
DBusGConnection *connection;
@@ -723,12 +639,33 @@ gpm_prefs_set_defaults_cb (GtkWidget *widget, GpmPrefs *prefs)
}
#endif
-/**
- * gpm_prefs_init:
- * @prefs: This prefs class instance
- **/
static void
-gpm_prefs_init (GpmPrefs *prefs)
+cc_power_panel_class_init (CcPowerPanelClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ g_type_class_add_private (klass, sizeof (CcPowerPanelPrivate));
+ object_class->finalize = cc_power_panel_finalize;
+}
+
+static void
+cc_power_panel_class_finalize (CcPowerPanelClass *klass)
+{
+}
+
+static void
+cc_power_panel_finalize (GObject *object)
+{
+ CcPowerPanel *panel = CC_POWER_PANEL (object);
+
+ g_object_unref (panel->priv->settings);
+ g_object_unref (panel->priv->client);
+ g_object_unref (panel->priv->console);
+
+ G_OBJECT_CLASS (cc_power_panel_parent_class)->finalize (object);
+}
+
+static void
+cc_power_panel_init (CcPowerPanel *panel)
{
GtkWidget *main_window;
GtkWidget *widget;
@@ -741,41 +678,41 @@ gpm_prefs_init (GpmPrefs *prefs)
gboolean ret;
guint i;
- prefs->priv = GPM_PREFS_GET_PRIVATE (prefs);
+ panel->priv = CC_POWER_PREFS_GET_PRIVATE (panel);
- prefs->priv->client = up_client_new ();
- prefs->priv->console = egg_console_kit_new ();
- prefs->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
+ panel->priv->client = up_client_new ();
+ panel->priv->console = egg_console_kit_new ();
+ panel->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
/* are we allowed to shutdown? */
- prefs->priv->can_shutdown = TRUE;
- egg_console_kit_can_stop (prefs->priv->console, &prefs->priv->can_shutdown, NULL);
+ panel->priv->can_shutdown = TRUE;
+ egg_console_kit_can_stop (panel->priv->console, &panel->priv->can_shutdown, NULL);
/* get values from UpClient */
- prefs->priv->can_suspend = up_client_get_can_suspend (prefs->priv->client);
- prefs->priv->can_hibernate = up_client_get_can_hibernate (prefs->priv->client);
+ panel->priv->can_suspend = up_client_get_can_suspend (panel->priv->client);
+ panel->priv->can_hibernate = up_client_get_can_hibernate (panel->priv->client);
#if UP_CHECK_VERSION(0,9,2)
- prefs->priv->has_button_lid = up_client_get_lid_is_present (prefs->priv->client);
+ panel->priv->has_button_lid = up_client_get_lid_is_present (panel->priv->client);
#else
- g_object_get (prefs->priv->client,
- "lid-is-present", &prefs->priv->has_button_lid,
+ g_object_get (panel->priv->client,
+ "lid-is-present", &panel->priv->has_button_lid,
NULL);
#endif
- prefs->priv->has_button_suspend = TRUE;
+ panel->priv->has_button_suspend = TRUE;
/* find if we have brightness hardware */
brightness = gpm_brightness_new ();
- prefs->priv->has_lcd = gpm_brightness_has_hw (brightness);
+ panel->priv->has_lcd = gpm_brightness_has_hw (brightness);
g_object_unref (brightness);
/* get device list */
- ret = up_client_enumerate_devices_sync (prefs->priv->client, NULL, &error);
+ ret = up_client_enumerate_devices_sync (panel->priv->client, NULL, &error);
if (!ret) {
- egg_warning ("failed to get device list: %s", error->message);
+ g_warning ("failed to get device list: %s", error->message);
g_error_free (error);
}
- devices = up_client_get_devices (prefs->priv->client);
+ devices = up_client_get_devices (panel->priv->client);
for (i=0; i<devices->len; i++) {
device = g_ptr_array_index (devices, i);
//kind = up_device_get_kind (device);
@@ -783,83 +720,68 @@ gpm_prefs_init (GpmPrefs *prefs)
"kind", &kind,
NULL);
if (kind == UP_DEVICE_KIND_BATTERY)
- prefs->priv->has_batteries = TRUE;
+ panel->priv->has_batteries = TRUE;
if (kind == UP_DEVICE_KIND_UPS)
- prefs->priv->has_ups = TRUE;
+ panel->priv->has_ups = TRUE;
}
g_ptr_array_unref (devices);
- prefs->priv->builder = gtk_builder_new ();
- retval = gtk_builder_add_from_file (prefs->priv->builder, GPM_DATA "/gpm-prefs.ui", &error);
+ panel->priv->builder = gtk_builder_new ();
+ retval = gtk_builder_add_from_file (panel->priv->builder, GPM_DATA "/gpm-prefs.ui", &error);
if (retval == 0) {
- egg_warning ("failed to load ui: %s", error->message);
+ g_warning ("failed to load ui: %s", error->message);
g_error_free (error);
+ goto out;
}
- main_window = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "dialog_preferences"));
-
- /* Hide window first so that the dialogue resizes itself without redrawing */
- gtk_widget_hide (main_window);
- gtk_window_set_default_icon_name (GPM_STOCK_APP_ICON);
-
- /* Get the main window quit */
- g_signal_connect (main_window, "delete-event",
- G_CALLBACK (gpm_prefs_delete_event_cb), prefs);
-
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "button_close"));
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "button_help"));
g_signal_connect (widget, "clicked",
- G_CALLBACK (gpm_prefs_close_cb), prefs);
+ G_CALLBACK (cc_power_panel_help_cb), panel);
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "button_help"));
- g_signal_connect (widget, "clicked",
- G_CALLBACK (gpm_prefs_help_cb), prefs);
-
- widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, "button_defaults"));
+ widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "button_defaults"));
#ifdef HAVE_GCONF_DEFAULTS
g_signal_connect (widget, "clicked",
- G_CALLBACK (gpm_prefs_set_defaults_cb), prefs);
+ G_CALLBACK (cc_power_panel_set_defaults_cb), panel);
#else
gtk_widget_hide (widget);
#endif
- prefs_setup_ac (prefs);
- prefs_setup_battery (prefs);
- prefs_setup_ups (prefs);
- prefs_setup_general (prefs);
- prefs_setup_notification (prefs);
+ cc_power_panel_setup_ac (panel);
+ cc_power_panel_setup_battery (panel);
+ cc_power_panel_setup_ups (panel);
+ cc_power_panel_setup_general (panel);
+ cc_power_panel_setup_notification (panel);
+
+out:
+ main_window = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "dialog_preferences"));
+// gtk_widget_show (main_window);
+ widget = gtk_dialog_get_content_area (GTK_DIALOG (main_window));
+ gtk_widget_unparent (widget);
- gtk_widget_show (main_window);
+ gtk_container_add (GTK_CONTAINER (panel), widget);
}
-/**
- * gpm_prefs_finalize:
- * @object: This prefs class instance
- **/
-static void
-gpm_prefs_finalize (GObject *object)
+void
+cc_power_panel_register (GIOModule *module)
{
- GpmPrefs *prefs;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GPM_IS_PREFS (object));
-
- prefs = GPM_PREFS (object);
- prefs->priv = GPM_PREFS_GET_PRIVATE (prefs);
+ cc_power_panel_register_type (G_TYPE_MODULE (module));
+ g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
+ CC_TYPE_POWER_PANEL,
+ "power", 0);
+}
- g_object_unref (prefs->priv->settings);
- g_object_unref (prefs->priv->client);
- g_object_unref (prefs->priv->console);
+/* GIO extension stuff */
+void
+g_io_module_load (GIOModule *module)
+{
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- G_OBJECT_CLASS (gpm_prefs_parent_class)->finalize (object);
+ /* register the panel */
+ cc_power_panel_register (module);
}
-/**
- * gpm_prefs_new:
- * Return value: new GpmPrefs instance.
- **/
-GpmPrefs *
-gpm_prefs_new (void)
+void
+g_io_module_unload (GIOModule *module)
{
- GpmPrefs *prefs;
- prefs = g_object_new (GPM_TYPE_PREFS, NULL);
- return GPM_PREFS (prefs);
}
diff --git a/src/cc-power-panel.h b/src/cc-power-panel.h
new file mode 100644
index 0000000..8a2b01a
--- /dev/null
+++ b/src/cc-power-panel.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _CC_POWER_PANEL_H
+#define _CC_POWER_PANEL_H
+
+#include <libgnome-control-center/cc-panel.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_POWER_PANEL cc_power_panel_get_type()
+#define CC_POWER_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TYPE_POWER_PANEL, CcPowerPanel))
+#define CC_POWER_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TYPE_POWER_PANEL, CcPowerPanelClass))
+#define CC_IS_POWER_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TYPE_POWER_PANEL))
+#define CC_IS_POWER_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TYPE_POWER_PANEL))
+#define CC_POWER_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TYPE_POWER_PANEL, CcPowerPanelClass))
+
+typedef struct _CcPowerPanel CcPowerPanel;
+typedef struct _CcPowerPanelClass CcPowerPanelClass;
+typedef struct _CcPowerPanelPrivate CcPowerPanelPrivate;
+
+struct _CcPowerPanel {
+ CcPanel parent;
+ CcPowerPanelPrivate *priv;
+};
+
+struct _CcPowerPanelClass {
+ CcPanelClass parent_class;
+};
+
+GType cc_power_panel_get_type (void) G_GNUC_CONST;
+void cc_power_panel_register (GIOModule *module);
+
+G_END_DECLS
+
+#endif /* _CC_POWER_PANEL_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]