Added a 'activate' signal, which is emitted when the 'Enter' key is pressed

This commit is contained in:
Neil J. Patel 2007-06-07 21:23:07 +00:00
parent 42ebf073bd
commit 3649b4734b
4 changed files with 41 additions and 0 deletions

View File

@ -1,3 +1,14 @@
2007-06-07 Neil J. Patel <njp@o-hand.com>
* 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 <ebassi@openedhand.com>
* clutter/*: Move documentation from the templates into the

View File

@ -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:

View File

@ -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);

View File

@ -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;