mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-12-22 13:30:49 +02:00
sanitize show var/code handling; switch to enum for future changes
This commit is contained in:
parent
ad2c07f49c
commit
73389fba76
20
gui.c
20
gui.c
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* gui.c - Editor GUI core
|
||||
*
|
||||
* Written 2009-2012 by Werner Almesberger
|
||||
* Copyright 2009-2012 by Werner Almesberger
|
||||
* Written 2009-2012, 2015 by Werner Almesberger
|
||||
* Copyright 2009-2012, 2015 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
|
||||
@ -81,11 +81,16 @@ static void save_as_fpd(void)
|
||||
/* ----- view callbacks ---------------------------------------------------- */
|
||||
|
||||
|
||||
static void swap_var_code(void)
|
||||
static void show_var(void)
|
||||
{
|
||||
extern int show_vars;
|
||||
sidebar = sidebar_var;
|
||||
change_world();
|
||||
}
|
||||
|
||||
show_vars = !show_vars;
|
||||
|
||||
static void show_code(void)
|
||||
{
|
||||
sidebar = sidebar_code;
|
||||
change_world();
|
||||
}
|
||||
|
||||
@ -111,7 +116,10 @@ static GtkItemFactoryEntry menu_entries[] = {
|
||||
{ "/View/Zoom all", NULL, zoom_to_extents,0, "<Item>" },
|
||||
{ "/View/Zoom frame", NULL, zoom_to_frame, 0, "<Item>" },
|
||||
{ "/View/sep1", NULL, NULL, 0, "<Separator>" },
|
||||
{ "/View/Swap var&code",NULL, swap_var_code, 0, "<Item>" },
|
||||
{ "/View/Show variables",
|
||||
NULL, show_var, 0, "<RadioItem>" },
|
||||
{ "/View/Show code", NULL, show_code, 0,
|
||||
"/View/Show variables" },
|
||||
};
|
||||
|
||||
|
||||
|
2
gui.html
2
gui.html
@ -149,7 +149,7 @@ dimension is expected, or the removal of a variable that's still used
|
||||
somewhere.
|
||||
<P>
|
||||
If the location of the error is not obvious, the list of objects can be
|
||||
shown by selecting "Swap var&code" from the View menu. The object
|
||||
shown by selecting "Show code" from the View menu. The object
|
||||
in which the error occurred is shown in red. If the error occurred in a
|
||||
loop variable, the variable name is shown in red.
|
||||
|
||||
|
14
gui_canvas.c
14
gui_canvas.c
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* gui_canvas.c - GUI, canvas
|
||||
*
|
||||
* Written 2009, 2010, 2012 by Werner Almesberger
|
||||
* Copyright 2009, 2010, 2012 by Werner Almesberger
|
||||
* Written 2009, 2010, 2012, 2015 by Werner Almesberger
|
||||
* Copyright 2009, 2010, 2012, 2015 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
|
||||
@ -25,6 +25,7 @@
|
||||
#include "gui_tool.h"
|
||||
#include "gui.h"
|
||||
#include "gui_frame_drag.h"
|
||||
#include "gui_frame.h"
|
||||
#include "gui_canvas.h"
|
||||
|
||||
|
||||
@ -450,12 +451,9 @@ static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
|
||||
change_world();
|
||||
break;
|
||||
case '/':
|
||||
{
|
||||
/* @@@ find a better place for this */
|
||||
extern int show_vars;
|
||||
show_vars = !show_vars;
|
||||
change_world();
|
||||
}
|
||||
sidebar = sidebar == sidebar_var ? sidebar_code : sidebar_var;
|
||||
change_world();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
17
gui_frame.c
17
gui_frame.c
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* gui_frame.c - GUI, frame window
|
||||
*
|
||||
* Written 2009, 2010, 2012 by Werner Almesberger
|
||||
* Copyright 2009, 2010, 2012 by Werner Almesberger
|
||||
* Written 2009, 2010, 2012, 2015 by Werner Almesberger
|
||||
* Copyright 2009, 2010, 2012, 2015 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
|
||||
@ -31,7 +31,7 @@
|
||||
#include "gui_frame.h"
|
||||
|
||||
|
||||
int show_vars = 1;
|
||||
enum sidebar sidebar = sidebar_var;
|
||||
|
||||
|
||||
/* ----- add elements, shared ---------------------------------------------- */
|
||||
@ -1851,21 +1851,26 @@ void build_frames(GtkWidget *vbox, int wrap_width)
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), refs,
|
||||
1, 2, n*2+1, n*2+2);
|
||||
|
||||
if (show_vars) {
|
||||
switch (sidebar) {
|
||||
case sidebar_var:
|
||||
vars = build_vars(frame, wrap_width);
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), vars,
|
||||
1, 2, n*2+2, n*2+3);
|
||||
dont_build_items(frame);
|
||||
} else {
|
||||
break;
|
||||
case sidebar_code:
|
||||
items = build_items(frame);
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), items,
|
||||
1, 2, n*2+2, n*2+3);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
n++;
|
||||
}
|
||||
|
||||
if (!show_vars) {
|
||||
if (sidebar == sidebar_code) {
|
||||
meas = build_meas(frames);
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), meas,
|
||||
1, 2, n*2+2, n*2+3);
|
||||
|
12
gui_frame.h
12
gui_frame.h
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* gui_frame.h - GUI, frame window
|
||||
*
|
||||
* Written 2009, 2010, 2012 by Werner Almesberger
|
||||
* Copyright 2009, 2010, 2012 by Werner Almesberger
|
||||
* Written 2009, 2010, 2012, 2015 by Werner Almesberger
|
||||
* Copyright 2009, 2010, 2012, 2015 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
|
||||
@ -19,7 +19,13 @@
|
||||
#include "obj.h"
|
||||
|
||||
|
||||
extern int show_vars;
|
||||
enum sidebar {
|
||||
sidebar_var, /* show variables */
|
||||
sidebar_code, /* show code */
|
||||
};
|
||||
|
||||
|
||||
extern enum sidebar sidebar;
|
||||
|
||||
|
||||
void reselect_var(struct var *var);
|
||||
|
Loading…
Reference in New Issue
Block a user