[dconf-editor] Improve row selection when browsing.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Improve row selection when browsing.
- Date: Sun, 23 Sep 2018 14:48:09 +0000 (UTC)
commit 725df7b3c2c2943c800911cd198f91863f114037
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Sep 23 16:46:27 2018 +0200
Improve row selection when browsing.
Selecting the first folder row when there is no keys and the
new preferences row when there is at least one feels great.
editor/registry-view.vala | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index 5c29e14..9f0b5ce 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -90,9 +90,25 @@ private class RegistryView : RegistryList
internal override void select_first_row ()
{
- ListBoxRow? row = key_list_box.get_row_at_index (0);
- if (row != null)
- scroll_to_row ((!) row, true);
+ uint n_items = list_model.get_n_items ();
+ if (n_items == 0)
+ assert_not_reached ();
+
+ ListBoxRow? row;
+ if (n_items == 1)
+ row = key_list_box.get_row_at_index (0);
+ else
+ {
+ SimpleSettingObject sso = (SimpleSettingObject) list_model.get_object (n_items - 1);
+
+ if (ModelUtils.is_folder_context_id (sso.context_id)) // if do not contain at least one key
+ row = key_list_box.get_row_at_index (1);
+ else
+ row = key_list_box.get_row_at_index (0);
+ }
+ if (row == null)
+ assert_not_reached ();
+ scroll_to_row ((!) row, true);
}
/*\
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]