[epiphany] Create a find toolbar to each tab



commit 610586172fd8492f826adcba0f7685bf14db747e
Author: Yosef Or Boczko <yoseforb gmail com>
Date:   Mon Dec 9 13:32:53 2013 +0200

    Create a find toolbar to each tab
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710542

 embed/Makefile.am                  |    2 +
 embed/ephy-embed.c                 |   39 ++++++++++++++++++++++++++++++++++++
 embed/ephy-embed.h                 |   38 ++++++++++++++++++----------------
 {src => embed}/ephy-find-toolbar.c |   38 ++++++++++++++++------------------
 {src => embed}/ephy-find-toolbar.h |    9 +++----
 src/Makefile.am                    |    2 -
 src/ephy-private.h                 |    2 +-
 src/ephy-window.c                  |   35 ++++---------------------------
 src/window-commands.c              |    6 ++--
 9 files changed, 92 insertions(+), 79 deletions(-)
---
diff --git a/embed/Makefile.am b/embed/Makefile.am
index ba0fb44..75ab652 100644
--- a/embed/Makefile.am
+++ b/embed/Makefile.am
@@ -20,6 +20,7 @@ INST_H_FILES = \
        ephy-embed-prefs.h              \
        ephy-embed-shell.h              \
        ephy-embed-utils.h              \
+       ephy-find-toolbar.h             \
        ephy-overview.h                 \
        ephy-web-view.h
 
@@ -40,6 +41,7 @@ libephyembed_la_SOURCES = \
        ephy-encoding.c                 \
        ephy-encodings.c                \
        ephy-file-monitor.c             \
+       ephy-find-toolbar.c             \
        ephy-overview.c                 \
        ephy-embed-prefs.c              \
        ephy-web-view.c                 \
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 01e10b5..849a2a0 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -30,6 +30,7 @@
 #include "ephy-download.h"
 #include "ephy-embed-prefs.h"
 #include "ephy-embed-shell.h"
+#include "ephy-find-toolbar.h"
 #include "ephy-prefs.h"
 #include "ephy-settings.h"
 #include "ephy-web-view.h"
