[Xfce4-commits] <xfce4-power-manager:master> Fix dump data when xfpm is not running.
Ali Abdallah
noreply at xfce.org
Sat Jan 30 02:18:23 CET 2010
Updating branch refs/heads/master
to b4211ea84016787e1fa4350a19ff1562e101d970 (commit)
from f867843829bf5d2acf34f8d75a93033558e944e3 (commit)
commit b4211ea84016787e1fa4350a19ff1562e101d970
Author: Ali Abdallah <ali at ali-xfce.org>
Date: Mon Nov 9 15:15:43 2009 +0100
Fix dump data when xfpm is not running.
configure.ac.in | 2 +-
src/xfpm-backlight.c | 8 ++-
src/xfpm-battery.c | 2 +-
src/xfpm-main.c | 71 +++++++++++++++++-----------
src/xfpm-manager.c | 128 ++++++++++++++++++++++++++-----------------------
src/xfpm-manager.h | 2 +
6 files changed, 120 insertions(+), 93 deletions(-)
diff --git a/configure.ac.in b/configure.ac.in
index 2d80340..8ca5377 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -54,7 +54,7 @@ m4_define([dbus_minimum_version], [0.60])
m4_define([dbus_glib_minimum_version], [0.70])
m4_define([xfconf_minimum_version], [4.6.0])
-m4_define([libxfce4ui_minimum_version],[4.6.0])
+m4_define([libxfce4ui_minimum_version],[4.7.0])
m4_define([libxfce4util_minimum_version],[4.6.0])
m4_define([libxfce4panel_minimum_version],[4.6.0])
diff --git a/src/xfpm-backlight.c b/src/xfpm-backlight.c
index ce64805..31055da 100644
--- a/src/xfpm-backlight.c
+++ b/src/xfpm-backlight.c
@@ -38,6 +38,7 @@
#include "xfpm-button.h"
#include "xfpm-brightness.h"
#include "xfpm-debug.h"
+#include "xfpm-icons.h"
static void xfpm_backlight_finalize (GObject *object);
@@ -86,7 +87,7 @@ xfpm_backlight_dim_brightness (XfpmBacklight *backlight)
g_warning ("Unable to get current brightness level");
return;
}
- XFPM_DEBUG ("Current brightness level : %u", backlight->priv->last_level);
+ XFPM_DEBUG ("Current brightness level before dimming : %u", backlight->priv->last_level);
xfpm_brightness_dim_down (backlight->priv->brightness);
}
@@ -200,7 +201,7 @@ xfpm_backlight_create_popup (XfpmBacklight *backlight)
gtk_container_add (GTK_CONTAINER (backlight->priv->window), align);
gtk_container_add (GTK_CONTAINER (align), vbox);
- img = gtk_image_new_from_icon_name ("xfpm-brightness-lcd", GTK_ICON_SIZE_DIALOG);
+ img = gtk_image_new_from_icon_name (XFPM_DISPLAY_BRIGHTNESS_ICON, GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (vbox), img, TRUE, TRUE, 0);
@@ -286,6 +287,7 @@ xfpm_backlight_alarm_timeout_cb (XfpmIdle *idle, guint id, XfpmBacklight *backli
static void
xfpm_backlight_reset_cb (XfpmIdle *idle, XfpmBacklight *backlight)
{
+ XFPM_DEBUG ("Alarm reset, setting level to %i", backlight->priv->last_level);
xfpm_brightness_set_level (backlight->priv->brightness, backlight->priv->last_level);
}
@@ -358,7 +360,7 @@ xfpm_backlight_brightness_on_battery_settings_changed (XfpmBacklight *backlight)
BRIGHTNESS_ON_BATTERY, &timeout_on_battery,
NULL);
- XFPM_DEBUG ("Alarm on ac timeout changed %u", timeout_on_battery);
+ XFPM_DEBUG ("Alarm on battery timeout changed %u", timeout_on_battery);
if ( timeout_on_battery == ALARM_DISABLED )
{
diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c
index df8b7c6..04705c1 100644
--- a/src/xfpm-battery.c
+++ b/src/xfpm-battery.c
@@ -365,7 +365,7 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
if ( battery->priv->time_to_empty != 0 )
{
est_time_str = xfpm_battery_get_time_string (battery->priv->time_to_empty);
- tip = g_strdup_printf (_("%s\nYour %s is discharging (%i%%)\n estimate time left is %s."),
+ tip = g_strdup_printf (_("%s\nYour %s is discharging (%i%%)\nestimated time left is %s."),
power_status,
battery_name,
battery->priv->percentage,
diff --git a/src/xfpm-main.c b/src/xfpm-main.c
index a106f50..766a001 100644
--- a/src/xfpm-main.c
+++ b/src/xfpm-main.c
@@ -77,12 +77,8 @@ xfpm_bool_to_local_string (gboolean value)
}
static void
-xfpm_dump (DBusGConnection *bus)
+xfpm_dump (GHashTable *hash)
{
- DBusGProxy *proxy;
- GError *error = NULL;
- GHashTable *hash;
-
gboolean has_battery;
gboolean auth_suspend;
gboolean auth_hibernate;
@@ -97,21 +93,6 @@ xfpm_dump (DBusGConnection *bus)
gboolean can_spin_down;
gboolean devkit_disk;
- proxy = dbus_g_proxy_new_for_name (bus,
- "org.xfce.PowerManager",
- "/org/xfce/PowerManager",
- "org.xfce.Power.Manager");
-
- xfpm_manager_dbus_client_get_config (proxy,
- &hash,
- &error);
-
- if ( error )
- {
- g_error ("%s", error->message);
- exit (EXIT_FAILURE);
- }
-
has_battery = xfpm_string_to_bool (g_hash_table_lookup (hash, "has-battery"));
has_lid = xfpm_string_to_bool (g_hash_table_lookup (hash, "has-lid"));
can_suspend = xfpm_string_to_bool (g_hash_table_lookup (hash, "can-suspend"));
@@ -125,9 +106,6 @@ xfpm_dump (DBusGConnection *bus)
can_shutdown = xfpm_string_to_bool (g_hash_table_lookup (hash, "can-shutdown"));
can_spin_down = xfpm_string_to_bool (g_hash_table_lookup (hash, "can-spin"));
devkit_disk = xfpm_string_to_bool (g_hash_table_lookup (hash, "devkit-disk"));
-
- dbus_g_connection_unref (bus);
- g_object_unref (proxy);
g_print ("---------------------------------------------------\n");
g_print (" Xfce power manager version %s\n", VERSION);
@@ -193,8 +171,36 @@ xfpm_dump (DBusGConnection *bus)
xfpm_bool_to_local_string (has_lid));
}
+static void
+xfpm_dump_remote (DBusGConnection *bus)
+{
+ DBusGProxy *proxy;
+ GError *error = NULL;
+ GHashTable *hash;
+
+ proxy = dbus_g_proxy_new_for_name (bus,
+ "org.xfce.PowerManager",
+ "/org/xfce/PowerManager",
+ "org.xfce.Power.Manager");
+
+ xfpm_manager_dbus_client_get_config (proxy,
+ &hash,
+ &error);
+
+ g_object_unref (proxy);
+
+ if ( error )
+ {
+ g_error ("%s", error->message);
+ exit (EXIT_FAILURE);
+ }
+
+ xfpm_dump (hash);
+ g_hash_table_destroy (hash);
+}
+
static void G_GNUC_NORETURN
-xfpm_start (DBusGConnection *bus, const gchar *client_id)
+xfpm_start (DBusGConnection *bus, const gchar *client_id, gboolean dump)
{
XfpmManager *manager;
GError *error = NULL;
@@ -224,6 +230,16 @@ xfpm_start (DBusGConnection *bus, const gchar *client_id)
}
xfpm_manager_start (manager);
+
+ if ( dump )
+ {
+ GHashTable *hash;
+ hash = xfpm_manager_get_config (manager);
+ xfpm_dump (hash);
+ g_hash_table_destroy (hash);
+ }
+
+
gtk_main ();
g_object_unref (manager);
@@ -362,7 +378,7 @@ int main (int argc, char **argv)
!xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus), "org.freedesktop.PowerManagement"))
{
g_print ("Xfce power manager is not running\n");
- xfpm_start (bus, client_id);
+ xfpm_start (bus, client_id, dump);
}
proxy = dbus_g_proxy_new_for_name (bus,
@@ -391,7 +407,7 @@ int main (int argc, char **argv)
if (xfpm_dbus_name_has_owner (dbus_g_connection_get_connection (bus),
"org.xfce.PowerManager"))
{
- xfpm_dump (bus);
+ xfpm_dump_remote (bus);
return EXIT_SUCCESS;
}
}
@@ -412,8 +428,7 @@ int main (int argc, char **argv)
}
else
{
- xfpm_start (bus, client_id);
- xfpm_dump (bus);
+ xfpm_start (bus, client_id, dump);
}
return EXIT_SUCCESS;
diff --git a/src/xfpm-manager.c b/src/xfpm-manager.c
index 0edcb3a..d505ebd 100644
--- a/src/xfpm-manager.c
+++ b/src/xfpm-manager.c
@@ -578,6 +578,73 @@ void xfpm_manager_stop (XfpmManager *manager)
xfpm_manager_quit (manager);
}
+GHashTable *xfpm_manager_get_config (XfpmManager *manager)
+{
+ GHashTable *hash;
+
+ guint8 mapped_buttons;
+ gboolean auth_hibernate = FALSE;
+ gboolean auth_suspend = FALSE;
+ gboolean can_suspend = FALSE;
+ gboolean can_hibernate = FALSE;
+ gboolean has_sleep_button = FALSE;
+ gboolean has_hibernate_button = FALSE;
+ gboolean has_power_button = FALSE;
+ gboolean has_battery = TRUE;
+ gboolean has_lcd_brightness = TRUE;
+ gboolean can_shutdown = TRUE;
+ gboolean has_lid = FALSE;
+ gboolean can_spin = FALSE;
+ gboolean devkit_disk = FALSE;
+
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ g_object_get (G_OBJECT (manager->priv->console),
+ "can-shutdown", &can_shutdown,
+ NULL);
+
+ g_object_get (G_OBJECT (manager->priv->dkp),
+ "auth-suspend", &auth_suspend,
+ "auth-hibernate", &auth_hibernate,
+ "can-suspend", &can_suspend,
+ "can-hibernate", &can_hibernate,
+ "has-lid", &has_lid,
+ NULL);
+
+ can_spin = xfpm_disks_get_can_spin (manager->priv->disks);
+ devkit_disk = xfpm_disks_kit_is_running (manager->priv->disks);
+
+ has_battery = xfpm_dkp_has_battery (manager->priv->dkp);
+ has_lcd_brightness = xfpm_backlight_has_hw (manager->priv->backlight);
+
+ mapped_buttons = xfpm_button_get_mapped (manager->priv->button);
+
+ if ( mapped_buttons & SLEEP_KEY )
+ has_sleep_button = TRUE;
+ if ( mapped_buttons & HIBERNATE_KEY )
+ has_hibernate_button = TRUE;
+ if ( mapped_buttons & POWER_KEY )
+ has_power_button = TRUE;
+
+ g_hash_table_insert (hash, g_strdup ("sleep-button"), g_strdup (xfpm_bool_to_string (has_sleep_button)));
+ g_hash_table_insert (hash, g_strdup ("power-button"), g_strdup (xfpm_bool_to_string (has_power_button)));
+ g_hash_table_insert (hash, g_strdup ("hibernate-button"), g_strdup (xfpm_bool_to_string (has_hibernate_button)));
+ g_hash_table_insert (hash, g_strdup ("auth-suspend"), g_strdup (xfpm_bool_to_string (auth_suspend)));
+ g_hash_table_insert (hash, g_strdup ("auth-hibernate"), g_strdup (xfpm_bool_to_string (auth_hibernate)));
+ g_hash_table_insert (hash, g_strdup ("can-suspend"), g_strdup (xfpm_bool_to_string (can_suspend)));
+ g_hash_table_insert (hash, g_strdup ("can-hibernate"), g_strdup (xfpm_bool_to_string (can_hibernate)));
+ g_hash_table_insert (hash, g_strdup ("can-shutdown"), g_strdup (xfpm_bool_to_string (can_shutdown)));
+
+ g_hash_table_insert (hash, g_strdup ("has-battery"), g_strdup (xfpm_bool_to_string (has_battery)));
+ g_hash_table_insert (hash, g_strdup ("has-lid"), g_strdup (xfpm_bool_to_string (has_lid)));
+ g_hash_table_insert (hash, g_strdup ("can-spin"), g_strdup (xfpm_bool_to_string (can_spin)));
+ g_hash_table_insert (hash, g_strdup ("devkit-disk"), g_strdup (xfpm_bool_to_string (devkit_disk)));
+
+ g_hash_table_insert (hash, g_strdup ("has-brightness"), g_strdup (xfpm_bool_to_string (has_lcd_brightness)));
+
+ return hash;
+}
+
/*
*
* DBus server implementation
@@ -643,66 +710,7 @@ static gboolean xfpm_manager_dbus_get_config (XfpmManager *manager,
GError **error)
{
- guint8 mapped_buttons;
- gboolean auth_hibernate = FALSE;
- gboolean auth_suspend = FALSE;
- gboolean can_suspend = FALSE;
- gboolean can_hibernate = FALSE;
- gboolean has_sleep_button = FALSE;
- gboolean has_hibernate_button = FALSE;
- gboolean has_power_button = FALSE;
- gboolean has_battery = TRUE;
- gboolean has_lcd_brightness = TRUE;
- gboolean can_shutdown = TRUE;
- gboolean has_lid = FALSE;
- gboolean can_spin = FALSE;
- gboolean devkit_disk = FALSE;
-
- *OUT_config = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
- g_object_get (G_OBJECT (manager->priv->console),
- "can-shutdown", &can_shutdown,
- NULL);
-
- g_object_get (G_OBJECT (manager->priv->dkp),
- "auth-suspend", &auth_suspend,
- "auth-hibernate", &auth_hibernate,
- "can-suspend", &can_suspend,
- "can-hibernate", &can_hibernate,
- "has-lid", &has_lid,
- NULL);
-
- can_spin = xfpm_disks_get_can_spin (manager->priv->disks);
- devkit_disk = xfpm_disks_kit_is_running (manager->priv->disks);
-
- has_battery = xfpm_dkp_has_battery (manager->priv->dkp);
- has_lcd_brightness = xfpm_backlight_has_hw (manager->priv->backlight);
-
- mapped_buttons = xfpm_button_get_mapped (manager->priv->button);
-
- if ( mapped_buttons & SLEEP_KEY )
- has_sleep_button = TRUE;
- if ( mapped_buttons & HIBERNATE_KEY )
- has_hibernate_button = TRUE;
- if ( mapped_buttons & POWER_KEY )
- has_power_button = TRUE;
-
- g_hash_table_insert (*OUT_config, g_strdup ("sleep-button"), g_strdup (xfpm_bool_to_string (has_sleep_button)));
- g_hash_table_insert (*OUT_config, g_strdup ("power-button"), g_strdup (xfpm_bool_to_string (has_power_button)));
- g_hash_table_insert (*OUT_config, g_strdup ("hibernate-button"), g_strdup (xfpm_bool_to_string (has_hibernate_button)));
- g_hash_table_insert (*OUT_config, g_strdup ("auth-suspend"), g_strdup (xfpm_bool_to_string (auth_suspend)));
- g_hash_table_insert (*OUT_config, g_strdup ("auth-hibernate"), g_strdup (xfpm_bool_to_string (auth_hibernate)));
- g_hash_table_insert (*OUT_config, g_strdup ("can-suspend"), g_strdup (xfpm_bool_to_string (can_suspend)));
- g_hash_table_insert (*OUT_config, g_strdup ("can-hibernate"), g_strdup (xfpm_bool_to_string (can_hibernate)));
- g_hash_table_insert (*OUT_config, g_strdup ("can-shutdown"), g_strdup (xfpm_bool_to_string (can_shutdown)));
-
- g_hash_table_insert (*OUT_config, g_strdup ("has-battery"), g_strdup (xfpm_bool_to_string (has_battery)));
- g_hash_table_insert (*OUT_config, g_strdup ("has-lid"), g_strdup (xfpm_bool_to_string (has_lid)));
- g_hash_table_insert (*OUT_config, g_strdup ("can-spin"), g_strdup (xfpm_bool_to_string (can_spin)));
- g_hash_table_insert (*OUT_config, g_strdup ("devkit-disk"), g_strdup (xfpm_bool_to_string (devkit_disk)));
-
- g_hash_table_insert (*OUT_config, g_strdup ("has-brightness"), g_strdup (xfpm_bool_to_string (has_lcd_brightness)));
-
+ *OUT_config = xfpm_manager_get_config (manager);
return TRUE;
}
diff --git a/src/xfpm-manager.h b/src/xfpm-manager.h
index 66153cd..9cca308 100644
--- a/src/xfpm-manager.h
+++ b/src/xfpm-manager.h
@@ -55,6 +55,8 @@ void xfpm_manager_start (XfpmManager *manager);
void xfpm_manager_stop (XfpmManager *manager);
+GHashTable *xfpm_manager_get_config (XfpmManager *manager);
+
G_END_DECLS
#endif /* __XFPM_MANAGER_H */
More information about the Xfce4-commits
mailing list