2009-08-08 22:35:16 +03:00
|
|
|
/*
|
|
|
|
* gui_frame.c - GUI, frame window
|
|
|
|
*
|
2010-01-02 14:55:34 +02:00
|
|
|
* Written 2009, 2010 by Werner Almesberger
|
|
|
|
* Copyright 2009, 2010 by Werner Almesberger
|
2009-08-08 22:35:16 +03:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
#include "error.h"
|
2009-08-12 13:45:52 +03:00
|
|
|
#include "dump.h"
|
2009-08-08 22:35:16 +03:00
|
|
|
#include "inst.h"
|
|
|
|
#include "obj.h"
|
|
|
|
#include "delete.h"
|
|
|
|
#include "unparse.h"
|
|
|
|
#include "gui_util.h"
|
|
|
|
#include "gui_style.h"
|
|
|
|
#include "gui_status.h"
|
2009-08-08 22:44:17 +03:00
|
|
|
#include "gui_tool.h"
|
2009-08-12 14:26:59 +03:00
|
|
|
#include "gui_canvas.h"
|
2009-08-08 22:35:16 +03:00
|
|
|
#include "gui.h"
|
|
|
|
#include "gui_frame.h"
|
|
|
|
|
|
|
|
|
2009-08-12 17:44:17 +03:00
|
|
|
int show_vars = 1;
|
|
|
|
|
|
|
|
|
2010-02-18 13:35:12 +02:00
|
|
|
/* ----- add elements, shared ---------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
/* @@@ merge with fpd.y */
|
|
|
|
|
|
|
|
static void add_table(struct frame *frame, struct table **anchor)
|
|
|
|
{
|
|
|
|
struct table *table, **walk;
|
|
|
|
|
|
|
|
table = zalloc_type(struct table);
|
|
|
|
table->vars = zalloc_type(struct var);
|
|
|
|
table->vars->name = unique("_");
|
|
|
|
table->vars->frame = frame;
|
|
|
|
table->vars->table = table;
|
|
|
|
table->rows = zalloc_type(struct row);
|
|
|
|
table->rows->table = table;
|
|
|
|
table->rows->values = zalloc_type(struct value);
|
|
|
|
table->rows->values->expr = parse_expr("0");
|
|
|
|
table->rows->values->row = table->rows;
|
|
|
|
table->active_row = table->rows;
|
|
|
|
if (anchor) {
|
|
|
|
table->next = *anchor;
|
|
|
|
*anchor = table;
|
|
|
|
} else {
|
|
|
|
for (walk = &frame->tables; *walk; walk = &(*walk)->next);
|
|
|
|
*walk = table;
|
|
|
|
}
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void add_loop(struct frame *frame, struct loop **anchor)
|
|
|
|
{
|
|
|
|
struct loop *loop, **walk;
|
|
|
|
|
|
|
|
loop = zalloc_type(struct loop);
|
|
|
|
loop->var.name = unique("_");
|
|
|
|
loop->var.frame = frame;
|
|
|
|
loop->from.expr = parse_expr("0");
|
|
|
|
loop->to.expr = parse_expr("0");
|
|
|
|
if (anchor) {
|
|
|
|
loop->next = *anchor;
|
|
|
|
*anchor = loop;
|
|
|
|
} else {
|
|
|
|
loop->next = NULL;
|
|
|
|
for (walk = &frame->loops; *walk; walk = &(*walk)->next);
|
|
|
|
*walk = loop;
|
|
|
|
}
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
/* ----- popup dispatcher -------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static void *popup_data;
|
|
|
|
|
|
|
|
|
|
|
|
static void pop_up(GtkWidget *menu, GdkEventButton *event, void *data)
|
|
|
|
{
|
|
|
|
popup_data = data;
|
|
|
|
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
|
|
|
|
event->button, event->time);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- popup: frame ------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
|
|
|
static GtkItemFactory *factory_frame;
|
|
|
|
static GtkWidget *popup_frame_widget;
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_add_frame(void)
|
|
|
|
{
|
|
|
|
struct frame *parent = popup_data;
|
|
|
|
struct frame *new;
|
|
|
|
|
|
|
|
new = zalloc_type(struct frame);
|
|
|
|
new->name = unique("_");
|
|
|
|
new->next = parent;
|
|
|
|
new->prev = parent->prev;
|
|
|
|
if (parent->prev)
|
|
|
|
parent->prev->next = new;
|
|
|
|
else
|
|
|
|
frames = new;
|
|
|
|
parent->prev = new;
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_del_frame(void)
|
|
|
|
{
|
|
|
|
struct frame *frame = popup_data;
|
|
|
|
|
|
|
|
assert(frame != root_frame);
|
2009-12-31 17:11:47 +02:00
|
|
|
tool_frame_deleted(frame);
|
2009-08-08 22:35:16 +03:00
|
|
|
delete_frame(frame);
|
|
|
|
if (active_frame == frame)
|
|
|
|
select_frame(root_frame);
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_add_table(void)
|
|
|
|
{
|
2010-02-18 13:35:12 +02:00
|
|
|
add_table(popup_data, NULL);
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_add_loop(void)
|
|
|
|
{
|
2010-02-18 13:35:12 +02:00
|
|
|
add_loop(popup_data, NULL);
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkItemFactoryEntry popup_frame_entries[] = {
|
2010-02-18 13:35:12 +02:00
|
|
|
{ "/Add frame", NULL, popup_add_frame,0, "<Item>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ "/sep0", NULL, NULL, 0, "<Separator>" },
|
2010-02-18 13:35:12 +02:00
|
|
|
{ "/Add variable", NULL, popup_add_table,0, "<Item>" },
|
|
|
|
{ "/Add loop", NULL, popup_add_loop, 0, "<Item>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ "/sep1", NULL, NULL, 0, "<Separator>" },
|
2010-02-18 13:35:12 +02:00
|
|
|
{ "/Delete frame", NULL, popup_del_frame,0, "<Item>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ "/sep2", NULL, NULL, 0, "<Separator>" },
|
|
|
|
{ "/Close", NULL, NULL, 0, "<Item>" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-31 18:13:49 +02:00
|
|
|
static gboolean can_add_frame(void)
|
|
|
|
{
|
|
|
|
const struct frame *frame;
|
|
|
|
|
|
|
|
for (frame = frames; frame; frame = frame->next)
|
|
|
|
if (frame->name && !strcmp(frame->name, "_"))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean can_add_var(const struct frame *frame)
|
|
|
|
{
|
|
|
|
const struct table *table;
|
|
|
|
const struct var *var;
|
|
|
|
const struct loop *loop;
|
|
|
|
|
|
|
|
for (table = frame->tables; table; table = table->next)
|
|
|
|
for (var = table->vars; var; var = var->next)
|
|
|
|
if (!strcmp(var->name, "_"))
|
|
|
|
return FALSE;
|
|
|
|
for (loop = frame->loops; loop; loop = loop->next)
|
|
|
|
if (!strcmp(loop->var.name, "_"))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-18 13:35:12 +02:00
|
|
|
static void enable_add_var(struct frame *frame, GtkItemFactory *factory)
|
2009-08-08 22:35:16 +03:00
|
|
|
{
|
2009-12-31 18:13:49 +02:00
|
|
|
gboolean add_var;
|
|
|
|
|
2010-02-18 13:35:12 +02:00
|
|
|
add_var = can_add_var(frame);
|
|
|
|
gtk_widget_set_sensitive(
|
|
|
|
gtk_item_factory_get_item(factory, "/Add variable"), add_var);
|
|
|
|
gtk_widget_set_sensitive(
|
|
|
|
gtk_item_factory_get_item(factory, "/Add loop"), add_var);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void pop_up_frame(struct frame *frame, GdkEventButton *event)
|
|
|
|
{
|
2009-08-08 22:35:16 +03:00
|
|
|
gtk_widget_set_sensitive(
|
|
|
|
gtk_item_factory_get_item(factory_frame, "/Delete frame"),
|
|
|
|
frame != root_frame);
|
2009-12-31 18:13:49 +02:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive(
|
|
|
|
gtk_item_factory_get_item(factory_frame, "/Add frame"),
|
|
|
|
can_add_frame());
|
|
|
|
|
2010-02-18 13:35:12 +02:00
|
|
|
enable_add_var(frame, factory_frame);
|
2009-12-31 18:13:49 +02:00
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
pop_up(popup_frame_widget, event, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- popup: single variable -------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static GtkItemFactory *factory_single_var;
|
|
|
|
static GtkWidget *popup_single_var_widget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void add_row_here(struct table *table, struct row **anchor)
|
|
|
|
{
|
|
|
|
struct row *row;
|
|
|
|
const struct value *walk;
|
|
|
|
struct value *value;
|
|
|
|
|
|
|
|
row = zalloc_type(struct row);
|
|
|
|
row->table = table;
|
|
|
|
/* @@@ future: adjust type */
|
|
|
|
for (walk = table->rows->values; walk; walk = walk->next) {
|
|
|
|
value = zalloc_type(struct value);
|
|
|
|
value->expr = parse_expr("0");
|
|
|
|
value->row = row;
|
|
|
|
value->next = row->values;
|
|
|
|
row->values = value;
|
|
|
|
}
|
|
|
|
row->next = *anchor;
|
|
|
|
*anchor = row;
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void add_column_here(struct table *table, struct var **anchor)
|
|
|
|
{
|
|
|
|
const struct var *walk;
|
|
|
|
struct var *var;
|
|
|
|
struct row *row;
|
|
|
|
struct value *value;
|
|
|
|
struct value **value_anchor;
|
|
|
|
int n = 0, i;
|
|
|
|
|
|
|
|
for (walk = table->vars; walk != *anchor; walk = walk->next)
|
|
|
|
n++;
|
|
|
|
var = zalloc_type(struct var);
|
|
|
|
var->name = unique("_");
|
|
|
|
var->frame = table->vars->frame;
|
|
|
|
var->table = table;
|
|
|
|
var->next = *anchor;
|
|
|
|
*anchor = var;
|
|
|
|
for (row = table->rows; row; row = row->next) {
|
|
|
|
value_anchor = &row->values;
|
|
|
|
for (i = 0; i != n; i++)
|
|
|
|
value_anchor = &(*value_anchor)->next;
|
|
|
|
value = zalloc_type(struct value);
|
|
|
|
value->expr = parse_expr("0");
|
|
|
|
value->row = row;
|
|
|
|
value->next = *value_anchor;
|
|
|
|
*value_anchor = value;
|
|
|
|
}
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_add_row(void)
|
|
|
|
{
|
|
|
|
struct var *var = popup_data;
|
|
|
|
|
|
|
|
add_row_here(var->table, &var->table->rows);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_add_column(void)
|
|
|
|
{
|
|
|
|
struct var *var = popup_data;
|
|
|
|
|
|
|
|
add_column_here(var->table, &var->next);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_del_table(void)
|
|
|
|
{
|
|
|
|
struct var *var = popup_data;
|
|
|
|
|
|
|
|
delete_table(var->table);
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-18 13:35:12 +02:00
|
|
|
static void popup_add_table_from_var(void)
|
|
|
|
{
|
|
|
|
struct var *var = popup_data;
|
|
|
|
|
|
|
|
add_table(var->frame, &var->table->next);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_add_loop_from_var(void)
|
|
|
|
{
|
|
|
|
struct var *var = popup_data;
|
|
|
|
|
|
|
|
add_loop(var->frame, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
static GtkItemFactoryEntry popup_single_var_entries[] = {
|
2010-02-18 13:35:12 +02:00
|
|
|
{ "/Add row", NULL, popup_add_row, 0, "<Item>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ "/Add column", NULL, popup_add_column, 0, "<Item>" },
|
|
|
|
{ "/sep1", NULL, NULL, 0, "<Separator>" },
|
2010-02-18 13:35:12 +02:00
|
|
|
{ "/Delete variable", NULL, popup_del_table,0, "<Item>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ "/sep2", NULL, NULL, 0, "<Separator>" },
|
2010-02-18 13:35:12 +02:00
|
|
|
{ "/Add variable", NULL, popup_add_table_from_var,
|
|
|
|
0, "<Item>" },
|
|
|
|
{ "/Add loop", NULL, popup_add_loop_from_var,
|
|
|
|
0, "<Item>" },
|
|
|
|
{ "/sep3", NULL, NULL, 0, "<Separator>" },
|
|
|
|
{ "/Close", NULL, NULL, 0, "<Item>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void pop_up_single_var(struct var *var, GdkEventButton *event)
|
|
|
|
{
|
2009-12-31 18:13:49 +02:00
|
|
|
gtk_widget_set_sensitive(
|
|
|
|
gtk_item_factory_get_item(factory_single_var, "/Add column"),
|
|
|
|
can_add_var(var->frame));
|
2010-02-18 13:35:12 +02:00
|
|
|
enable_add_var(var->frame, factory_single_var);
|
2009-08-08 22:35:16 +03:00
|
|
|
pop_up(popup_single_var_widget, event, var);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- popup: table variable --------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static GtkItemFactory *factory_table_var;
|
|
|
|
static GtkWidget *popup_table_var_widget;
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_del_column(void)
|
|
|
|
{
|
|
|
|
struct var *var = popup_data;
|
|
|
|
const struct var *walk;
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
for (walk = var->table->vars; walk != var; walk = walk->next)
|
|
|
|
n++;
|
|
|
|
delete_column(var->table, n);
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkItemFactoryEntry popup_table_var_entries[] = {
|
2010-02-18 13:35:12 +02:00
|
|
|
{ "/Add row", NULL, popup_add_row, 0, "<Item>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ "/Add column", NULL, popup_add_column, 0, "<Item>" },
|
|
|
|
{ "/sep1", NULL, NULL, 0, "<Separator>" },
|
2010-02-18 13:35:12 +02:00
|
|
|
{ "/Delete table", NULL, popup_del_table,0, "<Item>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ "/Delete column", NULL, popup_del_column, 0, "<Item>" },
|
|
|
|
{ "/sep2", NULL, NULL, 0, "<Separator>" },
|
2010-02-18 13:35:12 +02:00
|
|
|
{ "/Add variable", NULL, popup_add_table_from_var,
|
|
|
|
0, "<Item>" },
|
|
|
|
{ "/Add loop", NULL, popup_add_loop_from_var,
|
|
|
|
0, "<Item>" },
|
|
|
|
{ "/sep3", NULL, NULL, 0, "<Separator>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ "/Close", NULL, NULL, 0, "<Item>" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void pop_up_table_var(struct var *var, GdkEventButton *event)
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive(
|
|
|
|
gtk_item_factory_get_item(factory_table_var, "/Delete column"),
|
|
|
|
var->table->vars->next != NULL);
|
2009-12-31 18:13:49 +02:00
|
|
|
gtk_widget_set_sensitive(
|
|
|
|
gtk_item_factory_get_item(factory_table_var, "/Add column"),
|
|
|
|
can_add_var(var->frame));
|
2010-02-18 13:35:12 +02:00
|
|
|
enable_add_var(var->frame, factory_table_var);
|
2009-08-08 22:35:16 +03:00
|
|
|
pop_up(popup_table_var_widget, event, var);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- popup: table value ------------------------------------------------ */
|
|
|
|
|
|
|
|
|
|
|
|
static GtkItemFactory *factory_table_value;
|
|
|
|
static GtkWidget *popup_table_value_widget;
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_add_column_by_value(void)
|
|
|
|
{
|
|
|
|
struct value *value = popup_data;
|
|
|
|
const struct value *walk;
|
|
|
|
struct table *table = value->row->table;
|
|
|
|
struct var *var = table->vars;
|
|
|
|
|
|
|
|
for (walk = value->row->values; walk != value; walk = walk->next)
|
|
|
|
var = var->next;
|
|
|
|
add_column_here(table, &var->next);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_add_row_by_value(void)
|
|
|
|
{
|
|
|
|
struct value *value = popup_data;
|
|
|
|
|
|
|
|
add_row_here(value->row->table, &value->row->next);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_del_row(void)
|
|
|
|
{
|
|
|
|
struct value *value = popup_data;
|
|
|
|
struct table *table = value->row->table;
|
|
|
|
|
|
|
|
delete_row(value->row);
|
|
|
|
if (table->active_row == value->row)
|
|
|
|
table->active_row = table->rows;
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_del_column_by_value(void)
|
|
|
|
{
|
|
|
|
struct value *value = popup_data;
|
|
|
|
const struct value *walk;
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
for (walk = value->row->values; walk != value; walk = walk->next)
|
|
|
|
n++;
|
|
|
|
delete_column(value->row->table, n);
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkItemFactoryEntry popup_table_value_entries[] = {
|
|
|
|
{ "/Add row", NULL, popup_add_row_by_value, 0, "<Item>" },
|
|
|
|
{ "/Add column", NULL, popup_add_column_by_value,
|
|
|
|
0, "<Item>" },
|
|
|
|
{ "/sep1", NULL, NULL, 0, "<Separator>" },
|
2010-02-18 13:35:12 +02:00
|
|
|
{ "/Delete row", NULL, popup_del_row, 0, "<Item>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ "/Delete column", NULL, popup_del_column_by_value,
|
2010-02-18 13:35:12 +02:00
|
|
|
0, "<Item>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ "/sep2", NULL, NULL, 0, "<Separator>" },
|
|
|
|
{ "/Close", NULL, NULL, 0, "<Item>" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void pop_up_table_value(struct value *value, GdkEventButton *event)
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive(
|
|
|
|
gtk_item_factory_get_item(factory_table_value, "/Delete row"),
|
|
|
|
value->row->table->rows->next != NULL);
|
|
|
|
gtk_widget_set_sensitive(
|
|
|
|
gtk_item_factory_get_item(factory_table_value, "/Delete column"),
|
|
|
|
value->row->table->vars->next != NULL);
|
|
|
|
pop_up(popup_table_value_widget, event, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- popup: loop ------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static GtkItemFactory *factory_loop_var;
|
|
|
|
static GtkWidget *popup_loop_var_widget;
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_del_loop(void)
|
|
|
|
{
|
|
|
|
struct loop *loop = popup_data;
|
|
|
|
|
|
|
|
delete_loop(loop);
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-18 13:35:12 +02:00
|
|
|
static void popup_add_table_from_loop(void)
|
|
|
|
{
|
|
|
|
struct loop *loop = popup_data;
|
|
|
|
|
|
|
|
add_table(loop->var.frame, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void popup_add_loop_from_loop(void)
|
|
|
|
{
|
|
|
|
struct loop *loop = popup_data;
|
|
|
|
|
|
|
|
add_loop(loop->var.frame, &loop->next);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
static GtkItemFactoryEntry popup_loop_var_entries[] = {
|
2009-12-31 18:13:49 +02:00
|
|
|
{ "/Delete loop", NULL, popup_del_loop, 0, "<Item>" },
|
2010-02-18 13:35:12 +02:00
|
|
|
{ "/sep1", NULL, NULL, 0, "<Separator>" },
|
|
|
|
{ "/Add variable", NULL, popup_add_table_from_loop,
|
|
|
|
0, "<Item>" },
|
|
|
|
{ "/Add loop", NULL, popup_add_loop_from_loop,
|
|
|
|
0, "<Item>" },
|
2009-08-08 22:35:16 +03:00
|
|
|
{ "/sep2", NULL, NULL, 0, "<Separator>" },
|
|
|
|
{ "/Close", NULL, NULL, 0, "<Item>" },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void pop_up_loop_var(struct loop *loop, GdkEventButton *event)
|
|
|
|
{
|
2010-02-18 13:35:12 +02:00
|
|
|
enable_add_var(loop->var.frame, factory_loop_var);
|
2009-08-08 22:35:16 +03:00
|
|
|
pop_up(popup_loop_var_widget, event, loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- make popups ------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *make_popup(const char *name, GtkItemFactory **factory,
|
|
|
|
GtkItemFactoryEntry *entries)
|
|
|
|
{
|
|
|
|
GtkWidget *popup;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
for (n = 0; entries[n].path; n++);
|
|
|
|
|
|
|
|
*factory = gtk_item_factory_new(GTK_TYPE_MENU, name, NULL);
|
|
|
|
gtk_item_factory_create_items(*factory, n, entries, NULL);
|
|
|
|
popup = gtk_item_factory_get_widget(*factory, name);
|
|
|
|
return popup;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void make_popups(void)
|
|
|
|
{
|
|
|
|
popup_frame_widget = make_popup("<FpedFramePopUp>",
|
|
|
|
&factory_frame, popup_frame_entries);
|
|
|
|
popup_single_var_widget = make_popup("<FpedSingleVarPopUp>",
|
|
|
|
&factory_single_var, popup_single_var_entries);
|
|
|
|
popup_table_var_widget = make_popup("<FpedTableVarPopUp>",
|
|
|
|
&factory_table_var, popup_table_var_entries);
|
|
|
|
popup_table_value_widget = make_popup("<FpedTableValusPopUp>",
|
|
|
|
&factory_table_value, popup_table_value_entries);
|
|
|
|
popup_loop_var_widget = make_popup("<FpedLoopVarPopUp>",
|
|
|
|
&factory_loop_var, popup_loop_var_entries);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- variable list ----------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static void add_sep(GtkWidget *box, int size)
|
|
|
|
{
|
|
|
|
GtkWidget *sep;
|
|
|
|
GdkColor black = { 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
sep = gtk_drawing_area_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(box), sep, FALSE, TRUE, size);
|
|
|
|
gtk_widget_modify_bg(sep, GTK_STATE_NORMAL, &black);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- variable name editor ---------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-16 07:12:37 +03:00
|
|
|
static int find_var_in_frame(const struct frame *frame, const char *name,
|
|
|
|
const struct var *self)
|
2009-08-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
const struct table *table;
|
|
|
|
const struct loop *loop;
|
|
|
|
const struct var *var;
|
|
|
|
|
|
|
|
for (table = frame->tables; table; table = table->next)
|
|
|
|
for (var = table->vars; var; var = var->next)
|
2009-08-16 07:12:37 +03:00
|
|
|
if (var != self && !strcmp(var->name, name))
|
2009-08-08 22:35:16 +03:00
|
|
|
return 1;
|
|
|
|
for (loop = frame->loops; loop; loop = loop->next)
|
2009-08-16 07:12:37 +03:00
|
|
|
if (&loop->var != self && !strcmp(loop->var.name, name))
|
2009-08-08 22:35:16 +03:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int validate_var_name(const char *s, void *ctx)
|
|
|
|
{
|
|
|
|
struct var *var = ctx;
|
|
|
|
|
|
|
|
if (!is_id(s))
|
|
|
|
return 0;
|
2009-08-16 07:12:37 +03:00
|
|
|
return !find_var_in_frame(var->frame, s, var);
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void unselect_var(void *data)
|
|
|
|
{
|
|
|
|
struct var *var = data;
|
|
|
|
|
|
|
|
label_in_box_bg(var->widget, COLOR_VAR_PASSIVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
When editing a variable or value, the actual value is now shown. The choice
of active frame reference, row, and loop instance affects this value, as it
should.
- obj.c (run_loops): reset loop->curr_value to UNDEF when instantiation is done
- obj.c (generate_frame): reset frame->curr_parent to NULL when instantiation
is done
- expr.c (eval_var, eval_string_var): distinguish beteen instantiation and
editing mode, and use "active" values in the latter
- gui_frame.c (edit_var, edit_value, edit_value_list): display the value of the
variable or the active expression in the "X" field
- gui_frame.c (assignment_value_select_event, table_value_select_event,
loop_from_select_event, loop_to_select_event): pass the frame to edit_value
and edit_value_list
- expr.c (str_unit): since we may now accidently expose a wider range of
exponents, removed -2 ... 2 exponent range limitation
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5788 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-01-10 15:09:55 +02:00
|
|
|
static void show_value(const struct expr *expr, const struct frame *frame)
|
|
|
|
{
|
|
|
|
const char *value_string;
|
|
|
|
struct num value;
|
|
|
|
|
|
|
|
status_set_type_x(NULL, "value =");
|
|
|
|
value_string = eval_str(expr, frame);
|
|
|
|
if (value_string)
|
|
|
|
status_set_x(NULL, "\"%s\"", value_string);
|
|
|
|
else {
|
|
|
|
value = eval_num(expr, frame);
|
|
|
|
if (is_undef(value))
|
|
|
|
status_set_x(NULL, "undefined");
|
|
|
|
else
|
|
|
|
status_set_x(NULL, "%lg%s", value.n, str_unit(value));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void show_var_value(const struct var *var, const struct frame *frame)
|
|
|
|
{
|
|
|
|
const struct var *walk;
|
|
|
|
const struct value *value;
|
|
|
|
|
|
|
|
if (!var->table)
|
|
|
|
return;
|
|
|
|
value = var->table->active_row->values;
|
|
|
|
for (walk = var->table->vars; walk != var; walk = walk->next)
|
|
|
|
value = value->next;
|
|
|
|
show_value(value->expr, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-16 07:12:37 +03:00
|
|
|
static void edit_var(struct var *var,
|
|
|
|
void (*set_values)(void *user, const struct value *values, int n_values),
|
|
|
|
void *user, int max_values)
|
2009-08-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
inst_select_outside(var, unselect_var);
|
|
|
|
label_in_box_bg(var->widget, COLOR_VAR_EDITING);
|
2010-01-03 02:36:52 +02:00
|
|
|
status_set_type_entry(NULL, "name =");
|
2010-01-03 01:27:36 +02:00
|
|
|
status_set_name("Variable name", "%s", var->name);
|
When editing a variable or value, the actual value is now shown. The choice
of active frame reference, row, and loop instance affects this value, as it
should.
- obj.c (run_loops): reset loop->curr_value to UNDEF when instantiation is done
- obj.c (generate_frame): reset frame->curr_parent to NULL when instantiation
is done
- expr.c (eval_var, eval_string_var): distinguish beteen instantiation and
editing mode, and use "active" values in the latter
- gui_frame.c (edit_var, edit_value, edit_value_list): display the value of the
variable or the active expression in the "X" field
- gui_frame.c (assignment_value_select_event, table_value_select_event,
loop_from_select_event, loop_to_select_event): pass the frame to edit_value
and edit_value_list
- expr.c (str_unit): since we may now accidently expose a wider range of
exponents, removed -2 ... 2 exponent range limitation
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5788 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-01-10 15:09:55 +02:00
|
|
|
show_var_value(var, var->frame);
|
2009-08-12 02:26:38 +03:00
|
|
|
edit_nothing();
|
2009-08-16 07:12:37 +03:00
|
|
|
edit_unique_with_values(&var->name, validate_var_name, var,
|
2010-01-03 02:36:52 +02:00
|
|
|
set_values, user, max_values,
|
|
|
|
"Variable name. "
|
|
|
|
"Shortcut:<b><i>name</i>=<i>value</i>,<i>...</i> </b>");
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- value editor ------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
|
|
|
static void unselect_value(void *data)
|
|
|
|
{
|
|
|
|
struct value *value = data;
|
|
|
|
|
2009-12-31 11:34:17 +02:00
|
|
|
/*
|
|
|
|
* This condition is a little cryptic. Here is what it does:
|
|
|
|
*
|
|
|
|
* IF table/assignment (not loop)
|
|
|
|
* AND the current row is the active (selected) row
|
|
|
|
* AND it's an assignment (not a table).
|
|
|
|
*
|
|
|
|
* We need the last condition because the expressions of assignments
|
|
|
|
* are drawn with COLOR_VAR_PASSIVE. (See build_assignment.)
|
|
|
|
*/
|
2009-08-08 22:35:16 +03:00
|
|
|
label_in_box_bg(value->widget,
|
2009-12-31 11:34:17 +02:00
|
|
|
value->row && value->row->table->active_row == value->row &&
|
|
|
|
value->row->table->rows->next ?
|
2009-08-08 22:35:16 +03:00
|
|
|
COLOR_CHOICE_SELECTED : COLOR_EXPR_PASSIVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
When editing a variable or value, the actual value is now shown. The choice
of active frame reference, row, and loop instance affects this value, as it
should.
- obj.c (run_loops): reset loop->curr_value to UNDEF when instantiation is done
- obj.c (generate_frame): reset frame->curr_parent to NULL when instantiation
is done
- expr.c (eval_var, eval_string_var): distinguish beteen instantiation and
editing mode, and use "active" values in the latter
- gui_frame.c (edit_var, edit_value, edit_value_list): display the value of the
variable or the active expression in the "X" field
- gui_frame.c (assignment_value_select_event, table_value_select_event,
loop_from_select_event, loop_to_select_event): pass the frame to edit_value
and edit_value_list
- expr.c (str_unit): since we may now accidently expose a wider range of
exponents, removed -2 ... 2 exponent range limitation
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5788 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-01-10 15:09:55 +02:00
|
|
|
static void edit_value(struct value *value, const struct frame *frame)
|
2009-08-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
inst_select_outside(value, unselect_value);
|
|
|
|
label_in_box_bg(value->widget, COLOR_EXPR_EDITING);
|
When editing a variable or value, the actual value is now shown. The choice
of active frame reference, row, and loop instance affects this value, as it
should.
- obj.c (run_loops): reset loop->curr_value to UNDEF when instantiation is done
- obj.c (generate_frame): reset frame->curr_parent to NULL when instantiation
is done
- expr.c (eval_var, eval_string_var): distinguish beteen instantiation and
editing mode, and use "active" values in the latter
- gui_frame.c (edit_var, edit_value, edit_value_list): display the value of the
variable or the active expression in the "X" field
- gui_frame.c (assignment_value_select_event, table_value_select_event,
loop_from_select_event, loop_to_select_event): pass the frame to edit_value
and edit_value_list
- expr.c (str_unit): since we may now accidently expose a wider range of
exponents, removed -2 ... 2 exponent range limitation
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5788 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-01-10 15:09:55 +02:00
|
|
|
show_value(value->expr, frame);
|
2009-08-12 02:26:38 +03:00
|
|
|
edit_nothing();
|
2010-01-03 02:36:52 +02:00
|
|
|
edit_expr(&value->expr, "Value");
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
When editing a variable or value, the actual value is now shown. The choice
of active frame reference, row, and loop instance affects this value, as it
should.
- obj.c (run_loops): reset loop->curr_value to UNDEF when instantiation is done
- obj.c (generate_frame): reset frame->curr_parent to NULL when instantiation
is done
- expr.c (eval_var, eval_string_var): distinguish beteen instantiation and
editing mode, and use "active" values in the latter
- gui_frame.c (edit_var, edit_value, edit_value_list): display the value of the
variable or the active expression in the "X" field
- gui_frame.c (assignment_value_select_event, table_value_select_event,
loop_from_select_event, loop_to_select_event): pass the frame to edit_value
and edit_value_list
- expr.c (str_unit): since we may now accidently expose a wider range of
exponents, removed -2 ... 2 exponent range limitation
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5788 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-01-10 15:09:55 +02:00
|
|
|
static void edit_value_list(struct value *value, const struct frame *frame,
|
2009-08-16 08:05:12 +03:00
|
|
|
void (*set_values)(void *user, const struct value *values, int n_values),
|
|
|
|
void *user)
|
|
|
|
{
|
|
|
|
inst_select_outside(value, unselect_value);
|
|
|
|
label_in_box_bg(value->widget, COLOR_VAR_EDITING);
|
When editing a variable or value, the actual value is now shown. The choice
of active frame reference, row, and loop instance affects this value, as it
should.
- obj.c (run_loops): reset loop->curr_value to UNDEF when instantiation is done
- obj.c (generate_frame): reset frame->curr_parent to NULL when instantiation
is done
- expr.c (eval_var, eval_string_var): distinguish beteen instantiation and
editing mode, and use "active" values in the latter
- gui_frame.c (edit_var, edit_value, edit_value_list): display the value of the
variable or the active expression in the "X" field
- gui_frame.c (assignment_value_select_event, table_value_select_event,
loop_from_select_event, loop_to_select_event): pass the frame to edit_value
and edit_value_list
- expr.c (str_unit): since we may now accidently expose a wider range of
exponents, removed -2 ... 2 exponent range limitation
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5788 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-01-10 15:09:55 +02:00
|
|
|
show_value(value->expr, frame);
|
2009-08-16 08:05:12 +03:00
|
|
|
edit_nothing();
|
2010-01-03 02:36:52 +02:00
|
|
|
edit_expr_list(value->expr, set_values, user, "Value(s)");
|
2009-08-16 08:05:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
/* ----- activator --------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *add_activator(GtkWidget *hbox, int active,
|
|
|
|
gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data),
|
2010-01-02 00:08:29 +02:00
|
|
|
gpointer user, const char *tooltip, const char *fmt, ...)
|
2009-08-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
va_list ap;
|
|
|
|
char buf[100];
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vsprintf(buf, fmt, ap);
|
|
|
|
va_end(ap);
|
2010-01-02 00:08:29 +02:00
|
|
|
label = label_in_box_new(buf, tooltip);
|
2009-08-08 22:35:16 +03:00
|
|
|
gtk_misc_set_padding(GTK_MISC(label), 2, 2);
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
|
|
|
label_in_box_bg(label,
|
|
|
|
active ? COLOR_CHOICE_SELECTED : COLOR_CHOICE_UNSELECTED);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), box_of_label(label),
|
|
|
|
FALSE, FALSE, 2);
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(label)),
|
|
|
|
"button_press_event", G_CALLBACK(cb), user);
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- assignments ------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-16 07:12:37 +03:00
|
|
|
static void set_col_values(void *user, const struct value *values,
|
|
|
|
int n_values)
|
|
|
|
{
|
|
|
|
struct var *var = user;
|
|
|
|
struct table *table = var->table;
|
|
|
|
struct value *value;
|
|
|
|
const struct var *walk;
|
|
|
|
struct row **row;
|
|
|
|
|
|
|
|
row = &table->rows;
|
|
|
|
while (values) {
|
|
|
|
if (!*row)
|
|
|
|
add_row_here(table, row);
|
|
|
|
value = (*row)->values;
|
|
|
|
for (walk = table->vars; walk != var; walk = walk->next)
|
|
|
|
value = value->next;
|
2009-08-16 08:05:12 +03:00
|
|
|
free_expr(value->expr);
|
2009-08-16 07:12:37 +03:00
|
|
|
value->expr = values->expr;
|
|
|
|
values = values->next;
|
|
|
|
row = &(*row)->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
static gboolean assignment_var_select_event(GtkWidget *widget,
|
|
|
|
GdkEventButton *event, gpointer data)
|
|
|
|
{
|
|
|
|
struct var *var = data;
|
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
2009-08-16 07:12:37 +03:00
|
|
|
edit_var(var, set_col_values, var, -1);
|
2009-08-08 22:35:16 +03:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
pop_up_single_var(var, event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean assignment_value_select_event(GtkWidget *widget,
|
|
|
|
GdkEventButton *event, gpointer data)
|
|
|
|
{
|
|
|
|
struct value *value = data;
|
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
2009-08-12 02:26:38 +03:00
|
|
|
edit_nothing();
|
When editing a variable or value, the actual value is now shown. The choice
of active frame reference, row, and loop instance affects this value, as it
should.
- obj.c (run_loops): reset loop->curr_value to UNDEF when instantiation is done
- obj.c (generate_frame): reset frame->curr_parent to NULL when instantiation
is done
- expr.c (eval_var, eval_string_var): distinguish beteen instantiation and
editing mode, and use "active" values in the latter
- gui_frame.c (edit_var, edit_value, edit_value_list): display the value of the
variable or the active expression in the "X" field
- gui_frame.c (assignment_value_select_event, table_value_select_event,
loop_from_select_event, loop_to_select_event): pass the frame to edit_value
and edit_value_list
- expr.c (str_unit): since we may now accidently expose a wider range of
exponents, removed -2 ... 2 exponent range limitation
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5788 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-01-10 15:09:55 +02:00
|
|
|
edit_value(value, value->row->table->vars->frame);
|
2009-08-08 22:35:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 11:34:17 +02:00
|
|
|
/*
|
|
|
|
* In tables, expressions in the active row have a COLOR_CHOICE_SELECTED
|
|
|
|
* background. While expressions in assignments are technically on the active
|
|
|
|
* (and only) row, we use COLOR_VAR_PASSIVE for better readability.
|
|
|
|
*/
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
static void build_assignment(GtkWidget *vbox, struct frame *frame,
|
|
|
|
struct table *table)
|
|
|
|
{
|
|
|
|
GtkWidget *hbox, *field;
|
|
|
|
char *expr;
|
|
|
|
|
|
|
|
if (!table->vars || table->vars->next)
|
|
|
|
return;
|
|
|
|
if (!table->rows || table->rows->next)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
2010-01-02 00:08:29 +02:00
|
|
|
field = label_in_box_new(table->vars->name,
|
|
|
|
"Variable name. Click to edit.");
|
2009-08-08 22:35:16 +03:00
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), box_of_label(field), FALSE, FALSE, 0);
|
|
|
|
label_in_box_bg(field, COLOR_VAR_PASSIVE);
|
|
|
|
table->vars->widget = field;
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(field)),
|
|
|
|
"button_press_event",
|
|
|
|
G_CALLBACK(assignment_var_select_event), table->vars);
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(" = "),
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
expr = unparse(table->rows->values->expr);
|
2010-01-02 00:08:29 +02:00
|
|
|
field = label_in_box_new(expr, "Variable value. Click to edit.");
|
2009-08-08 22:35:16 +03:00
|
|
|
free(expr);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), box_of_label(field), FALSE, FALSE, 0);
|
|
|
|
label_in_box_bg(field, COLOR_EXPR_PASSIVE);
|
|
|
|
table->rows->values->widget = field;
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(field)),
|
|
|
|
"button_press_event",
|
|
|
|
G_CALLBACK(assignment_value_select_event), table->rows->values);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- tables ------------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
|
|
|
static void select_row(struct row *row)
|
|
|
|
{
|
|
|
|
struct table *table = row->table;
|
|
|
|
struct value *value;
|
|
|
|
|
|
|
|
for (value = table->active_row->values; value; value = value->next)
|
|
|
|
label_in_box_bg(value->widget, COLOR_ROW_UNSELECTED);
|
|
|
|
table->active_row = row;
|
|
|
|
for (value = table->active_row->values; value; value = value->next)
|
|
|
|
label_in_box_bg(value->widget, COLOR_ROW_SELECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-16 08:05:12 +03:00
|
|
|
static void set_row_values(void *user, const struct value *values,
|
|
|
|
int n_values)
|
|
|
|
{
|
|
|
|
struct value *value = user;
|
|
|
|
struct row *row = value->row;
|
|
|
|
struct table *table = row->table;
|
|
|
|
struct var **var;
|
|
|
|
const struct value *walk;
|
|
|
|
int first = 1;
|
|
|
|
|
|
|
|
var = &table->vars;
|
|
|
|
for (walk = row->values; walk != value; walk = walk->next)
|
|
|
|
var = &(*var)->next;
|
|
|
|
|
|
|
|
while (values) {
|
|
|
|
if (!*var)
|
|
|
|
add_column_here(table, var);
|
|
|
|
if (first)
|
|
|
|
first = 0;
|
|
|
|
else
|
|
|
|
value = value->next;
|
|
|
|
free_expr(value->expr);
|
|
|
|
value->expr = values->expr;
|
|
|
|
values = values->next;
|
|
|
|
var = &(*var)->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
static gboolean table_var_select_event(GtkWidget *widget,
|
|
|
|
GdkEventButton *event, gpointer data)
|
|
|
|
{
|
|
|
|
struct var *var = data;
|
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
2009-08-16 07:12:37 +03:00
|
|
|
edit_var(var, set_col_values, var, -1);
|
2009-08-08 22:35:16 +03:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
pop_up_table_var(var, event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean table_value_select_event(GtkWidget *widget,
|
|
|
|
GdkEventButton *event, gpointer data)
|
|
|
|
{
|
|
|
|
struct value *value = data;
|
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
2009-08-12 02:26:38 +03:00
|
|
|
if (!value->row ||
|
|
|
|
value->row->table->active_row == value->row) {
|
|
|
|
edit_nothing();
|
When editing a variable or value, the actual value is now shown. The choice
of active frame reference, row, and loop instance affects this value, as it
should.
- obj.c (run_loops): reset loop->curr_value to UNDEF when instantiation is done
- obj.c (generate_frame): reset frame->curr_parent to NULL when instantiation
is done
- expr.c (eval_var, eval_string_var): distinguish beteen instantiation and
editing mode, and use "active" values in the latter
- gui_frame.c (edit_var, edit_value, edit_value_list): display the value of the
variable or the active expression in the "X" field
- gui_frame.c (assignment_value_select_event, table_value_select_event,
loop_from_select_event, loop_to_select_event): pass the frame to edit_value
and edit_value_list
- expr.c (str_unit): since we may now accidently expose a wider range of
exponents, removed -2 ... 2 exponent range limitation
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5788 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-01-10 15:09:55 +02:00
|
|
|
edit_value_list(value, value->row->table->vars->frame,
|
|
|
|
set_row_values, value);
|
2009-08-12 02:26:38 +03:00
|
|
|
} else {
|
2009-08-08 22:35:16 +03:00
|
|
|
select_row(value->row);
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
pop_up_table_value(value, event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-16 15:04:01 +03:00
|
|
|
static gboolean table_scroll_event(GtkWidget *widget, GdkEventScroll *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
struct table *table = data;
|
|
|
|
struct row *row, *last;
|
|
|
|
|
|
|
|
switch (event->direction) {
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
last = NULL;
|
|
|
|
for (row = table->rows;
|
|
|
|
row && (!last || row != table->active_row); row = row->next)
|
|
|
|
last = row;
|
|
|
|
table->active_row = last;
|
|
|
|
change_world();
|
|
|
|
break;
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
table->active_row = table->active_row->next;
|
|
|
|
if (!table->active_row)
|
|
|
|
table->active_row = table->rows;
|
|
|
|
change_world();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ignore */;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-19 12:27:46 +02:00
|
|
|
/* @@@ this function is too long */
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
static void build_table(GtkWidget *vbox, struct frame *frame,
|
2010-02-19 12:27:46 +02:00
|
|
|
struct table *table, int wrap_width)
|
2009-08-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
GtkWidget *tab, *field;
|
2010-02-19 16:00:55 +02:00
|
|
|
GtkWidget *evbox, *align, *sep;
|
2009-08-08 22:35:16 +03:00
|
|
|
struct var *var;
|
|
|
|
struct row *row;
|
|
|
|
struct value *value;
|
|
|
|
int n_vars = 0, n_rows = 0;
|
2010-02-19 16:00:55 +02:00
|
|
|
int n_var, n_row, pos;
|
2009-08-08 22:35:16 +03:00
|
|
|
char *expr;
|
2010-02-19 12:27:46 +02:00
|
|
|
GdkColor color;
|
2009-08-08 22:35:16 +03:00
|
|
|
|
|
|
|
for (var = table->vars; var; var = var->next)
|
|
|
|
n_vars++;
|
|
|
|
for (row = table->rows; row; row = row->next)
|
|
|
|
n_rows++;
|
|
|
|
|
|
|
|
if (n_vars == 1 && n_rows == 1)
|
|
|
|
return;
|
|
|
|
|
2010-02-19 12:27:46 +02:00
|
|
|
var = table->vars;
|
|
|
|
n_var = 0;
|
2009-08-08 22:35:16 +03:00
|
|
|
n_vars = 0;
|
2010-02-19 12:27:46 +02:00
|
|
|
while (var) {
|
2010-02-19 16:00:55 +02:00
|
|
|
if (n_vars) {
|
|
|
|
gtk_table_resize(GTK_TABLE(tab), n_rows, n_vars+1);
|
|
|
|
} else {
|
2010-02-19 12:27:46 +02:00
|
|
|
evbox = gtk_event_box_new();
|
|
|
|
align = gtk_alignment_new(0, 0, 0, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(align), evbox);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), align,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
|
2010-02-19 16:00:55 +02:00
|
|
|
tab = gtk_table_new(n_rows+1, n_vars, FALSE);
|
2010-02-19 12:27:46 +02:00
|
|
|
gtk_container_add(GTK_CONTAINER(evbox), tab);
|
|
|
|
color = get_color(COLOR_VAR_TABLE_SEP);
|
|
|
|
gtk_widget_modify_bg(GTK_WIDGET(evbox),
|
|
|
|
GTK_STATE_NORMAL, &color);
|
|
|
|
|
|
|
|
gtk_table_set_row_spacings(GTK_TABLE(tab), 1);
|
|
|
|
gtk_table_set_col_spacings(GTK_TABLE(tab), 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-01-02 00:08:29 +02:00
|
|
|
field = label_in_box_new(var->name,
|
|
|
|
"Variable (column) name. Click to edit.");
|
2009-08-08 22:35:16 +03:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tab), box_of_label(field),
|
2010-02-19 16:00:55 +02:00
|
|
|
n_vars, n_vars+1, 0, 1);
|
2009-08-08 22:35:16 +03:00
|
|
|
label_in_box_bg(field, COLOR_VAR_PASSIVE);
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(field)),
|
|
|
|
"button_press_event",
|
|
|
|
G_CALLBACK(table_var_select_event), var);
|
2009-08-16 15:04:01 +03:00
|
|
|
g_signal_connect(G_OBJECT(box_of_label(field)),
|
|
|
|
"scroll_event",
|
|
|
|
G_CALLBACK(table_scroll_event), table);
|
2009-08-08 22:35:16 +03:00
|
|
|
var->widget = field;
|
2010-02-19 12:27:46 +02:00
|
|
|
|
|
|
|
n_row = 0;
|
|
|
|
for (row = table->rows; row; row = row->next) {
|
|
|
|
value = row->values;
|
|
|
|
for (pos = 0; pos != n_var; pos++)
|
|
|
|
value = value->next;
|
2009-08-08 22:35:16 +03:00
|
|
|
expr = unparse(value->expr);
|
2010-01-02 00:08:29 +02:00
|
|
|
field = label_in_box_new(expr,
|
|
|
|
"Variable value. Click to select row or to edit.");
|
2009-08-08 22:35:16 +03:00
|
|
|
free(expr);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tab),
|
|
|
|
box_of_label(field),
|
2010-02-19 16:00:55 +02:00
|
|
|
n_vars, n_vars+1,
|
2010-02-19 12:27:46 +02:00
|
|
|
n_row+1, n_row+2);
|
2009-08-08 22:35:16 +03:00
|
|
|
label_in_box_bg(field, table->active_row == row ?
|
|
|
|
COLOR_ROW_SELECTED : COLOR_ROW_UNSELECTED);
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(field)),
|
|
|
|
"button_press_event",
|
|
|
|
G_CALLBACK(table_value_select_event), value);
|
2009-08-16 15:04:01 +03:00
|
|
|
g_signal_connect(G_OBJECT(box_of_label(field)),
|
|
|
|
"scroll_event",
|
|
|
|
G_CALLBACK(table_scroll_event), table);
|
2009-08-08 22:35:16 +03:00
|
|
|
value->widget = field;
|
2010-02-19 12:27:46 +02:00
|
|
|
n_row++;
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
2010-02-19 12:27:46 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Wrap tables wider than the screen area available for
|
|
|
|
* variables and tables. Don't wrap before having output at
|
|
|
|
* least one column.
|
|
|
|
*/
|
|
|
|
if (n_vars && get_widget_width(tab) > wrap_width) {
|
|
|
|
/*
|
|
|
|
* Resizing alone doesn't hide extra columns. We have
|
|
|
|
* to explicitly remove their content as well.
|
|
|
|
*/
|
|
|
|
gtk_container_remove(GTK_CONTAINER(tab),
|
|
|
|
box_of_label(var->widget));
|
|
|
|
for (row = table->rows; row; row = row->next) {
|
|
|
|
value = row->values;
|
|
|
|
for (pos = 0; pos != n_var; pos++)
|
|
|
|
value = value->next;
|
|
|
|
gtk_container_remove(GTK_CONTAINER(tab),
|
|
|
|
box_of_label(value->widget));
|
|
|
|
}
|
2010-02-19 16:00:55 +02:00
|
|
|
gtk_table_resize(GTK_TABLE(tab), n_rows, n_vars);
|
|
|
|
|
|
|
|
sep = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), sep,
|
|
|
|
FALSE, FALSE, 1);
|
2010-02-19 12:27:46 +02:00
|
|
|
|
|
|
|
n_vars = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var = var->next;
|
|
|
|
n_var++;
|
|
|
|
n_vars++;
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
2010-02-19 12:27:46 +02:00
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- loops ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2009-08-16 07:12:37 +03:00
|
|
|
static void set_loop_values(void *user, const struct value *values,
|
|
|
|
int n_values)
|
|
|
|
{
|
|
|
|
struct loop *loop = user;
|
|
|
|
|
|
|
|
switch (n_values) {
|
|
|
|
case 2:
|
|
|
|
if (loop->to.expr)
|
|
|
|
free_expr(loop->to.expr);
|
|
|
|
loop->to.expr = values->next->expr;
|
|
|
|
/* fall through */
|
|
|
|
case 1:
|
|
|
|
if (loop->from.expr)
|
|
|
|
free_expr(loop->from.expr);
|
|
|
|
loop->from.expr = values->expr;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
static gboolean loop_var_select_event(GtkWidget *widget,
|
|
|
|
GdkEventButton *event, gpointer data)
|
|
|
|
{
|
|
|
|
struct loop *loop = data;
|
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
2009-08-16 07:12:37 +03:00
|
|
|
edit_var(&loop->var, set_loop_values, loop, 2);
|
2009-08-08 22:35:16 +03:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
pop_up_loop_var(loop, event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean loop_from_select_event(GtkWidget *widget,
|
|
|
|
GdkEventButton *event, gpointer data)
|
|
|
|
{
|
|
|
|
struct loop *loop = data;
|
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
2009-08-12 02:26:38 +03:00
|
|
|
edit_nothing();
|
When editing a variable or value, the actual value is now shown. The choice
of active frame reference, row, and loop instance affects this value, as it
should.
- obj.c (run_loops): reset loop->curr_value to UNDEF when instantiation is done
- obj.c (generate_frame): reset frame->curr_parent to NULL when instantiation
is done
- expr.c (eval_var, eval_string_var): distinguish beteen instantiation and
editing mode, and use "active" values in the latter
- gui_frame.c (edit_var, edit_value, edit_value_list): display the value of the
variable or the active expression in the "X" field
- gui_frame.c (assignment_value_select_event, table_value_select_event,
loop_from_select_event, loop_to_select_event): pass the frame to edit_value
and edit_value_list
- expr.c (str_unit): since we may now accidently expose a wider range of
exponents, removed -2 ... 2 exponent range limitation
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5788 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-01-10 15:09:55 +02:00
|
|
|
edit_value(&loop->from, loop->var.frame);
|
2009-08-08 22:35:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean loop_to_select_event(GtkWidget *widget,
|
|
|
|
GdkEventButton *event, gpointer data)
|
|
|
|
{
|
|
|
|
struct loop *loop = data;
|
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
2009-08-12 02:26:38 +03:00
|
|
|
edit_nothing();
|
When editing a variable or value, the actual value is now shown. The choice
of active frame reference, row, and loop instance affects this value, as it
should.
- obj.c (run_loops): reset loop->curr_value to UNDEF when instantiation is done
- obj.c (generate_frame): reset frame->curr_parent to NULL when instantiation
is done
- expr.c (eval_var, eval_string_var): distinguish beteen instantiation and
editing mode, and use "active" values in the latter
- gui_frame.c (edit_var, edit_value, edit_value_list): display the value of the
variable or the active expression in the "X" field
- gui_frame.c (assignment_value_select_event, table_value_select_event,
loop_from_select_event, loop_to_select_event): pass the frame to edit_value
and edit_value_list
- expr.c (str_unit): since we may now accidently expose a wider range of
exponents, removed -2 ... 2 exponent range limitation
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5788 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-01-10 15:09:55 +02:00
|
|
|
edit_value(&loop->to, loop->var.frame);
|
2009-08-08 22:35:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean loop_select_event(GtkWidget *widget, GdkEventButton *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
struct loop *loop = data;
|
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
|
|
|
loop->active =
|
|
|
|
(long) gtk_object_get_data(GTK_OBJECT(widget), "value");
|
|
|
|
change_world();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-09 04:51:20 +03:00
|
|
|
static gboolean loop_scroll_event(GtkWidget *widget, GdkEventScroll *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
struct loop *loop = data;
|
|
|
|
|
|
|
|
switch (event->direction) {
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
if (loop->active < loop->iterations-1) {
|
|
|
|
loop->active++;
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
if (loop->active) {
|
|
|
|
loop->active--;
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ignore */;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
static void build_loop(GtkWidget *vbox, struct frame *frame,
|
|
|
|
struct loop *loop)
|
|
|
|
{
|
|
|
|
GtkWidget *hbox, *field, *label;
|
|
|
|
char *expr;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
2010-01-02 00:08:29 +02:00
|
|
|
field = label_in_box_new(loop->var.name,
|
|
|
|
"Variable name. Click to edit.");
|
2009-08-08 22:35:16 +03:00
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), box_of_label(field), FALSE, FALSE, 0);
|
|
|
|
label_in_box_bg(field, COLOR_VAR_PASSIVE);
|
2009-08-13 12:30:16 +03:00
|
|
|
if (instantiation_error == loop)
|
|
|
|
label_in_box_fg(field, COLOR_ITEM_ERROR);
|
2009-08-08 22:35:16 +03:00
|
|
|
g_signal_connect(G_OBJECT(box_of_label(field)),
|
|
|
|
"button_press_event",
|
|
|
|
G_CALLBACK(loop_var_select_event), loop);
|
|
|
|
loop->var.widget = field;
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(" = "),
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
expr = unparse(loop->from.expr);
|
2010-01-02 00:08:29 +02:00
|
|
|
field = label_in_box_new(expr,
|
|
|
|
"Start value of loop. Click to edit.");
|
2009-08-08 22:35:16 +03:00
|
|
|
free(expr);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), box_of_label(field), FALSE, FALSE, 0);
|
|
|
|
label_in_box_bg(field, COLOR_EXPR_PASSIVE);
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(field)),
|
|
|
|
"button_press_event",
|
|
|
|
G_CALLBACK(loop_from_select_event), loop);
|
|
|
|
loop->from.widget = field;
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(" ... "),
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
expr = unparse(loop->to.expr);
|
2010-01-02 00:08:29 +02:00
|
|
|
field = label_in_box_new(expr, "End value of loop. Click to edit.");
|
2009-08-08 22:35:16 +03:00
|
|
|
free(expr);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), box_of_label(field), FALSE, FALSE, 0);
|
|
|
|
label_in_box_bg(field, COLOR_EXPR_PASSIVE);
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(field)),
|
|
|
|
"button_press_event",
|
|
|
|
G_CALLBACK(loop_to_select_event), loop);
|
|
|
|
loop->to.widget = field;
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(" ("),
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
for (i = 0; i != loop->iterations; i++) {
|
|
|
|
label = add_activator(hbox, loop->active == i,
|
2010-01-02 00:08:29 +02:00
|
|
|
loop_select_event, loop,
|
|
|
|
"Loop value. Click to make active.",
|
|
|
|
"%g", loop->n+i);
|
2009-08-08 22:35:16 +03:00
|
|
|
gtk_object_set_data(GTK_OBJECT(box_of_label(label)), "value",
|
|
|
|
(gpointer) (long) i);
|
2009-08-09 04:51:20 +03:00
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(label)),
|
|
|
|
"scroll_event",
|
|
|
|
G_CALLBACK(loop_scroll_event), loop);
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(")"),
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- the list of variables, tables, and loops -------------------------- */
|
|
|
|
|
|
|
|
|
2010-02-19 12:27:46 +02:00
|
|
|
static GtkWidget *build_vars(struct frame *frame, int wrap_width)
|
2009-08-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
GtkWidget *vbox;
|
|
|
|
struct table *table;
|
|
|
|
struct loop *loop;
|
|
|
|
|
2009-08-12 13:45:52 +03:00
|
|
|
vbox = gtk_vbox_new(FALSE, 0);
|
2009-08-08 22:35:16 +03:00
|
|
|
for (table = frame->tables; table; table = table->next) {
|
|
|
|
add_sep(vbox, 3);
|
|
|
|
build_assignment(vbox, frame, table);
|
2010-02-19 12:27:46 +02:00
|
|
|
build_table(vbox, frame, table, wrap_width);
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
for (loop = frame->loops; loop; loop = loop->next) {
|
|
|
|
add_sep(vbox, 3);
|
|
|
|
build_loop(vbox, frame, loop);
|
|
|
|
}
|
|
|
|
return vbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-12 13:45:52 +03:00
|
|
|
/* ----- items ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static void set_item_color(struct inst *inst, const char *color)
|
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
if (inst->vec)
|
|
|
|
label = inst->vec->list_widget;
|
|
|
|
else
|
|
|
|
label = inst->obj->list_widget;
|
2009-08-14 13:18:40 +03:00
|
|
|
if (label)
|
|
|
|
label_in_box_bg(box_of_label(label), color);
|
2009-08-12 13:45:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void gui_frame_select_inst(struct inst *inst)
|
|
|
|
{
|
|
|
|
set_item_color(inst, COLOR_ITEM_SELECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void gui_frame_deselect_inst(struct inst *inst)
|
|
|
|
{
|
|
|
|
set_item_color(inst, COLOR_ITEM_NORMAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-12 14:26:59 +03:00
|
|
|
static gboolean item_select_vec(GtkWidget *widget, GdkEventButton *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2009-08-13 13:57:39 +03:00
|
|
|
struct vec *vec = data;
|
2009-08-12 14:26:59 +03:00
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
|
|
|
inst_select_vec(vec);
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean item_select_obj(GtkWidget *widget, GdkEventButton *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2009-08-13 13:57:39 +03:00
|
|
|
struct obj *obj = data;
|
2009-08-12 14:26:59 +03:00
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
|
|
|
inst_select_obj(obj);
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *item_label(GtkWidget *tab, char *s, int col, int row,
|
|
|
|
gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data),
|
|
|
|
gpointer data)
|
2009-08-12 13:45:52 +03:00
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
|
2010-01-02 00:08:29 +02:00
|
|
|
label = label_in_box_new(s, "Click to select.");
|
2009-08-12 20:01:40 +03:00
|
|
|
gtk_misc_set_padding(GTK_MISC(label), 0, 0);
|
2009-08-12 13:45:52 +03:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
|
|
|
gtk_widget_modify_font(label, item_list_font);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tab), box_of_label(label),
|
|
|
|
col, col+1, row, row+1);
|
|
|
|
label_in_box_bg(box_of_label(label), COLOR_ITEM_NORMAL);
|
2009-08-12 14:26:59 +03:00
|
|
|
|
|
|
|
if (cb)
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(label)),
|
|
|
|
"button_press_event", G_CALLBACK(cb), data);
|
|
|
|
|
2009-08-12 13:45:52 +03:00
|
|
|
free(s);
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *build_items(struct frame *frame)
|
|
|
|
{
|
2009-08-12 17:44:17 +03:00
|
|
|
GtkWidget *vbox, *hbox, *tab;
|
2009-08-12 13:45:52 +03:00
|
|
|
struct order *order, *item;
|
|
|
|
struct vec *vec;
|
|
|
|
struct obj *obj;
|
|
|
|
int n;
|
|
|
|
char *s, *t;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
for (vec = frame->vecs; vec; vec = vec->next)
|
|
|
|
n++;
|
|
|
|
for (obj = frame->objs; obj; obj = obj->next)
|
|
|
|
if (obj->type != ot_meas)
|
|
|
|
n++;
|
|
|
|
|
2009-08-12 17:44:17 +03:00
|
|
|
vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
add_sep(vbox, 3);
|
|
|
|
|
2009-08-12 13:45:52 +03:00
|
|
|
hbox = gtk_hbox_new(FALSE, 0);
|
2009-08-12 17:44:17 +03:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
2009-08-12 13:45:52 +03:00
|
|
|
|
|
|
|
tab = gtk_table_new(n, 2, FALSE);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), tab, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
order = order_frame(frame);
|
|
|
|
n = 0;
|
|
|
|
for (item = order; item->vec || item->obj; item++) {
|
|
|
|
if (item->obj) {
|
|
|
|
s = print_obj(item->obj, item->vec);
|
2009-08-12 14:26:59 +03:00
|
|
|
item->obj->list_widget = item_label(tab, s, 1, n,
|
|
|
|
item_select_obj, item->obj);
|
2009-08-13 12:30:16 +03:00
|
|
|
if (item->obj == instantiation_error)
|
|
|
|
label_in_box_fg(item->obj->list_widget,
|
|
|
|
COLOR_ITEM_ERROR);
|
2009-08-12 13:45:52 +03:00
|
|
|
} else {
|
2009-11-27 21:55:25 +02:00
|
|
|
t = stralloc_printf("%s: ", print_label(item->vec));
|
2009-08-12 14:26:59 +03:00
|
|
|
item_label(tab, t, 0, n, NULL, NULL);
|
2009-08-12 13:45:52 +03:00
|
|
|
|
|
|
|
s = print_vec(item->vec);
|
2009-08-12 14:26:59 +03:00
|
|
|
item->vec->list_widget = item_label(tab, s, 1, n,
|
|
|
|
item_select_vec, item->vec);
|
2009-08-13 12:30:16 +03:00
|
|
|
if (item->vec == instantiation_error)
|
|
|
|
label_in_box_fg(item->vec->list_widget,
|
|
|
|
COLOR_ITEM_ERROR);
|
2009-08-12 13:45:52 +03:00
|
|
|
}
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
free(order);
|
|
|
|
|
2009-08-12 17:44:17 +03:00
|
|
|
return vbox;
|
2009-08-12 13:45:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *build_meas(struct frame *frame)
|
|
|
|
{
|
2009-08-12 17:44:17 +03:00
|
|
|
GtkWidget *vbox, *hbox, *tab;
|
2009-08-12 13:45:52 +03:00
|
|
|
struct obj *obj;
|
|
|
|
int n;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
for (obj = frame->objs; obj; obj = obj->next)
|
|
|
|
if (obj->type == ot_meas)
|
|
|
|
n++;
|
|
|
|
|
2009-08-12 17:44:17 +03:00
|
|
|
vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
add_sep(vbox, 3);
|
|
|
|
|
2009-08-12 13:45:52 +03:00
|
|
|
hbox = gtk_hbox_new(FALSE, 0);
|
2009-08-12 17:44:17 +03:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
2009-08-12 13:45:52 +03:00
|
|
|
|
|
|
|
tab = gtk_table_new(n, 2, FALSE);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), tab, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
for (obj = frame->objs; obj; obj = obj->next) {
|
|
|
|
if (obj->type != ot_meas)
|
|
|
|
continue;
|
|
|
|
s = print_meas(obj);
|
2009-08-12 14:26:59 +03:00
|
|
|
obj->list_widget = item_label(tab, s, 0, n,
|
|
|
|
item_select_obj, obj);
|
2009-08-13 12:30:16 +03:00
|
|
|
if (obj == instantiation_error)
|
|
|
|
label_in_box_fg(obj->list_widget, COLOR_ITEM_ERROR);
|
2009-08-12 13:45:52 +03:00
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
2009-08-12 17:44:17 +03:00
|
|
|
return vbox;
|
2009-08-12 13:45:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-14 13:18:40 +03:00
|
|
|
static void dont_build_items(struct frame *frame)
|
|
|
|
{
|
|
|
|
struct vec *vec;
|
|
|
|
struct obj *obj;
|
|
|
|
|
|
|
|
for (vec = frame->vecs; vec; vec = vec->next)
|
|
|
|
vec->list_widget = NULL;
|
|
|
|
for (obj = frame->objs; obj; obj = obj->next)
|
|
|
|
obj->list_widget = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-17 23:42:51 +03:00
|
|
|
/* ----- package name ------------------------------------------------------ */
|
2009-08-08 22:35:16 +03:00
|
|
|
|
|
|
|
|
2009-08-17 23:42:51 +03:00
|
|
|
static int validate_pkg_name(const char *s, void *ctx)
|
2009-08-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
if (!*s)
|
|
|
|
return 0;
|
2009-08-15 01:12:16 +03:00
|
|
|
while (*s) {
|
|
|
|
if (*s < 32 || *s > 126)
|
2009-08-08 22:35:16 +03:00
|
|
|
return 0;
|
2009-08-15 01:12:16 +03:00
|
|
|
s++;
|
|
|
|
}
|
2009-08-08 22:35:16 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-17 23:42:51 +03:00
|
|
|
static void unselect_pkg_name(void *data)
|
2009-08-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
GtkWidget *widget = data;
|
|
|
|
|
|
|
|
label_in_box_bg(widget, COLOR_PART_NAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-17 23:42:51 +03:00
|
|
|
static gboolean pkg_name_edit_event(GtkWidget *widget, GdkEventButton *event,
|
2009-08-08 22:35:16 +03:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
2009-08-17 23:42:51 +03:00
|
|
|
inst_select_outside(widget, unselect_pkg_name);
|
2009-08-08 22:35:16 +03:00
|
|
|
label_in_box_bg(widget, COLOR_PART_NAME_EDITING);
|
2010-01-03 02:36:52 +02:00
|
|
|
status_set_type_entry(NULL, "package =");
|
2010-01-03 01:27:36 +02:00
|
|
|
status_set_name("Package name (actual)", "%s", pkg_name);
|
2009-08-12 02:26:38 +03:00
|
|
|
edit_nothing();
|
2010-01-03 02:36:52 +02:00
|
|
|
edit_name(&pkg_name, validate_pkg_name, NULL,
|
|
|
|
"Package name (template)");
|
2009-08-08 22:35:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-17 23:42:51 +03:00
|
|
|
static GtkWidget *build_pkg_name(void)
|
2009-08-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
|
2010-01-02 00:08:29 +02:00
|
|
|
label = label_in_box_new(pkg_name,
|
|
|
|
"Package name. (Template) Click to edit.");
|
2009-08-08 22:35:16 +03:00
|
|
|
gtk_misc_set_padding(GTK_MISC(label), 2, 2);
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
|
|
|
|
|
|
|
label_in_box_bg(label, COLOR_PART_NAME);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(label)),
|
2009-08-17 23:42:51 +03:00
|
|
|
"button_press_event", G_CALLBACK(pkg_name_edit_event), NULL);
|
2009-08-08 22:35:16 +03:00
|
|
|
|
|
|
|
return box_of_label(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-17 23:42:51 +03:00
|
|
|
/* ----- packages ---------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean pkg_scroll_event(GtkWidget *widget, GdkEventScroll *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
struct pkg *pkg, *last;
|
|
|
|
|
|
|
|
switch (event->direction) {
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
if (active_pkg->next)
|
|
|
|
active_pkg = active_pkg->next;
|
|
|
|
else
|
|
|
|
active_pkg = pkgs->next;
|
|
|
|
change_world();
|
|
|
|
break;
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
last = NULL;
|
|
|
|
for (pkg = pkgs->next; pkg && (!last || pkg != active_pkg);
|
|
|
|
pkg = pkg->next)
|
|
|
|
last = pkg;
|
|
|
|
active_pkg = last;
|
|
|
|
change_world();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ignore */;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean pkg_select_event(GtkWidget *widget, GdkEventButton *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
struct pkg *pkg = data;
|
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
|
|
|
active_pkg = pkg;
|
|
|
|
/* @@@ we could actually skip instantiation here */
|
|
|
|
change_world();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *build_pkg_names(void)
|
|
|
|
{
|
|
|
|
GtkWidget *hbox;
|
|
|
|
struct pkg *pkg;
|
|
|
|
GtkWidget *field;
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new(FALSE, 0);
|
|
|
|
for (pkg = pkgs; pkg; pkg = pkg->next)
|
|
|
|
if (pkg->name) {
|
|
|
|
field = add_activator(hbox, pkg == active_pkg,
|
|
|
|
pkg_select_event, pkg,
|
2010-01-02 00:08:29 +02:00
|
|
|
"Package name. Click to make active.",
|
2009-08-17 23:42:51 +03:00
|
|
|
"%s", pkg->name);
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(field)),
|
|
|
|
"scroll_event",
|
|
|
|
G_CALLBACK(pkg_scroll_event), NULL);
|
|
|
|
}
|
|
|
|
return hbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
/* ----- frame labels ------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
|
|
|
static int validate_frame_name(const char *s, void *ctx)
|
|
|
|
{
|
|
|
|
struct frame *f;
|
|
|
|
|
|
|
|
if (!is_id(s))
|
|
|
|
return 0;
|
|
|
|
for (f = frames; f; f = f->next)
|
|
|
|
if (f->name && !strcmp(f->name, s))
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void unselect_frame(void *data)
|
|
|
|
{
|
|
|
|
struct frame *frame= data;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* "unselect" means in this context that the selection has moved
|
|
|
|
* elsewhere. However, this does not necessarily change the frame.
|
|
|
|
* (And, in fact, since we rebuild the frame list anyway, the color
|
|
|
|
* change here doesn't matter if selecting a different frame.)
|
|
|
|
* So we revert from "editing" to "selected".
|
|
|
|
*/
|
|
|
|
label_in_box_bg(frame->label, COLOR_FRAME_SELECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void edit_frame(struct frame *frame)
|
|
|
|
{
|
2010-01-03 01:27:36 +02:00
|
|
|
const char *tip;
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
inst_select_outside(frame, unselect_frame);
|
|
|
|
label_in_box_bg(frame->label, COLOR_FRAME_EDITING);
|
2010-01-03 01:27:36 +02:00
|
|
|
tip = "Frame name";
|
2010-01-03 02:36:52 +02:00
|
|
|
status_set_type_entry(NULL, "name =");
|
2010-01-03 01:27:36 +02:00
|
|
|
status_set_name(tip, "%s", frame->name);
|
2009-08-12 02:26:38 +03:00
|
|
|
edit_nothing();
|
2010-01-03 02:36:52 +02:00
|
|
|
edit_unique(&frame->name, validate_frame_name, frame, tip);
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void select_frame(struct frame *frame)
|
|
|
|
{
|
|
|
|
if (active_frame)
|
|
|
|
label_in_box_bg(active_frame->label, COLOR_FRAME_UNSELECTED);
|
|
|
|
active_frame = frame;
|
|
|
|
tool_frame_update();
|
|
|
|
change_world();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean frame_select_event(GtkWidget *widget, GdkEventButton *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
struct frame *frame = data;
|
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
|
|
|
if (active_frame != frame)
|
|
|
|
select_frame(frame);
|
|
|
|
else {
|
2009-08-12 02:26:38 +03:00
|
|
|
if (active_frame->name) {
|
|
|
|
edit_nothing();
|
2009-08-08 22:35:16 +03:00
|
|
|
edit_frame(frame);
|
2009-08-12 02:26:38 +03:00
|
|
|
}
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
pop_up_frame(frame, event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *build_frame_label(struct frame *frame)
|
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
|
2010-01-02 00:08:29 +02:00
|
|
|
label = label_in_box_new(frame->name ? frame->name : "(root)",
|
|
|
|
frame->name ? "Frame name. Click to select or edit." :
|
|
|
|
"Root frame. Click to select.");
|
2009-08-08 22:35:16 +03:00
|
|
|
gtk_misc_set_padding(GTK_MISC(label), 2, 2);
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
|
|
|
|
|
|
|
label_in_box_bg(label, active_frame == frame ?
|
|
|
|
COLOR_FRAME_SELECTED : COLOR_FRAME_UNSELECTED);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(box_of_label(label)),
|
|
|
|
"button_press_event", G_CALLBACK(frame_select_event), frame);
|
|
|
|
frame->label = label;
|
|
|
|
|
|
|
|
return box_of_label(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- frame references -------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean frame_ref_select_event(GtkWidget *widget, GdkEventButton *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
struct obj *obj = data;
|
|
|
|
|
|
|
|
switch (event->button) {
|
|
|
|
case 1:
|
|
|
|
obj->u.frame.ref->active_ref = data;
|
|
|
|
change_world();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *build_frame_refs(const struct frame *frame)
|
|
|
|
{
|
|
|
|
GtkWidget *hbox;
|
|
|
|
struct obj *obj;
|
2010-01-02 00:08:29 +02:00
|
|
|
char *tooltip;
|
2009-08-08 22:35:16 +03:00
|
|
|
|
|
|
|
hbox = gtk_hbox_new(FALSE, 0);
|
|
|
|
for (obj = frame->objs; obj; obj = obj->next)
|
2010-01-02 00:08:29 +02:00
|
|
|
if (obj->type == ot_frame &&
|
|
|
|
obj->u.frame.ref == active_frame) {
|
|
|
|
tooltip = stralloc_printf(
|
|
|
|
"Frame <b>%s</b> is referenced here. "
|
|
|
|
"Click to make active.", active_frame->name);
|
2009-08-08 22:35:16 +03:00
|
|
|
add_activator(hbox,
|
|
|
|
obj == obj->u.frame.ref->active_ref,
|
|
|
|
frame_ref_select_event, obj,
|
2010-01-02 00:08:29 +02:00
|
|
|
tooltip,
|
2009-08-08 22:35:16 +03:00
|
|
|
"%d", obj->u.frame.lineno);
|
2010-01-02 00:08:29 +02:00
|
|
|
free(tooltip);
|
|
|
|
}
|
2009-08-08 22:35:16 +03:00
|
|
|
return hbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----- frames ------------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
2010-02-19 12:27:46 +02:00
|
|
|
void build_frames(GtkWidget *vbox, int wrap_width)
|
2009-08-08 22:35:16 +03:00
|
|
|
{
|
|
|
|
struct frame *frame;
|
2009-08-17 23:42:51 +03:00
|
|
|
GtkWidget *hbox, *tab, *label, *packages, *refs, *vars, *items, *meas;
|
2009-08-08 22:35:16 +03:00
|
|
|
int n = 0;
|
2010-02-19 12:27:46 +02:00
|
|
|
int max_name_width, name_width;
|
2009-08-08 22:35:16 +03:00
|
|
|
|
|
|
|
destroy_all_children(GTK_CONTAINER(vbox));
|
|
|
|
for (frame = frames; frame; frame = frame->next)
|
|
|
|
n++;
|
|
|
|
|
2009-08-12 13:45:52 +03:00
|
|
|
hbox = gtk_hbox_new(FALSE, 0);
|
|
|
|
|
2009-08-12 17:44:17 +03:00
|
|
|
tab = gtk_table_new(n*2+3, 2, FALSE);
|
2009-08-08 22:35:16 +03:00
|
|
|
gtk_table_set_row_spacings(GTK_TABLE(tab), 1);
|
|
|
|
gtk_table_set_col_spacings(GTK_TABLE(tab), 1);
|
2009-08-12 13:45:52 +03:00
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), tab, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
2009-08-08 22:35:16 +03:00
|
|
|
|
2009-08-17 23:42:51 +03:00
|
|
|
label = build_pkg_name();
|
2009-08-08 22:35:16 +03:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tab), label, 0, 1, 0, 1);
|
2010-02-19 12:27:46 +02:00
|
|
|
max_name_width = get_widget_width(label);
|
2009-08-08 22:35:16 +03:00
|
|
|
|
2009-08-17 23:42:51 +03:00
|
|
|
packages = build_pkg_names();
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tab), packages, 1, 2, 0, 1);
|
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
n = 0;
|
|
|
|
for (frame = root_frame; frame; frame = frame->prev) {
|
|
|
|
label = build_frame_label(frame);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tab), label,
|
|
|
|
0, 1, n*2+1, n*2+2);
|
2010-02-19 12:27:46 +02:00
|
|
|
n++;
|
|
|
|
name_width = get_widget_width(label);
|
|
|
|
if (name_width > max_name_width)
|
|
|
|
max_name_width = name_width;
|
|
|
|
}
|
2009-08-08 22:35:16 +03:00
|
|
|
|
2010-02-19 12:27:46 +02:00
|
|
|
wrap_width -= max_name_width+FRAME_AREA_MISC_WIDTH;
|
|
|
|
n = 0;
|
|
|
|
for (frame = root_frame; frame; frame = frame->prev) {
|
2009-08-08 22:35:16 +03:00
|
|
|
refs = build_frame_refs(frame);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tab), refs,
|
|
|
|
1, 2, n*2+1, n*2+2);
|
|
|
|
|
2009-08-12 17:44:17 +03:00
|
|
|
if (show_vars) {
|
2010-02-19 12:27:46 +02:00
|
|
|
vars = build_vars(frame, wrap_width);
|
2009-08-12 17:44:17 +03:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tab), vars,
|
|
|
|
1, 2, n*2+2, n*2+3);
|
2009-08-14 13:18:40 +03:00
|
|
|
dont_build_items(frame);
|
2009-08-12 17:44:17 +03:00
|
|
|
} else {
|
|
|
|
items = build_items(frame);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tab), items,
|
|
|
|
1, 2, n*2+2, n*2+3);
|
|
|
|
}
|
2009-08-12 13:45:52 +03:00
|
|
|
|
2009-08-08 22:35:16 +03:00
|
|
|
n++;
|
|
|
|
}
|
2009-08-12 13:45:52 +03:00
|
|
|
|
2009-08-12 17:44:17 +03:00
|
|
|
if (!show_vars) {
|
|
|
|
meas = build_meas(root_frame);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tab), meas,
|
|
|
|
1, 2, n*2+2, n*2+3);
|
|
|
|
}
|
2009-08-12 13:45:52 +03:00
|
|
|
|
|
|
|
gtk_widget_show_all(hbox);
|
2009-08-08 22:35:16 +03:00
|
|
|
}
|