aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
Diffstat (limited to 'embed')
-rw-r--r--embed/Makefile.am2
-rw-r--r--embed/ephy-base-embed.c114
-rw-r--r--embed/ephy-base-embed.h34
-rw-r--r--embed/mozilla/EphyBrowser.cpp6
-rw-r--r--embed/mozilla/EphyBrowser.h2
-rw-r--r--embed/mozilla/mozilla-embed.cpp110
6 files changed, 218 insertions, 50 deletions
diff --git a/embed/Makefile.am b/embed/Makefile.am
index 209eb74e6..48259ab18 100644
--- a/embed/Makefile.am
+++ b/embed/Makefile.am
@@ -22,6 +22,7 @@ NOINST_H_FILES = \
INST_H_FILES = \
ephy-adblock.h \
ephy-adblock-manager.h \
+ ephy-base-embed.h \
ephy-command-manager.h \
ephy-cookie-manager.h \
ephy-embed.h \
@@ -43,6 +44,7 @@ BUILT_SOURCES = \
libephyembed_la_SOURCES = \
ephy-adblock.c \
ephy-adblock-manager.c \
+ ephy-base-embed.c \
downloader-view.c \
ephy-command-manager.c \
ephy-cookie-manager.c \
diff --git a/embed/ephy-base-embed.c b/embed/ephy-base-embed.c
new file mode 100644
index 000000000..776ee8e1a
--- /dev/null
+++ b/embed/ephy-base-embed.c
@@ -0,0 +1,114 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2007 Xan Lopez
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "ephy-embed.h"
+#include "ephy-base-embed.h"
+
+struct _EphyBaseEmbedPrivate
+{
+ /* Flags */
+ guint is_blank : 1;
+
+ char *address;
+ char *typed_address;
+ char *title;
+ char *loading_title;
+};
+
+static void ephy_base_embed_dispose (GObject *object);
+static void ephy_base_embed_finalize (GObject *object);
+static void ephy_embed_iface_init (EphyEmbedIface *iface);
+
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (EphyBaseEmbed, ephy_base_embed, GTK_TYPE_BIN,
+ G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED,
+ ephy_embed_iface_init))
+
+static void
+ephy_base_embed_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ GtkWidget *child;
+
+ GTK_WIDGET_CLASS (ephy_base_embed_parent_class)->size_request (widget, requisition);
+
+ child = GTK_BIN (widget)->child;
+
+ if (child && GTK_WIDGET_VISIBLE (child))
+ {
+ GtkRequisition child_requisition;
+ gtk_widget_size_request (GTK_WIDGET (child), &child_requisition);
+ }
+}
+
+static void
+ephy_base_embed_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkWidget *child;
+ GtkAllocation invalid = { -1, -1, 1, 1 };
+
+ widget->allocation = *allocation;
+
+ child = GTK_BIN (widget)->child;
+ g_return_if_fail (child != NULL);
+
+ gtk_widget_size_allocate (child, allocation);
+}
+
+static void
+ephy_base_embed_class_init (EphyBaseEmbedClass *klass)
+{
+ GObjectClass *gobject_class = (GObjectClass *)klass;
+ GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
+
+ gobject_class->dispose = ephy_base_embed_dispose;
+ gobject_class->finalize = ephy_base_embed_finalize;
+
+ widget_class->size_request = ephy_base_embed_size_request;
+ widget_class->size_allocate = ephy_base_embed_size_allocate;
+ g_type_class_add_private (gobject_class, sizeof (EphyBaseEmbedPrivate));
+}
+
+static void
+ephy_base_embed_init (EphyBaseEmbed *self)
+{
+}
+
+static void
+ephy_base_embed_dispose (GObject *object)
+{
+ EphyBaseEmbed *self = (EphyBaseEmbed *)object;
+
+ G_OBJECT_CLASS (ephy_base_embed_parent_class)->dispose (object);
+}
+
+static void
+ephy_base_embed_finalize (GObject *object)
+{
+ EphyBaseEmbed *self = (EphyBaseEmbed *)object;
+
+ G_OBJECT_CLASS (ephy_base_embed_parent_class)->finalize (object);
+}
+
+static void
+ephy_embed_iface_init (EphyEmbedIface *iface)
+{
+}
diff --git a/embed/ephy-base-embed.h b/embed/ephy-base-embed.h
new file mode 100644
index 000000000..4fe5b120d
--- /dev/null
+++ b/embed/ephy-base-embed.h
@@ -0,0 +1,34 @@
+#ifndef __EPHY_BASE_EMBED_H__
+#define __EPHY_BASE_EMBED_H__
+
+#include <gtk/gtk.h>
+
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_BASE_EMBED (ephy_base_embed_get_type())
+#define EPHY_BASE_EMBED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_BASE_EMBED, EphyBaseEmbed))
+#define EPHY_BASE_EMBED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_BASE_EMBED, EphyBaseEmbedClass))
+#define EPHY_IS_BASE_EMBED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_BASE_EMBED))
+#define EPHY_IS_BASE_EMBED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EPHY_TYPE_BASE_EMBED))
+#define EPHY_BASE_EMBED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EPHY_TYPE_BASE_EMBED, EphyBaseEmbedClass))
+
+typedef struct _EphyBaseEmbed EphyBaseEmbed;
+typedef struct _EphyBaseEmbedClass EphyBaseEmbedClass;
+typedef struct _EphyBaseEmbedPrivate EphyBaseEmbedPrivate;
+
+struct _EphyBaseEmbedClass
+{
+ GtkBinClass parent_class;
+};
+
+struct _EphyBaseEmbed
+{
+ GtkBin parent_instance;
+};
+
+GType ephy_base_embed_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __EPHY_BASE_EMBED_H__ */
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index 9ea302360..d4a53811b 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -566,13 +566,13 @@ EphyBrowser::~EphyBrowser ()
LOG ("EphyBrowser dtor (%p)", this);
}
-nsresult EphyBrowser::Init (GtkMozEmbed *mozembed)
+nsresult EphyBrowser::Init (EphyEmbed *embed)
{
if (mInitialized) return NS_OK;
- mEmbed = GTK_WIDGET (mozembed);
+ mEmbed = GTK_WIDGET (embed);
- gtk_moz_embed_get_nsIWebBrowser (mozembed,
+ gtk_moz_embed_get_nsIWebBrowser (GTK_MOZ_EMBED (gtk_bin_get_child (GTK_BIN (embed))),
getter_AddRefs(mWebBrowser));
NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h
index a498f42c9..57cec5ad6 100644
--- a/embed/mozilla/EphyBrowser.h
+++ b/embed/mozilla/EphyBrowser.h
@@ -136,7 +136,7 @@ public:
EphyBrowser();
~EphyBrowser();
- nsresult Init (GtkMozEmbed *mozembed);
+ nsresult Init (EphyEmbed *embed);
nsresult Destroy (void);
nsresult DoCommand (const char *command);
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 12b1f200b..e0622ccad 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -41,6 +41,7 @@
#include "EphyUtils.h"
#include "EventContext.h"
+#include "ephy-base-embed.h"
#include "ephy-command-manager.h"
#include "ephy-debug.h"
#include "ephy-embed-shell.h"
@@ -90,9 +91,9 @@ static void mozilla_embed_document_type_cb (EphyEmbed *embed,
static void mozilla_embed_zoom_change_cb (EphyEmbed *embed,
float zoom,
MozillaEmbed *membed);
-static void mozilla_embed_title_change_cb (EphyEmbed *embed,
+static void mozilla_embed_title_change_cb (GtkMozEmbed *embed,
MozillaEmbed *membed);
-static void mozilla_embed_link_message_cb (EphyEmbed *embed,
+static void mozilla_embed_link_message_cb (GtkMozEmbed *embed,
MozillaEmbed *membed);
static void mozilla_embed_set_title (MozillaEmbed *embed,
char *title);
@@ -104,9 +105,9 @@ static void mozilla_embed_icon_cache_changed_cb (EphyFaviconCache *cache,
MozillaEmbed *embed);
static void mozilla_embed_set_icon_address (MozillaEmbed *embed,
const char *address);
-static void mozilla_embed_favicon_cb (EphyEmbed *embed,
+static void mozilla_embed_favicon_cb (MozillaEmbed *membed,
const char *address,
- MozillaEmbed *membed);
+ GtkMozEmbed *embed);
static gboolean mozilla_embed_open_uri_cb (EphyEmbed *embed,
const char *uri,
MozillaEmbed *membed);
@@ -142,6 +143,7 @@ typedef enum
struct MozillaEmbedPrivate
{
EphyBrowser *browser;
+ GtkMozEmbed *moz_embed;
MozillaEmbedLoadState load_state;
EphyEmbedAddressExpire address_expire;
@@ -236,7 +238,7 @@ ephy_command_manager_iface_init (EphyCommandManagerIface *iface)
iface->can_do_command = impl_manager_can_do_command;
}
-G_DEFINE_TYPE_WITH_CODE (MozillaEmbed, mozilla_embed, GTK_TYPE_MOZ_EMBED,
+G_DEFINE_TYPE_WITH_CODE (MozillaEmbed, mozilla_embed, EPHY_TYPE_BASE_EMBED,
G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED,
ephy_embed_iface_init)
G_IMPLEMENT_INTERFACE (EPHY_TYPE_COMMAND_MANAGER,
@@ -274,9 +276,10 @@ mozilla_embed_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (mozilla_embed_parent_class)->realize (widget);
+ gtk_widget_realize (GTK_WIDGET (mpriv->moz_embed));
/* Initialise our helper class */
nsresult rv;
- rv = mpriv->browser->Init (GTK_MOZ_EMBED (widget));
+ rv = mpriv->browser->Init (EPHY_EMBED (widget));
if (NS_FAILED (rv))
{
g_warning ("EphyBrowser initialization failed for %p\n", widget);
@@ -406,8 +409,6 @@ mozilla_embed_class_init (MozillaEmbedClass *klass)
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- mozilla_embed_parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
-
object_class->constructor = mozilla_embed_constructor;
object_class->finalize = mozilla_embed_finalize;
object_class->dispose = mozilla_embed_dispose;
@@ -439,59 +440,67 @@ mozilla_embed_class_init (MozillaEmbedClass *klass)
}
static void
-mozilla_embed_init (MozillaEmbed *embed)
+mozilla_embed_init (MozillaEmbed *membed)
{
EphyFaviconCache *cache;
MozillaEmbedPrivate *priv;
- embed->priv = MOZILLA_EMBED_GET_PRIVATE (embed);
- priv = embed->priv;
+ GtkWidget *embed;
+
+ membed->priv = MOZILLA_EMBED_GET_PRIVATE (membed);
+ priv = membed->priv;
+
+ embed = gtk_moz_embed_new ();
+ priv->moz_embed = GTK_MOZ_EMBED (embed);
+ gtk_container_add (GTK_CONTAINER (membed), embed);
+ gtk_widget_show (embed);
+
priv->browser = new EphyBrowser ();
g_signal_connect_object (embed, "location",
G_CALLBACK (mozilla_embed_location_changed_cb),
- embed, (GConnectFlags) 0);
+ membed, (GConnectFlags) 0);
g_signal_connect_object (embed, "net_state_all",
G_CALLBACK (mozilla_embed_net_state_all_cb),
- embed, (GConnectFlags) 0);
+ membed, (GConnectFlags) 0);
g_signal_connect_object (embed, "dom_mouse_click",
G_CALLBACK (mozilla_embed_dom_mouse_click_cb),
- embed, (GConnectFlags) 0);
+ membed, (GConnectFlags) 0);
g_signal_connect_object (embed, "dom_mouse_down",
G_CALLBACK (mozilla_embed_dom_mouse_down_cb),
- embed, (GConnectFlags) 0);
+ membed, (GConnectFlags) 0);
g_signal_connect_object (embed, "dom-key-press",
G_CALLBACK (mozilla_embed_dom_key_press_cb),
- embed, (GConnectFlags) 0);
+ membed, (GConnectFlags) 0);
g_signal_connect_object (embed, "new_window",
G_CALLBACK (mozilla_embed_new_window_cb),
- embed, (GConnectFlags) 0);
+ membed, (GConnectFlags) 0);
g_signal_connect_object (embed, "security_change",
G_CALLBACK (mozilla_embed_security_change_cb),
- embed, (GConnectFlags) 0);
- g_signal_connect_object (embed, "ge_document_type",
+ membed, (GConnectFlags) 0);
+ g_signal_connect_object (membed, "ge_document_type",
G_CALLBACK (mozilla_embed_document_type_cb),
- embed, (GConnectFlags) 0);
- g_signal_connect_object (embed, "ge_zoom_change",
+ membed, (GConnectFlags) 0);
+ g_signal_connect_object (membed, "ge_zoom_change",
G_CALLBACK (mozilla_embed_zoom_change_cb),
embed, (GConnectFlags) 0);
g_signal_connect_object (embed, "title",
G_CALLBACK (mozilla_embed_title_change_cb),
- embed, (GConnectFlags) 0);
+ membed, (GConnectFlags) 0);
g_signal_connect_object (embed, "link_message",
G_CALLBACK (mozilla_embed_link_message_cb),
- embed, (GConnectFlags)0);
- g_signal_connect_object (embed, "ge_favicon",
+ membed, (GConnectFlags)0);
+ g_signal_connect_object (membed, "ge_favicon",
G_CALLBACK (mozilla_embed_favicon_cb),
embed, (GConnectFlags)0);
g_signal_connect_object (embed, "open_uri",
G_CALLBACK (mozilla_embed_open_uri_cb),
- embed,(GConnectFlags) 0);
+ membed,(GConnectFlags) 0);
cache = EPHY_FAVICON_CACHE
(ephy_embed_shell_get_favicon_cache (embed_shell));
g_signal_connect_object (G_OBJECT (cache), "changed",
G_CALLBACK (mozilla_embed_icon_cache_changed_cb),
- embed, (GConnectFlags)0);
+ membed, (GConnectFlags)0);
priv->document_type = EPHY_EMBED_DOCUMENT_HTML;
priv->security_level = EPHY_EMBED_STATE_IS_UNKNOWN;
@@ -888,7 +897,8 @@ static void
impl_load_url (EphyEmbed *embed,
const char *url)
{
- gtk_moz_embed_load_url (GTK_MOZ_EMBED(embed), url);
+ GtkMozEmbed *moz_embed = MOZILLA_EMBED (embed)->priv->moz_embed;
+ gtk_moz_embed_load_url (moz_embed, url);
}
static char * impl_get_location (EphyEmbed *embed, gboolean toplevel);
@@ -931,19 +941,22 @@ impl_load (EphyEmbed *embed,
static void
impl_stop_load (EphyEmbed *embed)
{
- gtk_moz_embed_stop_load (GTK_MOZ_EMBED(embed));
+ GtkMozEmbed *moz_embed = MOZILLA_EMBED (embed)->priv->moz_embed;
+ gtk_moz_embed_stop_load (moz_embed);
}
static gboolean
impl_can_go_back (EphyEmbed *embed)
{
- return gtk_moz_embed_can_go_back (GTK_MOZ_EMBED(embed));
+ GtkMozEmbed *moz_embed = MOZILLA_EMBED (embed)->priv->moz_embed;
+ return gtk_moz_embed_can_go_back (moz_embed);
}
static gboolean
impl_can_go_forward (EphyEmbed *embed)
{
- return gtk_moz_embed_can_go_forward (GTK_MOZ_EMBED(embed));
+ GtkMozEmbed *moz_embed = MOZILLA_EMBED (embed)->priv->moz_embed;
+ return gtk_moz_embed_can_go_forward (moz_embed);
}
static gboolean
@@ -1035,13 +1048,15 @@ impl_get_go_up_list (EphyEmbed *embed)
static void
impl_go_back (EphyEmbed *embed)
{
- gtk_moz_embed_go_back (GTK_MOZ_EMBED(embed));
+ GtkMozEmbed *moz_embed = MOZILLA_EMBED (embed)->priv->moz_embed;
+ gtk_moz_embed_go_back (moz_embed);
}
static void
impl_go_forward (EphyEmbed *embed)
{
- gtk_moz_embed_go_forward (GTK_MOZ_EMBED(embed));
+ GtkMozEmbed *moz_embed = MOZILLA_EMBED (embed)->priv->moz_embed;
+ gtk_moz_embed_go_forward (moz_embed);
}
static void
@@ -1072,7 +1087,8 @@ impl_get_title (EphyEmbed *embed)
static char *
impl_get_js_status (EphyEmbed *embed)
{
- return gtk_moz_embed_get_js_status (GTK_MOZ_EMBED (embed));
+ GtkMozEmbed *moz_embed = MOZILLA_EMBED (embed)->priv->moz_embed;
+ return gtk_moz_embed_get_js_status (moz_embed);
}
static char *
@@ -1114,6 +1130,7 @@ static void
impl_reload (EphyEmbed *embed,
gboolean force)
{
+ GtkMozEmbed *moz_embed = MOZILLA_EMBED (embed)->priv->moz_embed;
guint32 mflags = GTK_MOZ_EMBED_FLAG_RELOADNORMAL;
if (force)
@@ -1121,7 +1138,7 @@ impl_reload (EphyEmbed *embed,
mflags = GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE;
}
- gtk_moz_embed_reload (GTK_MOZ_EMBED(embed), mflags);
+ gtk_moz_embed_reload (moz_embed, mflags);
}
static void
@@ -1359,7 +1376,7 @@ impl_set_encoding (EphyEmbed *embed,
if (NS_FAILED (rv)) return;
}
- gtk_moz_embed_reload (GTK_MOZ_EMBED (embed),
+ gtk_moz_embed_reload (mpriv->moz_embed,
GTK_MOZ_EMBED_FLAG_RELOADCHARSETCHANGE);
}
@@ -1802,7 +1819,7 @@ mozilla_embed_location_changed_cb (GtkMozEmbed *embed,
MozillaEmbed *membed)
{
char *location;
- GObject *object = G_OBJECT (embed);
+ GObject *object = G_OBJECT (membed);
location = gtk_moz_embed_get_location (embed);
g_signal_emit_by_name (membed, "ge_location", location);
@@ -1825,7 +1842,7 @@ mozilla_embed_location_changed_cb (GtkMozEmbed *embed,
char *embed_address;
/* we do this to get rid of an eventual password in the URL */
- embed_address = impl_get_location (EPHY_EMBED (embed), TRUE);
+ embed_address = impl_get_location (EPHY_EMBED (membed), TRUE);
mozilla_embed_set_address (membed, embed_address);
mozilla_embed_set_loading_title (membed, embed_address, TRUE);
}
@@ -1842,10 +1859,10 @@ mozilla_embed_location_changed_cb (GtkMozEmbed *embed,
}
static void
-mozilla_embed_link_message_cb (EphyEmbed *embed,
+mozilla_embed_link_message_cb (GtkMozEmbed *embed,
MozillaEmbed *membed)
{
- char *link_message = gtk_moz_embed_get_link_message (GTK_MOZ_EMBED (membed));
+ char *link_message = gtk_moz_embed_get_link_message (embed);
mozilla_embed_set_link_message (membed, link_message);
g_free (link_message);
}
@@ -1924,9 +1941,9 @@ mozilla_embed_set_icon_address (MozillaEmbed *embed,
}
static void
-mozilla_embed_favicon_cb (EphyEmbed *embed,
+mozilla_embed_favicon_cb (MozillaEmbed *membed,
const char *address,
- MozillaEmbed *membed)
+ GtkMozEmbed *embed)
{
mozilla_embed_set_icon_address (membed, address);
}
@@ -1987,6 +2004,7 @@ static void
update_load_state (MozillaEmbed *membed, gint state)
{
MozillaEmbedPrivate *priv = membed->priv;
+ GtkMozEmbed *moz_embed = priv->moz_embed;
if (state & GTK_MOZ_EMBED_FLAG_IS_DOCUMENT &&
state & (GTK_MOZ_EMBED_FLAG_START | GTK_MOZ_EMBED_FLAG_STOP))
@@ -2001,7 +2019,7 @@ update_load_state (MozillaEmbed *membed, gint state)
priv->load_state = MOZILLA_EMBED_LOAD_LOADING;
char *address;
- address = gtk_moz_embed_get_location (GTK_MOZ_EMBED (membed));
+ address = gtk_moz_embed_get_location (moz_embed);
g_signal_emit_by_name (membed, "ge-content-change", address);
mozilla_embed_restore_zoom_level (membed, address);
g_free (address);
@@ -2030,7 +2048,7 @@ update_load_state (MozillaEmbed *membed, gint state)
priv->load_state = MOZILLA_EMBED_LOAD_LOADING;
char *address;
- address = gtk_moz_embed_get_location (GTK_MOZ_EMBED (membed));
+ address = gtk_moz_embed_get_location (moz_embed);
g_signal_emit_by_name (membed, "ge_content_change", address);
mozilla_embed_restore_zoom_level (membed, address);
g_free (address);
@@ -2406,7 +2424,7 @@ mozilla_embed_new_window_cb (GtkMozEmbed *embed,
g_assert (new_embed != NULL);
- gtk_moz_embed_set_chrome_mask (GTK_MOZ_EMBED (new_embed), chrome);
+ gtk_moz_embed_set_chrome_mask (embed, chrome);
g_signal_emit_by_name (membed, "ge-new-window", new_embed);
@@ -2572,13 +2590,13 @@ mozilla_embed_set_title (MozillaEmbed *embed,
}
static void
-mozilla_embed_title_change_cb (EphyEmbed *embed,
+mozilla_embed_title_change_cb (GtkMozEmbed *embed,
MozillaEmbed *membed)
{
GObject *object = G_OBJECT (embed);
char *title;
- title = gtk_moz_embed_get_title (GTK_MOZ_EMBED (embed));
+ title = gtk_moz_embed_get_title (embed);
g_object_freeze_notify (object);