[gcalctool] Correctly choose the first conversion when none/invalid defined (Bug #645663)



commit afe60e3615963e8648eccc521b625503b9780a03
Author: Robert Ancell <robert ancell canonical com>
Date:   Sat Mar 26 12:11:11 2011 +1100

    Correctly choose the first conversion when none/invalid defined (Bug #645663)

 NEWS                 |    2 ++
 src/math-converter.c |    8 +++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index 3fcd506..1d42780 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ Overview of changes in gcalctool 6.0.0
 
     * Use /org/gnome as location for gsettings keys.  This will mean
       gcalctool 5.31.x users will have their settings reset to defaults.
+    * Correctly choose the first conversion when none/invalid defined
+      (Bug #645663)
 
 Overview of changes in gcalctool 5.91.93
 
diff --git a/src/math-converter.c b/src/math-converter.c
index 92c2dc9..28d380f 100644
--- a/src/math-converter.c
+++ b/src/math-converter.c
@@ -224,7 +224,13 @@ math_converter_set_conversion(MathConverter *converter, /*const gchar *category,
     ub = unit_manager_get_unit_by_name(unit_manager_get_default(), unit_b);
     if (!ua || !ub)
     {
-        gtk_combo_box_set_active(GTK_COMBO_BOX(converter->priv->from_combo), 0);
+        GtkTreeModel *model;
+        GtkTreeIter iter, child_iter;
+
+        /* Select the first unit */
+        model = gtk_combo_box_get_model(GTK_COMBO_BOX(converter->priv->from_combo));
+        if (gtk_tree_model_get_iter_first(model, &iter) && gtk_tree_model_iter_children(model, &child_iter, &iter))
+            gtk_combo_box_set_active_iter(GTK_COMBO_BOX(converter->priv->from_combo), &child_iter);
         return;
     }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]