From e60714be29895ac385f494e30bd1573f30b8adea Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Tue, 26 Jun 2007 12:18:23 +0000 Subject: [PATCH] 2007-06-26 Xan Lopez * src/hildon-date-editor.c: (hildon_date_editor_keypress): * src/hildon-time-editor.c: (hildon_time_editor_entry_keypress): Move all focus crazyness to the rc files. This depends on gtk+2.0 >= 2.10.12-osso6 because the move-focus signal needs to be available in GtkWidget. --- ChangeLog | 9 +++++ src/hildon-date-editor.c | 29 ++------------- src/hildon-time-editor.c | 88 +++++++++------------------------------------- 3 files changed, 28 insertions(+), 98 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f6c933..d41f994 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-06-26 Xan Lopez + + * src/hildon-date-editor.c: (hildon_date_editor_keypress): + * src/hildon-time-editor.c: (hildon_time_editor_entry_keypress): + + Move all focus crazyness to the rc files. This depends on gtk+2.0 >= + 2.10.12-osso6 because the move-focus signal needs to be available in + GtkWidget. + 2007-06-25 Michael Dominic Kostrzewa * examples/Makefile.am: diff --git a/src/hildon-date-editor.c b/src/hildon-date-editor.c index 7c5b146..a3087f5 100644 --- a/src/hildon-date-editor.c +++ b/src/hildon-date-editor.c @@ -1129,46 +1129,21 @@ hildon_date_editor_keypress (GtkWidget *widget, { HildonDateEditor *ed; HildonDateEditorPrivate *priv; - gint pos; - gboolean r; g_assert (HILDON_IS_DATE_EDITOR (data)); g_assert (GTK_IS_ENTRY (widget)); ed = HILDON_DATE_EDITOR (data); - priv = HILDON_DATE_EDITOR_GET_PRIVATE (ed); - pos = gtk_editable_get_position (GTK_EDITABLE (widget)); - g_assert (priv); - - /* Show error message in case the key pressed is not allowed - (only digits and control characters are allowed )*/ - if (!g_unichar_isdigit (event->keyval) && ! (event->keyval & 0xF000)) { - g_signal_emit (ed, date_editor_signals[DATE_ERROR], 0, HILDON_DATE_TIME_ERROR_INVALID_CHAR, &r); - return TRUE; - } switch (event->keyval) { - case GDK_Left: - if (pos == 0) { - (void) gtk_widget_child_focus (GTK_WIDGET (data), GTK_DIR_LEFT); - return TRUE; - } - break; - - case GDK_Right: - if (pos >= g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (widget)), -1)) { - (void) gtk_widget_child_focus (GTK_WIDGET (data), GTK_DIR_RIGHT); - return TRUE; - } - break; case GDK_Return: case GDK_ISO_Enter: /* Ignore return value, since we want to handle event at all times. otherwise vkb would popup when the keyrepeat starts. */ - (void) hildon_date_editor_set_calendar_icon_state (ed, TRUE); + hildon_date_editor_set_calendar_icon_state (ed, TRUE); return TRUE; - case GDK_Escape: + priv = HILDON_DATE_EDITOR_GET_PRIVATE (ed); priv->skip_validation = TRUE; break; default: diff --git a/src/hildon-time-editor.c b/src/hildon-time-editor.c index 702d5aa..48fd5c5 100644 --- a/src/hildon-time-editor.c +++ b/src/hildon-time-editor.c @@ -224,10 +224,10 @@ static void hildon_time_editor_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static gboolean -hildon_time_editor_entry_keypress (GtkWidget *widget, - GdkEventKey *event, - gpointer data); +static gboolean +hildon_time_editor_entry_keypress (GtkEntry *entry, + GdkEventKey* event, + gpointer user_data); static gboolean hildon_time_editor_check_locale (HildonTimeEditor *editor); @@ -1776,76 +1776,22 @@ hildon_time_editor_size_allocate (GtkWidget *widget, gtk_widget_size_allocate (priv->sec_label, &alloc); } -static gboolean -hildon_time_editor_entry_keypress (GtkWidget *widget, - GdkEventKey *event, - gpointer data) +static gboolean +hildon_time_editor_entry_keypress (GtkEntry *entry, + GdkEventKey *event, + gpointer data) { - HildonTimeEditor *editor; - HildonTimeEditorPrivate *priv; - gint cursor_pos; - gboolean r; - - g_assert (GTK_IS_ENTRY (widget)); - g_assert (event != NULL); - g_assert (HILDON_IS_TIME_EDITOR (data)); - - editor = HILDON_TIME_EDITOR (data); - priv = HILDON_TIME_EDITOR_GET_PRIVATE (editor); - g_assert (priv); - cursor_pos = gtk_editable_get_position (GTK_EDITABLE (widget)); - - /* Show error message in case the key pressed is not allowed - (only digits and control characters are allowed )*/ - if (!g_unichar_isdigit (event->keyval) && ! (event->keyval & 0xF000)) { - g_signal_emit (editor, time_editor_signals[TIME_ERROR], 0, HILDON_DATE_TIME_ERROR_INVALID_CHAR, &r); - hildon_banner_show_information (widget, NULL, c_("ckct_ib_illegal_character")); - return TRUE; - } - - switch (event->keyval) + switch (event->keyval) { - case GDK_Return: - /* Return key popups up time picker dialog. Visually it looks as if - the time picker icon was clicked. Before opening the time picker - the fields are first validated and fixed. */ - - /* hildon_time_editor_validate (editor, FALSE); - hildon_gtk_button_set_depressed (GTK_BUTTON (priv->iconbutton), TRUE); - hildon_time_editor_icon_clicked (widget, data); - hildon_gtk_button_set_depressed (GTK_BUTTON (priv->iconbutton), FALSE); - - FIXME The above code used to be here before the consolidation that removed the - _set_depressed crap. However, I think this code had NO EFFECT anyways, since - there is no expose event after the _set functions. So I'm just cutting it out. - Another story would be to actually fix it... */ - - hildon_time_editor_icon_clicked (widget, data); - return TRUE; - - case GDK_Left: - /* left arrow pressed in the entry. If we are on first position, try to - move to the previous field. */ - if (cursor_pos == 0) { - (void) gtk_widget_child_focus (GTK_WIDGET (editor), GTK_DIR_LEFT); - return TRUE; - } - break; - - case GDK_Right: - /* right arrow pressed in the entry. If we are on last position, try to - move to the next field. */ - if (cursor_pos >= g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (widget)), -1)) { - (void) gtk_widget_child_focus (GTK_WIDGET (editor), GTK_DIR_RIGHT); - return TRUE; - } - break; - - default: - break; - }; + case GDK_Return: + case GDK_ISO_Enter: + hildon_time_editor_icon_clicked (entry, data); + return TRUE; + default: + return FALSE; + } - return FALSE; + g_assert_not_reached (); } static void -- 1.7.9.5