r5633 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Sun Sep 13 01:15:15 CEST 2009


Author: werner
Date: 2009-09-13 01:15:15 +0200 (Sun, 13 Sep 2009)
New Revision: 5633

Modified:
   trunk/eda/fped/gui.c
   trunk/eda/fped/gui.h
   trunk/eda/fped/gui_status.c
   trunk/eda/fped/gui_status.h
   trunk/eda/fped/gui_style.h
   trunk/eda/fped/gui_util.c
   trunk/eda/fped/gui_util.h
   trunk/eda/fped/inst.c
   trunk/eda/fped/obj.h
Log:
- gui_util.c: make container clean-out globally available as vacate_widget
- gui_status.c: the x entry are is now a vbox with variable content
- the pad type is now shown in the x entry area and can be changed by clicking
  on it



Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c	2009-09-12 16:02:07 UTC (rev 5632)
+++ trunk/eda/fped/gui.c	2009-09-12 23:15:15 UTC (rev 5633)
@@ -261,6 +261,16 @@
 }
 
 
+void change_world_reselect(void)
+{
+	struct obj *selected_obj;
+
+	selected_obj = selected_inst->obj;
+	change_world();
+	inst_select_obj(selected_obj);
+}
+
+
 static void make_screen(GtkWidget *window)
 {
 	GtkWidget *vbox;
@@ -309,6 +319,7 @@
 	gui_cleanup_style();
 	gui_cleanup_tools();
 	cleanup_tool_bar();
+	cleanup_status_area();
 
 	return 0;
 }

Modified: trunk/eda/fped/gui.h
===================================================================
--- trunk/eda/fped/gui.h	2009-09-12 16:02:07 UTC (rev 5632)
+++ trunk/eda/fped/gui.h	2009-09-12 23:15:15 UTC (rev 5633)
@@ -27,6 +27,9 @@
 /* update everything after a model change */
 void change_world(void);
 
+/* like change_world, but select the object again */
+void change_world_reselect(void);
+
 int gui_init(int *argc, char ***argv);
 int gui_main(void);
 

Modified: trunk/eda/fped/gui_status.c
===================================================================
--- trunk/eda/fped/gui_status.c	2009-09-12 16:02:07 UTC (rev 5632)
+++ trunk/eda/fped/gui_status.c	2009-09-12 23:15:15 UTC (rev 5633)
@@ -23,6 +23,7 @@
 #include "coord.h"
 #include "error.h"
 #include "unparse.h"
+#include "obj.h"
 #include "gui_util.h"
 #include "gui_style.h"
 #include "gui_canvas.h"
@@ -56,7 +57,7 @@
 
 static GtkWidget *status_name, *status_entry;
 static GtkWidget *status_type_x, *status_type_y, *status_type_entry;
-static GtkWidget *status_entry_x, *status_entry_y;
+static GtkWidget *status_box_x, *status_entry_y;
 static GtkWidget *status_x, *status_y;
 static GtkWidget *status_r, *status_angle;
 static GtkWidget *status_sys_x, *status_sys_y;
@@ -64,7 +65,11 @@
 static GtkWidget *status_zoom, *status_grid, *status_unit;
 static GtkWidget *status_msg;
 
+/* The x entry area serves multiple purposes */
 
+static GtkWidget *status_entry_x;
+
+
 static void set_label(GtkWidget *label, const char *fmt, va_list ap)
 {
 	char *s;
@@ -159,9 +164,74 @@
 }
 
 
