Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        commitlog-requ...@lists.openmoko.org

You can reach the person managing the list at
        commitlog-ow...@lists.openmoko.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r5843 - trunk/eda/fped (wer...@docs.openmoko.org)
   2. r5844 - trunk/eda/fped (wer...@docs.openmoko.org)
   3. r5845 - trunk/eda/fped (wer...@docs.openmoko.org)
   4. r5846 - trunk/eda/fped (wer...@docs.openmoko.org)
   5. r5847 - trunk/eda/fped (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2010-02-18 12:35:12 +0100 (Thu, 18 Feb 2010)
New Revision: 5843

Modified:
   trunk/eda/fped/gui_frame.c
Log:
Variables and loops can now be added from the variable/loop pop-ups, without
having to go all the way up to the frame.

- gui_frame.c: factory tables had very ragged indentation
- gui_frame.c: added "Add variable" and "Add loop" to variable, table, and loop
  pop-up



Modified: trunk/eda/fped/gui_frame.c
===================================================================
--- trunk/eda/fped/gui_frame.c  2010-02-09 01:46:48 UTC (rev 5842)
+++ trunk/eda/fped/gui_frame.c  2010-02-18 11:35:12 UTC (rev 5843)
@@ -33,6 +33,58 @@
 int show_vars = 1;
 
 
+/* ----- 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();
+}
+
+
 /* ----- popup dispatcher -------------------------------------------------- */
 
 
@@ -85,54 +137,25 @@
 }
 
 
-/* @@@ merge with fpd.y */
-
 static void popup_add_table(void)
 {
-       struct frame *frame = popup_data;
-       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;
-       for (walk = &frame->tables; *walk; walk = &(*walk)->next);
-       *walk = table;
-       change_world();
+       add_table(popup_data, NULL);
 }
 
 
 static void popup_add_loop(void)
 {
-       struct frame *frame = popup_data;
-       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");
-       loop->next = NULL;
-       for (walk = &frame->loops; *walk; walk = &(*walk)->next);
-       *walk = loop;
-       change_world();
+       add_loop(popup_data, NULL);
 }
 
 
 static GtkItemFactoryEntry popup_frame_entries[] = {
-       { "/Add frame",         NULL,   popup_add_frame,        0, "<Item>" },
+       { "/Add frame",         NULL,   popup_add_frame,0, "<Item>" },
        { "/sep0",              NULL,   NULL,           0, "<Separator>" },
-       { "/Add variable",      NULL,   popup_add_table,        0, "<Item>" },
-       { "/Add loop",          NULL,   popup_add_loop,         0, "<Item>" },
+       { "/Add variable",      NULL,   popup_add_table,0, "<Item>" },
+       { "/Add loop",          NULL,   popup_add_loop, 0, "<Item>" },
        { "/sep1",              NULL,   NULL,           0, "<Separator>" },
-       { "/Delete frame",      NULL,   popup_del_frame,        0, "<Item>" },
+       { "/Delete frame",      NULL,   popup_del_frame,0, "<Item>" },
        { "/sep2",              NULL,   NULL,           0, "<Separator>" },
        { "/Close",             NULL,   NULL,           0, "<Item>" },
        { NULL }
@@ -167,11 +190,21 @@
 }
 
 
-static void pop_up_frame(struct frame *frame, GdkEventButton *event)
+static void enable_add_var(struct frame *frame, GtkItemFactory *factory)
 {
        gboolean add_var;
 
+       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)
+{
+       gtk_widget_set_sensitive(
            gtk_item_factory_get_item(factory_frame, "/Delete frame"),
            frame != root_frame);
 
@@ -179,11 +212,7 @@
            gtk_item_factory_get_item(factory_frame, "/Add frame"),
            can_add_frame());
 
-       add_var = can_add_var(frame);
-       gtk_widget_set_sensitive(
-           gtk_item_factory_get_item(factory_frame, "/Add variable"), add_var);
-       gtk_widget_set_sensitive(
-           gtk_item_factory_get_item(factory_frame, "/Add loop"), add_var);
+       enable_add_var(frame, factory_frame);
        
        pop_up(popup_frame_widget, event, frame);
 }
@@ -275,13 +304,34 @@
 }
 
 
