1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-21 20:49:21 +02:00

sanitize show var/code handling; switch to enum for future changes

This commit is contained in:
Werner Almesberger 2015-01-09 00:57:36 -03:00
parent ad2c07f49c
commit 73389fba76
5 changed files with 41 additions and 24 deletions

20
gui.c
View File

@ -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" },
};

View File

@ -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&amp;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.

View File

@ -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;
}

View File

@ -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);

View File

@ -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);