-/* ----- helper functions -------------------------------------------------- */
+/* ----- pad type display and change --------------------------------------- */
 
 
+static enum pad_type *curr_pad_type;
+static GtkWidget *pad_type;
+
+
+static void show_pad_type(void)
+{
+	const char *s;
+
+	switch (*curr_pad_type) {
+	case pt_normal:
+		s = "normal";
+		break;
+	case pt_bare:
+		s = "bare";
+		break;
+	case pt_paste:
+		s = "paste";
+		break;
+	case pt_mask:
+		s = "mask";
+		break;
+	default:
+		abort();
+	}
+	gtk_label_set_text(GTK_LABEL(pad_type), s);
+}
+
+
+static gboolean pad_type_button_press_event(GtkWidget *widget,
+    GdkEventButton *event, gpointer data)
+{
+	switch (event->button) {
+	case 1:
+		*curr_pad_type = (*curr_pad_type+1) % pt_n;
+		show_pad_type();
+		break;
+	}
+	/*
+	 * We can't just redraw() here, because changing the pad type may also
+	 * affect the visual stacking. So we change the world and hope we end
+	 * up selecting the same pad afterwards.
+	 */
+	change_world_reselect();
+	return TRUE;
+}
+
+
+void edit_pad_type(enum pad_type *type)
+{
+	vacate_widget(status_box_x);
+	curr_pad_type = type;
+	pad_type = label_in_box_new(NULL);
+	gtk_container_add(GTK_CONTAINER(status_box_x), box_of_label(pad_type));
+	label_in_box_bg(pad_type, COLOR_SELECTOR);
+	g_signal_connect(G_OBJECT(box_of_label(pad_type)),
+	    "button_press_event", G_CALLBACK(pad_type_button_press_event),
+	    NULL);
+	show_pad_type();
+	gtk_widget_show_all(status_box_x);
+}
+
+
+/* ----- edit helper functions --------------------------------------------- */
+
+
 static void reset_edit(GtkWidget *widget)
 {
 	struct edit_ops *ops;
@@ -532,6 +602,9 @@
 
 void edit_x(struct expr **expr)
 {
+	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);
 }
 
@@ -695,7 +768,7 @@
 void edit_nothing(void)
 {
 	gtk_widget_hide(status_entry);
-	gtk_widget_hide(status_entry_x);
+	gtk_widget_hide(status_box_x);
 	gtk_widget_hide(status_entry_y);
 	open_edits = NULL;
 	last_edit = NULL;
@@ -772,6 +845,17 @@
 /* ----- setup ------------------------------------------------------------- */
 
 
+static GtkWidget *add_vbox(GtkWidget *tab, int col, int row)
+{
+	GtkWidget *vbox;
+
+	vbox = gtk_vbox_new(FALSE, 0);
+	gtk_table_attach_defaults(GTK_TABLE(tab), vbox,
+	    col, col+1, row, row+1);
+	return vbox;
+}
+
+
 static GtkWidget *add_label_basic(GtkWidget *tab, int col, int row)
 {
 	GtkWidget *label;
@@ -796,14 +880,12 @@
 }
 
 
-static GtkWidget *add_entry(GtkWidget *tab, int col, int row)
+static GtkWidget *make_entry(void)
 {
 	GtkWidget *entry;
 
 	entry = gtk_entry_new();
 	gtk_entry_set_has_frame(GTK_ENTRY(entry), FALSE);
-	gtk_table_attach_defaults(GTK_TABLE(tab), entry,
-	    col, col+1, row, row+1);
 
 	g_signal_connect(G_OBJECT(entry), "changed",
 	    G_CALLBACK(changed), entry);
@@ -814,6 +896,17 @@
 }
 
 
+static GtkWidget *add_entry(GtkWidget *tab, int col, int row)
+{
+	GtkWidget *entry;
+
+	entry = make_entry();
+	gtk_table_attach_defaults(GTK_TABLE(tab), entry,
+	    col, col+1, row, row+1);
+	return entry;
+}
+
+
 void make_status_area(GtkWidget *vbox)
 {
 	GtkWidget *tab, *sep;
@@ -830,10 +923,12 @@
 	/* x / y */
 
 	status_x = add_label(tab, 1, 0);
-	status_entry_x = add_entry(tab, 2, 0);
+	status_box_x = add_vbox(tab, 2, 0);
 	status_y = add_label(tab, 1, 1);
 	status_entry_y = add_entry(tab, 2, 1);
 
+	status_entry_x = gtk_widget_ref(make_entry());
+	
 	/* name and input */
 
 	status_name = add_label(tab, 1, 2);
@@ -864,7 +959,7 @@
 
 	/* unit selection */
 
-	label_in_box_bg(status_unit, COLOR_UNIT_SELECTOR);
+	label_in_box_bg(status_unit, COLOR_SELECTOR);
 	show_curr_unit();
 	g_signal_connect(G_OBJECT(box_of_label(status_unit)),
 	    "button_press_event", G_CALLBACK(unit_button_press_event), NULL);
@@ -877,3 +972,9 @@
 	context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(status_msg),
 	    "messages");
 }
