[dconf-editor] Introduce ViewType enum.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Introduce ViewType enum.
- Date: Fri, 16 Feb 2018 09:34:50 +0000 (UTC)
commit 552bb4f84ae96270c9f4fa9cd816082a3d02a028
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Feb 16 09:53:33 2018 +0100
Introduce ViewType enum.
editor/bookmarks.vala | 3 ++-
editor/browser-stack.vala | 9 ++++++---
editor/browser-view.vala | 5 +++--
editor/dconf-window.vala | 19 +++++++++++++------
editor/pathbar.vala | 10 +++++-----
5 files changed, 29 insertions(+), 17 deletions(-)
---
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index fe62014..968dcbd 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -53,7 +53,8 @@ public class Bookmarks : MenuButton
* * Public calls
\*/
- public void set_path (string path)
+ public void set_path (ViewType type, string path)
+ requires (type != ViewType.SEARCH)
{
if (current_path != path)
current_path = path;
diff --git a/editor/browser-stack.vala b/editor/browser-stack.vala
index 688d60a..aeab35a 100644
--- a/editor/browser-stack.vala
+++ b/editor/browser-stack.vala
@@ -108,12 +108,15 @@ class BrowserStack : Grid
search_results_view.stop_search ();
}
- public void set_path (string path)
+ public void set_path (ViewType type, string path)
+ requires (type != ViewType.SEARCH)
{
- if (path.has_suffix ("/"))
+ if (type == ViewType.FOLDER)
stack.set_visible_child (browse_view);
- else
+ else if (type == ViewType.OBJECT)
stack.set_visible_child (properties_view);
+ else
+ assert_not_reached ();
}
public string? get_copy_text ()
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index d64b8a5..7cb44f4 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -181,9 +181,10 @@ class BrowserView : Grid
current_child.hide_search_view ();
}
- public void set_path (string path)
+ public void set_path (ViewType type, string path)
+ requires (type != ViewType.SEARCH)
{
- current_child.set_path (path);
+ current_child.set_path (type, path);
modifications_handler.path_changed ();
}
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index e488239..4fd5e6b 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -26,6 +26,12 @@ enum RelocatableSchemasEnabledMappings
STARTUP
}
+public enum ViewType {
+ OBJECT,
+ FOLDER,
+ SEARCH
+}
+
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/dconf-editor.ui")]
class DConfWindow : ApplicationWindow
{
@@ -541,7 +547,7 @@ class DConfWindow : ApplicationWindow
if (key_model != null)
{
browser_view.prepare_browse_view ((!) key_model, current_path.has_prefix (fallback_path));
- update_current_path (fallback_path);
+ update_current_path (ViewType.FOLDER, fallback_path);
if (selected_or_empty == "")
browser_view.select_row (pathbar.get_selected_child (fallback_path));
@@ -572,7 +578,7 @@ class DConfWindow : ApplicationWindow
else
{
browser_view.prepare_properties_view ((!) found_object, current_path ==
SettingsModel.get_parent_path (full_name));
- update_current_path (strdup (full_name));
+ update_current_path (ViewType.OBJECT, strdup (full_name));
}
search_bar.search_mode_enabled = false; // do last to avoid flickering RegistryView before
PropertiesView when selecting a search result
@@ -592,12 +598,13 @@ class DConfWindow : ApplicationWindow
* * Path changing
\*/
- private void update_current_path (string path)
+ private void update_current_path (ViewType type, string path)
+ requires (type != ViewType.SEARCH)
{
current_path = path;
- browser_view.set_path (path);
- bookmarks_button.set_path (path);
- pathbar.set_path (path);
+ browser_view.set_path (type, path);
+ bookmarks_button.set_path (type, path);
+ pathbar.set_path (type, path);
invalidate_popovers_without_reload ();
}
diff --git a/editor/pathbar.vala b/editor/pathbar.vala
index ae0926d..fd1ff06 100644
--- a/editor/pathbar.vala
+++ b/editor/pathbar.vala
@@ -33,15 +33,15 @@ public class PathBar : Box
* * public calls
\*/
- public void set_path (string path)
+ public void set_path (ViewType type, string path)
requires (path [0] == '/')
+// requires (type != ViewType.SEARCH) // FIXME makes the app crash at startup, for no reason
{
activate_item (root_button, path == "/");
complete_path = "";
string [] split = path.split ("/", /* max tokens disabled */ 0);
string last = split [split.length - 1];
- bool is_key_path = last != "";
bool destroy_all = false;
bool maintain_all = false;
@@ -68,7 +68,7 @@ public class PathBar : Box
{
complete_path += split [0];
split = split [1:split.length];
- if (split.length == 0 || (split.length == 1 && !is_key_path))
+ if (split.length == 0 || (split.length == 1 && type == ViewType.FOLDER))
{
activate_item (item, true);
maintain_all = true;
@@ -91,14 +91,14 @@ public class PathBar : Box
foreach (string item in split [0:split.length - 1])
{
complete_path += item + "/";
- add_path_bar_item (item, complete_path, true, !is_key_path && (index == split.length -
2));
+ add_path_bar_item (item, complete_path, true, type == ViewType.FOLDER && (index ==
split.length - 2));
add_slash_label ();
index++;
}
}
/* if key path */
- if (is_key_path)
+ if (type == ViewType.OBJECT)
{
complete_path += last;
add_path_bar_item (last, complete_path, false, true);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]