[dconf-editor] Fix search.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Fix search.
- Date: Sun, 12 Aug 2018 07:19:39 +0000 (UTC)
commit c59c09f20314d0ff48029293708a9f815370764c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Aug 10 16:15:20 2018 +0200
Fix search.
editor/dconf-model.vala | 54 ++++++++++++++++++++++++++++++++++++++-------
editor/dconf-window.vala | 2 +-
editor/registry-search.vala | 44 ++++++++++++++++++------------------
3 files changed, 68 insertions(+), 32 deletions(-)
---
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index 66cddea..dfde6cf 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -127,10 +127,10 @@ private abstract class SettingsModelCore : Object
return key_model;
}
- protected Variant? _get_children (string folder_path, bool update_watch)
+ protected Variant? _get_children (string folder_path, bool watch, bool clean_watched)
{
- if (update_watch)
- clean_watched_keys ();
+ if (clean_watched)
+ _clean_watched_keys ();
GLib.ListStore list_store = get_children_as_liststore (folder_path);
uint n_items = list_store.get_n_items ();
@@ -145,7 +145,7 @@ private abstract class SettingsModelCore : Object
SettingObject base_object = (SettingObject) (!) object;
if (base_object is Key)
{
- if (update_watch)
+ if (watch)
add_watched_key ((Key) base_object);
builder.add ("(qs)", get_context_id_from_key ((Key) base_object), base_object.name);
@@ -207,6 +207,9 @@ private abstract class SettingsModelCore : Object
return false;
}
+ if ((!) object is Key)
+ add_watched_key ((Key) (!) object);
+
context_id = get_context_id_from_object ((!) object);
name = ((!) object).name;
return true;
@@ -562,6 +565,28 @@ private abstract class SettingsModelCore : Object
push_gsettings_key_value ((GSettingsKey) (!) object);
else if ((!) object is DConfKey)
push_dconf_key_value (((Key) (!) object).full_name, client);
+ else assert_not_reached ();
+ position++;
+ object = watched_keys.get_item (position);
+ };
+ }
+
+ protected void _key_value_push (string key_path, uint16 key_context_id)
+ {
+ uint position = 0;
+ Object? object = watched_keys.get_item (0);
+ while (object != null)
+ {
+ if (((Key) (!) object).full_name == key_path
+ && get_context_id_from_key ((Key) (!) object) == key_context_id)
+ {
+ if ((!) object is GSettingsKey)
+ push_gsettings_key_value ((GSettingsKey) (!) object);
+ else if ((!) object is DConfKey)
+ push_dconf_key_value (((Key) (!) object).full_name, client);
+ else assert_not_reached ();
+ return;
+ }
position++;
object = watched_keys.get_item (position);
};
@@ -587,7 +612,7 @@ private abstract class SettingsModelCore : Object
private void on_gkey_value_changed (Key key) { push_gsettings_key_value ((GSettingsKey) key); }
private void on_dkey_value_changed (Key key) { push_dconf_key_value (key.full_name, client); }
- private void clean_watched_keys ()
+ protected void _clean_watched_keys ()
{
uint position = 0;
Object? object = watched_keys.get_item (0);
@@ -681,7 +706,7 @@ private abstract class SettingsModelCore : Object
if (found_object == null)
return ModelUtils.undefined_context_id;
- clean_watched_keys ();
+ _clean_watched_keys ();
add_watched_key ((!) found_object);
return get_context_id_from_object ((!) found_object);
@@ -943,10 +968,10 @@ private class SettingsModel : SettingsModelCore
* * Directories informations
\*/
- internal Variant? get_children (string folder_path, bool update_watch = false)
+ internal Variant? get_children (string folder_path, bool watch = false, bool clean_watched = false)
requires (ModelUtils.is_folder_path (folder_path))
{
- return _get_children (folder_path, update_watch);
+ return _get_children (folder_path, watch, clean_watched);
}
internal uint16 [] get_sorted_context_id (bool case_sensitive)
@@ -960,10 +985,23 @@ private class SettingsModel : SettingsModelCore
_keys_value_push ();
}
+ internal void key_value_push (string key_path, uint16 key_context_id)
+ requires (ModelUtils.is_key_path (key_path))
+ requires (!ModelUtils.is_undefined_context_id (key_context_id))
+ requires (!ModelUtils.is_folder_context_id (key_context_id))
+ {
+ _key_value_push (key_path, key_context_id);
+ }
+
/*\
* * Weird things
\*/
+ internal void clean_watched_keys ()
+ {
+ _clean_watched_keys ();
+ }
+
internal void copy_action_called ()
{
copy_action = true;
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index e4ffa89..a0dd1ed 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -570,7 +570,7 @@ private class DConfWindow : ApplicationWindow
if (notify_missing && (fallback_path != full_name))
cannot_find_folder (full_name); // do not place after, full_name is in some cases changed by
set_directory()...
- browser_view.prepare_folder_view (fallback_path, model.get_children (fallback_path, true),
current_path.has_prefix (fallback_path));
+ browser_view.prepare_folder_view (fallback_path, model.get_children (fallback_path, true, true),
current_path.has_prefix (fallback_path));
update_current_path (ViewType.FOLDER, fallback_path);
if (selected_or_empty == "")
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index fd24d66..66d33b4 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -131,9 +131,13 @@ private class RegistrySearch : RegistryList
}
ensure_selection ();
+
+ model.keys_value_push ();
}
else
{
+ model.clean_watched_keys ();
+
stop_global_search ();
list_model.remove_all ();
post_local = -1;
@@ -145,11 +149,12 @@ private class RegistrySearch : RegistryList
select_first_row ();
+ model.keys_value_push ();
+
if (term != "")
start_global_search (model, (!) current_path_if_search_mode, term);
}
old_term = term;
- model.keys_value_push ();
}
private void refine_local_results (string term)
@@ -200,39 +205,33 @@ private class RegistrySearch : RegistryList
}
}
- private bool local_search (SettingsModel model, SortingOptions sorting_options, string current_path,
string term)
+ private void local_search (SettingsModel model, SortingOptions sorting_options, string current_path,
string term)
+ requires (ModelUtils.is_folder_path (current_path))
{
SettingComparator comparator = sorting_options.get_comparator ();
GLib.CompareDataFunc compare = (a, b) => comparator.compare ((SimpleSettingObject) a,
(SimpleSettingObject) b);
- if (ModelUtils.is_folder_path (current_path))
+ Variant? key_model = model.get_children (current_path, true, false); // here to update watched keys
even coming from RegistryInfo
+ if (key_model != null)
{
- Variant? key_model = model.get_children (current_path);
- if (key_model != null)
+ VariantIter iter = new VariantIter ((!) key_model);
+ uint16 context_id;
+ string name;
+ while (iter.next ("(qs)", out context_id, out name))
{
- VariantIter iter = new VariantIter ((!) key_model);
- uint16 context_id;
- string name;
- while (iter.next ("(qs)", out context_id, out name))
+ if (term in name)
{
- if (term in name)
- {
- SimpleSettingObject sso = new SimpleSettingObject.from_base_path (context_id, name,
current_path);
- list_model.insert_sorted (sso, compare);
- }
+ SimpleSettingObject sso = new SimpleSettingObject.from_base_path (context_id, name,
current_path);
+ list_model.insert_sorted (sso, compare);
}
}
}
post_local = (int) list_model.get_n_items ();
post_bookmarks = post_local;
post_folders = post_local;
-
- if (term == "")
- return false;
- return true;
}
- private bool bookmark_search (SettingsModel model, string current_path, string term, string [] bookmarks)
+ private void bookmark_search (SettingsModel model, string current_path, string term, string [] bookmarks)
{
string [] installed_bookmarks = {}; // TODO move check in Bookmarks
foreach (string bookmark in bookmarks)
@@ -243,7 +242,7 @@ private class RegistrySearch : RegistryList
if (bookmark == current_path)
continue;
- if (ModelUtils.get_parent_path (bookmark) == current_path)
+ if (ModelUtils.get_parent_path (bookmark) == ModelUtils.get_base_path (current_path))
continue;
uint16 context_id;
@@ -259,8 +258,6 @@ private class RegistrySearch : RegistryList
list_model.insert (post_bookmarks - 1, sso);
}
}
-
- return true;
}
private void stop_global_search ()
@@ -301,7 +298,7 @@ private class RegistrySearch : RegistryList
string next = (!) search_nodes.pop_head ();
bool local_again = next == current_path;
- Variant? next_key_model = model.get_children (next);
+ Variant? next_key_model = model.get_children (next, true, false);
if (next_key_model == null)
return true;
@@ -326,6 +323,7 @@ private class RegistrySearch : RegistryList
{
SimpleSettingObject sso = new SimpleSettingObject.from_base_path (context_id, name,
next);
list_model.append (sso);
+ model.key_value_push (next + name, context_id);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]