2 * This file is part of hildon-libs
4 * Copyright (C) 2005 Nokia Corporation.
6 * Contact: Luc Pionchon <luc.pionchon@nokia.com>
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.
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.
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
24 #include <gtk/gtkwidget.h>
25 #include <gtk/gtkwindow.h>
26 #include "hildon-composite-widget.h"
29 hildon_composite_widget_focus (GtkWidget *widget, GtkDirectionType direction)
31 GtkWidget *toplevel = NULL;
32 GtkWidget *focus_widget = NULL;
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);
39 focus_widget = GTK_WINDOW (toplevel)->focus_widget;
41 if (!GTK_IS_WIDGET (focus_widget))
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);
48 return GTK_WIDGET_CLASS (g_type_class_peek_parent (
49 GTK_WIDGET_GET_CLASS(widget)))->focus (widget, direction);