Add a 'Power' panel that matches the mockups

This commit is contained in:
Richard Hughes 2010-11-18 17:23:50 +00:00
parent d08cfeae5c
commit 0ce60e84cb
9 changed files with 926 additions and 12 deletions

View file

@ -96,6 +96,7 @@ PKG_CHECK_MODULES(DEFAULT_APPLICATIONS_CAPPLET, libxml-2.0)
PKG_CHECK_MODULES(GSD_DBUS, gnome-settings-daemon) PKG_CHECK_MODULES(GSD_DBUS, gnome-settings-daemon)
PKG_CHECK_MODULES(GIO, gio-2.0 gio-unix-2.0) PKG_CHECK_MODULES(GIO, gio-2.0 gio-unix-2.0)
PKG_CHECK_MODULES(XML, libxml-2.0) PKG_CHECK_MODULES(XML, libxml-2.0)
PKG_CHECK_MODULES(UPOWER, upower-glib >= 0.9.1)
PKG_CHECK_MODULES(CANBERRA, libcanberra-gtk3 >= $CANBERRA_REQUIRED_VERSION) PKG_CHECK_MODULES(CANBERRA, libcanberra-gtk3 >= $CANBERRA_REQUIRED_VERSION)
AC_SUBST(CANBERRA_CFLAGS) AC_SUBST(CANBERRA_CFLAGS)
AC_SUBST(CANBERRA_LIBS) AC_SUBST(CANBERRA_LIBS)
@ -369,6 +370,8 @@ panels/sound/data/icons/scalable/devices/Makefile
panels/sound/data/sounds/Makefile panels/sound/data/sounds/Makefile
panels/screen/Makefile panels/screen/Makefile
panels/screen/gnome-screen-panel.desktop.in panels/screen/gnome-screen-panel.desktop.in
panels/power/Makefile
panels/power/gnome-power-panel.desktop.in
panels/universal-access/Makefile panels/universal-access/Makefile
panels/universal-access/gnome-universal-access-panel.desktop.in panels/universal-access/gnome-universal-access-panel.desktop.in
panels/user-accounts/Makefile panels/user-accounts/Makefile

View file

@ -1,6 +1,7 @@
SUBDIRS= \ SUBDIRS= \
background \ background \
screen \ screen \
power \
display \ display \
mouse \ mouse \
region \ region \

31
panels/power/Makefile.am Normal file
View file

@ -0,0 +1,31 @@
INCLUDES = \
$(PANEL_CFLAGS) \
$(GNOMECC_CAPPLETS_CFLAGS) \
-DGNOMECC_UI_DIR="\"$(uidir)\"" \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
$(NULL)
ccpanelsdir = $(PANELS_DIR)
ccpanels_LTLIBRARIES = libpower.la
libpower_la_SOURCES = \
power-module.c \
cc-power-panel.c \
cc-power-panel.h
libpower_la_LIBADD = $(PANEL_LIBS) $(UPOWER_LIBS)
libpower_la_LDFLAGS = $(PANEL_LDFLAGS)
uidir = $(pkgdatadir)/ui
dist_ui_DATA = power.ui
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
desktop_in_files = gnome-power-panel.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
CLEANFILES = $(desktop_in_files) $(desktop_DATA)
-include $(top_srcdir)/git.mk

View file

