[gegl/soc-2012-editor] Added gegl-gtk as a dependency and moved thumbnail preview to the sidebar which now uses a GeglGtkVi



commit 640f09eaa7434ed632fe9446f690f0b54558f9da
Author: Isaac Wagner <isaacbw src gnome org>
Date:   Mon Jul 2 13:44:09 2012 -0400

    Added gegl-gtk as a dependency and moved thumbnail preview to the sidebar which now uses a GeglGtkView widget (much cleaner now)

 bin/editor/build               |    3 +-
 bin/editor/gegl-editor-layer.c |   21 +++++--
 bin/editor/gegl-editor-layer.h |    1 +
 bin/editor/gegl-editor.c       |   12 +---
 bin/editor/gegl-node-widget.c  |  123 +++++++++++++++++++++-------------------
 5 files changed, 87 insertions(+), 73 deletions(-)
---
diff --git a/bin/editor/build b/bin/editor/build
index 10d996c..b216128 100755
--- a/bin/editor/build
+++ b/bin/editor/build
@@ -1 +1,2 @@
-gcc -g gegl-editor.c gegl-editor-layer.c gegl-node-widget.c -o editor `pkg-config --cflags --libs gtk+-2.0 gthread-2.0` -I/usr/local/include/gegl-0.2/ -I/usr/local/include/babl-0.1/ -lgegl-0.2 -lbabl-0.1
\ No newline at end of file
+export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/
+gcc -g gegl-editor.c gegl-editor-layer.c gegl-node-widget.c -o editor `pkg-config --cflags --libs glib-2.0 gtk+-2.0 gthread-2.0 gegl-0.2 babl gegl-gtk2-0.1`
\ No newline at end of file
diff --git a/bin/editor/gegl-editor-layer.c b/bin/editor/gegl-editor-layer.c
index a669d90..84d5fec 100644
--- a/bin/editor/gegl-editor-layer.c
+++ b/bin/editor/gegl-editor-layer.c
@@ -4,6 +4,7 @@
 
 void refresh_images(GeglEditorLayer* self)
 {
+  return;
   GSList*	pair = self->pairs;
   for(;pair != NULL; pair = pair->next)
     {
@@ -181,7 +182,7 @@ gint layer_node_selected (gpointer host, GeglEditor* editor, gint node_id)
 
   g_assert(node != NULL);
 
-  g_print("selected: %s\n", gegl_node_get_operation(node));
+  //  g_print("selected: %s\n", gegl_node_get_operation(node));
 
   guint		n_props;
   GParamSpec**	properties = gegl_operation_list_properties(gegl_node_get_operation(node), &n_props);
@@ -189,8 +190,9 @@ gint layer_node_selected (gpointer host, GeglEditor* editor, gint node_id)
   //TODO: only create enough columns for the properties which will actually be included (i.e. ignoring GeglBuffer props)
   GtkTable	*prop_table = gtk_table_new(2, n_props, FALSE);
 
-  int	i;
-  for(i = 0; i < n_props; i++)
+  int i;
+  int d;
+  for(d = 0, i = 0; i < n_props; i++, d++)
     {
       GParamSpec*	prop = properties[i];
       GType		type = prop->value_type;
@@ -227,6 +229,7 @@ gint layer_node_selected (gpointer host, GeglEditor* editor, gint node_id)
 
       if(type == GEGL_TYPE_BUFFER) {
 	skip = TRUE;
+	d--;
       } else if( type == GEGL_TYPE_COLOR) {
 	skip = TRUE;
 	GtkWidget *color_button = gtk_button_new_with_label("Select");
@@ -238,8 +241,8 @@ gint layer_node_selected (gpointer host, GeglEditor* editor, gint node_id)
 
 	g_signal_connect(color_button, "clicked", (GCallback)select_color, info);
 
-	gtk_table_attach(prop_table, name_label, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 1, 1);
-	gtk_table_attach(prop_table, color_button, 1, 2, i, i+1, GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 1, 1);
+	gtk_table_attach(prop_table, name_label, 0, 1, d, d+1, GTK_FILL, GTK_FILL, 1, 1);
+	gtk_table_attach(prop_table, color_button, 1, 2, d, d+1, GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 1, 1);
       }
 
       if(!skip)
@@ -259,7 +262,13 @@ gint layer_node_selected (gpointer host, GeglEditor* editor, gint node_id)
 	}
     }
 
-  gtk_box_pack_start(GTK_BOX(self->prop_box), prop_table, TRUE, TRUE, 0);
+  //  gegl_node_process(node);
+  GtkWidget *gtk_view = gegl_gtk_view_new_for_node(node);
+  gtk_widget_show(gtk_view);
+
+  gtk_box_pack_start(GTK_BOX(self->prop_box), prop_table, FALSE, TRUE, 0);
+  gtk_box_pack_start(GTK_BOX(self->prop_box), gtk_view, TRUE, TRUE, 10);
+
   gtk_widget_show_all(self->prop_box);
 }
 
