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

gEDA-cvs: pcb.git: branch: master updated (2185dc1f86f7ffc830d950ca821080bc7238e7d6)



The branch, master has been updated
       via  2185dc1f86f7ffc830d950ca821080bc7238e7d6 (commit)
       via  46dab7d5d39aa9f45c59b50862c41c39e51d6f8c (commit)
       via  886348e148fdd2951983910c1f39b260831605c3 (commit)
       via  d0062d735ba2194a64cc78726c9867e3ffa39460 (commit)
       via  8e8fbf053f12bbd741d4842258e7f7f62f6e1799 (commit)
       via  da4b3b720d55aa5cfe9868f56d54cde7d5a02e5f (commit)
       via  b1a35c9c9afc64ebfcf2208bc13968a641da4b1a (commit)
       via  28f6cd1f67b6c3a7a9639ceea67b29474d5a649b (commit)
       via  880affd3b2680782e923c421136b4286c1e94c74 (commit)
       via  8d881c4fcaa2faddb2b4e47a8f6309c80d147632 (commit)
       via  2d7de84dd42cb9e2eccd8f41f878b4cacad3c895 (commit)
       via  7c0af9f92a78cafc9d81ca77937b26f18f0b5531 (commit)
       via  7ef3aa04772b11db6afd14c626a6c49882c5850b (commit)
       via  a86548a6c26429e0b420602f98152d881f84cc2a (commit)
      from  128ac62fe7270950eafb1c59c408bae974972e8d (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/draw.c                     |   14 ++--
 src/hid.h                      |   26 ++----
 src/hid/common/actions.c       |  224 ++++++++++++----------------------------
 src/hid/common/hidinit.c       |   18 +++-
 src/hid/gtk/gui-config.c       |    3 +-
 src/hid/gtk/gui-dialog-print.c |   30 +++++-
 src/hid/hidint.h               |    2 +-
 src/hid/lesstif/menu.c         |   15 ++--
 src/main.c                     |   51 ++++-----
 9 files changed, 149 insertions(+), 234 deletions(-)


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

commit 2185dc1f86f7ffc830d950ca821080bc7238e7d6
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Add function to register single action.
    
    The possibility to register a single action has been introduced with
    commit 337fa8ba8094cee1ed291cec7bf29895ac7c9d72 but then reverted later
    when changing way of passing context to action callback.

:100644 100644 823e4e3... 7b30022... M	src/hid.h
:100644 100644 7bc336a... a2ad612... M	src/hid/common/actions.c

commit 46dab7d5d39aa9f45c59b50862c41c39e51d6f8c
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Modify HID actions storage.
    
    It removes the HID_ActionNode structure and directly store registered
    actions in an array of HID_Action*.
    
    It also provides a nicer way of making sure the array is sorted and
    the code for binary search within the array has been removed in favor of
    a call to bsearch().

:100644 100644 04270f1... 7bc336a... M	src/hid/common/actions.c

commit 886348e148fdd2951983910c1f39b260831605c3
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud:  Set 'exporter' global variable before
    printing defaults.
    
    In print_defaults(), when the HID to print defaults is not a gui, set
    'exporter' global variable prior to calling HID's get_export_options()
    callback.

:100644 100644 3c5ecae... 2fe588c... M	src/main.c

commit d0062d735ba2194a64cc78726c9867e3ffa39460
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud:  Rewrite function that print HID options.
    
    The previous version of usage_hid() had a strange search for gui HID
    attributes through 'hid_attr_node' rather than requesting them directly
    from the HID.
    
    As a result it was calling the get_export_options() callback on exporter
    without prior setting of the exporter global variable.

:100644 100644 99dcba1... 3c5ecae... M	src/main.c

commit 8e8fbf053f12bbd741d4842258e7f7f62f6e1799
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: gtkhid: Avoid use of 'exporter' when testing
    for exporter availability.

:100644 100644 1d4fbda... 0c50aed... M	src/hid/gtk/gui-dialog-print.c

commit da4b3b720d55aa5cfe9868f56d54cde7d5a02e5f
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud:  gtkhid: Set and unset global variable
    'exporter' when printing.
    
    The GTK hid was not setting the global variable 'exporter' before
    exporting the layout in ghid_dialog_print(): exporter HID relying on
    this variable being set were lost.

:100644 100644 c5c2fff... 1d4fbda... M	src/hid/gtk/gui-dialog-print.c

commit b1a35c9c9afc64ebfcf2208bc13968a641da4b1a
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud:  Provide context to callbacks of actions
    through global variable.
    
    Providing a context to action is necessary for scripting languages (for
    example). To do so, a global variable ('current_action') is being
    defined: it is saved, set and restored when running the callback of an
    action in a way similar to what PCB already does with HIDs.
    
    The callback function may access the action it belongs to and cast it
    the way it wants to extract information from a potentially extended
    HID_Action structure.

:100644 100644 067beb0... 823e4e3... M	src/hid.h
:100644 100644 123a2f4... 04270f1... M	src/hid/common/actions.c
:100644 100644 f391778... 9869483... M	src/hid/lesstif/menu.c

commit 28f6cd1f67b6c3a7a9639ceea67b29474d5a649b
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Sort actions by references in 'all_actions'.
    
    Previously, when building 'all_actions', a copy of every HID_Action
    was performed for each action. Now it builds 'all_actions' with pointers
    to the actual HID_Action structures (without reallocating).

:100644 100644 e172d51... 123a2f4... M	src/hid/common/actions.c

commit 880affd3b2680782e923c421136b4286c1e94c74
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Revert "single-action register/deregister".
    
    This reverts commits 337fa8ba8094cee1ed291cec7bf29895ac7c9d72 and
    b274cf8fe9c8caf5bcd4edc28935c88cf5bab7f4 before the introduction of a
    new context passing scheme for actions.

:100644 100644 9b26ef8... 067beb0... M	src/hid.h
:100644 100644 8678ad9... e172d51... M	src/hid/common/actions.c
:100644 100644 5840e20... a2148a0... M	src/hid/hidint.h
:100644 100644 d3e421d... f391778... M	src/hid/lesstif/menu.c

commit 8d881c4fcaa2faddb2b4e47a8f6309c80d147632
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud:  Fix comment for global variable 'gui' in
    hid.h.
    
    hid_start_gui() does not exist. The variable is instead set in main()
    and hid_expose_callback().

:100644 100644 7409bbf... 9b26ef8... M	src/hid.h

commit 2d7de84dd42cb9e2eccd8f41f878b4cacad3c895
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Modify DrawSpecialPolygon() prototype to not
    take a pointer on HID.
    
    DrawSpecialPolygon() was the only function to take a HID as parameter.
    Every other draw function works on the current HID through global
    variable 'gui'.

:100644 100644 9571b29... d06813d... M	src/draw.c

commit 7c0af9f92a78cafc9d81ca77937b26f18f0b5531
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Support HID_Mixed options in attribute dialog
    
    Since an HID_Mixed attribute is the combination of a real and an enum,
    reuse the code for HID_Enum to provide a combo box next to the spin button
    for the real part.

:100644 100644 922b719... c5c2fff... M	src/hid/gtk/gui-dialog-print.c

commit 7ef3aa04772b11db6afd14c626a6c49882c5850b
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud.
    
    Modified code to not abort on HID_Mixed attributes. Th gtk HID is
    modified to understand such an attribute (though the attribute dialog
    has still no support for them), the lesstif HID is unchanged.

:100644 100644 9581d32... bb1a66b... M	src/hid/common/hidinit.c
:100644 100644 490befc... c9bf82b... M	src/hid/gtk/gui-config.c
:100644 100644 5f68465... 99dcba1... M	src/main.c

commit a86548a6c26429e0b420602f98152d881f84cc2a
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Applying patch from Patrick Bernaud.
    
    HIDs with a name too long were breaking alignement in usage() as the
    code requested insertion of a tab after the name even for HID names
    already exceeding the length of the tabulation.
    
    This is similar to how usage_attr() already does alignment of
    name and help text.

:100644 100644 162a0e0... 5f68465... M	src/main.c

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

commit 2185dc1f86f7ffc830d950ca821080bc7238e7d6
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Add function to register single action.
    
    The possibility to register a single action has been introduced with
    commit 337fa8ba8094cee1ed291cec7bf29895ac7c9d72 but then reverted later
    when changing way of passing context to action callback.

diff --git a/src/hid.h b/src/hid.h
index 823e4e3..7b30022 100644
--- a/src/hid.h
+++ b/src/hid.h
@@ -86,6 +86,8 @@ extern "C"
     const char *syntax;
   } HID_Action;
 
