[dconf-editor] Add BrowserInfoBar.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Add BrowserInfoBar.
- Date: Sun, 17 Dec 2017 06:48:29 +0000 (UTC)
commit ce8ba92b24412055012d85a3a339e460c26d3577
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Dec 17 07:47:25 2017 +0100
Add BrowserInfoBar.
There’s a bug when sort preferences are changed multiple times
in the row, but looks like it is in the model since before.
editor/browser-infobar.ui | 30 +++++++++++++
editor/browser-infobar.vala | 82 +++++++++++++++++++++++++++++++++++
editor/browser-view.ui | 85 +------------------------------------
editor/browser-view.vala | 19 ++++----
editor/dconf-editor.gresource.xml | 1 +
editor/meson.build | 2 +
editor/registry-view.ui | 34 +--------------
editor/registry-view.vala | 9 +++-
8 files changed, 134 insertions(+), 128 deletions(-)
---
diff --git a/editor/browser-infobar.ui b/editor/browser-infobar.ui
new file mode 100644
index 0000000..5b96760
--- /dev/null
+++ b/editor/browser-infobar.ui
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="dconf-editor">
+ <!-- interface-requires gtk+ 3.0 -->
+ <template class="BrowserInfoBar" parent="GtkRevealer">
+ <property name="visible">True</property>
+ <property name="reveal-child">False</property>
+ <child>
+ <object class="GtkInfoBar">
+ <property name="visible">True</property>
+ <property name="message-type">warning</property>
+ <child internal-child="action_area">
+ <object class="GtkBox">
+ <property name="visible">False</property>
+ </object>
+ </child>
+ <child internal-child="content_area">
+ <object class="GtkBox">
+ <child>
+ <object class="GtkStack" id="content">
+ <property name="visible">True</property>
+ <property name="halign">center</property>
+ <property name="transition-duration">400</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/editor/browser-infobar.vala b/editor/browser-infobar.vala
new file mode 100644
index 0000000..f3b5b6b
--- /dev/null
+++ b/editor/browser-infobar.vala
@@ -0,0 +1,82 @@
+/*
+ This file is part of Dconf Editor
+
+ Dconf Editor is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Dconf Editor is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Dconf Editor. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+using Gtk;
+
+[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/browser-infobar.ui")]
+class BrowserInfoBar : Revealer
+{
+ [GtkChild] Stack content;
+
+ public void add_label (string name, string text_label, string? button_label = null, string
button_action_name = "")
+ {
+ bool has_button = button_label != null;
+ if (has_button && button_action_name == "")
+ assert_not_reached ();
+
+ RegistryWarning grid = new RegistryWarning ();
+
+ Label label = new Label (text_label);
+ label.hexpand = true;
+ label.max_width_chars = 40;
+ label.wrap = true;
+
+ if (has_button)
+ {
+ Button button = new Button ();
+ button.label = (!) button_label;
+ button.action_name = (!) button_action_name;
+
+ label.set_xalign ((float) 0.0);
+ grid.add (label);
+ grid.add (button);
+ }
+ else
+ {
+ label.set_xalign ((float) 0.5);
+ grid.add (label);
+ }
+
+ grid.show_all ();
+ content.add_named (grid, name);
+ }
+
+ public void hide_warning ()
+ {
+ set_reveal_child (false);
+ }
+
+ public bool is_shown (string name)
+ {
+ return get_child_revealed () && (content.get_visible_child_name () == name);
+ }
+
+ public void show_warning (string name)
+ {
+ if (!get_child_revealed ())
+ {
+ content.set_transition_type (StackTransitionType.NONE);
+ content.set_visible_child_name (name);
+ set_reveal_child (true);
+ }
+ else if (content.get_visible_child_name () != name)
+ {
+ content.set_transition_type (StackTransitionType.SLIDE_DOWN);
+ content.set_visible_child_name (name);
+ }
+ }
+}
diff --git a/editor/browser-view.ui b/editor/browser-view.ui
index 137c779..77a5a84 100644
--- a/editor/browser-view.ui
+++ b/editor/browser-view.ui
@@ -4,91 +4,8 @@
<template class="BrowserView" parent="GtkGrid">
<property name="orientation">vertical</property>
<child>
- <object class="GtkRevealer" id="need_soft_reload_warning_revealer">
+ <object class="BrowserInfoBar" id="info_bar">
<property name="visible">True</property>
- <property name="reveal-child">False</property>
- <child>
- <object class="GtkInfoBar">
- <property name="visible">True</property>
- <property name="message-type">info</property>
- <child internal-child="action_area">
- <object class="GtkBox">
- <property name="visible">False</property>
- </object>
- </child>
- <child internal-child="content_area">
- <object class="GtkBox">
- <child>
- <object class="RegistryWarning">
- <property name="visible">True</property>
- <property name="halign">center</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="hexpand">True</property>
- <property name="xalign">0</property>
- <property name="max-width-chars">40</property>
- <property name="wrap">True</property>
- <property name="label" translatable="yes">Sort preferences have changed. Do you want
to reload the view?</property>
- </object>
- </child>
- <child>
- <object class="GtkButton">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Refresh</property>
- <property name="action-name">browser.reload</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkRevealer" id="need_hard_reload_warning_revealer">
- <property name="visible">True</property>
- <property name="reveal-child">False</property>
- <child>
- <object class="GtkInfoBar">
- <property name="visible">True</property>
- <property name="message-type">info</property>
- <child internal-child="action_area">
- <object class="GtkBox">
- <property name="visible">False</property>
- </object>
- </child>
- <child internal-child="content_area">
- <object class="GtkBox">
- <child>
- <object class="RegistryWarning">
- <property name="visible">True</property>
- <property name="halign">center</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="hexpand">True</property>
- <property name="xalign">0</property>
- <property name="max-width-chars">40</property>
- <property name="wrap">True</property>
- <property name="label" translatable="yes">This content has changed. Do you want to
reload the view?</property>
- </object>
- </child>
- <child>
- <object class="GtkButton">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Reload</property>
- <property name="action-name">browser.reload</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
</object>
</child>
<child>
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 3c4336c..82b62a6 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -38,8 +38,7 @@ class BrowserView : Grid, PathElement
private GLib.Settings settings = new GLib.Settings ("ca.desrt.dconf-editor.Settings");
private Directory current_directory;
- [GtkChild] private Revealer need_soft_reload_warning_revealer;
- [GtkChild] private Revealer need_hard_reload_warning_revealer;
+ [GtkChild] private BrowserInfoBar info_bar;
[GtkChild] private Stack stack;
[GtkChild] private RegistryView browse_view;
@@ -93,6 +92,11 @@ class BrowserView : Grid, PathElement
action_group.add_action_entries (action_entries, this);
insert_action_group ("browser", action_group);
+ info_bar.add_label ("soft-reload", _("Sort preferences have changed. Do you want to reload the
view?"),
+ _("Refresh"), "browser.reload");
+ info_bar.add_label ("hard-reload", _("This content has changed. Do you want to reload the view?"),
+ _("Reload"), "browser.reload");
+
ulong behaviour_changed_handler = settings.changed ["behaviour"].connect (invalidate_popovers);
settings.bind ("behaviour", browse_view, "behaviour",
SettingsBindFlags.GET|SettingsBindFlags.NO_SENSITIVITY);
@@ -278,21 +282,18 @@ class BrowserView : Grid, PathElement
private void hide_reload_warning ()
{
- need_soft_reload_warning_revealer.set_reveal_child (false);
- need_hard_reload_warning_revealer.set_reveal_child (false);
+ info_bar.hide_warning ();
}
private void show_soft_reload_warning ()
{
- if (!need_hard_reload_warning_revealer.get_reveal_child ())
- need_soft_reload_warning_revealer.set_reveal_child (true);
+ if (!info_bar.is_shown ("hard-reload"))
+ info_bar.show_warning ("soft-reload");
}
public void show_hard_reload_warning ()
{
- if (need_soft_reload_warning_revealer.get_reveal_child ())
- need_soft_reload_warning_revealer.set_reveal_child (false);
- need_hard_reload_warning_revealer.set_reveal_child (true);
+ info_bar.show_warning ("hard-reload");
}
private void reload (/* SimpleAction action, Variant? path_variant */)
diff --git a/editor/dconf-editor.gresource.xml b/editor/dconf-editor.gresource.xml
index 5e240a8..ff333ed 100644
--- a/editor/dconf-editor.gresource.xml
+++ b/editor/dconf-editor.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix="/ca/desrt/dconf-editor/ui">
<file preprocess="xml-stripblanks">bookmark.ui</file>
<file preprocess="xml-stripblanks">bookmarks.ui</file>
+ <file preprocess="xml-stripblanks">browser-infobar.ui</file>
<file preprocess="xml-stripblanks">browser-view.ui</file>
<file>dconf-editor.css</file>
<file preprocess="xml-stripblanks">dconf-editor.ui</file>
diff --git a/editor/meson.build b/editor/meson.build
index b0febdf..e160ab3 100644
--- a/editor/meson.build
+++ b/editor/meson.build
@@ -62,6 +62,7 @@ install_data(
sources = files(
'bookmarks.vala',
+ 'browser-infobar.vala',
'browser-view.vala',
'dconf-editor.vala',
'dconf-model.vala',
@@ -80,6 +81,7 @@ sources = files(
resource_data = files(
'bookmarks.ui',
'bookmark.ui',
+ 'browser-infobar.ui',
'browser-view.ui',
'dconf-editor.css',
'dconf-editor-menu.ui',
diff --git a/editor/registry-view.ui b/editor/registry-view.ui
index 8009988..664e84b 100644
--- a/editor/registry-view.ui
+++ b/editor/registry-view.ui
@@ -4,40 +4,8 @@
<template class="RegistryView" parent="GtkGrid">
<property name="orientation">vertical</property>
<child>
- <object class="GtkRevealer" id="multiple_schemas_warning_revealer">
+ <object class="BrowserInfoBar" id="info_bar">
<property name="visible">True</property>
- <property name="reveal-child">False</property>
- <child>
- <object class="GtkInfoBar">
- <property name="visible">True</property>
- <property name="message-type">warning</property>
- <child internal-child="action_area">
- <object class="GtkBox">
- <property name="visible">False</property>
- </object>
- </child>
- <child internal-child="content_area">
- <object class="GtkBox">
- <child>
- <object class="RegistryWarning">
- <property name="visible">True</property>
- <property name="halign">center</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="hexpand">True</property>
- <property name="xalign">0.5</property>
- <property name="max-width-chars">40</property>
- <property name="wrap">True</property>
- <property name="label" translatable="yes">Multiple schemas are installed at this
path. This could lead to problems if it hasn’t been done carefully. Only one schema is displayed here. Edit
values at your own risk.</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
</object>
</child>
<child>
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index 94895df..72abaaf 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -22,7 +22,7 @@ class RegistryView : Grid, PathElement, BrowsableView
{
public Behaviour behaviour { private get; set; }
- [GtkChild] private Revealer multiple_schemas_warning_revealer;
+ [GtkChild] private BrowserInfoBar info_bar;
[GtkChild] private ScrolledWindow scrolled;
@@ -58,6 +58,8 @@ class RegistryView : Grid, PathElement, BrowsableView
construct
{
+ info_bar.add_label ("multiple-schemas-folder", _("Multiple schemas are installed at this path. This
could lead to problems if it hasn’t been done carefully. Only one schema is displayed here. Edit values at
your own risk."));
+
key_list_box.set_header_func (update_row_header);
}
@@ -97,7 +99,10 @@ class RegistryView : Grid, PathElement, BrowsableView
public void show_multiple_schemas_warning (bool multiple_schemas_warning_needed)
{
- multiple_schemas_warning_revealer.set_reveal_child (multiple_schemas_warning_needed);
+ if (multiple_schemas_warning_needed)
+ info_bar.show_warning ("multiple-schemas-folder");
+ else
+ info_bar.hide_warning ();
}
public void focus_selected_row ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]