@ -0,0 +1,638 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2010 Red Hat, Inc
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
* Copyright (C) 2010 Richard Hughes <richard@hughsie.com>
*
* 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 <libupower-glib/upower.h>
#include <glib/gi18n.h>
#include "cc-power-panel.h"
#define WID(b, w) (GtkWidget *) gtk_builder_get_object (b, w)
G_DEFINE_DYNAMIC_TYPE (CcPowerPanel, cc_power_panel, CC_TYPE_PANEL)
#define POWER_PANEL_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_POWER_PANEL, CcPowerPanelPrivate))
struct _CcPowerPanelPrivate
{
GSettings *lock_settings;
GSettings *gsd_settings;
GCancellable *cancellable;
GtkBuilder *builder;
GDBusProxy *proxy;
UpClient *up_client;
};
static void
cc_power_panel_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
cc_power_panel_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
cc_power_panel_dispose (GObject *object)
{
CcPowerPanelPrivate *priv = CC_POWER_PANEL (object)->priv;
if (priv->gsd_settings)
{
g_object_unref (priv->gsd_settings);
priv->gsd_settings = NULL;
}
if (priv->cancellable != NULL)
{
g_object_unref (priv->cancellable);
priv->cancellable = NULL;
}
if (priv->builder != NULL)
{
g_object_unref (priv->builder);
priv->builder = NULL;
}
if (priv->proxy != NULL)
{
g_object_unref (priv->proxy);
priv->proxy = NULL;
}
if (priv->up_client != NULL)
{
g_object_unref (priv->up_client);
priv->up_client = NULL;
}
G_OBJECT_CLASS (cc_power_panel_parent_class)->dispose (object);
}
static void
cc_power_panel_finalize (GObject *object)
{
CcPowerPanelPrivate *priv = CC_POWER_PANEL (object)->priv;
g_cancellable_cancel (priv->cancellable);
G_OBJECT_CLASS (cc_power_panel_parent_class)->finalize (object);
}
static void
on_lock_settings_changed (GSettings *settings,
const char *key,
CcPowerPanel *panel)
{
}
static void
cc_power_panel_class_init (CcPowerPanelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (CcPowerPanelPrivate));
object_class->get_property = cc_power_panel_get_property;
object_class->set_property = cc_power_panel_set_property;
object_class->dispose = cc_power_panel_dispose;
object_class->finalize = cc_power_panel_finalize;
}
static void
cc_power_panel_class_finalize (CcPowerPanelClass *klass)
{
}
static gchar *
get_timestring (guint64 time_secs)
{
gchar* timestring = NULL;
gint hours;
gint minutes;
/* Add 0.5 to do rounding */
minutes = (int) ( ( time_secs / 60.0 ) + 0.5 );
if (minutes == 0)
{
timestring = g_strdup (_("Unknown time"));
return timestring;
}
if (minutes < 60)
{
timestring = g_strdup_printf (ngettext ("%i minute",
"%i minutes",
minutes), minutes);
return timestring;
}
hours = minutes / 60;
minutes = minutes % 60;
if (minutes == 0)
{
timestring = g_strdup_printf (ngettext (
"%i hour",
"%i hours",
hours), hours);
return timestring;
}
/* TRANSLATOR: "%i %s %i %s" are "%i hours %i minutes"
* Swap order with "%2$s %2$i %1$s %1$i if needed */
timestring = g_strdup_printf (_("%i %s %i %s"),
hours, ngettext ("hour", "hours", hours),
minutes, ngettext ("minute", "minutes", minutes));
return timestring;
}
static void
get_primary_device_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
const gchar *title = NULL;
gchar *details = NULL;
gchar *display_string = NULL;
gchar *icon_name = NULL;
gchar *object_path = NULL;
gdouble percentage;
GError *error = NULL;
GtkWidget *widget;
guint64 time;
gchar *time_string = NULL;
GVariant *result;
UpDeviceKind kind;
UpDeviceState state;
CcPowerPanelPrivate *priv = CC_POWER_PANEL (user_data)->priv;
result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error);
if (result == NULL)
{
g_printerr ("Error getting primary device: %s\n", error->message);
g_error_free (error);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"hbox_status"));
gtk_widget_hide (widget);
return;
}
/* set the icon and text */
g_variant_get (result,
"((susdut))",
&object_path,
&kind,
//&icon_name,
&display_string,
&percentage,
&state,
&time);
g_debug ("got data from object %s", object_path);
/* set icon and text parameters */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"image_status"));
gtk_image_set_from_icon_name (GTK_IMAGE (widget),
icon_name != NULL ? icon_name : "dialog-error",
GTK_ICON_SIZE_DIALOG);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"label_title"));
/* translate the title, which has limited entries as devices that are
* fully charged are not returned as the primary device */
if (kind == UP_DEVICE_KIND_BATTERY)
{
switch (state)
{
case UP_DEVICE_STATE_CHARGING:
title = _("Battery charging");
break;
case UP_DEVICE_STATE_DISCHARGING:
title = _("Battery discharging");
break;
default:
break;
}
}
else if (kind == UP_DEVICE_KIND_UPS)
{
switch (state)
{
case UP_DEVICE_STATE_CHARGING:
title = _("UPS charging");
break;
case UP_DEVICE_STATE_DISCHARGING:
title = _("UPS discharging");
break;
default:
break;
}
}
gtk_label_set_label (GTK_LABEL (widget),
title != NULL ? title : "");
gtk_widget_set_visible (widget, (title != NULL));
/* get the description */
if (time > 0)
{
time_string = get_timestring (time);
if (state == UP_DEVICE_STATE_CHARGING)
{
/* TRANSLATORS: %1 is a time string, e.g. "1 hour 5 minutes" */
details = g_strdup_printf(_("%s until charged (%.0lf%%)"),
time_string, percentage);
}
else if (state == UP_DEVICE_STATE_DISCHARGING)
{
/* TRANSLATORS: %1 is a time string, e.g. "1 hour 5 minutes" */
details = g_strdup_printf(_("%s until empty (%.0lf%%)"),
time_string, percentage);
}
}
else
{
/* TRANSLATORS: %1 is a percentage value. Note: this string is only
* used when we don't have a time value */
details = g_strdup_printf(_("%.0lf%% charged"),
percentage);
}
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"label_description"));
gtk_label_set_label (GTK_LABEL (widget),
details);
g_free (details);
g_free (display_string);
g_free (time_string);
g_free (object_path);
g_free (icon_name);
g_variant_unref (result);
}
static void
on_signal (GDBusProxy *proxy,
gchar *sender_name,
gchar *signal_name,
GVariant *parameters,
gpointer user_data)
{
CcPowerPanelPrivate *priv = CC_POWER_PANEL (user_data)->priv;
if (g_strcmp0 (signal_name, "Changed") == 0)
{
/* get the new state */
g_dbus_proxy_call (priv->proxy,
"GetPrimaryDevice",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
priv->cancellable,
get_primary_device_cb,
user_data);
}
}
static void
got_power_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
GError *error = NULL;
CcPowerPanelPrivate *priv = CC_POWER_PANEL (user_data)->priv;
priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
if (priv->proxy == NULL)
{
g_printerr ("Error creating proxy: %s\n", error->message);
g_error_free (error);
return;
}
/* we want to change the primary device changes */
g_signal_connect (priv->proxy,
"g-signal",
G_CALLBACK (on_signal),
user_data);
/* get the initial state */
g_dbus_proxy_call (priv->proxy,
"GetPrimaryDevice",
NULL,
G_DBUS_CALL_FLAGS_NONE,
200, /* we don't want to randomly expand the dialog */
priv->cancellable,
get_primary_device_cb,
user_data);
}
static void
combo_time_changed_cb (GtkWidget *widget, CcPowerPanel *self)
{
GtkTreeIter iter;
GtkTreeModel *model;
gint value;
gboolean ret;
const gchar *key = (const gchar *)g_object_get_data (G_OBJECT(widget), "_gsettings_key");
/* no selection */
ret = gtk_combo_box_get_active_iter (GTK_COMBO_BOX(widget), &iter);
if (!ret)
return;
/* get entry */
model = gtk_combo_box_get_model (GTK_COMBO_BOX(widget));
gtk_tree_model_get (model, &iter,
1, &value,
-1);
/* set both battery and ac keys */
g_settings_set_int (self->priv->gsd_settings, key, value);
}
static void
combo_enum_changed_cb (GtkWidget *widget, CcPowerPanel *self)
{
GtkTreeIter iter;
GtkTreeModel *model;
gint value;
gboolean ret;
const gchar *key = (const gchar *)g_object_get_data (G_OBJECT(widget), "_gsettings_key");
/* no selection */
ret = gtk_combo_box_get_active_iter (GTK_COMBO_BOX(widget), &iter);
if (!ret)
return;
/* get entry */
model = gtk_combo_box_get_model (GTK_COMBO_BOX(widget));
gtk_tree_model_get (model, &iter,
1, &value,
-1);
/* set both battery and ac keys */
g_settings_set_enum (self->priv->gsd_settings, key, value);
}
static void
set_value_for_combo (GtkComboBox *combo_box, gint value)
{
GtkTreeIter iter;
GtkTreeModel *model;
gint value_tmp;
gboolean ret;
/* get entry */
model = gtk_combo_box_get_model (combo_box);
ret = gtk_tree_model_get_iter_first (model, &iter);
if (!ret)
return;
/* try to make the UI match the setting */
do
{
gtk_tree_model_get (model, &iter,
1, &value_tmp,
-1);
if (value == value_tmp)
{
gtk_combo_box_set_active_iter (combo_box, &iter);
break;
}
} while (gtk_tree_model_iter_next (model, &iter));
}
static void
set_ac_battery_ui_mode (CcPowerPanel *self)
{
gboolean has_batteries = FALSE;
gboolean ret;
GError *error = NULL;
GPtrArray *devices;
GtkWidget *widget;
guint i;
UpDevice *device;
UpDeviceKind kind;
CcPowerPanelPrivate *priv = self->priv;
/* this is sync, but it's cached in the daemon and so quick */
ret = up_client_enumerate_devices_sync (self->priv->up_client, NULL, &error);
if (!ret)
{
g_warning ("failed to get device list: %s", error->message);
g_error_free (error);
goto out;
}
devices = up_client_get_devices (self->priv->up_client);
for (i=0; i<devices->len; i++)
{
device = g_ptr_array_index (devices, i);
g_object_get (device,
"kind", &kind,
NULL);
if (kind == UP_DEVICE_KIND_BATTERY ||
kind == UP_DEVICE_KIND_UPS)
{
has_batteries = TRUE;
break;
}
}
g_ptr_array_unref (devices);
out:
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"vbox_battery"));
gtk_widget_set_visible (widget, has_batteries);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"hbox_ac"));
gtk_widget_set_visible (widget, !has_batteries);
}
static void
cc_power_panel_init (CcPowerPanel *self)
{
GError *error;
GtkWidget *widget;
GtkWidget *target;
gint value;
self->priv = POWER_PANEL_PRIVATE (self);
self->priv->builder = gtk_builder_new ();
error = NULL;
gtk_builder_add_from_file (self->priv->builder,
GNOMECC_UI_DIR "/power.ui",
&error);
if (error != NULL)
{
g_warning ("Could not load interface file: %s", error->message);
g_error_free (error);
return;
}
self->priv->cancellable = g_cancellable_new ();
/* get initial icon state */
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
"org.gnome.PowerManager",
"/org/gnome/PowerManager",
"org.gnome.PowerManager",
self->priv->cancellable,
got_power_proxy_cb,
self);
/* find out if there are any battery or UPS devices attached
* and setup UI accordingly */
self->priv->up_client = up_client_new ();
set_ac_battery_ui_mode (self);
self->priv->gsd_settings = g_settings_new ("org.gnome.settings-daemon.plugins.power");
g_signal_connect (self->priv->gsd_settings,
"changed",
G_CALLBACK (on_lock_settings_changed),
self);
/* setup the checkboxes correcty */
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"checkbutton_sleep_ac"));
target = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"combobox_sleep_ac"));
g_object_bind_property (widget, "active",
target, "sensitive",
G_BINDING_SYNC_CREATE);
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"checkbutton_sleep_battery"));
target = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"combobox_sleep_battery"));
g_object_bind_property (widget, "active",
target, "sensitive",
G_BINDING_SYNC_CREATE);
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"checkbutton_sleep"));
target = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"combobox_sleep"));
g_object_bind_property (widget, "active",
target, "sensitive",
G_BINDING_SYNC_CREATE);
/* bind the checkboxes */
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"checkbutton_sleep_ac"));
g_settings_bind (self->priv->gsd_settings,
"sleep-inactive-ac",
widget, "active",
G_SETTINGS_BIND_DEFAULT);
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"checkbutton_sleep_battery"));
g_settings_bind (self->priv->gsd_settings,
"sleep-inactive-battery",
widget, "active",
G_SETTINGS_BIND_DEFAULT);
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"checkbutton_sleep"));
g_settings_bind (self->priv->gsd_settings,
"sleep-inactive-ac",
widget, "active",
G_SETTINGS_BIND_DEFAULT);
/* auto-sleep time */
value = g_settings_get_int (self->priv->gsd_settings, "sleep-inactive-ac-timeout");
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"combobox_sleep_ac"));
set_value_for_combo (GTK_COMBO_BOX (widget), value);
g_object_set_data (G_OBJECT(widget), "_gsettings_key", "sleep-inactive-ac-timeout");
g_signal_connect (widget, "changed",
G_CALLBACK (combo_time_changed_cb),
self);
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"combobox_sleep"));
set_value_for_combo (GTK_COMBO_BOX (widget), value);
g_object_set_data (G_OBJECT(widget), "_gsettings_key", "sleep-inactive-ac-timeout");
g_signal_connect (widget, "changed",
G_CALLBACK (combo_time_changed_cb),
self);
value = g_settings_get_int (self->priv->gsd_settings, "sleep-inactive-battery-timeout");
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"combobox_sleep_battery"));
set_value_for_combo (GTK_COMBO_BOX (widget), value);
g_object_set_data (G_OBJECT(widget), "_gsettings_key", "sleep-inactive-battery-timeout");
g_signal_connect (widget, "changed",
G_CALLBACK (combo_time_changed_cb),
self);
/* actions */
value = g_settings_get_enum (self->priv->gsd_settings, "critical-battery-action");
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"combobox_critical"));
set_value_for_combo (GTK_COMBO_BOX (widget), value);
g_object_set_data (G_OBJECT(widget), "_gsettings_key", "critical-battery-action");
g_signal_connect (widget, "changed",
G_CALLBACK (combo_enum_changed_cb),
self);
value = g_settings_get_enum (self->priv->gsd_settings, "button-power");
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"combobox_button_power"));
set_value_for_combo (GTK_COMBO_BOX (widget), value);
g_object_set_data (G_OBJECT(widget), "_gsettings_key", "button-power");
g_signal_connect (widget, "changed",
G_CALLBACK (combo_enum_changed_cb),
self);
value = g_settings_get_enum (self->priv->gsd_settings, "button-sleep");
widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"combobox_button_sleep"));
set_value_for_combo (GTK_COMBO_BOX (widget), value);
g_object_set_data (G_OBJECT(widget), "_gsettings_key", "button-sleep");
g_signal_connect (widget, "changed",
G_CALLBACK (combo_enum_changed_cb),
self);
widget = WID (self->priv->builder, "vbox_power");
gtk_widget_reparent (widget, (GtkWidget *) self);
}
void
cc_power_panel_register (GIOModule *module)
{
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);
}

