aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-07-04 20:22:41 +0800
committerChristian Persch <chpe@src.gnome.org>2005-07-04 20:22:41 +0800
commit553cf8c4a065086212d22d52715333ee166b85b5 (patch)
tree3927b984675f82fd3488def5827247166be9a3e3 /embed
parent0e935c597fe2e3e00f672b98f77eaebf48660857 (diff)
downloadgsoc2013-epiphany-553cf8c4a065086212d22d52715333ee166b85b5.tar
gsoc2013-epiphany-553cf8c4a065086212d22d52715333ee166b85b5.tar.gz
gsoc2013-epiphany-553cf8c4a065086212d22d52715333ee166b85b5.tar.bz2
gsoc2013-epiphany-553cf8c4a065086212d22d52715333ee166b85b5.tar.lz
gsoc2013-epiphany-553cf8c4a065086212d22d52715333ee166b85b5.tar.xz
gsoc2013-epiphany-553cf8c4a065086212d22d52715333ee166b85b5.tar.zst
gsoc2013-epiphany-553cf8c4a065086212d22d52715333ee166b85b5.zip
Better fix for bug #151037 to make session shutdown work again. Also fix
2005-07-04 Christian Persch <chpe@cvs.gnome.org> * embed/downloader-view.c: (remove_download), (prepare_close_cb), (downloader_view_init), (downloader_view_finalize), (downloader_view_remove_download), (download_dialog_delete_cb): * embed/ephy-embed-shell.c: (ephy_embed_shell_prepare_close), (ephy_embed_shell_class_init): * embed/ephy-embed-shell.h: * embed/ephy-favicon-cache.c: (prepare_close_cb), (ephy_favicon_cache_init), (kill_download): * embed/mozilla/mozilla-embed-find.cpp: * embed/mozilla/mozilla-embed-single.cpp: * embed/mozilla/mozilla-embed.cpp: * embed/mozilla/mozilla-notifiers.cpp: * embed/mozilla/mozilla-notifiers.h: * src/ephy-session.c: (ephy_session_init), (ephy_session_dispose), (ephy_session_autoresume), (close_dialog), (ephy_session_close): * src/ephy-shell.c: (ephy_shell_startup), (toolwindow_hide_cb): * src/ephy-window.c: (ephy_window_finalize): Better fix for bug #151037 to make session shutdown work again. Also fix session shutdown while resuming, and preserve the session in this case.
Diffstat (limited to 'embed')
-rw-r--r--embed/downloader-view.c62
-rw-r--r--embed/ephy-embed-shell.c33
-rw-r--r--embed/ephy-embed-shell.h4
-rw-r--r--embed/ephy-favicon-cache.c18
-rw-r--r--embed/mozilla/mozilla-embed-find.cpp3
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp19
-rw-r--r--embed/mozilla/mozilla-embed.cpp13
-rw-r--r--embed/mozilla/mozilla-notifiers.cpp6
-rw-r--r--embed/mozilla/mozilla-notifiers.h3
9 files changed, 146 insertions, 15 deletions
diff --git a/embed/downloader-view.c b/embed/downloader-view.c
index 7499264ed..9ec3ac2da 100644
--- a/embed/downloader-view.c
+++ b/embed/downloader-view.c
@@ -82,6 +82,8 @@ struct DownloaderViewPrivate
GtkWidget *abort_button;
EggStatusIcon *status_icon;
+
+ guint idle_unref : 1;
};
enum
@@ -207,33 +209,82 @@ show_status_icon (DownloaderView *dv)
G_CALLBACK(status_icon_popup_menu_cb), dv);
}
+static gboolean
+remove_download (EphyDownload *download,
+ gpointer rowref,
+ DownloaderView *view)
+{
+ g_signal_handlers_disconnect_matched
+ (download, G_SIGNAL_MATCH_DATA ,
+ 0, 0, NULL, NULL, view);
+ ephy_download_cancel (download);
+
+ g_object_unref (download);
+ return TRUE;
+}
+
+static void
+prepare_close_cb (EphyEmbedShell *shell,
+ DownloaderView *view)
+{
+ DownloaderViewPrivate *priv = view->priv;
+
+ /* the downloader owns a ref to itself, no need for another ref */
+
+ /* hide window already */
+ gtk_widget_hide (priv->window);
+
+ priv->idle_unref = FALSE;
+
+ /* cancel pending downloads */
+ g_hash_table_foreach_remove (priv->downloads_hash,
+ (GHRFunc) remove_download, view);
+
+ gtk_list_store_clear (GTK_LIST_STORE (priv->model));
+
+ /* drop the self reference */
+ g_object_unref (view);
+}
+
static void
downloader_view_init (DownloaderView *dv)
{
+ g_object_ref (embed_shell);
+
dv->priv = EPHY_DOWNLOADER_VIEW_GET_PRIVATE (dv);
dv->priv->downloads_hash = g_hash_table_new_full
(g_direct_hash, g_direct_equal, NULL,
(GDestroyNotify)gtk_tree_row_reference_free);
+ dv->priv->idle_unref = TRUE;
downloader_view_build_ui (dv);
show_status_icon (dv);
- g_object_ref (embed_shell);
+ g_signal_connect_object (embed_shell, "prepare_close",
+ G_CALLBACK (prepare_close_cb), dv, 0);
}
static void
downloader_view_finalize (GObject *object)
{
DownloaderView *dv = EPHY_DOWNLOADER_VIEW (object);
+ gboolean idle_unref = dv->priv->idle_unref;
g_object_unref (dv->priv->status_icon);
g_hash_table_destroy (dv->priv->downloads_hash);
G_OBJECT_CLASS (parent_class)->finalize (object);
- ephy_object_idle_unref (embed_shell);
+ if (idle_unref)
+ {
+ ephy_object_idle_unref (embed_shell);
+ }
+ else
+ {
+ g_object_unref (embed_shell);
+ }
}
DownloaderView *
@@ -709,7 +760,7 @@ downloader_view_remove_download (DownloaderView *dv, EphyDownload *download)
gtk_tree_path_free (path);
/* Removal */
-
+
gtk_list_store_remove (GTK_LIST_STORE (dv->priv->model), &iter2);
g_hash_table_remove (dv->priv->downloads_hash,
download);
@@ -734,7 +785,9 @@ downloader_view_remove_download (DownloaderView *dv, EphyDownload *download)
/* Close the dialog if there are no more downloads */
if (!g_hash_table_size (dv->priv->downloads_hash))
- g_object_unref (G_OBJECT (dv));
+ {
+ g_object_unref (dv);
+ }
}
void
@@ -765,6 +818,7 @@ gboolean
download_dialog_delete_cb (GtkWidget *window, GdkEventAny *event,
DownloaderView *dv)
{
+ /* FIXME multi-head */
if (egg_tray_manager_check_running (gdk_screen_get_default ()))
{
gtk_widget_hide (dv->priv->window);
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 8067bf0ea..600037c93 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -43,6 +43,14 @@ struct _EphyEmbedShellPrivate
EphyEncodings *encodings;
};
+enum
+{
+ PREPARE_CLOSE,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
static void ephy_embed_shell_class_init (EphyEmbedShellClass *klass);
static void ephy_embed_shell_init (EphyEmbedShell *shell);
@@ -204,6 +212,14 @@ ephy_embed_shell_get_encodings (EphyEmbedShell *shell)
return G_OBJECT (shell->priv->encodings);
}
+void
+ephy_embed_shell_prepare_close (EphyEmbedShell *shell)
+{
+ EphyEmbedShellPrivate *priv = shell->priv;
+
+ g_signal_emit (shell, signals[PREPARE_CLOSE], 0);
+}
+
static void
ephy_embed_shell_init (EphyEmbedShell *shell)
{
@@ -225,5 +241,22 @@ ephy_embed_shell_class_init (EphyEmbedShellClass *klass)
klass->get_embed_single = impl_get_embed_single;
+/**
+ * EphyEmbed::prepare-close:
+ * @shell:
+ *
+ * The ::prepare-close signal is emitted when epiphany is preparing to
+ * quit on command from the session manager. You can use it when you need
+ * to do something special (shut down a service, for example).
+ **/
+ signals[PREPARE_CLOSE] =
+ g_signal_new ("prepare-close",
+ EPHY_TYPE_EMBED_SHELL,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EphyEmbedShellClass, prepare_close),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
g_type_class_add_private (object_class, sizeof (EphyEmbedShellPrivate));
}
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index b5897781f..d5369749c 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -51,6 +51,8 @@ struct _EphyEmbedShellClass
{
GObjectClass parent_class;
+ void (* prepare_close) (EphyEmbedShell *shell);
+
/*< private >*/
GObject * (* get_embed_single) (EphyEmbedShell *shell);
};
@@ -67,6 +69,8 @@ GObject *ephy_embed_shell_get_encodings (EphyEmbedShell *shell);
GObject *ephy_embed_shell_get_embed_single (EphyEmbedShell *shell);
+void ephy_embed_shell_prepare_close (EphyEmbedShell *shell);
+
G_END_DECLS
#endif /* !EPHY_EMBED_SHELL_H */
diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c
index 83c14ffad..034ec305d 100644
--- a/embed/ephy-favicon-cache.c
+++ b/embed/ephy-favicon-cache.c
@@ -29,6 +29,7 @@
#include <time.h>
#include <sys/stat.h>
+#include "ephy-embed-shell.h"
#include "ephy-embed-persist.h"
#include "ephy-embed-factory.h"
#include "ephy-file-helpers.h"
@@ -44,6 +45,7 @@
static void ephy_favicon_cache_class_init (EphyFaviconCacheClass *klass);
static void ephy_favicon_cache_init (EphyFaviconCache *cache);
static void ephy_favicon_cache_finalize (GObject *object);
+static gboolean kill_download (const char*, EphyEmbedPersist*, EphyFaviconCache*);
#define EPHY_FAVICON_CACHE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_FAVICON_CACHE, EphyFaviconCachePrivate))
@@ -205,6 +207,16 @@ remove_obsolete_icons (EphyFaviconCache *eb)
}
static void
+prepare_close_cb (EphyEmbedShell *shell,
+ EphyFaviconCache *cache)
+{
+ EphyFaviconCachePrivate *priv = cache->priv;
+
+ g_hash_table_foreach_remove (priv->downloads_hash,
+ (GHRFunc) kill_download, cache);
+}
+
+static void
ephy_favicon_cache_init (EphyFaviconCache *cache)
{
EphyNodeDb *db;
@@ -251,10 +263,14 @@ ephy_favicon_cache_init (EphyFaviconCache *cache)
ephy_node_db_load_from_file (cache->priv->db, cache->priv->xml_file,
EPHY_FAVICON_CACHE_XML_ROOT,
EPHY_FAVICON_CACHE_XML_VERSION);
+
+ /* listen to prepare-close on the shell */
+ g_signal_connect_object (embed_shell, "prepare-close",
+ G_CALLBACK (prepare_close_cb), cache, 0);
}
static gboolean
-kill_download (char *key,
+kill_download (const char *key,
EphyEmbedPersist *persist,
EphyFaviconCache *cache)
{
diff --git a/embed/mozilla/mozilla-embed-find.cpp b/embed/mozilla/mozilla-embed-find.cpp
index 92e755e2b..d039b4d69 100644
--- a/embed/mozilla/mozilla-embed-find.cpp
+++ b/embed/mozilla/mozilla-embed-find.cpp
@@ -28,7 +28,6 @@
#include "mozilla-embed-find.h"
#include "ephy-embed-find.h"
#include "ephy-embed-shell.h"
-#include "ephy-object-helpers.h"
#include "ephy-debug.h"
#define MOZILLA_EMBED_FIND_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MOZILLA_TYPE_EMBED_FIND, MozillaEmbedFindPrivate))
@@ -122,7 +121,7 @@ mozilla_embed_find_finalize (GObject *object)
parent_class->finalize (object);
- ephy_object_idle_unref (embed_shell);
+ g_object_unref (embed_shell);
}
static void
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 2053914e9..00d06875a 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -28,6 +28,7 @@
#include "ephy-cookie-manager.h"
#include "ephy-password-manager.h"
#include "ephy-permission-manager.h"
+#include "ephy-embed-shell.h"
#include "glib.h"
#include "ephy-debug.h"
@@ -545,6 +546,20 @@ init_services (MozillaEmbedSingle *single)
}
static void
+prepare_close_cb (EphyEmbedShell *shell)
+{
+ GValue value = { 0, };
+
+ /* To avoid evil web sites posing an alert and thus inhibiting
+ * shutdown, we just turn off javascript! :)
+ */
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&value, FALSE);
+ mozilla_pref_set ("javascript.enabled", &value);
+ g_value_unset (&value);
+}
+
+static void
mozilla_embed_single_init (MozillaEmbedSingle *mes)
{
mes->priv = MOZILLA_EMBED_SINGLE_GET_PRIVATE (mes);
@@ -571,6 +586,10 @@ mozilla_embed_single_init (MozillaEmbedSingle *mes)
exit (0);
}
+
+ g_signal_connect_object (embed_shell, "prepare-close",
+ G_CALLBACK (prepare_close_cb), mes,
+ (GConnectFlags) 0);
}
static void
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 1b7733e0d..1a8e31b55 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -29,7 +29,6 @@
#include "ephy-embed-shell.h"
#include "ephy-command-manager.h"
#include "ephy-string.h"
-#include "ephy-object-helpers.h"
#include "ephy-debug.h"
#include "EphyBrowser.h"
@@ -293,7 +292,7 @@ mozilla_embed_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
- ephy_object_idle_unref (embed_shell);
+ g_object_unref (embed_shell);
}
static void
@@ -1135,6 +1134,13 @@ _mozilla_embed_new_xul_dialog (void)
g_object_ref (embed_shell);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ g_object_set_data_full (G_OBJECT (window), "EmbedShellRef",
+ embed_shell,
+ (GDestroyNotify) g_object_unref);
+ g_signal_connect_object (embed_shell, "prepare_close",
+ G_CALLBACK (gtk_widget_destroy), window,
+ (GConnectFlags) G_CONNECT_SWAPPED);
+
embed = gtk_moz_embed_new ();
gtk_widget_show (embed);
gtk_container_add (GTK_CONTAINER (window), embed);
@@ -1155,8 +1161,5 @@ _mozilla_embed_new_xul_dialog (void)
G_CALLBACK (xul_title_cb),
window, (GConnectFlags) 0);
- g_object_weak_ref (G_OBJECT (window),
- (GWeakNotify) ephy_object_idle_unref, embed_shell);
-
return GTK_MOZ_EMBED (embed);
}
diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp
index 717a4fcbc..db227962b 100644
--- a/embed/mozilla/mozilla-notifiers.cpp
+++ b/embed/mozilla/mozilla-notifiers.cpp
@@ -412,8 +412,8 @@ static const PrefData notifier_entries[] =
transform_cookies_accept_mode },
};
-static gboolean
-mozilla_set_pref (const char *pref,
+gboolean
+mozilla_pref_set (const char *pref,
const GValue *value)
{
g_return_val_if_fail (pref != NULL, FALSE);
@@ -466,7 +466,7 @@ notify_cb (GConfClient *client,
if (data->func (gcvalue, &value, data->user_data))
{
- mozilla_set_pref (data->mozilla_pref, &value);
+ mozilla_pref_set (data->mozilla_pref, &value);
g_value_unset (&value);
}
}
diff --git a/embed/mozilla/mozilla-notifiers.h b/embed/mozilla/mozilla-notifiers.h
index 72d5d1cf4..642361c29 100644
--- a/embed/mozilla/mozilla-notifiers.h
+++ b/embed/mozilla/mozilla-notifiers.h
@@ -45,6 +45,9 @@ guint mozilla_notifier_add (const char *gconf_key,
void mozilla_notifier_remove (guint id);
+gboolean mozilla_pref_set (const char *pref,
+ const GValue *value);
+
void mozilla_notifiers_init (void);
void mozilla_notifiers_shutdown (void);