gui.c |
1 | 1 | /* |
2 | 2 | * gui.c - Editor GUI core |
3 | 3 | * |
4 | | * Written 2009-2012, 2015 by Werner Almesberger |
5 | | * Copyright 2009-2012, 2015 by Werner Almesberger |
| 4 | * Written 2009-2012, 2015-2016 by Werner Almesberger |
| 5 | * Copyright 2009-2012, 2015-2016 by Werner Almesberger |
6 | 6 | * |
7 | 7 | * This program is free software; you can redistribute it and/or modify |
8 | 8 | * it under the terms of the GNU General Public License as published by |
... | ... | |
49 | 49 | static GtkWidget *stuff_image[2], *meas_image[2], *all_image[2]; |
50 | 50 | static GtkWidget *bright_image[2]; |
51 | 51 | |
| 52 | static GtkItemFactory *menu_factory; |
| 53 | |
52 | 54 | static void do_build_frames(void); |
53 | 55 | |
54 | 56 | |
... | ... | |
103 | 105 | } |
104 | 106 | |
105 | 107 | |
| 108 | /* ----- allow callbacks --------------------------------------------------- */ |
| 109 | |
| 110 | |
| 111 | static void allow_touch(void) |
| 112 | { |
| 113 | allow_overlap = ao_touch; |
| 114 | change_world(); |
| 115 | } |
| 116 | |
| 117 | |
| 118 | static void allow_any_overlap(void) |
| 119 | { |
| 120 | allow_overlap = ao_any; |
| 121 | change_world(); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | static void allow_neither(void) |
| 126 | { |
| 127 | allow_overlap = ao_none; |
| 128 | change_world(); |
| 129 | } |
| 130 | |
| 131 | |
| 132 | static void allow_holes(void) |
| 133 | { |
| 134 | GtkCheckMenuItem *item = |
| 135 | GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(menu_factory, |
| 136 | "/Allow/Holes")); |
| 137 | |
| 138 | holes_linked = !gtk_check_menu_item_get_active(item); |
| 139 | change_world(); |
| 140 | } |
| 141 | |
| 142 | |
106 | 143 | /* ----- menu bar ---------------------------------------------------------- */ |
107 | 144 | |
108 | 145 | |
... | ... | |
130 | 167 | "/View/Show variables" }, |
131 | 168 | { "/View/Show packages",NULL, show_pkg, 0, |
132 | 169 | "/View/Show variables" }, |
| 170 | { "/Allow/Touch", NULL, allow_touch, 0, "<RadioItem>" }, |
| 171 | { "/Allow/Overlap", NULL, allow_any_overlap, |
| 172 | 0, "/Allow/Touch" }, |
| 173 | { "/Allow/Neither", NULL, allow_neither, 0, "/Allow/Touch" }, |
| 174 | { "/Allow/sep1", NULL, NULL, 0, "<Separator>" }, |
| 175 | { "/Allow/Holes", NULL, allow_holes, 0, "<CheckItem>" } |
133 | 176 | }; |
134 | 177 | |
135 | 178 | |
136 | | static GtkItemFactory *menu_factory; |
137 | | |
138 | | |
139 | 179 | static void make_menu_bar(GtkWidget *hbox) |
140 | 180 | { |
141 | 181 | GtkWidget *bar; |
... | ... | |
176 | 216 | gtk_check_menu_item_set_active( |
177 | 217 | GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(menu_factory, s)), |
178 | 218 | TRUE); |
| 219 | |
| 220 | switch (allow_overlap) { |
| 221 | case ao_none: |
| 222 | s = "/Allow/Neither"; |
| 223 | break; |
| 224 | case ao_touch: |
| 225 | s = "/Allow/Touch"; |
| 226 | break; |
| 227 | case ao_any: |
| 228 | s = "/Allow/Overlap"; |
| 229 | break; |
| 230 | default: |
| 231 | abort(); |
| 232 | } |
| 233 | gtk_check_menu_item_set_active( |
| 234 | GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(menu_factory, s)), |
| 235 | TRUE); |
| 236 | |
| 237 | |
| 238 | gtk_check_menu_item_set_active( |
| 239 | GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(menu_factory, |
| 240 | "/Allow/Holes")), !holes_linked); |
179 | 241 | } |
180 | 242 | |
181 | 243 | |
... | ... | |
461 | 523 | edit_nothing(); |
462 | 524 | select_frame(frames); |
463 | 525 | make_popups(); |
| 526 | update_menu_bar(); |
464 | 527 | |
465 | 528 | gtk_main(); |
466 | 529 | |