summaryrefslogtreecommitdiff
path: root/settings
diff options
context:
space:
mode:
authorAli Abdallah <ali@ali-xfce.org>2009-11-06 17:00:06 +0100
committerAli Abdallah <ali@ali-xfce.org>2009-11-06 17:00:06 +0100
commitf9292aa5c359545cf2043d8c58899367d113bdcf (patch)
treeb9cf7070eee3dfa65491e0f2a0d85c429228c3c0 /settings
parent8510408fe399538d6644428b2dd6c1cbaa72e168 (diff)
downloadixfce4-power-manager-f9292aa5c359545cf2043d8c58899367d113bdcf.tar.gz
Support for spinning downs hard disks via device-kit-disks
to use this feature use has to have the policy kit permission on "org.freedesktop.devicekit.disks.drive-set-spindown"
Diffstat (limited to 'settings')
-rw-r--r--settings/xfpm-settings-main.c6
-rw-r--r--settings/xfpm-settings.c94
-rw-r--r--settings/xfpm-settings.h2
3 files changed, 83 insertions, 19 deletions
diff --git a/settings/xfpm-settings-main.c b/settings/xfpm-settings-main.c
index 9d751e7c..b228d7fb 100644
--- a/settings/xfpm-settings-main.c
+++ b/settings/xfpm-settings-main.c
@@ -61,6 +61,8 @@ int main (int argc, char **argv)
gboolean has_hibernate_button;
gboolean has_power_button;
gboolean has_lid;
+ gboolean can_spin_down;
+ gboolean devkit_disk;
gboolean start_xfpm_if_not_running;
GdkNativeWindow socket_id = 0;
@@ -159,11 +161,13 @@ int main (int argc, char **argv)
has_power_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "power-button"));
has_hibernate_button = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "hibernate-button"));
can_shutdown = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-shutdown"));
+ can_spin_down = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "can-spin"));
+ devkit_disk = xfpm_string_to_bool (g_hash_table_lookup (config_hash, "devkit-disk"));
xfpm_settings_dialog_new (channel, has_battery, auth_hibernate, auth_suspend,
can_shutdown, can_suspend, can_hibernate, has_lcd_brightness,
has_lid, has_sleep_button, has_hibernate_button, has_power_button,
- socket_id);
+ devkit_disk, can_spin_down, socket_id);
gtk_main();
diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c
index 0403c28a..81999953 100644
--- a/settings/xfpm-settings.c
+++ b/settings/xfpm-settings.c
@@ -148,7 +148,10 @@ void critical_level_value_changed_cb (GtkSpinButton *w,
void lock_screen_toggled_cb (GtkWidget *w,
XfconfChannel *channel);
-void cpu_freq_control_changed_cb (GtkWidget *w,
+void on_battery_spin_changed (GtkWidget *w,
+ XfconfChannel *channel);
+
+void on_ac_spin_changed (GtkWidget *w,
XfconfChannel *channel);
void _cursor_changed_cb (GtkTreeView *view,
@@ -701,24 +704,33 @@ lock_screen_toggled_cb (GtkWidget *w, XfconfChannel *channel)
}
}
-void
-cpu_freq_control_changed_cb (GtkWidget *w, XfconfChannel *channel)
+void on_battery_spin_changed (GtkWidget *w, XfconfChannel *channel)
{
-#ifdef SYSTEM_IS_LINUX
- gboolean val = (gint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(w));
+ gboolean val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(w));
- if ( !xfconf_channel_set_bool (channel, PROPERTIES_PREFIX CPU_FREQ_CONTROL, val) )
+ if ( !xfconf_channel_set_bool (channel, SPIN_DOWN_ON_BATTERY, val) )
{
- g_critical ("Unable to set value for property %s\n", CPU_FREQ_CONTROL);
+ g_critical ("Unable to set value for property %s\n", SPIN_DOWN_ON_BATTERY);
}
-#endif
+
}
+void on_ac_spin_changed (GtkWidget *w, XfconfChannel *channel)
+{
+ gboolean val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(w));
+
+ if ( !xfconf_channel_set_bool (channel, SPIN_DOWN_ON_AC, val) )
+ {
+ g_critical ("Unable to set value for property %s\n", SPIN_DOWN_ON_AC);
+ }
+}
static void
-xfpm_settings_on_battery (XfconfChannel *channel, gboolean auth_hibernate, gboolean auth_suspend,
- gboolean can_shutdown, gboolean can_suspend,
- gboolean can_hibernate, gboolean has_lcd_brightness, gboolean has_lid)
+xfpm_settings_on_battery (XfconfChannel *channel, gboolean auth_hibernate,
+ gboolean auth_suspend, gboolean can_shutdown,
+ gboolean can_suspend, gboolean can_hibernate,
+ gboolean has_lcd_brightness, gboolean has_lid,
+ gboolean devkit_disk, gboolean can_spin_down)
{
gboolean valid;
gint list_value;
@@ -733,6 +745,7 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean auth_hibernate, gbool
GtkWidget *label;
GtkWidget *brg;
GtkWidget *frame;
+ GtkWidget *spin_down;
#ifdef HAVE_DPMS
GtkWidget *dpms_frame_on_battery;
#endif
@@ -891,17 +904,31 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean auth_hibernate, gbool
gtk_notebook_remove_page (GTK_NOTEBOOK (nt), 1);
}
#endif
+
+ spin_down = GTK_WIDGET (gtk_builder_get_object (xml, "spin-down-on-battery"));
+ gtk_widget_set_sensitive (spin_down, can_spin_down);
+
+ if ( !devkit_disk )
+ {
+ gtk_widget_hide (spin_down);
+ }
+ else if ( !can_spin_down )
+ {
+ gtk_widget_set_tooltip_text (spin_down, _("Spinning down hard disks permission denied"));
+ }
}
static void
-xfpm_settings_on_ac (XfconfChannel *channel, gboolean auth_suspend, gboolean auth_hibernate,
- gboolean can_suspend, gboolean can_hibernate,
- gboolean has_lcd_brightness, gboolean has_lid)
+xfpm_settings_on_ac (XfconfChannel *channel, gboolean auth_suspend,
+ gboolean auth_hibernate, gboolean can_suspend,
+ gboolean can_hibernate, gboolean has_lcd_brightness,
+ gboolean has_lid, gboolean devkit_disk, gboolean can_spin_down)
{
GtkWidget *inact;
GtkWidget *lid;
GtkWidget *frame;
GtkWidget *brg;
+ GtkWidget *spin_down;
GtkListStore *list_store;
GtkTreeIter iter;
guint val;
@@ -1013,6 +1040,19 @@ xfpm_settings_on_ac (XfconfChannel *channel, gboolean auth_suspend, gboolean aut
gtk_notebook_remove_page (GTK_NOTEBOOK (GTK_WIDGET (gtk_builder_get_object (xml, "on-ac-notebook"))), 1);
}
#endif
+
+ spin_down = GTK_WIDGET (gtk_builder_get_object (xml, "spin-down-on-ac"));
+ gtk_widget_set_sensitive (spin_down, can_spin_down);
+
+ if ( !devkit_disk )
+ {
+ gtk_widget_hide (spin_down);
+ }
+ else if ( !can_spin_down )
+ {
+ gtk_widget_set_tooltip_text (spin_down, _("Spinning down hard disks permission denied"));
+ }
+
}
static void
@@ -1535,6 +1575,7 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop,
gboolean can_hibernate, gboolean has_lcd_brightness,
gboolean has_lid, gboolean has_sleep_button,
gboolean has_hibernate_button, gboolean has_power_button,
+ gboolean devkit_disk, gboolean can_spin_down,
GdkNativeWindow id)
{
GtkWidget *plug;
@@ -1543,13 +1584,13 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop,
GError *error = NULL;
g_debug ("system_laptop=%s auth_hibernate=%s auth_suspend=%s can_shutdown=%s can_suspend=%s can_hibernate=%s has_lcd_brightness=%s has_lid=%s "\
- "has_sleep_button=%s has_hibernate_button=%s has_power_button=%s",
+ "has_sleep_button=%s has_hibernate_button=%s has_power_button=%s can_spin_down=%s",
xfpm_bool_to_string (system_laptop), xfpm_bool_to_string (auth_hibernate),
xfpm_bool_to_string (can_shutdown), xfpm_bool_to_string (auth_suspend),
xfpm_bool_to_string (can_suspend), xfpm_bool_to_string (can_hibernate),
xfpm_bool_to_string (has_lcd_brightness), xfpm_bool_to_string (has_lid),
xfpm_bool_to_string (has_sleep_button), xfpm_bool_to_string (has_hibernate_button),
- xfpm_bool_to_string (has_power_button) );
+ xfpm_bool_to_string (has_power_button), xfpm_bool_to_string (can_spin_down) );
xml = xfpm_builder_new_from_string (xfpm_settings_ui, &error);
@@ -1571,10 +1612,27 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean system_laptop,
dialog = GTK_WIDGET (gtk_builder_get_object (xml, "xfpm-settings-dialog"));
nt = GTK_WIDGET (gtk_builder_get_object (xml, "main-notebook"));
- xfpm_settings_on_ac (channel, auth_hibernate, auth_suspend, can_suspend, can_hibernate, has_lcd_brightness, has_lid );
+ xfpm_settings_on_ac (channel,
+ auth_hibernate,
+ auth_suspend,
+ can_suspend,
+ can_hibernate,
+ has_lcd_brightness,
+ has_lid,
+ devkit_disk,
+ can_spin_down);
if ( system_laptop )
- xfpm_settings_on_battery (channel, auth_hibernate, auth_suspend, can_shutdown, can_suspend, can_hibernate, has_lcd_brightness, has_lid);
+ xfpm_settings_on_battery (channel,
+ auth_hibernate,
+ auth_suspend,
+ can_shutdown,
+ can_suspend,
+ can_hibernate,
+ has_lcd_brightness,
+ has_lid,
+ devkit_disk,
+ can_spin_down);
xfpm_settings_tree_view (channel, system_laptop);
diff --git a/settings/xfpm-settings.h b/settings/xfpm-settings.h
index 2b86d52c..0d398520 100644
--- a/settings/xfpm-settings.h
+++ b/settings/xfpm-settings.h
@@ -34,6 +34,8 @@ void xfpm_settings_dialog_new (XfconfChannel *channel,
gboolean has_sleep_button,
gboolean has_hibernate_button,
gboolean has_power_button,
+ gboolean devkit_disk,
+ gboolean can_spin_down,
GdkNativeWindow id);