[dconf-editor] Refactorise a bit.



commit 594cab48a46eab491e6308b3b24373b1bf65b727
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Dec 20 20:31:43 2018 +0100

    Refactorise a bit.

 editor/registry-list.vala   |  3 +--
 editor/registry-search.vala | 26 +++++++++++---------------
 2 files changed, 12 insertions(+), 17 deletions(-)
---
diff --git a/editor/registry-list.vala b/editor/registry-list.vala
index 4c1213f..c1cdbf0 100644
--- a/editor/registry-list.vala
+++ b/editor/registry-list.vala
@@ -1189,7 +1189,6 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
         else if (!((!) row_content is ConfigListBoxRow || (!) row_content is ReturnListBoxRow || (!) 
row_content is SearchListBoxRow))
             assert_not_reached ();
 
-        ListBoxRowHeader header = new ListBoxRowHeader (false, label_text);
-        row.set_header (header);
+        row.set_header (new ListBoxRowHeader (false, label_text));
     }
 }
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index 2f603fc..a223a66 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -95,9 +95,7 @@ private class RegistrySearch : RegistryList
         ListBoxRow? row;
         if (term.has_prefix ("/"))
         {
-            row = key_list_box.get_row_at_index (0);
-            if (row == null)
-                assert_not_reached ();
+            row = _get_first_row (ref key_list_box);
 
             ClickableListBoxRow? row_child = (ClickableListBoxRow?) ((!) row).get_child ();
             if (row_child != null)
@@ -111,25 +109,24 @@ private class RegistrySearch : RegistryList
             }
         }
         else if (term.length == 0)
-        {
-            row = key_list_box.get_row_at_index (0);
-            if (row == null)
-                assert_not_reached ();
-        }
+            row = _get_first_row (ref key_list_box);
         else
         {
             row = key_list_box.get_row_at_index (1);
             if (row == null)
-            {
-                row = key_list_box.get_row_at_index (0);
-                if (row == null)
-                    assert_not_reached ();
-            }
+                row = _get_first_row (ref key_list_box);
         }
 
         key_list_box.select_row ((!) row);
         key_list_box.get_adjustment ().set_value (0);
     }
+    private static ListBoxRow _get_first_row (ref unowned ListBox key_list_box)
+    {
+        ListBoxRow? row = key_list_box.get_row_at_index (0);
+        if (row == null)
+            assert_not_reached ();
+        return (!) row;
+    }
 
     private static bool _return_pressed (ListBox key_list_box)
     {
@@ -528,8 +525,7 @@ private class RegistrySearch : RegistryList
         }
 
         string? label_text = get_header_text (row_index, post_local, post_bookmarks, post_folders);
-        ListBoxRowHeader header = new ListBoxRowHeader (false, label_text);
-        row.set_header (header);
+        row.set_header (new ListBoxRowHeader (false, label_text));
     }
     private static string? get_header_text (int row_index, int post_local, int post_bookmarks, int 
post_folders)
     {


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