aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorXan Lopez <xlopez@igalia.com>2011-04-16 08:51:52 +0800
committerXan Lopez <xlopez@igalia.com>2011-04-16 08:51:52 +0800
commitd6ace50802104ef38d2272a6be4767de99923060 (patch)
tree306f10686ad2f7a534f51a5978a09304f63b38b2 /embed
parent6a3082a962422d0d15b25914eaa3cbb17443d7ef (diff)
downloadgsoc2013-epiphany-d6ace50802104ef38d2272a6be4767de99923060.tar
gsoc2013-epiphany-d6ace50802104ef38d2272a6be4767de99923060.tar.gz
gsoc2013-epiphany-d6ace50802104ef38d2272a6be4767de99923060.tar.bz2
gsoc2013-epiphany-d6ace50802104ef38d2272a6be4767de99923060.tar.lz
gsoc2013-epiphany-d6ace50802104ef38d2272a6be4767de99923060.tar.xz
gsoc2013-epiphany-d6ace50802104ef38d2272a6be4767de99923060.tar.zst
gsoc2013-epiphany-d6ace50802104ef38d2272a6be4767de99923060.zip
Move overlay statusbar to EphyEmbed
It's where it belongs, and it will make things easier for the following patches in this area.
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed.c168
-rw-r--r--embed/ephy-embed.h27
-rw-r--r--embed/ephy-web-view.c183
-rw-r--r--embed/ephy-web-view.h11
4 files changed, 187 insertions, 202 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 6f008f565..f41dc39ca 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -59,6 +59,12 @@ static gboolean ephy_embed_inspect_close_cb (WebKitWebInspector *inspector,
#define EPHY_EMBED_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_EMBED, EphyEmbedPrivate))
+typedef struct {
+ gchar *text;
+ guint context_id;
+ guint message_id;
+} EphyEmbedStatusbarMsg;
+
struct _EphyEmbedPrivate
{
GtkBox *top_widgets_vbox;
@@ -73,6 +79,14 @@ struct _EphyEmbedPrivate
guint is_setting_zoom : 1;
GSList *destroy_on_transition_list;
GtkWidget *statusbar_label;
+
+ GSList *messages;
+ GSList *keys;
+
+ guint seq_context_id;
+ guint seq_message_id;
+
+ guint tab_message_id;
};
G_DEFINE_TYPE (EphyEmbed, ephy_embed, GTK_TYPE_VBOX)
@@ -275,6 +289,23 @@ ephy_embed_finalize (GObject *object)
ephy_embed_history_cleared_cb,
embed);
+ for (list = embed->priv->messages; list; list = list->next) {
+ EphyEmbedStatusbarMsg *msg;
+
+ msg = list->data;
+ g_free (msg->text);
+ g_slice_free (EphyEmbedStatusbarMsg, msg);
+ }
+
+ g_slist_free (embed->priv->messages);
+ embed->priv->messages = NULL;
+
+ for (list = embed->priv->keys; list; list = list->next)
+ g_free (list->data);
+
+ g_slist_free (embed->priv->keys);
+ embed->priv->keys = NULL;
+
G_OBJECT_CLASS (ephy_embed_parent_class)->finalize (object);
}
@@ -390,9 +421,6 @@ download_requested_cb (WebKitWebView *web_view,
return TRUE;
}
-/* FIXME: it probably makes sense to move this stuff completely into
- * EphyEmbed now, since it's not an integral part of EphyWebView
- * anymore. */
void
_ephy_embed_set_statusbar_label (EphyEmbed *embed, const char *label)
{
@@ -412,6 +440,22 @@ _ephy_embed_set_statusbar_label (EphyEmbed *embed, const char *label)
}
static void
+status_message_notify_cb (EphyWebView *view, GParamSpec *pspec, EphyEmbed *embed)
+{
+ const char *message;
+ EphyEmbedPrivate *priv;
+
+ message = ephy_web_view_get_status_message (view);
+
+ priv = embed->priv;
+
+ ephy_embed_statusbar_pop (embed, priv->tab_message_id);
+
+ if (message)
+ ephy_embed_statusbar_push (embed, priv->tab_message_id, message);
+}
+
+static void
ephy_embed_constructed (GObject *object)
{
EphyEmbed *embed = (EphyEmbed*)object;
@@ -476,6 +520,7 @@ ephy_embed_constructed (GObject *object)
"signal::resource-request-starting", G_CALLBACK (resource_request_starting_cb), embed,
"signal::download-requested", G_CALLBACK (download_requested_cb), embed,
"signal::notify::zoom-level", G_CALLBACK (zoom_changed_cb), embed,
+ "signal::notify::status-message", G_CALLBACK (status_message_notify_cb), embed,
NULL);
/* The inspector */
@@ -530,6 +575,9 @@ ephy_embed_init (EphyEmbed *embed)
embed->priv->scrolled_window = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL));
embed->priv->paned = GTK_PANED (gtk_vpaned_new ());
embed->priv->top_widgets_vbox = GTK_BOX (gtk_vbox_new (FALSE, 0));
+ embed->priv->seq_context_id = 1;
+ embed->priv->seq_message_id = 1;
+ embed->priv->tab_message_id = ephy_embed_statusbar_get_context_id (embed, EPHY_EMBED_STATUSBAR_TAB_MESSAGE_CONTEXT_DESCRIPTION);
gtk_scrolled_window_set_policy (embed->priv->scrolled_window,
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -602,3 +650,117 @@ ephy_embed_remove_top_widget (EphyEmbed *embed, GtkWidget *widget)
gtk_container_remove (GTK_CONTAINER (embed->priv->top_widgets_vbox),
GTK_WIDGET (widget));
}
+
+static void
+ephy_embed_statusbar_update (EphyEmbed *embed, const char *text)
+{
+ g_return_if_fail (EPHY_IS_EMBED (embed));
+
+ _ephy_embed_set_statusbar_label (embed, text);
+}
+
+/* Portions of the following code based on GTK+.
+ * License block as follows:
+ *
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * GtkStatusbar Copyright (C) 1998 Shawn T. Amundson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ *
+ */
+
+guint
+ephy_embed_statusbar_get_context_id (EphyEmbed *embed, const char *context_description)
+{
+ char *string;
+ guint id;
+
+ g_return_val_if_fail (EPHY_IS_EMBED (embed), 0);
+ g_return_val_if_fail (context_description != NULL, 0);
+
+ /* we need to preserve namespaces on object datas */
+ string = g_strconcat ("ephy-embed-status-bar-context:", context_description, NULL);
+
+ id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (embed), string));
+ if (id == 0) {
+ EphyEmbedPrivate *priv = embed->priv;
+
+ id = priv->seq_context_id++;
+ g_object_set_data_full (G_OBJECT (embed), string, GUINT_TO_POINTER (id), NULL);
+ priv->keys = g_slist_prepend (priv->keys, string);
+ } else
+ g_free (string);
+
+ return id;
+}
+
+guint
+ephy_embed_statusbar_push (EphyEmbed *embed, guint context_id, const char *text)
+{
+ EphyEmbedPrivate *priv;
+ EphyEmbedStatusbarMsg *msg;
+
+ g_return_val_if_fail (EPHY_IS_EMBED (embed), 0);
+ g_return_val_if_fail (context_id != 0, 0);
+ g_return_val_if_fail (text != NULL, 0);
+
+ priv = embed->priv;
+
+ msg = g_slice_new (EphyEmbedStatusbarMsg);
+ msg->text = g_strdup (text);
+ msg->context_id = context_id;
+ msg->message_id = priv->seq_message_id++;
+
+ priv->messages = g_slist_prepend (priv->messages, msg);
+
+ ephy_embed_statusbar_update (embed, text);
+
+ return msg->message_id;
+}
+
+void
+ephy_embed_statusbar_pop (EphyEmbed *embed, guint context_id)
+{
+ EphyEmbedPrivate *priv;
+ EphyEmbedStatusbarMsg *msg;
+ GSList *list;
+
+ g_return_if_fail (EPHY_IS_EMBED (embed));
+ g_return_if_fail (context_id != 0);
+
+ priv = embed->priv;
+
+ for (list = priv->messages; list; list = list->next) {
+ EphyEmbedStatusbarMsg *msg = list->data;
+
+ if (msg->context_id == context_id) {
+ priv->messages = g_slist_remove_link (priv->messages, list);
+ g_free (msg->text);
+ g_slice_free (EphyEmbedStatusbarMsg, msg);
+ g_slist_free_1 (list);
+ break;
+ }
+ }
+
+ msg = priv->messages ? priv->messages->data : NULL;
+ ephy_embed_statusbar_update (embed, msg ? msg->text : NULL);
+}
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index c9fc1a4c8..b30b85fba 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -40,6 +40,9 @@ typedef struct _EphyEmbedClass EphyEmbedClass;
typedef struct _EphyEmbed EphyEmbed;
typedef struct _EphyEmbedPrivate EphyEmbedPrivate;
+#define EPHY_EMBED_STATUSBAR_TAB_MESSAGE_CONTEXT_DESCRIPTION "tab_message"
+#define EPHY_EMBED_STATUSBAR_HELP_MESSAGE_CONTEXT_DESCRIPTION "help_message"
+
struct _EphyEmbed {
GtkVBox parent_instance;
@@ -51,12 +54,24 @@ struct _EphyEmbedClass {
GtkVBoxClass 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_set_statusbar_label (EphyEmbed *embed, const char *label);
+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_set_statusbar_label (EphyEmbed *embed,
+ const char *label);
+void ephy_embed_statusbar_pop (EphyEmbed *embed,
+ guint context_id);
+guint ephy_embed_statusbar_push (EphyEmbed *embed,
+ guint context_id,
+ const char *text);
+guint ephy_embed_statusbar_get_context_id (EphyEmbed *embed,
+ const char *context_description);
G_END_DECLS
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 86baa5184..288472955 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -97,15 +97,6 @@ struct _EphyWebViewPrivate {
GSList *hidden_popups;
GSList *shown_popups;
- GSList *messages;
- GSList *keys;
-
- guint seq_context_id;
- guint seq_message_id;
-
- guint tab_message_id;
-
- char *text;
GdkRectangle text_rectangle;
GtkWidget *password_info_bar;
@@ -117,12 +108,6 @@ typedef struct {
char *features;
} PopupInfo;
-typedef struct {
- gchar *text;
- guint context_id;
- guint message_id;
-} EphyWebViewStatusbarMsg;
-
enum {
PROP_0,
PROP_ADDRESS,
@@ -549,29 +534,10 @@ ephy_web_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
}
static void
-status_message_notify_cb (EphyWebView *view, GParamSpec *pspec, gpointer data)
-{
- const char *message;
- EphyWebViewPrivate *priv;
-
- message = ephy_web_view_get_status_message (view);
-
- priv = view->priv;
-
- ephy_web_view_statusbar_pop (view, priv->tab_message_id);
-
- if (message)
- ephy_web_view_statusbar_push (view, priv->tab_message_id, message);
-
-}
-
-static void
ephy_web_view_dispose (GObject *object)
{
ephy_web_view_file_monitor_cancel (EPHY_WEB_VIEW (object));
- g_signal_handlers_disconnect_by_func (object, G_CALLBACK (status_message_notify_cb), NULL);
-
G_OBJECT_CLASS (ephy_web_view_parent_class)->dispose (object);
}
@@ -1059,7 +1025,6 @@ static void
ephy_web_view_finalize (GObject *object)
{
EphyWebViewPrivate *priv = EPHY_WEB_VIEW (object)->priv;
- GSList *list;
if (priv->icon != NULL) {
g_object_unref (priv->icon);
@@ -1071,26 +1036,6 @@ ephy_web_view_finalize (GObject *object)
priv->non_search_regex = NULL;
}
- for (list = priv->messages; list; list = list->next) {
- EphyWebViewStatusbarMsg *msg;
-
- msg = list->data;
- g_free (msg->text);
- g_slice_free (EphyWebViewStatusbarMsg, msg);
- }
-
- g_slist_free (priv->messages);
- priv->messages = NULL;
-
-
- for (list = priv->keys; list; list = list->next)
- g_free (list->data);
-
- g_slist_free (priv->keys);
- priv->keys = NULL;
-
- g_free (priv->text);
-
ephy_web_view_popups_manager_reset (EPHY_WEB_VIEW (object));
g_free (priv->address);
@@ -2221,9 +2166,6 @@ ephy_web_view_init (EphyWebView *web_view)
priv->document_type = EPHY_WEB_VIEW_DOCUMENT_HTML;
priv->security_level = EPHY_WEB_VIEW_STATE_IS_UNKNOWN;
priv->monitor_directory = FALSE;
- priv->seq_context_id = 1;
- priv->seq_message_id = 1;
- priv->tab_message_id = ephy_web_view_statusbar_get_context_id (web_view, EPHY_WEB_VIEW_STATUSBAR_TAB_MESSAGE_CONTEXT_DESCRIPTION);
priv->non_search_regex = g_regex_new ("(^localhost(\\.[^[:space:]]+)?(:\\d+)?(/.*)?$|"
"^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]$|"
@@ -2276,10 +2218,6 @@ ephy_web_view_init (EphyWebView *web_view)
G_CALLBACK (vadjustment_changed_cb),
NULL);
- g_signal_connect (web_view, "notify::status-message",
- G_CALLBACK (status_message_notify_cb),
- NULL);
-
cache = EPHY_FAVICON_CACHE
(ephy_embed_shell_get_favicon_cache (embed_shell));
g_signal_connect_object (G_OBJECT (cache), "changed",
@@ -3681,124 +3619,3 @@ ephy_web_view_load_homepage (EphyWebView *view)
return is_empty;
}
-static void
-ephy_web_view_statusbar_update (EphyWebView *view, const char *text)
-{
- EphyEmbed *embed;
-
- g_return_if_fail (EPHY_IS_WEB_VIEW (view));
-
- embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view);
- /* Inspector window does not have an embed for example */
- if (embed)
- _ephy_embed_set_statusbar_label (embed, text);
-}
-
-/* Portions of the following code based on GTK+.
- * License block as follows:
- *
- * GTK - The GIMP Toolkit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- * GtkStatusbar Copyright (C) 1998 Shawn T. Amundson
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- *
- */
-
-guint
-ephy_web_view_statusbar_get_context_id (EphyWebView *view, const char *context_description)
-{
- char *string;
- guint id;
-
- g_return_val_if_fail (EPHY_IS_WEB_VIEW (view), 0);
- g_return_val_if_fail (context_description != NULL, 0);
-
- /* we need to preserve namespaces on object datas */
- string = g_strconcat ("ephy-web-view-status-bar-context:", context_description, NULL);
-
- id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (view), string));
- if (id == 0) {
- EphyWebViewPrivate *priv = view->priv;
-
- id = priv->seq_context_id++;
- g_object_set_data_full (G_OBJECT (view), string, GUINT_TO_POINTER (id), NULL);
- priv->keys = g_slist_prepend (priv->keys, string);
- } else
- g_free (string);
-
- return id;
-}
-
-guint
-ephy_web_view_statusbar_push (EphyWebView *view, guint context_id, const char *text)
-{
- EphyWebViewPrivate *priv;
- EphyWebViewStatusbarMsg *msg;
-
- g_return_val_if_fail (EPHY_IS_WEB_VIEW (view), 0);
- g_return_val_if_fail (context_id != 0, 0);
- g_return_val_if_fail (text != NULL, 0);
-
- priv = view->priv;
-
- msg = g_slice_new (EphyWebViewStatusbarMsg);
- msg->text = g_strdup (text);
- msg->context_id = context_id;
- msg->message_id = priv->seq_message_id++;
-
- priv->messages = g_slist_prepend (priv->messages, msg);
-
- ephy_web_view_statusbar_update (view, text);
-
- return msg->message_id;
-}
-
-void
-ephy_web_view_statusbar_pop (EphyWebView *view, guint context_id)
-{
- EphyWebViewPrivate *priv;
- EphyWebViewStatusbarMsg *msg;
- GSList *list;
-
- g_return_if_fail (EPHY_IS_WEB_VIEW (view));
- g_return_if_fail (context_id != 0);
-
- priv = view->priv;
-
- for (list = priv->messages; list; list = list->next) {
- EphyWebViewStatusbarMsg *msg = list->data;
-
- if (msg->context_id == context_id) {
- priv->messages = g_slist_remove_link (priv->messages, list);
- g_free (msg->text);
- g_slice_free (EphyWebViewStatusbarMsg, msg);
- g_slist_free_1 (list);
- break;
- }
- }
-
- msg = priv->messages ? priv->messages->data : NULL;
- ephy_web_view_statusbar_update (view, msg ? msg->text : NULL);
-}
-
-
-
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index 7b412bd74..508ed2c99 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -45,9 +45,6 @@ typedef struct _EphyWebViewClass EphyWebViewClass;
typedef struct _EphyWebView EphyWebView;
typedef struct _EphyWebViewPrivate EphyWebViewPrivate;
-#define EPHY_WEB_VIEW_STATUSBAR_TAB_MESSAGE_CONTEXT_DESCRIPTION "tab_message"
-#define EPHY_WEB_VIEW_STATUSBAR_HELP_MESSAGE_CONTEXT_DESCRIPTION "help_message"
-
typedef enum
{
EPHY_WEB_VIEW_NAV_UP = 1 << 0,
@@ -196,13 +193,7 @@ void ephy_web_view_popups_manager_reset (EphyWebView
void ephy_web_view_save (EphyWebView *view,
const char *uri);
gboolean ephy_web_view_load_homepage (EphyWebView *view);
-void ephy_web_view_statusbar_pop (EphyWebView *view,
- guint context_id);
-guint ephy_web_view_statusbar_push (EphyWebView *view,
- guint context_id,
- const char *text);
-guint ephy_web_view_statusbar_get_context_id (EphyWebView *view,
- const char *context_description);
+
G_END_DECLS
#endif