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
26 #include <hildon-stackable-window.h>
27 #include <hildon-app-menu.h>
30 menu_button_clicked (GtkButton *button,
33 const char *buttontext = gtk_button_get_label (button);
34 char *text = g_strdup_printf("Last option selected:\n%s", buttontext);
35 gtk_label_set_text (label, text);
39 static HildonAppMenu *
40 create_menu (GtkWidget *label)
43 HildonAppMenu *menu = HILDON_APP_MENU (hildon_app_menu_new ());
46 button = gtk_button_new_with_label ("Menu command one");
47 g_signal_connect (button, "clicked", G_CALLBACK (menu_button_clicked), label);
48 hildon_app_menu_append (menu, GTK_BUTTON (button));
50 button = gtk_button_new_with_label ("Menu command two");
51 g_signal_connect (button, "clicked", G_CALLBACK (menu_button_clicked), label);
52 hildon_app_menu_append (menu, GTK_BUTTON (button));
54 button = gtk_button_new_with_label ("Menu command three");
55 g_signal_connect (button, "clicked", G_CALLBACK (menu_button_clicked), label);
56 hildon_app_menu_append (menu, GTK_BUTTON (button));
58 button = gtk_button_new_with_label ("Menu command four");
59 g_signal_connect (button, "clicked", G_CALLBACK (menu_button_clicked), label);
60 hildon_app_menu_append (menu, GTK_BUTTON (button));
62 button = gtk_button_new_with_label ("Menu command five");
63 g_signal_connect (button, "clicked", G_CALLBACK (menu_button_clicked), label);
64 hildon_app_menu_append (menu, GTK_BUTTON (button));
67 button = gtk_radio_button_new_with_label (NULL, "filter one");
68 g_signal_connect (button, "clicked", G_CALLBACK (menu_button_clicked), label);
69 hildon_app_menu_add_filter (menu, GTK_BUTTON (button));
70 gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
72 button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (button), "filter two");
73 g_signal_connect (button, "clicked", G_CALLBACK (menu_button_clicked), label);
74 hildon_app_menu_add_filter (menu, GTK_BUTTON (button));
75 gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
90 gtk_init (&argc, &argv);
92 gtk_rc_parse_string ("style \"default\" {\n"
93 "bg[NORMAL] = \"#505050\""
95 "class \"HildonAppMenu\" style \"default\"\n");
97 label = gtk_label_new ("This is an example of the\nHildonAppMenu widget.\n\n"
98 "Click on the titlebar\nto pop up the menu.");
99 label2 = gtk_label_new ("No menu option has been selected yet.");
101 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
102 gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_CENTER);
104 vbox = GTK_BOX (gtk_vbox_new (FALSE, 10));
105 win = hildon_stackable_window_new ();
107 menu = create_menu (label2);
109 hildon_stackable_window_set_main_menu (HILDON_STACKABLE_WINDOW (win), menu);
111 gtk_box_pack_start (vbox, label, TRUE, TRUE, 0);
112 gtk_box_pack_start (vbox, label2, TRUE, TRUE, 0);
114 gtk_container_set_border_width (GTK_CONTAINER (win), 20);
115 gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET (vbox));
117 g_signal_connect (win, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
119 gtk_widget_show_all (win);