diff --git a/bin/editor/gegl-editor-layer.h b/bin/editor/gegl-editor-layer.h
index e34356d..560edd8 100644
--- a/bin/editor/gegl-editor-layer.h
+++ b/bin/editor/gegl-editor-layer.h
@@ -4,6 +4,7 @@
 #include	"gegl-node-widget.h"
 #include <gegl.h>
 #include <glib.h>
+#include <gegl-gtk.h>
 
 /*	
 Creates and removes connections between pads in the Gegl graph 
diff --git a/bin/editor/gegl-editor.c b/bin/editor/gegl-editor.c
index 01416e1..a955383 100644
--- a/bin/editor/gegl-editor.c
+++ b/bin/editor/gegl-editor.c
@@ -25,7 +25,6 @@ void menuitem_activated(GtkMenuItem* item, gpointer data)
   GtkWidget *add_op_dialog = gtk_dialog_new_with_buttons("AddOperation", GTK_WINDOW(window), 
 							 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
 							 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT, NULL);
-
   /////list/////////
   GtkListStore *store = gtk_list_store_new(1, G_TYPE_STRING);
 
@@ -100,8 +99,7 @@ main (gint	  argc,
 
 ////////////////////////////////////////////CREATE OPERATION DIALOG///////////////////////////////////////////
 
-  GtkWidget* property_box = gtk_vbox_new(TRUE, 0);
-
+  GtkWidget* property_box = gtk_vbox_new(FALSE, 0);
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   
@@ -166,22 +164,20 @@ main (gint	  argc,
   gtk_widget_show_all(window);
 
 ////////////////////////////////////////////GEGL OPERATIONS///////////////////////////////////////////////////
-
-  GeglNode	*display = gegl_node_create_child (gegl, "gegl:display");
+  //GeglNode	*display = gegl_node_create_child (gegl, "gegl:display");
   GeglNode	*over = gegl_node_new_child (gegl, "operation", "gegl:over", NULL);
   GeglNode	*load = gegl_node_new_child(gegl, "operation", "gegl:load", "path", "./surfer.png", NULL);
   GeglNode	*text = gegl_node_new_child(gegl, "operation", "gegl:text", "size", 10.0, "color", 
 					    gegl_color_new("rgb(1.0,1.0,1.0)"), "text", "Hello world!", NULL);
 
-  layer_add_gegl_node(layer, display);
+  //layer_add_gegl_node(layer, display);
   layer_add_gegl_node(layer, over);
   layer_add_gegl_node(layer, load);
   layer_add_gegl_node(layer, text);
 
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-  g_print("%s\n", G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(load)));
-  
   gtk_main();
   
   return 0;
diff --git a/bin/editor/gegl-node-widget.c b/bin/editor/gegl-node-widget.c
index e3f0c44..6f1c4a2 100644
--- a/bin/editor/gegl-node-widget.c
+++ b/bin/editor/gegl-node-widget.c
@@ -407,83 +407,90 @@ gegl_editor_button_press(GtkWidget* widget, GdkEventButton* event)
 {
   GeglEditor*	editor = GEGL_EDITOR(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;
-  editor->dy		  = editor->py;
+  if(event->type == GDK_BUTTON_PRESS)
+    {
+      //TODO: check which mouse button was pressed rather than assume it was the left button
+      editor->left_mouse_down = TRUE;
+      editor->dx		  = editor->px;
+      editor->dy		  = editor->py;
 
-  editor->dragged_pad = NULL;
+      editor->dragged_pad = NULL;
 
-  NodePad*	pad = get_pad_at(editor->px, editor->py, editor);
-  if(pad)
-    {
-      editor->dragged_pad	  = pad;
-      if(pad->connected) {
-	if(editor->disconnectedPads != NULL)
-	  editor->disconnectedPads(editor->host, editor, 
-				pad->connected->node->id, pad->connected->name,
-				pad->node->id, pad->name);
-	pad->connected->connected = NULL;
-	pad->connected		  = NULL;
-      }
-    } //end if(pad)
-  else
-    {
-      EditorNode*	node  = editor->first_node;
-      EditorNode*	focus = NULL;
-      for(;node != NULL; node = node->next)
+      NodePad*	pad = get_pad_at(editor->px, editor->py, editor);
+      if(pad)
+	{
+	  editor->dragged_pad	  = pad;
+	  if(pad->connected) {
+	    if(editor->disconnectedPads != NULL)
+	      editor->disconnectedPads(editor->host, editor, 
+				       pad->connected->node->id, pad->connected->name,
+				       pad->node->id, pad->name);
+	    pad->connected->connected = NULL;
+	    pad->connected		  = NULL;
+	  }
+	} //end if(pad)
+      else
 	{
-	  if(editor->px > node->x && editor->px < node->x+node->width	&&
-	     editor->py > node->y && editor->py < node->y+node->height) 
+	  EditorNode*	node  = editor->first_node;
+	  EditorNode*	focus = NULL;
+	  for(;node != NULL; node = node->next)
 	    {
-	      if(editor->px >= node->x+node->width-15	&&
-		 editor->py >= node->y+node->height-15+(node->x+node->width-editor->px))
+	      if(editor->px > node->x && editor->px < node->x+node->width	&&
+		 editor->py > node->y && editor->py < node->y+node->height) 
 		{
-		  editor->dragged_node = NULL;
-		  editor->resized_node = node;
+		  if(editor->px >= node->x+node->width-15	&&
+		     editor->py >= node->y+node->height-15+(node->x+node->width-editor->px))
+		    {
+		      editor->dragged_node = NULL;
+		      editor->resized_node = node;
+		    }
+		  else
+		    {
+		      editor->resized_node = NULL;
+		      editor->dragged_node = node;
+		    }
+
+		  focus = node;
 		}
-	      else
-		{
-		  editor->resized_node = NULL;
-		  editor->dragged_node = node;
-		}
-
-	      focus = node;
 	    }
-	}
 
-      if(focus && focus->next != NULL)
-	{
-	  if(focus == editor->first_node)
+	  if(focus && focus->next != NULL)
 	    {
-	      editor->first_node = focus->next;
-	    }
+	      if(focus == editor->first_node)
+		{
+		  editor->first_node = focus->next;
+		}
 
-	  EditorNode*	node = editor->first_node;
+	      EditorNode*	node = editor->first_node;
 
-	  for(;node->next != NULL; node = node->next)
-	    {
-	      if(node->next == focus)
+	      for(;node->next != NULL; node = node->next)
 		{
-		  node->next = focus->next;
+		  if(node->next == focus)
+		    {
+		      node->next = focus->next;
+		    }
 		}
-	    }
 
-	  focus->next = NULL;
-	  node->next  = focus;
-	}
+	      focus->next = NULL;
+	      node->next  = focus;
+	    }
 
-      if(editor->selected_node && editor->selected_node != focus && editor->nodeDeselected)
-	editor->nodeDeselected(editor->host, editor, editor->selected_node->id);
+	  if(editor->selected_node && editor->selected_node != focus && editor->nodeDeselected)
+	    editor->nodeDeselected(editor->host, editor, editor->selected_node->id);
 
-      if(focus && editor->selected_node != focus && editor->nodeSelected)
-	editor->nodeSelected(editor->host, editor, focus->id);
+	  if(focus && editor->selected_node != focus && editor->nodeSelected)
+	    editor->nodeSelected(editor->host, editor, focus->id);
 
-      editor->selected_node = focus;
+	  editor->selected_node = focus;
 
-    }//end if(pad) else
+	}//end if(pad) else
 
-  gtk_widget_queue_draw(widget);
+      gtk_widget_queue_draw(widget);
+    }
+  else if(event->type == GDK_2BUTTON_PRESS)
+    {
+      g_print("Double click!\n");
+    }
 
   return FALSE;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]