[dconf-editor] Rework reload.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Rework reload.
- Date: Tue, 16 Jan 2018 15:54:58 +0000 (UTC)
commit 44f9ce9e1f20fb4c6f2fb627812877517f68ca19
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Jan 16 16:53:18 2018 +0100
Rework reload.
editor/browser-view.vala | 74 ++++++++++++++++++++++++++++++++++----------
editor/dconf-editor.ui | 24 ++++++++++++++-
editor/dconf-window.vala | 61 ++++++++++++++++++++++++++-----------
editor/registry-view.vala | 5 ---
4 files changed, 123 insertions(+), 41 deletions(-)
---
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 54cc935..e6e56f6 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -29,6 +29,7 @@ class BrowserView : Grid
private Widget? pre_search_view = null;
private SortingOptions sorting_options = new SortingOptions ();
+ private GLib.ListStore? key_model = null;
public bool small_keys_list_rows
{
@@ -53,21 +54,52 @@ class BrowserView : Grid
construct
{
- info_bar.add_label ("soft-reload", _("Sort preferences have changed. Do you want to reload the
view?"),
- _("Refresh"), "ui.reload");
- info_bar.add_label ("hard-reload", _("This content has changed. Do you want to reload the view?"),
- _("Reload"), "ui.reload");
+ install_action_entries ();
+
+ info_bar.add_label ("soft-reload-folder", _("Sort preferences have changed. Do you want to refresh
the view?"),
+ _("Refresh"), "bro.refresh-folder");
+ info_bar.add_label ("hard-reload-folder", _("This folder content has changed. Do you want to reload
the view?"),
+ _("Reload"), "ui.open-folder::''");
+ info_bar.add_label ("hard-reload-object", _("This key properties have changed. Do you want to reload
the view?"),
+ _("Reload"), "ui.open-object::''"); // TODO also for key
removing?
sorting_options.notify.connect (() => {
if (!current_view_is_browse_view ())
return;
- GLib.ListStore? key_model = browse_view.get_key_model ();
+
if (key_model != null && !sorting_options.is_key_model_sorted ((!) key_model))
show_soft_reload_warning ();
// TODO reload search results too
});
}
+ /*\
+ * * Action entries
+ \*/
+
+ private void install_action_entries ()
+ {
+ SimpleActionGroup action_group = new SimpleActionGroup ();
+ action_group.add_action_entries (action_entries, this);
+ insert_action_group ("bro", action_group);
+ }
+
+ private const GLib.ActionEntry [] action_entries =
+ {
+ { "refresh-folder", refresh_folder }
+ };
+
+ private void refresh_folder (SimpleAction action, Variant? path_variant)
+ requires (path_variant != null)
+ requires (key_model != null)
+ {
+ sorting_options.sort_key_model ((!) key_model);
+ }
+
+ /*\
+ * * Views
+ \*/
+
public string get_selected_row_name ()
{
if (current_view_is_browse_view ())
@@ -79,6 +111,7 @@ class BrowserView : Grid
public void prepare_browse_view (GLib.ListStore key_model, bool is_ancestor, bool
warning_multiple_schemas)
{
+ this.key_model = key_model;
sorting_options.sort_key_model (key_model);
browse_view.set_key_model (key_model);
@@ -214,13 +247,13 @@ class BrowserView : Grid
private void show_soft_reload_warning ()
{
- if (!info_bar.is_shown ("hard-reload"))
- info_bar.show_warning ("soft-reload");
+ if (!info_bar.is_shown ("hard-reload-folder") && !info_bar.is_shown ("hard-reload-object"))
+ info_bar.show_warning ("soft-reload-folder");
}
- public void show_hard_reload_warning ()
+ private void show_hard_reload_warning ()
{
- info_bar.show_warning ("hard-reload");
+ info_bar.show_warning (current_view_is_browse_view () ? "hard-reload-folder" : "hard-reload-object");
}
public void reload_search (string current_path, string [] bookmarks)
@@ -229,22 +262,29 @@ class BrowserView : Grid
search_results_view.reload_search (current_path, bookmarks, sorting_options);
}
- public bool check_reload (string path)
+ public bool check_reload (string path, bool show_infobar)
{
SettingsModel model = modifications_handler.model;
- if (current_view_is_properties_view ())
+
+ if (current_view_is_browse_view ())
+ {
+ Directory? fresh_dir = (Directory?) model.get_directory (path);
+ GLib.ListStore? fresh_key_model = model.get_children (fresh_dir);
+ if (fresh_key_model != null && !browse_view.check_reload ((!) fresh_dir, (!) fresh_key_model))
+ return false;
+ }
+ else if (current_view_is_properties_view ())
{
Key? fresh_key = (Key?) model.get_object (path);
if (fresh_key != null && !properties_view.check_reload ((!) fresh_key, model.get_key_value ((!)
fresh_key)))
return false;
}
- else if (current_view_is_browse_view ())
+
+ if (show_infobar && !current_view_is_search_results_view ())
{
- Directory? fresh_dir = (Directory?) model.get_directory (path);
- GLib.ListStore? fresh_key_model = model.get_children (fresh_dir);
- if (fresh_key_model != null && !browse_view.check_reload ((!) fresh_dir, (!) fresh_key_model))
- return false;
- } // search_results_view always reloads
+ show_hard_reload_warning ();
+ return false;
+ }
return true;
}
diff --git a/editor/dconf-editor.ui b/editor/dconf-editor.ui
index 6e0301a..8f3f71a 100644
--- a/editor/dconf-editor.ui
+++ b/editor/dconf-editor.ui
@@ -135,7 +135,7 @@
<signal name="stop-search" handler="search_cancelled"/>
</object>
</child>
- <child>
+ <!-- child>
<object class="GtkButton" id="search_options_button">
<property name="visible">False</property>
<property name="sensitive" bind-source="search_bar"
bind-property="search-mode-enabled"/>
@@ -146,6 +146,28 @@
</object>
</child>
</object>
+ </child -->
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">ui.reload-search</property>
+ <style>
+ <class name="image-button"/>
+ <class name="suggested-action"/>
+ </style>
+ <child internal-child="accessible">
+ <object class="AtkObject">
+ <property name="AtkObject::accessible-name"
translatable="yes">Refresh</property>
+ <property name="AtkObject::accessible-description"
translatable="yes">Refresh search results</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">view-refresh-symbolic</property>
+ </object>
+ </child>
+ </object>
</child>
</object>
</child>
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 3ee1bd5..72b0553 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -181,13 +181,12 @@ class DConfWindow : ApplicationWindow
model.finalize_model ();
model.paths_changed.connect ((_model, modified_path_specs, internal_changes) => {
- bool need_reload = browser_view.check_reload (current_path);
- if (need_reload)
+ if (browser_view.check_reload (current_path, !internal_changes)) // handle infobars in
needed
{
if (internal_changes)
- reload_view (false);
- else
- browser_view.show_hard_reload_warning ();
+ reload_view ();
+ else // search
+ reload_search_action.set_enabled (true);
}
pathbar.set_path (current_path); // update "ghost" status
});
@@ -333,11 +332,16 @@ class DConfWindow : ApplicationWindow
* * Action entries
\*/
+ private SimpleAction reload_search_action;
+
private void install_action_entries ()
{
SimpleActionGroup action_group = new SimpleActionGroup ();
action_group.add_action_entries (action_entries, this);
insert_action_group ("ui", action_group);
+
+ reload_search_action = (SimpleAction) action_group.lookup_action ("reload-search");
+ reload_search_action.set_enabled (false);
}
private const GLib.ActionEntry [] action_entries =
@@ -345,7 +349,8 @@ class DConfWindow : ApplicationWindow
{ "open-folder", open_folder, "s" },
{ "open-object", open_object, "s" },
{ "open-parent", open_parent, "s" },
- { "reload", reload },
+
+ { "reload-search", reload_search },
{ "reset-recursive", reset_recursively, "s" },
{ "reset-visible", reset_visible, "s" },
@@ -360,8 +365,12 @@ class DConfWindow : ApplicationWindow
{
if (bookmarks_button.active)
bookmarks_button.active = false;
+
string full_name = ((!) path_variant).get_string ();
- request_folder_path (full_name);
+ if (full_name == "") // reload
+ request_folder_path (current_path, browser_view.get_selected_row_name ());
+ else
+ request_folder_path (full_name, "");
}
private void open_object (SimpleAction action, Variant? path_variant)
@@ -369,8 +378,12 @@ class DConfWindow : ApplicationWindow
{
if (bookmarks_button.active)
bookmarks_button.active = false;
+
string full_name = ((!) path_variant).get_string ();
- request_object_path (full_name);
+ if (full_name == "") // reload
+ request_object_path (current_path);
+ else
+ request_object_path (full_name);
}
private void open_parent (SimpleAction action, Variant? path_variant)
@@ -380,9 +393,10 @@ class DConfWindow : ApplicationWindow
request_folder_path (SettingsModel.get_parent_path (full_name), full_name);
}
- private void reload (/* SimpleAction action, Variant? path_variant */)
+ private void reload_search (/* SimpleAction action, Variant? path_variant */)
{
- reload_view (true);
+ reload_search_action.set_enabled (false);
+ browser_view.reload_search (current_path, settings.get_strv ("bookmarks"));
}
private void reset_recursively (SimpleAction action, Variant? path_variant)
@@ -409,13 +423,13 @@ class DConfWindow : ApplicationWindow
invalidate_popovers ();
}
- private void apply_delayed_settings ()
+ private void apply_delayed_settings (/* SimpleAction action, Variant? path_variant */)
{
modifications_handler.apply_delayed_settings ();
invalidate_popovers ();
}
- private void dismiss_delayed_settings ()
+ private void dismiss_delayed_settings (/* SimpleAction action, Variant? path_variant */)
{
modifications_handler.dismiss_delayed_settings ();
invalidate_popovers ();
@@ -482,7 +496,7 @@ class DConfWindow : ApplicationWindow
browser_view.select_row (selected_or_empty);
}
- private void reload_view (bool notify_missing)
+ private void reload_view ()
{
if (browser_view.current_view_is_browse_view ())
{
@@ -496,7 +510,7 @@ class DConfWindow : ApplicationWindow
}
}
else if (browser_view.current_view_is_properties_view ())
- request_object_path (current_path, notify_missing);
+ request_object_path (current_path, false);
else if (browser_view.current_view_is_search_results_view ())
browser_view.reload_search (current_path, settings.get_strv ("bookmarks"));
}
@@ -553,7 +567,7 @@ class DConfWindow : ApplicationWindow
private void invalidate_popovers ()
{
invalidate_popovers_without_reload ();
- reload_view (false); // TODO better
+ reload_view (); // TODO better
}
private void invalidate_popovers_without_reload ()
{
@@ -568,15 +582,25 @@ class DConfWindow : ApplicationWindow
[GtkCallback]
private void search_changed ()
{
- if (search_bar.search_mode_enabled)
- browser_view.show_search_view (search_entry.text, current_path, settings.get_strv ("bookmarks"));
- else
+ if (!search_bar.search_mode_enabled)
+ {
+ reload_search_action.set_enabled (false);
browser_view.hide_search_view ();
+ return;
+ }
+ if (reload_search_action.get_enabled ())
+ {
+ reload_search_action.set_enabled (false);
+ browser_view.reload_search (current_path, settings.get_strv ("bookmarks"));
+ }
+ // do not place in an "else"
+ browser_view.show_search_view (search_entry.text, current_path, settings.get_strv ("bookmarks"));
}
[GtkCallback]
private void search_cancelled ()
{
+ reload_search_action.set_enabled (false);
browser_view.hide_search_view ();
}
@@ -818,6 +842,7 @@ class DConfWindow : ApplicationWindow
/*\
* * Non-existant path notifications
\*/
+
private void show_notification (string notification)
{
notification_label.set_text (notification);
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index fbd6d60..a68a803 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -56,11 +56,6 @@ class RegistryView : Grid, BrowsableView
* * Updating
\*/
- public GLib.ListStore? get_key_model ()
- {
- return key_model;
- }
-
public void set_key_model (GLib.ListStore _key_model)
{
key_model = _key_model;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]