Commit 61058617 authored by Yosef Or Boczko's avatar Yosef Or Boczko

Create a find toolbar to each tab

https://bugzilla.gnome.org/show_bug.cgi?id=710542
parent a35c0f13
......@@ -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 \
......
......@@ -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;
......@@ -420,6 +422,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)
{
......@@ -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;
......@@ -783,6 +805,23 @@ ephy_embed_get_web_view (EphyEmbed *embed)
return EPHY_WEB_VIEW (embed->priv->web_view);
}
/**
* 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
......
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
......@@ -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 \
......
......@@ -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);
......
......@@ -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 *
......@@ -3082,23 +3081,6 @@ ephy_window_finalize (GObject *object)
LOG ("EphyWindow finalised %p", 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,
......@@ -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));
}
/**
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment