[gimp/gimp-2-10] app: add "selection-changed" signal to GimpCruveView
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add "selection-changed" signal to GimpCruveView
- Date: Fri, 19 Apr 2019 14:37:20 +0000 (UTC)
commit 9861ea8e8787c16bced8c06ed254860036ee52a9
Author: Ell <ell_se yahoo com>
Date: Fri Apr 19 07:29:40 2019 -0400
app: add "selection-changed" signal to GimpCruveView
... which gets emitted when the selected point changes.
(cherry picked from commit 91ecca7e10c0bcc18479984c91a190c1e08e49f9)
app/widgets/gimpcurveview.c | 31 +++++++++++++++++++++++++++++--
app/widgets/gimpcurveview.h | 11 ++++++++---
2 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/app/widgets/gimpcurveview.c b/app/widgets/gimpcurveview.c
index 5bfeb1e1c8..1e971569ac 100644
--- a/app/widgets/gimpcurveview.c
+++ b/app/widgets/gimpcurveview.c
@@ -56,6 +56,7 @@ enum
enum
{
+ SELECTION_CHANGED,
CUT_CLIPBOARD,
COPY_CLIPBOARD,
PASTE_CLIPBOARD,
@@ -141,6 +142,7 @@ gimp_curve_view_class_init (GimpCurveViewClass *klass)
widget_class->leave_notify_event = gimp_curve_view_leave_notify;
widget_class->key_press_event = gimp_curve_view_key_press;
+ klass->selection_changed = NULL;
klass->cut_clipboard = gimp_curve_view_cut_clipboard;
klass->copy_clipboard = gimp_curve_view_copy_clipboard;
klass->paste_clipboard = gimp_curve_view_paste_clipboard;
@@ -180,6 +182,15 @@ gimp_curve_view_class_init (GimpCurveViewClass *klass)
NULL,
GIMP_PARAM_READWRITE));
+ curve_view_signals[SELECTION_CHANGED] =
+ g_signal_new ("selection-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GimpCurveViewClass, selection_changed),
+ NULL, NULL,
+ gimp_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
curve_view_signals[CUT_CLIPBOARD] =
g_signal_new ("cut-clipboard",
G_TYPE_FROM_CLASS (klass),
@@ -1386,9 +1397,25 @@ gimp_curve_view_set_selected (GimpCurveView *view,
{
g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
- view->selected = selected;
+ if (selected != view->selected)
+ {
+ view->selected = selected;
- gtk_widget_queue_draw (GTK_WIDGET (view));
+ g_signal_emit (view, curve_view_signals[SELECTION_CHANGED], 0);
+
+ gtk_widget_queue_draw (GTK_WIDGET (view));
+ }
+}
+
+gint
+gimp_curve_view_get_selected (GimpCurveView *view)
+{
+ g_return_val_if_fail (GIMP_IS_CURVE_VIEW (view), -1);
+
+ if (view->curve && view->selected < gimp_curve_get_n_points (view->curve))
+ return view->selected;
+ else
+ return -1;
}
void
diff --git a/app/widgets/gimpcurveview.h b/app/widgets/gimpcurveview.h
index b41358441e..903c8ec393 100644
--- a/app/widgets/gimpcurveview.h
+++ b/app/widgets/gimpcurveview.h
@@ -81,9 +81,12 @@ struct _GimpCurveViewClass
{
GimpHistogramViewClass parent_class;
- void (* cut_clipboard) (GimpCurveView *view);
- void (* copy_clipboard) (GimpCurveView *view);
- void (* paste_clipboard) (GimpCurveView *view);
+ /* signals */
+ void (* selection_changed) (GimpCurveView *view);
+
+ void (* cut_clipboard) (GimpCurveView *view);
+ void (* copy_clipboard) (GimpCurveView *view);
+ void (* paste_clipboard) (GimpCurveView *view);
};
@@ -106,6 +109,8 @@ void gimp_curve_view_remove_all_backgrounds (GimpCurveView *view);
void gimp_curve_view_set_selected (GimpCurveView *view,
gint selected);
+gint gimp_curve_view_get_selected (GimpCurveView *view);
+
void gimp_curve_view_set_range_x (GimpCurveView *view,
gdouble min,
gdouble max);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]