gnome-power-manager r3175 - in trunk: . src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-power-manager r3175 - in trunk: . src
- Date: Fri, 23 Jan 2009 12:15:24 +0000 (UTC)
Author: rhughes
Date: Fri Jan 23 12:15:24 2009
New Revision: 3175
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=3175&view=rev
Log:
2009-01-23 Richard Hughes <richard hughsie com>
* Makefile.am:
* configure.ac:
* src/Makefile.am:
* src/gpm-ac-adapter.c: (gpm_ac_adapter_is_present),
(gpm_ac_adapter_changed_cb), (gpm_ac_adapter_init):
* src/gpm-control.c: (gpm_control_allowed_suspend),
(gpm_control_allowed_hibernate), (gpm_control_shutdown),
(gpm_control_suspend), (gpm_control_hibernate),
(gpm_control_finalize), (gpm_control_init):
* src/gpm-manager.c: (gpm_engine_perhaps_recall_cb),
(gpm_engine_low_capacity_cb), (gpm_engine_fully_charged_cb),
(gpm_engine_discharging_cb), (gpm_engine_charge_low_cb),
(gpm_manager_get_time_until_action_text),
(gpm_engine_charge_critical_cb), (gpm_engine_charge_action_cb),
(has_inhibit_changed_cb), (gpm_manager_init):
* src/gpm-self-test.c: (main):
* src/gpm-tray-icon.c: (gpm_tray_icon_show_info_cb),
(gpm_tray_icon_add_device), (gpm_tray_icon_activate_cb),
(gpm_tray_icon_init), (gpm_tray_icon_finalize):
* src/gpm-tray-icon.h:
Now DeviceKit-power is a blessed external dependency, remove the compat
code.
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/configure.ac
trunk/src/Makefile.am
trunk/src/gpm-ac-adapter.c
trunk/src/gpm-control.c
trunk/src/gpm-manager.c
trunk/src/gpm-self-test.c
trunk/src/gpm-tray-icon.c
trunk/src/gpm-tray-icon.h
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Fri Jan 23 12:15:24 2009
@@ -1,13 +1,9 @@
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = libhal-glib
-
-if HAVE_DK_POWER
-SUBDIRS += libdevkit-power
-endif
-
-SUBDIRS += \
+SUBDIRS = \
+ libhal-glib \
+ libdevkit-power \
src \
po \
docs \
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri Jan 23 12:15:24 2009
@@ -239,23 +239,9 @@
fi
dnl ---------------------------------------------------------------------------
-dnl - Enable DeviceKit-power support
+dnl - Require DeviceKit-power support
dnl ---------------------------------------------------------------------------
-AC_ARG_ENABLE(dk_power,
- AS_HELP_STRING([--enable-devicekit-power],
- [Use DeviceKit-power for data sources]),
- enable_dk_power=$enableval,enable_dk_power=yes)
-
-AC_MSG_CHECKING([whether to use DeviceKit-power])
-have_dk_power=no
-if test x$enable_dk_power = xyes ; then
- have_dk_power=yes
- AC_DEFINE(HAVE_DK_POWER, 1, [Define if we want to use DeviceKit-power])
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
-fi
-AM_CONDITIONAL([HAVE_DK_POWER], [test $have_dk_power = yes])
+AC_PATH_PROG(DEVKIT_POWER, devkit-power)
dnl ---------------------------------------------------------------------------
dnl - Use check-foreground-console (Ubuntu specific) support?
@@ -678,7 +664,6 @@
cflags: ${CFLAGS}
Building extra applets: ${enable_applets}
DPMS support: ${have_dpms}
- DeviceKit-power support: ${have_dk_power}
PolicyKit support: ${have_polkit}
XEVENTS support: ${have_xevents}
Self test support: ${have_tests}
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Fri Jan 23 12:15:24 2009
@@ -48,18 +48,12 @@
bin_PROGRAMS = \
gnome-power-manager \
gnome-power-preferences \
- $(NULL)
-
-if HAVE_DK_POWER
-bin_PROGRAMS += \
gnome-power-statistics \
$(NULL)
-endif
check_PROGRAMS = \
gnome-power-self-test
-if HAVE_DK_POWER
gnome_power_statistics_SOURCES = \
egg-color.c \
egg-color.h \
@@ -95,7 +89,6 @@
gnome_power_statistics_CFLAGS = \
$(WARNINGFLAGS) \
$(NULL)
-endif
gnome_power_preferences_SOURCES = \
egg-debug.h \
@@ -204,28 +197,12 @@
gpm-feedback-widget.c \
$(NULL)
-if HAVE_DK_POWER
gnome_power_manager_SOURCES += \
gpm-engine.h \
gpm-engine.c \
gpm-devicekit.h \
gpm-devicekit.c \
$(NULL)
-else
- egg-color.c \
- egg-color.h \
- gpm-engine-old.h \
- gpm-engine-old.c \
- gpm-cell.h \
- gpm-cell.c \
- gpm-cell-unit.h \
- gpm-cell-unit.c \
- gpm-cell-array.h \
- gpm-cell-array.c \
- gpm-warnings.h \
- gpm-warnings.c \
- $(NULL)
-endif
gnome_power_manager_LDADD = \
$(GLIB_LIBS) \
@@ -239,13 +216,9 @@
$(LIBNOTIFY_LIBS) \
$(GPM_EXTRA_LIBS) \
$(LOCAL_LIBHAL_LIBS) \
+ $(DEVKIT_POWER_LIBS) \
$(NULL)
-if HAVE_DK_POWER
-gnome_power_manager_LDADD += \
- $(DEVKIT_POWER_LIBS)
-endif
-
gnome_power_manager_CFLAGS = \
$(WARNINGFLAGS) \
$(NULL)
@@ -300,25 +273,12 @@
gpm-inhibit.c \
$(NULL)
-if HAVE_DK_POWER
gnome_power_self_test_SOURCES += \
gpm-devicekit.h \
gpm-devicekit.c \
egg-console-kit.h \
egg-console-kit.c \
$(NULL)
-else
-gnome_power_self_test_SOURCES += \
- gpm-warnings.h \
- gpm-warnings.c \
- gpm-cell.h \
- gpm-cell.c \
- gpm-cell-unit.h \
- gpm-cell-unit.c \
- gpm-cell-array.h \
- gpm-cell-array.c \
- $(NULL)
-endif
gnome_power_self_test_LDADD = \
$(GLIB_LIBS) \
@@ -342,10 +302,6 @@
gpm-marshal.h \
$(NULL)
-if !HAVE_DK_POWER
-BUILT_SOURCES += org.freedesktop.PowerManagement.Statistics.h
-endif
-
gpm-marshal.c: gpm-marshal.list
echo "#include \"gpm-marshal.h\"" > $@ && \
@GLIB_GENMARSHAL@ $< --prefix=gpm_marshal --body >> $@
Modified: trunk/src/gpm-ac-adapter.c
==============================================================================
--- trunk/src/gpm-ac-adapter.c (original)
+++ trunk/src/gpm-ac-adapter.c Fri Jan 23 12:15:24 2009
@@ -38,13 +38,8 @@
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
-#ifdef HAVE_DK_POWER
#include <dkp-client.h>
#include <dkp-device.h>
-#else
- #include <hal-device.h>
- #include <hal-manager.h>
-#endif
#include "gpm-common.h"
#include "egg-debug.h"
@@ -55,11 +50,7 @@
struct GpmAcAdapterPrivate
{
gboolean has_hardware;
-#ifdef HAVE_DK_POWER
DkpClient *client;
-#else
- HalDevice *device;
-#endif
};
enum {
@@ -82,59 +73,13 @@
gpm_ac_adapter_is_present (GpmAcAdapter *ac_adapter)
{
gboolean is_on_ac;
-#ifndef HAVE_DK_POWER
- GError *error;
-
- g_return_val_if_fail (ac_adapter != NULL, FALSE);
- g_return_val_if_fail (GPM_IS_AC_ADAPTER (ac_adapter), FALSE);
-
- /* bodge for now, PC's are considered on AC power */
- if (!ac_adapter->priv->has_hardware)
- return TRUE;
-
- error = NULL;
- hal_device_get_bool (ac_adapter->priv->device, "ac_adapter.present", &is_on_ac, &error);
- if (error != NULL) {
- egg_warning ("could not read ac_adapter.present");
- g_error_free (error);
- }
-#else
gboolean on_battery;
on_battery = dkp_client_on_battery (ac_adapter->priv->client);
/* battery -> not AC */
is_on_ac = !on_battery;
-#endif
return is_on_ac;
}
-#ifndef HAVE_DK_POWER
-/**
- * hal_device_property_modified_cb:
- *
- * @udi: The HAL UDI
- * @key: Property key
- * @is_added: If the key was added
- * @is_removed: If the key was removed
- *
- * Invoked when a property of a device in the Global Device List is
- * changed, and we have we have subscribed to changes for that device.
- */
-static void
-hal_device_property_modified_cb (HalDevice *device,
- const gchar *key,
- gboolean is_added,
- gboolean is_removed,
- gboolean finally,
- GpmAcAdapter *ac_adapter)
-{
- gboolean on_ac;
- if (strcmp (key, "ac_adapter.present") == 0) {
- on_ac = gpm_ac_adapter_is_present (ac_adapter);
- g_signal_emit (ac_adapter, signals [AC_ADAPTER_CHANGED], 0, on_ac);
- return;
- }
-}
-#else
/**
* gpm_ac_adapter_changed_cb:
*/
@@ -145,7 +90,6 @@
on_battery = dkp_client_on_battery (client);
g_signal_emit (ac_adapter, signals [AC_ADAPTER_CHANGED], 0, !on_battery);
}
-#endif
/**
* gpm_ac_adapter_finalize:
@@ -197,48 +141,9 @@
gpm_ac_adapter_init (GpmAcAdapter *ac_adapter)
{
ac_adapter->priv = GPM_AC_ADAPTER_GET_PRIVATE (ac_adapter);
-#ifdef HAVE_DK_POWER
ac_adapter->priv->client = dkp_client_new ();
g_signal_connect (ac_adapter->priv->client, "changed",
G_CALLBACK (gpm_ac_adapter_changed_cb), ac_adapter);
-#else
- gchar **device_names;
- gboolean ret;
- GError *error;
- HalManager *hal_manager;
-
- ac_adapter->priv->device = hal_device_new ();
- hal_manager = hal_manager_new ();
-
- /* save udi of lcd adapter */
- error = NULL;
- ret = hal_manager_find_capability (hal_manager, "ac_adapter", &device_names, &error);
- if (!ret) {
- egg_warning ("Couldn't obtain list of AC adapters: %s", error->message);
- g_error_free (error);
- return;
- }
- if (device_names[0] != NULL) {
- /* we track this by hand as machines that have no ac_adapter object must
- * return that they are on ac power */
- ac_adapter->priv->has_hardware = TRUE;
- egg_debug ("using %s", device_names[0]);
-
- /* We only want first ac_adapter object (should only be one) */
- hal_device_set_udi (ac_adapter->priv->device, device_names[0]);
- hal_device_watch_property_modified (ac_adapter->priv->device);
-
- /* we want state changes */
- g_signal_connect (ac_adapter->priv->device, "property-modified",
- G_CALLBACK (hal_device_property_modified_cb), ac_adapter);
- } else {
- /* no ac-adapter class support */
- ac_adapter->priv->has_hardware = FALSE;
- egg_debug ("No devices of capability ac_adapter");
- }
- hal_manager_free_capability (device_names);
- g_object_unref (hal_manager);
-#endif
}
/**
Modified: trunk/src/gpm-control.c
==============================================================================
--- trunk/src/gpm-control.c (original)
+++ trunk/src/gpm-control.c Fri Jan 23 12:15:24 2009
@@ -41,12 +41,7 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <gnome-keyring.h>
#include <gconf/gconf-client.h>
-
-#ifdef HAVE_DK_POWER
- #include <dkp-client.h>
-#else
- #include <hal-device-power.h>
-#endif
+#include <dkp-client.h>
#ifdef HAVE_POLKIT
#include <polkit/polkit.h>
@@ -66,11 +61,7 @@
struct GpmControlPrivate
{
GConfClient *conf;
-#ifdef HAVE_DK_POWER
DkpClient *client;
-#else
- HalDevicePower *hal_device_power;
-#endif
};
enum {
@@ -174,13 +165,8 @@
*can = FALSE;
conf_ok = gconf_client_get_bool (control->priv->conf, GPM_CONF_CAN_SUSPEND, NULL);
-#ifdef HAVE_DK_POWER
polkit_ok = gpm_control_is_user_privileged (control, "org.freedesktop.devicekit.power.suspend");
hardware_ok = dkp_client_can_suspend (control->priv->client);
-#else
- polkit_ok = gpm_control_is_user_privileged (control, "org.freedesktop.hal.power-management.suspend");
- hardware_ok = hal_device_power_can_suspend (control->priv->hal_device_power);
-#endif
fg = gpm_control_check_foreground_console (control);
if (conf_ok && hardware_ok && polkit_ok && fg)
*can = TRUE;
@@ -208,51 +194,14 @@
*can = FALSE;
conf_ok = gconf_client_get_bool (control->priv->conf, GPM_CONF_CAN_HIBERNATE, NULL);
fg = gpm_control_check_foreground_console (control);
-#ifdef HAVE_DK_POWER
polkit_ok = gpm_control_is_user_privileged (control, "org.freedesktop.devicekit.power.hibernate");
hardware_ok = dkp_client_can_hibernate (control->priv->client);
-#else
- polkit_ok = gpm_control_is_user_privileged (control, "org.freedesktop.hal.power-management.hibernate");
- hardware_ok = hal_device_power_can_hibernate (control->priv->hal_device_power);
-#endif
if (conf_ok && hardware_ok && polkit_ok && fg)
*can = TRUE;
egg_debug ("conf=%i, polkit=%i, fg=%i, can=%i", conf_ok, polkit_ok, fg, *can);
return TRUE;
}
-#ifndef HAVE_DK_POWER
-/* convert the HAL error to a local error */
-static void
-gpm_control_convert_hal_error (GpmControl *control, GError **error)
-{
- gint code;
- gchar *message;
- if (error == NULL) {
- return;
- }
-
- /* copy out the needed data */
- code = (*error)->code;
- message = g_strdup ((*error)->message);
-
- /* clear the old HAL error */
- g_error_free (*error);
- *error = NULL;
-
- /* localize */
- if (code == 9) {
- /* DBUS security prevents sending */
- g_set_error (error, GPM_CONTROL_ERROR, GPM_CONTROL_ERROR_GENERAL,
- "%s", _("The message was not sent due to DBUS security rules"));
- } else {
- g_set_error (error, GPM_CONTROL_ERROR, GPM_CONTROL_ERROR_GENERAL,
- "%s:%s", _("General failure"), message);
- }
- g_free (message);
-}
-#endif
-
/**
* gpm_control_shutdown:
* @control: This class instance
@@ -263,18 +212,10 @@
gpm_control_shutdown (GpmControl *control, GError **error)
{
gboolean ret;
-
-#ifdef HAVE_DK_POWER
EggConsoleKit *console;
console = egg_console_kit_new ();
ret = egg_console_kit_stop (console, error);
g_object_unref (console);
-#else
- ret = hal_device_power_shutdown (control->priv->hal_device_power, error);
- if (!ret)
- gpm_control_convert_hal_error (control, error);
-#endif
-
return ret;
}
@@ -355,13 +296,7 @@
egg_debug ("emitting sleep");
g_signal_emit (control, signals [SLEEP], 0, GPM_CONTROL_ACTION_SUSPEND);
-#ifdef HAVE_DK_POWER
ret = dkp_client_suspend (control->priv->client, error);
-#else
- ret = hal_device_power_suspend (control->priv->hal_device_power, 0, error);
- if (!ret)
- gpm_control_convert_hal_error (control, error);
-#endif
egg_debug ("emitting resume");
g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_SUSPEND);
@@ -431,13 +366,7 @@
egg_debug ("emitting sleep");
g_signal_emit (control, signals [SLEEP], 0, GPM_CONTROL_ACTION_HIBERNATE);
-#ifdef HAVE_DK_POWER
ret = dkp_client_hibernate (control->priv->client, error);
-#else
- ret = hal_device_power_hibernate (control->priv->hal_device_power, error);
- if (!ret)
- gpm_control_convert_hal_error (control, error);
-#endif
egg_debug ("emitting resume");
g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_HIBERNATE);
@@ -472,11 +401,7 @@
control = GPM_CONTROL (object);
g_object_unref (control->priv->conf);
-#ifdef HAVE_DK_POWER
g_object_unref (control->priv->client);
-#else
- g_object_unref (control->priv->hal_device_power);
-#endif
g_return_if_fail (control->priv != NULL);
G_OBJECT_CLASS (gpm_control_parent_class)->finalize (object);
@@ -540,11 +465,7 @@
{
control->priv = GPM_CONTROL_GET_PRIVATE (control);
-#ifdef HAVE_DK_POWER
control->priv->client = dkp_client_new ();
-#else
- control->priv->hal_device_power = hal_device_power_new ();
-#endif
control->priv->conf = gconf_client_get_default ();
}
Modified: trunk/src/gpm-manager.c
==============================================================================
--- trunk/src/gpm-manager.c (original)
+++ trunk/src/gpm-manager.c Fri Jan 23 12:15:24 2009
@@ -40,13 +40,7 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <gconf/gconf-client.h>
#include <canberra-gtk.h>
-
-#ifdef HAVE_DK_POWER
- #include <dkp-device.h>
-#else
- #include <hal-device-power.h>
- #include <hal-manager.h>
-#endif
+#include <dkp-device.h>
#include "egg-debug.h"
#include "egg-console-kit.h"
@@ -68,12 +62,8 @@
#include "gpm-stock-icons.h"
#include "gpm-prefs-server.h"
#include "gpm-tray-icon.h"
-#ifdef HAVE_DK_POWER
- #include "gpm-engine.h"
- #include "gpm-devicekit.h"
-#else
- #include "gpm-engine-old.h"
-#endif
+#include "gpm-engine.h"
+#include "gpm-devicekit.h"
#include "gpm-feedback-widget.h"
#include "org.freedesktop.PowerManagement.Inhibit.h"
@@ -1191,11 +1181,7 @@
* gpm_engine_perhaps_recall_cb:
*/
static void
-#ifdef HAVE_DK_POWER
gpm_engine_perhaps_recall_cb (GpmEngine *engine, DkpDeviceType type, gchar *oem_vendor, gchar *website, GpmManager *manager)
-#else
-gpm_engine_perhaps_recall_cb (GpmEngine *engine, GpmCellUnitKind kind, gchar *oem_vendor, gchar *website, GpmManager *manager)
-#endif
{
g_object_set_data (G_OBJECT (manager), "recall-oem-vendor", (gpointer) g_strdup (oem_vendor));
g_object_set_data (G_OBJECT (manager), "recall-oem-website", (gpointer) g_strdup (website));
@@ -1207,11 +1193,7 @@
* gpm_engine_low_capacity_cb:
*/
static void
-#ifdef HAVE_DK_POWER
gpm_engine_low_capacity_cb (GpmEngine *engine, DkpDeviceType type, guint capacity, GpmManager *manager)
-#else
-gpm_engine_low_capacity_cb (GpmEngine *engine, GpmCellUnitKind kind, guint capacity, GpmManager *manager)
-#endif
{
/* We should notify the user if the battery has a low capacity,
* where capacity is the ratio of the last_full capacity with that of
@@ -1241,17 +1223,9 @@
* gpm_engine_low_capacity_cb:
*/
static void
-#ifdef HAVE_DK_POWER
gpm_engine_fully_charged_cb (GpmEngine *engine, DkpDeviceType type, GpmManager *manager)
-#else
-gpm_engine_fully_charged_cb (GpmEngine *engine, GpmCellUnitKind kind, GpmManager *manager)
-#endif
-{
-#ifndef HAVE_DK_POWER
- if (kind == GPM_CELL_UNIT_KIND_PRIMARY)
-#else
+{
if (type == DKP_DEVICE_TYPE_BATTERY)
-#endif
gpm_notify_fully_charged_primary (manager->priv->notify);
}
@@ -1259,23 +1233,11 @@
* gpm_engine_low_capacity_cb:
*/
static void
-#ifdef HAVE_DK_POWER
gpm_engine_discharging_cb (GpmEngine *engine, DkpDeviceType type, GpmManager *manager)
-#else
-gpm_engine_discharging_cb (GpmEngine *engine, GpmCellUnitKind kind, GpmManager *manager)
-#endif
-{
-#ifndef HAVE_DK_POWER
- if (kind == GPM_CELL_UNIT_KIND_PRIMARY)
-#else
+{
if (type == DKP_DEVICE_TYPE_BATTERY)
-#endif
gpm_notify_discharging_primary (manager->priv->notify);
-#ifndef HAVE_DK_POWER
- else if (kind == GPM_CELL_UNIT_KIND_UPS)
-#else
else if (type == DKP_DEVICE_TYPE_UPS)
-#endif
gpm_notify_discharging_ups (manager->priv->notify);
}
@@ -1309,45 +1271,13 @@
* gpm_engine_charge_low_cb:
*/
static void
-#ifdef HAVE_DK_POWER
gpm_engine_charge_low_cb (GpmEngine *engine, DkpObject *obj, GpmManager *manager)
-#else
-gpm_engine_charge_low_cb (GpmEngine *engine, GpmCellUnit *unit, GpmManager *manager)
-#endif
{
const gchar *title = NULL;
gchar *message = NULL;
gchar *remaining_text;
gchar *icon;
-#ifndef HAVE_DK_POWER
- if (unit->kind == GPM_CELL_UNIT_KIND_PRIMARY) {
- title = _("Laptop battery low");
- remaining_text = gpm_get_timestring (unit->time_discharge);
- message = g_strdup_printf (_("You have approximately <b>%s</b> of remaining battery life (%.1f%%)"),
- remaining_text, unit->percentage);
- } else if (unit->kind == GPM_CELL_UNIT_KIND_UPS) {
- title = _("UPS low");
- remaining_text = gpm_get_timestring (unit->time_discharge);
- message = g_strdup_printf (_("You have approximately <b>%s</b> of remaining UPS backup power (%.1f%%)"),
- remaining_text, unit->percentage);
- } else if (unit->kind == GPM_CELL_UNIT_KIND_MOUSE) {
- title = _("Mouse battery low");
- message = g_strdup_printf (_("The wireless mouse attached to this computer is low in power (%.1f%%)"), unit->percentage);
-
- } else if (unit->kind == GPM_CELL_UNIT_KIND_KEYBOARD) {
- title = _("Keyboard battery low");
- message = g_strdup_printf (_("The wireless keyboard attached to this computer is low in power (%.1f%%)"), unit->percentage);
-
- } else if (unit->kind == GPM_CELL_UNIT_KIND_PDA) {
- title = _("PDA battery low");
- message = g_strdup_printf (_("The PDA attached to this computer is low in power (%.1f%%)"), unit->percentage);
-
- } else if (unit->kind == GPM_CELL_UNIT_KIND_PHONE) {
- title = _("Cell phone battery low");
- message = g_strdup_printf (_("The cell phone attached to this computer is low in power (%.1f%%)"), unit->percentage);
- }
-#else
if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
title = _("Laptop battery low");
remaining_text = gpm_get_timestring (obj->time_to_empty);
@@ -1374,14 +1304,9 @@
title = _("Cell phone battery low");
message = g_strdup_printf (_("The cell phone attached to this computer is low in power (%.1f%%)"), obj->percentage);
}
-#endif
/* get correct icon */
-#ifndef HAVE_DK_POWER
- icon = gpm_cell_unit_get_icon (unit);
-#else
icon = gpm_devicekit_get_object_icon (obj);
-#endif
gpm_notify_display (manager->priv->notify, title, message, GPM_NOTIFY_TIMEOUT_LONG, icon, GPM_NOTIFY_URGENCY_NORMAL);
gpm_manager_play (manager, GPM_MANAGER_SOUND_BATTERY_LOW, TRUE);
g_free (icon);
@@ -1395,16 +1320,6 @@
gpm_manager_get_time_until_action_text (GpmManager *manager)
{
guint time_s = 0;
-#ifndef HAVE_DK_POWER
- GpmEngineCollection *collection;
-
- collection = gpm_engine_get_collection (manager->priv->engine);
-
- /* we should tell the user how much time they have */
- time_s = gpm_cell_array_get_time_until_action (collection->primary);
- if (time_s == 0)
- return g_strdup (_("a short time"));
-#endif
return gpm_get_timestring (time_s);
}
@@ -1412,11 +1327,7 @@
* gpm_engine_charge_critical_cb:
*/
static void
-#ifdef HAVE_DK_POWER
gpm_engine_charge_critical_cb (GpmEngine *engine, DkpObject *obj, GpmManager *manager)
-#else
-gpm_engine_charge_critical_cb (GpmEngine *engine, GpmCellUnit *unit, GpmManager *manager)
-#endif
{
const gchar *title = NULL;
gchar *message = NULL;
@@ -1426,65 +1337,6 @@
gchar *icon;
gchar *time_text;
-#ifndef HAVE_DK_POWER
- if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
- title = _("Laptop battery critically low");
- remaining_text = gpm_get_timestring (unit->time_discharge);
- time_text = gpm_manager_get_time_until_action_text (manager);
-
- /* we have to do different warnings depending on the policy */
- action = gconf_client_get_string (manager->priv->conf, GPM_CONF_ACTIONS_CRITICAL_BATT, NULL);
- if (action == NULL) {
- egg_warning ("schema invalid!");
- action = g_strdup (ACTION_NOTHING);
- }
-
- /* use different text for different actions */
- if (strcmp (action, ACTION_NOTHING) == 0)
- action_text = g_strdup (_("Plug in your AC adapter to avoid losing data."));
- else if (strcmp (action, ACTION_SUSPEND) == 0)
- action_text = g_strdup_printf (_("This computer will suspend in %s if the AC is not connected."), time_text);
- else if (strcmp (action, ACTION_HIBERNATE) == 0)
- action_text = g_strdup_printf (_("This computer will hibernate in %s if the AC is not connected."), time_text);
- else if (strcmp (action, ACTION_SHUTDOWN) == 0)
- action_text = g_strdup_printf (_("This computer will shutdown in %s if the AC is not connected."), time_text);
-
- message = g_strdup_printf (_("You have approximately <b>%s</b> of remaining battery life (%.1f%%). %s"),
- remaining_text, unit->percentage, action_text);
-
- g_free (action);
- g_free (action_text);
- g_free (remaining_text);
- g_free (time_text);
- } else if (unit->kind == GPM_CELL_UNIT_KIND_UPS) {
- title = _("UPS critically low");
- remaining_text = gpm_get_timestring (unit->time_discharge);
- message = g_strdup_printf (_("You have approximately <b>%s</b> of remaining UPS power (%.1f%%). "
- "Restore AC power to your computer to avoid losing data."),
- remaining_text, unit->percentage);
- g_free (remaining_text);
- } else if (unit->kind == GPM_CELL_UNIT_KIND_MOUSE) {
- title = _("Mouse battery low");
- message = g_strdup_printf (_("The wireless mouse attached to this computer is very low in power (%.1f%%). "
- "This device will soon stop functioning if not charged."),
- unit->percentage);
- } else if (unit->kind == GPM_CELL_UNIT_KIND_KEYBOARD) {
- title = _("Keyboard battery low");
- message = g_strdup_printf (_("The wireless keyboard attached to this computer is very low in power (%.1f%%). "
- "This device will soon stop functioning if not charged."),
- unit->percentage);
- } else if (unit->kind == GPM_CELL_UNIT_KIND_PDA) {
- title = _("PDA battery low");
- message = g_strdup_printf (_("The PDA attached to this computer is very low in power (%.1f%%). "
- "This device will soon stop functioning if not charged."),
- unit->percentage);
- } else if (unit->kind == GPM_CELL_UNIT_KIND_PHONE) {
- title = _("Cell phone battery low");
- message = g_strdup_printf (_("Your cell phone is very low in power (%.1f%%). "
- "This device will soon stop functioning if not charged."),
- unit->percentage);
- }
-#else
if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
title = _("Laptop battery critically low");
remaining_text = gpm_get_timestring (obj->time_to_empty);
@@ -1542,14 +1394,9 @@
"This device will soon stop functioning if not charged."),
obj->percentage);
}
-#endif
/* get correct icon */
-#ifndef HAVE_DK_POWER
- icon = gpm_cell_unit_get_icon (unit);
-#else
icon = gpm_devicekit_get_object_icon (obj);
-#endif
gpm_notify_display (manager->priv->notify, title, message, GPM_NOTIFY_TIMEOUT_LONG, icon, GPM_NOTIFY_URGENCY_CRITICAL);
gpm_manager_play (manager, GPM_MANAGER_SOUND_BATTERY_LOW, TRUE);
g_free (icon);
@@ -1560,22 +1407,14 @@
* gpm_engine_charge_action_cb:
*/
static void
-#ifdef HAVE_DK_POWER
gpm_engine_charge_action_cb (GpmEngine *engine, DkpObject *obj, GpmManager *manager)
-#else
-gpm_engine_charge_action_cb (GpmEngine *engine, GpmCellUnit *unit, GpmManager *manager)
-#endif
{
const gchar *title = NULL;
gchar *action;
gchar *message = NULL;
gchar *icon;
-#ifndef HAVE_DK_POWER
- if (unit->kind == GPM_CELL_UNIT_KIND_PRIMARY) {
-#else
if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
-#endif
title = _("Laptop battery critically low");
/* we have to do different warnings depending on the policy */
@@ -1607,11 +1446,7 @@
/* wait 10 seconds for user-panic */
g_timeout_add_seconds (10, (GSourceFunc) manager_critical_action_do, manager);
-#ifndef HAVE_DK_POWER
- } else if (unit->kind == GPM_CELL_UNIT_KIND_UPS) {
-#else
} else if (obj->type == DKP_DEVICE_TYPE_UPS) {
-#endif
title = _("UPS critically low");
/* we have to do different warnings depending on the policy */
@@ -1640,11 +1475,7 @@
return;
/* get correct icon */
-#ifndef HAVE_DK_POWER
- icon = gpm_cell_unit_get_icon (unit);
-#else
icon = gpm_devicekit_get_object_icon (obj);
-#endif
gpm_notify_display (manager->priv->notify,
title, message, GPM_NOTIFY_TIMEOUT_LONG,
icon, GPM_NOTIFY_URGENCY_CRITICAL);
@@ -1659,9 +1490,6 @@
static void
has_inhibit_changed_cb (GpmInhibit *inhibit, gboolean has_inhibit, GpmManager *manager)
{
-#ifndef HAVE_DK_POWER
- HalManager *hal_manager;
-#endif
gboolean is_laptop = FALSE;
gboolean show_inhibit_lid;
gchar *action = NULL;
@@ -1677,11 +1505,7 @@
if (show_inhibit_lid == FALSE)
return;
-#ifndef HAVE_DK_POWER
- hal_manager = hal_manager_new ();
- is_laptop = hal_manager_is_laptop (hal_manager);
- g_object_unref (hal_manager);
-#endif
+/* FIXME: detect if laptop */
/* we don't warn for desktops, as they do not have a lid... */
if (is_laptop == FALSE)
@@ -1758,9 +1582,6 @@
{
gboolean check_type_cpu;
DBusGConnection *connection;
-#ifndef HAVE_DK_POWER
- GpmEngineCollection *collection;
-#endif
GError *error = NULL;
gboolean on_ac;
guint version;
@@ -1905,11 +1726,6 @@
/* update ac throttle */
on_ac = gpm_ac_adapter_is_present (manager->priv->ac_adapter);
update_ac_throttle (manager, on_ac);
-
-#ifndef HAVE_DK_POWER
- collection = gpm_engine_get_collection (manager->priv->engine);
- gpm_tray_icon_set_collection_data (manager->priv->tray_icon, collection);
-#endif
}
/**
Modified: trunk/src/gpm-self-test.c
==============================================================================
--- trunk/src/gpm-self-test.c (original)
+++ trunk/src/gpm-self-test.c Fri Jan 23 12:15:24 2009
@@ -66,11 +66,6 @@
egg_array_float_test (test);
gpm_common_test (test);
-#ifndef HAVE_DK_POWER
- gpm_cell_unit_test (test);
- gpm_cell_test (test);
- gpm_cell_test_array (test);
-#endif
gpm_inhibit_test (test);
gpm_phone_test (test);
// gpm_graph_widget_test (test);
Modified: trunk/src/gpm-tray-icon.c
==============================================================================
--- trunk/src/gpm-tray-icon.c (original)
+++ trunk/src/gpm-tray-icon.c Fri Jan 23 12:15:24 2009
@@ -40,19 +40,14 @@
#include <gtk/gtk.h>
#include <gtk/gtkstatusicon.h>
#include <gconf/gconf-client.h>
+#include <dkp-device.h>
-#ifdef HAVE_DK_POWER
- #include <dkp-device.h>
-#endif
-
-#ifdef HAVE_DK_POWER
- #include "gpm-devicekit.h"
- #include "gpm-engine.h"
-#endif
+#include "egg-debug.h"
+#include "gpm-devicekit.h"
+#include "gpm-engine.h"
#include "gpm-control.h"
#include "gpm-common.h"
-#include "egg-debug.h"
#include "gpm-notify.h"
#include "gpm-cell-array.h"
#include "gpm-cell.h"
@@ -69,11 +64,7 @@
GConfClient *conf;
GpmControl *control;
GpmNotify *notify;
-#ifndef HAVE_DK_POWER
- GpmEngineCollection *collection;
-#else
GpmEngine *engine;
-#endif
GtkStatusIcon *status_icon;
gboolean is_visible;
gboolean show_suspend;
@@ -96,19 +87,6 @@
G_DEFINE_TYPE (GpmTrayIcon, gpm_tray_icon, G_TYPE_OBJECT)
-#ifndef HAVE_DK_POWER
-/**
- * gpm_tray_icon_set_collection_data:
- **/
-gboolean
-gpm_tray_icon_set_collection_data (GpmTrayIcon *icon, GpmEngineCollection *collection)
-{
- g_return_val_if_fail (GPM_IS_TRAY_ICON (icon), FALSE);
- icon->priv->collection = collection;
- return TRUE;
-}
-#endif
-
/**
* gpm_tray_icon_enable_suspend:
* @icon: This TrayIcon class instance
@@ -218,20 +196,11 @@
gchar *description = NULL;
GtkWidget *dialog;
GtkWidget *image;
-#ifndef HAVE_DK_POWER
- GpmCell *cell;
-#else
const DkpObject *obj;
const gchar *object_path;
- DkpDevice *device = NULL;
+ DkpDevice *device = NULL;
gboolean ret;
-#endif
-#ifndef HAVE_DK_POWER
- cell = g_object_get_data (G_OBJECT (item), "cell");
- description = gpm_cell_get_description (cell);
- icon_name = gpm_cell_get_icon (cell);
-#else
object_path = g_object_get_data (G_OBJECT (item), "object-path");
egg_debug ("object_path=%s", object_path);
if (object_path == NULL) {
@@ -252,7 +221,6 @@
obj = dkp_device_get_object (device);
icon_name = gpm_devicekit_get_object_icon (obj);
description = gpm_devicekit_get_object_description (obj);
-#endif
image = gtk_image_new ();
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -269,10 +237,8 @@
gtk_widget_destroy (GTK_WIDGET (dialog));
out:
-#ifdef HAVE_DK_POWER
if (device != NULL)
g_object_unref (device);
-#endif
g_free (description);
g_free (icon_name);
}
@@ -515,53 +481,6 @@
G_CALLBACK (gpm_tray_icon_popup_cleared_cd), icon);
}
-#ifndef HAVE_DK_POWER
-/**
- * gpm_tray_icon_add_device:
- *
- * Add all the selected type of devices to the menu to form "drop down" info.
- **/
-static guint
-gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, GpmCellArray *array)
-{
- GtkWidget *item;
- GtkWidget *image;
- GpmCell *cell;
- GpmCellUnit *unit;
- guint i;
- gchar *icon_name;
- gchar *label;
- const gchar *desc;
- guint len;
-
- len = gpm_cell_array_get_num_cells (array);
- for (i=0; i<len; i++) {
- cell = gpm_cell_array_get_cell (array, i);
- unit = gpm_cell_get_unit (cell);
-
- egg_debug ("adding device '%i'", i);
-
- /* generate the label */
- desc = gpm_cell_unit_get_kind_localised (unit, FALSE);
- label = g_strdup_printf ("%s (%.1f%%)", desc, unit->percentage);
- item = gtk_image_menu_item_new_with_label (label);
- g_free (label);
-
- /* generate the image */
- icon_name = gpm_cell_unit_get_icon (unit);
- image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- g_free (icon_name);
-
- /* callback with the UDI and add the the menu */
- g_signal_connect (G_OBJECT (item), "activate",
- G_CALLBACK (gpm_tray_icon_show_info_cb), icon);
- g_object_set_data (G_OBJECT (item), "cell", (gpointer) cell);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- }
- return len;
-}
-#else
/**
* gpm_tray_icon_add_device:
**/
@@ -610,7 +529,6 @@
}
return added;
}
-#endif
/**
* gpm_tray_icon_activate_cb:
@@ -626,20 +544,10 @@
GtkWidget *item;
GtkWidget *image;
guint dev_cnt = 0;
-#ifdef HAVE_DK_POWER
const GPtrArray *array;
-#endif
egg_debug ("icon left clicked");
/* add all device types to the drop down menu */
-#ifndef HAVE_DK_POWER
- dev_cnt += gpm_tray_icon_add_device (icon, menu, icon->priv->collection->primary);
- dev_cnt += gpm_tray_icon_add_device (icon, menu, icon->priv->collection->ups);
- dev_cnt += gpm_tray_icon_add_device (icon, menu, icon->priv->collection->phone);
- dev_cnt += gpm_tray_icon_add_device (icon, menu, icon->priv->collection->mouse);
- dev_cnt += gpm_tray_icon_add_device (icon, menu, icon->priv->collection->keyboard);
- dev_cnt += gpm_tray_icon_add_device (icon, menu, icon->priv->collection->pda);
-#else
array = gpm_engine_get_devices (icon->priv->engine);
dev_cnt += gpm_tray_icon_add_device (icon, menu, array, DKP_DEVICE_TYPE_BATTERY);
dev_cnt += gpm_tray_icon_add_device (icon, menu, array, DKP_DEVICE_TYPE_UPS);
@@ -648,7 +556,7 @@
dev_cnt += gpm_tray_icon_add_device (icon, menu, array, DKP_DEVICE_TYPE_PDA);
dev_cnt += gpm_tray_icon_add_device (icon, menu, array, DKP_DEVICE_TYPE_PHONE);
g_ptr_array_foreach ((GPtrArray*)array, (GFunc) g_object_unref, NULL);
-#endif
+
/* nothing to display! */
if (dev_cnt == 0 && !icon->priv->show_suspend && !icon->priv->show_hibernate)
return;
@@ -741,11 +649,8 @@
icon->priv = GPM_TRAY_ICON_GET_PRIVATE (icon);
-#ifndef HAVE_DK_POWER
- icon->priv->collection = NULL;
-#else
icon->priv->engine = gpm_engine_new ();
-#endif
+
/* use libnotify */
icon->priv->notify = gpm_notify_new ();
@@ -803,9 +708,7 @@
g_object_unref (tray_icon->priv->notify);
g_object_unref (tray_icon->priv->control);
g_object_unref (tray_icon->priv->status_icon);
-#ifndef HAVE_DK_POWER
g_object_unref (tray_icon->priv->engine);
-#endif
g_return_if_fail (tray_icon->priv != NULL);
G_OBJECT_CLASS (gpm_tray_icon_parent_class)->finalize (object);
Modified: trunk/src/gpm-tray-icon.h
==============================================================================
--- trunk/src/gpm-tray-icon.h (original)
+++ trunk/src/gpm-tray-icon.h Fri Jan 23 12:15:24 2009
@@ -24,9 +24,6 @@
#define __GPM_TRAY_ICON_H
#include <glib-object.h>
-#ifndef HAVE_DK_POWER
-#include "gpm-engine-old.h"
-#endif
G_BEGIN_DECLS
@@ -59,10 +56,6 @@
const gchar *tooltip);
gboolean gpm_tray_icon_set_icon (GpmTrayIcon *icon,
const gchar *filename);
-#ifndef HAVE_DK_POWER
-gboolean gpm_tray_icon_set_collection_data (GpmTrayIcon *icon,
- GpmEngineCollection *collection);
-#endif
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]