[devhelp/wip/searchbar] Use a revealer instead of egg find bar



commit 3e81237f1c9dfdb398fffef2a5b3f807a30b0b12
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Mon Mar 25 09:50:52 2013 +0100

    Use a revealer instead of egg find bar

 configure.ac     |    1 +
 src/Makefile.am  |    4 +-
 src/dh-window.c  |  105 ++++++---
 src/eggfindbar.c |  755 ------------------------------------------------------
 src/eggfindbar.h |   81 ------
 5 files changed, 77 insertions(+), 869 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ba81ef4..8cb4136 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,6 +108,7 @@ AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
 AM_PATH_PYTHON([2.3],[],[no])
 
 LIBGD_INIT([
+  revealer
   header-bar
   static
 ])
diff --git a/src/Makefile.am b/src/Makefile.am
index cd66e7c..44ed6d0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -93,9 +93,7 @@ libdevhelp_3_la_SOURCES =                             \
        dh-settings.c                                   \
        dh-settings.h                                   \
        dh-resources.c                                  \
-       dh-resources.h                                  \
-       eggfindbar.c                                    \
-       eggfindbar.h
+       dh-resources.h
 
 libdevhelp_3_la_CPPFLAGS =                             \
        $(AM_CPPFLAGS)                                  \
diff --git a/src/dh-window.c b/src/dh-window.c
index f17783c..70fa938 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -41,7 +41,6 @@
 #include "dh-util.h"
 #include "dh-enum-types.h"
 #include "dh-settings.h"
-#include "eggfindbar.h"
 
 #define TAB_WIDTH_N_CHARS 15
 
@@ -53,7 +52,10 @@ struct _DhWindowPriv {
         GtkWidget      *header_bar;
 
         GtkWidget      *vbox;
-        GtkWidget      *findbar;
+        GtkWidget      *findbar_revealer;
+        GtkWidget      *findbar_entry;
+        GtkWidget      *findbar_back;
+        GtkWidget      *findbar_forward;
 
         GtkBuilder     *builder;
 
@@ -256,8 +258,8 @@ find_cb (GSimpleAction *action,
 #endif
         priv = window->priv;
 
-        gtk_widget_show (priv->findbar);
-        gtk_widget_grab_focus (priv->findbar);
+        gd_revealer_set_reveal_child (GD_REVEALER (priv->findbar_revealer), TRUE);
+        gtk_widget_grab_focus (priv->findbar_entry);
 
 #ifdef HAVE_WEBKIT2
         /* The behaviour for WebKit1 is to re-enable highlighting without
@@ -658,6 +660,23 @@ window_web_view_switch_page_after_cb (GtkNotebook     *notebook,
         window_update_zoom_actions_state (window);
 }
 
+
+static GtkWidget *
+create_button_from_symbolic (const gchar *icon_name)
+{
+        GtkWidget *button;
+
+        button = gtk_button_new ();
+        gtk_widget_set_can_focus (button, FALSE);
+        gtk_style_context_add_class (gtk_widget_get_style_context (button), "raised");
+        gtk_style_context_add_class (gtk_widget_get_style_context (button), "image-button");
+        gtk_button_set_image (GTK_BUTTON (button),
+                              gtk_image_new_from_icon_name (icon_name,
+                                                            GTK_ICON_SIZE_MENU));
+
+        return button;
+}
+
 static void
 window_populate (DhWindow *window)
 {
@@ -668,6 +687,10 @@ window_populate (DhWindow *window)
         GtkWidget     *box;
         GtkWidget     *menu_button;
         GObject       *menu;
+        GtkWidget     *up_button;
+        GtkWidget     *down_button;
+        GtkWidget     *findbar_toolbar;
+        GtkToolItem   *toolitem;
 
         priv = window->priv;
         book_manager = dh_app_peek_book_manager (DH_APP (gtk_window_get_application (GTK_WINDOW (window))));
@@ -724,28 +747,34 @@ window_populate (DhWindow *window)
         priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
         gtk_paned_add2 (GTK_PANED (priv->hpaned), priv->vbox);
 
-        /* HTML tabs notebook. */
-        priv->notebook = gtk_notebook_new ();
-        gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), 0);
-        gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
-        gtk_notebook_set_scrollable (GTK_NOTEBOOK (priv->notebook), TRUE);
-        gtk_box_pack_start (GTK_BOX (priv->vbox), priv->notebook, TRUE, TRUE, 0);
+        /* Create findbar */
+        priv->findbar_revealer = gd_revealer_new ();
+        gtk_box_pack_start (GTK_BOX (priv->vbox), priv->findbar_revealer, FALSE, FALSE, 0);
 
-        g_signal_connect (priv->notebook,
-                          "switch-page",
-                          G_CALLBACK (window_web_view_switch_page_cb),
-                          window);
-        g_signal_connect_after (priv->notebook,
-                                "switch-page",
-                                G_CALLBACK (window_web_view_switch_page_after_cb),
-                                window);
+        findbar_toolbar = gtk_toolbar_new ();
+        gtk_style_context_add_class (gtk_widget_get_style_context (findbar_toolbar), "primary-toolbar");
+        gtk_container_add (GTK_CONTAINER (priv->findbar_revealer), findbar_toolbar);
 
