Commit 31e07f85b06bbc82373178efa3acb26ebef87084
1 parent
5c6e7a07
Exists in
master
and in
5 other branches
Testando popups em windows
Showing
2 changed files
with
38 additions
and
1 deletions
Show diff stats
src/gtk/common/config.c
src/gtk/uiparser/testprogram.c
... | ... | @@ -3,6 +3,10 @@ |
3 | 3 | #include "../common/common.h" |
4 | 4 | #include "parser.h" |
5 | 5 | |
6 | +/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
7 | + | |
8 | + static GtkWidget **popup = NULL; | |
9 | + | |
6 | 10 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
7 | 11 | |
8 | 12 | void activated(GtkAction *action, GtkWidget *widget) |
... | ... | @@ -36,6 +40,16 @@ void ui_connect_pakey(GtkAction *action, GtkWidget *widget, const gchar *name, c |
36 | 40 | g_signal_connect(action,"activate",G_CALLBACK(activated),widget); |
37 | 41 | } |
38 | 42 | |
43 | +void show_popup(GtkWidget *button, GtkWidget *menu) | |
44 | +{ | |
45 | + trace("Showing popup %p",popup); | |
46 | + | |
47 | + gtk_widget_show_all(menu); | |
48 | + gtk_menu_set_screen(GTK_MENU(menu), gtk_widget_get_screen(button)); | |
49 | + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, 0); | |
50 | + | |
51 | +} | |
52 | + | |
39 | 53 | int main (int argc, char *argv[]) |
40 | 54 | { |
41 | 55 | static const gchar *groupname[] = { "default", |
... | ... | @@ -50,17 +64,39 @@ int main (int argc, char *argv[]) |
50 | 64 | static const gchar *popupname[] = { "default", |
51 | 65 | "selection", |
52 | 66 | "offline", |
67 | + "dock", | |
53 | 68 | NULL }; |
69 | + int f; | |
54 | 70 | GtkWidget * window; |
55 | 71 | gchar * path; |
72 | + GtkWidget * vbox; | |
73 | + GtkWidget * hbox; | |
56 | 74 | |
57 | 75 | gtk_init(&argc, &argv); |
58 | 76 | configuration_init(); |
59 | 77 | |
78 | + hbox = gtk_hbox_new(FALSE,5); | |
79 | + vbox = gtk_vbox_new(FALSE,5); | |
60 | 80 | path = build_data_filename("ui",NULL); |
61 | - window = ui_parse_xml_folder(path,groupname,popupname,NULL,NULL); | |
81 | + window = ui_parse_xml_folder(path,groupname,popupname,vbox,NULL); | |
62 | 82 | g_free(path); |
63 | 83 | |
84 | + popup = g_object_get_data(G_OBJECT(window),"popup_menus"); | |
85 | + | |
86 | + for(f=0;popupname[f];f++) | |
87 | + { | |
88 | + if(popup[f]) | |
89 | + { | |
90 | + GtkWidget *button = gtk_button_new_with_label(popupname[f]); | |
91 | + gtk_box_pack_start(GTK_BOX(hbox),button,FALSE,FALSE,5); | |
92 | + g_signal_connect(button,"clicked",G_CALLBACK(show_popup),popup[f]); | |
93 | + } | |
94 | + } | |
95 | + | |
96 | + gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5); | |
97 | + | |
98 | + gtk_widget_show_all(vbox); | |
99 | + | |
64 | 100 | if(window) |
65 | 101 | { |
66 | 102 | gtk_widget_show(window); | ... | ... |