[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (17ae6c24c0ac2cd49b104496e3e650866d7ff29b)



The branch, master has been updated
       via  17ae6c24c0ac2cd49b104496e3e650866d7ff29b (commit)
       via  a2c8d70fddc6f1fcecce33452b717c4b5c9c4e57 (commit)
       via  4118a4bdcdaae5cb9ddf206744d693db4688a215 (commit)
       via  c874798634ea44e0384b48b18730b80d592b5377 (commit)
      from  7e95250675a70d8fec2bc9ed7ffb8ab067f4390b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/action.c              |   15 ++++----
 src/hid/lesstif/dialogs.c |   89 +++++++++++++++++++++++++++++++++++++++++++++
 src/misc.c                |   32 +++++++++++++++-
 src/misc.h                |    2 +-
 4 files changed, 128 insertions(+), 10 deletions(-)


=================
 Commit Messages
=================

commit 17ae6c24c0ac2cd49b104496e3e650866d7ff29b
Author: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>

    Implement lesstif ImportGUI()

:100644 100644 213c5f2... 72b41ee... M	src/hid/lesstif/dialogs.c

commit a2c8d70fddc6f1fcecce33452b717c4b5c9c4e57
Author: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>

    Add missing newline.

:100644 100644 5ace046... a81c142... M	src/action.c

commit 4118a4bdcdaae5cb9ddf206744d693db4688a215
Author: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>

    Let the GUI deal with choosing schematics.
    
    If the PCB is as yet unnamed, or if the pcb name doesn't
    correspond to a schematic file, have Import() call ImportGUI()
    to let the user tell PCB what to do.
    
    Note: corresponding HID changes are separate commits.

:100644 100644 c15c7c0... 5ace046... M	src/action.c

commit c874798634ea44e0384b48b18730b80d592b5377
Author: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>

    Add AttributePut functionality.
    
    Add the logic to put arbitrary attributes into a PCB.

:100644 100644 cca9e1b... d19970b... M	src/misc.c
:100644 100644 7f06804... 3634f9b... M	src/misc.h

=========
 Changes
=========

commit 17ae6c24c0ac2cd49b104496e3e650866d7ff29b
Author: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>

    Implement lesstif ImportGUI()

diff --git a/src/hid/lesstif/dialogs.c b/src/hid/lesstif/dialogs.c
index 213c5f2..72b41ee 100644
--- a/src/hid/lesstif/dialogs.c
+++ b/src/hid/lesstif/dialogs.c
@@ -2007,6 +2007,93 @@ lesstif_attributes_dialog (char *owner, AttributeListType *attrs_list)
   return;
 }
 
+/* ------------------------------------------------------------ */
+
+static const char importgui_syntax[] =
+"ImportGUI()";
+
+static const char importgui_help[] =
+"Lets the user choose the schematics to import from";
+
+/* %start-doc actions ImportGUI
+
+Displays a dialog that lets the user select the schematic(s) to import
+from, then saves that information in the layout's attributes for
+future imports.
+
+*/
+
+static int
+ImportGUI (int argc, char **argv, int x, int y)
+{
+  static int I_am_recursing = 0;
+  static XmString xms_sch = 0, xms_import = 0;
+  int rv;
+  XmString xmname;
+  char *name, *bname;
+  char *original_dir, *target_dir, *last_slash;
+
+  if (I_am_recursing)
+    return 1;
+
+  if (xms_sch == 0)
+    xms_sch = XmStringCreateLocalized ("*.sch");
+  if (xms_import == 0)
+    xms_import = XmStringCreateLocalized ("Import from");
+
+  setup_fsb_dialog ();
+
+  n = 0;
+  stdarg (XmNtitle, "Import From");
+  XtSetValues (XtParent (fsb), args, n);
+
+  n = 0;
+  stdarg (XmNpattern, xms_sch);
+  stdarg (XmNmustMatch, True);
+  stdarg (XmNselectionLabelString, xms_import);
+  XtSetValues (fsb, args, n);
+
+  n = 0;
+  stdarg (XmNdirectory, &xmname);
+  XtGetValues (fsb, args, n);
+  XmStringGetLtoR (xmname, XmFONTLIST_DEFAULT_TAG, &original_dir);
+
+  if (!wait_for_dialog (fsb))
+    return 1;
+
+  n = 0;
+  stdarg (XmNdirectory, &xmname);
+  XtGetValues (fsb, args, n);
+  XmStringGetLtoR (xmname, XmFONTLIST_DEFAULT_TAG, &target_dir);
+
+  n = 0;
+  stdarg (XmNdirSpec, &xmname);
+  XtGetValues (fsb, args, n);
+
+  XmStringGetLtoR (xmname, XmFONTLIST_DEFAULT_TAG, &name);
+
+  /* If the user didn't change directories, use just the base name.
+     This is the common case and means we don't have to get clever
+     about converting absolute paths into relative paths.  */
+  bname = name;
+  if (strcmp (original_dir, target_dir) == 0)
+    {
+      last_slash = strrchr (name, '/');
+      if (last_slash)
+	bname = last_slash + 1;
+    }
+
+  AttributePut (PCB, "import::src0", bname);
+
+  XtFree (name);
+
+
+  I_am_recursing = 1;
+  rv = hid_action ("Import");
+  I_am_recursing = 0;
+
+  return rv;
+}
 
 /* ------------------------------------------------------------ */
 