+  extern void hid_register_action (HID_Action *);
+
   extern void hid_register_actions (HID_Action *, int);
 #define REGISTER_ACTIONS(a) HIDCONCAT(void register_,a) ()\
 { hid_register_actions(a, sizeof(a)/sizeof(a[0])); }
diff --git a/src/hid/common/actions.c b/src/hid/common/actions.c
index 7bc336a..a2ad612 100644
--- a/src/hid/common/actions.c
+++ b/src/hid/common/actions.c
@@ -40,6 +40,12 @@ hid_register_actions (HID_Action * a, int n)
   all_actions_sorted = 0;
 }
 
+void
+hid_register_action (HID_Action * a)
+{
+  hid_register_actions (a, 1);
+}
+
 static int
 action_sort_compar (const void *va, const void *vb)
 {

commit 46dab7d5d39aa9f45c59b50862c41c39e51d6f8c
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Modify HID actions storage.
    
    It removes the HID_ActionNode structure and directly store registered
    actions in an array of HID_Action*.
    
    It also provides a nicer way of making sure the array is sorted and
    the code for binary search within the array has been removed in favor of
    a call to bsearch().

diff --git a/src/hid/common/actions.c b/src/hid/common/actions.c
index 04270f1..7bc336a 100644
--- a/src/hid/common/actions.c
+++ b/src/hid/common/actions.c
@@ -21,81 +21,64 @@
 
 RCSID ("$Id$");
 
-typedef struct HID_ActionNode
-{
-  struct HID_ActionNode *next;
-  HID_Action *actions;
-  int n;
-} HID_ActionNode;
-
-HID_ActionNode *hid_action_nodes = 0;
-static int n_actions = 0;
 static HID_Action **all_actions = 0;
+static int all_actions_sorted = 0;
+static int n_actions = 0;
 
 HID_Action *current_action = NULL;
 
 void
 hid_register_actions (HID_Action * a, int n)
 {
-  HID_ActionNode *ha;
-
-  /*printf("%d actions registered\n", n); */
-  ha = (HID_ActionNode *) malloc (sizeof (HID_ActionNode));
-  ha->next = hid_action_nodes;
-  hid_action_nodes = ha;
-  ha->actions = a;
-  ha->n = n;
+  int i;
+  
+  all_actions = realloc (all_actions,
+                         (n_actions + n) * sizeof (HID_Action*));
+  for (i = 0; i < n; i++)
+    all_actions[n_actions + i] = a + i;
   n_actions += n;
-  if (all_actions)
-    {
-      free (all_actions);
-      all_actions = 0;
-    }
+  all_actions_sorted = 0;
 }
 
 static int
-action_sort (const void *va, const void *vb)
+action_sort_compar (const void *va, const void *vb)
 {
   HID_Action *a = *(HID_Action **) va;
   HID_Action *b = *(HID_Action **) vb;
   return strcmp (a->name, b->name);
 }
 
+static void
+sort_actions ()
+{
+  qsort (all_actions, n_actions, sizeof (HID_Action*), action_sort_compar);
+  all_actions_sorted = 1;
+}
+
+static int
+action_search_compar (const void *va, const void *vb)
+{
+  char *name = (char*)va;
+  HID_Action *action = *(HID_Action**)vb;
+  return strcmp (name, action->name);
+}
+
 HID_Action *
 hid_find_action (const char *name)
 {
-  HID_ActionNode *ha;
-  int i, n, lower, upper;
-
+  HID_Action **action;
+  int i;
+  
   if (name == NULL)
     return 0;
 
-  if (all_actions == 0)
-    {
-      n = 0;
-      all_actions = malloc (n_actions * sizeof (HID_Action*));
-      for (ha = hid_action_nodes; ha; ha = ha->next)
-	for (i = 0; i < ha->n; i++)
-	  all_actions[n++] = &(ha->actions[i]);
-      qsort (all_actions, n_actions, sizeof (HID_Action*), action_sort);
-    }
-
+  if (!all_actions_sorted)
+    sort_actions ();
 
-  lower = -1;
-  upper = n_actions;
-  /*printf("search action %s\n", name); */
-  while (lower < upper - 1)
-    {
-      i = (lower + upper) / 2;
-      n = strcmp (all_actions[i]->name, name);
-      /*printf("try [%d].%s, cmp %d\n", i, all_actions[i].name, n); */
-      if (n == 0)
-	return all_actions[i];
-      if (n > 0)
-	upper = i;
-      else
-	lower = i;
-    }
+  action = bsearch (name, all_actions, n_actions, sizeof (HID_Action*),
+                    action_search_compar);
+  if (action)
+    return *action;
 
   for (i = 0; i < n_actions; i++)
     if (strcasecmp (all_actions[i]->name, name) == 0)
@@ -109,8 +92,10 @@ void
 print_actions ()
 {
   int i;
-  /* Forces them to be sorted in all_actions */
-  hid_find_action (hid_action_nodes->actions[0].name);
+
+  if (!all_actions_sorted)
+    sort_actions ();
+  
   fprintf (stderr, "Registered Actions:\n");
   for (i = 0; i < n_actions; i++)
     {
@@ -162,8 +147,10 @@ void
 dump_actions ()
 {
   int i;
-  /* Forces them to be sorted in all_actions */
-  hid_find_action (hid_action_nodes->actions[0].name);
+
+  if (!all_actions_sorted)
+    sort_actions ();
+
   for (i = 0; i < n_actions; i++)
     {
       const char *desc = all_actions[i]->description;

commit 886348e148fdd2951983910c1f39b260831605c3
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud:  Set 'exporter' global variable before
    printing defaults.
    
    In print_defaults(), when the HID to print defaults is not a gui, set
    'exporter' global variable prior to calling HID's get_export_options()
    callback.

diff --git a/src/main.c b/src/main.c
index 3c5ecae..2fe588c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -332,7 +332,9 @@ print_defaults ()
       else
 	{
 	  fprintf (stderr, "\n%s defaults:\n", h->name);
-	  e = h->get_export_options (&n);
+	  exporter = h;
+	  e = exporter->get_export_options (&n);
+	  exporter = NULL;
 	  if (e)
 	    for (i = 0; i < n; i++)
 	      print_defaults_1 (e + i, 0);

commit d0062d735ba2194a64cc78726c9867e3ffa39460
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud:  Rewrite function that print HID options.
    
    The previous version of usage_hid() had a strange search for gui HID
    attributes through 'hid_attr_node' rather than requesting them directly
    from the HID.
    
    As a result it was calling the get_export_options() callback on exporter
    without prior setting of the exporter global variable.

diff --git a/src/main.c b/src/main.c
index 99dcba1..3c5ecae 100644
--- a/src/main.c
+++ b/src/main.c
@@ -200,33 +200,24 @@ usage_attr (HID_Attribute * a)
 static void
 usage_hid (HID * h)
 {
-  HID_Attribute *e;
-  int i, n;
+  HID_Attribute *attributes;
+  int i, n_attributes = 0;
 
   if (h->gui)
     {
-      HID **hl = hid_enumerate ();
-      HID_AttrNode *ha;
       fprintf (stderr, "\n%s gui options:\n", h->name);
-      for (ha = hid_attr_nodes; ha; ha = ha->next)
-	{
-	  for (i = 0; hl[i]; i++)
-	    if (ha->attributes == hl[i]->get_export_options (0))
-	      goto skip_this_one;
-	  for (i = 0; i < ha->n; i++)
-	    usage_attr (ha->attributes + i);
-	skip_this_one:;
-	}
-      return;
+      attributes = h->get_export_options (&n_attributes);
     }
-  fprintf (stderr, "\n%s options:\n", h->name);
-  exporter = h;
-  e = h->get_export_options (&n);
-  if (!e)
-    return;
-  for (i = 0; i < n; i++)
-    usage_attr (e + i);
-  exporter = NULL;
+  else
+    {
+      fprintf (stderr, "\n%s options:\n", h->name);
+      exporter = h;
+      attributes = exporter->get_export_options (&n_attributes);
+      exporter = NULL;
+    }
+  
+  for (i = 0; i < n_attributes; i++)
+    usage_attr (attributes + i);
 }
 
 static void

commit 8e8fbf053f12bbd741d4842258e7f7f62f6e1799
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: gtkhid: Avoid use of 'exporter' when testing
    for exporter availability.

diff --git a/src/hid/gtk/gui-dialog-print.c b/src/hid/gtk/gui-dialog-print.c
index 1d4fbda..0c50aed 100644
--- a/src/hid/gtk/gui-dialog-print.c
+++ b/src/hid/gtk/gui-dialog-print.c
@@ -367,6 +367,7 @@ ghid_dialog_export (void)
   int i;
   HID **hids;
   GtkTooltips *tips;
+  gboolean no_exporter = TRUE;
 
   tips = gtk_tooltips_new ();
 
@@ -395,7 +396,7 @@ ghid_dialog_export (void)
     {
       if (hids[i]->exporter)
 	{
-	  exporter = hids[i];
+	  no_exporter = FALSE;
 	  button = gtk_button_new_with_label (hids[i]->name);
 	  gtk_tooltips_set_tip (tips, button, hids[i]->description, NULL);
 	  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
@@ -404,7 +405,7 @@ ghid_dialog_export (void)
 	}
     }
 
-  if (exporter == NULL)
+  if (no_exporter)
     {
       gui->log (_("Can't find a suitable exporter HID"));
     }
@@ -415,6 +416,4 @@ ghid_dialog_export (void)
   if (export_dialog != NULL)
     gtk_widget_destroy (export_dialog);
   export_dialog = NULL;
-
-  exporter = NULL;
 }

commit da4b3b720d55aa5cfe9868f56d54cde7d5a02e5f
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud:  gtkhid: Set and unset global variable
    'exporter' when printing.
    
    The GTK hid was not setting the global variable 'exporter' before
    exporting the layout in ghid_dialog_print(): exporter HID relying on
    this variable being set were lost.

diff --git a/src/hid/gtk/gui-dialog-print.c b/src/hid/gtk/gui-dialog-print.c
index c5c2fff..1d4fbda 100644
--- a/src/hid/gtk/gui-dialog-print.c
+++ b/src/hid/gtk/gui-dialog-print.c
@@ -315,7 +315,7 @@ exporter_clicked_cb (GtkButton * button, HID * exporter)
 }
 
 void
-ghid_dialog_print (HID *exporter)
+ghid_dialog_print (HID *hid)
 {
   HID_Attribute *attr;
   int n = 0;
@@ -326,6 +326,8 @@ ghid_dialog_print (HID *exporter)
   if (export_dialog)
     gtk_dialog_response (GTK_DIALOG (export_dialog), GTK_RESPONSE_CANCEL);
 
+  exporter = hid;
+
   attr = exporter->get_export_options (&n);
   if (n > 0)
     {
@@ -354,6 +356,7 @@ ghid_dialog_print (HID *exporter)
   if (results)
     free (results);
 
+  exporter = NULL;
 }
 
 void

commit b1a35c9c9afc64ebfcf2208bc13968a641da4b1a
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud:  Provide context to callbacks of actions
    through global variable.
    
    Providing a context to action is necessary for scripting languages (for
    example). To do so, a global variable ('current_action') is being
    defined: it is saved, set and restored when running the callback of an
    action in a way similar to what PCB already does with HIDs.
    
    The callback function may access the action it belongs to and cast it
    the way it wants to extract information from a potentially extended
    HID_Action structure.

diff --git a/src/hid.h b/src/hid.h
index 067beb0..823e4e3 100644
--- a/src/hid.h
+++ b/src/hid.h
@@ -579,6 +579,10 @@ typedef enum
 	do the exporting. The gui HIDs set and unset this var.*/
   extern HID *exporter;
 
+/* This is either NULL or points to the current HID_Action that is being
+   called. The action launcher sets and unsets this variable. */
+  extern HID_Action *current_action;
+
 /* The GUI may set this to be approximately the PCB size of a pixel,
    to allow for near-misses in selection and changes in drawing items
    smaller than a screen pixel.  */
diff --git a/src/hid/common/actions.c b/src/hid/common/actions.c
index 123a2f4..04270f1 100644
--- a/src/hid/common/actions.c
+++ b/src/hid/common/actions.c
@@ -32,6 +32,8 @@ HID_ActionNode *hid_action_nodes = 0;
 static int n_actions = 0;
 static HID_Action **all_actions = 0;
 
+HID_Action *current_action = NULL;
+
 void
 hid_register_actions (HID_Action * a, int n)
 {
@@ -200,8 +202,8 @@ hid_actionl (const char *name, ...)
 int
 hid_actionv (const char *name, int argc, char **argv)
 {
-  int x = 0, y = 0, i;
-  HID_Action *a;
+  int x = 0, y = 0, i, ret;
+  HID_Action *a, *old_action;
 
   if (Settings.verbose && name)
     {
@@ -216,7 +218,13 @@ hid_actionv (const char *name, int argc, char **argv)
     return 1;
   if (a->need_coord_msg)
     gui->get_coords (a->need_coord_msg, &x, &y);
-  return a->trigger_cb (argc, argv, x, y);
+  
+  old_action     = current_action;
+  current_action = a;
+  ret = current_action->trigger_cb (argc, argv, x, y);
+  current_action = old_action;
+  
+  return ret;
 }
 
 int
diff --git a/src/hid/lesstif/menu.c b/src/hid/lesstif/menu.c
index f391778..9869483 100644
--- a/src/hid/lesstif/menu.c
+++ b/src/hid/lesstif/menu.c
@@ -815,8 +815,8 @@ lesstif_get_coords (const char *msg, int *px, int *py)
 int
 lesstif_call_action (const char *aname, int argc, char **argv)
 {
-  int px, py;
-  HID_Action *a;
+  int px, py, ret;
+  HID_Action *a, *old_action;
 
   if (!aname)
     return 1;
@@ -850,7 +850,13 @@ lesstif_call_action (const char *aname, int argc, char **argv)
 	printf ("%s%s", i ? "," : "", argv[i]);
       printf (")\033[0m\n");
     }
-  return a->trigger_cb (argc, argv, px, py);
+
+  old_action     = current_action;
+  current_action = a;
+  ret = current_action->trigger_cb (argc, argv, x, y);
+  current_action = old_action;
+
+  return ret;
 }
 
 static void

commit 28f6cd1f67b6c3a7a9639ceea67b29474d5a649b
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Sort actions by references in 'all_actions'.
    
    Previously, when building 'all_actions', a copy of every HID_Action
    was performed for each action. Now it builds 'all_actions' with pointers
    to the actual HID_Action structures (without reallocating).

diff --git a/src/hid/common/actions.c b/src/hid/common/actions.c
index e172d51..123a2f4 100644
--- a/src/hid/common/actions.c
+++ b/src/hid/common/actions.c
@@ -30,7 +30,7 @@ typedef struct HID_ActionNode
 
 HID_ActionNode *hid_action_nodes = 0;
 static int n_actions = 0;
-static HID_Action *all_actions = 0;
+static HID_Action **all_actions = 0;
 
 void
 hid_register_actions (HID_Action * a, int n)
@@ -54,8 +54,8 @@ hid_register_actions (HID_Action * a, int n)
 static int
 action_sort (const void *va, const void *vb)
 {
-  HID_Action *a = (HID_Action *) va;
-  HID_Action *b = (HID_Action *) vb;
+  HID_Action *a = *(HID_Action **) va;
+  HID_Action *b = *(HID_Action **) vb;
   return strcmp (a->name, b->name);
 }
 
@@ -71,11 +71,11 @@ hid_find_action (const char *name)
   if (all_actions == 0)
     {
       n = 0;
-      all_actions = malloc (n_actions * sizeof (HID_Action));
+      all_actions = malloc (n_actions * sizeof (HID_Action*));
       for (ha = hid_action_nodes; ha; ha = ha->next)
 	for (i = 0; i < ha->n; i++)
-	  all_actions[n++] = ha->actions[i];
-      qsort (all_actions, n_actions, sizeof (HID_Action), action_sort);
+	  all_actions[n++] = &(ha->actions[i]);
+      qsort (all_actions, n_actions, sizeof (HID_Action*), action_sort);
     }
 
 
@@ -85,10 +85,10 @@ hid_find_action (const char *name)
   while (lower < upper - 1)
     {
       i = (lower + upper) / 2;
-      n = strcmp (all_actions[i].name, name);
+      n = strcmp (all_actions[i]->name, name);
       /*printf("try [%d].%s, cmp %d\n", i, all_actions[i].name, n); */
       if (n == 0)
-	return all_actions + i;
+	return all_actions[i];
       if (n > 0)
 	upper = i;
       else
@@ -96,8 +96,8 @@ hid_find_action (const char *name)
     }
 
   for (i = 0; i < n_actions; i++)
-    if (strcasecmp (all_actions[i].name, name) == 0)
-      return all_actions + i;
+    if (strcasecmp (all_actions[i]->name, name) == 0)
+      return all_actions[i];
 
   printf ("unknown action `%s'\n", name);
   return 0;
@@ -112,15 +112,15 @@ print_actions ()
   fprintf (stderr, "Registered Actions:\n");
   for (i = 0; i < n_actions; i++)
     {
-      if (all_actions[i].description)
-	fprintf (stderr, "  %s - %s\n", all_actions[i].name,
-		 all_actions[i].description);
+      if (all_actions[i]->description)
+	fprintf (stderr, "  %s - %s\n", all_actions[i]->name,
+		 all_actions[i]->description);
       else
-	fprintf (stderr, "  %s\n", all_actions[i].name);
-      if (all_actions[i].syntax)
+	fprintf (stderr, "  %s\n", all_actions[i]->name);
+      if (all_actions[i]->syntax)
 	{
 	  const char *bb, *eb;
-	  bb = eb = all_actions[i].syntax;
+	  bb = eb = all_actions[i]->syntax;
 	  while (1)
 	    {
 	      for (eb = bb; *eb && *eb != '\n'; eb++)
@@ -164,13 +164,13 @@ dump_actions ()
   hid_find_action (hid_action_nodes->actions[0].name);
   for (i = 0; i < n_actions; i++)
     {
-      const char *desc = all_actions[i].description;
-      const char *synt = all_actions[i].syntax;
+      const char *desc = all_actions[i]->description;
+      const char *synt = all_actions[i]->syntax;
 
       desc = desc ? desc : "";
       synt = synt ? synt : "";
 
-      printf ("A%s\n", all_actions[i].name);
+      printf ("A%s\n", all_actions[i]->name);
       dump_string ('D', desc);
       dump_string ('S', synt);
     }

commit 880affd3b2680782e923c421136b4286c1e94c74
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Revert "single-action register/deregister".
    
    This reverts commits 337fa8ba8094cee1ed291cec7bf29895ac7c9d72 and
    b274cf8fe9c8caf5bcd4edc28935c88cf5bab7f4 before the introduction of a
    new context passing scheme for actions.

diff --git a/src/hid.h b/src/hid.h
index 9b26ef8..067beb0 100644
--- a/src/hid.h
+++ b/src/hid.h
@@ -86,25 +86,7 @@ extern "C"
     const char *syntax;
   } HID_Action;
 
-  /* This global variable is always set to the action context, before
-     an action callback is called. Action context can be specified
-     when registering an action with hid_register_action() Intended
-     for plugins with hub action callbacks. */
-  extern void *hid_action_context;
-
-  /* Register a singe action associated with an action context. Makes
-     a copy of HID_Action.  Intended for plugins to register actions
-     with a hub callback. */
-  extern void hid_register_action(const HID_Action *, void *);
-
-  /* Deregister an action registered using hid_register_action().
-     Action context pointer is copied in the 2nd argument if it's not
-     NULL.  Intended for plugins to deregister custom actions. */
-  extern void hid_deregister_action(const char *, void **);
-
-  /* Register a list of static actions without action context */
   extern void hid_register_actions (HID_Action *, int);
-
 #define REGISTER_ACTIONS(a) HIDCONCAT(void register_,a) ()\
 { hid_register_actions(a, sizeof(a)/sizeof(a[0])); }
 
diff --git a/src/hid/common/actions.c b/src/hid/common/actions.c
index 8678ad9..e172d51 100644
--- a/src/hid/common/actions.c
+++ b/src/hid/common/actions.c
@@ -8,7 +8,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#include <assert.h>
 
 #include "global.h"
 #include "data.h"
@@ -27,29 +26,14 @@ typedef struct HID_ActionNode
   struct HID_ActionNode *next;
   HID_Action *actions;
   int n;
-  /* The registrar the callback function may use this pointer to
-     remember context; the action infrastructure will just pass it
-     along. */
-  void *context;
-  /* is this ActionNode registered runtime? (can be deregistered) */
-  int dynamic;
 } HID_ActionNode;
 
-/* The master list of all actions registered */ 
-typedef struct HID_ActionContext
-{
-  HID_Action action;
-  void *context;
-} HID_ActionContext;
+HID_ActionNode *hid_action_nodes = 0;
 static int n_actions = 0;
-static HID_ActionContext *all_actions = NULL;
-
-HID_ActionNode *hid_action_nodes = NULL;
+static HID_Action *all_actions = 0;
 
-void *hid_action_context = NULL;
-
-static void
-hid_register_actions_context (HID_Action * a, int n, void *context, int dynamic)
+void
+hid_register_actions (HID_Action * a, int n)
 {
   HID_ActionNode *ha;
 
@@ -57,87 +41,26 @@ hid_register_actions_context (HID_Action * a, int n, void *context, int dynamic)
   ha = (HID_ActionNode *) malloc (sizeof (HID_ActionNode));
   ha->next = hid_action_nodes;
   hid_action_nodes = ha;
-  if (dynamic) {
-    assert(n == 1); /* we register dynamic actions one by one */
-    ha->actions = malloc(sizeof(HID_Action));
-    memcpy(ha->actions, a, sizeof(HID_Action));
-  }
-  else
-    ha->actions = a;
-
+  ha->actions = a;
   ha->n = n;
-  ha->context = context;
-  ha->dynamic = dynamic;
   n_actions += n;
   if (all_actions)
     {
       free (all_actions);
-      all_actions = NULL;
+      all_actions = 0;
     }
 }
 
-void
-hid_register_actions (HID_Action * a, int n)
-{
-  hid_register_actions_context (a, n, NULL, 0);
-}
-
-void
-hid_register_action (const HID_Action * a, void *context)
-{
-  hid_register_actions_context (a, 1, context, 1);
-}
-
-void
-hid_deregister_action (const char *name, void **context)
-{
-  HID_ActionNode *prev, *ha;
-
-  if (context != NULL)
-    *context = NULL;
-
-  /* find the action in hid_action_nodes */
-  for(prev = NULL, ha = hid_action_nodes; ha != NULL; prev = ha, ha = ha->next) {
-    if (ha->dynamic) {
-      if (strcmp(ha->actions->name, name) == 0) {
-	/* found the action in the tree, save context */
-	if (context != NULL)
-	  *context = ha->context;
-
-	/* remove ha */
-	if (prev == NULL)
-	  hid_action_nodes = ha->next;
-	else
-	  prev->next = ha->next;
-
-	free(ha->actions);
-	free(ha);
-
-	/* to make sure the rebuild of the sorted list next time */
-	if (all_actions != NULL) {
-	  free (all_actions);
-	  all_actions = NULL;
-	}
-
-	n_actions--;
-	return;
-      }
-    }
-  }
-
-  /* action not found - nothing to do */
-}
-
 static int
 action_sort (const void *va, const void *vb)
 {
-  HID_ActionContext *a = (HID_ActionContext *) va;
-  HID_ActionContext *b = (HID_ActionContext *) vb;
-  return strcmp (a->action.name, b->action.name);
+  HID_Action *a = (HID_Action *) va;
+  HID_Action *b = (HID_Action *) vb;
+  return strcmp (a->name, b->name);
 }
 
 HID_Action *
-hid_find_action (const char *name, void **context)
+hid_find_action (const char *name)
 {
   HID_ActionNode *ha;
   int i, n, lower, upper;
@@ -145,17 +68,14 @@ hid_find_action (const char *name, void **context)
   if (name == NULL)
     return 0;
 
-  if (all_actions == NULL)
+  if (all_actions == 0)
     {
       n = 0;
-      all_actions = malloc (n_actions * sizeof (HID_ActionContext));
+      all_actions = malloc (n_actions * sizeof (HID_Action));
       for (ha = hid_action_nodes; ha; ha = ha->next)
-	for (i = 0; i < ha->n; i++) {
-	  all_actions[n].action = ha->actions[i];
-	  all_actions[n].context = ha->context;
-	  n++;
-	}
-      qsort (all_actions, n_actions, sizeof (HID_ActionContext), action_sort);
+	for (i = 0; i < ha->n; i++)
+	  all_actions[n++] = ha->actions[i];
+      qsort (all_actions, n_actions, sizeof (HID_Action), action_sort);
     }
 
 
@@ -165,13 +85,10 @@ hid_find_action (const char *name, void **context)
   while (lower < upper - 1)
     {
       i = (lower + upper) / 2;
-      n = strcmp (all_actions[i].action.name, name);
+      n = strcmp (all_actions[i].name, name);
       /*printf("try [%d].%s, cmp %d\n", i, all_actions[i].name, n); */
-      if (n == 0) {
-	if (context != NULL)
-	  *context = all_actions[i].context;
-	return &(all_actions[i].action);
-      }
+      if (n == 0)
+	return all_actions + i;
       if (n > 0)
 	upper = i;
       else
@@ -179,11 +96,8 @@ hid_find_action (const char *name, void **context)
     }
 
   for (i = 0; i < n_actions; i++)
-    if (strcasecmp (all_actions[i].action.name, name) == 0) {
-      if (context != NULL)
-        *context = all_actions[i].context;
-      return &(all_actions[i].action);
-    }
+    if (strcasecmp (all_actions[i].name, name) == 0)
+      return all_actions + i;
 
   printf ("unknown action `%s'\n", name);
   return 0;
@@ -194,19 +108,19 @@ print_actions ()
 {
   int i;
   /* Forces them to be sorted in all_actions */
-  hid_find_action (hid_action_nodes->actions[0].name, NULL);
+  hid_find_action (hid_action_nodes->actions[0].name);
   fprintf (stderr, "Registered Actions:\n");
   for (i = 0; i < n_actions; i++)
     {
-      if (all_actions[i].action.description)
-	fprintf (stderr, "  %s - %s\n", all_actions[i].action.name,
-		 all_actions[i].action.description);
+      if (all_actions[i].description)
+	fprintf (stderr, "  %s - %s\n", all_actions[i].name,
+		 all_actions[i].description);
       else
-	fprintf (stderr, "  %s\n", all_actions[i].action.name);
-      if (all_actions[i].action.syntax)
+	fprintf (stderr, "  %s\n", all_actions[i].name);
+      if (all_actions[i].syntax)
 	{
 	  const char *bb, *eb;
-	  bb = eb = all_actions[i].action.syntax;
+	  bb = eb = all_actions[i].syntax;
 	  while (1)
 	    {
 	      for (eb = bb; *eb && *eb != '\n'; eb++)
@@ -247,16 +161,16 @@ dump_actions ()
 {
   int i;
   /* Forces them to be sorted in all_actions */
-  hid_find_action (hid_action_nodes->actions[0].name, NULL);
+  hid_find_action (hid_action_nodes->actions[0].name);
   for (i = 0; i < n_actions; i++)
     {
-      const char *desc = all_actions[i].action.description;
-      const char *synt = all_actions[i].action.syntax;
+      const char *desc = all_actions[i].description;
+      const char *synt = all_actions[i].syntax;
 
       desc = desc ? desc : "";
       synt = synt ? synt : "";
 
-      printf ("A%s\n", all_actions[i].action.name);
+      printf ("A%s\n", all_actions[i].name);
       dump_string ('D', desc);
       dump_string ('S', synt);
     }
@@ -286,10 +200,8 @@ hid_actionl (const char *name, ...)
 int
 hid_actionv (const char *name, int argc, char **argv)
 {
-  int x = 0, y = 0, i, ret;
+  int x = 0, y = 0, i;
   HID_Action *a;
-  void *old_context;
-  void *context;
 
   if (Settings.verbose && name)
     {
@@ -299,21 +211,12 @@ hid_actionv (const char *name, int argc, char **argv)
       printf (")\033[0m\n");
     }
 
-  a = hid_find_action (name, &context);
+  a = hid_find_action (name);
   if (!a)
     return 1;
   if (a->need_coord_msg)
     gui->get_coords (a->need_coord_msg, &x, &y);
-
-  /* save old action context and set it to the context associated with the action */
-  old_context = hid_action_context;
-  hid_action_context = context;
-
-  ret = a->trigger_cb (argc, argv, x, y);
-
-  /* restore old context and return */
-  hid_action_context = old_context;
-  return ret;
+  return a->trigger_cb (argc, argv, x, y);
 }
 
 int
diff --git a/src/hid/hidint.h b/src/hid/hidint.h
index 5840e20..a2148a0 100644
--- a/src/hid/hidint.h
+++ b/src/hid/hidint.h
@@ -35,7 +35,7 @@ typedef struct HID_AttrNode
 
 extern HID_AttrNode *hid_attr_nodes;
 
-HID_Action *hid_find_action (const char *name, void **context);
+HID_Action *hid_find_action (const char *name);
 
 HID_Flag *hid_find_flag (const char *name);
 
diff --git a/src/hid/lesstif/menu.c b/src/hid/lesstif/menu.c
index d3e421d..f391778 100644
--- a/src/hid/lesstif/menu.c
+++ b/src/hid/lesstif/menu.c
@@ -815,13 +815,12 @@ lesstif_get_coords (const char *msg, int *px, int *py)
 int
 lesstif_call_action (const char *aname, int argc, char **argv)
 {
-  int px, py, ret;
+  int px, py;
   HID_Action *a;
-  void *context, *old_context;
 
   if (!aname)
     return 1;
-  a = hid_find_action (aname, &context);
+  a = hid_find_action (aname);
   if (!a)
     {
       int i;
@@ -851,11 +850,7 @@ lesstif_call_action (const char *aname, int argc, char **argv)
 	printf ("%s%s", i ? "," : "", argv[i]);
       printf (")\033[0m\n");
     }
-  old_context = hid_action_context;
-  hid_action_context = context;
-  ret = a->trigger_cb (argc, argv, px, py);
-  hid_action_context = old_context;
-  return ret;
+  return a->trigger_cb (argc, argv, px, py);
 }
 
 static void

commit 8d881c4fcaa2faddb2b4e47a8f6309c80d147632
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud:  Fix comment for global variable 'gui' in
    hid.h.
    
    hid_start_gui() does not exist. The variable is instead set in main()
    and hid_expose_callback().

diff --git a/src/hid.h b/src/hid.h
index 7409bbf..9b26ef8 100644
--- a/src/hid.h
+++ b/src/hid.h
@@ -590,7 +590,7 @@ typedef enum
   void hid_expose_callback (HID * hid_, struct BoxType *region_, void *item_);
 
 /* This is initially set to a "no-gui" gui, and later reset by
-   hid_start_gui.  */
+   main. hid_expose_callback also temporarily set it for drawing. */
   extern HID *gui;
 
 /* This is either NULL or points to the current HID that is being called to

commit 2d7de84dd42cb9e2eccd8f41f878b4cacad3c895
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Modify DrawSpecialPolygon() prototype to not
    take a pointer on HID.
    
    DrawSpecialPolygon() was the only function to take a HID as parameter.
    Every other draw function works on the current HID through global
    variable 'gui'.

diff --git a/src/draw.c b/src/draw.c
index 9571b29..d06813d 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -925,7 +925,7 @@ DrawLayerGroup (int group, const BoxType * screen)
  *          2 --- 1
   */
 static void
-DrawSpecialPolygon (HID * hid, hidGC DrawGC,
+DrawSpecialPolygon (hidGC DrawGC,
 		    LocationType X, LocationType Y, int Thickness,
 		    int thin_draw)
 {
@@ -973,16 +973,16 @@ DrawSpecialPolygon (HID * hid, hidGC DrawGC,
   if (thin_draw)
     {
       int i;
-      hid->set_line_cap (DrawGC, Round_Cap);
-      hid->set_line_width (DrawGC, 0);
+      gui->set_line_cap (DrawGC, Round_Cap);
+      gui->set_line_width (DrawGC, 0);
       polygon_x[8] = X + scaled_x[0];
       polygon_y[8] = Y + scaled_y[0];
       for (i = 0; i < 8; i++)
-	hid->draw_line (DrawGC, polygon_x[i], polygon_y[i],
+	gui->draw_line (DrawGC, polygon_x[i], polygon_y[i],
 			polygon_x[i + 1], polygon_y[i + 1]);
     }
   else
-    hid->fill_polygon (DrawGC, 8, polygon_x, polygon_y);
+    gui->fill_polygon (DrawGC, 8, polygon_x, polygon_y);
 }
 
 /* ---------------------------------------------------------------------------
@@ -1032,7 +1032,7 @@ DrawPinOrViaLowLevel (PinTypePtr Ptr, Boolean drawHole)
     }
   else if (TEST_FLAG (OCTAGONFLAG, Ptr))
     {
-      DrawSpecialPolygon (gui, Output.fgGC, Ptr->X, Ptr->Y, Ptr->Thickness,
+      DrawSpecialPolygon (Output.fgGC, Ptr->X, Ptr->Y, Ptr->Thickness,
 			  TEST_FLAG (THINDRAWFLAG, PCB));
     }
   else
@@ -1145,7 +1145,7 @@ ClearOnlyPin (PinTypePtr Pin, Boolean mask)
     }
   else if (TEST_FLAG (OCTAGONFLAG, Pin))
     {
-      DrawSpecialPolygon (gui, Output.pmGC, Pin->X, Pin->Y, half * 2,
+      DrawSpecialPolygon (Output.pmGC, Pin->X, Pin->Y, half * 2,
 			  TEST_FLAG (THINDRAWFLAG, PCB) ||
 			  TEST_FLAG (THINDRAWPOLYFLAG, PCB));
     }

commit 7c0af9f92a78cafc9d81ca77937b26f18f0b5531
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud: Support HID_Mixed options in attribute dialog
    
    Since an HID_Mixed attribute is the combination of a real and an enum,
    reuse the code for HID_Enum to provide a combo box next to the spin button
    for the real part.

diff --git a/src/hid/gtk/gui-dialog-print.c b/src/hid/gtk/gui-dialog-print.c
index 922b719..c5c2fff 100644
--- a/src/hid/gtk/gui-dialog-print.c
+++ b/src/hid/gtk/gui-dialog-print.c
@@ -213,6 +213,7 @@ ghid_attribute_dialog (HID_Attribute * attrs,
 	  hbox = gtk_hbox_new (FALSE, 4);
 	  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
+        do_enum:
 	  /* 
 	   * We have to put the combo_box inside of an event_box in
 	   * order for tooltips to work.
@@ -246,7 +247,22 @@ ghid_attribute_dialog (HID_Attribute * attrs,
 	  break;
 
 	case HID_Mixed:
-	  printf ("HID_Mixed\n");
+	  hbox = gtk_hbox_new (FALSE, 4);
+	  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+          
+	  /*
+	   * FIXME
+	   * need to pick the "digits" and step size argument more
+	   * intelligently
+	   */
+	  ghid_spin_button (hbox, &widget, attrs[j].default_val.real_value,
+			    attrs[j].min_val, attrs[j].max_val, 0.01, 0.01, 3,
+			    0,
+			    dblspinner_changed_cb,
+			    &(attrs[j].default_val.real_value), FALSE, NULL);
+	  gtk_tooltips_set_tip (tips, widget, attrs[j].help_text, NULL);
+
+          goto do_enum;
 	  break;
 
 	case HID_Path:

commit 7ef3aa04772b11db6afd14c626a6c49882c5850b
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Apply patch from Patrick Bernaud.
    
    Modified code to not abort on HID_Mixed attributes. Th gtk HID is
    modified to understand such an attribute (though the attribute dialog
    has still no support for them), the lesstif HID is unchanged.

diff --git a/src/hid/common/hidinit.c b/src/hid/common/hidinit.c
index 9581d32..bb1a66b 100644
--- a/src/hid/common/hidinit.c
+++ b/src/hid/common/hidinit.c
@@ -291,6 +291,11 @@ hid_parse_command_line (int *argc, char ***argv)
 	    if (a->value)
 	      *(int *) a->value = a->default_val.int_value;
 	    break;
+	  case HID_Mixed:
+	    if (a->value) {
+              *(HID_Attr_Val *) a->value = a->default_val;
+           }
+           break;
 	  default:
 	    abort ();
 	  }
@@ -345,7 +350,6 @@ hid_parse_command_line (int *argc, char ***argv)
 		    a->default_val.int_value = bool_val;
 		  break;
 		case HID_Mixed:
-		  abort ();
 		  a->default_val.real_value = strtod ((*argv)[1], &ep);
 		  goto do_enum;
 		case HID_Enum:
@@ -353,7 +357,7 @@ hid_parse_command_line (int *argc, char ***argv)
 		do_enum:
 		  ok = 0;
 		  for (e = 0; a->enumerations[e]; e++)
-		    if (strcmp (a->enumerations[e], (*argv)[1]) == 0)
+		    if (strcmp (a->enumerations[e], ep) == 0)
 		      {
 			ok = 1;
 			a->default_val.int_value = e;
@@ -491,7 +495,14 @@ hid_save_settings (int locally)
 		       a->enumerations[a->value ? *(int *)a->value : a->default_val.int_value]);
 	      break;
 	    case HID_Mixed:
-	      abort ();
+             {
+               HID_Attr_Val *value =
+                 a->value ? (HID_Attr_Val*) a->value : &(a->default_val);
+               fprintf (f, "%s = %g%s\n",
+                        a->name,
+                        value->real_value,
+                        a->enumerations[value->int_value]);
+             }
 	      break;
 	    }
 	}
@@ -529,7 +540,6 @@ hid_set_attribute (char *name, char *value)
 	      a->default_val.int_value = 1;
 	      break;
 	    case HID_Mixed:
-	      abort ();
 	      a->default_val.real_value = strtod (value, &value);
 	      /* fall through */
 	    case HID_Enum:
diff --git a/src/hid/gtk/gui-config.c b/src/hid/gtk/gui-config.c
index 490befc..c9bf82b 100644
--- a/src/hid/gtk/gui-config.c
+++ b/src/hid/gtk/gui-config.c
@@ -588,7 +588,6 @@ parse_optionv (gint * argc, gchar *** argv, gboolean from_cmd_line)
 		    a->default_val.int_value = 1;
 		  break;
 		case HID_Mixed:
-		  abort ();
 		  a->default_val.real_value = strtod ((*argv)[1], &ep);
 		  goto do_enum;
 		case HID_Enum:
@@ -596,7 +595,7 @@ parse_optionv (gint * argc, gchar *** argv, gboolean from_cmd_line)
 		do_enum:
 		  ok = 0;
 		  for (e = 0; a->enumerations[e]; e++)
-		    if (strcmp (a->enumerations[e], (*argv)[1]) == 0)
+		    if (strcmp (a->enumerations[e], ep) == 0)
 		      {
 			ok = 1;
 			a->default_val.int_value = e;
diff --git a/src/main.c b/src/main.c
index 5f68465..99dcba1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -309,8 +309,10 @@ print_defaults_1 (HID_Attribute * a, void *value)
       fprintf (stderr, "%s %s\n", a->name, a->enumerations[i]);
       break;
     case HID_Mixed:
-      i = value ? *(int *) value : a->default_val.int_value;
-      d = value ? *(double *) value : a->default_val.real_value;
+      i = value ?
+        ((HID_Attr_Val*)value)->int_value  : a->default_val.int_value;
+      d = value ?
+        ((HID_Attr_Val*)value)->real_value : a->default_val.real_value;
       fprintf (stderr, "%s %g%s\n", a->name, d, a->enumerations[i]);
       break;
     case HID_Label:

commit a86548a6c26429e0b420602f98152d881f84cc2a
Author: Stuart Brorson <sdb@xxxxxxxxxx>
Commit: Stuart Brorson <sdb@xxxxxxxxxx>

    Applying patch from Patrick Bernaud.
    
    HIDs with a name too long were breaking alignement in usage() as the
    code requested insertion of a tab after the name even for HID names
    already exceeding the length of the tabulation.
    
    This is similar to how usage_attr() already does alignment of
    name and help text.

diff --git a/src/main.c b/src/main.c
index 162a0e0..5f68465 100644
--- a/src/main.c
+++ b/src/main.c
@@ -252,17 +252,17 @@ usage (void)
   u ("Available GUI hid%s:", n_gui == 1 ? "" : "s");
   for (i = 0; hl[i]; i++)
     if (hl[i]->gui)
-      fprintf (stderr, "\t%s\t%s\n", hl[i]->name, hl[i]->description);
+      fprintf (stderr, "\t%-8s %s\n", hl[i]->name, hl[i]->description);
   u ("%s -p [printing options] <pcb file>\tto print", Progname);
   u ("Available printing hid%s:", n_printer == 1 ? "" : "s");
   for (i = 0; hl[i]; i++)
     if (hl[i]->printer)
-      fprintf (stderr, "\t%s\t%s\n", hl[i]->name, hl[i]->description);
+      fprintf (stderr, "\t%-8s %s\n", hl[i]->name, hl[i]->description);
   u ("%s -x hid [export options] <pcb file>\tto export", Progname);
   u ("Available export hid%s:", n_exporter == 1 ? "" : "s");
   for (i = 0; hl[i]; i++)
     if (hl[i]->exporter)
-      fprintf (stderr, "\t%s\t%s\n", hl[i]->name, hl[i]->description);
+      fprintf (stderr, "\t%-8s %s\n", hl[i]->name, hl[i]->description);
 
   for (i = 0; hl[i]; i++)
     if (hl[i]->gui)




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