1.1.21
by Robert Ancell
Import upstream version 3.5.6 |
1 |
#include <gtk/gtk.h> |
2 |
#include "prop-editor.h" |
|
3 |
||
4 |
int main (int argc, char **argv) |
|
5 |
{
|
|
6 |
GtkWidget *window; |
|
7 |
GtkWidget *button; |
|
8 |
GtkWidget *grid; |
|
9 |
GtkWidget *entry; |
|
10 |
GtkWidget *menu_widget; |
|
11 |
guint i; |
|
12 |
GMenu *menu; |
|
13 |
||
14 |
gtk_init (&argc, &argv); |
|
15 |
||
16 |
window = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
|
17 |
gtk_window_resize (GTK_WINDOW (window), 400, 300); |
|
18 |
||
19 |
grid = gtk_grid_new (); |
|
20 |
gtk_container_add (GTK_CONTAINER (window), grid); |
|
21 |
||
22 |
/* Button next to entry */
|
|
23 |
entry = gtk_entry_new (); |
|
24 |
gtk_grid_attach (GTK_GRID (grid), |
|
25 |
entry, |
|
26 |
0, 0, |
|
27 |
1, 1); |
|
28 |
button = gtk_menu_button_new (); |
|
29 |
gtk_grid_attach (GTK_GRID (grid), |
|
30 |
button, |
|
31 |
1, 0, |
|
32 |
1, 1); |
|
33 |
||
34 |
/* Button with GtkMenu */
|
|
35 |
menu_widget = gtk_menu_new (); |
|
36 |
for (i = 5; i > 0; i--) { |
|
37 |
GtkWidget *item; |
|
38 |
char *label; |
|
39 |
||
40 |
label = g_strdup_printf ("Item %d", i); |
|
41 |
item = gtk_menu_item_new_with_label (label); |
|
42 |
g_free (label); |
|
43 |
gtk_menu_attach (GTK_MENU (menu_widget), |
|
44 |
item, |
|
45 |
0, 1, |
|
46 |
i - 1, i); |
|
47 |
}
|
|
48 |
gtk_widget_show_all (menu_widget); |
|
49 |
||
50 |
button = gtk_menu_button_new (); |
|
1.1.24
by Sebastien Bacher
Import upstream version 3.5.12 |
51 |
gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), menu_widget); |
1.1.21
by Robert Ancell
Import upstream version 3.5.6 |
52 |
gtk_grid_attach (GTK_GRID (grid), |
53 |
button, |
|
54 |
1, 1, |
|
55 |
1, 1); |
|
56 |
gtk_widget_show (create_prop_editor (G_OBJECT (button), 0)); |
|
57 |
||
58 |
/* Button with GMenuModel */
|
|
59 |
menu = g_menu_new (); |
|
60 |
for (i = 5; i > 0; i--) { |
|
61 |
char *label; |
|
62 |
label = g_strdup_printf ("Item %d", i); |
|
63 |
g_menu_insert (menu, i - 1, label, NULL); |
|
64 |
g_free (label); |
|
65 |
}
|
|
66 |
button = gtk_menu_button_new (); |
|
67 |
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (menu)); |
|
68 |
gtk_grid_attach (GTK_GRID (grid), |
|
69 |
button, |
|
70 |
1, 2, |
|
71 |
1, 1); |
|
72 |
||
73 |
gtk_widget_show_all (window); |
|
74 |
||
75 |
gtk_main (); |
|
76 |
||
77 |
return 0; |
|
78 |
}
|