[dconf-editor] Introduce AdaptativeWidget.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Introduce AdaptativeWidget.
- Date: Wed, 14 Nov 2018 13:48:22 +0000 (UTC)
commit f4910a6b90a98f884ed32bf13b36660575acf781
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Oct 19 00:01:41 2018 +0200
Introduce AdaptativeWidget.
editor/adaptative-pathbar.vala | 23 ++++++---------
editor/browser-headerbar.vala | 40 ++++++++++++---------------
editor/browser-stack.vala | 11 +++-----
editor/browser-view.vala | 10 +++++--
editor/dconf-window.vala | 21 ++++++++------
editor/key-list-box-row.vala | 35 +++++++++++------------
editor/pathentry.vala | 63 +++++++++++++++++++-----------------------
editor/pathwidget.vala | 35 ++++++++++-------------
editor/registry-list.vala | 23 +++++++--------
9 files changed, 120 insertions(+), 141 deletions(-)
---
diff --git a/editor/adaptative-pathbar.vala b/editor/adaptative-pathbar.vala
index 5da9659..b352df2 100644
--- a/editor/adaptative-pathbar.vala
+++ b/editor/adaptative-pathbar.vala
@@ -18,24 +18,19 @@
using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/adaptative-pathbar.ui")]
-private class AdaptativePathbar : Stack, Pathbar
+private class AdaptativePathbar : Stack, Pathbar, AdaptativeWidget
{
[GtkChild] private LargePathbar large_pathbar;
[GtkChild] private ShortPathbar short_pathbar;
- private bool _extra_small_window = false;
- internal bool extra_small_window
+ private bool extra_small_window = false;
+ private void set_extra_small_window_state (bool new_value)
{
- private get { return _extra_small_window; }
- internal set
- {
- _extra_small_window = value;
-
- if (value)
- set_visible_child (short_pathbar);
- else
- set_visible_child (large_pathbar);
- }
+ extra_small_window = new_value;
+ if (new_value)
+ set_visible_child (short_pathbar);
+ else
+ set_visible_child (large_pathbar);
}
internal string get_complete_path ()
@@ -60,7 +55,7 @@ private class AdaptativePathbar : Stack, Pathbar
internal void toggle_menu ()
{
- if (_extra_small_window)
+ if (extra_small_window)
short_pathbar.toggle_menu ();
else
large_pathbar.toggle_menu ();
diff --git a/editor/browser-headerbar.vala b/editor/browser-headerbar.vala
index 19e072b..3d65ee5 100644
--- a/editor/browser-headerbar.vala
+++ b/editor/browser-headerbar.vala
@@ -18,7 +18,7 @@
using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/browser-headerbar.ui")]
-private class BrowserHeaderBar : HeaderBar
+private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
{
[GtkChild] private MenuButton info_button;
[GtkChild] private PathWidget path_widget;
@@ -33,30 +33,26 @@ private class BrowserHeaderBar : HeaderBar
internal signal void search_stopped ();
internal signal void update_bookmarks_icons (Variant bookmarks_variant);
- private bool _extra_small_window = false;
- internal bool extra_small_window
+ private bool extra_small_window = false;
+ private void set_extra_small_window_state (bool new_value)
{
- get { return _extra_small_window; }
- set
- {
- _extra_small_window = value;
+ extra_small_window = new_value;
- bookmarks_button.active = false;
- if (value)
- {
- bookmarks_button.sensitive = false;
- bookmarks_revealer.set_reveal_child (false);
- }
- else
- {
- bookmarks_button.sensitive = true;
- bookmarks_revealer.set_reveal_child (true);
- hide_in_window_bookmarks ();
- }
- update_hamburger_menu (delay_mode);
-
- path_widget.extra_small_window = value;
+ bookmarks_button.active = false;
+ if (new_value)
+ {
+ bookmarks_button.sensitive = false;
+ bookmarks_revealer.set_reveal_child (false);
}
+ else
+ {
+ bookmarks_button.sensitive = true;
+ bookmarks_revealer.set_reveal_child (true);
+ hide_in_window_bookmarks ();
+ }
+ update_hamburger_menu (delay_mode);
+
+ path_widget.set_extra_small_window_state (new_value);
}
internal bool search_mode_enabled { get { return path_widget.search_mode_enabled; }}
diff --git a/editor/browser-stack.vala b/editor/browser-stack.vala
index cae6092..868412c 100644
--- a/editor/browser-stack.vala
+++ b/editor/browser-stack.vala
@@ -18,7 +18,7 @@
using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/browser-stack.ui")]
-private class BrowserStack : Grid
+private class BrowserStack : Grid, AdaptativeWidget
{
[GtkChild] private Stack stack;
[GtkChild] private RegistryView folder_view;
@@ -36,13 +36,10 @@ private class BrowserStack : Grid
}
}
- internal bool extra_small_window
+ private void set_extra_small_window_state (bool new_value)
{
- set
- {
- folder_view.extra_small_window = value;
- search_view.extra_small_window = value;
- }
+ folder_view.set_extra_small_window_state (new_value);
+ search_view.set_extra_small_window_state (new_value);
}
internal ModificationsHandler modifications_handler
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index d482a52..1959bde 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -49,7 +49,7 @@ private class SimpleSettingObject : Object
}
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/browser-view.ui")]
-private class BrowserView : Stack
+private class BrowserView : Stack, AdaptativeWidget
{
internal uint16 last_context_id { get; private set; default = ModelUtils.undefined_context_id; }
@@ -60,7 +60,13 @@ private class BrowserView : Stack
private GLib.ListStore? key_model = null;
internal bool small_keys_list_rows { set { current_child.small_keys_list_rows = value; }}
- internal bool extra_small_window { set { current_child.extra_small_window = value; if (!value)
hide_in_window_bookmarks (); }}
+
+ private void set_extra_small_window_state (bool new_value)
+ {
+ current_child.set_extra_small_window_state (new_value);
+ if (!new_value)
+ hide_in_window_bookmarks ();
+ }
private ModificationsHandler _modifications_handler;
internal ModificationsHandler modifications_handler
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index a77d64d..2788a7e 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -85,6 +85,11 @@ internal enum ViewType {
}
}
+private interface AdaptativeWidget
+{
+ internal abstract void set_extra_small_window_state (bool new_value);
+}
+
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/dconf-editor.ui")]
private class DConfWindow : ApplicationWindow
{
@@ -429,8 +434,8 @@ private class DConfWindow : ApplicationWindow
{
extra_small_window = false;
context.remove_class ("extra-small-window");
- headerbar.extra_small_window = false;
- browser_view.extra_small_window = false;
+ headerbar.set_extra_small_window_state (false);
+ browser_view.set_extra_small_window_state (false);
}
context.remove_class ("small-window");
context.add_class ("large-window");
@@ -445,8 +450,8 @@ private class DConfWindow : ApplicationWindow
{
extra_small_window = true;
context.add_class ("extra-small-window");
- headerbar.extra_small_window = true;
- browser_view.extra_small_window = true;
+ headerbar.set_extra_small_window_state (true);
+ browser_view.set_extra_small_window_state (true);
}
notification_revealer.hexpand = true;
notification_revealer.halign = Align.FILL;
@@ -458,8 +463,8 @@ private class DConfWindow : ApplicationWindow
{
extra_small_window = false;
context.remove_class ("extra-small-window");
- headerbar.extra_small_window = false;
- browser_view.extra_small_window = false;
+ headerbar.set_extra_small_window_state (false);
+ browser_view.set_extra_small_window_state (false);
}
context.add_class ("small-window");
notification_revealer.hexpand = true;
@@ -473,8 +478,8 @@ private class DConfWindow : ApplicationWindow
{
extra_small_window = false;
context.remove_class ("extra-small-window");
- headerbar.extra_small_window = false;
- browser_view.extra_small_window = false;
+ headerbar.set_extra_small_window_state (false);
+ browser_view.set_extra_small_window_state (false);
}
notification_revealer.hexpand = false;
notification_revealer.halign = Align.CENTER;
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index acb3cdc..6877b82 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -219,27 +219,24 @@ private class KeyListBoxRow : ClickableListBoxRow
}
}
- private bool _extra_small_window = false;
- internal bool extra_small_window
+ private bool extra_small_window = false;
+ internal void set_extra_small_window_state (bool new_value)
{
- set
+ extra_small_window = new_value;
+ if (new_value)
{
- _extra_small_window = value;
- if (value)
- {
- if (boolean_switch != null)
- ((!) boolean_switch).hide ();
- key_value_label.hide ();
- key_type_label.show ();
- }
+ if (boolean_switch != null)
+ ((!) boolean_switch).hide ();
+ key_value_label.hide ();
+ key_type_label.show ();
+ }
+ else
+ {
+ key_type_label.hide ();
+ if (_use_switch && !delay_mode)
+ ((!) boolean_switch).show ();
else
- {
- key_type_label.hide ();
- if (_use_switch && !delay_mode)
- ((!) boolean_switch).show ();
- else
- key_value_label.show ();
- }
+ key_value_label.show ();
}
}
@@ -386,7 +383,7 @@ private class KeyListBoxRow : ClickableListBoxRow
private void hide_or_show_switch ()
requires (boolean_switch != null)
{
- if (_extra_small_window)
+ if (extra_small_window)
{
key_value_label.hide ();
((!) boolean_switch).hide ();
diff --git a/editor/pathentry.vala b/editor/pathentry.vala
index b0f7dcb..5ccfbe4 100644
--- a/editor/pathentry.vala
+++ b/editor/pathentry.vala
@@ -18,7 +18,7 @@
using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/pathentry.ui")]
-private class PathEntry : Box
+private class PathEntry : Box, AdaptativeWidget
{
[GtkChild] private Button hide_search_button;
[GtkChild] private Button reload_search_button;
@@ -31,46 +31,39 @@ private class PathEntry : Box
internal bool entry_has_focus { get { return search_entry.has_focus; }}
private ulong can_reload_handler = 0;
- private bool _extra_small_window = false;
- internal bool extra_small_window
+ private void set_extra_small_window_state (bool new_value)
{
- private get { return _extra_small_window; }
- internal set
+ if (new_value)
{
- _extra_small_window = value;
-
- if (value)
+ search_entry.set_icon_from_pixbuf (EntryIconPosition.PRIMARY, null);
+
+ can_reload_handler = reload_search_button.notify ["sensitive"].connect (() => {
+ if (reload_search_button.sensitive)
+ {
+ hide_search_button.hide ();
+ reload_search_button.show ();
+ }
+ else
+ {
+ reload_search_button.hide ();
+ hide_search_button.show ();
+ }
+ });
+
+ if (!reload_search_button.sensitive)
{
- search_entry.set_icon_from_pixbuf (EntryIconPosition.PRIMARY, null);
-
- can_reload_handler = reload_search_button.notify ["sensitive"].connect (() => {
- if (reload_search_button.sensitive)
- {
- hide_search_button.hide ();
- reload_search_button.show ();
- }
- else
- {
- reload_search_button.hide ();
- hide_search_button.show ();
- }
- });
-
- if (!reload_search_button.sensitive)
- {
- reload_search_button.hide ();
- hide_search_button.show ();
- }
+ reload_search_button.hide ();
+ hide_search_button.show ();
}
- else
- {
- search_entry.set_icon_from_icon_name (EntryIconPosition.PRIMARY, "edit-find-symbolic");
+ }
+ else
+ {
+ search_entry.set_icon_from_icon_name (EntryIconPosition.PRIMARY, "edit-find-symbolic");
- reload_search_button.disconnect (can_reload_handler);
+ reload_search_button.disconnect (can_reload_handler);
- hide_search_button.hide ();
- reload_search_button.show ();
- }
+ hide_search_button.hide ();
+ reload_search_button.show ();
}
}
diff --git a/editor/pathwidget.vala b/editor/pathwidget.vala
index dd5a1f3..3f1b63e 100644
--- a/editor/pathwidget.vala
+++ b/editor/pathwidget.vala
@@ -18,7 +18,7 @@
using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/pathwidget.ui")]
-private class PathWidget : Box
+private class PathWidget : Box, AdaptativeWidget
{
[GtkChild] private ModelButton search_toggle; // most window size button
[GtkChild] private ModelButton search_button; // extra-small-window only
@@ -37,29 +37,22 @@ private class PathWidget : Box
search_button.icon = search_icon;
}
- private bool _extra_small_window = false;
- internal bool extra_small_window
+ private void set_extra_small_window_state (bool new_value)
{
- private get { return _extra_small_window; }
- internal set
- {
- _extra_small_window = value;
-
- pathbar.extra_small_window = value;
+ pathbar.set_extra_small_window_state (new_value);
- if (value)
- {
- search_toggle.hide ();
- search_button.show ();
- }
- else
- {
- search_button.hide ();
- search_toggle.show ();
- }
-
- searchentry.extra_small_window = value;
+ if (new_value)
+ {
+ search_toggle.hide ();
+ search_button.show ();
}
+ else
+ {
+ search_button.hide ();
+ search_toggle.show ();
+ }
+
+ searchentry.set_extra_small_window_state (new_value);
}
/*\
diff --git a/editor/registry-list.vala b/editor/registry-list.vala
index f621b67..a0d205d 100644
--- a/editor/registry-list.vala
+++ b/editor/registry-list.vala
@@ -18,7 +18,7 @@
using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/registry-view.ui")]
-private abstract class RegistryList : Grid, BrowsableView
+private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
{
[GtkChild] protected ListBox key_list_box;
[GtkChild] protected RegistryPlaceholder placeholder;
@@ -54,18 +54,15 @@ private abstract class RegistryList : Grid, BrowsableView
}
}
- private bool _extra_small_window;
- internal bool extra_small_window
+ private bool extra_small_window = false;
+ private void set_extra_small_window_state (bool new_value)
{
- set
- {
- _extra_small_window = value;
- key_list_box.foreach ((row) => {
- Widget? row_child = ((ListBoxRow) row).get_child ();
- if (row_child != null && (!) row_child is KeyListBoxRow)
- ((KeyListBoxRow) (!) row_child).extra_small_window = value;
- });
- }
+ extra_small_window = new_value;
+ key_list_box.@foreach ((row) => {
+ Widget? row_child = ((ListBoxRow) row).get_child ();
+ if (row_child != null && (!) row_child is KeyListBoxRow)
+ ((KeyListBoxRow) (!) row_child).set_extra_small_window_state (new_value);
+ });
}
protected void select_row_and_if_true_grab_focus (ListBoxRow row, bool grab_focus)
@@ -394,7 +391,7 @@ private abstract class RegistryList : Grid, BrowsableView
KeyListBoxRow key_row = create_key_list_box_row (full_name, context_id, properties,
modifications_handler.get_current_delay_mode (), search_mode_non_local_result);
key_row.small_keys_list_rows = _small_keys_list_rows;
- key_row.extra_small_window = _extra_small_window;
+ key_row.set_extra_small_window_state (extra_small_window);
ulong delayed_modifications_changed_handler =
modifications_handler.delayed_changes_changed.connect ((_modifications_handler) => set_delayed_icon
(_modifications_handler, key_row));
set_delayed_icon (modifications_handler, key_row);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]