[Pkg-privacy-commits] [nautilus-wipe] 13/37: Add support for pausing operations
Intrigeri
intrigeri at moszumanska.debian.org
Wed Dec 7 18:46:02 UTC 2016
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to branch master
in repository nautilus-wipe.
commit 9a776f0187cd56928645e6e58f79672af1c5837b
Author: Colomban Wendling <ban at herbesfolles.org>
Date: Mon Jul 18 18:16:01 2016 +0200
Add support for pausing operations
---
help/C/index.docbook | 3 +
nautilus-wipe/nw-operation-manager.c | 11 +++
nautilus-wipe/nw-progress-dialog.c | 146 +++++++++++++++++++++++++++++++++++
nautilus-wipe/nw-progress-dialog.h | 12 ++-
po/POTFILES.in | 1 +
5 files changed, 172 insertions(+), 1 deletion(-)
diff --git a/help/C/index.docbook b/help/C/index.docbook
index bbeecb8..ac89c5b 100644
--- a/help/C/index.docbook
+++ b/help/C/index.docbook
@@ -391,6 +391,9 @@
but not deleted or big junk files.
</para>
<para>
+ It is also possible to pause, and later resume, the operation.
+ </para>
+ <para>
When the wipe is finished, a dialog should inform you of the
success of the deletion.
</para>
diff --git a/nautilus-wipe/nw-operation-manager.c b/nautilus-wipe/nw-operation-manager.c
index 32cf070..288a57c 100644
--- a/nautilus-wipe/nw-operation-manager.c
+++ b/nautilus-wipe/nw-operation-manager.c
@@ -522,6 +522,16 @@ progress_dialog_response_handler (GtkDialog *dialog,
}
break;
+ case NW_PROGRESS_DIALOG_RESPONSE_PAUSE:
+ nw_progress_dialog_set_paused (NW_PROGRESS_DIALOG (dialog),
+ gsd_async_operation_pause (GSD_ASYNC_OPERATION (opdata->operation)));
+ break;
+
+ case NW_PROGRESS_DIALOG_RESPONSE_RESUME:
+ nw_progress_dialog_set_paused (NW_PROGRESS_DIALOG (dialog),
+ ! gsd_async_operation_resume (GSD_ASYNC_OPERATION (opdata->operation)));
+ break;
+
default:
break;
}
@@ -582,6 +592,7 @@ nw_operation_manager_run (GtkWindow *parent,
opdata->progress_dialog = NW_PROGRESS_DIALOG (nw_progress_dialog_new (opdata->window, 0,
"%s", progress_dialog_text));
gtk_window_set_title (GTK_WINDOW (opdata->progress_dialog), title);
+ nw_progress_dialog_set_has_pause_button (opdata->progress_dialog, TRUE);
nw_progress_dialog_set_has_cancel_button (opdata->progress_dialog, TRUE);
g_signal_connect (opdata->progress_dialog, "response",
G_CALLBACK (progress_dialog_response_handler), opdata);
diff --git a/nautilus-wipe/nw-progress-dialog.c b/nautilus-wipe/nw-progress-dialog.c
index 93c5536..f191042 100644
--- a/nautilus-wipe/nw-progress-dialog.c
+++ b/nautilus-wipe/nw-progress-dialog.c
@@ -19,10 +19,15 @@
*
*/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "nw-progress-dialog.h"
#include <stdarg.h>
#include <glib.h>
+#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include "nw-compat.h" /* for gtk_dialog_get_action_area(),
@@ -35,9 +40,12 @@ struct _NwProgressDialogPrivate {
GtkLabel *label;
GtkProgressBar *progress;
GtkWidget *cancel_button;
+ GtkWidget *pause_button;
+ GtkWidget *resume_button;
GtkWidget *close_button;
gboolean finished;
gboolean canceled;
+ gboolean paused;
gboolean auto_hide_action_area;
gint current_response;
};
@@ -48,6 +56,7 @@ enum
PROP_TEXT,
PROP_HAS_CANCEL_BUTTON,
PROP_HAS_CLOSE_BUTTON,
+ PROP_HAS_PAUSE_BUTTON,
PROP_AUTO_HIDE_ACTION_AREA
};
@@ -73,6 +82,10 @@ nw_progress_dialog_set_property (GObject *obj,
case PROP_HAS_CLOSE_BUTTON:
nw_progress_dialog_set_has_close_button (self, g_value_get_boolean (value));
break;
+
+ case PROP_HAS_PAUSE_BUTTON:
+ nw_progress_dialog_set_has_pause_button (self, g_value_get_boolean (value));
+ break;
case PROP_AUTO_HIDE_ACTION_AREA:
nw_progress_dialog_set_auto_hide_action_area (self, g_value_get_boolean (value));
@@ -104,6 +117,10 @@ nw_progress_dialog_get_property (GObject *obj,
g_value_set_boolean (value, nw_progress_dialog_get_has_close_button (self));
break;
+ case PROP_HAS_PAUSE_BUTTON:
+ g_value_set_boolean (value, nw_progress_dialog_get_has_pause_button (self));
+ break;
+
case PROP_AUTO_HIDE_ACTION_AREA:
g_value_set_boolean (value, nw_progress_dialog_get_auto_hide_action_area (self));
break;
@@ -127,6 +144,18 @@ nw_progress_dialog_response (GtkDialog *dialog,
gtk_widget_set_sensitive (self->priv->close_button,
self->priv->finished || self->priv->canceled);
}
+ if (GTK_IS_WIDGET (self->priv->pause_button)) {
+ gtk_widget_set_sensitive (self->priv->pause_button,
+ ! self->priv->finished &&
+ ! self->priv->canceled &&
+ ! self->priv->paused);
+ }
+ if (GTK_IS_WIDGET (self->priv->resume_button)) {
+ gtk_widget_set_sensitive (self->priv->resume_button,
+ ! self->priv->finished &&
+ ! self->priv->canceled &&
+ self->priv->paused);
+ }
if (GTK_DIALOG_CLASS (nw_progress_dialog_parent_class)->response) {
GTK_DIALOG_CLASS (nw_progress_dialog_parent_class)->response (dialog, response_id);
@@ -185,8 +214,11 @@ nw_progress_dialog_init (NwProgressDialog *self)
self->priv->label = GTK_LABEL (gtk_label_new (""));
self->priv->close_button = NULL;
self->priv->cancel_button = NULL;
+ self->priv->pause_button = NULL;
+ self->priv->resume_button = NULL;
self->priv->finished = FALSE;
self->priv->canceled = FALSE;
+ self->priv->paused = FALSE;
self->priv->auto_hide_action_area = FALSE;
self->priv->current_response = GTK_RESPONSE_NONE;
@@ -260,6 +292,12 @@ nw_progress_dialog_class_init (NwProgressDialogClass *klass)
"Whether the dialog has a close button",
FALSE,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_HAS_PAUSE_BUTTON,
+ g_param_spec_boolean ("has-pause-button",
+ "Has pause button",
+ "Whether the dialog has a pause/resume button",
+ FALSE,
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_AUTO_HIDE_ACTION_AREA,
g_param_spec_boolean ("auto-hide-action-area",
"Auto hide action area",
@@ -528,6 +566,41 @@ nw_progress_dialog_is_canceled (NwProgressDialog *dialog)
return dialog->priv->canceled;
}
+void
+nw_progress_dialog_set_paused (NwProgressDialog *dialog,
+ gboolean paused)
+{
+ g_return_if_fail (NW_IS_PROGRESS_DIALOG (dialog));
+
+ if (dialog->priv->paused != !! paused) {
+ dialog->priv->paused = !! paused;
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ NW_PROGRESS_DIALOG_RESPONSE_PAUSE,
+ ! dialog->priv->paused);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ NW_PROGRESS_DIALOG_RESPONSE_RESUME,
+ dialog->priv->paused);
+ if (dialog->priv->pause_button) {
+ gtk_widget_set_visible (dialog->priv->pause_button, ! dialog->priv->paused);
+ }
+ if (dialog->priv->resume_button) {
+ gtk_widget_set_visible (dialog->priv->resume_button, dialog->priv->paused);
+ }
+ nw_progress_dialog_emit_response (dialog,
+ dialog->priv->paused
+ ? NW_PROGRESS_DIALOG_RESPONSE_PAUSE
+ : NW_PROGRESS_DIALOG_RESPONSE_RESUME);
+ }
+}
+
+gboolean
+nw_progress_dialog_get_paused (NwProgressDialog *dialog)
+{
+ g_return_val_if_fail (NW_IS_PROGRESS_DIALOG (dialog), FALSE);
+
+ return dialog->priv->paused;
+}
+
/**
* nw_progress_dialog_finish:
* @dialog: A #NwProgressDialog
@@ -548,6 +621,10 @@ nw_progress_dialog_finish (NwProgressDialog *dialog,
}
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL,
FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ NW_PROGRESS_DIALOG_RESPONSE_PAUSE, FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ NW_PROGRESS_DIALOG_RESPONSE_RESUME, FALSE);
nw_progress_dialog_emit_response (dialog,
NW_PROGRESS_DIALOG_RESPONSE_COMPLETE);
}
@@ -659,6 +736,75 @@ nw_progress_dialog_get_has_cancel_button (NwProgressDialog *dialog)
return dialog->priv->cancel_button != NULL;
}
+/**
+ * nw_progress_dialog_set_has_pause_button:
+ * @dialog: A #NwProgressDialog
+ * @has_cancel_button: Whether the dialog should have a pause button.
+ *
+ * Sets whether the dialog has a pause button. Enabling pause button at the
+ * progress dialog level enable automatic sensitivity update of the button
+ * according to the current operation state.
+ */
+void
+nw_progress_dialog_set_has_pause_button (NwProgressDialog *dialog,
+ gboolean has_pause_button)
+{
+ g_return_if_fail (NW_IS_PROGRESS_DIALOG (dialog));
+
+ if (has_pause_button != (dialog->priv->pause_button != NULL)) {
+ if (has_pause_button) {
+ dialog->priv->pause_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("Pause"),
+ NW_PROGRESS_DIALOG_RESPONSE_PAUSE);
+ gtk_button_set_image (GTK_BUTTON (dialog->priv->pause_button),
+ gtk_image_new_from_stock (GTK_STOCK_MEDIA_PAUSE,
+ GTK_ICON_SIZE_BUTTON));
+ dialog->priv->resume_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("Resume"),
+ NW_PROGRESS_DIALOG_RESPONSE_RESUME);
+ gtk_button_set_image (GTK_BUTTON (dialog->priv->resume_button),
+ gtk_image_new_from_stock (GTK_STOCK_MEDIA_PLAY,
+ GTK_ICON_SIZE_BUTTON));
+ gtk_widget_set_sensitive (dialog->priv->pause_button,
+ ! dialog->priv->canceled &&
+ ! dialog->priv->finished &&
+ ! dialog->priv->paused);
+ gtk_widget_set_visible (dialog->priv->pause_button,
+ ! dialog->priv->canceled &&
+ ! dialog->priv->finished &&
+ ! dialog->priv->paused);
+ gtk_widget_set_sensitive (dialog->priv->resume_button,
+ ! dialog->priv->canceled &&
+ ! dialog->priv->finished &&
+ dialog->priv->paused);
+ gtk_widget_set_visible (dialog->priv->resume_button,
+ ! dialog->priv->canceled &&
+ ! dialog->priv->finished &&
+ dialog->priv->paused);
+ } else {
+ gtk_widget_destroy (dialog->priv->pause_button);
+ dialog->priv->pause_button = NULL;
+ gtk_widget_destroy (dialog->priv->resume_button);
+ dialog->priv->resume_button = NULL;
+ }
+ update_action_area_visibility (dialog, FALSE);
+ }
+}
+
+/**
+ * nw_progress_dialog_get_has_pause_button:
+ * @dialog: A #NwProgressDialog
+ *
+ * Returns: Whether @dialog has a pause button.
+ */
+gboolean
+nw_progress_dialog_get_has_pause_button (NwProgressDialog *dialog)
+{
+ g_return_val_if_fail (NW_IS_PROGRESS_DIALOG (dialog), FALSE);
+
+ return dialog->priv->pause_button != NULL;
+}
+
void
nw_progress_dialog_set_auto_hide_action_area (NwProgressDialog *dialog,
gboolean auto_hide)
diff --git a/nautilus-wipe/nw-progress-dialog.h b/nautilus-wipe/nw-progress-dialog.h
index 05dbef4..fab8bfd 100644
--- a/nautilus-wipe/nw-progress-dialog.h
+++ b/nautilus-wipe/nw-progress-dialog.h
@@ -50,7 +50,11 @@ struct _NwProgressDialogClass {
GtkDialogClass parent_class;
};
-#define NW_PROGRESS_DIALOG_RESPONSE_COMPLETE 1
+enum {
+ NW_PROGRESS_DIALOG_RESPONSE_COMPLETE = 1,
+ NW_PROGRESS_DIALOG_RESPONSE_PAUSE,
+ NW_PROGRESS_DIALOG_RESPONSE_RESUME
+};
GType nw_progress_dialog_get_type (void) G_GNUC_CONST;
@@ -76,6 +80,9 @@ void nw_progress_dialog_set_text (NwProgressDialog *
const gchar *nw_progress_dialog_get_text (NwProgressDialog *dialog);
void nw_progress_dialog_cancel (NwProgressDialog *dialog);
gboolean nw_progress_dialog_is_canceled (NwProgressDialog *dialog);
+void nw_progress_dialog_set_paused (NwProgressDialog *dialog,
+ gboolean paused);
+gboolean nw_progress_dialog_get_paused (NwProgressDialog *dialog);
void nw_progress_dialog_finish (NwProgressDialog *dialog,
gboolean success);
gboolean nw_progress_dialog_is_finished (NwProgressDialog *dialog);
@@ -85,6 +92,9 @@ gboolean nw_progress_dialog_get_has_close_button (NwProgressDialog *
void nw_progress_dialog_set_has_cancel_button (NwProgressDialog *dialog,
gboolean has_close_button);
gboolean nw_progress_dialog_get_has_cancel_button (NwProgressDialog *dialog);
+void nw_progress_dialog_set_has_pause_button (NwProgressDialog *dialog,
+ gboolean has_pause_button);
+gboolean nw_progress_dialog_get_has_pause_button (NwProgressDialog *dialog);
void nw_progress_dialog_set_auto_hide_action_area (NwProgressDialog *dialog,
gboolean auto_hide);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 58a77a4..3897d49 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,3 +3,4 @@ nautilus-wipe/nw-delete-operation.c
nautilus-wipe/nw-fill-operation.c
nautilus-wipe/nw-extension.c
nautilus-wipe/nw-operation-manager.c
+nautilus-wipe/nw-progress-dialog.c
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/nautilus-wipe.git
More information about the Pkg-privacy-commits
mailing list