[dconf-editor] Isolate access to Directory.key_model
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Isolate access to Directory.key_model
- Date: Mon, 11 Dec 2017 22:59:18 +0000 (UTC)
commit 40337a8b6065c402ac15c644cecc362275f7d325
Author: Davi da Silva Böger <dsboger gmail com>
Date: Wed Dec 6 15:01:43 2017 -0200
Isolate access to Directory.key_model
editor/browser-view.vala | 28 +++++++++++++++++++++-------
editor/dconf-model.vala | 9 +++++++--
editor/dconf-window.vala | 7 ++++---
editor/registry-search.vala | 6 +++---
editor/registry-view.vala | 2 +-
5 files changed, 36 insertions(+), 16 deletions(-)
---
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 085b6d6..e4c9474 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -91,7 +91,10 @@ class BrowserView : Grid, PathElement
settings.bind ("sort-folders", sorting_options, "sort-folders", GLib.SettingsBindFlags.GET);
sorting_options.notify.connect (() => {
- if (current_view_is_browse_view () && !sorting_options.is_key_model_sorted
(current_directory.key_model))
+ if (!current_view_is_browse_view ())
+ return;
+ GLib.ListStore key_model = window.model.get_children (current_directory);
+ if (!sorting_options.is_key_model_sorted (key_model))
need_reload_warning_revealer.set_reveal_child (true);
// TODO reload search results too
});
@@ -116,9 +119,10 @@ class BrowserView : Grid, PathElement
public void set_directory (Directory directory, string? selected)
{
current_directory = directory;
- sorting_options.sort_key_model (current_directory.key_model);
+ GLib.ListStore key_model = window.model.get_children (current_directory);
+ sorting_options.sort_key_model (key_model);
- browse_view.set_key_model (directory.key_model);
+ browse_view.set_key_model (key_model);
show_browse_view (directory.full_name, selected);
properties_view.clean ();
@@ -290,7 +294,15 @@ class BrowserView : Grid, PathElement
public void reset (bool recursively)
{
- reset_objects (current_directory.key_model, recursively);
+ reset_objects (window.model.get_children (current_directory), recursively);
+ }
+
+ public void reset_directory (Directory parent, bool recursively)
+ {
+ enter_delay_mode ();
+ GLib.ListStore objects = window.model.get_children (parent);
+ reset_generic (objects, recursively);
+ revealer.warn_if_no_planned_changes ();
}
public void reset_objects (GLib.ListStore? objects, bool recursively)
@@ -314,8 +326,10 @@ class BrowserView : Grid, PathElement
SettingObject setting_object = (SettingObject) ((!) object);
if (setting_object is Directory)
{
- if (recursively)
- reset_generic (((Directory) setting_object).key_model, true);
+ if (recursively) {
+ GLib.ListStore children = window.model.get_children ((Directory) setting_object);
+ reset_generic (children, true);
+ }
continue;
}
if (setting_object is DConfKey)
@@ -338,7 +352,7 @@ class BrowserView : Grid, PathElement
private void reload ()
{
string? saved_selection = browse_view.get_selected_row_name ();
- sorting_options.sort_key_model (current_directory.key_model); // TODO duplicate in set_directory
+ sorting_options.sort_key_model (window.model.get_children (current_directory)); // TODO duplicate
in set_directory
show_browse_view (current_path, saved_selection);
}
}
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index b283070..71216a0 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -899,7 +899,7 @@ public class SettingsModel : Object
uint index = 1;
while (index < names.length - 1)
{
- dir = get_folder_from_path_and_name (((Directory) (!) dir).key_model, names [index]);
+ dir = get_folder_from_path_and_name (get_children ((Directory) dir), names [index]);
if (dir == null)
return null;
index++;
@@ -908,6 +908,11 @@ public class SettingsModel : Object
return (Directory) (!) dir;
}
+ public ListStore get_children (Directory parent)
+ {
+ return parent.key_model;
+ }
+
public SettingObject? get_object (string path)
{
if (path.has_suffix ("/"))
@@ -916,7 +921,7 @@ public class SettingsModel : Object
if (parent == null)
return null;
string name = path [path.last_index_of_char ('/') + 1:path.length];
- return get_key_from_path_and_name (((!) parent).key_model, name);
+ return get_key_from_path_and_name (get_children ((!) parent), name);
}
public static string get_parent_path (string path)
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 073d307..39bf15f 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -202,8 +202,9 @@ class DConfWindow : ApplicationWindow
string [] names = current_path.split ("/");
string object_name = names [names.length - 1];
- Key? existing_key = SettingsModel.get_key_from_path_and_name (((!) dir).key_model,
object_name);
- Directory? existing_dir = SettingsModel.get_folder_from_path_and_name (((!) dir).key_model,
object_name);
+ GLib.ListStore key_model = model.get_children ((!) dir);
+ Key? existing_key = SettingsModel.get_key_from_path_and_name (key_model, object_name);
+ Directory? existing_dir = SettingsModel.get_folder_from_path_and_name (key_model, object_name);
if (existing_key != null)
{
@@ -336,7 +337,7 @@ class DConfWindow : ApplicationWindow
string [] names = full_name.split ("/");
string object_name = names [names.length - 1];
- Key? existing_key = SettingsModel.get_key_from_path_and_name (((!) dir).key_model, object_name);
+ Key? existing_key = SettingsModel.get_key_from_path_and_name (model.get_children ((!) dir),
object_name);
if (existing_key == null)
cannot_find_key (object_name, (!) dir);
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index 525560f..107916d 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -147,7 +147,7 @@ class RegistrySearch : Grid, PathElement, BrowsableView
if (setting_object is Directory)
{
row = new FolderListBoxRow (setting_object.name, setting_object.full_name, !is_local_result);
- on_delete_call_handler = row.on_delete_call.connect (() => browser_view.reset_objects
(((Directory) setting_object).key_model, true));
+ on_delete_call_handler = row.on_delete_call.connect (() => browser_view.reset_directory
((Directory) setting_object, true));
}
else
{
@@ -487,7 +487,7 @@ class RegistrySearch : Grid, PathElement, BrowsableView
Directory? local = model.get_directory (current_path);
if (local != null)
{
- GLib.ListStore key_model = ((!) local).key_model;
+ GLib.ListStore key_model = model.get_children ((!) local);
for (uint i = 0; i < key_model.get_n_items (); i++)
{
SettingObject item = (SettingObject) key_model.get_item (i);
@@ -571,7 +571,7 @@ class RegistrySearch : Grid, PathElement, BrowsableView
Directory next = (!) search_nodes.pop_head ();
bool local_again = next.full_name == current_path;
- GLib.ListStore next_key_model = next.key_model;
+ GLib.ListStore next_key_model = window.model.get_children (next);
for (uint i = 0; i < next_key_model.get_n_items (); i++)
{
SettingObject item = (SettingObject) next_key_model.get_item (i);
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index 1b57c42..0c00022 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -140,7 +140,7 @@ class RegistryView : Grid, PathElement, BrowsableView
if (setting_object is Directory)
{
row = new FolderListBoxRow (setting_object.name, setting_object.full_name);
- on_delete_call_handler = row.on_delete_call.connect (() => browser_view.reset_objects
(((Directory) setting_object).key_model, true));
+ on_delete_call_handler = row.on_delete_call.connect (() => browser_view.reset_directory
((Directory) setting_object, true));
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]