r5379 - trunk/eda/fped
werner at docs.openmoko.org
werner at docs.openmoko.org
Tue Aug 4 00:58:16 CEST 2009
Author: werner
Date: 2009-08-04 00:58:15 +0200 (Tue, 04 Aug 2009)
New Revision: 5379
Modified:
trunk/eda/fped/gui.c
trunk/eda/fped/gui_style.h
trunk/eda/fped/obj.c
trunk/eda/fped/obj.h
Log:
- moved building of an activator into new function add_activator
- added loop value selection (quick and dirty)
Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c 2009-08-03 21:52:21 UTC (rev 5378)
+++ trunk/eda/fped/gui.c 2009-08-03 22:58:15 UTC (rev 5379)
@@ -140,6 +140,33 @@
}
+/* ----- 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 ------------------------------------------------------- */
@@ -336,11 +363,23 @@
}
+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,
struct loop *loop)
{
- GtkWidget *hbox, *field;
+ 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);
@@ -378,6 +417,19 @@
"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,
+ 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 GtkWidget *build_frame_refs(const struct frame *frame)
{
- GtkWidget *hbox, *label;
+ GtkWidget *hbox;
struct obj *obj;
- char buf[100];
hbox = gtk_hbox_new(FALSE, 0);
for (obj = frame->objs; obj; obj = obj->next)
- if (obj->type == ot_frame && obj->u.frame.ref == active_frame) {
- sprintf(buf, "%d", obj->u.frame.lineno);
- 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,
- 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);
- }
+ if (obj->type == ot_frame && obj->u.frame.ref == active_frame)
+ add_activator(hbox,
+ obj == obj->u.frame.ref->active_ref,
+ frame_ref_select_event, obj,
+ "%d", obj->u.frame.lineno);
return hbox;
}
Modified: trunk/eda/fped/gui_style.h
===================================================================
--- trunk/eda/fped/gui_style.h 2009-08-03 21:52:21 UTC (rev 5378)
+++ trunk/eda/fped/gui_style.h 2009-08-03 22:58:15 UTC (rev 5379)
@@ -62,9 +62,6 @@
#define COLOR_FRAME_SELECTED "#fff0a0"
#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_EDITING COLOR_EDITING
#define COLOR_EXPR_PASSIVE "#f0f0ff"
Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c 2009-08-03 21:52:21 UTC (rev 5378)
+++ trunk/eda/fped/obj.c 2009-08-03 22:58:15 UTC (rev 5379)
@@ -213,6 +213,7 @@
n++;
}
loop->initialized = 0;
+ loop->iterations = n;
return 1;
fail:
Modified: trunk/eda/fped/obj.h
===================================================================
--- trunk/eda/fped/obj.h 2009-08-03 21:52:21 UTC (rev 5378)
+++ trunk/eda/fped/obj.h 2009-08-03 22:58:15 UTC (rev 5379)
@@ -76,6 +76,7 @@
/* GUI use */
int active; /* n-th iteration is active, 0 based */
+ int iterations; /* iterations when it was active */
/* for evaluation */
int initialized;
More information about the commitlog
mailing list