aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-01-30 23:20:36 +0800
committerChristian Persch <chpe@src.gnome.org>2005-01-30 23:20:36 +0800
commit8f01817138c1852b319898a5de3f4b9f244cdea5 (patch)
tree3473088e9fc4b6200a85e6714183e6f8482b2963
parent58dba74abaf6313221c50629e546dc4492672486 (diff)
downloadgsoc2013-epiphany-8f01817138c1852b319898a5de3f4b9f244cdea5.tar
gsoc2013-epiphany-8f01817138c1852b319898a5de3f4b9f244cdea5.tar.gz
gsoc2013-epiphany-8f01817138c1852b319898a5de3f4b9f244cdea5.tar.bz2
gsoc2013-epiphany-8f01817138c1852b319898a5de3f4b9f244cdea5.tar.lz
gsoc2013-epiphany-8f01817138c1852b319898a5de3f4b9f244cdea5.tar.xz
gsoc2013-epiphany-8f01817138c1852b319898a5de3f4b9f244cdea5.tar.zst
gsoc2013-epiphany-8f01817138c1852b319898a5de3f4b9f244cdea5.zip
Move new-window signal to the embed single, and new window creation from
2005-01-30 Christian Persch <chpe@cvs.gnome.org> * doc/reference/tmpl/ephy-embed.sgml: * embed/ephy-embed-single.c: (ephy_embed_single_iface_init): * embed/ephy-embed-single.h: * embed/ephy-embed.c: (ephy_embed_base_init): * embed/ephy-embed.h: * embed/mozilla/mozilla-embed-single.cpp: * embed/mozilla/mozilla-embed.cpp: * embed/mozilla/mozilla-embed.h: * lib/ephy-marshal.list: * lib/ephy-prefs.h: * src/ephy-shell.c: (ephy_shell_new_window_cb), (impl_get_embed_single): * src/ephy-tab.c: (ephy_tab_new_window_cb): Move new-window signal to the embed single, and new window creation from EphyTab to EphyShell.
-rw-r--r--ChangeLog19
-rw-r--r--doc/reference/tmpl/ephy-embed.sgml6
-rw-r--r--embed/ephy-embed-single.c23
-rw-r--r--embed/ephy-embed-single.h4
-rw-r--r--embed/ephy-embed.c14
-rw-r--r--embed/ephy-embed.h4
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp27
-rw-r--r--embed/mozilla/mozilla-embed.cpp63
-rw-r--r--embed/mozilla/mozilla-embed.h10
-rw-r--r--lib/ephy-marshal.list2
-rw-r--r--lib/ephy-prefs.h1
-rw-r--r--src/ephy-shell.c42
-rw-r--r--src/ephy-tab.c27
13 files changed, 172 insertions, 70 deletions
diff --git a/ChangeLog b/ChangeLog
index a66d36bb6..f84c4255c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2005-01-30 Christian Persch <chpe@cvs.gnome.org>
+
+ * doc/reference/tmpl/ephy-embed.sgml:
+ * embed/ephy-embed-single.c: (ephy_embed_single_iface_init):
+ * embed/ephy-embed-single.h:
+ * embed/ephy-embed.c: (ephy_embed_base_init):
+ * embed/ephy-embed.h:
+ * embed/mozilla/mozilla-embed-single.cpp:
+ * embed/mozilla/mozilla-embed.cpp:
+ * embed/mozilla/mozilla-embed.h:
+ * lib/ephy-marshal.list:
+ * lib/ephy-prefs.h:
+ * src/ephy-shell.c: (ephy_shell_new_window_cb),
+ (impl_get_embed_single):
+ * src/ephy-tab.c: (ephy_tab_new_window_cb):
+
+ Move new-window signal to the embed single, and new window creation
+ from EphyTab to EphyShell.
+
2005-01-28 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/mozilla-embed.cpp:
diff --git a/doc/reference/tmpl/ephy-embed.sgml b/doc/reference/tmpl/ephy-embed.sgml
index 964dcfa00..25ecd5321 100644
--- a/doc/reference/tmpl/ephy-embed.sgml
+++ b/doc/reference/tmpl/ephy-embed.sgml
@@ -132,8 +132,8 @@ be done by casting).
@ephyembed: the object which received the signal.
@arg1:
-@Returns:
<!-- # Unused Parameters # -->
+@Returns:
@arg2:
<!-- ##### SIGNAL EphyEmbed::ge-popup-blocked ##### -->
@@ -205,6 +205,10 @@ be done by casting).
@:
@:
@:
+@:
+@:
+@:
+@:
@:
<!-- ##### SIGNAL EphyEmbed::ge-security-change ##### -->
diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c
index 3f5af639f..0b05dc876 100644
--- a/embed/ephy-embed-single.c
+++ b/embed/ephy-embed-single.c
@@ -23,6 +23,7 @@
#include "ephy-embed-single.h"
#include "ephy-embed-type-builtins.h"
#include "ephy-marshal.h"
+#include "ephy-signal-accumulator.h"
static void ephy_embed_single_iface_init (gpointer g_class);
@@ -57,6 +58,28 @@ ephy_embed_single_iface_init (gpointer g_class)
if (initialised == FALSE)
{
/**
+ * EphyEmbedSingle::new-window:
+ * @single:
+ * @parent_embed: the #EphyEmbed requesting the new window, or %NULL
+ * @mask: a #EphyEmbedChrome
+ *
+ * The ::new_window signal is emitted when a new window needs to be opened.
+ * For example, when a JavaScript popup window was opened.
+ *
+ * Return a new #EphyEmbed.
+ **/
+ g_signal_new ("new-window",
+ EPHY_TYPE_EMBED_SINGLE,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EphyEmbedSingleIface, new_window),
+ ephy_signal_accumulator_object, ephy_embed_get_type,
+ ephy_marshal_OBJECT__OBJECT_FLAGS,
+ GTK_TYPE_WIDGET,
+ 2,
+ GTK_TYPE_WIDGET,
+ EPHY_TYPE_EMBED_CHROME);
+
+/**
* EphyEmbedSingle::handle_content:
* @single:
* @mime_type: the MIME type of the content
diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h
index ceb2dcb19..03e4f9a05 100644
--- a/embed/ephy-embed-single.h
+++ b/embed/ephy-embed-single.h
@@ -53,6 +53,10 @@ struct _EphyEmbedSingleIface
/* Signals */
+ EphyEmbed * (* new_window) (EphyEmbedSingle *single,
+ EphyEmbed *parent_embed,
+ EphyEmbedChrome chromemask);
+
gboolean (* handle_content) (EphyEmbedSingle *shell,
char *mime_type,
char *uri);
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 376eede08..a331c2ab4 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -24,7 +24,6 @@
#include "ephy-embed-type-builtins.h"
#include "ephy-marshal.h"
-#include "ephy-signal-accumulator.h"
#include "mozilla-embed-single.h"
#include "mozilla-embed.h"
@@ -62,21 +61,20 @@ ephy_embed_base_init (gpointer g_class)
/**
* EphyEmbed::ge-new-window:
* @embed:
- * @mask: a #EphyChromeMask
+ * @new_embed: the newly opened #EphyEmbed
*
- * The ::ge_new_window signal is emitted when a new window has been opened by
+ * The ::ge_new_window signal is emitted after a new window has been opened by
* the embed. For example, when a JavaScript popup window is opened.
- * Return a new #EphyEmbed.
**/
g_signal_new ("ge_new_window",
EPHY_TYPE_EMBED,
G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EphyEmbedIface, new_window),
- ephy_signal_accumulator_object, ephy_embed_get_type,
- ephy_marshal_OBJECT__FLAGS,
- G_TYPE_OBJECT,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
1,
- EPHY_TYPE_EMBED_CHROME);
+ GTK_TYPE_WIDGET);
/**
* EphyEmbed::ge-popup-blocked:
* @embed:
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index d08174183..a25e74d78 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -138,8 +138,8 @@ struct _EphyEmbedIface
void (* modal_alert_closed) (EphyEmbed *embed);
void (* document_type) (EphyEmbed *embed,
EphyEmbedDocumentType type);
- EphyEmbed * (* new_window) (EphyEmbed *embed,
- EphyEmbedChrome chromemask);
+ void (* new_window) (EphyEmbed *embed,
+ EphyEmbed *new_embed);
/* Methods */
void (* load_url) (EphyEmbed *embed,
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index f1ac51326..06e830319 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -312,14 +312,31 @@ mozilla_setup_colors (MozillaEmbedSingle *mes)
}
static void
-mozilla_embed_single_new_window_orphan_cb (GtkMozEmbedSingle *embed,
- GtkMozEmbed **retval,
+mozilla_embed_single_new_window_orphan_cb (GtkMozEmbedSingle *moz_single,
+ GtkMozEmbed **newEmbed,
guint chrome_mask,
- EphyEmbedSingle *shell)
+ EphyEmbedSingle *single)
{
- g_assert (chrome_mask & GTK_MOZ_EMBED_FLAG_OPENASCHROME);
+ GtkMozEmbedChromeFlags chrome = (GtkMozEmbedChromeFlags) chrome_mask;
+ EphyEmbed *new_embed = NULL;
+ EphyEmbedChrome mask;
- *retval = _mozilla_embed_new_xul_dialog ();
+ if (chrome_mask & GTK_MOZ_EMBED_FLAG_OPENASCHROME)
+ {
+ *newEmbed = _mozilla_embed_new_xul_dialog ();
+ return;
+ }
+
+ mask = _mozilla_embed_translate_chrome (chrome);
+
+ g_signal_emit_by_name (single, "new-window", NULL, mask,
+ &new_embed);
+
+ g_assert (new_embed != NULL);
+
+ gtk_moz_embed_set_chrome_mask (GTK_MOZ_EMBED (new_embed), chrome);
+
+ *newEmbed = GTK_MOZ_EMBED (new_embed);
}
static void
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 54db6067c..fc77d32ae 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -25,6 +25,7 @@
#include "mozilla-embed.h"
#include "mozilla-embed-event.h"
+#include "ephy-embed-single.h"
#include "ephy-embed-shell.h"
#include "ephy-command-manager.h"
#include "ephy-string.h"
@@ -65,7 +66,7 @@ static gboolean mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed,
MozillaEmbed *membed);
static void mozilla_embed_new_window_cb (GtkMozEmbed *embed,
GtkMozEmbed **newEmbed,
- guint chromemask,
+ guint chrome_mask,
MozillaEmbed *membed);
static void mozilla_embed_security_change_cb (GtkMozEmbed *embed,
gpointer request,
@@ -932,20 +933,13 @@ mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event,
"ge_dom_mouse_down");
}
-static void
-mozilla_embed_new_window_cb (GtkMozEmbed *embed,
- GtkMozEmbed **newEmbed,
- guint chrome_mask,
- MozillaEmbed *membed)
+EphyEmbedChrome
+_mozilla_embed_translate_chrome (GtkMozEmbedChromeFlags flags)
{
- guint i;
- guint mask = 0;
- EphyEmbed *new_embed = NULL;
-
- struct
+ static const struct
{
- guint mozilla_mask;
- guint embed_mask;
+ guint mozilla_flag;
+ guint ephy_flag;
}
conversion_map [] =
{
@@ -953,28 +947,49 @@ mozilla_embed_new_window_cb (GtkMozEmbed *embed,
{ GTK_MOZ_EMBED_FLAG_TOOLBARON, EPHY_EMBED_CHROME_TOOLBAR },
{ GTK_MOZ_EMBED_FLAG_STATUSBARON, EPHY_EMBED_CHROME_STATUSBAR },
{ GTK_MOZ_EMBED_FLAG_PERSONALTOOLBARON, EPHY_EMBED_CHROME_BOOKMARKSBAR },
- { 0, 0 }
};
- if (chrome_mask & GTK_MOZ_EMBED_FLAG_OPENASCHROME)
- {
- *newEmbed = _mozilla_embed_new_xul_dialog ();
- return;
- }
+ guint mask = 0, i;
- for (i = 0; conversion_map[i].mozilla_mask != 0; i++)
+ for (i = 0; i < G_N_ELEMENTS (conversion_map); i++)
{
- if (chrome_mask & conversion_map[i].mozilla_mask)
+ if (flags & conversion_map[i].mozilla_flag)
{
- mask |= conversion_map[i].embed_mask;
+ mask |= conversion_map[i].ephy_flag;
}
}
- g_signal_emit_by_name (membed, "ge_new_window", mask, &new_embed);
+ return (EphyEmbedChrome) mask;
+}
+
+static void
+mozilla_embed_new_window_cb (GtkMozEmbed *embed,
+ GtkMozEmbed **newEmbed,
+ guint chrome_mask,
+ MozillaEmbed *membed)
+{
+ GtkMozEmbedChromeFlags chrome = (GtkMozEmbedChromeFlags) chrome_mask;
+ EphyEmbed *new_embed = NULL;
+ GObject *single;
+ EphyEmbedChrome mask;
+
+ if (chrome & GTK_MOZ_EMBED_FLAG_OPENASCHROME)
+ {
+ *newEmbed = _mozilla_embed_new_xul_dialog ();
+ return;
+ }
+
+ mask = _mozilla_embed_translate_chrome (chrome);
+
+ single = ephy_embed_shell_get_embed_single (embed_shell);
+ g_signal_emit_by_name (single, "new-window", embed, mask,
+ &new_embed);
g_assert (new_embed != NULL);
- gtk_moz_embed_set_chrome_mask (GTK_MOZ_EMBED (new_embed), chrome_mask);
+ gtk_moz_embed_set_chrome_mask (GTK_MOZ_EMBED (new_embed), chrome);
+
+ g_signal_emit_by_name (membed, "ge-new-window", new_embed);
*newEmbed = GTK_MOZ_EMBED (new_embed);
}
diff --git a/embed/mozilla/mozilla-embed.h b/embed/mozilla/mozilla-embed.h
index 64bb5ccd8..d10c850b8 100644
--- a/embed/mozilla/mozilla-embed.h
+++ b/embed/mozilla/mozilla-embed.h
@@ -54,11 +54,15 @@ struct MozillaEmbedClass
GtkMozEmbedClass parent_class;
};
-GType mozilla_embed_get_type (void);
+GType mozilla_embed_get_type (void);
-gpointer _mozilla_embed_get_ephy_browser (MozillaEmbed *embed);
+/* The following are private to the embed implementation */
-GtkMozEmbed *_mozilla_embed_new_xul_dialog (void);
+gpointer _mozilla_embed_get_ephy_browser (MozillaEmbed *embed);
+
+GtkMozEmbed *_mozilla_embed_new_xul_dialog (void);
+
+EphyEmbedChrome _mozilla_embed_translate_chrome (GtkMozEmbedChromeFlags flags);
G_END_DECLS
diff --git a/lib/ephy-marshal.list b/lib/ephy-marshal.list
index e088e8287..9d4efc5b9 100644
--- a/lib/ephy-marshal.list
+++ b/lib/ephy-marshal.list
@@ -2,7 +2,7 @@ BOOLEAN:ENUM,STRING,STRING,STRING
BOOLEAN:OBJECT
BOOLEAN:STRING,STRING
BOOLEAN:VOID
-OBJECT:FLAGS
+OBJECT:OBJECT,FLAGS
OBJECT:STRING,OBJECT,FLAGS
STRING:VOID
VOID:ENUM
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 550dc7c9c..53a3ee8d7 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -56,6 +56,7 @@ G_BEGIN_DECLS
#define CONF_LOCKDOWN_DISABLE_PRINT_SETUP "/desktop/gnome/lockdown/disable_print_setup"
#define CONF_LOCKDOWN_DISABLE_COMMAND_LINE "/desktop/gnome/lockdown/disable_command_line"
#define CONF_LOCKDOWN_DISABLE_QUIT "/apps/epiphany/lockdown/disable_quit"
+#define CONF_LOCKDOWN_DISABLE_JAVASCRIPT_CHROME "/apps/epiphany/lockdown/disable_javascript_chrome"
/* System prefs */
#define CONF_DESKTOP_FTP_HANDLER "/desktop/gnome/url-handlers/ftp/command"
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 1fc08162a..9af0c98e5 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -45,6 +45,7 @@
#include "ephy-toolbar.h"
#include "ephy-automation.h"
#include "print-dialog.h"
+#include "ephy-prefs.h"
#ifdef ENABLE_DBUS
#include "ephy-dbus.h"
@@ -150,6 +151,37 @@ ephy_shell_class_init (EphyShellClass *klass)
g_type_class_add_private (object_class, sizeof(EphyShellPrivate));
}
+static EphyEmbed *
+ephy_shell_new_window_cb (EphyEmbedSingle *single,
+ EphyEmbed *parent_embed,
+ EphyEmbedChrome chromemask,
+ EphyShell *shell)
+{
+ EphyTab *new_tab;
+ EphyWindow *window;
+
+ LOG ("ephy_shell_new_window_cb tab chrome %d", chromemask);
+
+ /* FIXME in lockdown-fullscreen mode, always add a new tab instead */
+
+ if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_JAVASCRIPT_CHROME))
+ {
+ window = ephy_window_new ();
+ }
+ else
+ {
+ window = ephy_window_new_with_chrome (chromemask);
+ }
+
+ new_tab = ephy_tab_new ();
+ gtk_widget_show (GTK_WIDGET (new_tab));
+
+ ephy_window_add_tab (window, new_tab, -1, FALSE);
+
+ return ephy_tab_get_embed (new_tab);
+}
+
+
static gboolean
ephy_shell_add_sidebar_cb (EphyEmbedSingle *embed_single,
const char *url,
@@ -189,18 +221,20 @@ ephy_shell_add_sidebar_cb (EphyEmbedSingle *embed_single,
static GObject*
impl_get_embed_single (EphyEmbedShell *embed_shell)
{
- EphyShell *shell;
+ EphyShell *shell = EPHY_SHELL (embed_shell);
GObject *embed_single;
embed_single = EPHY_EMBED_SHELL_CLASS (parent_class)->get_embed_single (embed_shell);
- shell = EPHY_SHELL (embed_shell);
-
if (embed_single != NULL && shell->priv->embed_single_connected == FALSE)
{
+ g_signal_connect_object (embed_single, "new-window",
+ G_CALLBACK (ephy_shell_new_window_cb),
+ shell, G_CONNECT_AFTER);
+
g_signal_connect_object (embed_single, "add-sidebar",
G_CALLBACK (ephy_shell_add_sidebar_cb),
- embed_shell, G_CONNECT_AFTER);
+ shell, G_CONNECT_AFTER);
shell->priv->embed_single_connected = TRUE;
}
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 009dbe2e3..b4de9b701 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -63,8 +63,6 @@
#define EPHY_TAB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TAB, EphyTabPrivate))
-#define CONF_LOCKDOWN_DISABLE_JAVASCRIPT_CHROME "/apps/epiphany/lockdown/disable_javascript_chrome"
-
#define MAX_HIDDEN_POPUPS 5
struct _EphyTabPrivate
@@ -1326,34 +1324,19 @@ ephy_tab_net_state_cb (EphyEmbed *embed,
build_progress_from_requests (tab, state);
}
-static EphyEmbed *
+static void
ephy_tab_new_window_cb (EphyEmbed *embed,
- EphyEmbedChrome chromemask,
+ EphyEmbed *new_embed,
EphyTab *tab)
{
- EphyTab *new_tab;
EphyWindow *window;
- LOG ("ephy_tab_new_window_cb tab %p with parent %p chrome %d",
- tab, ((GtkWidget *) tab)->parent, chromemask);
+ g_return_if_fail (new_embed != NULL);
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_JAVASCRIPT_CHROME))
- {
- window = ephy_window_new ();
- }
- else
- {
- window = ephy_window_new_with_chrome (chromemask);
- }
-
- new_tab = ephy_tab_new ();
- gtk_widget_show (GTK_WIDGET (new_tab));
-
- ephy_window_add_tab (window, new_tab, -1, FALSE);
+ window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (new_embed)));
+ g_return_if_fail (window != NULL);
popups_manager_add_window (tab, window);
-
- return ephy_tab_get_embed (new_tab);
}
static void