gegl r2632 - in trunk: . bin



Author: ok
Date: Thu Oct 16 20:28:03 2008
New Revision: 2632
URL: http://svn.gnome.org/viewvc/gegl?rev=2632&view=rev

Log:
* bin/gegl-view.c: (gegl_view_class_init), (detected_event),
(button_press_event): added a detected event which is emitted when
the hit detection in GEGL detects that a mouse press starts at a
node in the composition, the implementation and semantics of what
is considered a hit is not well defined at the moment.
* bin/editor.c: (cb_detected_event), (create_window): print a debug
message about which node was hit.


Modified:
   trunk/ChangeLog
   trunk/bin/editor.c
   trunk/bin/gegl-view.c

Modified: trunk/bin/editor.c
==============================================================================
--- trunk/bin/editor.c	(original)
+++ trunk/bin/editor.c	Thu Oct 16 20:28:03 2008
@@ -74,6 +74,22 @@
 
 Editor editor;
 
+static void cb_detected_event (GeglView *view,
+                               GeglNode *node,
+                               gpointer  userdata)
+{
+  gchar *name;
+  gchar *operation;
+
+  gegl_node_get (node, "name", &name, "operation", &operation, NULL);
+  g_print ("%s: %p %s:%s(%p)\n", G_STRLOC, view, operation, name, node);
+
+  tree_editor_set_active (GTK_WIDGET (userdata), node);
+
+  g_free (name);
+  g_free (operation);
+}
+
 static void editor_set_gegl (GeglNode    *gegl);
 static GtkWidget *create_menubar (Editor *editor);
 static GtkWidget *
@@ -138,6 +154,9 @@
   gtk_widget_set_size_request (property_scroll, -1, 100);
   gtk_widget_set_size_request (view, 89, 55);
 
+  g_signal_connect (view, "detected",
+                    G_CALLBACK (cb_detected_event), editor->tree_editor);
+
   g_signal_connect (self, "delete-event",
                     G_CALLBACK (cb_window_delete_event), NULL);
 

Modified: trunk/bin/gegl-view.c
==============================================================================
--- trunk/bin/gegl-view.c	(original)
+++ trunk/bin/gegl-view.c	Thu Oct 16 20:28:03 2008
@@ -59,6 +59,15 @@
   GeglProcessor *processor;
 } GeglViewPrivate;
 
+enum
+{
+  DETECTED,
+  LAST_SIGNAL
+};
+
+
+static gint gegl_view_signals[LAST_SIGNAL] = {0, };
+
 
 G_DEFINE_TYPE (GeglView, gegl_view, GTK_TYPE_DRAWING_AREA)
 #define GEGL_VIEW_GET_PRIVATE(obj) \
@@ -125,6 +134,18 @@
                                                         G_TYPE_OBJECT,
                                                         G_PARAM_CONSTRUCT |
                                                         G_PARAM_READWRITE));
+
+ gegl_view_signals[DETECTED] =
+   g_signal_new ("detected",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+                  0,
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__OBJECT,
+                  G_TYPE_NONE, 1,
+                  GEGL_TYPE_NODE);
+
+
    g_type_class_add_private (klass, sizeof (GeglViewPrivate));
 }
 
@@ -272,6 +293,14 @@
     }
 }
 
+static void
+detected_event (GeglView *self,
+                GeglNode *node)
+{
+  g_signal_emit (self, gegl_view_signals[DETECTED], 0, node, NULL, NULL);
+}
+
+
 static gboolean
 button_press_event (GtkWidget      *widget,
                     GdkEventButton *event)
@@ -302,18 +331,7 @@
                                            (priv->y + event->y) / priv->scale);
     if (detected)
       {
-#if 0
-        gchar *name;
-        gchar *operation;
-
-        gegl_node_get (detected, "name", &name, "operation", &operation, NULL);
-        g_warning ("%s:%s(%p)", operation, name, detected);
-        g_free (name);
-        g_free (operation);
-#endif
-#if 0
-        tree_editor_set_active (editor.tree_editor, detected);
-#endif
+        detected_event (view, detected);
       }
   }
 



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