add demo for testing gtk_menu_popup_at_* ()

https://bugzilla.gnome.org/show_bug.cgi?id=756579
This commit is contained in:
William Hua 2016-06-23 10:54:22 -04:00
parent b03361366a
commit 05b9bc5cff
3 changed files with 2998 additions and 0 deletions

View File

@ -172,6 +172,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
gdkgears \
listmodel \
testpopup \
testpopupat \
$(NULL)
if USE_X11

2933
tests/popupat.ui Normal file

File diff suppressed because it is too large Load Diff

64
tests/testpopupat.c Normal file
View File

@ -0,0 +1,64 @@
#include <gtk/gtk.h>
static void
destroy_cb (GtkWidget *window,
GtkBuilder *builder)
{
gtk_main_quit ();
}
static void
populate_popup_cb (GtkAppChooserWidget *app_chooser_widget,
GtkMenu *menu,
GAppInfo *app_info,
gpointer user_data)
{
GtkWidget *menu_item;
menu_item = gtk_menu_item_new_with_label ("Menu Item A");
gtk_widget_show (menu_item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
menu_item = gtk_menu_item_new_with_label ("Menu Item B");
gtk_widget_show (menu_item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
menu_item = gtk_menu_item_new_with_label ("Menu Item C");
gtk_widget_show (menu_item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
menu_item = gtk_menu_item_new_with_label ("Menu Item D");
gtk_widget_show (menu_item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
menu_item = gtk_menu_item_new_with_label ("Menu Item E");
gtk_widget_show (menu_item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
}
int
main (int argc,
char *argv[])
{
GtkBuilder *builder;
GtkWidget *window;
GtkWidget *app_chooser_widget;
gtk_init (&argc, &argv);
builder = gtk_builder_new_from_file ("popupat.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
g_signal_connect (window, "destroy", G_CALLBACK (destroy_cb), builder);
app_chooser_widget = GTK_WIDGET (gtk_builder_get_object (builder, "appchooserwidget"));
g_signal_connect (app_chooser_widget, "populate-popup", G_CALLBACK (populate_popup_cb), builder);
gtk_widget_show_all (window);
gtk_main ();
g_object_unref (builder);
return 0;
}