Gazpacho support, added the following properties:
[hildon] / hildon-widgets / hildon-composite-widget.c
1 /*
2  * This file is part of hildon-libs
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Luc Pionchon <luc.pionchon@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 #include <gtk/gtkwidget.h>
25 #include <gtk/gtkwindow.h>
26 #include "hildon-composite-widget.h"
27
28 gboolean
29 hildon_composite_widget_focus (GtkWidget *widget, GtkDirectionType direction)
30 {
31   GtkWidget *toplevel = NULL;
32   GtkWidget *focus_widget = NULL;
33   
34   toplevel = gtk_widget_get_toplevel (widget);
35   if (!GTK_IS_WINDOW(toplevel))
36     return GTK_WIDGET_CLASS (g_type_class_peek_parent (
37                      GTK_WIDGET_GET_CLASS (widget)))->focus (widget, direction);
38
39   focus_widget = GTK_WINDOW (toplevel)->focus_widget;
40
41   if (!GTK_IS_WIDGET (focus_widget))
42     return TRUE;
43
44   if (!gtk_widget_is_ancestor (focus_widget, widget))
45     /* Containers grab_focus grabs the focus to the correct widget */
46     gtk_widget_grab_focus (widget);
47   else
48     return GTK_WIDGET_CLASS (g_type_class_peek_parent (
49                      GTK_WIDGET_GET_CLASS(widget)))->focus (widget, direction);
50
51   return TRUE;
52 }