A patch by Xan Lopez to fix focus handling in subclassed composite widgets. Fixes...
authorMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Fri, 24 Aug 2007 13:00:44 +0000 (13:00 +0000)
committerMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Fri, 24 Aug 2007 13:00:44 +0000 (13:00 +0000)
ChangeLog
src/hildon-date-editor.c
src/hildon-number-editor.c
src/hildon-private.c
src/hildon-private.h
src/hildon-time-editor.c
src/hildon-weekday-picker.c

index c50e1a8..ce37a41 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2007-08-24  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
 
+       * src/hildon-date-editor.c:
+       * src/hildon-number-editor.c:
+       * src/hildon-private.c:
+       * src/hildon-private.h:
+       * src/hildon-time-editor.c:
+       * src/hildon-weekday-picker.c: A patch by Xan Lopez to fix focus
+       handling in subclassed composite widgets. Fixes: NB#66628.
+
+2007-08-24  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
+
        * src/hildon-window.c: Removing extra gtk_main_iteration () processing
        from destroy_ callback as it introduces problems in async dbus signal
        handlers. Fixes NB#66673.
index dd0cc08..5f0e28e 100644 (file)
@@ -164,7 +164,9 @@ hildon_date_editor_size_allocate                (GtkWidget *widget,
 static void
 hildon_date_editor_size_request                 (GtkWidget *widget,
                                                  GtkRequisition *requisition);
-
+static gboolean
+hildon_date_editor_focus                        (GtkWidget *widget,
+                                                 GtkDirectionType direction);
 static gboolean
 hildon_date_editor_entry_select_all             (GtkWidget *widget);
 
@@ -234,7 +236,7 @@ hildon_date_editor_class_init                   (HildonDateEditorClass *editor_c
     gobject_class->get_property             = hildon_date_editor_get_property;
     widget_class->size_request              = hildon_date_editor_size_request;
     widget_class->size_allocate             = hildon_date_editor_size_allocate;
-    widget_class->focus                     = hildon_private_composite_focus;
+    widget_class->focus                     = hildon_date_editor_focus;
 
     container_class->forall                 = hildon_child_forall;
     GTK_OBJECT_CLASS(editor_class)->destroy = hildon_date_editor_destroy;
@@ -1332,6 +1334,23 @@ hildon_date_editor_size_allocate                (GtkWidget *widget,
     }
 }
 
+static gboolean
+hildon_date_editor_focus                      (GtkWidget *widget,
+                                               GtkDirectionType direction)
+{
+  gboolean retval;
+  GtkDirectionType effective_direction;
+
+  g_assert (HILDON_IS_EDITOR_EDITOR (widget));
+
+  retval = hildon_private_composite_focus (widget, direction, &effective_direction);
+
+  if (retval == TRUE)
+    return GTK_WIDGET_CLASS (parent_class)->focus (widget, effective_direction);
+  else
+    return FALSE;
+}
+
 /**
  * hildon_date_editor_set_year:
  * @editor: the @HildonDateEditor widget
index 72914d5..5d6a855 100644 (file)
@@ -96,6 +96,10 @@ hildon_number_editor_size_allocate              (GtkWidget *widget,
                                                  GtkAllocation *allocation);
 
 static gboolean
+hildon_number_editor_focus                      (GtkWidget *widget,
+                                                 GtkDirectionType direction);
+
+static gboolean
 hildon_number_editor_entry_keypress             (GtkWidget *widget, 
                                                  GdkEventKey *event,
                                                  gpointer data);
@@ -220,7 +224,7 @@ hildon_number_editor_class_init                 (HildonNumberEditorClass *editor
 
     widget_class->size_request              = hildon_number_editor_size_request;
     widget_class->size_allocate             = hildon_number_editor_size_allocate;
-    widget_class->focus                     = hildon_private_composite_focus;
+    widget_class->focus                     = hildon_number_editor_focus;
 
     editor_class->range_error = hildon_number_editor_range_error;
 
@@ -761,6 +765,23 @@ hildon_number_editor_size_allocate              (GtkWidget *widget,
 }
 
 static gboolean
+hildon_number_editor_focus                      (GtkWidget *widget,
+                                                 GtkDirectionType direction)
+{
+  gboolean retval;
+  GtkDirectionType effective_direction;
+
+  g_assert (HILDON_IS_EDITOR_EDITOR (widget));
+
+  retval = hildon_private_composite_focus (widget, direction, &effective_direction);
+
+  if (retval == TRUE)
+    return GTK_WIDGET_CLASS (parent_class)->focus (widget, effective_direction);
+  else
+    return FALSE;
+}
+
+static gboolean
 hildon_number_editor_entry_focusout             (GtkWidget *widget, 
                                                  GdkEventFocus *event,
                                                  gpointer data)
index 2bf5eda..e91d9d9 100644 (file)
  * regardless of where the focus is coming from.
  */
 gboolean G_GNUC_INTERNAL
-hildon_private_composite_focus                  (GtkWidget *widget, 
-                                                 GtkDirectionType direction)
+hildon_private_composite_focus                  (GtkWidget *widget,
+                                                 GtkDirectionType direction,
+                                                 GtkDirectionType *effective_direction)
 {
   GtkWidget *toplevel = NULL;
   GtkWidget *focus_widget = NULL;
   gboolean coming_from_outside = FALSE;
-  GtkDirectionType effective_direction;
 
   toplevel = gtk_widget_get_toplevel (widget);
 
@@ -55,11 +55,11 @@ hildon_private_composite_focus                  (GtkWidget *widget,
     {
       /* When coming from outside we want to give focus to the first
          item in the widgets */
-      effective_direction = GTK_DIR_TAB_FORWARD;
+      *effective_direction = GTK_DIR_TAB_FORWARD;
       coming_from_outside = TRUE;
     }
   else
-    effective_direction = direction;
+    *effective_direction = direction;
 
   switch (direction) {
       case GTK_DIR_UP:
@@ -68,11 +68,10 @@ hildon_private_composite_focus                  (GtkWidget *widget,
       case GTK_DIR_TAB_BACKWARD:
         if ((HILDON_IS_DATE_EDITOR (widget) || HILDON_IS_TIME_EDITOR(widget)) &&
             !coming_from_outside)
-          return FALSE;
+            return FALSE;
         /* fall through */
       default:
-        return GTK_WIDGET_CLASS (g_type_class_peek_parent
-                                 (GTK_WIDGET_GET_CLASS(widget)))->focus (widget, effective_direction);
+        return TRUE;
   }
 
   g_assert_not_reached ();
index b005860..0d3b463 100644 (file)
@@ -31,7 +31,8 @@ G_BEGIN_DECLS
 
 gboolean G_GNUC_INTERNAL
 hildon_private_composite_focus                  (GtkWidget *widget, 
-                                                 GtkDirectionType direction);
+                                                 GtkDirectionType direction,
+                                                 GtkDirectionType *effective_direction);
 
 G_END_DECLS
 
index 48fd5c5..c7fe2f9 100644 (file)
@@ -225,6 +225,10 @@ hildon_time_editor_size_allocate                (GtkWidget *widget,
                                                  GtkAllocation *allocation);
 
 static gboolean
+hildon_time_editor_focus                        (GtkWidget *widget,
+                                                 GtkDirectionType direction);
+
+static gboolean
 hildon_time_editor_entry_keypress (GtkEntry *entry,
                                    GdkEventKey* event,
                                    gpointer user_data);
@@ -365,7 +369,7 @@ hildon_time_editor_class_init                   (HildonTimeEditorClass *editor_c
 #ifdef MAEMO_GTK 
     widget_class->tap_and_hold_setup            = hildon_time_editor_tap_and_hold_setup;
 #endif
-    widget_class->focus                         = hildon_private_composite_focus;
+    widget_class->focus                         = hildon_time_editor_focus;
 
     container_class->forall                     = hildon_time_editor_forall;
     GTK_OBJECT_CLASS (editor_class)->destroy    = hildon_time_editor_destroy;
@@ -1777,6 +1781,23 @@ hildon_time_editor_size_allocate                (GtkWidget *widget,
 }
 
 static gboolean
+hildon_time_editor_focus                      (GtkWidget *widget,
+                                               GtkDirectionType direction)
+{
+  gboolean retval;
+  GtkDirectionType effective_direction;
+
+  g_assert (HILDON_IS_EDITOR_EDITOR (widget));
+
+  retval = hildon_private_composite_focus (widget, direction, &effective_direction);
+
+  if (retval == TRUE)
+    return GTK_WIDGET_CLASS (parent_class)->focus (widget, effective_direction);
+  else
+    return FALSE;
+}
+
+static gboolean
 hildon_time_editor_entry_keypress (GtkEntry *entry,
                                    GdkEventKey *event,
                                    gpointer data)
index 3f1c56a..3a388a9 100644 (file)
@@ -89,6 +89,9 @@ hildon_weekday_picker_init                      (HildonWeekdayPicker *picker);
 static void
 hildon_weekday_picker_size_allocate             (GtkWidget *widget,
                                                  GtkAllocation *allocation);
+static gboolean
+hildon_weekday_picker_focus                     (GtkWidget *widget,
+                                                 GtkDirectionType direction);
 static void
 hildon_weekday_picker_size_request              (GtkWidget *widget,
                                                  GtkRequisition *requisition);
@@ -160,7 +163,7 @@ hildon_weekday_picker_class_init                (HildonWeekdayPickerClass *picke
     /* Override virtual methods */
     widget_class->size_request                  = hildon_weekday_picker_size_request;
     widget_class->size_allocate                 = hildon_weekday_picker_size_allocate;
-    widget_class->focus                         = hildon_private_composite_focus;
+    widget_class->focus                         = hildon_weekday_picker_focus;
     container_class->forall                     = hildon_weekday_picker_forall;
     GTK_OBJECT_CLASS (picker_class)->destroy    = hildon_weekday_picker_destroy;
 
@@ -374,6 +377,23 @@ hildon_weekday_picker_size_allocate             (GtkWidget *widget,
     }
 }
 
+static gboolean
+hildon_weekday_picker_focus                      (GtkWidget *widget,
+                                                  GtkDirectionType direction)
+{
+  gboolean retval;
+  GtkDirectionType effective_direction;
+
+  g_assert (HILDON_IS_EDITOR_EDITOR (widget));
+
+  retval = hildon_private_composite_focus (widget, direction, &effective_direction);
+
+  if (retval == TRUE)
+    return GTK_WIDGET_CLASS (parent_class)->focus (widget, effective_direction);
+  else
+    return FALSE;
+}
+
 static void
 button_toggle                                   (GtkToggleButton *button, 
                                                  gpointer wpicker)