@@ -2034,6 +2121,8 @@ HID_Action lesstif_dialog_action_list[] = {
    adjustsizes_help, adjustsizes_syntax},
   {"EditLayerGroups", 0, EditLayerGroups,
    editlayergroups_help, editlayergroups_syntax},
+  {"ImportGUI", 0, ImportGUI,
+   importgui_help, importgui_syntax},
 };
 
 REGISTER_ACTIONS (lesstif_dialog_action_list)

commit a2c8d70fddc6f1fcecce33452b717c4b5c9c4e57
Author: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>

    Add missing newline.

diff --git a/src/action.c b/src/action.c
index 5ace046..a81c142 100644
--- a/src/action.c
+++ b/src/action.c
@@ -7070,7 +7070,7 @@ ActionElementSetAttr (int argc, char **argv, int x, int y)
 
   if (!e)
     {
-      Message("Cannot change attribute of %s - element not found", refdes);
+      Message("Cannot change attribute of %s - element not found\n", refdes);
       return 1;
     }
 

commit 4118a4bdcdaae5cb9ddf206744d693db4688a215
Author: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>

    Let the GUI deal with choosing schematics.
    
    If the PCB is as yet unnamed, or if the pcb name doesn't
    correspond to a schematic file, have Import() call ImportGUI()
    to let the user tell PCB what to do.
    
    Note: corresponding HID changes are separate commits.

diff --git a/src/action.c b/src/action.c
index c15c7c0..5ace046 100644
--- a/src/action.c
+++ b/src/action.c
@@ -7190,6 +7190,9 @@ overridden by the user via the @code{make-program} and @code{gnetlist}
 @code{pcb} settings (i.e. in @code{~/.pcb/settings} or on the command
 line).
 
+If @pcb{} cannot determine which schematic(s) to import from, the GUI
+is called to let user choose (see @code{ImportGUI()}).
+
 %end-doc */
 
 static int
@@ -7438,12 +7441,7 @@ ActionImport (int argc, char **argv, int x, int y)
       char *dot, *slash, *bslash;
 
       if (!pcbname)
-	{
-	  Message ("Please save your PCB first, so that it has a\n"
-		   "file name, or manually add an import::src0 attribute with\n"
-		   "the name of the schematic to import from.");
-	  return 1;
-	}
+	return hid_action("ImportGUI");
 
       schname = (char *) malloc (strlen(pcbname) + 5);
       strcpy (schname, pcbname);
@@ -7458,6 +7456,9 @@ ActionImport (int argc, char **argv, int x, int y)
 	*dot = 0;
       strcat (schname, ".sch");
 
+      if (access (schname, F_OK))
+	return hid_action("ImportGUI");
+
       sources = (char **) malloc (2 * sizeof (char *));
       sources[0] = schname;
       sources[1] = NULL;

commit c874798634ea44e0384b48b18730b80d592b5377
Author: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxxxxxxxxxx>

    Add AttributePut functionality.
    
    Add the logic to put arbitrary attributes into a PCB.

diff --git a/src/misc.c b/src/misc.c
index cca9e1b..d19970b 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1886,8 +1886,36 @@ AttributeGetFromList (AttributeListType *list, char *name)
 int
 AttributePutToList (AttributeListType *list, char *name, char *value, int replace)
 {
-  /* Not implemented yet.  */
-  abort ();
+  int i;
+
+  /* If we're allowed to replace an existing attribute, see if we
+     can.  */
+  if (replace)
+    {
+      for (i=0; i<list->Number; i++)
+	if (strcmp (name, list->List[i].name) == 0)
+	  {
+	    free (list->List[i].value);
+	    list->List[i].value = MyStrdup (value, "AttributePutToList");
+	    return 1;
+	  }
+    }
+
+  /* At this point, we're going to need to add a new attribute to the
+     list.  See if there's room.  */
+  if (list->Number >= list->Max)
+    {
+      list->Max += 10;
+      list->List = (AttributeType *) realloc (list->List,
+					      list->Max * sizeof (AttributeType));
+    }
+
+  /* Now add the new attribute.  */
+  i = list->Number;
+  list->List[i].name = MyStrdup (name, "AttributePutToList");
+  list->List[i].value = MyStrdup (value, "AttributePutToList");
+  list->Number ++;
+  return 0;
 }
 
 
diff --git a/src/misc.h b/src/misc.h
index 7f06804..3634f9b 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -85,7 +85,7 @@ char *pcb_author ();
 char *AttributeGetFromList (AttributeListType *list, char *name);
 /* Adds an attribute to the list.  If the attribute already exists,
    whether it's replaced or a second copy added depends on
-   REPLACE.  */
+   REPLACE.  Returns non-zero if an existing attribute was replaced.  */
 int AttributePutToList (AttributeListType *list, char *name, char *value, int replace);
 /* Simplistic version: Takes a pointer to an object, looks up attributes in it.  */
 #define AttributeGet(OBJ,name) AttributeGetFromList (&(OBJ->Attributes), name)




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