From 71f2e05b9be805d34e564d7b6e0996083a056c79 Mon Sep 17 00:00:00 2001 From: "Neil J. Patel" Date: Fri, 1 Jun 2007 11:50:18 +0000 Subject: [PATCH] Add a text-changed signal to the entry --- ChangeLog | 8 ++++++++ clutter/clutter-entry.c | 26 ++++++++++++++++++++++++++ clutter/clutter-entry.h | 6 +++++- examples/test-entry.c | 12 +++++++++++- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c598798a0..42c14988c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-06-01 Neil J. Patel + + * 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 * clutter/clutter-effect.h: diff --git a/clutter/clutter-entry.c b/clutter/clutter-entry.c index 694b3afa0..b7ac5a8e6 100644 --- a/clutter/clutter-entry.c +++ b/clutter/clutter-entry.c @@ -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); } diff --git a/clutter/clutter-entry.h b/clutter/clutter-entry.h index af3938834..48f8411c1 100644 --- a/clutter/clutter-entry.h +++ b/clutter/clutter-entry.h @@ -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); diff --git a/examples/test-entry.c b/examples/test-entry.c index bcf689f47..707e780ca 100644 --- a/examples/test-entry.c +++ b/examples/test-entry.c @@ -1,5 +1,11 @@ #include +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;