2 * This file is a part of hildon examples
4 * Copyright (C) 2008 Nokia Corporation, all rights reserved.
6 * Author: Karl Lattimer <karl.lattimer@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
33 #include <X11/Xatom.h>
36 add_window (GtkWidget* w);
39 detach_window (GtkWidget* w)
41 HildonProgram *program = hildon_program_get_instance ();
42 hildon_program_remove_window (program, HILDON_WINDOW (w));
46 new_window (gboolean ismain)
48 GtkWidget *window, *hbbox, *add;
52 window = hildon_stackable_window_new ();
55 title = g_strdup ("main window");
57 title = g_strdup_printf ("win%d", count);
59 gtk_window_set_title (GTK_WINDOW (window), title);
64 gtk_container_set_border_width (GTK_CONTAINER (window), 6);
66 hbbox = gtk_hbutton_box_new ();
67 gtk_container_add (GTK_CONTAINER (window), hbbox);
69 add = gtk_button_new_with_label ("Add a window");
70 gtk_box_pack_start (GTK_BOX (hbbox), add, FALSE, FALSE, 0);
72 g_signal_connect (G_OBJECT (add), "clicked", G_CALLBACK (add_window), NULL);
76 GtkWidget *detach, *back;
77 detach = GTK_WIDGET (gtk_button_new_with_label ("Detach"));
78 gtk_box_pack_end (GTK_BOX (hbbox), detach, FALSE, FALSE, 0);
80 g_signal_connect_swapped (G_OBJECT (detach), "clicked",
81 G_CALLBACK (detach_window),
82 HILDON_STACKABLE_WINDOW (window));
84 back = GTK_WIDGET (gtk_button_new_with_label ("Back to root"));
85 gtk_box_pack_end (GTK_BOX (hbbox), back, FALSE, FALSE, 0);
87 g_signal_connect_swapped (G_OBJECT (back), "clicked",
88 G_CALLBACK (hildon_program_go_to_root_window),
89 hildon_program_get_instance ());
96 add_window (GtkWidget *w)
98 GtkWidget *window = new_window (FALSE);
99 HildonProgram *program = hildon_program_get_instance ();
101 hildon_program_add_window (program, HILDON_WINDOW (window));
103 gtk_widget_show_all (window);
112 HildonProgram *program;
115 gtk_init (&argc, &args);
117 g_set_application_name ("stack");
119 program = hildon_program_get_instance ();
120 window = new_window (TRUE);
121 hildon_program_add_window (program, HILDON_WINDOW (window));
123 g_signal_connect (G_OBJECT (window), "delete_event",
124 G_CALLBACK (gtk_main_quit), NULL);
126 gtk_widget_show_all (GTK_WIDGET (window));