[maemo-commits] [maemo-commits] r12475 - in projects/haf/trunk/hildon-1: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Jun 26 15:18:29 EEST 2007
Author: xan
Date: 2007-06-26 15:18:23 +0300 (Tue, 26 Jun 2007)
New Revision: 12475

Modified:
   projects/haf/trunk/hildon-1/ChangeLog
   projects/haf/trunk/hildon-1/src/hildon-date-editor.c
   projects/haf/trunk/hildon-1/src/hildon-time-editor.c
Log:
2007-06-26  Xan Lopez  <xan at nokia.com>

	* 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.


Modified: projects/haf/trunk/hildon-1/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-1/ChangeLog	2007-06-26 12:17:01 UTC (rev 12474)
+++ projects/haf/trunk/hildon-1/ChangeLog	2007-06-26 12:18:23 UTC (rev 12475)
@@ -1,3 +1,12 @@
+2007-06-26  Xan Lopez  <xan at nokia.com>
+
+	* 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  <michael.kostrzewa at nokia.com> 
 
 	* examples/Makefile.am:

Modified: projects/haf/trunk/hildon-1/src/hildon-date-editor.c
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-date-editor.c	2007-06-26 12:17:01 UTC (rev 12474)
+++ projects/haf/trunk/hildon-1/src/hildon-date-editor.c	2007-06-26 12:18:23 UTC (rev 12475)
@@ -1129,46 +1129,21 @@
 {
     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:

Modified: projects/haf/trunk/hildon-1/src/hildon-time-editor.c
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-time-editor.c	2007-06-26 12:17:01 UTC (rev 12474)
+++ projects/haf/trunk/hildon-1/src/hildon-time-editor.c	2007-06-26 12:18:23 UTC (rev 12475)
@@ -224,10 +224,10 @@
 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 @@
     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)
+    {
+    case GDK_Return:
+    case GDK_ISO_Enter:
+      hildon_time_editor_icon_clicked (entry, data);
+      return TRUE;
+    default:
+      return FALSE;
     }
 
-    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;
-    };
-
-    return FALSE;
+  g_assert_not_reached ();
 }
 
 static void


More information about the maemo-commits mailing list