aboutsummaryrefslogtreecommitdiffstats
path: root/embed/downloader-view.c
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/downloader-view.c
parent0e935c597fe2e3e00f672b98f77eaebf48660857 (diff)
downloadgsoc2013-epiphany-553cf8c4a065086212d22d52715333ee166b85b5.tar.gz
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/downloader-view.c')
-rw-r--r--embed/downloader-view.c62
1 files changed, 58 insertions, 4 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);