-        /* Create findbar */
-        priv->findbar = egg_find_bar_new ();
-        gtk_widget_set_no_show_all (priv->findbar, TRUE);
-        gtk_box_pack_start (GTK_BOX (priv->vbox), priv->findbar, FALSE, FALSE, 0);
+        toolitem = gtk_tool_item_new ();
+        gtk_tool_item_set_expand (toolitem, TRUE);
+        gtk_container_add (GTK_CONTAINER (findbar_toolbar), toolitem);
 
-        g_signal_connect (priv->findbar,
+        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), "linked");
+        gtk_container_add (GTK_CONTAINER (toolitem), box);
+
+        priv->findbar_entry = gtk_search_entry_new ();
+        gtk_widget_set_size_request (priv->findbar_entry, 500, -1);
+        gtk_container_add (GTK_CONTAINER (box), priv->findbar_entry);
+
+        up_button = create_button_from_symbolic ("go-up-symbolic");
+        gtk_container_add (GTK_CONTAINER (box), up_button);
+
+        down_button = create_button_from_symbolic ("go-down-symbolic");
+        gtk_container_add (GTK_CONTAINER (box), down_button);
+
+        /*g_signal_connect (priv->findbar,
                           "notify::search-string",
                           G_CALLBACK(window_find_search_changed_cb),
                           window);
@@ -764,7 +793,23 @@ window_populate (DhWindow *window)
         g_signal_connect (priv->findbar,
                           "close",
                           G_CALLBACK (window_findbar_close_cb),
+                          window);*/
+
+        /* HTML tabs notebook. */
+        priv->notebook = gtk_notebook_new ();
+        gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), 0);
+        gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
+        gtk_notebook_set_scrollable (GTK_NOTEBOOK (priv->notebook), TRUE);
+        gtk_box_pack_start (GTK_BOX (priv->vbox), priv->notebook, TRUE, TRUE, 0);
+
+        g_signal_connect (priv->notebook,
+                          "switch-page",
+                          G_CALLBACK (window_web_view_switch_page_cb),
                           window);
+        g_signal_connect_after (priv->notebook,
+                                "switch-page",
+                                G_CALLBACK (window_web_view_switch_page_after_cb),
+                                window);
 
         gtk_widget_show_all (priv->hpaned);
 
@@ -1049,17 +1094,17 @@ do_search (DhWindow *window)
         const gchar          *search_text;
 
         find_controller = webkit_web_view_get_find_controller (window_get_active_web_view (window));
-        if (!egg_find_bar_get_case_sensitive (EGG_FIND_BAR (priv->findbar)))
+/*        if (!egg_find_bar_get_case_sensitive (EGG_FIND_BAR (priv->findbar)))
                 find_options |= WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE;
 
         search_text = egg_find_bar_get_search_string (EGG_FIND_BAR (priv->findbar));
-        webkit_find_controller_search (find_controller, search_text, find_options, G_MAXUINT);
+        webkit_find_controller_search (find_controller, search_text, find_options, G_MAXUINT);*/
 #else
         WebKitWebView *web_view;
 
         web_view = window_get_active_web_view (window);
 
-        webkit_web_view_unmark_text_matches (web_view);
+/*        webkit_web_view_unmark_text_matches (web_view);
         webkit_web_view_mark_text_matches (
                 web_view,
                 egg_find_bar_get_search_string (EGG_FIND_BAR (priv->findbar)),
@@ -1069,7 +1114,7 @@ do_search (DhWindow *window)
         webkit_web_view_search_text (
                 web_view, egg_find_bar_get_search_string (EGG_FIND_BAR (priv->findbar)),
                 egg_find_bar_get_case_sensitive (EGG_FIND_BAR (priv->findbar)),
-                TRUE, TRUE);
+                TRUE, TRUE);*/
 #endif /* HAVE_WEBKIT2 */
 
         priv->find_source_id = 0;
@@ -1129,7 +1174,7 @@ findbar_find_next (DhWindow *window)
 #endif
         view = window_get_active_web_view (window);
 
-        gtk_widget_show (priv->findbar);
+        gd_revealer_set_reveal_child (GD_REVEALER (priv->findbar_revealer), TRUE);
 #ifdef HAVE_WEBKIT2
         find_controller = webkit_web_view_get_find_controller (view);
         webkit_find_controller_search_next(find_controller);
@@ -1160,7 +1205,7 @@ findbar_find_previous (DhWindow *window)
 #endif
         view = window_get_active_web_view (window);
 
-        gtk_widget_show (priv->findbar);
+        gd_revealer_set_reveal_child (GD_REVEALER (priv->findbar_revealer), TRUE);
 
 #ifdef HAVE_WEBKIT2
         find_controller = webkit_web_view_get_find_controller (view);
@@ -1190,7 +1235,7 @@ window_findbar_close_cb (GtkWidget *widget,
 #endif
         view = window_get_active_web_view (window);
 
-        gtk_widget_hide (priv->findbar);
+        gd_revealer_set_reveal_child (GD_REVEALER (priv->findbar_revealer), FALSE);
 #ifdef HAVE_WEBKIT2
         find_controller = webkit_web_view_get_find_controller (view);
         webkit_find_controller_search_finish (find_controller);


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