aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog20
-rw-r--r--embed/downloader-view.c2
-rw-r--r--embed/downloader-view.h10
-rw-r--r--embed/ephy-embed-shell.c8
-rw-r--r--embed/ephy-embed-shell.h2
-rw-r--r--lib/ephy-gui.c24
-rw-r--r--lib/ephy-gui.h2
-rw-r--r--src/ephy-session.c207
8 files changed, 268 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index ba6707f13..0132f6107 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2006-02-02 Christian Persch <chpe@cvs.gnome.org>
+
+ * embed/downloader-view.c:
+ * embed/downloader-view.h:
+ * embed/ephy-embed-shell.c:
+ (ephy_embed_shell_get_downloader_view_nocreate):
+ * embed/ephy-embed-shell.h:
+ * lib/ephy-gui.c: (ephy_gui_message_dialog_get_content_box):
+ * lib/ephy-gui.h:
+ * src/ephy-session.c:
+ (confirm_shutdown_dialog_update_timeout_label),
+ (confirm_shutdown_dialog_tick_cb),
+ (confirm_shutdown_dialog_response_cb),
+ (confirm_shutdown_dialog_accept_cb),
+ (confirm_shutdown_dialog_weak_ref_cb), (confirm_shutdown_cb),
+ (save_yourself_cb):
+
+ On session logout, check if there are downloads pending (since
+ they're not resumable, bug #128048). #if 0'd for now.
+
2006-02-02 Jean-François Rameau <jframeau@cvs.gnome.org>
* lib/egg/egg-editable-toolbar.c: (toolbar_visibility_refresh):
diff --git a/embed/downloader-view.c b/embed/downloader-view.c
index 4877f03df..1057d0e79 100644
--- a/embed/downloader-view.c
+++ b/embed/downloader-view.c
@@ -70,7 +70,7 @@ enum
#define EPHY_DOWNLOADER_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_DOWNLOADER_VIEW, DownloaderViewPrivate))
-struct DownloaderViewPrivate
+struct _DownloaderViewPrivate
{
GtkTreeModel *model;
GHashTable *downloads_hash;
diff --git a/embed/downloader-view.h b/embed/downloader-view.h
index 2e3b869fc..5a8fb7368 100644
--- a/embed/downloader-view.h
+++ b/embed/downloader-view.h
@@ -36,11 +36,11 @@ G_BEGIN_DECLS
#define EPHY_IS_DOWNLOADER_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_DOWNLOADER_VIEW))
#define EPHY_DOWNLOADER_VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_DOWNLOADER_VIEW, DownloaderViewClass))
-typedef struct DownloaderView DownloaderView;
-typedef struct DownloaderViewClass DownloaderViewClass;
-typedef struct DownloaderViewPrivate DownloaderViewPrivate;
+typedef struct _DownloaderView DownloaderView;
+typedef struct _DownloaderViewPrivate DownloaderViewPrivate;
+typedef struct _DownloaderViewClass DownloaderViewClass;
-struct DownloaderView
+struct _DownloaderView
{
EphyDialog parent;
@@ -48,7 +48,7 @@ struct DownloaderView
DownloaderViewPrivate *priv;
};
-struct DownloaderViewClass
+struct _DownloaderViewClass
{
EphyDialogClass parent_class;
};
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 32dd8e1bc..6474fb2ed 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -202,6 +202,14 @@ ephy_embed_shell_get_downloader_view (EphyEmbedShell *shell)
return G_OBJECT (shell->priv->downloader_view);
}
+GObject *
+ephy_embed_shell_get_downloader_view_nocreate (EphyEmbedShell *shell)
+{
+ g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), NULL);
+
+ return (GObject *) shell->priv->downloader_view;
+}
+
static GObject *
impl_get_embed_single (EphyEmbedShell *shell)
{
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index 5f5a1b7df..74a25a22e 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -67,6 +67,8 @@ GObject *ephy_embed_shell_get_global_history (EphyEmbedShell *shell);
GObject *ephy_embed_shell_get_downloader_view (EphyEmbedShell *shell);
+GObject *ephy_embed_shell_get_downloader_view_nocreate (EphyEmbedShell *shell);
+
GObject *ephy_embed_shell_get_encodings (EphyEmbedShell *shell);
GObject *ephy_embed_shell_get_embed_single (EphyEmbedShell *shell);
diff --git a/lib/ephy-gui.c b/lib/ephy-gui.c
index 7ed8b36ef..d5104ad10 100644
--- a/lib/ephy-gui.c
+++ b/lib/ephy-gui.c
@@ -526,3 +526,27 @@ ephy_gui_window_present (GtkWindow *window,
gtk_widget_show (widget);
}
}
+
+/* Pending gtk+ bug http://bugzilla.gnome.org/show_bug.cgi?id=328069 */
+GtkWidget *
+ephy_gui_message_dialog_get_content_box (GtkWidget *dialog)
+{
+ GtkWidget *container;
+ GList *children;
+
+ /* Get the hbox which is the first child of the main vbox */
+ children = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox));
+ g_return_val_if_fail (children != NULL, NULL);
+
+ container = GTK_WIDGET (children->data);
+ g_list_free (children);
+
+ /* Get the vbox which is the second child of the hbox */
+ children = gtk_container_get_children (GTK_CONTAINER (container));
+ g_return_val_if_fail (children != NULL && children->next != NULL, NULL);
+
+ container = GTK_WIDGET (children->next->data);
+ g_list_free (children);
+
+ return container;
+}
diff --git a/lib/ephy-gui.h b/lib/ephy-gui.h
index c46efe746..a471f29b2 100644
--- a/lib/ephy-gui.h
+++ b/lib/ephy-gui.h
@@ -80,6 +80,8 @@ void ephy_gui_window_update_user_time (GtkWidget *window,
void ephy_gui_window_present (GtkWindow *window,
guint32 user_time);
+GtkWidget *ephy_gui_message_dialog_get_content_box (GtkWidget *dialog);
+
G_END_DECLS
#endif
diff --git a/src/ephy-session.c b/src/ephy-session.c
index d9a9a59a0..827435df4 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -138,9 +138,200 @@ ephy_session_get_type (void)
/* Gnome session client */
+#if 0
+
+typedef struct
+{
+ GtkWidget *dialog;
+ GtkWidget *label;
+ guint timeout_id;
+ guint ticks;
+ int response;
+ int key;
+} InteractData;
+
+static void
+confirm_shutdown_dialog_update_timeout_label (InteractData *data)
+{
+ char *text;
+
+ text = g_strdup_printf (ngettext ("Downloads will be aborted and logout proceed in %d second.",
+ "Downloads will be aborted and logout proceed in %d seconds.",
+ data->ticks),
+ data->ticks);
+
+ gtk_label_set_text (GTK_LABEL (data->label), text);
+ g_free (text);
+}
+
+static gboolean
+confirm_shutdown_dialog_tick_cb (InteractData *data)
+{
+ if (data->ticks > 0)
+ {
+ --data->ticks;
+ confirm_shutdown_dialog_update_timeout_label (data);
+ return TRUE;
+ }
+
+ data->timeout_id = 0;
+ gtk_dialog_response (GTK_DIALOG (data->dialog),
+ GTK_RESPONSE_ACCEPT);
+ return FALSE;
+}
+
+static void
+confirm_shutdown_dialog_response_cb (GtkWidget *dialog,
+ int response,
+ InteractData *data)
+{
+ LOG ("confirm_shutdown_dialog_response_cb response %d", response);
+
+ data->response = response;
+
+ gtk_widget_destroy (dialog);
+}
+
+static void
+confirm_shutdown_dialog_accept_cb (InteractData *data,
+ GObject *zombie)
+{
+ gtk_dialog_response (GTK_DIALOG (data->dialog),
+ GTK_RESPONSE_ACCEPT);
+}
+
+static void
+confirm_shutdown_dialog_weak_ref_cb (InteractData *data,
+ GObject *zombie)
+{
+ EphyShell *shell;
+ GObject *dv;
+ int key;
+ gboolean cancel_shutdown;
+
+ LOG ("confirm_shutdown_dialog_weak_ref_cb response %d", data->response);
+
+ shell = ephy_shell_get_default ();
+ if (shell != NULL)
+ {
+ g_object_weak_unref (G_OBJECT (shell),
+ (GWeakNotify) confirm_shutdown_dialog_accept_cb,
+ data);
+
+ dv = ephy_embed_shell_get_downloader_view_nocreate (ephy_embed_shell_get_default ());
+ if (dv != NULL)
+ {
+ g_object_weak_unref (dv,
+ (GWeakNotify) confirm_shutdown_dialog_accept_cb,
+ data);
+ }
+ }
+
+ if (data->timeout_id != 0)
+ {
+ g_source_remove (data->timeout_id);
+ }
+
+ key = data->key;
+ cancel_shutdown = data->response != GTK_RESPONSE_ACCEPT;
+
+ g_free (data);
+
+ gnome_interaction_key_return (key, cancel_shutdown);
+}
+
+static void
+confirm_shutdown_cb (GnomeClient *client,
+ int key,
+ GnomeDialogType dialog_type,
+ gpointer user_data)
+{
+ GObject *dv;
+ GtkWidget *dialog, *box;
+ InteractData *data;
+
+ /* FIXME: Can this happen: We already quit? */
+ if (ephy_shell_get_default () == NULL)
+ {
+ gnome_interaction_key_return (key, FALSE);
+ return;
+ }
+
+ dv = ephy_embed_shell_get_downloader_view_nocreate (ephy_embed_shell_get_default ());
+
+ /* Check if there are still downloads pending */
+ if (dv == NULL)
+ {
+ gnome_interaction_key_return (key, FALSE);
+ return;
+ }
+
+ dialog = gtk_message_dialog_new
+ (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ _("Abort pending downloads?"));
+
+ gtk_message_dialog_format_secondary_text
+ (GTK_MESSAGE_DIALOG (dialog),
+ _("There are still downloads pending. If you log out, "
+ "they will be aborted and lost."));
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Cancel Logout"), GTK_RESPONSE_REJECT);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Abort Downloads"), GTK_RESPONSE_ACCEPT);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), "");
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT);
+
+ data = g_new (InteractData, 1);
+ data->dialog = dialog;
+ data->response = GTK_RESPONSE_REJECT;
+ data->key = key;
+
+ /* This isn't very exact, but it's good enough here */
+ data->timeout_id = g_timeout_add (1000,
+ (GSourceFunc) confirm_shutdown_dialog_tick_cb,
+ data);
+ data->ticks = 60;
+
+ /* Add timeout label */
+ data->label = gtk_label_new (NULL);
+ gtk_label_set_line_wrap (GTK_LABEL (data->label), TRUE);
+ confirm_shutdown_dialog_update_timeout_label (data);
+
+ box = ephy_gui_message_dialog_get_content_box (dialog);
+ gtk_box_pack_end (GTK_BOX (box), data->label, FALSE, FALSE, 0);
+ gtk_widget_show (data->label);
+
+ /* When we're quitting, un-veto the shutdown */
+ g_object_weak_ref (G_OBJECT (ephy_shell_get_default ()),
+ (GWeakNotify) confirm_shutdown_dialog_accept_cb,
+ data);
+
+ /* When the download finishes, un-veto the shutdown */
+ g_object_weak_ref (dv,
+ (GWeakNotify) confirm_shutdown_dialog_accept_cb,
+ data);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (confirm_shutdown_dialog_response_cb), data);
+ g_object_weak_ref (G_OBJECT (dialog),
+ (GWeakNotify) confirm_shutdown_dialog_weak_ref_cb,
+ data);
+
+ gtk_window_present (GTK_WINDOW (dialog));
+}
+
+#endif /* if 0 */
+
static gboolean
save_yourself_cb (GnomeClient *client,
- gint phase,
+ int phase,
GnomeSaveStyle save_style,
gboolean shutdown,
GnomeInteractStyle interact_style,
@@ -172,6 +363,20 @@ save_yourself_cb (GnomeClient *client,
g_free (save_to);
+#if 0
+ /* If we're shutting down, check if there are downloads
+ * remaining, since they can't be restarted.
+ */
+ if (shutdown &&
+ ephy_embed_shell_get_downloader_view_nocreate (ephy_embed_shell_get_default ()) != NULL)
+ {
+ gnome_client_request_interaction (client,
+ GNOME_DIALOG_NORMAL,
+ (GnomeInteractFunction) confirm_shutdown_cb,
+ session);
+ }
+#endif
+
return TRUE;
}