[gimp] app: implement progress canceling in GimpTool
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: implement progress canceling in GimpTool
- Date: Sun, 29 Jun 2014 22:16:45 +0000 (UTC)
commit 9ec2a3cdebffb697c08676d3d19fa79e8bd62841
Author: Michael Natterer <mitch gimp org>
Date: Mon Jun 30 00:00:15 2014 +0200
app: implement progress canceling in GimpTool
In gimp_tool_progress_start(), if the progress is cancelable, grab on
an invisible widget and emit the progress' "cancel" signal when Escape
is pressed.
app/tools/gimptool-progress.c | 32 ++++++++++++++++++++++++++++++++
app/tools/gimptool.h | 1 +
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimptool-progress.c b/app/tools/gimptool-progress.c
index 703356e..03d2d53 100644
--- a/app/tools/gimptool-progress.c
+++ b/app/tools/gimptool-progress.c
@@ -22,6 +22,7 @@
#include <gegl.h>
#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
#include "tools-types.h"
@@ -78,6 +79,19 @@ gimp_tool_progress_iface_init (GimpProgressInterface *iface)
/* private functions */
+static gboolean
+gimp_tool_progress_key_event (GtkWidget *widget,
+ const GdkEventKey *kevent,
+ GimpTool *tool)
+{
+ if (kevent->keyval == GDK_KEY_Escape)
+ {
+ gimp_progress_cancel (GIMP_PROGRESS (tool));
+ }
+
+ return TRUE;
+}
+
static GimpProgress *
gimp_tool_progress_start (GimpProgress *progress,
const gchar *message,
@@ -109,6 +123,17 @@ gimp_tool_progress_start (GimpProgress *progress,
tool->progress_display = tool->display;
+ if (cancelable)
+ {
+ tool->progress_grab_widget = gtk_invisible_new ();
+ gtk_widget_show (tool->progress_grab_widget);
+ gtk_grab_add (tool->progress_grab_widget);
+
+ g_signal_connect (tool->progress_grab_widget, "key-press-event",
+ G_CALLBACK (gimp_tool_progress_key_event),
+ tool);
+ }
+
return progress;
}
@@ -126,6 +151,13 @@ gimp_tool_progress_end (GimpProgress *progress)
tool->progress = NULL;
tool->progress_display = NULL;
+
+ if (tool->progress_grab_widget)
+ {
+ gtk_grab_remove (tool->progress_grab_widget);
+ gtk_widget_destroy (tool->progress_grab_widget);
+ tool->progress_grab_widget = NULL;
+ }
}
}
diff --git a/app/tools/gimptool.h b/app/tools/gimptool.h
index fbaebae..c8a9313 100644
--- a/app/tools/gimptool.h
+++ b/app/tools/gimptool.h
@@ -69,6 +69,7 @@ struct _GimpTool
/* on-canvas progress */
GimpCanvasItem *progress;
GimpDisplay *progress_display;
+ GtkWidget *progress_grab_widget;
};
struct _GimpToolClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]