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

gEDA-cvs: pcb.git: branch: sdb-playpen updated (209e1031656f58ffe40189d93893457975c4042f)



The branch, sdb-playpen has been updated
       via  209e1031656f58ffe40189d93893457975c4042f (commit)
       via  fde396b99032150688e75819ff778a40237904d2 (commit)
       via  17ae6c24c0ac2cd49b104496e3e650866d7ff29b (commit)
       via  a2c8d70fddc6f1fcecce33452b717c4b5c9c4e57 (commit)
       via  4118a4bdcdaae5cb9ddf206744d693db4688a215 (commit)
       via  c874798634ea44e0384b48b18730b80d592b5377 (commit)
      from  282f7216dec565223415f16d5dc7517917aed776 (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              |    2 +-
 src/hid/gtk/gtkhid-main.c |   45 +++++++++++++++++++++++
 src/hid/gtk/gui-dialog.c  |   11 +++++-
 src/hid/lesstif/dialogs.c |   89 +++++++++++++++++++++++++++++++++++++++++++++
 src/misc.c                |   32 +++++++++++++++-
 src/misc.h                |    2 +-
 6 files changed, 176 insertions(+), 5 deletions(-)


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

commit 209e1031656f58ffe40189d93893457975c4042f
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Open schematic file chooser dialog if PCB name is not set.

:100644 100644 9f184a2... 5f2755d... M	src/hid/gtk/gtkhid-main.c
:100644 100644 7fcbf6d... 1697324... M	src/hid/gtk/gui-dialog.c

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 209e1031656f58ffe40189d93893457975c4042f
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Open schematic file chooser dialog if PCB name is not set.

diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 9f184a2..5f2755d 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -2205,7 +2205,51 @@ Popup (int argc, char **argv, int x, int y)
     }
   return 0;
 }
+/* ------------------------------------------------------------ */
+static const char importgui_syntax[] =
+"Popup(MenuName, [Button])";
+
+static const char importgui_help[] =
+"Asks user which schematics to import into PCB.\n";
+
+/* %start-doc actions ImportGUI
+
+Asks user which schematics to import into PCB.
+
+%end-doc */
+
+
+static int
+ImportGUI (int argc, char **argv, int x, int y)
+{
+    char *name = NULL;
+    static gchar *current_layout_dir = NULL;
+    static int I_am_recursing = 0; 
+    int rv;
 
+    if (I_am_recursing)
+	return 1;
+
+
+    name = ghid_dialog_file_select_open (_("Load schematics"),
+					 &current_layout_dir,
+					 Settings.FilePath);
+
+#ifdef DEBUG
+    printf("File selected = %s\n", name);
+#endif
+
+    AttributePut (PCB, "import::src0", name);
+    free (name);
+
+    I_am_recursing = 1;
+    rv = hid_action ("Import");
+    I_am_recursing = 0;
+
+    return rv;
+}
+
+/* ------------------------------------------------------------ */
 static int
 Busy (int argc, char **argv, int x, int y)
 {
@@ -2223,6 +2267,7 @@ HID_Action ghid_main_action_list[] = {
   {"DoWindows", 0, DoWindows, dowindows_help, dowindows_syntax},
   {"Export", 0, Export},
   {"GetXY", "", GetXY, getxy_help, getxy_syntax},
+  {"ImportGUI", 0, ImportGUI, importgui_help, importgui_syntax},
   {"LayerGroupsChanged", 0, LayerGroupsChanged},
   {"LibraryChanged", 0, LibraryChanged},
   {"Load", 0, Load},
diff --git a/src/hid/gtk/gui-dialog.c b/src/hid/gtk/gui-dialog.c
index 7fcbf6d..1697324 100644
--- a/src/hid/gtk/gui-dialog.c
+++ b/src/hid/gtk/gui-dialog.c
@@ -44,6 +44,7 @@
 
 RCSID ("$Id$");
 
+/* ---------------------------------------------- */
 gchar *
 ghid_dialog_input (gchar * prompt, gchar * initial)
 {
@@ -87,6 +88,7 @@ ghid_dialog_input (gchar * prompt, gchar * initial)
   return string;
 }
 
+/* ---------------------------------------------- */
 void
 ghid_dialog_about (void)
 {
@@ -103,6 +105,7 @@ ghid_dialog_about (void)
   gtk_widget_destroy (dialog);
 }
 
+/* ---------------------------------------------- */
 gint
 ghid_dialog_confirm_all (gchar * all_message)
 {
@@ -131,6 +134,7 @@ ghid_dialog_confirm_all (gchar * all_message)
   return response;
 }
 
+/* ---------------------------------------------- */
 void
 ghid_dialog_message (gchar * message)
 {
@@ -147,6 +151,7 @@ ghid_dialog_message (gchar * message)
   gtk_widget_destroy (dialog);
 }
 
+/* ---------------------------------------------- */
 gboolean
 ghid_dialog_confirm (gchar * message, gchar * cancelmsg, gchar * okmsg)
 {
@@ -188,6 +193,7 @@ ghid_dialog_confirm (gchar * message, gchar * cancelmsg, gchar * okmsg)
   return confirm;
 }
 
+/* ---------------------------------------------- */
 gint
 ghid_dialog_close_confirm ()
 {
@@ -255,6 +261,7 @@ ghid_dialog_close_confirm ()
   return rv;
 }
 
+/* ---------------------------------------------- */
 /* Caller must g_free() the returned filename.*/
 gchar *
 ghid_dialog_file_select_open (gchar * title, gchar ** path, gchar * shortcuts)
@@ -353,7 +360,7 @@ ghid_dialog_file_select_open (gchar * title, gchar ** path, gchar * shortcuts)
   return result;
 }
 
-
+/* ---------------------------------------------- */
 /* Caller must g_free() the returned filename. */
 gchar *
 ghid_dialog_file_select_save (gchar * title, gchar ** path, gchar * file,
@@ -408,6 +415,7 @@ ghid_dialog_file_select_save (gchar * title, gchar ** path, gchar * file,
 }
 
 
+/* ---------------------------------------------- */
 /* how many files and directories to keep for the shortcuts */
 #define NHIST 8
 typedef struct ghid_file_history_struct
@@ -427,6 +435,7 @@ typedef struct ghid_file_history_struct
 static int n_recent_dirs = 0;
 static ghid_file_history * recent_dirs = NULL;
 
+/* ---------------------------------------------- */
 /* Caller must g_free() the returned filename. */
 gchar *
 ghid_fileselect (const char *title, const char *descr,

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