---
 gschem/include/prototype.h |    2 +-
 gschem/src/i_callbacks.c   |   67 ++++++++++++++++++++++++++++---------------
 gschem/src/o_attrib.c      |   43 +++++++++-------------------
 3 files changed, 58 insertions(+), 54 deletions(-)

diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index edf3b53..a9628b8 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -469,7 +469,7 @@ void o_arc_erase_grips(GSCHEM_TOPLEVEL *w_current, OBJECT 
*o_current);
 /* o_attrib.c */
 void o_attrib_add_selected(GSCHEM_TOPLEVEL *w_current, SELECTION *selection, 
OBJECT *selected);
 void o_attrib_toggle_visibility(GSCHEM_TOPLEVEL *w_current, OBJECT *object);
-void o_attrib_toggle_show_name_value(GSCHEM_TOPLEVEL *w_current, GList *list, 
int new_show_name_value);
+void o_attrib_toggle_show_name_value(GSCHEM_TOPLEVEL *w_current, OBJECT 
*object, int new_show_name_value);
 OBJECT *o_attrib_add_attrib(GSCHEM_TOPLEVEL *w_current, char *text_string, int 
visibility, int show_name_value, OBJECT *object);
 /* o_basic.c */
 void o_redraw_all(GSCHEM_TOPLEVEL *w_current);
diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index 245fe1f..4b5f2c9 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -3114,12 +3114,10 @@ DEFINE_I_CALLBACK(attributes_detach)
 DEFINE_I_CALLBACK(attributes_show_name)
 {
   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
-  OBJECT *object;
+  TOPLEVEL *toplevel = w_current->toplevel;
 
   exit_if_null(w_current);
 
-  object = o_select_return_first_object(w_current);
-
   /* This is a new addition 3/15 to prevent this from executing
    * inside an action */
   if (w_current->inside_action) {
@@ -3129,10 +3127,19 @@ DEFINE_I_CALLBACK(attributes_show_name)
   i_update_middle_button(w_current, i_callback_attributes_show_name,
                          _("ShowN"));
 
-  if (object != NULL) {
-    o_attrib_toggle_show_name_value(w_current,
-                                    geda_list_get_glist( 
w_current->toplevel->page_current->selection_list ),
-                                    SHOW_NAME);
+  if (o_select_selected (w_current)) {
+    SELECTION *selection = toplevel->page_current->selection_list;
+    GList *s_current;
+    
+    for (s_current = geda_list_get_glist (selection);
+         s_current != NULL;
+         s_current = g_list_next (s_current)) {
+      OBJECT *object = (OBJECT*)s_current->data;
+      o_attrib_toggle_show_name_value (w_current, object, SHOW_NAME);
+    }
+    
+    toplevel->page_current->CHANGED=1;
+    o_undo_savestate (w_current, UNDO_ALL);
   }
 }
 
@@ -3144,12 +3151,10 @@ DEFINE_I_CALLBACK(attributes_show_name)
 DEFINE_I_CALLBACK(attributes_show_value)
 {
   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
-  OBJECT *object;
+  TOPLEVEL *toplevel = w_current->toplevel;
 
   exit_if_null(w_current);
 
-  object = o_select_return_first_object(w_current);
-
   /* This is a new addition 3/15 to prevent this from executing
    * inside an action */
   if (w_current->inside_action) {
@@ -3159,10 +3164,19 @@ DEFINE_I_CALLBACK(attributes_show_value)
   i_update_middle_button(w_current, i_callback_attributes_show_value,
                          _("ShowV"));
 
-  if (object != NULL) {
-    o_attrib_toggle_show_name_value(w_current,
-                                    geda_list_get_glist( 
w_current->toplevel->page_current->selection_list ),
-                                    SHOW_VALUE);
+  if (o_select_selected (w_current)) {
+    SELECTION *selection = toplevel->page_current->selection_list;
+    GList *s_current;
+    
+    for (s_current = geda_list_get_glist (selection);
+         s_current != NULL;
+         s_current = g_list_next (s_current)) {
+      OBJECT *object = (OBJECT*)s_current->data;
+      o_attrib_toggle_show_name_value (w_current, object, SHOW_VALUE);
+    }
+    
+    toplevel->page_current->CHANGED=1;
+    o_undo_savestate (w_current, UNDO_ALL);
   }
 }
 
@@ -3174,12 +3188,10 @@ DEFINE_I_CALLBACK(attributes_show_value)
 DEFINE_I_CALLBACK(attributes_show_both)
 {
   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
-  OBJECT *object;
+  TOPLEVEL *toplevel = w_current->toplevel;
 
   exit_if_null(w_current);
 
-  object = o_select_return_first_object(w_current);
-
   /* This is a new addition 3/15 to prevent this from executing
    * inside an action */
   if (w_current->inside_action) {
@@ -3189,10 +3201,19 @@ DEFINE_I_CALLBACK(attributes_show_both)
   i_update_middle_button(w_current, i_callback_attributes_show_both,
                          _("ShowB"));
 
-  if (object != NULL) {
-    o_attrib_toggle_show_name_value(w_current,
-                                    geda_list_get_glist( 
w_current->toplevel->page_current->selection_list ),
-                                    SHOW_NAME_VALUE);
+  if (o_select_selected (w_current)) {
+    SELECTION *selection = toplevel->page_current->selection_list;
+    GList *s_current;
+    
+    for (s_current = geda_list_get_glist (selection);
+         s_current != NULL;
+         s_current = g_list_next (s_current)) {
+      OBJECT *object = (OBJECT*)s_current->data;
+      o_attrib_toggle_show_name_value (w_current, object, SHOW_NAME_VALUE);
+    }
+    
+    toplevel->page_current->CHANGED=1;
+    o_undo_savestate (w_current, UNDO_ALL);
   }
 }
 
@@ -3204,12 +3225,10 @@ DEFINE_I_CALLBACK(attributes_show_both)
 DEFINE_I_CALLBACK(attributes_visibility_toggle)
 {
   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
-  OBJECT *object;
+  TOPLEVEL *toplevel = w_current->toplevel;
 
   exit_if_null(w_current);
 
-  object = o_select_return_first_object(w_current);
-
   /* This is a new addition 3/15 to prevent this from executing
    * inside an action */
   if (w_current->inside_action) {
diff --git a/gschem/src/o_attrib.c b/gschem/src/o_attrib.c
index 1d9a3d9..0654a32 100644
--- a/gschem/src/o_attrib.c
+++ b/gschem/src/o_attrib.c
@@ -133,42 +133,27 @@ void o_attrib_toggle_visibility(GSCHEM_TOPLEVEL 
*w_current, OBJECT *object)
   }
 }
 
-/*! \todo Finish function documentation!!!
- *  \brief
+/*! \brief Set what part of an attribute is shown.
  *  \par Function Description
+ *  This function changes what part (name, value or both) of an
+ *  attribute is shown by its attribute object. The attribute object
+ *  is erased, updated and finally redrawn.
  *
+ *  \param [in] w_current  The GSCHEM_TOPLEVEL object.
+ *  \param [in] object     The attribute object.
+ *  \param [in] show_name_value  The new display flag for attribute.
  */
 void o_attrib_toggle_show_name_value(GSCHEM_TOPLEVEL *w_current,
-                                    GList *list, int new_show_name_value)
+                                     OBJECT *object, int show_name_value)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  GList *s_current = NULL;
-  OBJECT *object = NULL;
-
-  if (list == NULL) {
-    return;
-  }
-
-  s_current = list;
-
-  while(s_current != NULL) {
-    object = (OBJECT *) s_current->data;
 
-    if (object == NULL) {
-      fprintf(stderr, _("Got NULL in o_attrib_toggle_show_name_value\n"));
-      exit(-1);
-    }
-
-    if (object->type == OBJ_TEXT) {
-      o_erase_single(w_current, object);
-      object->show_name_value = new_show_name_value;
-      o_text_recreate(toplevel, object);
-      o_text_draw(w_current, object);
-      toplevel->page_current->CHANGED=1;
-    }
-    s_current = g_list_next(s_current);
-  }
-  o_undo_savestate(w_current, UNDO_ALL);
+  g_return_if_fail (object != NULL && object->type == OBJ_TEXT);
+  
+  o_erase_single(w_current, object);
+  object->show_name_value = show_name_value;
+  o_text_recreate(toplevel, object);
+  o_text_draw(w_current, object);
 }
 
 
-- 
1.5.6




_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev

Reply via email to