View file

@ -0,0 +1,73 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2010 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
* 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 _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 */

View file

@ -0,0 +1,17 @@
[Desktop Entry]
_Name=Power
_Comment=Power management settings
Exec=gnome-control-center power
Icon=gnome-power-manager
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;
OnlyShowIn=GNOME;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center
X-GNOME-Bugzilla-Component=power
X-GNOME-Bugzilla-Version=@VERSION@
X-GNOME-Settings-Panel=power
# Translators: those are keywords for the power control-center panel
_X-GNOME-Keywords=Power;Sleep;Suspend;Hibernate;

View file

@ -0,0 +1,41 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2010 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
* 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 "cc-power-panel.h"
#include <glib/gi18n-lib.h>
void
g_io_module_load (GIOModule *module)
{
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
/* register the panel */
cc_power_panel_register (module);
}
void
g_io_module_unload (GIOModule *module)
{
}

View file

@ -2,6 +2,72 @@
<interface> <interface>
<requires lib="gtk+" version="2.20"/> <requires lib="gtk+" version="2.20"/>
<!-- interface-naming-policy project-wide --> <!-- interface-naming-policy project-wide -->
<object class="GtkListStore" id="liststore_sleep">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name value -->
<column type="gint"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Suspend</col>
<col id="1">1</col>
</row>
<row>
<col id="0" translatable="yes">Hibernate</col>
<col id="1">3</col>
</row>
</data>
</object>
<object class="GtkListStore" id="liststore_power">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name value -->
<column type="gint"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Suspend</col>
<col id="1">1</col>
</row>
<row>
<col id="0" translatable="yes">Hibernate</col>
<col id="1">3</col>
</row>
<row>
<col id="0" translatable="yes">Do nothing</col>
<col id="1">5</col>
</row>
<row>
<col id="0" translatable="yes">Ask me</col>
<col id="1">4</col>
</row>
<row>
<col id="0" translatable="yes">Shutdown</col>
<col id="1">2</col>
</row>
</data>
</object>
<object class="GtkListStore" id="liststore_critical">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name gint1 -->
<column type="gint"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Hibernate</col>
<col id="1">3</col>
</row>
<row>
<col id="0" translatable="yes">Shutdown</col>
<col id="1">2</col>
</row>
</data>
</object>
<object class="GtkSizeGroup" id="sizegroup_combos"> <object class="GtkSizeGroup" id="sizegroup_combos">
<widgets> <widgets>
<widget name="combobox_critical"/> <widget name="combobox_critical"/>
@ -15,7 +81,7 @@
<object class="GtkWindow" id="window_power"> <object class="GtkWindow" id="window_power">
<property name="resizable">False</property> <property name="resizable">False</property>
<child> <child>
<object class="GtkVBox" id="vbox1"> <object class="GtkVBox" id="vbox_power">
<property name="visible">True</property> <property name="visible">True</property>
<property name="border_width">12</property> <property name="border_width">12</property>
<property name="spacing">12</property> <property name="spacing">12</property>
@ -80,8 +146,9 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkComboBox" id="combobox_sleep_ac"> <object class="GtkComboBoxText" id="combobox_sleep_ac">
<property name="visible">True</property> <property name="visible">True</property>
<property name="model">liststore_time</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -123,8 +190,9 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkComboBox" id="combobox_sleep_battery"> <object class="GtkComboBoxText" id="combobox_sleep_battery">
<property name="visible">True</property> <property name="visible">True</property>
<property name="model">liststore_time</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -179,8 +247,9 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkComboBox" id="combobox_sleep"> <object class="GtkComboBoxText" id="combobox_sleep">
<property name="visible">True</property> <property name="visible">True</property>
<property name="model">liststore_time</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -230,8 +299,9 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkComboBox" id="combobox_critical"> <object class="GtkComboBoxText" id="combobox_critical">
<property name="visible">True</property> <property name="visible">True</property>
<property name="model">liststore_critical</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -282,8 +352,9 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkComboBox" id="combobox_button_power"> <object class="GtkComboBoxText" id="combobox_button_power">
<property name="visible">True</property> <property name="visible">True</property>
<property name="model">liststore_power</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -324,8 +395,9 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkComboBox" id="combobox_button_sleep"> <object class="GtkComboBoxText" id="combobox_button_sleep">
<property name="visible">True</property> <property name="visible">True</property>
<property name="model">liststore_sleep</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -352,6 +424,7 @@
<object class="GtkHBox" id="hbox2"> <object class="GtkHBox" id="hbox2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="border_width">12</property> <property name="border_width">12</property>
<property name="spacing">6</property>
<child> <child>
<object class="GtkImage" id="image_status"> <object class="GtkImage" id="image_status">
<property name="visible">True</property> <property name="visible">True</property>
@ -368,12 +441,21 @@
<object class="GtkVBox" id="vbox4"> <object class="GtkVBox" id="vbox4">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<object class="GtkLabel" id="label_title"> <object class="GtkHBox" id="hbox3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label">Battery charging</property> <child>
<attributes> <object class="GtkLabel" id="label_title">
<attribute name="weight" value="bold"/> <property name="visible">True</property>
</attributes> <property name="label">Battery charging</property>
<attributes>
<attribute name="scale" value="1.500000"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="position">0</property> <property name="position">0</property>
@ -418,4 +500,30 @@
<widget name="hbox14"/> <widget name="hbox14"/>
</widgets> </widgets>
</object> </object>
<object class="GtkListStore" id="liststore_time">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name value -->
<column type="gint"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">5 minutes</col>
<col id="1">300</col>
</row>
<row>
<col id="0" translatable="yes">10 minutes</col>
<col id="1">600</col>
</row>
<row>
<col id="0" translatable="yes">30 minutes</col>
<col id="1">1800</col>
</row>
<row>
<col id="0" translatable="yes">1 hour</col>
<col id="1">3600</col>
</row>
</data>
</object>
</interface> </interface>

View file

@ -45,6 +45,8 @@ panels/network/gnome-network-panel.desktop.in.in
[type: gettext/glade]panels/network/gnome-network-properties.ui [type: gettext/glade]panels/network/gnome-network-properties.ui
panels/screen/gnome-screen-panel.desktop.in.in panels/screen/gnome-screen-panel.desktop.in.in
panels/screen/screen.ui panels/screen/screen.ui
panels/power/gnome-power-panel.desktop.in.in
panels/power/screen.ui
panels/sound/applet-main.c panels/sound/applet-main.c
panels/sound/cc-sound-panel.c panels/sound/cc-sound-panel.c
panels/sound/gvc-applet.c panels/sound/gvc-applet.c