Add a text-changed signal to the entry
authorNeil J. Patel <njp@openedhand.com>
Fri, 1 Jun 2007 11:50:18 +0000 (11:50 +0000)
committerNeil J. Patel <njp@openedhand.com>
Fri, 1 Jun 2007 11:50:18 +0000 (11:50 +0000)
ChangeLog
clutter/clutter-entry.c
clutter/clutter-entry.h
examples/test-entry.c

index c598798..42c1498 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2007-06-01  Neil J. Patel  <njp@o-hand.com>
 
+       * clutter/clutter-entry.c: (clutter_entry_class_init),
+       (clutter_entry_set_text):
+       * clutter/clutter-entry.h:
+       * examples/test-entry.c: (on_entry_text_changed), (main):
+       Added a text-changed signal to the entry.
+
+2007-06-01  Neil J. Patel  <njp@o-hand.com>
+
        * clutter/clutter-effect.h:
        Removed extra G_END_DECLS outside the #endif
 
index 694b3af..b7ac5a8 100644 (file)
@@ -63,6 +63,15 @@ enum
   PROP_CURSOR
 };
 
+enum
+{
+  TEXT_CHANGED,
+  
+  LAST_SIGNAL
+};
+
+static guint entry_signals[LAST_SIGNAL] = { 0, };
+
 #define CLUTTER_ENTRY_GET_PRIVATE(obj) \
 (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_ENTRY, ClutterEntryPrivate))
 
@@ -391,6 +400,22 @@ clutter_entry_class_init (ClutterEntryClass *klass)
                        "Whether the input cursor is visible ",
                        TRUE,
                        CLUTTER_PARAM_READWRITE));
+                       
+
+  /**
+   * ClutterEntry::text-changed:
+   * @entry: the actor which received the event
+   *
+   * The ::text-changed signal is emitted after the @entrys text changes
+   */
+  entry_signals[TEXT_CHANGED] =
+    g_signal_new ("text-changed",
+                  G_TYPE_FROM_CLASS (gobject_class),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (ClutterEntryClass, text_changed),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
 
   g_type_class_add_private (gobject_class, sizeof (ClutterEntryPrivate));
 }
@@ -543,6 +568,7 @@ clutter_entry_set_text (ClutterEntry *entry,
     clutter_actor_queue_redraw (CLUTTER_ACTOR(entry));
 
   g_object_notify (G_OBJECT (entry), "text");
+  g_signal_emit (G_OBJECT (entry), entry_signals[TEXT_CHANGED], 0);  
   g_object_unref (entry);
 }
 
index af39388..48f8411 100644 (file)
@@ -73,7 +73,11 @@ struct _ClutterEntryClass
 {
   /*< private >*/
   ClutterActorClass parent_class;
-
+  
+  /* signals */
+  void     (* text_changed)         (ClutterEntry           *stage);
+  
+  /* padding for future */
   void (*_clutter_entry_1) (void);
   void (*_clutter_entry_2) (void);
   void (*_clutter_entry_3) (void);
index bcf689f..707e780 100644 (file)
@@ -1,5 +1,11 @@
 #include <clutter/clutter.h>
 
+static void
+on_entry_text_changed (ClutterEntry *entry)
+{
+  g_print ("Text changed\n");
+}
+
 void                
 on_key_release_cb (ClutterStage *stage, ClutterEvent *event, ClutterEntry *entry)
 {
@@ -42,7 +48,11 @@ main (int argc, char *argv[])
 
   g_signal_connect (stage, "key-release-event",
                    G_CALLBACK (on_key_release_cb), (gpointer)entry);
-
+  /*
+  g_signal_connect (entry, "text-changed",
+                    G_CALLBACK (on_entry_text_changed), NULL);
+  */
   clutter_main();
 
   return 0;