[gimp/gimp-2-10] app: add GimpToolPolygon::change-complete signal
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add GimpToolPolygon::change-complete signal
- Date: Thu, 25 Apr 2019 10:11:05 +0000 (UTC)
commit 67f44f3e34a4fe185798da4ca48878c115ad4219
Author: Ell <ell_se yahoo com>
Date: Thu Apr 25 04:25:31 2019 -0400
app: add GimpToolPolygon::change-complete signal
... which is emitted when finishing a change to the polygon,
similarly to GimpToolRectangle::change-complete.
(cherry picked from commit 134ff92fe0b30466dfdd846207682c4474f7041d)
app/display/gimptoolpolygon.c | 37 ++++++++++++++++++++++++++++++++++++-
app/display/gimptoolpolygon.h | 3 +++
2 files changed, 39 insertions(+), 1 deletion(-)
---
diff --git a/app/display/gimptoolpolygon.c b/app/display/gimptoolpolygon.c
index 017e713cae..4f2c20b518 100644
--- a/app/display/gimptoolpolygon.c
+++ b/app/display/gimptoolpolygon.c
@@ -37,6 +37,7 @@
#include "display-types.h"
#include "core/gimp-utils.h"
+#include "core/gimpmarshal.h"
#include "widgets/gimpwidgets-utils.h"
@@ -57,6 +58,13 @@
#define NO_CLICK_TIME_AVAILABLE 0
+enum
+{
+ CHANGE_COMPLETE,
+ LAST_SIGNAL
+};
+
+
struct _GimpToolPolygonPrivate
{
/* Index of grabbed segment index. */
@@ -185,6 +193,8 @@ static gboolean gimp_tool_polygon_get_cursor (GimpToolWidget *widget
GimpToolCursorType *tool_cursor,
GimpCursorModifier *modifier);
+static void gimp_tool_polygon_change_complete (GimpToolPolygon *polygon);
+
static gint gimp_tool_polygon_get_segment_index (GimpToolPolygon *polygon,
const GimpCoords *coords);
@@ -194,6 +204,8 @@ G_DEFINE_TYPE_WITH_PRIVATE (GimpToolPolygon, gimp_tool_polygon,
#define parent_class gimp_tool_polygon_parent_class
+static guint polygon_signals[LAST_SIGNAL] = { 0, };
+
static const GimpVector2 vector2_zero = { 0.0, 0.0 };
@@ -219,6 +231,15 @@ gimp_tool_polygon_class_init (GimpToolPolygonClass *klass)
widget_class->motion_modifier = gimp_tool_polygon_motion_modifier;
widget_class->hover_modifier = gimp_tool_polygon_hover_modifier;
widget_class->get_cursor = gimp_tool_polygon_get_cursor;
+
+ polygon_signals[CHANGE_COMPLETE] =
+ g_signal_new ("change-complete",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GimpToolPolygonClass, change_complete),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
@@ -1131,6 +1152,8 @@ gimp_tool_polygon_button_release (GimpToolWidget *widget,
gimp_tool_polygon_revert_to_saved_state (polygon);
priv->polygon_closed = TRUE;
+
+ gimp_tool_polygon_change_complete (polygon);
}
priv->last_click_time = time;
@@ -1152,6 +1175,8 @@ gimp_tool_polygon_button_release (GimpToolWidget *widget,
{
priv->polygon_closed = TRUE;
}
+
+ gimp_tool_polygon_change_complete (polygon);
break;
case GIMP_BUTTON_RELEASE_CANCEL:
@@ -1301,12 +1326,16 @@ static gboolean
gimp_tool_polygon_key_press (GimpToolWidget *widget,
GdkEventKey *kevent)
{
- GimpToolPolygon *polygon = GIMP_TOOL_POLYGON (widget);
+ GimpToolPolygon *polygon = GIMP_TOOL_POLYGON (widget);
+ GimpToolPolygonPrivate *priv = polygon->private;
switch (kevent->keyval)
{
case GDK_KEY_BackSpace:
gimp_tool_polygon_remove_last_segment (polygon);
+
+ if (priv->n_segment_indices > 0)
+ gimp_tool_polygon_change_complete (polygon);
return TRUE;
default:
@@ -1382,6 +1411,12 @@ gimp_tool_polygon_get_cursor (GimpToolWidget *widget,
return FALSE;
}
+static void
+gimp_tool_polygon_change_complete (GimpToolPolygon *polygon)
+{
+ g_signal_emit (polygon, polygon_signals[CHANGE_COMPLETE], 0);
+}
+
static gint
gimp_tool_polygon_get_segment_index (GimpToolPolygon *polygon,
const GimpCoords *coords)
diff --git a/app/display/gimptoolpolygon.h b/app/display/gimptoolpolygon.h
index d7b7eb193d..fa3560a17f 100644
--- a/app/display/gimptoolpolygon.h
+++ b/app/display/gimptoolpolygon.h
@@ -47,6 +47,9 @@ struct _GimpToolPolygon
struct _GimpToolPolygonClass
{
GimpToolWidgetClass parent_class;
+
+ /* signals */
+ void (* change_complete) (GimpToolPolygon *polygon);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]