Date:2016-03-22 01:28:59 (3 years 8 months ago)
Author:Werner Almesberger
Commit:f3299aaf29636b8df86cab1bd994479574a55a2d
Message:gui.c: add "Allow" menu to GUI

Files: gui.c (6 diffs)

Change Details

gui.c
11/*
22 * gui.c - Editor GUI core
33 *
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
66 *
77 * This program is free software; you can redistribute it and/or modify
88 * it under the terms of the GNU General Public License as published by
...... 
4949static GtkWidget *stuff_image[2], *meas_image[2], *all_image[2];
5050static GtkWidget *bright_image[2];
5151
52static GtkItemFactory *menu_factory;
53
5254static void do_build_frames(void);
5355
5456
...... 
103105}
104106
105107
108/* ----- allow callbacks --------------------------------------------------- */
109
110
111static void allow_touch(void)
112{
113    allow_overlap = ao_touch;
114    change_world();
115}
116
117
118static void allow_any_overlap(void)
119{
120    allow_overlap = ao_any;
121    change_world();
122}
123
124
125static void allow_neither(void)
126{
127    allow_overlap = ao_none;
128    change_world();
129}
130
131
132static 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
106143/* ----- menu bar ---------------------------------------------------------- */
107144
108145
...... 
130167                        "/View/Show variables" },
131168    { "/View/Show packages",NULL, show_pkg, 0,
132169                        "/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>" }
133176};
134177
135178
136static GtkItemFactory *menu_factory;
137
138
139179static void make_menu_bar(GtkWidget *hbox)
140180{
141181    GtkWidget *bar;
...... 
176216    gtk_check_menu_item_set_active(
177217        GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(menu_factory, s)),
178218        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);
179241}
180242
181243
...... 
461523    edit_nothing();
462524    select_frame(frames);
463525    make_popups();
526    update_menu_bar();
464527
465528    gtk_main();
466529

Archive Download the corresponding diff file

Branches:
master



interactive