Implementing the proper focus grabbing in the HildonCaption. Fixes NB#52379.
authorMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Wed, 30 May 2007 12:43:46 +0000 (12:43 +0000)
committerMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Wed, 30 May 2007 12:43:46 +0000 (12:43 +0000)
ChangeLog
src/hildon-caption.c

index 05380c8..9f2b587 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-05-30  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
+
+       * src/hildon-caption.c: Implementing the proper focus grabbing in the
+       HildonCaption. Fixes NB#52379. 
+
 2007-05-30  Xan Lopez  <xan.lopez@nokia.com>
 
        * src/hildon-bread-crumb-trail.c (crumb_activated_cb): be very paranoid about
@@ -6,7 +11,7 @@
        is removed and the user still lets the default handler run. This would segfault
        previously.
 
-2007-05-28  Michael Dominic K.  <michael.kostrzewa@nokia.com> 
+2007-05-28  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
 
        * src/hildon-font-selection-dialog.c: When the font is really big, add the
        scrollbar to the preview dialog. Fixes NB#54147.
index 4eac71e..a28171c 100644 (file)
@@ -92,6 +92,9 @@ hildon_caption_set_focus                        (GtkWindow *window,
                                                  GtkWidget *caption);
 
 static void 
+hildon_caption_grab_focus                       (GtkWidget *widget);
+
+static void 
 hildon_caption_activate                         (GtkWidget *widget);
 
 static void
@@ -213,6 +216,7 @@ hildon_caption_class_init                       (HildonCaptionClass *caption_cla
     widget_class->size_request                  = hildon_caption_size_request;
     widget_class->size_allocate                 = hildon_caption_size_allocate;
     widget_class->button_press_event            = hildon_caption_button_press;
+    widget_class->grab_focus                    = hildon_caption_grab_focus;
 
     /* Create new signals and properties */
     widget_class->activate_signal = g_signal_new ("activate",
@@ -576,26 +580,8 @@ hildon_caption_button_press                     (GtkWidget *widget,
     g_assert (priv);
     GtkWidget *child = GTK_BIN (widget)->child;
 
-    /* nothing to do */
-    if (priv->is_focused == TRUE)
-        return FALSE;
-
-    /* If child can take focus, we simply grab focus to it */
-    if ((GTK_WIDGET_CAN_FOCUS (child) || GTK_IS_CONTAINER (child)) &&
-            GTK_WIDGET_IS_SENSITIVE (child))
-    {
-        /* Only if container can be focusable we must set is_focused to TRUE */ 
-        if (GTK_IS_CONTAINER (child))
-        {
-            if (gtk_widget_child_focus (child, GTK_DIR_TAB_FORWARD))
-                priv->is_focused = TRUE;
-        }
-        else
-        {
-            priv->is_focused = TRUE;
-            gtk_widget_grab_focus (GTK_BIN (widget)->child);
-        }
-    }
+    priv->is_focused = TRUE;
+    gtk_widget_grab_focus (GTK_BIN (widget)->child);
 
     return FALSE;
 }
@@ -1159,6 +1145,12 @@ hildon_caption_activate                         (GtkWidget *widget)
     gtk_widget_grab_focus (child);
 }
 
+static void
+hildon_caption_grab_focus                       (GtkWidget *widget)
+{
+    gtk_widget_grab_focus (GTK_BIN (widget)->child);
+}
+
 /**
  * hildon_caption_set_child_expand:
  * @caption : a #HildonCaption