[dconf-editor] Make transition work as expected.



commit c8982f8735f130a2f5c0878e4110725642736c5c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue Aug 2 00:45:27 2016 +0200

    Make transition work as expected.

 editor/bookmarks.vala     |    5 +--
 editor/dconf-editor.ui    |    4 +-
 editor/dconf-window.vala  |   19 ++------------
 editor/pathbar.vala       |    6 ++--
 editor/registry-info.vala |    2 +-
 editor/registry-view.vala |   60 ++++++++++++++++++--------------------------
 6 files changed, 36 insertions(+), 60 deletions(-)
---
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index 03b5e37..733f7e8 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -37,7 +37,7 @@ public class Bookmarks : MenuButton
     public string schema_id { get; construct; }
     private GLib.Settings settings;
 
-    public signal bool bookmark_activated (string bookmark);
+    public signal void request_path (string bookmark);
 
     private ulong switch_active_handler = 0;
 
@@ -124,8 +124,7 @@ public class Bookmarks : MenuButton
     {
         bookmarks_popover.closed ();
         string bookmark = ((Bookmark) list_box_row.get_child ()).bookmark_name;
-        if (!bookmark_activated (bookmark))
-            warning ("broken bookmark: %s", bookmark);
+        request_path (bookmark);
     }
 
     private void remove_bookmark (string bookmark_name)
diff --git a/editor/dconf-editor.ui b/editor/dconf-editor.ui
index dadb722..14e82fc 100644
--- a/editor/dconf-editor.ui
+++ b/editor/dconf-editor.ui
@@ -20,7 +20,7 @@
           <object class="PathBar" id="pathbar">
             <property name="visible">True</property>
             <property name="valign">center</property>
-            <signal name="path_selected" handler="scroll_to_sure_path"/>
+            <signal name="request_path" handler="request_path"/>
           </object>
           <packing>
             <property name="pack-type">start</property>
@@ -94,7 +94,7 @@
             <property name="focus-on-click">False</property>
             <property name="schema-id">ca.desrt.dconf-editor.Settings</property>
             <signal name="clicked" handler="on_menu_button_clicked"/>
-            <signal name="bookmark_activated" handler="scroll_to_path_without_transition"/>
+            <signal name="request_path" handler="request_path"/>
             <!-- <accelerator key="B" signal="activate" modifiers="GDK_CONTROL_MASK"/> TODO -->
             <style>
               <class name="image-button"/> <!-- TODO https://bugzilla.gnome.org/show_bug.cgi?id=756731 -->
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 67772e2..c8e1cb3 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -217,23 +217,10 @@ class DConfWindow : ApplicationWindow
     }
 
     [GtkCallback]
-    private bool scroll_to_path_without_transition (string full_name)
+    private void request_path (string full_name)
     {
-        registry_view.enable_transition (false);
-        bool return_value = registry_view.scroll_to_path (full_name);
-        registry_view.enable_transition (true);
-        return return_value;
-    }
-    [GtkCallback]
-    private void scroll_to_sure_path (string full_name)
-    {
-        if (!scroll_to_path (full_name))
-            assert_not_reached ();
-    }
-    private bool scroll_to_path (string full_name)
-    {
-        registry_view.set_search_mode (false);
-        return registry_view.scroll_to_path (full_name);
+        registry_view.set_search_mode (false);  // TODO only useful when called from pathbar
+        registry_view.request_path (full_name);
     }
 
     /*\
diff --git a/editor/pathbar.vala b/editor/pathbar.vala
index 86c00f5..74080ac 100644
--- a/editor/pathbar.vala
+++ b/editor/pathbar.vala
@@ -22,12 +22,12 @@ public class PathBar : Box
 {
     [GtkChild] private Button root_button;
 
-    public signal void path_selected (string path);
+    public signal void request_path (string path);
 
     construct
     {
         add_slash_label ();
-        root_button.clicked.connect (() => path_selected ("/"));
+        root_button.clicked.connect (() => request_path ("/"));
     }
 
     public void set_path (string path)
@@ -116,7 +116,7 @@ public class PathBar : Box
     {
         PathBarItem path_bar_item = new PathBarItem (label);
 
-        path_bar_item.path_bar_item_clicked_handler = path_bar_item.clicked.connect (() => path_selected 
(complete_path));
+        path_bar_item.path_bar_item_clicked_handler = path_bar_item.clicked.connect (() => request_path 
(complete_path));
         path_bar_item.set_sensitive (!block);
 
         add (path_bar_item);
diff --git a/editor/registry-info.vala b/editor/registry-info.vala
index 08cede8..2608451 100644
--- a/editor/registry-info.vala
+++ b/editor/registry-info.vala
@@ -96,7 +96,7 @@ class RegistryInfo : Grid
         Label label = new Label (get_current_value_text (has_schema && ((GSettingsKey) key).is_default, 
key));
         ulong key_value_changed_handler = key.value_changed.connect (() => {
                 if (!has_schema && ((DConfKey) key).is_ghost)
-                    ((RegistryView) get_parent ().get_parent ()).scroll_to_path (parent_path);
+                    ((RegistryView) get_parent ().get_parent ()).request_path (parent_path);
                 else
                     label.set_text (get_current_value_text (has_schema && ((GSettingsKey) key).is_default, 
key));
             });
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index b89d4b3..8183a97 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -74,33 +74,30 @@ class RegistryView : Grid
         }
     }
 
-    private void update_current_path (string path)
-    {
-        revealer.path_changed ();
-        current_path = path;
-        invalidate_popovers ();
-    }
-
     /*\
     * * Stack switching
     \*/
 
