mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-24 12:39:21 +02:00
update the menu bar (specifically, View > Show ...) after changes with "/"
This commit is contained in:
parent
5fdea0e99a
commit
e3deb3978f
39
gui.c
39
gui.c
@ -11,6 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
@ -132,26 +133,52 @@ static GtkItemFactoryEntry menu_entries[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static GtkItemFactory *menu_factory;
|
||||||
|
|
||||||
|
|
||||||
static void make_menu_bar(GtkWidget *hbox)
|
static void make_menu_bar(GtkWidget *hbox)
|
||||||
{
|
{
|
||||||
GtkItemFactory *factory;
|
|
||||||
GtkWidget *bar;
|
GtkWidget *bar;
|
||||||
|
|
||||||
factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<FpedMenu>", NULL);
|
menu_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<FpedMenu>",
|
||||||
gtk_item_factory_create_items(factory,
|
NULL);
|
||||||
|
gtk_item_factory_create_items(menu_factory,
|
||||||
sizeof(menu_entries)/sizeof(*menu_entries), menu_entries, NULL);
|
sizeof(menu_entries)/sizeof(*menu_entries), menu_entries, NULL);
|
||||||
|
|
||||||
bar = gtk_item_factory_get_widget(factory, "<FpedMenu>");
|
bar = gtk_item_factory_get_widget(menu_factory, "<FpedMenu>");
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), bar, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(hbox), bar, TRUE, TRUE, 0);
|
||||||
|
|
||||||
gtk_widget_set_sensitive(
|
gtk_widget_set_sensitive(
|
||||||
gtk_item_factory_get_item(factory, "/File/Save"), !no_save);
|
gtk_item_factory_get_item(menu_factory, "/File/Save"), !no_save);
|
||||||
gtk_widget_set_sensitive(
|
gtk_widget_set_sensitive(
|
||||||
gtk_item_factory_get_item(factory, "/File/Reload"),
|
gtk_item_factory_get_item(menu_factory, "/File/Reload"),
|
||||||
no_save && !!save_file_name);
|
no_save && !!save_file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void update_menu_bar(void)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
switch (sidebar) {
|
||||||
|
case sidebar_var:
|
||||||
|
s = "/View/Show variables";
|
||||||
|
break;
|
||||||
|
case sidebar_code:
|
||||||
|
s = "/View/Show code";
|
||||||
|
break;
|
||||||
|
case sidebar_pkg:
|
||||||
|
s = "/View/Show packages";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
gtk_check_menu_item_set_active(
|
||||||
|
GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(menu_factory, s)),
|
||||||
|
TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean toggle_all(GtkWidget *widget, GdkEventButton *event,
|
static gboolean toggle_all(GtkWidget *widget, GdkEventButton *event,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
3
gui.h
3
gui.h
@ -26,6 +26,9 @@ extern int show_bright;
|
|||||||
extern int no_save;
|
extern int no_save;
|
||||||
|
|
||||||
|
|
||||||
|
/* update the menu bar after configuration changes */
|
||||||
|
void update_menu_bar(void);
|
||||||
|
|
||||||
/* update everything after a model change */
|
/* update everything after a model change */
|
||||||
void change_world(void);
|
void change_world(void);
|
||||||
|
|
||||||
|
@ -452,6 +452,7 @@ static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
|
|||||||
break;
|
break;
|
||||||
case '/':
|
case '/':
|
||||||
sidebar = sidebar == sidebar_last ? 0 : sidebar + 1;
|
sidebar = sidebar == sidebar_last ? 0 : sidebar + 1;
|
||||||
|
update_menu_bar();
|
||||||
change_world();
|
change_world();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user