[gnome-control-center] screen: Make sure the combo box is always set
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] screen: Make sure the combo box is always set
- Date: Tue, 8 Feb 2011 21:36:43 +0000 (UTC)
commit 99c1d959be62b6d4b6849dc0d4be7a126b7251de
Author: Bastien Nocera <hadess hadess net>
Date: Tue Feb 8 21:35:30 2011 +0000
screen: Make sure the combo box is always set
If a value is between 2 values, choose the upper one. If a value
is higher than the maximim used in the combobox, set it to the
maximum.
panels/screen/cc-screen-panel.c | 32 ++++++++++++++++++++++++++------
1 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/panels/screen/cc-screen-panel.c b/panels/screen/cc-screen-panel.c
index bff1a16..944750c 100644
--- a/panels/screen/cc-screen-panel.c
+++ b/panels/screen/cc-screen-panel.c
@@ -326,8 +326,9 @@ set_dpms_value_for_combo (GtkComboBox *combo_box, CcScreenPanel *self)
GtkTreeIter iter;
GtkTreeModel *model;
gint value;
- gint value_tmp;
+ gint value_tmp, value_prev;
gboolean ret;
+ guint i;
/* get entry */
model = gtk_combo_box_get_model (combo_box);
@@ -335,6 +336,9 @@ set_dpms_value_for_combo (GtkComboBox *combo_box, CcScreenPanel *self)
if (!ret)
return;
+ value_prev = 0;
+ i = 0;
+
/* try to make the UI match the AC setting */
value = g_settings_get_int (self->priv->gsd_settings, "sleep-display-ac");
do
@@ -342,12 +346,18 @@ set_dpms_value_for_combo (GtkComboBox *combo_box, CcScreenPanel *self)
gtk_tree_model_get (model, &iter,
1, &value_tmp,
-1);
- if (value == value_tmp)
+ if (value == value_tmp ||
+ (value_tmp > value_prev && value < value_tmp))
{
gtk_combo_box_set_active_iter (combo_box, &iter);
- break;
+ return;
}
+ value_prev = value_tmp;
+ i++;
} while (gtk_tree_model_iter_next (model, &iter));
+
+ /* If we didn't find the setting in the list */
+ gtk_combo_box_set_active (combo_box, i - 1);
}
static void
@@ -356,8 +366,9 @@ set_lock_value_for_combo (GtkComboBox *combo_box, CcScreenPanel *self)
GtkTreeIter iter;
GtkTreeModel *model;
guint value;
- gint value_tmp;
+ gint value_tmp, value_prev;
gboolean ret;
+ guint i;
/* get entry */
model = gtk_combo_box_get_model (combo_box);
@@ -365,6 +376,9 @@ set_lock_value_for_combo (GtkComboBox *combo_box, CcScreenPanel *self)
if (!ret)
return;
+ value_prev = 0;
+ i = 0;
+
/* try to make the UI match the AC setting */
g_settings_get (self->priv->lock_settings, "lock-delay", "u", &value);
do
@@ -372,12 +386,18 @@ set_lock_value_for_combo (GtkComboBox *combo_box, CcScreenPanel *self)
gtk_tree_model_get (model, &iter,
1, &value_tmp,
-1);
- if (value == value_tmp)
+ if (value == value_tmp ||
+ (value_tmp > value_prev && value < value_tmp))
{
gtk_combo_box_set_active_iter (combo_box, &iter);
- break;
+ return;
}
+ value_prev = value_tmp;
+ i++;
} while (gtk_tree_model_iter_next (model, &iter));
+
+ /* If we didn't find the setting in the list */
+ gtk_combo_box_set_active (combo_box, i - 1);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]