@@ -54,6 +55,7 @@ typedef struct {
 
 struct _EphyEmbedPrivate
 {
+  EphyFindToolbar *find_toolbar;
   GtkBox *top_widgets_vbox;
   GtkPaned *paned;
   WebKitWebView *web_view;
@@ -421,6 +423,17 @@ ephy_embed_get_property (GObject *object,
 }
 
 static void
+ephy_embed_find_toolbar_close_cb (EphyFindToolbar *toolbar,
+                                  EphyEmbed *embed)
+{
+  EphyEmbedPrivate *priv = embed->priv;
+
+  ephy_find_toolbar_close (priv->find_toolbar);
+
+  gtk_widget_grab_focus (GTK_WIDGET (embed));
+}
+
+static void
 ephy_embed_class_init (EphyEmbedClass *klass)
 {
   GObjectClass *object_class = (GObjectClass *)klass;
@@ -710,6 +723,15 @@ ephy_embed_constructed (GObject *object)
   gtk_widget_set_valign (priv->progress, GTK_ALIGN_START);
   gtk_overlay_add_overlay (GTK_OVERLAY (overlay), priv->progress);
 
+  priv->find_toolbar = ephy_find_toolbar_new (priv->web_view);
+  g_signal_connect (priv->find_toolbar, "close",
+                    G_CALLBACK (ephy_embed_find_toolbar_close_cb),
+                    embed);
+
+  gtk_box_pack_start (GTK_BOX (embed),
+                      GTK_WIDGET (priv->find_toolbar),
+                      FALSE, FALSE, 0);
+
   paned = GTK_WIDGET (priv->paned);
 
   priv->web_view = web_view;
@@ -784,6 +806,23 @@ ephy_embed_get_web_view (EphyEmbed *embed)
 }
 
 /**
+ * ephy_embed_get_find_toolbar:
+ * @embed: and #EphyEmbed
+ * 
+ * Returns the #EphyFindToolbar wrapped by @embed.
+ * 
+ * Returns: (transfer none): an #EphyFindToolbar
+ **/
+EphyFindToolbar*
+ephy_embed_get_find_toolbar (EphyEmbed *embed)
+{
+  g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
+
+  return EPHY_FIND_TOOLBAR (embed->priv->find_toolbar);
+}
+
+
+/**
  * ephy_embed_add_top_widget:
  * @embed: an #EphyEmbed
  * @widget: a #GtkWidget
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index f59a4a5..d599ab3 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -22,6 +22,7 @@
 #ifndef EPHY_EMBED_H
 #define EPHY_EMBED_H
 
+#include "ephy-find-toolbar.h"
 #include "ephy-overview.h"
 #include "ephy-web-view.h"
 
@@ -51,24 +52,25 @@ struct _EphyEmbedClass {
   GtkBoxClass parent_class;
 };
 
-GType        ephy_embed_get_type                 (void);
-EphyWebView* ephy_embed_get_web_view             (EphyEmbed  *embed);
-void         ephy_embed_add_top_widget           (EphyEmbed  *embed,
-                                                  GtkWidget  *widget,
-                                                  gboolean    destroy_on_transition);
-void         ephy_embed_remove_top_widget        (EphyEmbed  *embed,
-                                                  GtkWidget  *widget);
-void         ephy_embed_auto_download_url        (EphyEmbed  *embed,
-                                                  const char *url);
-void         ephy_embed_entering_fullscreen      (EphyEmbed *embed);
-void         ephy_embed_leaving_fullscreen       (EphyEmbed *embed);
-void         ephy_embed_set_delayed_load_request (EphyEmbed *embed,
-                                                  WebKitURIRequest     *request);
-gboolean     ephy_embed_has_load_pending         (EphyEmbed *embed);
-void         ephy_embed_set_overview_mode        (EphyEmbed *embed,
-                                                  gboolean   overview_mode);
-gboolean     ephy_embed_get_overview_mode        (EphyEmbed *embed);
-EphyOverview*ephy_embed_get_overview             (EphyEmbed *embed);
+GType            ephy_embed_get_type                 (void);
+EphyWebView*     ephy_embed_get_web_view             (EphyEmbed  *embed);
+EphyFindToolbar* ephy_embed_get_find_toolbar         (EphyEmbed  *embed);
+void             ephy_embed_add_top_widget           (EphyEmbed  *embed,
+                                                      GtkWidget  *widget,
+                                                      gboolean    destroy_on_transition);
+void             ephy_embed_remove_top_widget        (EphyEmbed  *embed,
+                                                      GtkWidget  *widget);
+void             ephy_embed_auto_download_url        (EphyEmbed  *embed,
+                                                      const char *url);
+void             ephy_embed_entering_fullscreen      (EphyEmbed *embed);
+void             ephy_embed_leaving_fullscreen       (EphyEmbed *embed);
+void             ephy_embed_set_delayed_load_request (EphyEmbed *embed,
+                                                      WebKitURIRequest     *request);
+gboolean         ephy_embed_has_load_pending         (EphyEmbed *embed);
+void             ephy_embed_set_overview_mode        (EphyEmbed *embed,
+                                                      gboolean   overview_mode);
+gboolean         ephy_embed_get_overview_mode        (EphyEmbed *embed);
+EphyOverview*    ephy_embed_get_overview             (EphyEmbed *embed);
 
 G_END_DECLS
 
diff --git a/src/ephy-find-toolbar.c b/embed/ephy-find-toolbar.c
similarity index 96%
rename from src/ephy-find-toolbar.c
rename to embed/ephy-find-toolbar.c
index d6aac37..4f80fe5 100644
--- a/src/ephy-find-toolbar.c
+++ b/embed/ephy-find-toolbar.c
@@ -23,7 +23,7 @@
 #include "ephy-find-toolbar.h"
 
 #include "ephy-debug.h"
-#include "ephy-embed-utils.h"
+#include "ephy-web-view.h"
 
 #include <math.h>
 
@@ -37,7 +37,6 @@
 
 struct _EphyFindToolbarPrivate
 {
-       EphyWindow *window;
        WebKitWebView *web_view;
         WebKitFindController *controller;
        GtkWidget *entry;
@@ -56,7 +55,7 @@ struct _EphyFindToolbarPrivate
 enum
 {
        PROP_0,
-       PROP_WINDOW
+       PROP_WEB_VIEW
 };
 
 enum
@@ -102,7 +101,7 @@ set_status (EphyFindToolbar *toolbar,
                case EPHY_FIND_RESULT_NOTFOUND:
                        icon_name = "face-uncertain-symbolic";
                        tooltip = _("Text not found");
-                       gtk_widget_error_bell (GTK_WIDGET (priv->window));
+                       gtk_widget_error_bell (GTK_WIDGET (toolbar));
 
                        break;
                case EPHY_FIND_RESULT_FOUNDWRAPPED:
@@ -144,7 +143,7 @@ clear_status (EphyFindToolbar *toolbar)
  * gtk_tree_view_real_start_interactive_seach()
  */
 static gboolean
-tab_search_key_press_cb (EphyEmbed *embed,
+tab_search_key_press_cb (WebKitWebView *web_view,
                         GdkEventKey *event,
                         EphyFindToolbar *toolbar)
 {
@@ -346,12 +345,12 @@ entry_activate_cb (GtkWidget *entry,
 }
 
 static void
-ephy_find_toolbar_set_window (EphyFindToolbar *toolbar,
-                             EphyWindow *window)
+_ephy_find_toolbar_set_web_view (EphyFindToolbar *toolbar,
+                                WebKitWebView *web_view)
 {
        EphyFindToolbarPrivate *priv = toolbar->priv;
 
-       priv->window = window;
+       priv->web_view = web_view;
 }
 
 static void
@@ -534,8 +533,8 @@ ephy_find_toolbar_set_property (GObject *object,
 
        switch (prop_id)
        {
-               case PROP_WINDOW:
-                       ephy_find_toolbar_set_window (toolbar, (EphyWindow *) g_value_get_object (value));
+               case PROP_WEB_VIEW:
+                       _ephy_find_toolbar_set_web_view (toolbar, (WebKitWebView *) g_value_get_object 
(value));
                        break;
        }
 }
@@ -596,11 +595,11 @@ ephy_find_toolbar_class_init (EphyFindToolbarClass *klass)
 
        g_object_class_install_property
                (object_class,
-                PROP_WINDOW,
-                g_param_spec_object ("window",
-                                     "Window",
-                                     "Parent window",
-                                     EPHY_TYPE_WINDOW,
+                PROP_WEB_VIEW,
+                g_param_spec_object ("web-view",
+                                     "WebView",
+                                     "Parent web view",
+                                     WEBKIT_TYPE_WEB_VIEW,
                                      (GParamFlags) (G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | 
G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY)));
 
        g_type_class_add_private (klass, sizeof (EphyFindToolbarPrivate));
@@ -609,10 +608,10 @@ ephy_find_toolbar_class_init (EphyFindToolbarClass *klass)
 /* public functions */
 
 EphyFindToolbar *
-ephy_find_toolbar_new (EphyWindow *window)
+ephy_find_toolbar_new (WebKitWebView *web_view)
 {
        return g_object_new (EPHY_TYPE_FIND_TOOLBAR,
-                            "window", window,
+                            "web-view", web_view,
                             NULL);
 }
 
@@ -625,11 +624,10 @@ ephy_find_toolbar_get_text (EphyFindToolbar *toolbar)
 }
 
 void
-ephy_find_toolbar_set_embed (EphyFindToolbar *toolbar,
-                            EphyEmbed *embed)
+ephy_find_toolbar_set_web_view (EphyFindToolbar *toolbar,
+                               WebKitWebView *web_view)
 {
        EphyFindToolbarPrivate *priv = toolbar->priv;
-       WebKitWebView *web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED(embed);
 
        if (priv->web_view == web_view) return;
 
diff --git a/src/ephy-find-toolbar.h b/embed/ephy-find-toolbar.h
similarity index 93%
rename from src/ephy-find-toolbar.h
rename to embed/ephy-find-toolbar.h
index bb3494a..82a441f 100644
--- a/src/ephy-find-toolbar.h
+++ b/embed/ephy-find-toolbar.h
@@ -27,8 +27,7 @@
 
 #include <gtk/gtk.h>
 
-#include "ephy-embed.h"
-#include "ephy-window.h"
+#include "ephy-web-view.h"
 
 G_BEGIN_DECLS
 
@@ -63,12 +62,12 @@ struct _EphyFindToolbarClass
 
 GType           ephy_find_toolbar_get_type      (void) G_GNUC_CONST;
 
-EphyFindToolbar *ephy_find_toolbar_new          (EphyWindow *window);
+EphyFindToolbar *ephy_find_toolbar_new          (WebKitWebView *web_view);
 
 const char     *ephy_find_toolbar_get_text      (EphyFindToolbar *toolbar);
 
-void            ephy_find_toolbar_set_embed     (EphyFindToolbar *toolbar,
-                                                 EphyEmbed *embed);
+void            ephy_find_toolbar_set_web_view  (EphyFindToolbar *toolbar,
+                                                 WebKitWebView *web_view);
 
 void            ephy_find_toolbar_find_next     (EphyFindToolbar *toolbar);
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 3afd7eb..cba743a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,7 +17,6 @@ NOINST_H_FILES = \
        ephy-combined-stop-reload-action.h      \
        ephy-encoding-dialog.h                  \
        ephy-encoding-menu.h                    \
-       ephy-find-toolbar.h                     \
        ephy-history-window.h                   \
        ephy-home-action.h                      \
        ephy-link-action.h                      \
@@ -51,7 +50,6 @@ libephymain_la_SOURCES = \
        ephy-combined-stop-reload-action.c      \
        ephy-encoding-dialog.c                  \
        ephy-encoding-menu.c                    \
-       ephy-find-toolbar.c                     \
        ephy-home-action.c                      \
        ephy-history-window.c                   \
        ephy-link.c                             \
diff --git a/src/ephy-private.h b/src/ephy-private.h
index 5e7b77a..9d8770c 100644
--- a/src/ephy-private.h
+++ b/src/ephy-private.h
@@ -43,7 +43,7 @@ EphyLocationController  *ephy_window_get_location_controller  (EphyWindow
 
 EphyEmbedEvent          *ephy_window_get_context_event        (EphyWindow               *window);
 
-GtkWidget               *ephy_window_get_find_toolbar         (EphyWindow               *window);
+GtkWidget               *ephy_window_get_current_find_toolbar (EphyWindow               *window);
 
 void                     ephy_window_set_location             (EphyWindow               *window,
                                                                const char               *address);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 5be0923..754eebe 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -345,7 +345,6 @@ struct _EphyWindowPrivate
        EphyEncodingMenu *enc_menu;
        GtkNotebook *notebook;
        EphyEmbed *active_embed;
-       EphyFindToolbar *find_toolbar;
        EphyWebViewChrome chrome;
        EphyWebViewChrome pre_fullscreen_chrome;
        EphyEmbedEvent *context_event;
@@ -1329,7 +1328,6 @@ sync_tab_address (EphyWebView *view,
        location = calculate_location (typed_address, address);
        ephy_window_set_location (window, location);
        g_free (location);
-       ephy_find_toolbar_request_close (priv->find_toolbar);
 }
 
 static void
@@ -1402,7 +1400,7 @@ sync_tab_document_type (EphyWebView *view,
 
        if (!can_find)
        {
-               ephy_find_toolbar_request_close (priv->find_toolbar);
+               ephy_find_toolbar_request_close (ephy_embed_get_find_toolbar (priv->active_embed));
        }
 }
 
@@ -2781,7 +2779,8 @@ notebook_switch_page_cb (GtkNotebook *notebook,
        /* update new tab */
        ephy_window_set_active_tab (window, embed);
 
-       ephy_find_toolbar_set_embed (priv->find_toolbar, embed);
+       ephy_find_toolbar_set_web_view (ephy_embed_get_find_toolbar (embed),
+                                       EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
 }
 
 static GtkNotebook *
@@ -3083,23 +3082,6 @@ ephy_window_finalize (GObject *object)
 }
 
 static void
-find_toolbar_close_cb (EphyFindToolbar *toolbar,
-                      EphyWindow *window)
-{
-       EphyWindowPrivate *priv = window->priv;
-       EphyEmbed *embed;
-
-       if (priv->closing) return;
-
-       ephy_find_toolbar_close (priv->find_toolbar);
-
-       embed = priv->active_embed;
-       if (embed == NULL) return;
-
-       gtk_widget_grab_focus (GTK_WIDGET (embed));
-}
-
-static void
 allow_popups_notifier (GSettings *settings,
                       char *key,
                       EphyWindow *window)
@@ -3360,13 +3342,6 @@ ephy_window_constructor (GType type,
        g_signal_connect (priv->location_controller, "lock-clicked",
                          G_CALLBACK (lock_clicked_cb), window);
 
-       priv->find_toolbar = ephy_find_toolbar_new (window);
-       g_signal_connect (priv->find_toolbar, "close",
-                         G_CALLBACK (find_toolbar_close_cb), window);
-
-       gtk_box_pack_start (GTK_BOX (priv->main_vbox),
-                           GTK_WIDGET (priv->find_toolbar), FALSE, FALSE, 0);
-
        g_signal_connect_swapped (priv->notebook, "open-link",
                                  G_CALLBACK (ephy_link_open), window);
        gtk_box_pack_start (GTK_BOX (priv->main_vbox),
@@ -3681,11 +3656,11 @@ ephy_window_get_notebook (EphyWindow *window)
  * Return value: (transfer none): the @window's #EphyFindToolbar
  **/
 GtkWidget *
-ephy_window_get_find_toolbar (EphyWindow *window)
+ephy_window_get_current_find_toolbar (EphyWindow *window)
 {
        g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
 
-       return GTK_WIDGET (window->priv->find_toolbar);
+       return GTK_WIDGET (ephy_embed_get_find_toolbar (window->priv->active_embed));
 }
 
 /**
diff --git a/src/window-commands.c b/src/window-commands.c
index 45dd141..ed6ba96 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1156,7 +1156,7 @@ window_cmd_edit_find (GtkAction *action,
 {
        EphyFindToolbar *toolbar;
        
-       toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_find_toolbar (window));
+       toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_current_find_toolbar (window));
        ephy_find_toolbar_open (toolbar, FALSE, FALSE);
 }
 
@@ -1166,7 +1166,7 @@ window_cmd_edit_find_next (GtkAction *action,
 {
        EphyFindToolbar *toolbar;
 
-       toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_find_toolbar (window));
+       toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_current_find_toolbar (window));
        ephy_find_toolbar_find_next (toolbar);
 }
 
@@ -1176,7 +1176,7 @@ window_cmd_edit_find_prev (GtkAction *action,
 {
        EphyFindToolbar *toolbar;
 
-       toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_find_toolbar (window));
+       toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_current_find_toolbar (window));
        ephy_find_toolbar_find_previous (toolbar);
 }
 


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