[Goodies-commits] r6879 - in xfce4-power-manager/trunk: . libxfpm settings src
Ali Abdallah
aliov at xfce.org
Tue Mar 10 21:13:44 CET 2009
Author: aliov
Date: 2009-03-10 20:13:44 +0000 (Tue, 10 Mar 2009)
New Revision: 6879
Modified:
xfce4-power-manager/trunk/ChangeLog
xfce4-power-manager/trunk/libxfpm/xfpm-common.c
xfce4-power-manager/trunk/libxfpm/xfpm-common.h
xfce4-power-manager/trunk/settings/xfpm-settings.c
xfce4-power-manager/trunk/settings/xfpm-settings.glade
xfce4-power-manager/trunk/src/xfpm-engine.c
xfce4-power-manager/trunk/src/xfpm-supply.c
Log:
properties shutdown,suspend and hibernate are noe strings in xfce4-power-manager channel configuration
Modified: xfce4-power-manager/trunk/ChangeLog
===================================================================
--- xfce4-power-manager/trunk/ChangeLog 2009-03-10 12:24:36 UTC (rev 6878)
+++ xfce4-power-manager/trunk/ChangeLog 2009-03-10 20:13:44 UTC (rev 6879)
@@ -1,4 +1,7 @@
+2009-03-10 21:13 Ali aliov at xfce.org
+ * : properties shutdown,suspend and hibernate are noe strings in xfce4-power-manager channel configuration
+
2009-03-10 13:24 Ali aliov at xfce.org
* : Handle critical battery charge+ update on the notifications
Modified: xfce4-power-manager/trunk/libxfpm/xfpm-common.c
===================================================================
--- xfce4-power-manager/trunk/libxfpm/xfpm-common.c 2009-03-10 12:24:36 UTC (rev 6878)
+++ xfce4-power-manager/trunk/libxfpm/xfpm-common.c 2009-03-10 20:13:44 UTC (rev 6879)
@@ -24,6 +24,7 @@
#include <libxfce4util/libxfce4util.h>
#include "xfpm-common.h"
+#include "xfpm-string.h"
static void
xfpm_link_browser(GtkAboutDialog *about,const gchar *link,gpointer data)
@@ -64,6 +65,39 @@
return icon;
}
+/*
+ * Map of int to strings shutdown values
+ */
+const gchar *xfpm_int_to_shutdown_string (gint val)
+{
+ if ( val == 0 )
+ return "Nothing";
+ else if ( val == 1)
+ return "Suspend";
+ else if ( val == 2)
+ return "Hibernate";
+ else if ( val == 3)
+ return "Shutdown";
+
+ return "Invalid";
+}
+
+gint xfpm_shutdown_string_to_int (const gchar *string)
+{
+ if ( xfpm_strequal("Nothing", string) )
+ return 0;
+ else if ( xfpm_strequal("Suspend", string) )
+ return 1;
+ else if (xfpm_strequal("Hibernate", string) )
+ return 2;
+ else if (xfpm_strequal("Shutdown", string) )
+ return 3;
+
+ return -1; /* error here */
+
+
+}
+
void
xfpm_lock_screen(void)
{
Modified: xfce4-power-manager/trunk/libxfpm/xfpm-common.h
===================================================================
--- xfce4-power-manager/trunk/libxfpm/xfpm-common.h 2009-03-10 12:24:36 UTC (rev 6878)
+++ xfce4-power-manager/trunk/libxfpm/xfpm-common.h 2009-03-10 20:13:44 UTC (rev 6879)
@@ -29,14 +29,18 @@
G_BEGIN_DECLS
-GdkPixbuf* xfpm_load_icon (const gchar *icon_name,
- gint size);
-void xfpm_lock_screen (void);
-void xfpm_preferences (void);
-void xfpm_help (void);
-void xfpm_about (GtkWidget *widget,
- gpointer data);
+GdkPixbuf* xfpm_load_icon (const gchar *icon_name,
+ gint size);
+
+const gchar *xfpm_int_to_shutdown_string (gint val);
+gint xfpm_shutdown_string_to_int (const gchar *string);
+void xfpm_lock_screen (void);
+void xfpm_preferences (void);
+void xfpm_help (void);
+void xfpm_about (GtkWidget *widget,
+ gpointer data);
+
G_END_DECLS
#endif /* XFPM_COMMON_H */
Modified: xfce4-power-manager/trunk/settings/xfpm-settings.c
===================================================================
--- xfce4-power-manager/trunk/settings/xfpm-settings.c 2009-03-10 12:24:36 UTC (rev 6878)
+++ xfce4-power-manager/trunk/settings/xfpm-settings.c 2009-03-10 20:13:44 UTC (rev 6879)
@@ -49,15 +49,30 @@
static GtkWidget *on_ac_dpms_sleep = NULL;
static GtkWidget *on_ac_dpms_off = NULL;
#endif
+
/*
* Callback settings
*/
static void
battery_critical_changed_cb (GtkWidget *w, XfconfChannel *channel)
{
- guint value = gtk_combo_box_get_active ( GTK_COMBO_BOX (w));
- if (!xfconf_channel_set_uint (channel, CRITICAL_BATT_ACTION_CFG, value) )
+ GtkTreeModel *model;
+ GtkTreeIter selected_row;
+ gint value = 0;
+
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (w), &selected_row))
+ return;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(w));
+
+ gtk_tree_model_get(model,
+ &selected_row,
+ 1,
+ &value,
+ -1);
+
+ if (!xfconf_channel_set_string (channel, CRITICAL_BATT_ACTION_CFG, xfpm_int_to_shutdown_string(value)) )
{
g_critical ("Cannot set value for property %s\n", CRITICAL_BATT_ACTION_CFG);
}
@@ -66,8 +81,21 @@
static void
set_show_tray_icon_cb (GtkWidget *w, XfconfChannel *channel)
{
- guint value = gtk_combo_box_get_active ( GTK_COMBO_BOX (w));
+ GtkTreeModel *model;
+ GtkTreeIter selected_row;
+ gint value = 0;
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (w), &selected_row))
+ return;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(w));
+
+ gtk_tree_model_get(model,
+ &selected_row,
+ 1,
+ &value,
+ -1);
+
if (!xfconf_channel_set_uint (channel, SHOW_TRAY_ICON_CFG, value) )
{
g_critical ("Cannot set value for property %s\n", SHOW_TRAY_ICON_CFG);
@@ -77,9 +105,22 @@
static void
set_sleep_changed_cb (GtkWidget *w, XfconfChannel *channel)
{
- guint value = gtk_combo_box_get_active ( GTK_COMBO_BOX (w));
+ GtkTreeModel *model;
+ GtkTreeIter selected_row;
+ gint value = 0;
- if (!xfconf_channel_set_uint (channel, SLEEP_SWITCH_CFG, value) )
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (w), &selected_row))
+ return;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(w));
+
+ gtk_tree_model_get(model,
+ &selected_row,
+ 1,
+ &value,
+ -1);
+
+ if (!xfconf_channel_set_string (channel, SLEEP_SWITCH_CFG, xfpm_int_to_shutdown_string(value) ) )
{
g_critical ("Cannot set value for property %s\n", SLEEP_SWITCH_CFG);
}
@@ -236,9 +277,22 @@
static void
on_battery_lid_changed_cb (GtkWidget *w, XfconfChannel *channel)
{
- guint val = gtk_combo_box_get_active (GTK_COMBO_BOX(w));
+ GtkTreeModel *model;
+ GtkTreeIter selected_row;
+ gint value = 0;
- if (!xfconf_channel_set_uint (channel, LID_SWITCH_ON_BATTERY_CFG, val) )
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (w), &selected_row))
+ return;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(w));
+
+ gtk_tree_model_get(model,
+ &selected_row,
+ 1,
+ &value,
+ -1);
+
+ if (!xfconf_channel_set_string (channel, LID_SWITCH_ON_BATTERY_CFG, xfpm_int_to_shutdown_string(value)) )
{
g_critical ("Cannot set value for property %s\n", LID_SWITCH_ON_BATTERY_CFG);
}
@@ -247,9 +301,22 @@
static void
on_ac_lid_changed_cb (GtkWidget *w, XfconfChannel *channel)
{
- guint val = gtk_combo_box_get_active (GTK_COMBO_BOX(w));
+ GtkTreeModel *model;
+ GtkTreeIter selected_row;
+ gint value = 0;
- if (!xfconf_channel_set_uint (channel, LID_SWITCH_ON_AC_CFG, val) )
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (w), &selected_row))
+ return;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(w));
+
+ gtk_tree_model_get(model,
+ &selected_row,
+ 1,
+ &value,
+ -1);
+
+ if (!xfconf_channel_set_string (channel, LID_SWITCH_ON_AC_CFG, xfpm_int_to_shutdown_string(value)) )
{
g_critical ("Cannot set value for property %s\n", LID_SWITCH_ON_AC_CFG);
}
@@ -258,23 +325,47 @@
static void
xfpm_settings_on_battery (XfconfChannel *channel)
{
- guint val;
+ gint val;
GtkWidget *battery_critical = glade_xml_get_widget (xml, "battery-critical-combox");
+ GtkListStore *list_store;
+ GtkTreeIter iter;
+ list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
- gtk_combo_box_append_text (GTK_COMBO_BOX(battery_critical), _("Shutdown"));
- gtk_combo_box_append_text (GTK_COMBO_BOX(battery_critical), _("Hibernate"));
+ gtk_combo_box_set_model (GTK_COMBO_BOX(battery_critical), GTK_TREE_MODEL(list_store));
- guint critical_action = xfconf_channel_get_uint (channel, CRITICAL_BATT_ACTION_CFG, 0);
- gtk_combo_box_set_active (GTK_COMBO_BOX(battery_critical), critical_action);
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, 0, -1);
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, 1, -1);
+
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, 2, -1);
+
g_signal_connect (battery_critical, "changed",
G_CALLBACK(battery_critical_changed_cb), channel);
+
+ gchar *str = xfconf_channel_get_string (channel, CRITICAL_BATT_ACTION_CFG, "Nothing");
+
+ val = xfpm_shutdown_string_to_int (str);
+
+ if ( val == -1 || val == 3 /*we don't do shutdown here */)
+ {
+ g_warning ("Invalid value %s for property %s\n", str, CRITICAL_BATT_ACTION_CFG);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(battery_critical), 0);
+ }
+ else
+ gtk_combo_box_set_active (GTK_COMBO_BOX(battery_critical), val);
+
+ g_free(str);
+
GtkWidget *power_save = glade_xml_get_widget (xml, "power-save");
gboolean save_power = xfconf_channel_get_bool (channel, POWER_SAVE_ON_BATTERY, TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(power_save), save_power);
g_signal_connect (power_save, "toggled",
G_CALLBACK(power_save_toggled_cb), channel);
+
/*
* DPMS settings when running on battery power
@@ -309,15 +400,37 @@
* Lid switch settings on battery
*/
GtkWidget *lid = glade_xml_get_widget (xml, "on-battery-lid");
- val = xfconf_channel_get_uint (channel, LID_SWITCH_ON_BATTERY_CFG, 0);
- gtk_combo_box_append_text (GTK_COMBO_BOX(lid), _("Suspend"));
- gtk_combo_box_append_text (GTK_COMBO_BOX(lid), _("Hibernate"));
+ list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
- gtk_combo_box_set_active (GTK_COMBO_BOX(lid), val);
+ gtk_combo_box_set_model (GTK_COMBO_BOX(lid), GTK_TREE_MODEL(list_store));
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, 0, -1);
+
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, 1, -1);
+
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, 2, -1);
+
g_signal_connect (lid, "changed",
G_CALLBACK(on_battery_lid_changed_cb), channel);
+
+ str = xfconf_channel_get_string (channel, LID_SWITCH_ON_BATTERY_CFG, "Nothing");
+
+ val = xfpm_shutdown_string_to_int (str);
+
+ if ( val == -1 || val == 3 /*we don't do shutdown here */)
+ {
+ g_warning ("Invalid value %s for property %s\n", str, LID_SWITCH_ON_BATTERY_CFG);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(lid), 0);
+ }
+ else
+ gtk_combo_box_set_active (GTK_COMBO_BOX(lid), val);
+
+ g_free (str);
+
}
static void
@@ -354,18 +467,40 @@
#endif
/*
- * Lid switch settings on battery
+ * Lid switch settings on AC power
*/
+ GtkListStore *list_store;
+ GtkTreeIter iter;
+ list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
+
GtkWidget *lid = glade_xml_get_widget (xml, "on-ac-lid");
- val = xfconf_channel_get_uint (channel, LID_SWITCH_ON_AC_CFG, 0);
+ gtk_combo_box_set_model (GTK_COMBO_BOX(lid), GTK_TREE_MODEL(list_store));
- gtk_combo_box_append_text (GTK_COMBO_BOX(lid), _("Suspend"));
- gtk_combo_box_append_text (GTK_COMBO_BOX(lid), _("Hibernate"));
-
- gtk_combo_box_set_active (GTK_COMBO_BOX(lid), val);
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, 0, -1);
+
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, 1, -1);
+
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, 2, -1);
+
g_signal_connect (lid, "changed",
G_CALLBACK(on_ac_lid_changed_cb), channel);
+
+ gchar *str = xfconf_channel_get_string (channel, LID_SWITCH_ON_AC_CFG, "Nothing");
+ val = xfpm_shutdown_string_to_int (str);
+
+ if ( val == -1 || val == 3 /*we don't do shutdown here */)
+ {
+ g_warning ("Invalid value %s for property %s\n", str, LID_SWITCH_ON_AC_CFG);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(lid), 0);
+ }
+ else
+ gtk_combo_box_set_active (GTK_COMBO_BOX(lid), val);
+
+ g_free (str);
}
static void
@@ -374,15 +509,24 @@
/*
* Tray icon settings
*/
+ GtkListStore *list_store;
+ GtkTreeIter iter;
+ list_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
+
GtkWidget *tray = glade_xml_get_widget (xml, "tray-combox");
+ gtk_combo_box_set_model (GTK_COMBO_BOX(tray), GTK_TREE_MODEL(list_store));
+
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Always show icon"), 1, 0, -1);
+
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("When battery is present"), 1, 1, -1);
- gtk_combo_box_append_text (GTK_COMBO_BOX(tray), _("When battery is present"));
- gtk_combo_box_append_text (GTK_COMBO_BOX(tray), _("When battery is charging or discharging"));
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("When battery is charging or discharging"), 1, 2, -1);
guint show_tray = xfconf_channel_get_uint (channel, SHOW_TRAY_ICON_CFG, 0);
-
gtk_combo_box_set_active (GTK_COMBO_BOX(tray), show_tray);
-
g_signal_connect (tray, "changed",
G_CALLBACK(set_show_tray_icon_cb), channel);
gboolean val;
@@ -403,19 +547,39 @@
/*
* Sleep button
*/
+ list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
GtkWidget *sleep = glade_xml_get_widget (xml, "sleep-combox");
+
+ gtk_combo_box_set_model (GTK_COMBO_BOX(sleep), GTK_TREE_MODEL(list_store));
- gtk_combo_box_append_text (GTK_COMBO_BOX(sleep), _("Suspend"));
- gtk_combo_box_append_text (GTK_COMBO_BOX(sleep), _("Hibernate"));
- gtk_combo_box_append_text (GTK_COMBO_BOX(sleep), _("Shutdown"));
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Nothing"), 1, 0, -1);
- guint sleep_val = xfconf_channel_get_uint (channel, SLEEP_SWITCH_CFG, 0);
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, 1, -1);
- gtk_combo_box_set_active (GTK_COMBO_BOX(sleep), sleep_val);
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, 2, -1);
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, _("Shutdown"), 1, 3, -1);
+
g_signal_connect (sleep, "changed",
G_CALLBACK(set_sleep_changed_cb), channel);
+ gchar *default_sleep_value = xfconf_channel_get_string (channel, SLEEP_SWITCH_CFG, "Nothing");
+ gint sleep_val_int = xfpm_shutdown_string_to_int (default_sleep_value );
+ if ( sleep_val_int == -1)
+ {
+ g_warning ("Invalid value %s for property %s\n", default_sleep_value, SLEEP_SWITCH_CFG);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(sleep), 0);
+ }
+ else
+ gtk_combo_box_set_active (GTK_COMBO_BOX(sleep), sleep_val_int);
+
+ g_free (default_sleep_value);
+
+
/*
* Enable/Disable Notification
*/
@@ -505,12 +669,12 @@
gtk_list_store_append(list_store, &iter);
if ( pix )
{
- gtk_list_store_set(list_store, &iter, 0, pix, 1, _("ON AC"), 2, i, -1);
+ gtk_list_store_set(list_store, &iter, 0, pix, 1, _("On AC"), 2, i, -1);
g_object_unref(pix);
}
else
{
- gtk_list_store_set(list_store, &iter, 1, _("ON AC"), 2, i, -1);
+ gtk_list_store_set(list_store, &iter, 1, _("On AC"), 2, i, -1);
}
i++;
@@ -519,12 +683,12 @@
gtk_list_store_append(list_store, &iter);
if ( pix )
{
- gtk_list_store_set(list_store, &iter, 0, pix, 1, _("ON Battery"), 2, i, -1);
+ gtk_list_store_set(list_store, &iter, 0, pix, 1, _("On Battery"), 2, i, -1);
g_object_unref(pix);
}
else
{
- gtk_list_store_set(list_store, &iter, 1, _("ON Battery"), 2, i, -1);
+ gtk_list_store_set(list_store, &iter, 1, _("On Battery"), 2, i, -1);
}
i++;
@@ -587,28 +751,61 @@
else if ( xfpm_strequal (property, SLEEP_SWITCH_CFG ) )
{
GtkWidget *widget = glade_xml_get_widget (xml, "sleep-combox");
- guint val = g_value_get_uint (value);
- gtk_combo_box_set_active (GTK_COMBO_BOX(widget), val);
+ const gchar *str = g_value_get_string (value);
+ gint val = xfpm_shutdown_string_to_int (str);
+ if ( val == -1)
+ {
+ g_warning ("Invalid value %s for property, using default %s\n", str, SLEEP_SWITCH_CFG);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(widget), 0);
+ }
+ else
+ gtk_combo_box_set_active (GTK_COMBO_BOX(widget), val);
}
else if ( xfpm_strequal (property, LID_SWITCH_ON_AC_CFG ) )
{
GtkWidget *widget = glade_xml_get_widget (xml, "on-ac-lid");
- guint val = g_value_get_uint (value);
- gtk_combo_box_set_active (GTK_COMBO_BOX(widget), val);
+ const gchar *str = g_value_get_string (value);
+ gint val = xfpm_shutdown_string_to_int (str);
+ if ( val == -1 || val == 3 /*we don't do shutdown here */)
+ {
+ g_warning ("Invalid value %s for property %s\n", str, LID_SWITCH_ON_AC_CFG);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(widget), 0);
+ }
+ else
+ gtk_combo_box_set_active (GTK_COMBO_BOX(widget), val);
}
else if ( xfpm_strequal (property, LID_SWITCH_ON_BATTERY_CFG ) )
{
GtkWidget *widget = glade_xml_get_widget (xml, "on-battery-lid");
- guint val = g_value_get_uint (value);
- gtk_combo_box_set_active (GTK_COMBO_BOX(widget), val);
+ const gchar *str = g_value_get_string (value);
+ gint val = xfpm_shutdown_string_to_int (str);
+ if ( val == -1 || val == 3 /*we don't do shutdown here */)
+ {
+ g_warning ("Invalid value %s for property %s\n", str, LID_SWITCH_ON_BATTERY_CFG);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(widget), 0);
+ }
+ else
+ gtk_combo_box_set_active (GTK_COMBO_BOX(widget), val);
}
+ else if ( xfpm_strequal (property, CRITICAL_BATT_ACTION_CFG ) )
+ {
+ GtkWidget *widget = glade_xml_get_widget (xml, "battery-critical-combox");
+ const gchar *str = g_value_get_string (value);
+ gint val = xfpm_shutdown_string_to_int (str);
+ if ( val == -1 || val == 3 /*we don't do shutdown here */)
+ {
+ g_warning ("Invalid value %s for property %s\n", str, CRITICAL_BATT_ACTION_CFG);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(widget), 0);
+ }
+ else
+ gtk_combo_box_set_active (GTK_COMBO_BOX(widget), val);
+ }
if ( xfpm_strequal (property, GENERAL_NOTIFICATION_CFG ) )
{
GtkWidget *widget = glade_xml_get_widget (xml, "notification");
guint val = g_value_get_boolean (value);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(widget), val);
}
-
}
static void dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
Modified: xfce4-power-manager/trunk/settings/xfpm-settings.glade
===================================================================
--- xfce4-power-manager/trunk/settings/xfpm-settings.glade 2009-03-10 12:24:36 UTC (rev 6878)
+++ xfce4-power-manager/trunk/settings/xfpm-settings.glade 2009-03-10 20:13:44 UTC (rev 6879)
@@ -1,14 +1,15 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Sun Mar 8 17:07:51 2009 -->
+<?xml version="1.0"?>
<glade-interface>
+ <!-- interface-requires gtk+ 2.16 -->
<requires lib="xfce4"/>
+ <!-- interface-requires xfce4 2243.42112 -->
+ <!-- interface-naming-policy toplevel-contextual -->
<widget class="XfceTitledDialog" id="xfpm-settings-dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Xfce Power Manager</property>
- <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+ <property name="window_position">center-on-parent</property>
<property name="icon_name">gpm-ac-adapter</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<property name="subtitle" translatable="yes">Power manager settings</property>
<child internal-child="vbox">
@@ -27,6 +28,9 @@
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
</widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<widget class="GtkNotebook" id="main-notebook">
@@ -37,7 +41,7 @@
<widget class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="label_xalign">0</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
@@ -57,10 +61,11 @@
<child>
<widget class="GtkComboBox" id="sleep-combox">
<property name="visible">True</property>
- <property name="items" translatable="yes">Nothing</property>
+ <property name="items" translatable="yes"></property>
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
</widget>
@@ -72,21 +77,16 @@
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkHBox" id="hbox9">
<property name="visible">True</property>
<child>
<widget class="GtkComboBox" id="tray-combox">
<property name="visible">True</property>
- <property name="items" translatable="yes">Always show icon</property>
+ <property name="items" translatable="yes"></property>
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
</widget>
@@ -105,6 +105,7 @@
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
</widget>
@@ -119,6 +120,7 @@
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
</widget>
@@ -127,17 +129,24 @@
<property name="bottom_attach">2</property>
</packing>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="enable-dpms">
+ <property name="label" translatable="yes">Enable monitor power management control</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Enable monitor power management control</property>
- <property name="response_id">0</property>
+ <property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
@@ -147,10 +156,10 @@
</child>
<child>
<widget class="GtkCheckButton" id="notification">
+ <property name="label" translatable="yes">Enable notification</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Enable notification</property>
- <property name="response_id">0</property>
+ <property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
@@ -180,8 +189,8 @@
<property name="label" translatable="yes">General Options</property>
</widget>
<packing>
+ <property name="tab_fill">False</property>
<property name="type">tab</property>
- <property name="tab_fill">False</property>
</packing>
</child>
<child>
@@ -191,7 +200,7 @@
<widget class="GtkFrame" id="frame5">
<property name="visible">True</property>
<property name="label_xalign">0</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
@@ -210,12 +219,13 @@
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="on-ac-lid">
<property name="visible">True</property>
- <property name="items" translatable="yes">Nothing</property>
+ <property name="items" translatable="yes"></property>
</widget>
<packing>
<property name="expand">False</property>
@@ -225,6 +235,7 @@
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
@@ -248,12 +259,13 @@
<packing>
<property name="expand">False</property>
<property name="padding">10</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="dpms-on-ac-frame">
<property name="label_xalign">0</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
@@ -271,6 +283,9 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Put display to sleep when computer is inactive for:</property>
</widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<widget class="GtkHScale" id="sleep-dpms-on-ac">
@@ -279,13 +294,16 @@
<property name="adjustment">0 0 100 1 10 10</property>
<property name="show_fill_level">True</property>
<property name="digits">0</property>
- <property name="value_pos">GTK_POS_BOTTOM</property>
+ <property name="value_pos">bottom</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<widget class="GtkVBox" id="vbox12">
@@ -295,6 +313,9 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Switch off display when computer is inactive for:</property>
</widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<widget class="GtkHScale" id="off-dpms-on-ac">
@@ -303,7 +324,7 @@
<property name="adjustment">0 0 100 1 10 10</property>
<property name="show_fill_level">True</property>
<property name="digits">0</property>
- <property name="value_pos">GTK_POS_BOTTOM</property>
+ <property name="value_pos">bottom</property>
</widget>
<packing>
<property name="position">1</property>
@@ -338,7 +359,7 @@
<widget class="GtkFrame" id="frame6">
<property name="visible">True</property>
<property name="label_xalign">0</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment8">
<property name="visible">True</property>
@@ -352,6 +373,9 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Reduce screen brightness when computer is inactive for:</property>
</widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<widget class="GtkHScale" id="hscale2">
@@ -359,7 +383,7 @@
<property name="can_focus">True</property>
<property name="adjustment">0 0 100 1 10 10</property>
<property name="digits">0</property>
- <property name="value_pos">GTK_POS_BOTTOM</property>
+ <property name="value_pos">bottom</property>
</widget>
<packing>
<property name="position">1</property>
@@ -402,9 +426,9 @@
<property name="label" translatable="yes">Running on AC</property>
</widget>
<packing>
- <property name="type">tab</property>
<property name="position">1</property>
<property name="tab_fill">False</property>
+ <property name="type">tab</property>
</packing>
</child>
<child>
@@ -417,7 +441,7 @@
<widget class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="label_xalign">0</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
@@ -438,10 +462,11 @@
<child>
<widget class="GtkComboBox" id="on-battery-lid">
<property name="visible">True</property>
- <property name="items" translatable="yes">Nothing</property>
+ <property name="items" translatable="yes"></property>
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
</widget>
@@ -458,10 +483,11 @@
<child>
<widget class="GtkComboBox" id="battery-critical-combox">
<property name="visible">True</property>
- <property name="items" translatable="yes">Nothing</property>
+ <property name="items" translatable="yes"></property>
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
</widget>
@@ -480,6 +506,7 @@
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
</widget>
@@ -498,6 +525,7 @@
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
</widget>
@@ -505,14 +533,15 @@
</widget>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="power-save">
+ <property name="label" translatable="yes">Prefer power savings over performance</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Prefer power savings over performance</property>
- <property name="response_id">0</property>
+ <property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
@@ -537,12 +566,13 @@
<packing>
<property name="expand">False</property>
<property name="padding">10</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="dpms-on-battery-frame">
<property name="label_xalign">0</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
@@ -560,6 +590,9 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Put display to sleep when computer is inactive for:</property>
</widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<widget class="GtkHScale" id="sleep-dpms-on-battery">
@@ -568,13 +601,16 @@
<property name="adjustment">0 0 60 1 10 10</property>
<property name="show_fill_level">True</property>
<property name="digits">0</property>
- <property name="value_pos">GTK_POS_BOTTOM</property>
+ <property name="value_pos">bottom</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<widget class="GtkVBox" id="vbox10">
@@ -584,6 +620,9 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Switch off display when computer is inactive for:</property>
</widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<widget class="GtkHScale" id="off-dpms-on-battery">
@@ -592,7 +631,7 @@
<property name="adjustment">0 0 60 1 10 10</property>
<property name="show_fill_level">True</property>
<property name="digits">0</property>
- <property name="value_pos">GTK_POS_BOTTOM</property>
+ <property name="value_pos">bottom</property>
</widget>
<packing>
<property name="position">1</property>
@@ -627,7 +666,7 @@
<widget class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="label_xalign">0</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
@@ -641,6 +680,9 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Reduce screen brightness when computer is inactive for:</property>
</widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<widget class="GtkHScale" id="hscale1">
@@ -648,7 +690,7 @@
<property name="can_focus">True</property>
<property name="adjustment">0 0 100 1 10 10</property>
<property name="digits">0</property>
- <property name="value_pos">GTK_POS_BOTTOM</property>
+ <property name="value_pos">bottom</property>
</widget>
<packing>
<property name="position">1</property>
@@ -705,6 +747,9 @@
</packing>
</child>
</widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
</widget>
<packing>
@@ -717,9 +762,9 @@
<property name="label" translatable="yes">Running on battery</property>
</widget>
<packing>
- <property name="type">tab</property>
<property name="position">2</property>
<property name="tab_fill">False</property>
+ <property name="type">tab</property>
</packing>
</child>
</widget>
@@ -728,6 +773,9 @@
</packing>
</child>
</widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
</widget>
<packing>
@@ -738,34 +786,40 @@
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_EDGE</property>
+ <property name="layout_style">edge</property>
<child>
<widget class="GtkButton" id="button2">
+ <property name="label" translatable="yes">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="label" translatable="yes">gtk-help</property>
<property name="use_stock">True</property>
- <property name="response_id">0</property>
</widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<widget class="GtkButton" id="button1">
+ <property name="label" translatable="yes">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="label" translatable="yes">gtk-close</property>
<property name="use_stock">True</property>
- <property name="response_id">0</property>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
- <property name="pack_type">GTK_PACK_END</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
</packing>
</child>
</widget>
Modified: xfce4-power-manager/trunk/src/xfpm-engine.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-engine.c 2009-03-10 12:24:36 UTC (rev 6878)
+++ xfce4-power-manager/trunk/src/xfpm-engine.c 2009-03-10 20:13:44 UTC (rev 6879)
@@ -160,37 +160,32 @@
G_OBJECT_CLASS(xfpm_engine_parent_class)->finalize(object);
}
-const gchar *
-_shutdown_string_from_enum (XfpmShutdownRequest shutdown)
+static void
+xfpm_engine_shutdown_request (XfpmEngine *engine, XfpmShutdownRequest shutdown)
{
- if ( shutdown == XFPM_DO_HIBERNATE )
- return "Hibernate";
- else if ( shutdown == XFPM_DO_SUSPEND )
- return "Suspend";
- else if ( shutdown == XFPM_DO_SHUTDOWN)
- return "Shutdown";
+ const gchar *action = xfpm_int_to_shutdown_string (shutdown);
- return "Nothing";
+ if ( xfpm_strequal(action, "Nothing") )
+ {
+ TRACE("Sleep button disabled in configuration");
+ return;
+ }
+ else
+ {
+ TRACE("Going to do %s\n", action);
+ xfpm_send_message_to_network_manager ("sleep");
+ xfpm_lock_screen ();
+ if ( shutdown != XFPM_DO_SHUTDOWN )
+ xfpm_lock_screen ();
+ dbus_hal_shutdown (engine->priv->hbus, action, NULL);
+ xfpm_send_message_to_network_manager ("wake");
+ }
}
static void
xfpm_engine_shutdown_request_battery_cb (XfpmSupply *supply, XfpmShutdownRequest action, XfpmEngine *engine)
{
- const gchar *shutdown =
- _shutdown_string_from_enum (action);
-
- if ( xfpm_strequal (shutdown, "Nothing") )
- return;
-
-
- xfpm_send_message_to_network_manager ("sleep");
-
- if ( action != XFPM_DO_SHUTDOWN )
- xfpm_lock_screen ();
-
- dbus_hal_shutdown (engine->priv->hbus, shutdown, NULL);
-
- xfpm_send_message_to_network_manager ("wake");
+ xfpm_engine_shutdown_request (engine, action);
}
static void
@@ -204,24 +199,6 @@
}
static void
-xfpm_engine_shutdown_request (XfpmEngine *engine, XfpmShutdownRequest shutdown)
-{
- const gchar *action =
- _shutdown_string_from_enum (shutdown);
-
- if ( xfpm_strequal(action, "Nothing") )
- {
- TRACE("Sleep button disabled in configuration");
- return;
- }
- else
- {
- xfpm_lock_screen ();
- dbus_hal_shutdown (engine->priv->hbus, action, NULL);
- }
-}
-
-static void
xfpm_engine_xf86_button_pressed_cb (XfpmButtonXf86 *button, XfpmXF86Button type, XfpmEngine *engine)
{
TRACE("Received button press event type %d", type);
@@ -251,7 +228,7 @@
{
g_return_if_fail (engine->priv->lid_button_ac != XFPM_DO_SHUTDOWN );
g_return_if_fail (engine->priv->lid_button_battery != XFPM_DO_SHUTDOWN );
-
+
if ( engine->priv->on_battery && engine->priv->lid_button_battery == XFPM_DO_NOTHING )
{
TRACE("System on battery, doing nothing: user settings\n");
@@ -278,7 +255,6 @@
xfpm_engine_shutdown_request (engine, engine->priv->on_battery ?
engine->priv->lid_button_battery :
engine->priv->lid_button_ac);
-
g_timer_reset (engine->priv->button_timer);
}
@@ -325,33 +301,48 @@
static void
xfpm_engine_load_configuration (XfpmEngine *engine)
{
- engine->priv->sleep_button =
- xfconf_channel_get_uint (engine->priv->channel, SLEEP_SWITCH_CFG, 0);
-
- if ( engine->priv->sleep_button > 3 )
+ gchar *str;
+ gint val;
+
+ str = xfconf_channel_get_string (engine->priv->channel, SLEEP_SWITCH_CFG, "Nothing");
+ val = xfpm_shutdown_string_to_int (str);
+
+ if ( val == -1 )
{
- g_warning ("Configuratuon value for %s is wrong\n", SLEEP_SWITCH_CFG );
- engine->priv->sleep_button = 0;
+ g_warning ("Invalid value %s for property %s, using default\n", str, SLEEP_SWITCH_CFG);
+ engine->priv->sleep_button = XFPM_DO_NOTHING;
+ xfconf_channel_set_string (engine->priv->channel, SLEEP_SWITCH_CFG, "Nothing");
}
+ else engine->priv->sleep_button = val;
- engine->priv->lid_button_ac =
- xfconf_channel_get_uint (engine->priv->channel, LID_SWITCH_ON_AC_CFG, 0);
-
- if ( engine->priv->lid_button_ac > 2 )
+ g_free (str);
+
+ str = xfconf_channel_get_string (engine->priv->channel, LID_SWITCH_ON_AC_CFG, "Nothing");
+ val = xfpm_shutdown_string_to_int (str);
+
+ if ( val == -1 || val == 3)
{
- g_warning ("Configuratuon value for %s is wrong\n", LID_SWITCH_ON_AC_CFG);
- engine->priv->lid_button_ac = 0;
+ g_warning ("Invalid value %s for property %s, using default\n", str, LID_SWITCH_ON_AC_CFG);
+ engine->priv->lid_button_ac = XFPM_DO_NOTHING;
+ xfconf_channel_set_string (engine->priv->channel, LID_SWITCH_ON_AC_CFG, "Nothing");
}
+ else engine->priv->lid_button_ac = val;
- engine->priv->lid_button_battery =
- xfconf_channel_get_uint (engine->priv->channel, LID_SWITCH_ON_BATTERY_CFG, 0);
-
- if ( engine->priv->lid_button_battery > 2 )
+ g_free (str);
+
+ str = xfconf_channel_get_string (engine->priv->channel, LID_SWITCH_ON_BATTERY_CFG, "Nothing");
+ val = xfpm_shutdown_string_to_int (str);
+
+ if ( val == -1 || val == 3)
{
- g_warning ("Configuratuon value for %s is wrong\n", LID_SWITCH_ON_BATTERY_CFG);
- engine->priv->lid_button_battery = 0;
+ g_warning ("Invalid value %s for property %s, using default\n", str, LID_SWITCH_ON_BATTERY_CFG);
+ engine->priv->lid_button_battery = XFPM_DO_NOTHING;
+ xfconf_channel_set_string (engine->priv->channel, LID_SWITCH_ON_BATTERY_CFG, "Nothing");
}
+ else engine->priv->lid_button_battery = val;
+ g_free (str);
+
}
static void
@@ -362,22 +353,52 @@
if ( xfpm_strequal (property, SLEEP_SWITCH_CFG) )
{
- guint val = g_value_get_uint (value);
- engine->priv->sleep_button = val;
+ const gchar *str = g_value_get_string (value);
+ gint val = xfpm_shutdown_string_to_int (str);
+ if ( val == -1 )
+ {
+ g_warning ("Invalid value %s for property %s, using default\n", str, SLEEP_SWITCH_CFG);
+ engine->priv->sleep_button = XFPM_DO_NOTHING;
+ }
+ else
+ engine->priv->sleep_button = val;
}
else if ( xfpm_strequal (property, LID_SWITCH_ON_AC_CFG) )
{
- guint val = g_value_get_uint (value);
- engine->priv->lid_button_ac = val;
+ const gchar *str = g_value_get_string (value);
+ gint val = xfpm_shutdown_string_to_int (str);
+ if ( val == -1 || val == 3 )
+ {
+ g_warning ("Invalid value %s for property %s, using default\n", str, LID_SWITCH_ON_AC_CFG);
+ engine->priv->lid_button_ac = XFPM_DO_NOTHING;
+ }
+ else
+ engine->priv->lid_button_ac = val;
}
else if ( xfpm_strequal (property, LID_SWITCH_ON_BATTERY_CFG) )
{
- guint val = g_value_get_uint (value);
- engine->priv->lid_button_battery = val;
+ const gchar *str = g_value_get_string (value);
+ gint val = xfpm_shutdown_string_to_int (str);
+ if ( val == -1 || val == 3 )
+ {
+ g_warning ("Invalid value %s for property %s, using default\n", str, LID_SWITCH_ON_BATTERY_CFG);
+ engine->priv->lid_button_battery = XFPM_DO_NOTHING;
+ }
+ else
+ engine->priv->lid_button_battery = val;
}
+}
+
+/*
+ *
+ */
+/*
+static void
+xfpm_engine_reset_all_properties (XfpmEngine *engine)
+{
}
-
+*/
XfpmEngine *
xfpm_engine_new(void)
{
Modified: xfce4-power-manager/trunk/src/xfpm-supply.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-supply.c 2009-03-10 12:24:36 UTC (rev 6878)
+++ xfce4-power-manager/trunk/src/xfpm-supply.c 2009-03-10 20:13:44 UTC (rev 6879)
@@ -713,6 +713,8 @@
g_list_free (list);
}
+//static void
+//xfpm_supply_check_configuration (const gchar *property,
static void
xfpm_supply_property_changed_cb (XfconfChannel *channel, gchar *property, GValue *value, XfpmSupply *supply)
{
@@ -721,8 +723,15 @@
if ( xfpm_strequal (property, CRITICAL_BATT_ACTION_CFG) )
{
- guint val = g_value_get_uint (value);
- supply->priv->critical_action = val;
+ const gchar *str = g_value_get_string (value);
+ gint val = xfpm_shutdown_string_to_int (str);
+ if ( val == -1 || val == 3 )
+ {
+ g_warning ("Invalid value %s for property %s, using default\n", str, CRITICAL_BATT_ACTION_CFG);
+ supply->priv->critical_action = XFPM_DO_NOTHING;
+ }
+ else
+ supply->priv->critical_action = val;
}
else if ( xfpm_strequal (property, SHOW_TRAY_ICON_CFG) )
{
@@ -736,11 +745,30 @@
xfpm_supply_load_configuration (XfpmSupply *supply)
{
//FIXME: Check if the action specified we can actually do it
- supply->priv->critical_action =
- xfconf_channel_get_uint (supply->priv->channel, CRITICAL_BATT_ACTION_CFG, 0);
-
+ gchar *str;
+ gint val;
+
+ str = xfconf_channel_get_string (supply->priv->channel, CRITICAL_BATT_ACTION_CFG, "Nothing");
+ val = xfpm_shutdown_string_to_int (str);
+
+ if ( val == -1 || val > 3 )
+ {
+ g_warning ("Invalid value %s for property %s, using default\n", str, CRITICAL_BATT_ACTION_CFG);
+ supply->priv->critical_action = XFPM_DO_NOTHING;
+ xfconf_channel_set_string ( supply->priv->channel, CRITICAL_BATT_ACTION_CFG, "Nothing");
+ }
+ else supply->priv->critical_action = val;
+
+ g_free (str);
+
supply->priv->show_icon =
xfconf_channel_get_uint (supply->priv->channel, SHOW_TRAY_ICON_CFG, 0);
+
+ if ( supply->priv->show_icon < 0 || supply->priv->show_icon > 3 )
+ {
+ g_warning ("Invalid value %d for property %s, using default\n", supply->priv->show_icon, SHOW_TRAY_ICON_CFG);
+ xfconf_channel_set_uint (supply->priv->channel, CRITICAL_BATT_ACTION_CFG, 0);
+ }
}
/*
@@ -755,11 +783,11 @@
supply->priv->hbus = bus;
supply->priv->channel = channel;
- xfpm_supply_load_configuration (supply);
-
g_object_get (G_OBJECT(supply->priv->hbus) ,
"power-management-info", &supply->priv->power_management, NULL);
-
+
+ xfpm_supply_load_configuration (supply);
+
g_signal_connect (channel, "property-changed",
G_CALLBACK(xfpm_supply_property_changed_cb), supply);
More information about the Goodies-commits
mailing list