+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);
+}
+
+
 static GtkItemFactoryEntry popup_single_var_entries[] = {
-       { "/Add row",           NULL,   popup_add_row,          0, "<Item>" },
+       { "/Add row",           NULL,   popup_add_row,  0, "<Item>" },
        { "/Add column",        NULL,   popup_add_column,       0, "<Item>" },
        { "/sep1",              NULL,   NULL,           0, "<Separator>" },
-       { "/Delete variable",   NULL,   popup_del_table,        0, "<Item>" },
+       { "/Delete variable",   NULL,   popup_del_table,0, "<Item>" },
        { "/sep2",              NULL,   NULL,           0, "<Separator>" },
-       { "/Close",             NULL,   NULL,                   0, "<Item>" },
+       { "/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>" },
        { NULL }
 };
 
@@ -291,6 +341,7 @@
        gtk_widget_set_sensitive(
            gtk_item_factory_get_item(factory_single_var, "/Add column"),
            can_add_var(var->frame));
+       enable_add_var(var->frame, factory_single_var);
        pop_up(popup_single_var_widget, event, var);
 }
 
@@ -316,12 +367,17 @@
 
 
 static GtkItemFactoryEntry popup_table_var_entries[] = {
-       { "/Add row",           NULL,   popup_add_row,          0, "<Item>" },
+       { "/Add row",           NULL,   popup_add_row,  0, "<Item>" },
        { "/Add column",        NULL,   popup_add_column,       0, "<Item>" },
        { "/sep1",              NULL,   NULL,           0, "<Separator>" },
-       { "/Delete table",      NULL,   popup_del_table,        0, "<Item>" },
+       { "/Delete table",      NULL,   popup_del_table,0, "<Item>" },
        { "/Delete column",     NULL,   popup_del_column,       0, "<Item>" },
        { "/sep2",              NULL,   NULL,           0, "<Separator>" },
+       { "/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>" },
        { NULL }
 };
@@ -335,6 +391,7 @@
        gtk_widget_set_sensitive(
            gtk_item_factory_get_item(factory_table_var, "/Add column"),
            can_add_var(var->frame));
+       enable_add_var(var->frame, factory_table_var);
        pop_up(popup_table_var_widget, event, var);
 }
 
@@ -397,9 +454,9 @@
        { "/Add column",        NULL,   popup_add_column_by_value,
                                                        0, "<Item>" },
        { "/sep1",              NULL,   NULL,           0, "<Separator>" },
-       { "/Delete row",        NULL,   popup_del_row,          0, "<Item>" },
+       { "/Delete row",        NULL,   popup_del_row,  0, "<Item>" },
        { "/Delete column",     NULL,   popup_del_column_by_value,
-                                                               0, "<Item>" },
+                                                       0, "<Item>" },
        { "/sep2",              NULL,   NULL,           0, "<Separator>" },
        { "/Close",             NULL,   NULL,           0, "<Item>" },
        { NULL }
@@ -434,8 +491,29 @@
 }
 
 
+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);
+}
+
+
 static GtkItemFactoryEntry popup_loop_var_entries[] = {
        { "/Delete loop",       NULL,   popup_del_loop, 0, "<Item>" },
+       { "/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>" },
        { "/sep2",              NULL,   NULL,           0, "<Separator>" },
        { "/Close",             NULL,   NULL,           0, "<Item>" },
        { NULL }
@@ -444,6 +522,7 @@
 
 static void pop_up_loop_var(struct loop *loop, GdkEventButton *event)
 {
+       enable_add_var(loop->var.frame, factory_loop_var);
        pop_up(popup_loop_var_widget, event, loop);
 }
 




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-02-18 14:39:20 +0100 (Thu, 18 Feb 2010)
New Revision: 5844

Modified:
   trunk/eda/fped/gui_status.c
   trunk/eda/fped/gui_status.h
   trunk/eda/fped/inst.c
Log:
As a shortcut, accept entry of "0" as a valid distance for dimensions. (For
safety, this only works if used directly, not through variables.)

- gui_status.c (edit_any_expr): replaced with dist_expr_store, which changes
  values of "0" to "0mm"
- gui_status.c, gui_status.h (edit_dist_expr): new function to edit distance
  expressions
- inst.c (obj_line_edit, obj_rect_edit, obj_arc_edit, obj_meas_edit): changed
  edit_expr to edit_dist_expr



Modified: trunk/eda/fped/gui_status.c
===================================================================
--- trunk/eda/fped/gui_status.c 2010-02-18 11:35:12 UTC (rev 5843)
+++ trunk/eda/fped/gui_status.c 2010-02-18 13:39:20 UTC (rev 5844)
@@ -615,16 +615,44 @@
 };
 
 
