[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gEDA-dev: Proof of concept PCB Library picker (PCB Patch)



Hi all,

Please find attached a proof of concept patch for the GTK Hid which
demonstrates a PCB which supports the "--library" option.

When invoked with this option, the main GUI window is not shown, and all
logging is dumped to stdout, rather than a the log window (which remains
unshown).

When called with --library, selecting a component in the library results
in its footprint string being emitted on stderr for the invoking program
to read.

(Yes, I relise it might be nicer to have errors on stderr, and this
other output and stdout, but it would be much more work to go through
and audit any possible printf in PCB.)


Previews will have to wait for another time, however it ought not to be
too hard with the pinout windows already available.

Next job is a generic scheme interface for attribute helpers in gschem,
and an example hook which makes use of "pcb --library"

Regards,

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)
Index: src/hid/gtk/gui-library-window.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/hid/gtk/gui-library-window.c,v
retrieving revision 1.4
diff -U3 -p -r1.4 gui-library-window.c
--- src/hid/gtk/gui-library-window.c	6 Dec 2006 15:10:17 -0000	1.4
+++ src/hid/gtk/gui-library-window.c	30 May 2007 00:07:45 -0000
@@ -106,6 +106,8 @@ entry_tree_selection_changed_cb (GtkTree
    */
   if (entry->Template == (char *) -1)
     {
+      if (ghidgui->library_picker)
+        fprintf (stderr, "%s\n", entry->ListEntry); /* Should this be stdout? */
       if (LoadElementToBuffer (PASTEBUFFER, entry->AllocatedMemory, True))
 	SetMode (PASTEBUFFER_MODE);
       return;
@@ -118,6 +120,8 @@ entry_tree_selection_changed_cb (GtkTree
   m4_args = g_strdup_printf ("'%s' '%s' '%s'", EMPTY (entry->Template),
 			     EMPTY (entry->Value), EMPTY (entry->Package));
 
+  if (ghidgui->library_picker)
+    fprintf (stderr, "%s\n", entry->Package); /* Should this be stdout? */
   if (LoadElementToBuffer (PASTEBUFFER, m4_args, False))
     SetMode (PASTEBUFFER_MODE);
   g_free (m4_args);
@@ -239,6 +243,8 @@ library_close_cb (gpointer data)
 {
   gtk_widget_destroy (library_window);
   library_window = NULL;
+  if (ghidgui->library_picker)
+    hid_action ("Quit");
 }
 
 static void
Index: src/hid/gtk/gui-log-window.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/hid/gtk/gui-log-window.c,v
retrieving revision 1.5
diff -U3 -p -r1.5 gui-log-window.c
--- src/hid/gtk/gui-log-window.c	6 Dec 2006 15:10:17 -0000	1.5
+++ src/hid/gtk/gui-log-window.c	30 May 2007 00:07:45 -0000
@@ -154,12 +154,14 @@ ghid_logv (const char *fmt, va_list args
    * that needed here?  Lesstif does it.
    */
 #ifdef FIXME
-  if (!mainwind)
+  if (!mainwind || ghidgui->library_picker)
+#endif
+
+  if (ghidgui->library_picker)
     {
       vprintf (fmt, args);
       return;
     }
-#endif
 
 #ifdef HAVE_VSNPRINTF
 
Index: src/hid/gtk/gui-top-window.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/hid/gtk/gui-top-window.c,v
retrieving revision 1.42
diff -U3 -p -r1.42 gui-top-window.c
--- src/hid/gtk/gui-top-window.c	23 May 2007 01:21:51 -0000	1.42
+++ src/hid/gtk/gui-top-window.c	30 May 2007 00:07:46 -0000
@@ -2549,6 +2549,15 @@ HID_Attribute ghid_attribute_list[] = {
 
 REGISTER_ATTRIBUTES (ghid_attribute_list)
 
+static int library_picker = 0;
+
+static HID_Attribute library_attr[] = {
+{"library", "Display the only the library picker",
+   HID_Boolean, 0, 0, {0, 0, 0}, 0, &library_picker}
+};
+
+REGISTER_ATTRIBUTES (library_attr)
+
   /* Create top level window for routines that will need top_window
      |  before ghid_create_pcb_widgets() is called.
    */
@@ -2636,8 +2645,13 @@ ghid_parse_arguments (int *argc, char **
   if (Settings.AutoPlace)
     gtk_widget_set_uposition (GTK_WIDGET (window), 10, 10);
 
-  gtk_widget_realize (gport->top_window);
-  gtk_widget_show_all (gport->top_window);
+  ghidgui->library_picker = library_picker;
+
+  if (!ghidgui->library_picker)
+    {
+      gtk_widget_realize (gport->top_window);
+      gtk_widget_show_all (gport->top_window);
+    }
   ghidgui->creating = TRUE;
 }
 
@@ -2665,13 +2679,16 @@ ghid_make_gc (void)
 void
 ghid_do_export (HID_Attr_Val * options)
 {
-  ghid_create_pcb_widgets ();
+  if ( !ghidgui->library_picker )
+    {
+      ghid_create_pcb_widgets ();
 
-  /* These are needed to make sure the @layerpick and @layerview menus
-   * are properly initialized and synchronized with the current PCB.
-   */
-  ghid_layer_buttons_update ();
-  ghid_show_layer_buttons();
+      /* These are needed to make sure the @layerpick and @layerview menus
+       * are properly initialized and synchronized with the current PCB.
+       */
+      ghid_layer_buttons_update ();
+      ghid_show_layer_buttons();
+  }
 
   if (stdin_listen)
     ghid_create_listener ();
@@ -2847,7 +2864,7 @@ static HID_Attribute pcbmenu_attr[] = {
 };
 
 REGISTER_ATTRIBUTES (pcbmenu_attr) 
-     
+
 /* 
  * This function is used to check if a specified hotkey in the menu
  * resource file is "special".  In this case "special" means that gtk
Index: src/hid/gtk/gui.h
===================================================================
RCS file: /cvsroot/pcb/pcb/src/hid/gtk/gui.h,v
retrieving revision 1.14
diff -U3 -p -r1.14 gui.h
--- src/hid/gtk/gui.h	1 May 2007 03:29:33 -0000	1.14
+++ src/hid/gtk/gui.h	30 May 2007 00:07:46 -0000
@@ -169,7 +169,8 @@ typedef struct
     small_label_markup,
     compact_horizontal,
     compact_vertical,
-    ghid_title_window, use_command_window, need_restore_crosshair, creating;
+    ghid_title_window, use_command_window, need_restore_crosshair, creating,
+    library_picker;
 
   gint n_mode_button_columns,
     top_window_width,


_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev