2 * This file is a part of hildon
4 * Copyright (C) 2005, 2006, 2009 Nokia Corporation, all rights reserved.
6 * Contact: Rodrigo Novo <rodrigo.novo@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; 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
25 #undef HILDON_DISABLE_DEPRECATED
31 #include "hildon-private.h"
32 #include "hildon-date-editor.h"
33 #include "hildon-time-editor.h"
34 #include "hildon-defines.h"
36 /* This function is a private function of hildon. It hadles focus
37 * changing for composite hildon widgets: HildonDateEditor,
38 * HildonNumberEditor, HildonTimeEditor, HildonWeekdayPicker.
39 * Its purpose is to focus the first widget (from left) inside the container
40 * regardless of where the focus is coming from.
42 gboolean G_GNUC_INTERNAL
43 hildon_private_composite_focus (GtkWidget *widget,
44 GtkDirectionType direction,
45 GtkDirectionType *effective_direction)
47 GtkWidget *toplevel = NULL;
48 GtkWidget *focus_widget = NULL;
49 gboolean coming_from_outside = FALSE;
51 toplevel = gtk_widget_get_toplevel (widget);
53 focus_widget = GTK_WINDOW (toplevel)->focus_widget;
55 if (focus_widget == NULL || gtk_widget_is_ancestor (focus_widget, widget) == FALSE)
57 /* When coming from outside we want to give focus to the first
58 item in the widgets */
59 *effective_direction = GTK_DIR_TAB_FORWARD;
60 coming_from_outside = TRUE;
63 *effective_direction = direction;
68 case GTK_DIR_TAB_FORWARD:
69 case GTK_DIR_TAB_BACKWARD:
70 if ((HILDON_IS_DATE_EDITOR (widget) || HILDON_IS_TIME_EDITOR(widget)) &&
78 g_assert_not_reached ();
83 G_GNUC_INTERNAL GtkWidget *
84 hildon_private_create_animation (gfloat framerate,
85 const gchar *template,
89 GdkPixbufSimpleAnim *anim;
93 anim = gdk_pixbuf_simple_anim_new (HILDON_ICON_PIXEL_SIZE_STYLUS,
94 HILDON_ICON_PIXEL_SIZE_STYLUS,
96 gdk_pixbuf_simple_anim_set_loop (anim, TRUE);
97 theme = gtk_icon_theme_get_default ();
99 for (i = 1; i <= nframes; i++) {
101 GError *error = NULL;
102 gchar *icon_name = g_strdup_printf (template, i);
103 frame = gtk_icon_theme_load_icon (theme, icon_name,
104 HILDON_ICON_PIXEL_SIZE_STYLUS,
108 g_warning ("Icon theme lookup for icon `%s' failed: %s",
109 icon_name, error->message);
110 g_error_free (error);
112 gdk_pixbuf_simple_anim_add_frame (anim, frame);
115 g_object_unref (frame);
119 image = gtk_image_new_from_animation (GDK_PIXBUF_ANIMATION (anim));
120 g_object_unref (anim);
127 hildon_gtk_window_set_clear_window_flag (GtkWindow *window,
128 const gchar *atomname,
132 GdkWindow *gdkwin = GTK_WIDGET (window)->window;
133 GdkAtom atom = gdk_atom_intern (atomname, FALSE);
137 gdk_property_change (gdkwin, atom, gdk_x11_xatom_to_atom (xatom),
138 32, GDK_PROP_MODE_REPLACE, (const guchar *) &set, 1);
140 gdk_property_delete (gdkwin, atom);
145 hildon_gtk_window_set_flag (GtkWindow *window,
149 g_return_if_fail (GTK_IS_WINDOW (window));
150 if (GTK_WIDGET_REALIZED (window)) {
151 (*func) (window, userdata);
153 g_signal_handlers_disconnect_matched (window, G_SIGNAL_MATCH_FUNC,
154 0, 0, NULL, func, NULL);
155 g_signal_connect (window, "realize", G_CALLBACK (func), userdata);