-static void edit_any_expr(GtkWidget *widget, struct expr **expr,
+void edit_expr(struct expr **expr, const char *tooltip)
+{
+       setup_edit(status_entry, &edit_ops_expr, expr, tooltip);
+}
+
+
+/* ----- distance expressions ---------------------------------------------- */
+
+
+static void dist_expr_store(const char *s, void *ctx)
+{
+       struct expr **anchor = ctx;
+       struct expr *expr;
+
+       expr_store(s, ctx);
+       expr = *anchor;
+       if (expr->op == op_num && !expr->u.num.exponent && !expr->u.num.n)
+               expr->u.num.exponent = 1;
+}
+
+
+static struct edit_ops edit_ops_dist_expr = {
+       .retrieve       = expr_retrieve,
+       .status         = expr_status,
+       .store          = dist_expr_store,
+};
+
+
+static void edit_any_dist_expr(GtkWidget *widget, struct expr **expr,
     const char *tooltip)
 {
-       setup_edit(widget, &edit_ops_expr, expr, tooltip);
+       setup_edit(widget, &edit_ops_dist_expr, expr, tooltip);
 }
 
 
-void edit_expr(struct expr **expr, const char *tooltip)
+void edit_dist_expr(struct expr **expr, const char *tooltip)
 {
-       edit_any_expr(status_entry, expr, tooltip);
+       edit_any_dist_expr(status_entry, expr, tooltip);
 }
 
 
@@ -633,13 +661,13 @@
        vacate_widget(status_box_x);
        gtk_container_add(GTK_CONTAINER(status_box_x), status_entry_x);
        gtk_widget_show(status_box_x);
-       edit_any_expr(status_entry_x, expr, tooltip);
+       edit_any_dist_expr(status_entry_x, expr, tooltip);
 }
 
 
 void edit_y(struct expr **expr, const char *tooltip)
 {
-       edit_any_expr(status_entry_y, expr, tooltip);
+       edit_any_dist_expr(status_entry_y, expr, tooltip);
 }
 
 

Modified: trunk/eda/fped/gui_status.h
===================================================================
--- trunk/eda/fped/gui_status.h 2010-02-18 11:35:12 UTC (rev 5843)
+++ trunk/eda/fped/gui_status.h 2010-02-18 13:39:20 UTC (rev 5844)
@@ -47,6 +47,7 @@
 void edit_expr_list(struct expr *expr,
     void (*set_values)(void *user, const struct value *values, int n_values),
     void *user, const char *tooltip);
+void edit_dist_expr(struct expr **expr, const char *tooltip);
 void edit_x(struct expr **expr, const char *tooltip);
 void edit_y(struct expr **expr, const char *tooltip);
 void edit_nothing(void);

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2010-02-18 11:35:12 UTC (rev 5843)
+++ trunk/eda/fped/inst.c       2010-02-18 13:39:20 UTC (rev 5844)
@@ -754,7 +754,7 @@
 
 static void obj_line_edit(struct obj *obj)
 {
-       edit_expr(&obj->u.line.width, "Line width");
+       edit_dist_expr(&obj->u.line.width, "Line width");
 }
 
 
@@ -805,7 +805,7 @@
 
 static void obj_rect_edit(struct obj *obj)
 {
-       edit_expr(&obj->u.rect.width, "Line width");
+       edit_dist_expr(&obj->u.rect.width, "Line width");
 }
 
 
@@ -934,7 +934,7 @@
 
 static void obj_arc_edit(struct obj *obj)
 {
-       edit_expr(&obj->u.arc.width, "Line width");
+       edit_dist_expr(&obj->u.arc.width, "Line width");
 }
 
 
@@ -1008,7 +1008,7 @@
 
 static void obj_meas_edit(struct obj *obj)
 {
-       edit_expr(&obj->u.meas.offset, "Measurement line offset");
+       edit_dist_expr(&obj->u.meas.offset, "Measurement line offset");
 }
 
 




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-02-18 15:03:14 +0100 (Thu, 18 Feb 2010)
New Revision: 5845

Modified:
   trunk/eda/fped/Makefile
   trunk/eda/fped/gui.c
Log:
Show fped's SVN revision in the title bar.

- Makefile: pass SVN version and commit status to CPP
- gui.c (gui_main): show SVN revision in the title bar, if available



Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile     2010-02-18 13:39:20 UTC (rev 5844)
+++ trunk/eda/fped/Makefile     2010-02-18 14:03:14 UTC (rev 5845)
@@ -37,13 +37,18 @@
 
 CFLAGS_WARN = -Wall -Wshadow -Wmissing-prototypes \
              -Wmissing-declarations -Wno-format-zero-length
-CFLAGS = -g -std=gnu99 $(CFLAGS_GTK) -DCPP='"cpp"' $(CFLAGS_WARN)
+CFLAGS = -g -std=gnu99 $(CFLAGS_GTK) -DCPP='"cpp"' \
+         -DSVN_VERSION='"$(SVN_VERSION)$(SVN_STATUS)"' $(CFLAGS_WARN)
 SLOPPY = -Wno-unused -Wno-implicit-function-declaration \
         -Wno-missing-prototypes -Wno-missing-declarations
 LDLIBS = -lm -lfl $(LIBS_GTK)
 YACC = bison -y
 YYFLAGS = -v
 
+SVN_VERSION=$(shell svn info | sed '/Last Changed Rev: /s///p;d')
+SVN_STATUS=$(shell [ -z "`svn status -q`" ] || echo +)
+
+
 # ----- Verbosity control -----------------------------------------------------
 
 CPP := $(CPP)   # make sure changing CC won't affect CPP

Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c        2010-02-18 13:39:20 UTC (rev 5844)
+++ trunk/eda/fped/gui.c        2010-02-18 14:03:14 UTC (rev 5845)
@@ -314,7 +314,11 @@
        root = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_position(GTK_WINDOW(root), GTK_WIN_POS_CENTER);
        gtk_window_set_default_size(GTK_WINDOW(root), 620, 460);
-       gtk_window_set_title(GTK_WINDOW(root), "fped");
+       if (*SVN_VERSION)
+               gtk_window_set_title(GTK_WINDOW(root),
+                   "fped (rev " SVN_VERSION ")");
+       else
+               gtk_window_set_title(GTK_WINDOW(root), "fped");
 
        /* get root->window */
        gtk_widget_show_all(root);




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-02-18 15:18:30 +0100 (Thu, 18 Feb 2010)
New Revision: 5846

Modified:
   trunk/eda/fped/Makefile
Log:
- Makefile (SVN_VERSION): use "svn info -R" to get the correct SVN revision



Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile     2010-02-18 14:03:14 UTC (rev 5845)
+++ trunk/eda/fped/Makefile     2010-02-18 14:18:30 UTC (rev 5846)
@@ -45,7 +45,8 @@
 YACC = bison -y
 YYFLAGS = -v
 
-SVN_VERSION=$(shell svn info | sed '/Last Changed Rev: /s///p;d')
+SVN_VERSION=$(shell svn info -R | sed '/Last Changed Rev: /s///p;d' | \
+    sort -r | sed 1q)
 SVN_STATUS=$(shell [ -z "`svn status -q`" ] || echo +)
 
 




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-02-19 11:27:46 +0100 (Fri, 19 Feb 2010)
New Revision: 5847

Modified:
   trunk/eda/fped/gui.c
   trunk/eda/fped/gui_frame.c
   trunk/eda/fped/gui_frame.h
   trunk/eda/fped/gui_style.h
   trunk/eda/fped/gui_util.c
   trunk/eda/fped/gui_util.h
Log:
Wrap wide tables. 

- gui_frame.c (build_table): restructured code to build tables column by column
  instead of row by row
- gui_frame.c (build_table): wrap tables wider than the screen area available
  for variables and tables
- gui_util.h, gui_util.c (get_widget_width): new helper function that returns a
  widget's requested width
- gui.c, gui_style.h: replace hard-coded initial pane size with constants
  DEFAULT_FRAME_AREA_WIDTH and DEFAULT_FRAME_AREA_HEIGHT
- gui.c (change_world): pass the width of the left pane as a wrapping hint to 
  build_frames
- gui_frame.c (build_frames): subtract width of longest package template or 
  frame name from available width
