aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw44@gmail.com>2013-09-15 18:22:23 +0800
committerLAN-TW <lantw44@gmail.com>2013-09-15 18:22:23 +0800
commit17c25e5bdfa617b67ac3a40f4d7a43f70cb8e91f (patch)
tree860328e3b358125b688d24e913aad4267f83fe65
parent774d016516f2af752cc9f2d17e0a95d0feb754b0 (diff)
downloadgsoc2013-epiphany-17c25e5bdfa617b67ac3a40f4d7a43f70cb8e91f.tar
gsoc2013-epiphany-17c25e5bdfa617b67ac3a40f4d7a43f70cb8e91f.tar.gz
gsoc2013-epiphany-17c25e5bdfa617b67ac3a40f4d7a43f70cb8e91f.tar.bz2
gsoc2013-epiphany-17c25e5bdfa617b67ac3a40f4d7a43f70cb8e91f.tar.lz
gsoc2013-epiphany-17c25e5bdfa617b67ac3a40f4d7a43f70cb8e91f.tar.xz
gsoc2013-epiphany-17c25e5bdfa617b67ac3a40f4d7a43f70cb8e91f.tar.zst
gsoc2013-epiphany-17c25e5bdfa617b67ac3a40f4d7a43f70cb8e91f.zip
Archive creating can be cancelled
-rw-r--r--embed/ephy-web-view.c89
-rw-r--r--embed/ephy-web-view.h2
-rw-r--r--src/ephy-window.c4
-rw-r--r--src/resources/epiphany-ui.xml1
-rw-r--r--src/window-commands.c15
-rw-r--r--src/window-commands.h2
6 files changed, 103 insertions, 10 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 033c6eb5c..298a6fc8e 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -76,6 +76,7 @@ struct _EphyWebViewPrivate {
/* Flags */
guint is_blank : 1;
guint is_setting_zoom : 1;
+ guint is_archiving : 1;
guint load_failed : 1;
guint history_frozen : 1;
@@ -111,6 +112,9 @@ struct _EphyWebViewPrivate {
/* TLS information. */
GTlsCertificate *certificate;
GTlsCertificateFlags tls_errors;
+
+ /* Archive cancellable */
+ GCancellable *archive_cancellable;
};
typedef struct {
@@ -133,6 +137,7 @@ enum {
PROP_EMBED_TITLE,
PROP_TYPED_ADDRESS,
PROP_IS_BLANK,
+ PROP_IS_ARCHIVING
};
#define EPHY_WEB_VIEW_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_WEB_VIEW, EphyWebViewPrivate))
@@ -403,6 +408,9 @@ ephy_web_view_get_property (GObject *object,
case PROP_IS_BLANK:
g_value_set_boolean (value, priv->is_blank);
break;
+ case PROP_IS_ARCHIVING:
+ g_value_set_boolean (value, priv->is_archiving);
+ break;
default:
break;
}
@@ -432,6 +440,7 @@ ephy_web_view_set_property (GObject *object,
case PROP_STATUS_MESSAGE:
case PROP_EMBED_TITLE:
case PROP_IS_BLANK:
+ case PROP_IS_ARCHIVING:
/* read only */
break;
default:
@@ -681,6 +690,11 @@ ephy_web_view_dispose (GObject *object)
g_clear_object(&priv->certificate);
+ if (priv->archive_cancellable) {
+ g_cancellable_cancel (priv->archive_cancellable);
+ g_clear_object (&priv->archive_cancellable);
+ }
+
G_OBJECT_CLASS (ephy_web_view_parent_class)->dispose (object);
}
@@ -1062,6 +1076,19 @@ ephy_web_view_class_init (EphyWebViewClass *klass)
G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
/**
+ * EphyWebView:is-archiving:
+ *
+ * Whether the view is archiving files.
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_IS_ARCHIVING,
+ g_param_spec_boolean ("is-archiving",
+ "Is archiving",
+ "If the EphyWebView is archiving",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+/**
* EphyWebView::new-window:
* @view: the #EphyWebView that received the signal
* @new_view: the newly opened #EphyWebView
@@ -1890,7 +1917,6 @@ typedef struct {
typedef struct {
FileChooserInfo *info;
- GCancellable *cancellable;
GPtrArray *wk_filenames;
GSList *filenames;
char *dest;
@@ -1929,8 +1955,6 @@ archive_info_free (ArchiveInfo *ainfo)
{
if (ainfo->info != NULL)
g_free (ainfo->info);
- if (ainfo->cancellable != NULL)
- g_object_unref (ainfo->cancellable);
if (ainfo->wk_filenames != NULL)
g_ptr_array_unref (ainfo->wk_filenames);
if (ainfo->filenames != NULL)
@@ -1965,6 +1989,8 @@ run_file_chooser_cancel (ArchiveInfo *ainfo, GError *error, const char *reason)
gtk_widget_destroy (error_dialog);
}
+ web_view->priv->is_archiving = FALSE;
+ g_cancellable_reset (web_view->priv->archive_cancellable);
archive_info_free (ainfo);
}
@@ -1982,6 +2008,8 @@ run_file_chooser_complete (ArchiveInfo *ainfo)
web_view->priv->status_message = NULL;
g_object_notify (G_OBJECT (web_view), "status-message");
+ web_view->priv->is_archiving = FALSE;
+ g_cancellable_reset (web_view->priv->archive_cancellable);
archive_info_free (ainfo);
}
@@ -2002,12 +2030,14 @@ run_file_chooser_next (ArchiveInfo *ainfo, gboolean add_to_wk_filenames)
run_file_chooser_complete (ainfo);
} else {
GFile *file;
+ EphyWebView *web_view;
file = g_file_new_for_path (ainfo->filenames->data);
+ web_view = EPHY_WEB_VIEW (ainfo->info->web_view);
g_file_query_info_async (file,
G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
- ainfo->cancellable,
+ web_view->priv->archive_cancellable,
(GAsyncReadyCallback)file_query_info_cb,
ainfo);
}
@@ -2068,6 +2098,7 @@ file_query_info_cb (GFile *file,
GAsyncResult *res,
ArchiveInfo *ainfo)
{
+ EphyWebView *web_view;
GFileInfo *file_info;
GFileType file_type;
GError *error;
@@ -2082,6 +2113,12 @@ file_query_info_cb (GFile *file,
return;
}
+ web_view = EPHY_WEB_VIEW (ainfo->info->web_view);
+ if (g_cancellable_is_cancelled (web_view->priv->archive_cancellable)) {
+ run_file_chooser_cancel (ainfo, NULL, NULL);
+ return;
+ }
+
file_type = g_file_info_get_file_type (file_info);
if (file_type == G_FILE_TYPE_DIRECTORY) {
AutoarCreate *arcreate;
@@ -2104,7 +2141,7 @@ file_query_info_cb (GFile *file,
g_signal_connect (arcreate, "error",
G_CALLBACK (archive_error_cb), ainfo);
- autoar_create_start_async (arcreate, ainfo->cancellable);
+ autoar_create_start_async (arcreate, web_view->priv->archive_cancellable);
g_object_unref (arcreate);
g_free (output);
g_free (tmp);
@@ -2119,21 +2156,27 @@ run_file_chooser_response_cb (GtkFileChooser *file_chooser,
int response_id,
FileChooserInfo *info)
{
+ EphyWebView *web_view;
+ GCancellable *cancellable;
+
+ web_view = EPHY_WEB_VIEW (info->web_view);
+ cancellable = web_view->priv->archive_cancellable;
+ g_cancellable_reset (cancellable);
+
if (response_id == GTK_RESPONSE_OK || response_id == EPHY_RESPONSE_SELECT) {
ArchiveInfo *ainfo;
- GCancellable *cancellable;
GSList *filenames, *iter;
int format, filter;
int c;
+ web_view->priv->is_archiving = TRUE;
+
filenames = gtk_file_chooser_get_filenames (file_chooser);
autoar_gtk_format_filter_simple_get (info->format, &format, &filter);
for (iter = filenames, c = 0; iter != NULL; iter = iter->next, c++);
- cancellable = g_cancellable_new ();
ainfo = g_new (ArchiveInfo, 1);
ainfo->info = info;
- ainfo->cancellable = g_object_ref (cancellable);
ainfo->wk_filenames = g_ptr_array_new_with_free_func (g_free);
ainfo->filenames = NULL;
ainfo->dest = NULL;
@@ -2203,8 +2246,6 @@ run_file_chooser_response_cb (GtkFileChooser *file_chooser,
ainfo);
}
- g_object_unref (cancellable);
-
} else {
webkit_file_chooser_request_cancel (info->request);
file_chooser_info_free (info);
@@ -2463,6 +2504,7 @@ ephy_web_view_init (EphyWebView *web_view)
priv = web_view->priv = EPHY_WEB_VIEW_GET_PRIVATE (web_view);
priv->is_blank = TRUE;
+ priv->is_archiving = TRUE;
priv->title = g_strdup (EMPTY_PAGE);
priv->document_type = EPHY_WEB_VIEW_DOCUMENT_HTML;
priv->security_level = EPHY_WEB_VIEW_STATE_IS_UNKNOWN;
@@ -2477,6 +2519,7 @@ ephy_web_view_init (EphyWebView *web_view)
priv->history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ()));
priv->history_service_cancellable = g_cancellable_new ();
+ priv->archive_cancellable = g_cancellable_new ();
g_signal_connect (priv->history_service,
"cleared", G_CALLBACK (ephy_web_view_history_cleared_cb),
@@ -2805,6 +2848,32 @@ ephy_web_view_get_is_blank (EphyWebView *view)
}
/**
+ * ephy_web_view_get_is_archiving:
+ * @view: an #EphyWebView
+ *
+ * Returns whether the @view is archiving files.
+ *
+ * Return value: %TRUE if the @view is archiving files.
+ **/
+gboolean
+ephy_web_view_get_is_archiving (EphyWebView *view)
+{
+ return view->priv->is_archiving;
+}
+
+/**
+ * ephy_web_view_cancel_archiving:
+ * @view: an #EphyWebView
+ *
+ * Cancel the @view's archive work.
+ **/
+void
+ephy_web_view_cancel_archiving (EphyWebView *view)
+{
+ g_cancellable_cancel (view->priv->archive_cancellable);
+}
+
+/**
* ephy_web_view_get_address:
* @view: an #EphyWebView
*
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index a24f96269..d22ac4586 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -144,6 +144,8 @@ const char * ephy_web_view_get_typed_address (EphyWebView
void ephy_web_view_set_typed_address (EphyWebView *view,
const char *address);
gboolean ephy_web_view_get_is_blank (EphyWebView *view);
+gboolean ephy_web_view_get_is_archiving (EphyWebView *view);
+void ephy_web_view_cancel_archiving (EphyWebView *view);
gboolean ephy_web_view_has_modified_forms (EphyWebView *view);
void ephy_web_view_get_security_level (EphyWebView *view,
EphyWebViewSecurityLevel *level,
diff --git a/src/ephy-window.c b/src/ephy-window.c
index bec411398..c05734ab8 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -168,6 +168,8 @@ static const GtkActionEntry ephy_menu_entries [] = {
{ "ViewEncoding", NULL, N_("Text _Encoding"), NULL, NULL, NULL },
{ "ViewPageSource", NULL, N_("_Page Source"), "<control>U", NULL,
G_CALLBACK (window_cmd_view_page_source) },
+ { "ViewStopArchiving", NULL, N_("Stop _Archiving"), NULL, NULL,
+ G_CALLBACK (window_cmd_view_stop_archiving) },
/* Bookmarks actions. */
@@ -1994,6 +1996,8 @@ populate_context_menu (WebKitWebView *web_view,
priv->toolbar_action_group, "NavigationForward");
add_action_to_context_menu (context_menu,
priv->action_group, "ViewReload");
+ add_action_to_context_menu (context_menu,
+ priv->action_group, "ViewStopArchiving");
webkit_context_menu_append (context_menu,
webkit_context_menu_item_new_separator ());
add_action_to_context_menu (context_menu,
diff --git a/src/resources/epiphany-ui.xml b/src/resources/epiphany-ui.xml
index 976dddce4..14906bcd3 100644
--- a/src/resources/epiphany-ui.xml
+++ b/src/resources/epiphany-ui.xml
@@ -23,6 +23,7 @@
<menuitem name="GoBackDP" action="NavigationBack"/>
<menuitem name="GoForwardDP" action="NavigationForward"/>
<menuitem name="GoReloadDP" action="ViewReload"/>
+ <menuitem name="StopArchivingDP" action="ViewStopArchiving"/>
<separator />
<menuitem name="EditCopyDP" action="EditCopy"/>
<separator />
diff --git a/src/window-commands.c b/src/window-commands.c
index 9f61c27e4..d3cf07fe1 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1659,6 +1659,21 @@ window_cmd_view_page_source (GtkAction *action,
}
}
+void
+window_cmd_view_stop_archiving (GtkAction *action,
+ EphyWindow *window)
+{
+ EphyEmbed *embed;
+ EphyWebView *view;
+
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (EPHY_IS_EMBED (embed));
+ view = ephy_embed_get_web_view (embed);
+
+ ephy_web_view_cancel_archiving (view);
+}
+
#define ABOUT_GROUP "About"
void
diff --git a/src/window-commands.h b/src/window-commands.h
index abf5865d6..885c4034b 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -84,6 +84,8 @@ void window_cmd_view_zoom_normal (GtkAction *action,
EphyWindow *window);
void window_cmd_view_page_source (GtkAction *action,
EphyWindow *window);
+void window_cmd_view_stop_archiving (GtkAction *action,
+ EphyWindow *window);
void window_cmd_help_about (GtkAction *action,
GtkWidget *window);
void window_cmd_tabs_next (GtkAction *action,
span>/+38 * - Update to 20140310sunpoet2014-03-142-3/+3 * - Update to 20140309sunpoet2014-03-112-3/+8 * Convert p* to USES=zipbapt2014-03-113-3/+3 * KDE/FreeBSD team presents KDE SC 4.12.3 and KDE Workspace 4.11.7!makc2014-03-054-19/+16 * Update to 4.1.5. It is partially based on the following PR.jkim2014-02-262-8/+8 * - Bump PORTREVISION after KDE4_PREFIX changemakc2014-02-182-0/+2 * KDE/FreeBSD team presents KDE SC 4.12.2 and KDE Workspace 4.11.6!makc2014-02-188-211/+245 * - Update to 20140211sunpoet2014-02-152-3/+3 * - Reassign lioux' ports to the heaptabthorpe2014-02-151-1/+1 * - Update to 20140125sunpoet2014-02-062-3/+3 * - Update gimp-help ports to 2.8.1. Polish translation has been removed, newmakc2014-02-012-0/+16 * Remove ispell which is deprecated for long, consider using aspell instead or ...bapt2014-01-296-78/+0 * Support stagebapt2014-01-282-2/+0 * - Update to 20140102sunpoet2014-01-122-3/+3 * - Update to 20131229sunpoet2013-12-302-3/+3 * - Update Calligra Suite to 2.7.5.avilla2013-12-176-11/+8 * - Update to 20131125sunpoet2013-12-092-3/+3 * - use STAGEDIRdinoex2013-11-292-2/+0 * - Update to 20131118sunpoet2013-11-212-3/+3 * - Use single space after WWW:sunpoet2013-11-181-1/+1 * - Update to 20110813sunpoet2013-11-172-3/+3 * Stagifybapt2013-11-041-5/+4 * Stagifybapt2013-11-041-6/+5 * - Update to 4.0.6.jkim2013-10-264-10/+8 * - Update to 20131006sunpoet2013-10-122-3/+3 * - Update to 20131001sunpoet2013-10-042-6/+5 * Add NO_STAGE all over the place in preparation for the staging support (cat: ...bapt2013-09-2117-36/+22 * - Update to 20130902sunpoet2013-09-092-3/+3 * Update to 4.0.5.jkim2013-08-232-8/+8 * KDE3 and QT3 expired on 2013-07-01, remove these ports.rene2013-07-279-4811/+0 * Hopefully finish fixing the l10n ports after r322586 and r322618.rakuco2013-07-101-0/+1 * Fix INDEX by really fixing the kde4-l10n portsbapt2013-07-101-0/+1 * KDE4 l10n fixes.rakuco2013-07-104-6/+2 * Update the KDE Software Compilation to 4.10.5.rakuco2013-07-052-4/+4 * Update to KDE SC 4.10.4, proudly presented by the KDE on FreeBSD team.rakuco2013-07-032-4/+4 * Update to 4.0.4.jkim2013-06-202-8/+8 * KDE/FreeBSD team presents KDE SC 4.10.3 ports!makc2013-05-194-8/+5 * Update to 4.0.3.jkim2013-05-102-8/+8 * Rely on bsdtar to autodetermine the format of the distfiles when possiblebapt2013-04-291-4/+0 * - Convert USE_GETTEXT to USES (part 2)ak2013-04-242-2/+2 * - Update to 20130331sunpoet2013-04-192-4/+5 * Update to 4.0.2.jkim2013-04-172-8/+8 * - Update Calligra and l10n ports to 2.6.2:avilla2013-03-304-14/+10