[gnome-control-center/meego-security: 7/8] First stab at the power applet
- From: Ross Burton <rburton src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/meego-security: 7/8] First stab at the power applet
- Date: Thu, 18 Mar 2010 10:51:34 +0000 (UTC)
commit e687f007806dde6f87d7bf9e77bb4b4331af52f0
Author: Ross Burton <ross linux intel com>
Date: Thu Mar 4 16:22:39 2010 +0000
First stab at the power applet
capplets/power/Makefile.am | 38 ++++++
capplets/power/cc-power-panel.c | 138 +++++++++++++++++++
capplets/power/cc-power-panel.h | 54 ++++++++
capplets/power/power-module.c | 42 ++++++
capplets/power/power-properties.desktop.in.in | 4 +-
capplets/power/power.ui | 177 +++++++++++++++++++++++++
6 files changed, 452 insertions(+), 1 deletions(-)
---
diff --git a/capplets/power/Makefile.am b/capplets/power/Makefile.am
index ae44c94..0af6296 100644
--- a/capplets/power/Makefile.am
+++ b/capplets/power/Makefile.am
@@ -1 +1,39 @@
+ INTLTOOL_DESKTOP_RULE@
+
+cappletname = power
+
+INCLUDES = \
+ $(GNOMECC_CAPPLETS_CFLAGS) \
+ -I$(top_srcdir)/libgnome-control-center-extension \
+ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
+ -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
+ -DGNOMECC_UI_DIR="\"$(uidir)\""
+
+ccmodulesdir = $(EXTENSIONSDIR)
+ccmodules_LTLIBRARIES = libpower.la
+
+libpower_la_SOURCES = \
+ power-module.c \
+ cc-power-panel.h cc-power-panel.c
+
+libpower_la_CFLAGS = \
+ $(EXTENSION_CFLAGS) \
+ $(EXTENSION_COMMON_CFLAGS)
+
+libpower_la_LDFLAGS = \
+ $(EXTENSION_LIBTOOL_FLAGS)
+
+libpower_la_LIBADD = \
+ $(EXTENSION_LIBS) \
+ $(EXTENSION_COMMON_LIBS)
+
+uidir = $(pkgdatadir)/ui
+dist_ui_DATA = power.ui
+
+desktopdir = $(datadir)/applications
+desktop_in_files = power-properties.desktop.in
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+
+CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) $(desktop_in_files) $(desktop_DATA)
+
-include $(top_srcdir)/git.mk
diff --git a/capplets/power/cc-power-panel.c b/capplets/power/cc-power-panel.c
new file mode 100644
index 0000000..4cd2a9c
--- /dev/null
+++ b/capplets/power/cc-power-panel.c
@@ -0,0 +1,138 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * 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 <stdlib.h>
+#include <stdio.h>
+
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n-lib.h>
+
+#include <gconf/gconf-client.h>
+
+#include "cc-power-panel.h"
+
+#define CC_POWER_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_POWER_PANEL, CcPowerPanelPrivate))
+
+#define WID(s) GTK_WIDGET (gtk_builder_get_object (builder, s))
+
+struct CcPowerPanelPrivate
+{
+ GtkWidget *idle_slider;
+};
+
+static void cc_power_panel_class_init (CcPowerPanelClass *klass);
+static void cc_power_panel_init (CcPowerPanel *power_panel);
+static void cc_power_panel_finalize (GObject *object);
+
+G_DEFINE_DYNAMIC_TYPE (CcPowerPanel, cc_power_panel, CC_TYPE_PANEL)
+
+static void
+setup_panel (CcPowerPanel *panel)
+{
+ GError *error = NULL;
+ GtkBuilder *builder;
+ GtkWidget *widget;
+
+ builder = gtk_builder_new ();
+
+ gtk_builder_add_from_file (builder,
+ GNOMECC_UI_DIR "/power.ui",
+ &error);
+
+ if (error != NULL) {
+ g_error (_("Could not load user interface file: %s"), error->message);
+ g_error_free (error);
+ return;
+ }
+
+ widget = WID ("main_vbox");
+ gtk_widget_reparent (widget, GTK_WIDGET (panel));
+ gtk_widget_show (widget);
+}
+
+static GObject *
+cc_power_panel_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ CcPowerPanel *power_panel;
+
+ power_panel = CC_POWER_PANEL (G_OBJECT_CLASS (cc_power_panel_parent_class)->constructor
+ (type, n_construct_properties, construct_properties));
+
+ g_object_set (power_panel,
+ "display-name", _("Power and brightness"),
+ "id", "power-properties.desktop",
+ NULL);
+
+ setup_panel (power_panel);
+
+ return G_OBJECT (power_panel);
+}
+
+static void
+cc_power_panel_class_init (CcPowerPanelClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructor = cc_power_panel_constructor;
+ object_class->finalize = cc_power_panel_finalize;
+
+ g_type_class_add_private (klass, sizeof (CcPowerPanelPrivate));
+}
+
+static void
+cc_power_panel_class_finalize (CcPowerPanelClass *klass)
+{
+}
+
+static void
+cc_power_panel_init (CcPowerPanel *panel)
+{
+ panel->priv = CC_POWER_PANEL_GET_PRIVATE (panel);
+}
+
+static void
+cc_power_panel_finalize (GObject *object)
+{
+ CcPowerPanel *power_panel;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (CC_IS_POWER_PANEL (object));
+
+ power_panel = CC_POWER_PANEL (object);
+
+ g_return_if_fail (power_panel->priv != NULL);
+
+ G_OBJECT_CLASS (cc_power_panel_parent_class)->finalize (object);
+}
+
+void
+cc_power_panel_register (GIOModule *module)
+{
+ cc_power_panel_register_type (G_TYPE_MODULE (module));
+ g_io_extension_point_implement (CC_PANEL_EXTENSION_POINT_NAME,
+ CC_TYPE_POWER_PANEL,
+ "power",
+ 10);
+}
diff --git a/capplets/power/cc-power-panel.h b/capplets/power/cc-power-panel.h
new file mode 100644
index 0000000..4a059f9
--- /dev/null
+++ b/capplets/power/cc-power-panel.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * 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 <gtk/gtk.h>
+#include "cc-panel.h"
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_POWER_PANEL (cc_power_panel_get_type ())
+#define CC_POWER_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_POWER_PANEL, CcPowerPanel))
+#define CC_POWER_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_POWER_PANEL, CcPowerPanelClass))
+#define CC_IS_POWER_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_POWER_PANEL))
+#define CC_IS_POWER_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_POWER_PANEL))
+#define CC_POWER_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_POWER_PANEL, CcPowerPanelClass))
+
+typedef struct CcPowerPanelPrivate CcPowerPanelPrivate;
+
+typedef struct
+{
+ CcPanel parent;
+ CcPowerPanelPrivate *priv;
+} CcPowerPanel;
+
+typedef struct
+{
+ CcPanelClass parent_class;
+} CcPowerPanelClass;
+
+GType cc_power_panel_get_type (void);
+void cc_power_panel_register (GIOModule *module);
+
+G_END_DECLS
+
+#endif /* __CC_POWER_PANEL_H */
diff --git a/capplets/power/power-module.c b/capplets/power/power-module.c
new file mode 100644
index 0000000..d317f7b
--- /dev/null
+++ b/capplets/power/power-module.c
@@ -0,0 +1,42 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Intel Corp
+ *
+ * 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 <glib.h>
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+#include <gio/gio.h>
+
+#include "cc-power-panel.h"
+
+void
+g_io_module_load (GIOModule *module)
+{
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ cc_power_panel_register (module);
+}
+
+void
+g_io_module_unload (GIOModule *module)
+{
+}
diff --git a/capplets/power/power-properties.desktop.in.in b/capplets/power/power-properties.desktop.in.in
index 32e9f0e..be2553f 100644
--- a/capplets/power/power-properties.desktop.in.in
+++ b/capplets/power/power-properties.desktop.in.in
@@ -1,7 +1,9 @@
[Desktop Entry]
_Name=Power and brightness
+Icon=
+Exec=gnome-control-center power.desktop
Terminal=false
Type=Application
StartupNotify=true
-Categories=GNOME;GTK;Settings;SystemSettings;
+Categories=GNOME;GTK;Settings;HardwareSettings;
OnlyShowIn=GNOME;
diff --git a/capplets/power/power.ui b/capplets/power/power.ui
new file mode 100644
index 0000000..2e80ffd
--- /dev/null
+++ b/capplets/power/power.ui
@@ -0,0 +1,177 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkWindow" id="window1">
+ <child>
+ <object class="GtkVBox" id="main_vbox">
+ <property name="visible">True</property>
+ <property name="border_width">12</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">8</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Power and brightness</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="scale" value="1.200000"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">ldle</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="scale" value="1.200000"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Set computer as idle when inactive for:</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHScale" id="idle_scale">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="value_pos">bottom</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">This will blank the screen and set your messaging state to 'away'.</property>
+ <attributes>
+ <attribute name="scale" value="0.830000"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Sleep</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="scale" value="1.200000"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Put computer to sleep when inactive for:</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHScale" id="sleep_scale">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="value_pos">bottom</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">This will suspend everything on your computer. It'll wake up in just the same state as it was before.</property>
+ <attributes>
+ <attribute name="scale" value="0.830000"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Sleep</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="scale" value="1.200000"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">To change your brightness, you can use the keys on your computer.</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]