+
+
+void cleanup_status_area(void)
+{
+	gtk_widget_unref(status_entry_x);
+}

Modified: trunk/eda/fped/gui_status.h
===================================================================
--- trunk/eda/fped/gui_status.h	2009-09-12 16:02:07 UTC (rev 5632)
+++ trunk/eda/fped/gui_status.h	2009-09-12 23:15:15 UTC (rev 5633)
@@ -31,6 +31,8 @@
 extern enum curr_unit curr_unit;
 
 
+void edit_pad_type(enum pad_type *type);
+
 void edit_unique(const char **s, int (*validate)(const char *s, void *ctx),
     void *ctx);
 void edit_unique_null(const char **s, int (*validate)(const char *s, void *ctx),
@@ -86,6 +88,7 @@
 
 void status_begin_reporting(void);
 
-void make_status_area(GtkWidget *vbox) ;
+void make_status_area(GtkWidget *vbox);
+void cleanup_status_area(void);
 
 #endif /* !GUI_STATUS_H */

Modified: trunk/eda/fped/gui_style.h
===================================================================
--- trunk/eda/fped/gui_style.h	2009-09-12 16:02:07 UTC (rev 5632)
+++ trunk/eda/fped/gui_style.h	2009-09-12 23:15:15 UTC (rev 5633)
@@ -96,7 +96,7 @@
 #define	COLOR_ITEM_SELECTED	COLOR_FRAME_SELECTED
 #define	COLOR_ITEM_ERROR	"red"
 
-#define	COLOR_UNIT_SELECTOR	"white"
+#define	COLOR_SELECTOR		"white"
 
 
 /* ----- canvas drawing styles --------------------------------------------- */

Modified: trunk/eda/fped/gui_util.c
===================================================================
--- trunk/eda/fped/gui_util.c	2009-09-12 16:02:07 UTC (rev 5632)
+++ trunk/eda/fped/gui_util.c	2009-09-12 23:15:15 UTC (rev 5633)
@@ -190,9 +190,15 @@
 }
 
 
+void vacate_widget(GtkWidget *widget)
+{
+	gtk_container_foreach(GTK_CONTAINER(widget), remove_child, widget);
+}
+
+
 void set_image(GtkWidget *widget, GtkWidget *image)
 {
-	gtk_container_foreach(GTK_CONTAINER(widget), remove_child, widget);
+	vacate_widget(widget);
 	gtk_container_add(GTK_CONTAINER(widget), image);
 	gtk_widget_show_all(widget);
 }

Modified: trunk/eda/fped/gui_util.h
===================================================================
--- trunk/eda/fped/gui_util.h	2009-09-12 16:02:07 UTC (rev 5632)
+++ trunk/eda/fped/gui_util.h	2009-09-12 23:15:15 UTC (rev 5633)
@@ -57,6 +57,8 @@
 void label_in_box_fg(GtkWidget *box, const char *color);
 void label_in_box_bg(GtkWidget *box, const char *color);
 
+void vacate_widget(GtkWidget *widget);
+
 GtkWidget *make_image(GdkDrawable *drawable, char **xpm);
 void set_image(GtkWidget *widget, GtkWidget *image);
 GtkWidget *tool_button(GtkWidget *bar, GdkDrawable *drawable, char **xpm,

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c	2009-09-12 16:02:07 UTC (rev 5632)
+++ trunk/eda/fped/inst.c	2009-09-12 23:15:15 UTC (rev 5633)
@@ -742,6 +742,7 @@
 
 static void obj_pad_edit(struct obj *obj)
 {
+	edit_pad_type(&obj->u.pad.type);
 	edit_name(&obj->u.pad.name, validate_pad_name, NULL);
 }
 

Modified: trunk/eda/fped/obj.h
===================================================================
--- trunk/eda/fped/obj.h	2009-09-12 16:02:07 UTC (rev 5632)
+++ trunk/eda/fped/obj.h	2009-09-12 23:15:15 UTC (rev 5633)
@@ -144,6 +144,7 @@
 	pt_bare,	/* only copper (and finish) */
 	pt_paste,	/* only solder paste */
 	pt_mask,	/* only solder mask */
+	pt_n
 };
 
 struct frame_ref {




More information about the commitlog mailing list