[epiphany] find-toolbar: Make EphyFindToolbar descend from HdySearchBar
- From: Jan-Michael Brummer <jbrummer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] find-toolbar: Make EphyFindToolbar descend from HdySearchBar
- Date: Wed, 23 Jan 2019 19:46:23 +0000 (UTC)
commit cde95449973461c695788ba7e15cd0c85b9c7f32
Author: Adrien Plazas <kekun plazas laposte net>
Date: Mon Nov 26 16:11:20 2018 +0100
find-toolbar: Make EphyFindToolbar descend from HdySearchBar
Make EphyFindToolbar descend from HdySearchBar rather than GtkSearchBar
as the libhandy variant allows the entry to span all the widget's width.
This is needed to make the entry automatically adapt to the available
width by putting it into a HdyColumn.
embed/ephy-find-toolbar.c | 17 +++++++++--------
embed/ephy-find-toolbar.h | 4 +++-
2 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/embed/ephy-find-toolbar.c b/embed/ephy-find-toolbar.c
index 80a01400f..01dad16ae 100644
--- a/embed/ephy-find-toolbar.c
+++ b/embed/ephy-find-toolbar.c
@@ -34,7 +34,7 @@
#include <webkit2/webkit2.h>
struct _EphyFindToolbar {
- GtkSearchBar parent_instance;
+ HdySearchBar parent_instance;
WebKitWebView *web_view;
WebKitFindController *controller;
@@ -51,7 +51,7 @@ struct _EphyFindToolbar {
guint typing_ahead : 1;
};
-G_DEFINE_TYPE (EphyFindToolbar, ephy_find_toolbar, GTK_TYPE_SEARCH_BAR)
+G_DEFINE_TYPE (EphyFindToolbar, ephy_find_toolbar, HDY_TYPE_SEARCH_BAR)
enum {
PROP_0,
@@ -338,7 +338,7 @@ ephy_find_toolbar_load_changed_cb (WebKitWebView *web_view,
EphyFindToolbar *toolbar)
{
if (load_event == WEBKIT_LOAD_STARTED &&
- gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (toolbar))) {
+ hdy_search_bar_get_search_mode (HDY_SEARCH_BAR (toolbar))) {
ephy_find_toolbar_close (toolbar);
}
}
@@ -352,6 +352,7 @@ ephy_find_toolbar_init (EphyFindToolbar *toolbar)
size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_widget_set_halign (box, GTK_ALIGN_CENTER);
gtk_style_context_add_class (gtk_widget_get_style_context (box),
GTK_STYLE_CLASS_RAISED);
gtk_style_context_add_class (gtk_widget_get_style_context (box),
@@ -397,7 +398,7 @@ ephy_find_toolbar_init (EphyFindToolbar *toolbar)
G_CALLBACK (ephy_find_toolbar_find_next), toolbar);
g_signal_connect_swapped (toolbar->prev, "clicked",
G_CALLBACK (ephy_find_toolbar_find_previous), toolbar);
- gtk_search_bar_connect_entry (GTK_SEARCH_BAR (toolbar),
+ hdy_search_bar_connect_entry (HDY_SEARCH_BAR (toolbar),
GTK_ENTRY (toolbar->entry));
search_entry_changed_cb (GTK_ENTRY (toolbar->entry), toolbar);
@@ -565,15 +566,15 @@ ephy_find_toolbar_open (EphyFindToolbar *toolbar,
gtk_editable_select_region (GTK_EDITABLE (toolbar->entry), 0, -1);
- gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (toolbar), TRUE);
- gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (toolbar), TRUE);
+ hdy_search_bar_set_search_mode (HDY_SEARCH_BAR (toolbar), TRUE);
+ hdy_search_bar_set_show_close_button (HDY_SEARCH_BAR (toolbar), TRUE);
gtk_widget_grab_focus (toolbar->entry);
}
void
ephy_find_toolbar_close (EphyFindToolbar *toolbar)
{
- gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (toolbar), FALSE);
+ hdy_search_bar_set_search_mode (HDY_SEARCH_BAR (toolbar), FALSE);
if (toolbar->web_view == NULL) return;
@@ -583,7 +584,7 @@ ephy_find_toolbar_close (EphyFindToolbar *toolbar)
void
ephy_find_toolbar_request_close (EphyFindToolbar *toolbar)
{
- if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (toolbar))) {
+ if (hdy_search_bar_get_search_mode (HDY_SEARCH_BAR (toolbar))) {
g_signal_emit (toolbar, signals[CLOSE], 0);
}
}
diff --git a/embed/ephy-find-toolbar.h b/embed/ephy-find-toolbar.h
index bd588dc12..c70e38cd4 100644
--- a/embed/ephy-find-toolbar.h
+++ b/embed/ephy-find-toolbar.h
@@ -22,6 +22,8 @@
#pragma once
#include <gtk/gtk.h>
+#define HANDY_USE_UNSTABLE_API
+#include <handy.h>
#include "ephy-web-view.h"
@@ -29,7 +31,7 @@ G_BEGIN_DECLS
#define EPHY_TYPE_FIND_TOOLBAR (ephy_find_toolbar_get_type ())
-G_DECLARE_FINAL_TYPE (EphyFindToolbar, ephy_find_toolbar, EPHY, FIND_TOOLBAR, GtkSearchBar)
+G_DECLARE_FINAL_TYPE (EphyFindToolbar, ephy_find_toolbar, EPHY, FIND_TOOLBAR, HdySearchBar)
EphyFindToolbar *ephy_find_toolbar_new (WebKitWebView *web_view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]