[gnome-notes/wip/igaldino/narrow] search-toolbar: reduce search entry



commit ddcaec41ca111e8580bfed9a785b0aa9839aff36
Author: Isaque Galdino <igaldino gmail com>
Date:   Wed Oct 23 22:59:57 2019 -0300

    search-toolbar: reduce search entry
    
    In order to be more descriptive, this commit replaces GtkSearchBar by
    HdySearchBar widget. The latter handles window resizing better, so
    search entry field resizes according to window size.
    
    The downside of this change it's the addiction of a new dependency:
    libhandy.

 build-aux/flatpak/org.gnome.Notes.json | 17 +++++++++++++++++
 meson.build                            |  1 +
 src/bjb-search-toolbar.c               | 11 +++++------
 src/bjb-search-toolbar.h               | 10 +++-------
 4 files changed, 26 insertions(+), 13 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Notes.json b/build-aux/flatpak/org.gnome.Notes.json
index 784c37b..88353e6 100644
--- a/build-aux/flatpak/org.gnome.Notes.json
+++ b/build-aux/flatpak/org.gnome.Notes.json
@@ -47,6 +47,23 @@
         "*.a"
     ],
     "modules" : [
+        {
+            "name" : "libhandy",
+            "buildsystem" : "meson",
+            "config-opts" : [
+                "-Dexamples=false",
+                "-Dglade_catalog=disabled",
+                "-Dintrospection=disabled",
+                "-Dtests=false",
+                "-Dvapi=false"
+            ],
+            "sources" : [
+                {
+                    "type" : "git",
+                    "url" : "https://source.puri.sm/Librem5/libhandy.git";
+                }
+            ]
+        },
         {
             "name" : "gnome-online-accounts",
             "config-opts" : [
diff --git a/meson.build b/meson.build
index 5c7ab37..afce972 100644
--- a/meson.build
+++ b/meson.build
@@ -116,6 +116,7 @@ bijiben_deps = [
   dependency('gtk+-3.0', version: '>= 3.19.3'),
   dependency('libecal-2.0', version: '>= 3.33.2'),
   dependency('libedataserver-1.2', version: '>= 3.13.90'),
+  dependency('libhandy-0.0', version: '>= 0.0.10'),
   dependency('libxml-2.0'),
   dependency('uuid'),
   dependency('webkit2gtk-4.0', version: '>= 2.10'),
diff --git a/src/bjb-search-toolbar.c b/src/bjb-search-toolbar.c
index 64f68e9..c1ed11c 100644
--- a/src/bjb-search-toolbar.c
+++ b/src/bjb-search-toolbar.c
@@ -47,7 +47,7 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
 
 struct _BjbSearchToolbar
 {
-  GtkSearchBar       parent_instance;
+  HdySearchBar       parent_instance;
 
   GtkWidget         *entry;
   gchar             *needle;
@@ -61,14 +61,14 @@ struct _BjbSearchToolbar
   GtkWidget         *window;
 };
 
-G_DEFINE_TYPE (BjbSearchToolbar, bjb_search_toolbar, GTK_TYPE_SEARCH_BAR)
+G_DEFINE_TYPE (BjbSearchToolbar, bjb_search_toolbar, HDY_TYPE_SEARCH_BAR)
 
 static gboolean
 on_key_pressed (GtkWidget *widget,GdkEvent  *event,gpointer user_data)
 {
-  GtkSearchBar *search_bar = GTK_SEARCH_BAR (user_data);
+  HdySearchBar *search_bar = HDY_SEARCH_BAR (user_data);
 
-  return gtk_search_bar_handle_event (search_bar, event);
+  return hdy_search_bar_handle_event (search_bar, event);
 }
 
 
@@ -173,8 +173,7 @@ static void
 bjb_search_toolbar_init (BjbSearchToolbar *self)
 {
   self->entry = gtk_search_entry_new ();
-  gtk_search_bar_connect_entry (GTK_SEARCH_BAR (self), GTK_ENTRY (self->entry));
-  g_object_set (self->entry, "width_request", 500, NULL);
+  hdy_search_bar_connect_entry (HDY_SEARCH_BAR (self), GTK_ENTRY (self->entry));
   gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->entry));
   gtk_widget_show (GTK_WIDGET (self->entry));
 }
diff --git a/src/bjb-search-toolbar.h b/src/bjb-search-toolbar.h
index 9a7e644..6113871 100644
--- a/src/bjb-search-toolbar.h
+++ b/src/bjb-search-toolbar.h
@@ -18,24 +18,20 @@
 
 #pragma once
 
-#include <gtk/gtk.h>
+#define HANDY_USE_UNSTABLE_API
+#include <handy.h>
 
 G_BEGIN_DECLS
 
 #define BJB_TYPE_SEARCH_TOOLBAR (bjb_search_toolbar_get_type ())
 
-G_DECLARE_FINAL_TYPE (BjbSearchToolbar, bjb_search_toolbar, BJB, SEARCH_TOOLBAR, GtkSearchBar)
-
+G_DECLARE_FINAL_TYPE (BjbSearchToolbar, bjb_search_toolbar, BJB, SEARCH_TOOLBAR, HdySearchBar)
 
 BjbSearchToolbar  *bjb_search_toolbar_new                   (GtkWidget *window,
                                                              BjbController *controller);
 
-
 void               bjb_search_toolbar_disconnect            (BjbSearchToolbar *self);
 
-
 void               bjb_search_toolbar_connect               (BjbSearchToolbar *self);
 
-
-
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]