[gegl/soc-2012-editor: 34/36] Deleting a node in the editor now properly removes it from the gegl graph as well
- From: Isaac Wagner <isaacbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/soc-2012-editor: 34/36] Deleting a node in the editor now properly removes it from the gegl graph as well
- Date: Thu, 5 Jul 2012 21:59:04 +0000 (UTC)
commit 71e95d79274df24e2e2caf10a185ab1a5319d32b
Author: Isaac Wagner <isaacbw src gnome org>
Date: Thu Jul 5 15:27:14 2012 -0400
Deleting a node in the editor now properly removes it from the gegl graph as well
bin/editor/gegl-editor-layer.c | 26 ++++++++++++++++++++++++++
bin/editor/gegl-editor-layer.h | 3 +++
bin/editor/gegl-node-widget.c | 5 +++--
3 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/bin/editor/gegl-editor-layer.c b/bin/editor/gegl-editor-layer.c
index d74dd10..75bc39e 100644
--- a/bin/editor/gegl-editor-layer.c
+++ b/bin/editor/gegl-editor-layer.c
@@ -49,6 +49,7 @@ void refresh_images(GeglEditorLayer* self)
gint layer_node_removed (gpointer host, GeglEditor* editor, gint node_id)
{
+ g_print("remove\n");
GeglEditorLayer* self = (GeglEditorLayer*)host;
//TODO: put this in its own function
GeglNode* node = NULL;
@@ -65,6 +66,7 @@ gint layer_node_removed (gpointer host, GeglEditor* editor, gint node_id)
g_assert(node != NULL);
+ gegl_node_disconnect_all_pads(node);
gegl_node_disconnect(self->gegl, node);
}
@@ -360,3 +362,27 @@ layer_add_gegl_node(GeglEditorLayer* layer, GeglNode* node)
new_pair->id = id;
layer->pairs = g_slist_append(layer->pairs, new_pair);
}
+
+void
+gegl_node_disconnect_all_pads(GeglNode* node)
+{
+ GSList* list;
+ for(list = gegl_node_get_pads(node); list != NULL; list = list->next)
+ {
+ if(gegl_pad_is_input(list->data)) //disconnect inputs
+ {
+ gegl_node_disconnect(node, gegl_pad_get_name(list->data));
+ }
+ else if(gegl_pad_is_output(list->data)) //disconnect outputs
+ {
+ GeglNode** nodes;
+ gchar** pads;
+ gint num_consumers = gegl_node_get_consumers(node, gegl_pad_get_name(list->data), &nodes, &pads);
+ gint i;
+ for(i = 0; i < num_consumers; i++)
+ {
+ gegl_node_disconnect(nodes[i], pads[i]);
+ }
+ }
+ }
+}
diff --git a/bin/editor/gegl-editor-layer.h b/bin/editor/gegl-editor-layer.h
index 560edd8..682c89f 100644
--- a/bin/editor/gegl-editor-layer.h
+++ b/bin/editor/gegl-editor-layer.h
@@ -36,4 +36,7 @@ void layer_add_gegl_node(GeglEditorLayer* layer, GeglNode* node);
//void layer_remove_gegl_node(GeglNode* node);
//link, unlink
+void
+gegl_node_disconnect_all_pads(GeglNode* node);
+
#endif
diff --git a/bin/editor/gegl-node-widget.c b/bin/editor/gegl-node-widget.c
index d746a31..4b4b87f 100644
--- a/bin/editor/gegl-node-widget.c
+++ b/bin/editor/gegl-node-widget.c
@@ -424,7 +424,7 @@ static gboolean
gegl_editor_key_press (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
GeglEditor* editor = GEGL_EDITOR(widget);
- //print_node_list(editor);
+ print_node_list(editor);
if(event->keyval == GDK_KEY_Delete && editor->selected_node != NULL)
{
//todo: put in its own function
@@ -446,7 +446,7 @@ gegl_editor_key_press (GtkWidget *widget, GdkEventKey *event, gpointer user_data
}
editor->selected_node = NULL;
}
- //print_node_list(editor);
+ print_node_list(editor);
gtk_widget_queue_draw(widget);
}
@@ -457,6 +457,7 @@ gegl_editor_button_press(GtkWidget* widget, GdkEventButton* event)
if(event->type == GDK_BUTTON_PRESS)
{
+ gtk_widget_grab_focus(widget);
//TODO: check which mouse button was pressed rather than assume it was the left button
editor->left_mouse_down = TRUE;
editor->dx = editor->px;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]