app: add "selection-changed" signal to GimpCruveView

... which gets emitted when the selected point changes.
This commit is contained in:
Ell 2019-04-19 07:29:40 -04:00
parent b6d829a1b2
commit 91ecca7e10
2 changed files with 37 additions and 5 deletions

View File

@ -56,6 +56,7 @@ enum
enum
{
SELECTION_CHANGED,
CUT_CLIPBOARD,
COPY_CLIPBOARD,
PASTE_CLIPBOARD,
@ -140,6 +141,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;
@ -179,6 +181,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),
@ -1389,9 +1400,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

View File

@ -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);