diff --git a/data/interfaces/xfpm-settings.ui b/data/interfaces/xfpm-settings.ui index bd09980..427afd0 100644 --- a/data/interfaces/xfpm-settings.ui +++ b/data/interfaces/xfpm-settings.ui @@ -730,6 +730,8 @@ 6 6 18 + + True True @@ -767,15 +769,31 @@ - + True - True - system-sleep-inactivity-on-battery-adjustment - 0 - 0 - bottom - - + False + vertical + + + True + True + system-sleep-inactivity-on-battery-adjustment + 0 + 0 + False + + + + + + + True + False + 0.5 + + 1 @@ -783,15 +801,35 @@ - + True - True - system-sleep-inactivity-on-ac-adjustment - 0 - 0 - bottom - - + False + vertical + + + True + True + system-sleep-inactivity-on-ac-adjustment + 0 + 0 + False + + + + + + + True + False + 0.5 + + + True + True + + 2 @@ -907,6 +945,7 @@ False False critical-power-level-spin-adjustment + 100 @@ -1193,8 +1232,7 @@ display-blank-on-battery-adjustment 0 0 - bottom - + False @@ -1236,7 +1274,7 @@ display-blank-on-ac-adjustment 0 0 - bottom + False @@ -1272,8 +1310,7 @@ dpms-sleep-on-battery-adjustment 0 0 - bottom - + False @@ -1289,7 +1326,7 @@ dpms-sleep-on-ac-adjustment 0 0 - bottom + False @@ -1318,8 +1355,7 @@ dpms-off-on-battery-adjustment 0 0 - bottom - + False @@ -1335,7 +1371,7 @@ dpms-off-on-ac-adjustment 0 0 - bottom + False @@ -1467,7 +1503,7 @@ brightness-level-on-battery-adjustment 0 0 - bottom + False @@ -1510,7 +1546,7 @@ brightness-level-on-ac-adjustment 0 0 - bottom + False @@ -1546,7 +1582,7 @@ brightness-inactivity-on-battery-adjustment 0 0 - bottom + False @@ -1563,7 +1599,7 @@ brightness-inactivity-on-ac-adjustment 0 0 - bottom + False @@ -1705,7 +1741,7 @@ light-locker-late-locking-adjustment 0 0 - bottom + False diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c index bdc3124..0edb045 100644 --- a/settings/xfpm-settings.c +++ b/settings/xfpm-settings.c @@ -157,9 +157,7 @@ gchar *format_dpms_value_cb (GtkScale *scale, gdouble value, gpointer data); -gchar *format_inactivity_value_cb (GtkScale *scale, - gdouble value, - gpointer data); +gchar *format_inactivity_value_cb (gint value); gchar *format_brightness_value_cb (GtkScale *scale, gdouble value, @@ -211,6 +209,20 @@ void light_locker_automatic_locking_changed_cb (GtkWidget *w, void xfpm_update_logind_handle_lid_switch (XfconfChannel *channel); /* END Light Locker Integration */ + +static GtkWidget* label_inactivity_on_ac; +static GtkWidget* label_inactivity_on_battery; + +static void +update_label (GtkWidget *label, GtkWidget *scale, gchar* (*format)(gint)) +{ + gint value = (gint) gtk_range_get_value (GTK_RANGE (scale)); + + gchar *formatted_value = format (value); + gtk_label_set_text (GTK_LABEL (label), formatted_value); + g_free (formatted_value); +} + void brightness_level_on_ac (GtkWidget *w, XfconfChannel *channel) { guint val = (guint) gtk_range_get_value (GTK_RANGE (w)); @@ -264,6 +276,8 @@ inactivity_on_ac_value_changed_cb (GtkWidget *widget, XfconfChannel *channel) { g_critical ("Cannot set value for property %s\n", ON_AC_INACTIVITY_TIMEOUT); } + + update_label (label_inactivity_on_ac, widget, format_inactivity_value_cb); } void @@ -275,6 +289,8 @@ inactivity_on_battery_value_changed_cb (GtkWidget *widget, XfconfChannel *channe { g_critical ("Cannot set value for property %s\n", ON_BATTERY_INACTIVITY_TIMEOUT); } + + update_label (label_inactivity_on_battery, widget, format_inactivity_value_cb); } void @@ -643,20 +659,20 @@ format_dpms_value_cb (GtkScale *scale, gdouble value, gpointer data) gchar * -format_inactivity_value_cb (GtkScale *scale, gdouble value, gpointer data) +format_inactivity_value_cb (gint value) { gint h, min; - if ( (gint)value <= 14 ) + if ( value <= 14 ) return g_strdup (_("Never")); - else if ( (gint)value < 60 ) - return g_strdup_printf ("%d %s", (gint)value, _("minutes")); - else if ( (gint)value == 60) + else if ( value < 60 ) + return g_strdup_printf ("%d %s", value, _("minutes")); + else if ( value == 60 ) return g_strdup (_("One hour")); /* value > 60 */ - h = (gint)value/60; - min = (gint)value%60; + h = value/60; + min = value%60; if ( h <= 1 ) if ( min == 0 ) return g_strdup_printf ("%s", _("One hour")); @@ -1065,6 +1081,8 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean auth_suspend, gtk_widget_hide (brg_level); } + label_inactivity_on_battery = GTK_WIDGET (gtk_builder_get_object (xml, "system-sleep-inactivity-on-battery-label")); + update_label (label_inactivity_on_battery, inact_timeout, format_inactivity_value_cb); } static void @@ -1244,6 +1262,8 @@ xfpm_settings_on_ac (XfconfChannel *channel, gboolean auth_suspend, gtk_widget_hide (brg_level); } + label_inactivity_on_ac = GTK_WIDGET (gtk_builder_get_object (xml, "system-sleep-inactivity-on-ac-label")); + update_label (label_inactivity_on_ac, inact_timeout, format_inactivity_value_cb); } static void @@ -2275,6 +2295,7 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean auth_suspend, GtkCellRenderer *renderer; GError *error = NULL; guint val; + GtkCssProvider *css_provider; XFPM_DEBUG ("auth_hibernate=%s auth_suspend=%s can_shutdown=%s can_suspend=%s can_hibernate=%s " \ "has_battery=%s has_lcd_brightness=%s has_lid=%s has_sleep_button=%s " \ @@ -2329,6 +2350,20 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean auth_suspend, dialog = GTK_WIDGET (gtk_builder_get_object (xml, "xfpm-settings-dialog")); nt = GTK_WIDGET (gtk_builder_get_object (xml, "main-notebook")); + /* Set Gtk style */ + css_provider = gtk_css_provider_new (); + gtk_css_provider_load_from_data (css_provider, + ".xfce4-custom-scale { padding-bottom: 0; }", + -1, NULL); + /* FIXME: This is a hack */ + gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), + GTK_STYLE_PROVIDER(css_provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + /* DOES NOT WORK + gtk_style_context_add_provider (GTK_STYLE_CONTEXT (gtk_widget_get_style_context (dialog)), + GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + */ + /* Devices listview */ sideview = gtk_tree_view_new (); list_store = gtk_list_store_new (NCOLS_SIDEBAR,