1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-18 01:37:30 +02:00

- moved building of an activator into new function add_activator

- added loop value selection (quick and dirty)



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5379 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-08-03 22:58:15 +00:00
parent 3c026696d4
commit 96d41a37ab
4 changed files with 61 additions and 20 deletions

76
gui.c
View File

@ -140,6 +140,33 @@ static void edit_value(struct value *value)
} }
/* ----- activator --------------------------------------------------------- */
static GtkWidget *add_activator(GtkWidget *hbox, int active,
gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data),
gpointer user, const char *fmt, ...)
{
GtkWidget *label;
va_list ap;
char buf[100];
va_start(ap, fmt);
vsprintf(buf, fmt, ap);
va_end(ap);
label = label_in_box_new(buf);
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 ------------------------------------------------------- */ /* ----- assignments ------------------------------------------------------- */
@ -336,11 +363,23 @@ static gboolean loop_to_select_event(GtkWidget *widget,
} }
static gboolean loop_select_event(GtkWidget *widget, GdkEventButton *event,
gpointer data)
{
struct loop *loop = data;
loop->active = (long) gtk_object_get_data(GTK_OBJECT(widget), "value");
change_world();
return TRUE;
}
static void build_loop(GtkWidget *vbox, struct frame *frame, static void build_loop(GtkWidget *vbox, struct frame *frame,
struct loop *loop) struct loop *loop)
{ {
GtkWidget *hbox, *field; GtkWidget *hbox, *field, *label;
char *expr; char *expr;
int i;
hbox = gtk_hbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
@ -378,6 +417,19 @@ static void build_loop(GtkWidget *vbox, struct frame *frame,
"button_press_event", "button_press_event",
G_CALLBACK(loop_to_select_event), loop); G_CALLBACK(loop_to_select_event), loop);
loop->to.widget = field; 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,
loop_select_event, loop, "%d", i);
gtk_object_set_data(GTK_OBJECT(box_of_label(label)), "value",
(gpointer) (long) i);
}
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(")"),
FALSE, FALSE, 0);
} }
@ -503,26 +555,16 @@ static gboolean frame_ref_select_event(GtkWidget *widget, GdkEventButton *event,
static GtkWidget *build_frame_refs(const struct frame *frame) static GtkWidget *build_frame_refs(const struct frame *frame)
{ {
GtkWidget *hbox, *label; GtkWidget *hbox;
struct obj *obj; struct obj *obj;
char buf[100];
hbox = gtk_hbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0);
for (obj = frame->objs; obj; obj = obj->next) for (obj = frame->objs; obj; obj = obj->next)
if (obj->type == ot_frame && obj->u.frame.ref == active_frame) { if (obj->type == ot_frame && obj->u.frame.ref == active_frame)
sprintf(buf, "%d", obj->u.frame.lineno); add_activator(hbox,
label = label_in_box_new(buf); obj == obj->u.frame.ref->active_ref,
gtk_misc_set_padding(GTK_MISC(label), 2, 2); frame_ref_select_event, obj,
gtk_misc_set_alignment(GTK_MISC(label), 0, 0); "%d", obj->u.frame.lineno);
label_in_box_bg(label,
obj == obj->u.frame.ref->active_ref ?
COLOR_REF_SELECTED : COLOR_REF_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(frame_ref_select_event), obj);
}
return hbox; return hbox;
} }

View File

@ -62,9 +62,6 @@
#define COLOR_FRAME_SELECTED "#fff0a0" #define COLOR_FRAME_SELECTED "#fff0a0"
#define COLOR_FRAME_EDITING COLOR_EDITING #define COLOR_FRAME_EDITING COLOR_EDITING
#define COLOR_REF_UNSELECTED COLOR_CHOICE_UNSELECTED
#define COLOR_REF_SELECTED COLOR_CHOICE_SELECTED
#define COLOR_VAR_PASSIVE COLOR_FRAME_UNSELECTED #define COLOR_VAR_PASSIVE COLOR_FRAME_UNSELECTED
#define COLOR_VAR_EDITING COLOR_EDITING #define COLOR_VAR_EDITING COLOR_EDITING
#define COLOR_EXPR_PASSIVE "#f0f0ff" #define COLOR_EXPR_PASSIVE "#f0f0ff"

1
obj.c
View File

@ -213,6 +213,7 @@ static int run_loops(struct frame *frame, struct loop *loop,
n++; n++;
} }
loop->initialized = 0; loop->initialized = 0;
loop->iterations = n;
return 1; return 1;
fail: fail:

1
obj.h
View File

@ -76,6 +76,7 @@ struct loop {
/* GUI use */ /* GUI use */
int active; /* n-th iteration is active, 0 based */ int active; /* n-th iteration is active, 0 based */
int iterations; /* iterations when it was active */
/* for evaluation */ /* for evaluation */
int initialized; int initialized;