- gui.c (change_world): moved call to build_frames to separate function
  do_build_frames
- gui.c (gui_main): used g_signal_connect_swapped instead of g_signal_connect
  for no good reason



Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c        2010-02-18 14:18:30 UTC (rev 5846)
+++ trunk/eda/fped/gui.c        2010-02-19 10:27:46 UTC (rev 5847)
@@ -41,12 +41,15 @@
 int show_bright = 0;
 
 
+static GtkWidget *paned;
 static GtkWidget *frames_box;
 static GtkWidget *ev_stuff, *ev_meas, *ev_all, *ev_bright;
 static GtkWidget *stuff_image[2], *meas_image[2], *all_image[2];
 static GtkWidget *bright_image[2];
 
+static void do_build_frames(void);
 
+
 /* ----- view callbacks ---------------------------------------------------- */
 
 
@@ -220,9 +223,21 @@
 /* ----- central screen area ----------------------------------------------- */
 
 
+static void resize_frames_area(GtkWidget *widget, GtkAllocation *allocation,
+    gpointer user_data)
+{
+       static int width = 0;
+
+       if (allocation->width == width)
+               return;
+       width = allocation->width;
+       do_build_frames();
+}
+
+
 static void make_center_area(GtkWidget *vbox)
 {
-       GtkWidget *hbox, *frames_area, *paned;
+       GtkWidget *hbox, *frames_area;//, *paned;
        GtkWidget *tools;
 
        hbox = gtk_hbox_new(FALSE, 0);
@@ -237,14 +252,18 @@
        gtk_paned_add1(GTK_PANED(paned), frames_area);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(frames_area),
            GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-       gtk_widget_set_size_request(frames_area, 250, 100);
+       gtk_widget_set_size_request(frames_area,
+           DEFAULT_FRAME_AREA_WIDTH, DEFAULT_FRAME_AREA_HEIGHT);
 
        frames_box = gtk_vbox_new(FALSE, 0);
-       build_frames(frames_box);
+       build_frames(frames_box, DEFAULT_FRAME_AREA_WIDTH);
 
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(frames_area),
            frames_box);
 
+       g_signal_connect(G_OBJECT(frames_area), "size-allocate",
+           G_CALLBACK(resize_frames_area), NULL);
+
        /* Canvas */
 
        gtk_paned_add2(GTK_PANED(paned), make_canvas());
@@ -259,6 +278,15 @@
 /* ----- GUI construction -------------------------------------------------- */
 
 
+static void do_build_frames(void)
+{
+       int width;
+
+       width = gtk_paned_get_position(GTK_PANED(paned));
+       build_frames(frames_box, width > 0 ? width : DEFAULT_FRAME_AREA_WIDTH);
+}
+
+
 void change_world(void)
 {
        struct bbox before, after;
@@ -269,7 +297,7 @@
        instantiate();
        after = inst_get_bbox();
        label_in_box_bg(active_frame->label, COLOR_FRAME_SELECTED);
-       build_frames(frames_box);
+       do_build_frames();
        if (after.min.x < before.min.x || after.min.y < before.min.y || 
            after.max.x > before.max.x || after.max.y > before.max.y)
                zoom_to_extents();
@@ -323,7 +351,7 @@
        /* get root->window */
        gtk_widget_show_all(root);
 
-       g_signal_connect_swapped(G_OBJECT(root), "destroy",
+       g_signal_connect(G_OBJECT(root), "destroy",
            G_CALLBACK(gtk_main_quit), NULL);
 
        make_screen(root);

Modified: trunk/eda/fped/gui_frame.c
===================================================================
--- trunk/eda/fped/gui_frame.c  2010-02-18 14:18:30 UTC (rev 5846)
+++ trunk/eda/fped/gui_frame.c  2010-02-19 10:27:46 UTC (rev 5847)
@@ -955,8 +955,10 @@
 }
 
 
+/* @@@ this function is too long */
+
 static void build_table(GtkWidget *vbox, struct frame *frame,
-    struct table *table)
+    struct table *table, int wrap_width)
 {
        GtkWidget *tab, *field;
        GtkWidget *evbox, *align;
@@ -964,8 +966,9 @@
        struct row *row;
        struct value *value;
        int n_vars = 0, n_rows = 0;
+       int n_var, n_row, pos, col;
        char *expr;
-       GdkColor col;
+       GdkColor color;
 
        for (var = table->vars; var; var = var->next)
                n_vars++;
@@ -975,26 +978,40 @@
        if (n_vars == 1 && n_rows == 1)
                return;
 
-       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);
+       var = table->vars;
+       n_var = 0;
+       n_vars = 0;
+       while (var) {
+               col = n_vars+(n_var != n_vars);;
+               if (!n_vars) {
+                       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);
 
-       tab = gtk_table_new(n_rows+1, n_vars, FALSE);
-       gtk_container_add(GTK_CONTAINER(evbox), tab);
-       col = get_color(COLOR_VAR_TABLE_SEP);
-       gtk_widget_modify_bg(GTK_WIDGET(evbox),
-           GTK_STATE_NORMAL, &col);
+                       tab = gtk_table_new(n_rows+1, col, FALSE);
+                       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);
+                       gtk_table_set_row_spacings(GTK_TABLE(tab), 1);
+                       gtk_table_set_col_spacings(GTK_TABLE(tab), 1);
 
