Commit 9f7fd9ea authored by Georges Basile Stavracas Neto's avatar Georges Basile Stavracas Neto Committed by Corentin Noël
Browse files

marker-layer: Implement shumate_marker_layer_remove_all()

Implement it, and add a corresponding test too.
parent 68a9a45f
......@@ -464,26 +464,20 @@ shumate_marker_layer_add_marker (ShumateMarkerLayer *layer,
shumate_marker_layer_remove_all (ShumateMarkerLayer *layer)
//ClutterActorIter iter;
//ClutterActor *child;
GtkWidget *child;
g_return_if_fail (SHUMATE_IS_MARKER_LAYER (layer));
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (layer));
while (clutter_actor_iter_next (&iter, &child))
child = gtk_widget_get_first_child (GTK_WIDGET (layer));
while (child)
GObject *marker = G_OBJECT (child);
g_signal_handlers_disconnect_by_func (marker,
G_CALLBACK (marker_position_notify), layer);
GtkWidget *next = gtk_widget_get_next_sibling (child);
g_signal_handlers_disconnect_by_func (marker,
G_CALLBACK (marker_move_by_cb), layer);
g_signal_handlers_disconnect_by_data (child, layer);
gtk_widget_unparent (child);
clutter_actor_iter_remove (&iter);
child = next;
......@@ -59,6 +59,31 @@ test_marker_layer_remove_marker (void)
g_object_unref (viewport);
static void
test_marker_layer_remove_all_markers (void)
ShumateMarkerLayer *marker_layer;
ShumateViewport *viewport;
int i;
viewport = shumate_viewport_new ();
marker_layer = shumate_marker_layer_new (viewport);
for (i = 0; i < 100; i++)
ShumateMarker *point;
point = shumate_point_new ();
shumate_marker_layer_add_marker (marker_layer, point);
g_assert_true (gtk_widget_get_parent (GTK_WIDGET (point)) == GTK_WIDGET (marker_layer));
shumate_marker_layer_remove_all (marker_layer);
g_assert_null (gtk_widget_get_first_child (GTK_WIDGET (marker_layer)));
g_object_unref (viewport);
main (int argc, char *argv[])
......@@ -68,6 +93,7 @@ main (int argc, char *argv[])
g_test_add_func ("/marker-layer/new", test_marker_layer_new);
g_test_add_func ("/marker-layer/add-marker", test_marker_layer_add_marker);
g_test_add_func ("/marker-layer/remove-marker", test_marker_layer_remove_marker);
g_test_add_func ("/marker-layer/remove-all-markers", test_marker_layer_remove_all_markers);
return g_test_run ();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment