2012-05-29 17:39:37 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "prop-editor.h"
|
|
|
|
|
|
|
|
int main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *grid;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *menu_widget;
|
2012-09-12 17:12:41 +00:00
|
|
|
GtkAccelGroup *accel_group;
|
2012-05-29 17:39:37 +00:00
|
|
|
guint i;
|
|
|
|
GMenu *menu;
|
|
|
|
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_resize (GTK_WINDOW (window), 400, 300);
|
|
|
|
|
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), grid);
|
|
|
|
|
2012-09-12 17:12:41 +00:00
|
|
|
accel_group = gtk_accel_group_new ();
|
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
|
|
|
|
2012-05-29 17:39:37 +00:00
|
|
|
/* Button next to entry */
|
|
|
|
entry = gtk_entry_new ();
|
|
|
|
gtk_grid_attach (GTK_GRID (grid),
|
|
|
|
entry,
|
|
|
|
0, 0,
|
|
|
|
1, 1);
|
|
|
|
button = gtk_menu_button_new ();
|
|
|
|
gtk_grid_attach (GTK_GRID (grid),
|
|
|
|
button,
|
|
|
|
1, 0,
|
|
|
|
1, 1);
|
|
|
|
|
|
|
|
/* Button with GtkMenu */
|
|
|
|
menu_widget = gtk_menu_new ();
|
|
|
|
for (i = 5; i > 0; i--) {
|
|
|
|
GtkWidget *item;
|
|
|
|
|
2012-09-12 17:12:41 +00:00
|
|
|
if (i == 3) {
|
2013-06-24 21:31:22 +00:00
|
|
|
item = gtk_menu_item_new_with_mnemonic ("_Copy");
|
2012-09-12 17:12:41 +00:00
|
|
|
} else {
|
|
|
|
char *label;
|
|
|
|
|
|
|
|
label = g_strdup_printf ("Item _%d", i);
|
|
|
|
item = gtk_menu_item_new_with_mnemonic (label);
|
|
|
|
g_free (label);
|
|
|
|
}
|
|
|
|
gtk_menu_item_set_use_underline (GTK_MENU_ITEM (item), TRUE);
|
2012-05-29 17:39:37 +00:00
|
|
|
gtk_menu_attach (GTK_MENU (menu_widget),
|
|
|
|
item,
|
|
|
|
0, 1,
|
|
|
|
i - 1, i);
|
|
|
|
}
|
|
|
|
gtk_widget_show_all (menu_widget);
|
|
|
|
|
|
|
|
button = gtk_menu_button_new ();
|
2012-08-20 21:03:15 +00:00
|
|
|
gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), menu_widget);
|
2012-05-29 17:39:37 +00:00
|
|
|
gtk_grid_attach (GTK_GRID (grid),
|
|
|
|
button,
|
|
|
|
1, 1,
|
|
|
|
1, 1);
|
|
|
|
gtk_widget_show (create_prop_editor (G_OBJECT (button), 0));
|
|
|
|
|
|
|
|
/* Button with GMenuModel */
|
|
|
|
menu = g_menu_new ();
|
|
|
|
for (i = 5; i > 0; i--) {
|
|
|
|
char *label;
|
2013-09-09 02:37:50 +00:00
|
|
|
GMenuItem *item;
|
2012-09-10 16:38:35 +00:00
|
|
|
label = g_strdup_printf ("Item _%d", i);
|
2013-09-09 02:37:50 +00:00
|
|
|
item = g_menu_item_new (label, NULL);
|
|
|
|
if (i == 3)
|
|
|
|
g_menu_item_set_attribute (item, "icon", "s", "preferences-desktop-locale-symbolic");
|
|
|
|
g_menu_insert_item (menu, i - 1, item);
|
|
|
|
g_object_unref (item);
|
2012-05-29 17:39:37 +00:00
|
|
|
g_free (label);
|
|
|
|
}
|
|
|
|
button = gtk_menu_button_new ();
|
|
|
|
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (menu));
|
|
|
|
gtk_grid_attach (GTK_GRID (grid),
|
|
|
|
button,
|
|
|
|
1, 2,
|
|
|
|
1, 1);
|
|
|
|
|
|
|
|
gtk_widget_show_all (window);
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|