[gnome-software] Do not show the search bar by default
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Do not show the search bar by default
- Date: Tue, 31 May 2016 16:37:35 +0000 (UTC)
commit 3299b31df7d95bd645af4abc6382e246c6d3fad7
Author: Richard Hughes <richard hughsie com>
Date: Tue May 31 16:45:51 2016 +0100
Do not show the search bar by default
Thes user has to start typing or click the search button to show it.
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=710640
src/gnome-software.ui | 111 +++++++++++++++++++++++++---------------------
src/gs-shell-overview.c | 36 ++++++++++++++-
src/gs-shell-overview.ui | 2 +-
src/gs-shell.c | 6 ++-
4 files changed, 101 insertions(+), 54 deletions(-)
---
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index 857ded6..4207bd6 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -248,76 +248,84 @@
<property name="position">0</property>
</packing>
</child>
+
<child>
- <object class="GtkToolbar" id="search_bar">
- <property name="visible">False</property>
- <property name="can_focus">False</property>
- <style>
- <class name="search-bar"/>
- </style>
+ <object class="GtkRevealer" id="search_bar">
+ <property name="visible">True</property>
+ <property name="transition-type">slide-up</property>
+
<child>
- <object class="GtkToolItem" id="search_toolitem">
+ <object class="GtkToolbar" id="search_bar_toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <style>
+ <class name="search-bar"/>
+ </style>
<child>
- <object class="GtkBox" id="search_toolbox">
+ <object class="GtkToolItem" id="search_toolitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkBox" id="box_left">
+ <object class="GtkBox" id="search_toolbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="hexpand">True</property>
- <property name="orientation">vertical</property>
<child>
- <placeholder/>
+ <object class="GtkBox" id="box_left">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
</child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkSearchEntry" id="entry_search">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="activates_default">True</property>
- <property name="width_request">500</property>
- <property name="hexpand">True</property>
- <property name="halign">center</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="box_right">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="hexpand">True</property>
- <property name="orientation">vertical</property>
<child>
- <placeholder/>
+ <object class="GtkSearchEntry" id="entry_search">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="activates_default">True</property>
+ <property name="width_request">500</property>
+ <property name="hexpand">True</property>
+ <property name="halign">center</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box_right">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
</object>
+ <packing>
+ <property name="expand">True</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="expand">True</property>
- </packing>
</child>
</object>
<packing>
@@ -326,6 +334,7 @@
<property name="position">1</property>
</packing>
</child>
+
<child>
<object class="GtkStack" id="stack_main">
<property name="visible">True</property>
diff --git a/src/gs-shell-overview.c b/src/gs-shell-overview.c
index 9025f39..435514a 100644
--- a/src/gs-shell-overview.c
+++ b/src/gs-shell-overview.c
@@ -50,6 +50,8 @@ typedef struct
gboolean empty;
gchar *category_of_day;
+ GtkWidget *search_button;
+
GtkWidget *bin_featured;
GtkWidget *box_overview;
GtkWidget *box_popular;
@@ -490,10 +492,13 @@ gs_shell_overview_switch_to (GsPage *page, gboolean scroll_up)
return;
}
+ /* we hid the search bar */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->search_button), FALSE);
+
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
gtk_widget_show (widget);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
- gtk_widget_show (widget);
+ gtk_revealer_set_reveal_child (GTK_REVEALER (widget), FALSE);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search"));
gtk_entry_set_text (GTK_ENTRY (widget), "");
@@ -510,6 +515,24 @@ gs_shell_overview_switch_to (GsPage *page, gboolean scroll_up)
}
static void
+gs_shell_overview_search_button_cb (GtkButton *button, GsShellOverview *self)
+{
+ GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self);
+ GtkWidget *widget;
+
+ /* show search */
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search_button))) {
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
+ gtk_revealer_set_reveal_child (GTK_REVEALER (widget), TRUE);
+ return;
+ }
+
+ /* hide search */
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
+ gtk_revealer_set_reveal_child (GTK_REVEALER (widget), FALSE);
+}
+
+static void
gs_shell_overview_categories_expander_cb (GtkButton *button, GsShellOverview *self)
{
GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self);
@@ -527,6 +550,7 @@ gs_shell_overview_setup (GsShellOverview *self,
GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self);
GtkAdjustment *adj;
GtkWidget *tile;
+ GtkWidget *im;
gint i;
g_return_if_fail (GS_IS_SHELL_OVERVIEW (self));
@@ -556,6 +580,16 @@ gs_shell_overview_setup (GsShellOverview *self,
g_signal_connect (priv->categories_expander_button, "clicked",
G_CALLBACK (gs_shell_overview_categories_expander_cb), self);
+ /* search button */
+ priv->search_button = gtk_toggle_button_new ();
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->search_button), FALSE);
+ im = gtk_image_new_from_icon_name ("edit-find-symbolic", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_set_visible (im, TRUE);
+ gtk_container_add (GTK_CONTAINER (priv->search_button), im);
+ gtk_widget_set_visible (priv->search_button, TRUE);
+ gs_page_set_header_end_widget (GS_PAGE (self), priv->search_button);
+ g_signal_connect (priv->search_button, "clicked",
+ G_CALLBACK (gs_shell_overview_search_button_cb), self);
/* chain up */
gs_page_setup (GS_PAGE (self),
diff --git a/src/gs-shell-overview.ui b/src/gs-shell-overview.ui
index 62ce9b8..aa470bc 100644
--- a/src/gs-shell-overview.ui
+++ b/src/gs-shell-overview.ui
@@ -34,7 +34,7 @@
<property name="halign">fill</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
- <property name="margin-top">6</property>
+ <property name="margin-top">12</property>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 09b1b07..382d11f 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -248,7 +248,7 @@ gs_shell_change_mode (GsShell *shell,
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header_selection_menu_button"));
gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
- gtk_widget_hide (widget);
+ gtk_revealer_set_reveal_child (GTK_REVEALER (widget), FALSE);
context = gtk_widget_get_style_context (GTK_WIDGET (gtk_builder_get_object (priv->builder,
"header")));
gtk_style_context_remove_class (context, "selection-mode");
@@ -496,6 +496,7 @@ window_keypress_handler (GtkWidget *window, GdkEvent *event, GsShell *shell)
{
GsShellPrivate *priv = gs_shell_get_instance_private (shell);
GtkWidget *entry;
+ GtkWidget *widget;
guint keyval;
gboolean handled;
gboolean preedit_changed;
@@ -514,6 +515,9 @@ window_keypress_handler (GtkWidget *window, GdkEvent *event, GsShell *shell)
keyval == GDK_KEY_Menu)
return GDK_EVENT_PROPAGATE;
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
+ gtk_revealer_set_reveal_child (GTK_REVEALER (widget), TRUE);
+
entry = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search"));
handled = GDK_EVENT_PROPAGATE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]