-       n_vars = 0;
-       for (var = table->vars; var; var = var->next) {
+                       /* @@@
+                        * for now, we just add an empty first column to
+                        * wrapped tables, which yields a thin black line.
+                        * Might want to put something more visible later.
+                        */
+
+               }
+               gtk_table_resize(GTK_TABLE(tab), n_rows, col+1);
+       
                field = label_in_box_new(var->name,
                    "Variable (column) name. Click to edit.");
                gtk_table_attach_defaults(GTK_TABLE(tab), box_of_label(field),
-                   n_vars, n_vars+1, 0, 1);
+                   col, col+1, 0, 1);
                label_in_box_bg(field, COLOR_VAR_PASSIVE);
                g_signal_connect(G_OBJECT(box_of_label(field)),
                    "button_press_event",
@@ -1003,20 +1020,20 @@
                    "scroll_event",
                    G_CALLBACK(table_scroll_event), table);
                var->widget = field;
-               n_vars++;
-       }
-       n_rows = 0;
-       for (row = table->rows; row; row = row->next) {
-               n_vars = 0;
-               for (value = row->values; value; value = value->next) {
+
+               n_row = 0;
+               for (row = table->rows; row; row = row->next) {
+                       value = row->values;
+                       for (pos = 0; pos != n_var; pos++)
+                               value = value->next;
                        expr = unparse(value->expr);
                        field = label_in_box_new(expr,
                            "Variable value. Click to select row or to edit.");
                        free(expr);
                        gtk_table_attach_defaults(GTK_TABLE(tab),
                            box_of_label(field),
-                           n_vars, n_vars+1,
-                           n_rows+1, n_rows+2);
+                           col, col+1,
+                           n_row+1, n_row+2);
                        label_in_box_bg(field, table->active_row == row ?
                            COLOR_ROW_SELECTED : COLOR_ROW_UNSELECTED);
                        g_signal_connect(G_OBJECT(box_of_label(field)),
@@ -1026,10 +1043,39 @@
                            "scroll_event",
                            G_CALLBACK(table_scroll_event), table);
                        value->widget = field;
-                       n_vars++;
+                       n_row++;
                }
-               n_rows++;
+
+               /*
+                * 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));
+                       }
+                       gtk_table_resize(GTK_TABLE(tab), n_rows, col);
+
+                       n_vars = 0;
+                       continue;
+               }
+
+               var = var->next;
+               n_var++;
+               n_vars++;
        }
+       
 }
 
 
@@ -1220,7 +1266,7 @@
 /* ----- the list of variables, tables, and loops -------------------------- */
 
 
-static GtkWidget *build_vars(struct frame *frame)
+static GtkWidget *build_vars(struct frame *frame, int wrap_width)
 {
        GtkWidget *vbox;
        struct table *table;
@@ -1230,7 +1276,7 @@
        for (table = frame->tables; table; table = table->next) {
                add_sep(vbox, 3);
                build_assignment(vbox, frame, table);
-               build_table(vbox, frame, table);
+               build_table(vbox, frame, table, wrap_width);
        }
        for (loop = frame->loops; loop; loop = loop->next) {
                add_sep(vbox, 3);
@@ -1696,11 +1742,12 @@
 /* ----- frames ------------------------------------------------------------ */
 
 
-void build_frames(GtkWidget *vbox)
+void build_frames(GtkWidget *vbox, int wrap_width)
 {
        struct frame *frame;
        GtkWidget *hbox, *tab, *label, *packages, *refs, *vars, *items, *meas;
        int n = 0;
+       int max_name_width, name_width;
 
        destroy_all_children(GTK_CONTAINER(vbox));
        for (frame = frames; frame; frame = frame->next)
@@ -1717,6 +1764,7 @@
 
        label = build_pkg_name();
        gtk_table_attach_defaults(GTK_TABLE(tab), label, 0, 1, 0, 1);
+       max_name_width = get_widget_width(label);
 
        packages = build_pkg_names();
        gtk_table_attach_defaults(GTK_TABLE(tab), packages, 1, 2, 0, 1);
@@ -1726,13 +1774,21 @@
                label = build_frame_label(frame);
                gtk_table_attach_defaults(GTK_TABLE(tab), label,
                    0, 1, n*2+1, n*2+2);
+               n++;
+               name_width = get_widget_width(label);
+               if (name_width > max_name_width)
+                       max_name_width = name_width;
+       }
 
+       wrap_width -= max_name_width+FRAME_AREA_MISC_WIDTH;
+       n = 0;
+       for (frame = root_frame; frame; frame = frame->prev) {
                refs = build_frame_refs(frame);
                gtk_table_attach_defaults(GTK_TABLE(tab), refs,
                    1, 2, n*2+1, n*2+2);
 
                if (show_vars) {
-                       vars = build_vars(frame);
+                       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);

Modified: trunk/eda/fped/gui_frame.h
===================================================================
--- trunk/eda/fped/gui_frame.h  2010-02-18 14:18:30 UTC (rev 5846)
+++ trunk/eda/fped/gui_frame.h  2010-02-19 10:27:46 UTC (rev 5847)
@@ -1,8 +1,8 @@
 /*
  * gui_frame.h - GUI, frame window
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 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
@@ -27,6 +27,6 @@
 void gui_frame_select_inst(struct inst *inst);
 void gui_frame_deselect_inst(struct inst *inst);
 
-void build_frames(GtkWidget *vbox);
+void build_frames(GtkWidget *vbox, int warp_width);
 
 #endif /* !GUI_FRAME_H */

Modified: trunk/eda/fped/gui_style.h
===================================================================
--- trunk/eda/fped/gui_style.h  2010-02-18 14:18:30 UTC (rev 5846)
+++ trunk/eda/fped/gui_style.h  2010-02-19 10:27:46 UTC (rev 5847)
@@ -1,8 +1,8 @@
 /*
  * gui_style.h - GUI, style definitions
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 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
@@ -61,7 +61,11 @@
 #define        MM_FORMAT_SHORT         "%.4g"
 #define        MIL_FORMAT_SHORT        "%.4g"
 
+#define        DEFAULT_FRAME_AREA_WIDTH 250
+#define        DEFAULT_FRAME_AREA_HEIGHT 100
+#define        FRAME_AREA_MISC_WIDTH   26      /* pane, scroll bar, slack */
 
+
 /* ----- assorted colors --------------------------------------------------- */
 
 

Modified: trunk/eda/fped/gui_util.c
===================================================================
--- trunk/eda/fped/gui_util.c   2010-02-18 14:18:30 UTC (rev 5846)
+++ trunk/eda/fped/gui_util.c   2010-02-19 10:27:46 UTC (rev 5847)
@@ -387,3 +387,16 @@
 {
        gtk_container_foreach(container, destroy_callback, NULL);
 }
+
+
+/* ----- get a widget's desired width -------------------------------------- */
+
+
+int get_widget_width(GtkWidget *widget)
+{
+       GtkRequisition req;
+
+       gtk_widget_show_all(widget);
+       gtk_widget_size_request(widget, &req);
+       return req.width;
+}

Modified: trunk/eda/fped/gui_util.h
===================================================================
--- trunk/eda/fped/gui_util.h   2010-02-18 14:18:30 UTC (rev 5846)
+++ trunk/eda/fped/gui_util.h   2010-02-19 10:27:46 UTC (rev 5847)
@@ -79,4 +79,6 @@
 
 void destroy_all_children(GtkContainer *container);
 
+int get_widget_width(GtkWidget *widget);
+
 #endif /* !GUI_UTIL_H */




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to