diff --git a/ChangeLog b/ChangeLog index 9bcac352e..a642c2574 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 5a5bd0cdb..43ce7e35f 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 b3870c221..3d6898ade 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 d0109c8cd..3c232751d 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;