1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-12-22 23:14:36 +02:00

gui.c: add "Allow" menu to GUI

This commit is contained in:
Werner Almesberger 2016-03-21 21:28:59 -03:00
parent 377b7f8119
commit f3299aaf29

73
gui.c
View File

@ -1,8 +1,8 @@
/*
* gui.c - Editor GUI core
*
* Written 2009-2012, 2015 by Werner Almesberger
* Copyright 2009-2012, 2015 by Werner Almesberger
* Written 2009-2012, 2015-2016 by Werner Almesberger
* Copyright 2009-2012, 2015-2016 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -49,6 +49,8 @@ static GtkWidget *ev_stuff, *ev_meas, *ev_all, *ev_bright;
static GtkWidget *stuff_image[2], *meas_image[2], *all_image[2];
static GtkWidget *bright_image[2];
static GtkItemFactory *menu_factory;
static void do_build_frames(void);
@ -103,6 +105,41 @@ static void show_pkg(void)
}
/* ----- allow callbacks --------------------------------------------------- */
static void allow_touch(void)
{
allow_overlap = ao_touch;
change_world();
}
static void allow_any_overlap(void)
{
allow_overlap = ao_any;
change_world();
}
static void allow_neither(void)
{
allow_overlap = ao_none;
change_world();
}
static void allow_holes(void)
{
GtkCheckMenuItem *item =
GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(menu_factory,
"/Allow/Holes"));
holes_linked = !gtk_check_menu_item_get_active(item);
change_world();
}
/* ----- menu bar ---------------------------------------------------------- */
@ -130,12 +167,15 @@ static GtkItemFactoryEntry menu_entries[] = {
"/View/Show variables" },
{ "/View/Show packages",NULL, show_pkg, 0,
"/View/Show variables" },
{ "/Allow/Touch", NULL, allow_touch, 0, "<RadioItem>" },
{ "/Allow/Overlap", NULL, allow_any_overlap,
0, "/Allow/Touch" },
{ "/Allow/Neither", NULL, allow_neither, 0, "/Allow/Touch" },
{ "/Allow/sep1", NULL, NULL, 0, "<Separator>" },
{ "/Allow/Holes", NULL, allow_holes, 0, "<CheckItem>" }
};
static GtkItemFactory *menu_factory;
static void make_menu_bar(GtkWidget *hbox)
{
GtkWidget *bar;
@ -176,6 +216,28 @@ void update_menu_bar(void)
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(menu_factory, s)),
TRUE);
switch (allow_overlap) {
case ao_none:
s = "/Allow/Neither";
break;
case ao_touch:
s = "/Allow/Touch";
break;
case ao_any:
s = "/Allow/Overlap";
break;
default:
abort();
}
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(menu_factory, s)),
TRUE);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(menu_factory,
"/Allow/Holes")), !holes_linked);
}
@ -461,6 +523,7 @@ int gui_main(void)
edit_nothing();
select_frame(frames);
make_popups();
update_menu_bar();
gtk_main();