From 3649b4734b6c69d563c954d23d015552ac7ea9cc Mon Sep 17 00:00:00 2001 From: "Neil J. Patel" Date: Thu, 7 Jun 2007 21:23:07 +0000 Subject: [PATCH] Added a 'activate' signal, which is emitted when the 'Enter' key is pressed --- ChangeLog | 11 +++++++++++ clutter/clutter-entry.c | 21 +++++++++++++++++++++ clutter/clutter-entry.h | 1 + examples/test-entry.c | 8 ++++++++ 4 files changed, 41 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9bcac35..a642c25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-06-07 Neil J. Patel + + * clutter/clutter-entry.c: (clutter_entry_class_init), + (clutter_entry_handle_key_event): + * clutter/clutter-entry.h: + Added an 'activated' signal, whihc is emitted when the 'Enter' key is + pressed. + + * examples/test-entry.c: (on_entry_activated), (main): + Added a test handler for the activated signal. + 2007-06-07 Emmanuele Bassi * clutter/*: Move documentation from the templates into the diff --git a/clutter/clutter-entry.c b/clutter/clutter-entry.c index 5a5bd0c..43ce7e3 100644 --- a/clutter/clutter-entry.c +++ b/clutter/clutter-entry.c @@ -72,6 +72,7 @@ enum { TEXT_CHANGED, CURSOR_EVENT, + ACTIVATE, LAST_SIGNAL }; @@ -580,6 +581,24 @@ clutter_entry_class_init (ClutterEntryClass *klass) clutter_marshal_VOID__BOXED, G_TYPE_NONE, 1, CLUTTER_TYPE_GEOMETRY | G_SIGNAL_TYPE_STATIC_SCOPE); + + /** + * ClutterEntry::activate: + * @entry: the actor which received the event + * + * The ::cursor-event signal is emitted each time the netry is 'activated' + * by the user, normally by pressing the 'Enter' key. This will only be + * emitted when your are adding text to the entry via + * #clutter_entry_handle_key_event. + */ + entry_signals[ACTIVATE] = + g_signal_new ("activate", + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ClutterEntryClass, activate), + NULL, NULL, + clutter_marshal_VOID__VOID, + G_TYPE_NONE, 0); g_type_class_add_private (gobject_class, sizeof (ClutterEntryPrivate)); } @@ -1070,6 +1089,8 @@ clutter_entry_handle_key_event (ClutterEntry *entry, ClutterKeyEvent *kev) case CLUTTER_Return: case CLUTTER_KP_Enter: case CLUTTER_ISO_Enter: + g_signal_emit (G_OBJECT (entry), entry_signals[ACTIVATE], 0); + break; case CLUTTER_Escape: case CLUTTER_Up: case CLUTTER_KP_Up: diff --git a/clutter/clutter-entry.h b/clutter/clutter-entry.h index b3870c2..3d6898a 100644 --- a/clutter/clutter-entry.h +++ b/clutter/clutter-entry.h @@ -81,6 +81,7 @@ struct _ClutterEntryClass void (* text_changed) (ClutterEntry *entry); void (* cursor_event) (ClutterEntry *entry, ClutterGeometry *geometry); + void (* activate) (ClutterEntry *entry); /* padding for future */ void (*_clutter_entry_1) (void); diff --git a/examples/test-entry.c b/examples/test-entry.c index d0109c8..3c23275 100644 --- a/examples/test-entry.c +++ b/examples/test-entry.c @@ -17,6 +17,12 @@ on_key_release_cb (ClutterStage *stage, ClutterEvent *event, ClutterEntry *entry } } +static void +on_entry_activated (ClutterEntry *entry, gpointer null) +{ + g_print ("Activated: %s\n", clutter_entry_get_text (entry)); +} + int main (int argc, char *argv[]) { @@ -55,6 +61,8 @@ main (int argc, char *argv[]) g_signal_connect (entry, "text-changed", G_CALLBACK (on_entry_text_changed), NULL); */ + g_signal_connect (entry, "activate", + G_CALLBACK (on_entry_activated), NULL); clutter_main(); return 0; -- 2.7.4