[gegl-edit] *Fixed "Delete" menu item to property disconnect and delete gegl node as well as graph-gtk node *Add
- From: Isaac Wagner <isaacbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl-edit] *Fixed "Delete" menu item to property disconnect and delete gegl node as well as graph-gtk node *Add
- Date: Wed, 8 Aug 2012 19:58:28 +0000 (UTC)
commit ac5cf821c691f73ca38f4f4fbd8a6a7fe5c9ddac
Author: Isaac Wagner <isaacbw src gnome org>
Date: Wed Aug 8 15:57:45 2012 -0400
*Fixed "Delete" menu item to property disconnect and delete gegl node as well as graph-gtk node
*Added functionality to "Disconnect" menu item
gegl-edit/gegl-edit.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
gegl-edit/menubar.ui | 29 +++++++++++-----------
2 files changed, 78 insertions(+), 14 deletions(-)
---
diff --git a/gegl-edit/gegl-edit.c b/gegl-edit/gegl-edit.c
index e2f14ad..c20df30 100644
--- a/gegl-edit/gegl-edit.c
+++ b/gegl-edit/gegl-edit.c
@@ -35,6 +35,8 @@ static void load_graph(GraphGtkView *view, GeglNode *node);
static void update_images(GraphGtkView *view);
static void update_bg_image(GraphGtkView *view);
+static void gegl_node_disconnect_all_pads(GeglNode* node);
+
//Undocumented gegl functions
GSList *gegl_node_get_input_pads(GeglNode*);
GSList *gegl_node_get_pads(GeglNode *self);
@@ -229,6 +231,31 @@ nodes_disconnected(GraphGtkView *view, GraphGtkNode *from, const gchar* output,
//////////Gtk+ callbacks//////////
+G_MODULE_EXPORT void activated_disconnect(GtkMenuItem *menuitem, gpointer user_data)
+{
+ CallbackData *data = user_data;
+ GraphGtkView *view = g_queue_peek_head(data->view_stack);
+ gtk_widget_queue_draw(GTK_WIDGET(view));
+
+ if(view->selected_nodes)
+ {
+ GraphGtkNode *node = view->selected_nodes->data;
+
+ gegl_node_disconnect_all_pads(node->user_data);
+
+ GList *pad;
+ for(pad = graph_gtk_node_get_input_pads(node); pad != NULL; pad = pad->next)
+ {
+ graph_gtk_pad_disconnect((GraphGtkPad*)(pad->data));
+ }
+
+ for(pad = graph_gtk_node_get_output_pads(node); pad != NULL; pad = pad->next)
+ {
+ graph_gtk_pad_disconnect((GraphGtkPad*)(pad->data));
+ }
+ }
+}
+
G_MODULE_EXPORT void activated_arrange(GtkMenuItem *menuitem, gpointer user_data)
{
CallbackData *data = user_data;
@@ -485,6 +512,18 @@ G_MODULE_EXPORT void activated_save(GtkMenuItem *menuitem, gpointer user_data)
G_MODULE_EXPORT void activated_delete(GtkMenuItem *menuitem, gpointer user_data)
{
CallbackData *data = user_data;
+
+ GraphGtkView *view = g_queue_peek_head(data->view_stack);
+ GeglNode *graph = g_queue_peek_head(data->graph_stack);
+
+ GList *list;
+ for(list = view->selected_nodes; list != NULL; list = list->next)
+ {
+ GraphGtkNode *node = list->data;
+ gegl_node_disconnect_all_pads(node->user_data);
+ gegl_node_remove_child(graph, node);
+ }
+
graph_gtk_view_remove_selected_nodes(g_queue_peek_head(data->view_stack));
}
@@ -792,3 +831,27 @@ static void load_graph(GraphGtkView *view, GeglNode *gegl)
graph_gtk_view_arrange(view);
}
+
+static 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, (gchar*)gegl_pad_get_name(list->data));
+ }
+ else if(gegl_pad_is_output(list->data)) //disconnect outputs
+ {
+ GeglNode** nodes;
+ const 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/gegl-edit/menubar.ui b/gegl-edit/menubar.ui
index 7df9047..6317b89 100644
--- a/gegl-edit/menubar.ui
+++ b/gegl-edit/menubar.ui
@@ -1,6 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkImage" id="image6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0.47999998927116394</property>
+ <property name="stock">gtk-yes</property>
+ </object>
+ <object class="GtkImage" id="image7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0.49000000953674316</property>
+ <property name="yalign">0.49000000953674316</property>
+ <property name="stock">gtk-yes</property>
+ </object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -29,19 +42,6 @@
<property name="can_focus">False</property>
<property name="stock">gtk-cancel</property>
</object>
- <object class="GtkImage" id="image6">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0.47999998927116394</property>
- <property name="stock">gtk-yes</property>
- </object>
- <object class="GtkImage" id="image7">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0.49000000953674316</property>
- <property name="yalign">0.49000000953674316</property>
- <property name="stock">gtk-yes</property>
- </object>
<object class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -173,12 +173,13 @@
</object>
</child>
<child>
- <object class="GtkMenuItem" id="imagemenuitem5">
+ <object class="GtkMenuItem" id="disconnect">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Disconnect</property>
<property name="use_underline">True</property>
+ <signal name="activate" handler="activated_disconnect" swapped="no"/>
</object>
</child>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]