[gnome-calculator/convert-categories: 19/21] Fixed category combo visibility
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator/convert-categories: 19/21] Fixed category combo visibility
- Date: Mon, 15 Nov 2021 14:29:52 +0000 (UTC)
commit 66ddaa56a2a143a0356e1ce7b64280b18d7e3e01
Author: Robert Roth <robert roth off gmail com>
Date: Fri Nov 12 09:17:31 2021 +0200
Fixed category combo visibility
src/math-converter.vala | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/src/math-converter.vala b/src/math-converter.vala
index 23dfc3c4..da51acc2 100644
--- a/src/math-converter.vala
+++ b/src/math-converter.vala
@@ -15,6 +15,8 @@ public class MathConverter : Gtk.Grid
private string category;
+ private bool single_category = false;
+
[GtkChild]
private unowned Gtk.CellRendererText from_renderer;
@@ -83,9 +85,19 @@ public class MathConverter : Gtk.Grid
if (this.category == category)
return;
this.category = category;
+ if (this.category != null) {
+ this.single_category = true;
+ UnitCategory? unit_category = UnitManager.get_default ().get_category (this.category);
+ uint position = 0;
+ var model = category_combo.get_model () as ListStore;
+ model.find (unit_category, out position);
+ category_combo.selected = position;
+ } else {
+ this.single_category = false;
+ category_combo.selected = 0;
+ }
+ // from_combobox_changed_cb ();
- update_visibility ();
- update_from_model ();
}
public string get_category ()
@@ -129,12 +141,14 @@ public class MathConverter : Gtk.Grid
private void update_visibility ()
{
+ this.category_combo.visible = !this.single_category;
if (category != "currency") {
this.outer_box_visible = true;
return;
}
this.outer_box_visible = CurrencyManager.get_default ().loaded;
+
}
private void update_result_label ()
@@ -223,8 +237,12 @@ public class MathConverter : Gtk.Grid
{
UnitCategory? category = category_combo.selected_item as UnitCategory;
- print ("%s\n", category.name);
- // set_category (category.name);
+
+ this.category = category.name;
+
+ update_visibility ();
+ update_from_model ();
+ from_combo.set_active (0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]