[dconf-editor] Make some methods static.



commit 174be54c65dae05648a571cf79f2da8a6a87206b
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Nov 28 11:45:06 2018 +0100

    Make some methods static.

 editor/about-list.vala     | 12 +++++-----
 editor/overlayed-list.vala | 60 ++++++++++++++++++++++++++++++++--------------
 2 files changed, 48 insertions(+), 24 deletions(-)
---
diff --git a/editor/about-list.vala b/editor/about-list.vala
index 7258214..656de77 100644
--- a/editor/about-list.vala
+++ b/editor/about-list.vala
@@ -30,13 +30,13 @@ private class AboutList : OverlayedList
         second_mode_name = _("Credits");
         change_editability (true);
 
-        show_apropos ();
+        show_apropos (ref main_list_store);
     }
 
     internal void reset ()
     {
         edit_mode_action.set_state (false);
-        show_apropos ();
+        show_apropos (ref main_list_store);
     }
 
     /*\
@@ -66,12 +66,12 @@ private class AboutList : OverlayedList
         action.set_state (new_state);
 
         if (new_state)
-            show_credits ();
+            show_credits (ref main_list_store);
         else
-            show_apropos ();
+            show_apropos (ref main_list_store);
     }
 
-    private void show_apropos ()
+    private static inline void show_apropos (ref GLib.ListStore main_list_store)
     {
         main_list_store.remove_all ();
         main_list_store.append (new AboutListItem.from_icon_name    (AboutDialogInfos.logo_icon_name));
@@ -87,7 +87,7 @@ private class AboutList : OverlayedList
         main_list_store.append (new AboutListItem.from_link         
("https://www.gnu.org/licenses/gpl-3.0.html";, _("GNU General Public License\nversion 3 or later")));    // 
TODO better
     }
 
-    private void show_credits ()
+    private static inline void show_credits (ref GLib.ListStore main_list_store)
     {
         main_list_store.remove_all ();
         main_list_store.append (new AboutListItem.from_icon_name    (AboutDialogInfos.logo_icon_name));
diff --git a/editor/overlayed-list.vala b/editor/overlayed-list.vala
index 9bf759d..c002772 100644
--- a/editor/overlayed-list.vala
+++ b/editor/overlayed-list.vala
@@ -87,23 +87,27 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
     internal void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
         if (!AdaptativeWidget.WindowSize.is_extra_thin (new_size) && 
AdaptativeWidget.WindowSize.is_extra_flat (new_size))
-        {
-            main_context.remove_class ("vertical");
-            edit_mode_box.halign = Align.END;
-            edit_mode_box.valign = Align.CENTER;
-            edit_mode_box.orientation = Orientation.VERTICAL;
-            edit_mode_box.width_request = 160;
-            main_context.add_class ("horizontal");
-        }
+            set_horizontal (ref main_context, ref edit_mode_box);
         else
-        {
-            main_context.remove_class ("horizontal");
-            edit_mode_box.halign = Align.CENTER;
-            edit_mode_box.valign = Align.END;
-            edit_mode_box.orientation = Orientation.HORIZONTAL;
-            edit_mode_box.width_request = 200;
-            main_context.add_class ("vertical");
-        }
+            set_vertical (ref main_context, ref edit_mode_box);
+    }
+    private static inline void set_horizontal (ref StyleContext main_context, ref Box edit_mode_box)
+    {
+        main_context.remove_class ("vertical");
+        edit_mode_box.halign = Align.END;
+        edit_mode_box.valign = Align.CENTER;
+        edit_mode_box.orientation = Orientation.VERTICAL;
+        edit_mode_box.width_request = 160;
+        main_context.add_class ("horizontal");
+    }
+    private static inline void set_vertical (ref StyleContext main_context, ref Box edit_mode_box)
+    {
+        main_context.remove_class ("horizontal");
+        edit_mode_box.halign = Align.CENTER;
+        edit_mode_box.valign = Align.END;
+        edit_mode_box.orientation = Orientation.HORIZONTAL;
+        edit_mode_box.width_request = 200;
+        main_context.add_class ("vertical");
     }
 
     /*\
@@ -112,7 +116,11 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
 
     internal void down_pressed ()
     {
-        ListBoxRow? row = main_list_box.get_selected_row ();
+        _down_pressed (ref main_list_box);
+    }
+    private static inline void _down_pressed (ref ListBox main_list_box)
+    {
+        ListBoxRow? row = main_list_box.get_selected_row ();    // TODO multiple rows
         if (row == null)
             row = main_list_box.get_row_at_index (0);
         else
@@ -125,11 +133,15 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
     }
 
     internal void up_pressed ()
+    {
+        _up_pressed (n_items, ref main_list_box);
+    }
+    private static inline void _up_pressed (uint n_items, ref ListBox main_list_box)
     {
         if (n_items == 0)
             return;
 
-        ListBoxRow? row = main_list_box.get_selected_row ();
+        ListBoxRow? row = main_list_box.get_selected_row ();    // TODO multiple rows
         if (row == null)
             row = main_list_box.get_row_at_index ((int) n_items - 1);
         else
@@ -168,6 +180,10 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
     \*/
 
     protected int [] get_selected_rows_indices ()
+    {
+        return _get_selected_rows_indices (ref main_list_box);
+    }
+    private static inline int [] _get_selected_rows_indices (ref ListBox main_list_box)
     {
         int [] indices = new int [0];
         main_list_box.selected_foreach ((_list_box, selected_row) => {
@@ -192,6 +208,10 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
     }
 
     internal string? get_copy_text ()
+    {
+        return _get_copy_text (ref main_list_box);
+    }
+    private static inline string? _get_copy_text (ref ListBox main_list_box)
     {
         List<weak ListBoxRow> selected_rows = main_list_box.get_selected_rows ();
         OverlayedListRow row;
@@ -244,6 +264,10 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
     }
 
     internal SelectionState get_selection_state ()
+    {
+        return _get_selection_state (ref main_list_box, ref main_list_store);
+    }
+    private static inline SelectionState _get_selection_state (ref ListBox main_list_box, ref GLib.ListStore 
main_list_store)
     {
         List<weak ListBoxRow> selected_rows = main_list_box.get_selected_rows ();
         uint n_selected_rows = selected_rows.length ();


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