app: connect to the background curves' "dirty" signal in GimpCurveView
and make sure curves are not added twice to the background list. Also warn when trying to remove a non-existent background curve.
This commit is contained in:
@ -244,12 +244,8 @@ gimp_curve_view_dispose (GObject *object)
|
|||||||
|
|
||||||
gimp_curve_view_set_curve (view, NULL);
|
gimp_curve_view_set_curve (view, NULL);
|
||||||
|
|
||||||
while (view->bg_curves)
|
if (view->bg_curves)
|
||||||
{
|
gimp_curve_view_remove_all_backgrounds (view);
|
||||||
BGCurve *bg = view->bg_curves->data;
|
|
||||||
|
|
||||||
gimp_curve_view_remove_background (view, bg->curve);
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
@ -1134,17 +1130,29 @@ gimp_curve_view_add_background (GimpCurveView *view,
|
|||||||
GimpCurve *curve,
|
GimpCurve *curve,
|
||||||
const GimpRGB *color)
|
const GimpRGB *color)
|
||||||
{
|
{
|
||||||
|
GList *list;
|
||||||
BGCurve *bg;
|
BGCurve *bg;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
|
g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
|
||||||
g_return_if_fail (GIMP_IS_CURVE (curve));
|
g_return_if_fail (GIMP_IS_CURVE (curve));
|
||||||
g_return_if_fail (color != NULL);
|
g_return_if_fail (color != NULL);
|
||||||
|
|
||||||
|
for (list = view->bg_curves; list; list = g_list_next (list))
|
||||||
|
{
|
||||||
|
bg = list->data;
|
||||||
|
|
||||||
|
g_return_if_fail (curve != bg->curve);
|
||||||
|
}
|
||||||
|
|
||||||
bg = g_slice_new0 (BGCurve);
|
bg = g_slice_new0 (BGCurve);
|
||||||
|
|
||||||
bg->curve = g_object_ref (curve);
|
bg->curve = g_object_ref (curve);
|
||||||
bg->color = *color;
|
bg->color = *color;
|
||||||
|
|
||||||
|
g_signal_connect (bg->curve, "dirty",
|
||||||
|
G_CALLBACK (gimp_curve_view_curve_dirty),
|
||||||
|
view);
|
||||||
|
|
||||||
view->bg_curves = g_list_append (view->bg_curves, bg);
|
view->bg_curves = g_list_append (view->bg_curves, bg);
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (view));
|
gtk_widget_queue_draw (GTK_WIDGET (view));
|
||||||
@ -1165,6 +1173,9 @@ gimp_curve_view_remove_background (GimpCurveView *view,
|
|||||||
|
|
||||||
if (bg->curve == curve)
|
if (bg->curve == curve)
|
||||||
{
|
{
|
||||||
|
g_signal_handlers_disconnect_by_func (bg->curve,
|
||||||
|
gimp_curve_view_curve_dirty,
|
||||||
|
view);
|
||||||
g_object_unref (bg->curve);
|
g_object_unref (bg->curve);
|
||||||
|
|
||||||
view->bg_curves = g_list_remove (view->bg_curves, bg);
|
view->bg_curves = g_list_remove (view->bg_curves, bg);
|
||||||
@ -1176,6 +1187,9 @@ gimp_curve_view_remove_background (GimpCurveView *view,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! list)
|
||||||
|
g_return_if_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1187,6 +1201,9 @@ gimp_curve_view_remove_all_backgrounds (GimpCurveView *view)
|
|||||||
{
|
{
|
||||||
BGCurve *bg = view->bg_curves->data;
|
BGCurve *bg = view->bg_curves->data;
|
||||||
|
|
||||||
|
g_signal_handlers_disconnect_by_func (bg->curve,
|
||||||
|
gimp_curve_view_curve_dirty,
|
||||||
|
view);
|
||||||
g_object_unref (bg->curve);
|
g_object_unref (bg->curve);
|
||||||
|
|
||||||
view->bg_curves = g_list_remove (view->bg_curves, bg);
|
view->bg_curves = g_list_remove (view->bg_curves, bg);
|
||||||
|
Reference in New Issue
Block a user