-    public void show_browse_view (bool transition = true)
+    private void show_browse_view (string path)
     {
-        enable_transition (transition);
+        stack.set_transition_type (current_path.has_prefix (path) ? StackTransitionType.CROSSFADE : 
StackTransitionType.NONE);
+        update_current_path (path);
         stack.set_visible_child_name ("browse-view");
         properties_view.clean ();
     }
 
-    private void show_properties_view (bool transition = true)
+    private void show_properties_view (string path)
     {
-        enable_transition (transition);
+        stack.set_transition_type (path.has_prefix (current_path) && current_path.length == 
path.last_index_of_char ('/') + 1 ? StackTransitionType.CROSSFADE : StackTransitionType.NONE);
+        update_current_path (path);
         stack.set_visible_child (properties_view);
     }
 
-    public void enable_transition (bool enable)
+    private void update_current_path (string path)
     {
-        stack.set_transition_type (enable ? StackTransitionType.CROSSFADE : StackTransitionType.NONE);
+        revealer.path_changed ();
+        current_path = path;
+        invalidate_popovers ();
     }
 
     /*\
@@ -124,7 +121,13 @@ class RegistryView : Grid
             return model.get_root_directory ();
     }
 
-    public bool scroll_to_path (string _full_name)      // TODO don't do all the selection work if the 
folder didn't change; clarify what "return true" means
+    public void request_path (string path)
+    {
+        if (!scroll_to_path (path))
+            assert_not_reached ();
+    }
+
+    private bool scroll_to_path (string _full_name)     // TODO don't do all the selection work if the 
folder didn't change; clarify what "return true" means
     {
         string full_name = _full_name.dup ();
         string folder_name;
@@ -141,7 +144,7 @@ class RegistryView : Grid
 
         if (full_name == folder_name)
         {
-            open_folder (full_name);
+            show_browse_view (full_name);
             return true;
         }
 
@@ -150,19 +153,18 @@ class RegistryView : Grid
         Key? key = get_key_from_name (key_name);
         if (key == null)
         {
-            open_folder (folder_name);
+            show_browse_view (folder_name);
             get_dconf_window ().show_notification (_("Cannot find key \"%s\" here.").printf (key_name));
             return true;
         }
         if (!properties_view.populate_properties_list_box ((!) key))
         {
-            open_folder (folder_name);
+            show_browse_view (folder_name);
             get_dconf_window ().show_notification (_("Key \"%s\" has been removed.").printf (key_name));
             return true;
         }
 
-        update_current_path (full_name);
-        show_properties_view ();
+        show_properties_view (full_name);
         return true;
     }
     private bool select_folder (string full_name)
@@ -202,11 +204,6 @@ class RegistryView : Grid
         }
         return null;
     }
-    private void open_folder (string folder_path)
-    {
-        update_current_path (folder_path);
-        show_browse_view ();
-    }
 
     private DConfWindow get_dconf_window ()
     {
@@ -250,8 +247,7 @@ class RegistryView : Grid
                     if (!properties_view.populate_properties_list_box (key))  // TODO unduplicate
                         return;
 
-                    update_current_path (key.full_name);
-                    show_properties_view ();
+                    show_properties_view (key.full_name);
                 });
             // TODO bug: row is always visually activated after the dialog destruction if mouse is over at 
this time
 
@@ -477,9 +473,7 @@ class RegistryView : Grid
             if (!on_first_directory && dir.name.index_of (search_entry.text) >= 0)
             {
                 dir_tree_selection.select_iter (iter);
-                update_current_path (dir.full_name);
-
-                show_browse_view (false);
+                show_browse_view (dir.full_name);
                 return;
             }
             on_first_directory = false;
@@ -492,10 +486,8 @@ class RegistryView : Grid
                 if (object.name.index_of (search_entry.text) >= 0)
                 {
                     dir_tree_selection.select_iter (iter);
-                    update_current_path (dir.full_name);
                     key_list_box.select_row (key_list_box.get_row_at_index (position)); // TODO scroll to 
key in ListBox
-
-                    show_browse_view (false);
+                    show_browse_view (dir.full_name);
                     return;
                 }
                 else if (object is Key)
@@ -504,10 +496,8 @@ class RegistryView : Grid
                     if ((key is GSettingsKey || !((DConfKey) key).is_ghost) && key_matches (key, 
search_entry.text) && properties_view.populate_properties_list_box (key))
                     {
                         dir_tree_selection.select_iter (iter);
-                        update_current_path (object.full_name);
                         key_list_box.select_row (key_list_box.get_row_at_index (position));
-
-                        show_properties_view (false);
+                        show_properties_view (object.full_name);
                         return;
                     }
                 }


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