[gnome-clocks] world-dialog: Re structure
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] world-dialog: Re structure
- Date: Fri, 7 Jan 2022 17:23:45 +0000 (UTC)
commit 816654a354215c181cc72cbec434386897d2df84
Author: Maximiliano Sandoval R <msandova gnome org>
Date: Tue Dec 14 02:56:08 2021 +0100
world-dialog: Re structure
data/ui/world-location-dialog.ui | 57 ++++++++++++++++++++--------------------
src/world-location-dialog.vala | 15 ++++++++++-
2 files changed, 42 insertions(+), 30 deletions(-)
---
diff --git a/data/ui/world-location-dialog.ui b/data/ui/world-location-dialog.ui
index 24c87c9f..94e98537 100644
--- a/data/ui/world-location-dialog.ui
+++ b/data/ui/world-location-dialog.ui
@@ -32,46 +32,45 @@
</object>
</property>
<child>
- <object class="GtkScrolledWindow">
- <property name="hscrollbar_policy">never</property>
- <property name="height_request">250</property>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
<child>
- <object class="AdwClamp">
- <property name="width_request">300</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
+ <object class="GtkSearchBar" id="search_bar">
+ <property name="search-mode-enabled">True</property>
+ <signal name="notify::search-mode-enabled" handler="on_search_mode_notify" swapped="no"/>
+ <property name="child">
+ <object class="GtkSearchEntry" id="location_entry">
+ <signal name="search-changed" handler="on_search_changed" swapped="no"/>
+ </object>
+ </property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="stack">
<child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkSearchEntry" id="location_entry">
- <property name="margin_top">18</property>
- <property name="margin_start">50</property>
- <property name="margin_end">50</property>
- <signal name="search-changed" handler="on_search_changed" swapped="no"/>
- </object>
- </child>
+ <object class="AdwStatusPage" id="empty_search">
+ <property name="icon_name">edit-find-symbolic</property>
+ <property name="title" translatable="yes">Search for a City</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="search_results">
+ <property name="hscrollbar_policy">never</property>
+ <property name="vexpand">True</property>
<child>
- <object class="GtkStack" id="stack">
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="transition_duration">100</property>
- <property name="transition_type">crossfade</property>
- <child>
- <object class="AdwStatusPage" id="empty_search">
- <property name="icon_name">edit-find-symbolic</property>
- <property name="title" translatable="yes">Search for a City</property>
- </object>
- </child>
+ <object class="AdwClamp">
+ <property name="width_request">300</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
<child>
<object class="GtkListBox" id="listbox">
<property name="valign">start</property>
<property name="selection_mode">none</property>
+ <signal name="row-activated" handler="item_activated" swapped="no"/>
<style>
<class name="clocks-list"/>
<class name="boxed-list"/>
</style>
- <signal name="row-activated" handler="item_activated" swapped="no"/>
</object>
</child>
</object>
diff --git a/src/world-location-dialog.vala b/src/world-location-dialog.vala
index fa22280b..35e64585 100644
--- a/src/world-location-dialog.vala
+++ b/src/world-location-dialog.vala
@@ -35,6 +35,8 @@ private class LocationDialog : Gtk.Window {
[GtkChild]
private unowned Gtk.Widget empty_search;
[GtkChild]
+ private unowned Gtk.Widget search_results;
+ [GtkChild]
private unowned Gtk.SearchEntry location_entry;
[GtkChild]
private unowned Gtk.ListBox listbox;
@@ -58,6 +60,9 @@ private class LocationDialog : Gtk.Window {
public LocationDialog (Gtk.Window parent, Face world_face) {
Object (transient_for: parent);
+ // HACK: We set the key capture widget on the entry
+ // rather than the search bar. This way when pressing
+ // TAB the widget will continue to get input events.
location_entry.set_key_capture_widget (this);
world = world_face;
@@ -74,6 +79,14 @@ private class LocationDialog : Gtk.Window {
return ((LocationDialogRow) selected_row).data.location;
}
+ [GtkCallback]
+ private void on_search_mode_notify (GLib.Object object, GLib.ParamSpec param) {
+ // Pressing ESC will close the search bar, we don't want that.
+ var search_bar = (Gtk.SearchBar) object;
+ if (!search_bar.search_mode_enabled)
+ search_bar.search_mode_enabled = true;
+ }
+
[GtkCallback]
private void item_activated (Gtk.ListBoxRow listbox_row) {
var row = (LocationDialogRow) listbox_row;
@@ -120,7 +133,7 @@ private class LocationDialog : Gtk.Window {
return strcmp (name_a, name_b);
});
- stack.visible_child = listbox;
+ stack.visible_child = search_results;
}
public signal void location_added ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]