Date:2015-01-14 01:54:59 (4 years 9 months ago)
Author:Werner Almesberger
Commit:e3deb3978f9f4a0d22cf1427ffe8e323af344b1d
Message:update the menu bar (specifically, View > Show ...) after changes with "/"

Files: gui.c (2 diffs)
gui.h (1 diff)
gui_canvas.c (1 diff)

Change Details

gui.c
1111 */
1212
1313
14#include <stdlib.h>
1415#include <locale.h>
1516#include <gtk/gtk.h>
1617
...... 
132133};
133134
134135
136static GtkItemFactory *menu_factory;
137
138
135139static void make_menu_bar(GtkWidget *hbox)
136140{
137    GtkItemFactory *factory;
138141    GtkWidget *bar;
139142
140    factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<FpedMenu>", NULL);
141        gtk_item_factory_create_items(factory,
143    menu_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<FpedMenu>",
144        NULL);
145        gtk_item_factory_create_items(menu_factory,
142146        sizeof(menu_entries)/sizeof(*menu_entries), menu_entries, NULL);
143147
144    bar = gtk_item_factory_get_widget(factory, "<FpedMenu>");
148    bar = gtk_item_factory_get_widget(menu_factory, "<FpedMenu>");
145149    gtk_box_pack_start(GTK_BOX(hbox), bar, TRUE, TRUE, 0);
146150
147151    gtk_widget_set_sensitive(
148        gtk_item_factory_get_item(factory, "/File/Save"), !no_save);
152        gtk_item_factory_get_item(menu_factory, "/File/Save"), !no_save);
149153    gtk_widget_set_sensitive(
150        gtk_item_factory_get_item(factory, "/File/Reload"),
154        gtk_item_factory_get_item(menu_factory, "/File/Reload"),
151155        no_save && !!save_file_name);
152156}
153157
154158
159void update_menu_bar(void)
160{
161    const char *s;
162
163    switch (sidebar) {
164    case sidebar_var:
165        s = "/View/Show variables";
166        break;
167    case sidebar_code:
168        s = "/View/Show code";
169        break;
170    case sidebar_pkg:
171        s = "/View/Show packages";
172        break;
173    default:
174        abort();
175    }
176    gtk_check_menu_item_set_active(
177        GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(menu_factory, s)),
178        TRUE);
179}
180
181
155182static gboolean toggle_all(GtkWidget *widget, GdkEventButton *event,
156183    gpointer data)
157184{
gui.h
2626extern int no_save;
2727
2828
29/* update the menu bar after configuration changes */
30void update_menu_bar(void);
31
2932/* update everything after a model change */
3033void change_world(void);
3134
gui_canvas.c
452452        break;
453453    case '/':
454454        sidebar = sidebar == sidebar_last ? 0 : sidebar + 1;
455        update_menu_bar();
455456        change_world();
456457        break;
457458    }

Archive Download the corresponding diff file

Branches:
master



interactive