[dconf-editor] Make PathEntry work on small screens.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Make PathEntry work on small screens.
- Date: Wed, 14 Nov 2018 13:47:37 +0000 (UTC)
commit b6a0bdb1bbe780bbce905670e421e521b93f61ea
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Oct 12 11:23:26 2018 +0200
Make PathEntry work on small screens.
editor/browser-headerbar.ui | 1 -
editor/browser-headerbar.vala | 3 +++
editor/dconf-editor.ui | 2 +-
editor/dconf-window.vala | 16 ++++++++++++-
editor/pathentry.ui | 23 +++++++++++++++++-
editor/pathentry.vala | 45 +++++++++++++++++++++++++++++++++-
editor/pathwidget.ui | 56 +++++++++++++++++++++++++++++--------------
editor/pathwidget.vala | 38 +++++++++++++++++++++++++----
8 files changed, 157 insertions(+), 27 deletions(-)
---
diff --git a/editor/browser-headerbar.ui b/editor/browser-headerbar.ui
index fe61b3a..e68752c 100644
--- a/editor/browser-headerbar.ui
+++ b/editor/browser-headerbar.ui
@@ -45,7 +45,6 @@
<property name="valign">center</property>
<property name="focus-on-click">False</property>
<property name="schema-path">/ca/desrt/dconf-editor/</property>
- <!-- <accelerator key="B" signal="activate" modifiers="GDK_CONTROL_MASK"/> TODO -->
<signal name="update-bookmarks-icons" handler="update_bookmarks_icons_cb"/>
<style>
<class name="image-button"/> <!-- TODO https://bugzilla.gnome.org/show_bug.cgi?id=756731
-->
diff --git a/editor/browser-headerbar.vala b/editor/browser-headerbar.vala
index 2c2b1a1..fdd6aa9 100644
--- a/editor/browser-headerbar.vala
+++ b/editor/browser-headerbar.vala
@@ -40,6 +40,7 @@ private class BrowserHeaderBar : HeaderBar
set
{
_extra_small_window = value;
+
bookmarks_button.active = false;
if (value)
{
@@ -53,6 +54,8 @@ private class BrowserHeaderBar : HeaderBar
hide_in_window_bookmarks ();
}
update_hamburger_menu (delay_mode);
+
+ path_widget.extra_small_window = value;
}
}
diff --git a/editor/dconf-editor.ui b/editor/dconf-editor.ui
index cd70c46..a834143 100644
--- a/editor/dconf-editor.ui
+++ b/editor/dconf-editor.ui
@@ -5,7 +5,7 @@
<property name="visible">False</property>
<property name="title" translatable="yes">dconf Editor</property>
<property name="height-request">290</property> <!-- 294 max for Purism Librem 5 landscape -->
- <property name="width-request">550</property> <!-- 360 max for Purism Librem 5 portrait -->
+ <property name="width-request">450</property> <!-- 360 max for Purism Librem 5 portrait -->
<signal name="key-press-event" handler="on_key_press_event"/>
<signal name="button-press-event" handler="on_button_press_event"/>
<signal name="window-state-event" handler="on_window_state_event"/>
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 256b623..edb6b24 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -559,7 +559,10 @@ private class DConfWindow : ApplicationWindow
{ "reload-object", reload_object },
{ "reload-search", reload_search },
- { "toggle-search", toggle_search, "b" },
+ { "hide-search", hide_search },
+ { "show-search", show_search },
+
+ { "toggle-search", toggle_search, "b", "false" },
{ "update-bookmarks-icons", update_bookmarks_icons, "as" },
{ "show-in-window-bookmarks", show_in_window_bookmarks },
@@ -668,10 +671,21 @@ private class DConfWindow : ApplicationWindow
request_search (true);
}
+ private void hide_search (/* SimpleAction action, Variant? path_variant */)
+ {
+ stop_search ();
+ }
+
+ private void show_search (/* SimpleAction action, Variant? path_variant */)
+ {
+ request_search (true, PathEntry.SearchMode.EDIT_PATH_SELECT_ALL);
+ }
+
private void toggle_search (SimpleAction action, Variant? path_variant)
requires (path_variant != null)
{
bool search_request = ((!) path_variant).get_boolean ();
+ action.change_state (search_request);
if (search_request && !headerbar.search_mode_enabled)
request_search (true, PathEntry.SearchMode.EDIT_PATH_SELECT_ALL);
else if (!search_request && headerbar.search_mode_enabled)
diff --git a/editor/pathentry.ui b/editor/pathentry.ui
index 87ca2b6..1f609d3 100644
--- a/editor/pathentry.ui
+++ b/editor/pathentry.ui
@@ -28,7 +28,28 @@
</object>
</child -->
<child>
- <object class="GtkButton">
+ <object class="GtkButton" id="hide_search_button">
+ <property name="visible">False</property>
+ <property name="action-name">ui.hide-search</property>
+ <style>
+ <class name="image-button"/>
+ </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">window-close-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="reload_search_button">
<property name="visible">True</property>
<property name="action-name">ui.reload-search</property>
<style>
diff --git a/editor/pathentry.vala b/editor/pathentry.vala
index 87033cd..b54110f 100644
--- a/editor/pathentry.vala
+++ b/editor/pathentry.vala
@@ -20,13 +20,56 @@ using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/pathentry.ui")]
private class PathEntry : Box
{
- [GtkChild] SearchEntry search_entry;
+ [GtkChild] private Button hide_search_button;
+ [GtkChild] private Button reload_search_button;
+
+ [GtkChild] private SearchEntry search_entry;
private string current_path = "";
internal string text { get { return search_entry.text; }}
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 get { return _extra_small_window; }
+ internal set
+ {
+ _extra_small_window = value;
+
+ if (value)
+ {
+ 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 ();
+ }
+ }
+ else
+ {
+ reload_search_button.disconnect (can_reload_handler);
+
+ hide_search_button.hide ();
+ reload_search_button.show ();
+ }
+ }
+ }
+
internal enum SearchMode {
UNCLEAR,
EDIT_PATH_MOVE_END,
diff --git a/editor/pathwidget.ui b/editor/pathwidget.ui
index a4533a4..c3588b5 100644
--- a/editor/pathwidget.ui
+++ b/editor/pathwidget.ui
@@ -7,7 +7,7 @@
<object class="GtkStack" id="pathbar_stack">
<property name="visible">True</property>
<property name="valign">center</property>
- <property name="visible-child">pathbar</property> <!-- uses the "id" attribute -->
+ <property name="visible-child">pathbar_grid</property> <!-- uses the "id" attribute -->
<property name="transition-duration">300</property>
<property name="transition-type">crossfade</property>
<child>
@@ -17,32 +17,59 @@
<signal name="search-stopped" handler="search_stopped_cb"/>
</object>
<packing>
- <property name="icon-name">document-edit-symbolic</property> <!-- TODO document-edit-symbolic ?
-->
- <property name="title" translatable="yes">Edit path</property>
- <property name="name">entry</property>
+ <!-- property name="icon-name">document-edit-symbolic</property> TODO document-edit-symbolic
? -->
+ <property name="title" translatable="yes">Edit path</property> <!-- TODO reuse translation...
1/2 -->
+ <!-- property name="name">entry</property -->
</packing>
</child>
<child>
- <object class="PathBar" id="pathbar">
+ <object class="GtkGrid" id="pathbar_grid">
<property name="visible">True</property>
- <property name="valign">center</property>
+ <child>
+ <object class="PathBar" id="pathbar">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton" id="search_button">
+ <property name="visible">False</property>
+ <property name="halign">end</property>
+ <property name="hexpand">True</property>
+ <property name="valign">center</property>
+ <property name="focus-on-click">False</property>
+ <property name="iconic">True</property>
+ <property name="centered">True</property>
+ <property name="action-name">ui.show-search</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child internal-child="accessible">
+ <object class="AtkObject">
+ <property name="AtkObject::accessible-name" translatable="yes">Search</property>
+ <property name="AtkObject::accessible-description" translatable="yes">Search
keys</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
- <property name="icon-name">folder-visiting-symbolic</property>
- <property name="title" translatable="yes">Browse keys</property>
- <property name="name">pathbar</property>
+ <!-- property name="icon-name">folder-visiting-symbolic</property -->
+ <property name="title" translatable="yes">Browse keys</property> <!-- TODO reuse translation...
2/2 -->
+ <!-- property name="name">pathbar</property -->
</packing>
</child>
</object>
</child>
<child>
- <object class="GtkToggleButton" id="search_toggle">
+ <object class="GtkModelButton" id="search_toggle">
<property name="visible">True</property>
<property name="valign">center</property>
<property name="focus-on-click">False</property>
+ <property name="iconic">True</property>
+ <property name="centered">True</property>
<property name="action-name">ui.toggle-search</property>
<property name="action-target">true</property>
- <!-- <accelerator key="F" signal="toggled" modifiers="GDK_CONTROL_MASK"/> TODO -->
<style>
<class name="image-button"/>
</style>
@@ -52,13 +79,6 @@
<property name="AtkObject::accessible-description" translatable="yes">Search keys</property>
</object>
</child>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon-name">edit-find-symbolic</property>
- <property name="icon-size">1</property>
- </object>
- </child>
</object>
</child>
</template>
diff --git a/editor/pathwidget.vala b/editor/pathwidget.vala
index bb2851a..6d63c95 100644
--- a/editor/pathwidget.vala
+++ b/editor/pathwidget.vala
@@ -20,14 +20,46 @@ using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/pathwidget.ui")]
private class PathWidget : Box
{
- [GtkChild] private ToggleButton search_toggle;
+ [GtkChild] private ModelButton search_toggle; // most window size button
+ [GtkChild] private ModelButton search_button; // extra-small-window only
[GtkChild] private Stack pathbar_stack;
+ [GtkChild] private Grid pathbar_grid;
[GtkChild] private PathBar pathbar;
[GtkChild] private PathEntry searchentry;
internal signal void search_changed ();
internal signal void search_stopped ();
+ private ThemedIcon search_icon = new ThemedIcon.from_names ({"edit-find-symbolic"});
+ construct
+ {
+ search_toggle.icon = search_icon;
+ search_button.icon = search_icon;
+ }
+
+ private bool _extra_small_window = false;
+ internal bool extra_small_window
+ {
+ private get { return _extra_small_window; }
+ internal set
+ {
+ _extra_small_window = value;
+
+ if (value)
+ {
+ search_toggle.hide ();
+ search_button.show ();
+ }
+ else
+ {
+ search_button.hide ();
+ search_toggle.show ();
+ }
+
+ searchentry.extra_small_window = value;
+ }
+ }
+
/*\
* * search mode
\*/
@@ -37,7 +69,6 @@ private class PathWidget : Box
private void enter_search_mode ()
{
search_mode_enabled = true;
- search_toggle.active = true;
search_toggle.set_action_target_value (false);
pathbar_stack.set_visible_child (searchentry);
}
@@ -45,9 +76,8 @@ private class PathWidget : Box
private void leave_search_mode ()
{
search_mode_enabled = false;
- search_toggle.active = false;
search_toggle.set_action_target_value (true);
- pathbar_stack.set_visible_child (pathbar);
+ pathbar_stack.set_visible_child (pathbar_grid);
}
/*\
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]