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

gEDA-cvs: gaf.git: branch: master updated (1.5.0-20080706-124-g2fe94f7)



The branch, master has been updated
       via  2fe94f7887ccf4b990bb285fc9def966ce857e0b (commit)
       via  6718a8d2187b4a871051eee299cef8bbbef02280 (commit)
       via  df8478a9706694220919f3e3f6304a351a7eca68 (commit)
       via  e44826c49a0db40b0c5e981431fd005b6e8d9048 (commit)
       via  89c9af836536c13d97fde7d8b408e084f4b0e1d5 (commit)
      from  0865651615cf79b1392c34381cbee3095faa5a01 (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
=========

 gschem/src/g_funcs.c        |   10 +--
 gschem/src/g_hook.c         |   11 +--
 gschem/src/o_misc.c         |   23 +++--
 gschem/src/o_slot.c         |    7 +-
 gschem/src/o_text.c         |   28 +++----
 gschem/src/x_attribedit.c   |   10 +-
 gschem/src/x_autonumber.c   |   56 +++++++-----
 gschem/src/x_dialog.c       |    4 +-
 gschem/src/x_multiattrib.c  |   32 +++++--
 libgeda/include/prototype.h |    2 +
 libgeda/include/struct.h    |    1 +
 libgeda/src/o_text_basic.c  |  202 +++++++++++++++++++++++++------------------
 libgeda/src/s_basic.c       |    1 +
 13 files changed, 221 insertions(+), 166 deletions(-)


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

commit 2fe94f7887ccf4b990bb285fc9def966ce857e0b
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Sat Aug 16 18:32:53 2008 +0100

    gschem: Use accessors to get/set TEXT strings.
    
    Don't access the TEXT struct directly.

:100644 100644 1f5ca1b... 6809aa1... M	gschem/src/g_funcs.c
:100644 100644 55d9345... 8488832... M	gschem/src/g_hook.c
:100644 100644 3354474... de1bd0b... M	gschem/src/o_misc.c
:100644 100644 bbcd2cc... 4b12984... M	gschem/src/o_slot.c
:100644 100644 cc66b18... 797f05e... M	gschem/src/o_text.c
:100644 100644 45c5203... b29a00f... M	gschem/src/x_attribedit.c
:100644 100644 166142b... d05f394... M	gschem/src/x_autonumber.c
:100644 100644 751fad3... 2014eaa... M	gschem/src/x_dialog.c
:100644 100644 58ae786... 9e7da61... M	gschem/src/x_multiattrib.c

commit 6718a8d2187b4a871051eee299cef8bbbef02280
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Sat Aug 16 18:10:53 2008 +0100

    gschem: Pass dialog to multiattrib treeview data funcs.
    
    The cell data funcs for the multi-attribute editor dialog's treeview
    need to have access to a libgeda TOPLEVEL to be able to use
    o_text_get_string(). The obvious thing to do is to pass in a pointer
    to the dialog (which contains a pointer to the GSCHEM_TOPLEVEL, etc)
    as the user data pointer.

:100644 100644 f0910cd... 58ae786... M	gschem/src/x_multiattrib.c

commit df8478a9706694220919f3e3f6304a351a7eca68
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Sat Aug 16 18:10:21 2008 +0100

    libgeda: Add static update_disp_string() function.
    
    Adds update_disp_string() to o_text_basic.c, to reduce code
    duplication between o_text_recreate() and o_text_add().

:100644 100644 6fdfe6c... 677b5cd... M	libgeda/src/o_text_basic.c

commit e44826c49a0db40b0c5e981431fd005b6e8d9048
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Sat Aug 16 18:08:31 2008 +0100

    libgeda: Add field to TEXT for storing displayed string.
    
    Sometimes, the string to be displayed is different from the whole
    string contained by a TEXT object (for instance, when an attribute has
    either its name or value unshown). When using "real" fonts we don't
    want to fix this up each and every time the string is rendered, so
    it needs to be stashed somewhere.

:100644 100644 51701ba... 28f0d64... M	libgeda/include/struct.h
:100644 100644 1ac0935... 6fdfe6c... M	libgeda/src/o_text_basic.c
:100644 100644 cc36057... 258d0d9... M	libgeda/src/s_basic.c

commit 89c9af836536c13d97fde7d8b408e084f4b0e1d5
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Sat Aug 16 18:04:22 2008 +0100

    libgeda: Add accessors to get/set a text object's string.
    
    In later commits, direct application accesses to the string in the
    TEXT structure will be removed.

:100644 100644 974c97f... b5549ec... M	libgeda/include/prototype.h
:100644 100644 f0d1124... 1ac0935... M	libgeda/src/o_text_basic.c

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

commit 2fe94f7887ccf4b990bb285fc9def966ce857e0b
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Sat Aug 16 18:32:53 2008 +0100

    gschem: Use accessors to get/set TEXT strings.
    
    Don't access the TEXT struct directly.

diff --git a/gschem/src/g_funcs.c b/gschem/src/g_funcs.c
index 1f5ca1b..6809aa1 100644
--- a/gschem/src/g_funcs.c
+++ b/gschem/src/g_funcs.c
@@ -269,13 +269,11 @@ SCM get_selected_component_attributes(GSCHEM_TOPLEVEL *w_current)
   ht = g_hash_table_new (g_str_hash, g_str_equal);
   for (obj = w_current->toplevel->page_current->object_head; obj != NULL;
        obj = obj->next) {
-    if (obj->selected &&
-        obj->type == OBJ_TEXT &&
-        obj->text->string != NULL) {
+    if (obj->selected && obj->type == OBJ_TEXT) {
+      const gchar *str = o_text_get_string (w_current->toplevel, obj);
+      if (str == NULL) continue;
       /* add text string in the hash table */
-      g_hash_table_insert (ht,
-                           obj->text->string,
-                           obj->text->string);
+      g_hash_table_insert (ht, (gchar *) str, (gchar *) str);
      }
    }
   /* now create a scheme list of the entries in the hash table */
diff --git a/gschem/src/g_hook.c b/gschem/src/g_hook.c
index 55d9345..8488832 100644
--- a/gschem/src/g_hook.c
+++ b/gschem/src/g_hook.c
@@ -73,9 +73,8 @@ SCM g_make_attrib_smob_list(GSCHEM_TOPLEVEL *w_current, OBJECT *curr_object)
   a_iter = object->attribs;
   while(a_iter != NULL) {
     a_current = a_iter->data;
-    if (a_current->object->type == OBJ_TEXT && 
-        a_current->object->text) {
-      if (a_current->object->text->string) {
+    if (a_current->object->type == OBJ_TEXT) {
+      if (o_text_get_string (w_current->toplevel, a_current->object)) {
         smob_list = scm_cons (g_make_attrib_smob (w_current->toplevel, a_current),
                               smob_list);
       }
@@ -411,7 +410,7 @@ static void custom_world_get_single_object_bounds
     ATTRIB *a_current;
     GList *a_iter;
     int rleft, rright, rbottom, rtop;
-    char *text_value; 
+    const gchar *text_value; 
     char *name_ptr, aux_ptr[2];
     gboolean include_text;
 
@@ -431,8 +430,8 @@ static void custom_world_get_single_object_bounds
 					    &rleft, &rtop, &rright, &rbottom);
 	    break;
           case (OBJ_TEXT):
-	    if (obj_ptr->text && obj_ptr->text->string) {
-	      text_value = obj_ptr->text->string;
+            text_value = o_text_get_string (toplevel, obj_ptr);
+	    if (text_value) {
 	      if (o_attrib_get_name_value(text_value, &name_ptr, NULL) &&
 		  g_list_find_custom(exclude_attrib_list, name_ptr, (GCompareFunc) &strcmp)) {
 		include_text = FALSE;
diff --git a/gschem/src/o_misc.c b/gschem/src/o_misc.c
index 3354474..de1bd0b 100644
--- a/gschem/src/o_misc.c
+++ b/gschem/src/o_misc.c
@@ -48,6 +48,7 @@
 void o_edit(GSCHEM_TOPLEVEL *w_current, GList *list)
 {
   OBJECT *o_current;
+  const gchar *str = NULL;
 
   if (list == NULL) {
     w_current->inside_action = 0;
@@ -77,9 +78,10 @@ void o_edit(GSCHEM_TOPLEVEL *w_current, GList *list)
     picture_change_filename_dialog(w_current);
     break;
     case(OBJ_TEXT):
-    if (o_attrib_get_name_value (o_current->text->string, NULL, NULL) &&
+      str = o_text_get_string (w_current->toplevel, o_current);
+      if (o_attrib_get_name_value (str, NULL, NULL) &&
         /* attribute editor only accept 1-line values for attribute */
-        o_text_num_lines (o_current->text->string) == 1) {
+        o_text_num_lines (str) == 1) {
         attrib_edit_dialog(w_current,o_current, FROM_MENU);
     } else {
       o_text_edit(w_current, o_current);
@@ -610,21 +612,20 @@ int o_edit_find_text(GSCHEM_TOPLEVEL *w_current, OBJECT * o_list, char *stext,
     }
 
     if (o_current->type == OBJ_TEXT) {
+      const gchar *str = o_text_get_string (toplevel, o_current);
      /* replaced strcmp with strstr to simplify the search */
-      if (strstr(o_current->text->string,stext)) {
+      if (strstr (str,stext)) {
         if (!skiplast) {
           a_zoom(w_current, ZOOM_FULL, DONTCARE, A_PAN_DONT_REDRAW);
           text_screen_height =
-            SCREENabs(toplevel, o_text_height(o_current->text->string,
-                                              o_current->text->size));
+            SCREENabs (toplevel, o_text_height (str, o_current->text->size));
           /* this code will zoom/pan till the text screen height is about */
           /* 50 pixels high, perhaps a future enhancement will be to make */
           /* this number configurable */
           while (text_screen_height < 50) {
             a_zoom(w_current, ZOOM_IN, DONTCARE, A_PAN_DONT_REDRAW);
             text_screen_height =
-              SCREENabs(toplevel, o_text_height(o_current->text->string,
-                                                o_current->text->size));
+              SCREENabs (toplevel, o_text_height (str, o_current->text->size));
           }
           a_pan_general(w_current,
                         o_current->text->x, o_current->text->y,
@@ -672,7 +673,8 @@ void o_edit_hide_specific_text(GSCHEM_TOPLEVEL *w_current, OBJECT * o_list,
   while (o_current != NULL) {
 
     if (o_current->type == OBJ_TEXT) {
-      if (!strncmp(stext, o_current->text->string, strlen(stext))) {
+      const gchar *str = o_text_get_string (w_current->toplevel, o_current);
+      if (!strncmp (stext, str, strlen (stext))) {
         if (o_current->visibility == VISIBLE) {
           o_current->visibility = INVISIBLE;
 
@@ -708,7 +710,8 @@ void o_edit_show_specific_text(GSCHEM_TOPLEVEL *w_current, OBJECT * o_list,
   while (o_current != NULL) {
 
     if (o_current->type == OBJ_TEXT) {
-      if (!strncmp(stext, o_current->text->string, strlen(stext))) {
+      const gchar *str = o_text_get_string (w_current->toplevel, o_current);
+      if (!strncmp (stext, str, strlen (stext))) {
         if (o_current->visibility == INVISIBLE) {
           o_current->visibility = VISIBLE;
 
@@ -795,7 +798,7 @@ void o_update_component(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
     gchar *name;
     char *attrfound;
     g_assert (a_current->object->type == OBJ_TEXT);
-    o_attrib_get_name_value (a_current->object->text->string,
+    o_attrib_get_name_value (o_text_get_string (toplevel, a_current->object),
                              &name, NULL);
 
     attrfound = o_attrib_search_name_single(o_current, name, NULL);
diff --git a/gschem/src/o_slot.c b/gschem/src/o_slot.c
index bbcd2cc..4b12984 100644
--- a/gschem/src/o_slot.c
+++ b/gschem/src/o_slot.c
@@ -67,7 +67,8 @@ void o_slot_start(GSCHEM_TOPLEVEL *w_current, OBJECT *list)
              slot_text_object->text->string);
 #endif
       slot_edit_dialog(w_current,
-                       slot_text_object->text->string);
+                       o_text_get_string (w_current->toplevel,
+                                          slot_text_object));
       g_free(slot_value);
     } else {
       /* we didn't find an attached slot=? attribute */
@@ -161,9 +162,7 @@ void o_slot_end(GSCHEM_TOPLEVEL *w_current, const char *string, int len)
     slot_value = o_attrib_search_slot(object, &slot_text_object);
 
     if (slot_value) {
-      g_free(slot_text_object->text->string);
-
-      slot_text_object->text->string = g_strdup (string);
+      o_text_set_string (toplevel, slot_text_object, string);
 
       temp = slot_text_object;
 
diff --git a/gschem/src/o_text.c b/gschem/src/o_text.c
index cc66b18..797f05e 100644
--- a/gschem/src/o_text.c
+++ b/gschem/src/o_text.c
@@ -327,8 +327,8 @@ void o_text_edit(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
   /* you need to check to make sure only one object is selected */
   /* no actually this is okay... not here in o_edit */
   text_edit_dialog(w_current,
-                   o_current->text->string, o_current->text->size,
-                   o_current->text->alignment);
+                   o_text_get_string (w_current->toplevel, o_current),
+                   o_current->text->size, o_current->text->alignment);
 }
 
 /*! \todo Finish function documentation!!!
@@ -353,28 +353,25 @@ void o_text_edit_end(GSCHEM_TOPLEVEL *w_current, char *string, int len, int text
 
     if (object) {
       if (object->type == OBJ_TEXT) {
+        o_erase_single(w_current, object);
+
+        object->text->size = text_size;
+        object->text->alignment = text_alignment;
+
+        /* probably the text object should be extended to carry a color */
+        /* and we should pass it here with a function parameter (?) */
+        object->saved_color = w_current->edit_color;
 
         /* only change text string if there is only ONE text object selected */
         if (numselect == 1 && string) {
-          g_free(object->text->string);
-          object->text->string = g_strdup (string);
+          o_text_set_string (w_current->toplevel, object, string);
 	  /* handle slot= attribute, it's a special case */
 	  if (g_ascii_strncasecmp (string, "slot=", 5) == 0) {
 	    o_slot_end (w_current, string, strlen (string));
 	  }
         }
-
-        object->text->size = text_size;
-        object->text->alignment = text_alignment;
-		
-        /* probably the text object should be extended to carry a color */
-        /* and we should pass it here with a function parameter (?) */
-        object->saved_color = w_current->edit_color;
-
-        o_erase_single(w_current, object);
         o_text_recreate(toplevel, object);
         o_text_draw(w_current, object);
-
       } 
     }
     
@@ -409,9 +406,8 @@ void o_text_change(GSCHEM_TOPLEVEL *w_current, OBJECT *object, char *string,
   o_erase_single(w_current, object);
 
   /* second change the real object */
-  g_free(object->text->string);
+  o_text_set_string (toplevel, object, string);
 
-  object->text->string = g_strdup (string);
   object->visibility = visibility;
   object->show_name_value = show;
   o_text_recreate(toplevel, object);
diff --git a/gschem/src/x_attribedit.c b/gschem/src/x_attribedit.c
index 45c5203..b29a00f 100644
--- a/gschem/src/x_attribedit.c
+++ b/gschem/src/x_attribedit.c
@@ -199,10 +199,9 @@ void attrib_edit_dialog_ok(GtkWidget * w, GSCHEM_TOPLEVEL *w_current)
             if (replace) {
               while (a_iter != NULL) {
                 a_current = a_iter->data;
-
-                if (a_current->object->text != NULL) {
-                  if (!strncmp(a_current->object->text->string, newtext,
-                               strchr(newtext, '=') - newtext)) {
+                const gchar *str = o_text_get_string (toplevel, a_current->object);
+                if (str) {
+                  if (!strncmp (str, newtext, strchr (newtext, '=') - newtext)) {
                     o_text_change(w_current, a_current->object,
                                   newtext, vis, show);
                     replaced = TRUE;
@@ -491,7 +490,8 @@ void attrib_edit_dialog(GSCHEM_TOPLEVEL *w_current, OBJECT * list, int flag)
 
   /* gschem specific */
   if (list) {
-    o_attrib_get_name_value(list->text->string, &name, &val);
+    o_attrib_get_name_value (o_text_get_string (toplevel, list),
+                             &name, &val);
     attrib = list;
     if (attrib->visibility == VISIBLE) {
       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(visbutton), TRUE);
diff --git a/gschem/src/x_autonumber.c b/gschem/src/x_autonumber.c
index 166142b..d05f394 100644
--- a/gschem/src/x_autonumber.c
+++ b/gschem/src/x_autonumber.c
@@ -328,28 +328,33 @@ void autonumber_clear_database (AUTONUMBER_TEXT *autotext)
 gint autonumber_match(AUTONUMBER_TEXT *autotext, OBJECT *o_current, gint *number)
 {
   gint i, len, isnumbered=1; 
+  const gchar *str = NULL;
 
   len = strlen(autotext->current_searchtext);
   /* first find out whether we can ignore that object */
-  if (o_current->type != OBJ_TEXT  /* text object */
-      || !(strlen(o_current->text->string) - len > 0)
-      || !g_str_has_prefix(o_current->text->string, autotext->current_searchtext))
+  if (o_current->type != OBJ_TEXT)  /* text object */
+    return AUTONUMBER_IGNORE;
+
+  str = o_text_get_string (autotext->w_current->toplevel, o_current);
+
+  if (!(strlen(str) - len > 0)
+      || !g_str_has_prefix(str, autotext->current_searchtext))
     return AUTONUMBER_IGNORE;
 
   /* the string object matches with its leading characters to the searchtext */
   /* now look for the extension, either a number or the "?" */
-  if (g_str_has_suffix (o_current->text->string,"?")) {
+  if (g_str_has_suffix (str,"?")) {
     isnumbered = 0;
     /* There must not be any character between the "?" and the searchtext */
-    if (strlen(o_current->text->string) != len+1)
+    if (strlen(str) != len+1)
       return AUTONUMBER_IGNORE;
   }
   else {
-    if (!isdigit( (int) (o_current->text->string[len]) )) /* has at least one digit */
+    if (!isdigit( (int) (str[len]) )) /* has at least one digit */
       return AUTONUMBER_IGNORE;
     
-    for (i=len+1; o_current->text->string[i]; i++) /* and only digits */
-      if (!isdigit( (int) (o_current->text->string[i]) ))
+    for (i=len+1; str[i]; i++) /* and only digits */
+      if (!isdigit( (int) (str[i]) ))
 	return AUTONUMBER_IGNORE;
   }
   
@@ -363,7 +368,7 @@ gint autonumber_match(AUTONUMBER_TEXT *autotext, OBJECT *o_current, gint *number
   if (isnumbered
       && !(autotext->scope_skip == SCOPE_SELECTED 
 	   && !(o_current->selected)  && autotext->root_page)) {
-    sscanf(&(o_current->text->string[len])," %d", number);
+    sscanf(&(str[len])," %d", number);
     return AUTONUMBER_RESPECT; /* numbered objects which we don't renumber */
   }
   else
@@ -558,11 +563,12 @@ void autonumber_remove_number(AUTONUMBER_TEXT * autotext, OBJECT *o_current)
 {
   OBJECT *o_parent, *o_slot;
   gchar *slot_str;
+  gchar *str = NULL;
 
   /* replace old text */
-  g_free(o_current->text->string);
-  o_current->text->string = g_strdup_printf("%s?", 
-					    autotext->current_searchtext);
+  str = g_strdup_printf("%s?", autotext->current_searchtext);
+  o_text_set_string (autotext->w_current->toplevel, o_current, str);
+  g_free (str);
 
   /* redraw the text */
   o_erase_single(autotext->w_current, o_current);
@@ -597,6 +603,7 @@ void autonumber_apply_new_text(AUTONUMBER_TEXT * autotext, OBJECT *o_current,
 {
   OBJECT *o_parent, *o_slot;
   gchar *slot_str;
+  gchar *str = NULL;
 
   /* add the slot as attribute to the object */
   o_parent = o_current->attached_to;
@@ -605,8 +612,9 @@ void autonumber_apply_new_text(AUTONUMBER_TEXT * autotext, OBJECT *o_current,
     if (slot_str != NULL) {
       /* update the slot attribute */
       g_free(slot_str);
-      g_free(o_slot->text->string);
-      o_slot->text->string = g_strdup_printf("slot=%d",slot);
+      slot_str = g_strdup_printf("slot=%d",slot);
+      o_text_set_string (autotext->w_current->toplevel, o_slot, slot_str);
+      g_free (slot_str);
       o_erase_single(autotext->w_current, o_slot);
       o_text_recreate(autotext->w_current->toplevel, o_slot);
       o_text_draw(autotext->w_current, o_slot);
@@ -622,9 +630,10 @@ void autonumber_apply_new_text(AUTONUMBER_TEXT * autotext, OBJECT *o_current,
   }
 
   /* replace old text */
-  g_free(o_current->text->string);
-  o_current->text->string = g_strdup_printf("%s%d", autotext->current_searchtext,
-					    number);
+  str = g_strdup_printf("%s%d", autotext->current_searchtext, number);
+  o_text_set_string (autotext->w_current->toplevel, o_current, str);
+  g_free (str);
+
   /* redraw the text */
   o_erase_single(autotext->w_current, o_current);
   o_text_recreate(autotext->w_current->toplevel, o_current);
@@ -701,22 +710,21 @@ void autonumber_text_autonumber(AUTONUMBER_TEXT *autotext)
 	  if (autotext->scope_number == SCOPE_HIERARCHY
 	      || autotext->scope_number == SCOPE_PAGE
 	      || ((autotext->scope_number == SCOPE_SELECTED) && (o_current->selected))) {
-	    if (g_str_has_prefix(o_current->text->string, searchtext) == TRUE) {
+            const gchar *str = o_text_get_string (w_current->toplevel, o_current);
+	    if (g_str_has_prefix (str, searchtext)) {
 	      /* the beginnig of the current text matches with the searchtext now */
 	      /* strip of the trailing [0-9?] chars and add it too the searchtext */
-	      for (i = strlen(o_current->text->string)-1;
+	      for (i = strlen (str)-1;
 		   (i >= strlen(searchtext))
-		     && (o_current->text->string[i] == '?'
-			 || isdigit( (int) (o_current->text->string[i]) ));
+		     && (str[i] == '?'
+			 || isdigit( (int) (str[i]) ));
 		   i--)
 		; /* void */
 		
-	      new_searchtext=g_strndup(o_current->text->string, i+1);
+	      new_searchtext = g_strndup (str, i+1);
 	      if (g_list_find_custom(searchtext_list, new_searchtext,
 				     (GCompareFunc) strcmp) == NULL ) {
 		searchtext_list = g_list_append(searchtext_list, new_searchtext);
-		/*printf("autonumber_text: text \"%s\", \"%s\"\n",  */
-		/*       o_current->text->string, new_searchtext);  */
 	      }
 	      else {
 		g_free(new_searchtext);
diff --git a/gschem/src/x_dialog.c b/gschem/src/x_dialog.c
index 751fad3..2014eaa 100644
--- a/gschem/src/x_dialog.c
+++ b/gschem/src/x_dialog.c
@@ -2871,7 +2871,9 @@ void find_text_dialog(GSCHEM_TOPLEVEL *w_current)
   remember_page = w_current->toplevel->page_current;
   if ((object = o_select_return_first_object(w_current)) != NULL) {
     if (object->type == OBJ_TEXT) {
-      strncpy(generic_textstring, object->text->string, 256);
+      strncpy (generic_textstring,
+               o_text_get_string (w_current->toplevel, object),
+               256);
     }
   }
 
diff --git a/gschem/src/x_multiattrib.c b/gschem/src/x_multiattrib.c
index 58ae786..9e7da61 100644
--- a/gschem/src/x_multiattrib.c
+++ b/gschem/src/x_multiattrib.c
@@ -643,7 +643,7 @@ static void multiattrib_action_duplicate_attribute(GSCHEM_TOPLEVEL *w_current,
   OBJECT *o_new;
   
   o_new = o_attrib_add_attrib (w_current,
-                               o_attrib->text->string,
+                               o_text_get_string (w_current->toplevel, o_attrib),
                                o_attrib->visibility,
                                o_attrib->show_name_value,
                                object);
@@ -682,13 +682,17 @@ static void multiattrib_column_set_data_name(GtkTreeViewColumn *tree_column,
   OBJECT *o_attrib;
   gchar *name;
   Multiattrib *dialog = (Multiattrib *) data;
+  const gchar *str = NULL;
 
   gtk_tree_model_get (tree_model, iter,
                       COLUMN_ATTRIBUTE, &o_attrib,
                       -1);
   g_assert (o_attrib->type == OBJ_TEXT);
-  
-  o_attrib_get_name_value (o_attrib->text->string, &name, NULL);
+
+  str = o_text_get_string (GSCHEM_DIALOG(dialog)->w_current->toplevel,
+                           o_attrib);
+
+  o_attrib_get_name_value (str, &name, NULL);
   g_object_set (cell,
                 "text", name,
                 NULL);
@@ -710,13 +714,17 @@ static void multiattrib_column_set_data_value(GtkTreeViewColumn *tree_column,
   OBJECT *o_attrib;
   gchar *value;
   Multiattrib *dialog = (Multiattrib *) data;
+  const gchar *str = NULL;
 
   gtk_tree_model_get (tree_model, iter,
                       COLUMN_ATTRIBUTE, &o_attrib,
                       -1);
   g_assert (o_attrib->type == OBJ_TEXT);
-  
-  o_attrib_get_name_value (o_attrib->text->string, NULL, &value);
+
+  str = o_text_get_string (GSCHEM_DIALOG(dialog)->w_current->toplevel,
+                           o_attrib);
+
+  o_attrib_get_name_value (str, NULL, &value);
   g_object_set (cell,
                 "text", value,
                 NULL);
@@ -861,7 +869,9 @@ static void multiattrib_callback_edited_name(GtkCellRendererText *cellrendererte
                       -1);
   g_assert (o_attrib->type == OBJ_TEXT);
 
-  o_attrib_get_name_value (o_attrib->text->string, NULL, &value);
+  o_attrib_get_name_value (o_text_get_string (w_current->toplevel,
+                                              o_attrib),
+                           NULL, &value);
   newtext = g_strdup_printf ("%s=%s", arg2, value);
 
   if (!x_dialog_validate_attribute(GTK_WINDOW(multiattrib), newtext)) {
@@ -909,7 +919,9 @@ static void multiattrib_callback_edited_value(GtkCellRendererText *cell_renderer
                       -1);
   g_assert (o_attrib->type == OBJ_TEXT);
 
-  o_attrib_get_name_value (o_attrib->text->string, &name, NULL);
+  o_attrib_get_name_value (o_text_get_string (w_current->toplevel,
+                                              o_attrib),
+                           &name, NULL);
   newtext = g_strdup_printf ("%s=%s", name, arg2);
 
   if (!x_dialog_validate_attribute(GTK_WINDOW(multiattrib), newtext)) {

commit 6718a8d2187b4a871051eee299cef8bbbef02280
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Sat Aug 16 18:10:53 2008 +0100

    gschem: Pass dialog to multiattrib treeview data funcs.
    
    The cell data funcs for the multi-attribute editor dialog's treeview
    need to have access to a libgeda TOPLEVEL to be able to use
    o_text_get_string(). The obvious thing to do is to pass in a pointer
    to the dialog (which contains a pointer to the GSCHEM_TOPLEVEL, etc)
    as the user data pointer.

diff --git a/gschem/src/x_multiattrib.c b/gschem/src/x_multiattrib.c
index f0910cd..58ae786 100644
--- a/gschem/src/x_multiattrib.c
+++ b/gschem/src/x_multiattrib.c
@@ -681,6 +681,7 @@ static void multiattrib_column_set_data_name(GtkTreeViewColumn *tree_column,
 {
   OBJECT *o_attrib;
   gchar *name;
+  Multiattrib *dialog = (Multiattrib *) data;
 
   gtk_tree_model_get (tree_model, iter,
                       COLUMN_ATTRIBUTE, &o_attrib,
@@ -708,6 +709,7 @@ static void multiattrib_column_set_data_value(GtkTreeViewColumn *tree_column,
 {
   OBJECT *o_attrib;
   gchar *value;
+  Multiattrib *dialog = (Multiattrib *) data;
 
   gtk_tree_model_get (tree_model, iter,
                       COLUMN_ATTRIBUTE, &o_attrib,
@@ -1590,7 +1592,7 @@ static void multiattrib_init(Multiattrib *multiattrib)
   gtk_tree_view_column_pack_start (column, renderer, TRUE);
   gtk_tree_view_column_set_cell_data_func (column, renderer,
 					   multiattrib_column_set_data_name,
-					   NULL, NULL);
+					   multiattrib, NULL);
   gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
   /*       - column 2: attribute value */
   renderer = GTK_CELL_RENDERER (
@@ -1615,7 +1617,7 @@ static void multiattrib_init(Multiattrib *multiattrib)
   gtk_tree_view_column_pack_start (column, renderer, TRUE);
   gtk_tree_view_column_set_cell_data_func (column, renderer,
 					   multiattrib_column_set_data_value,
-					   NULL, NULL);
+					   multiattrib, NULL);
   gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
   /*       - column 3: visibility */
   renderer = GTK_CELL_RENDERER (

commit df8478a9706694220919f3e3f6304a351a7eca68
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Sat Aug 16 18:10:21 2008 +0100

    libgeda: Add static update_disp_string() function.
    
    Adds update_disp_string() to o_text_basic.c, to reduce code
    duplication between o_text_recreate() and o_text_add().

diff --git a/libgeda/src/o_text_basic.c b/libgeda/src/o_text_basic.c
index 6fdfe6c..677b5cd 100644
--- a/libgeda/src/o_text_basic.c
+++ b/libgeda/src/o_text_basic.c
@@ -41,6 +41,45 @@ void (*text_draw_func)() = NULL;
 #define WINONLY	1
 #define BACKING 2
 
+static void update_disp_string(OBJECT *o)
+{
+  char *name = NULL;
+  char *value = NULL;
+  TEXT *text = o->text;
+
+  g_free (text->disp_string);
+
+  if (o_attrib_get_name_value (text->string, &name, &value)) {
+    switch (o->show_name_value) {
+      case (SHOW_NAME_VALUE):
+        text->disp_string = g_strdup (text->string);
+        break;
+
+      case (SHOW_NAME):
+        if (name[0] != '\0') {
+          text->disp_string = g_strdup (name);
+        } else {
+          g_critical ("Got an improper attribute: %s\n",
+                      text->string);
+          text->disp_string = g_strdup ("invalid");
+        }
+        break;
+
+      case (SHOW_VALUE):
+        if (value[0] != '\0') {
+          text->disp_string = g_strdup(value);
+        } else {
+          g_critical ("Got an improper attribute: %s\n",
+                      text->string);
+          text->disp_string = g_strdup ("invalid");
+        }
+        break;
+    }
+  } else {
+    text->disp_string = g_strdup (text->string);
+  }
+}
+
 /*! \note
  *  font storage and friends are staying global so that all can access
  */
@@ -928,45 +967,7 @@ OBJECT *o_text_add(TOPLEVEL *toplevel, OBJECT *object_list,
   /* properly */ 
   object_list = (OBJECT *) s_basic_link_object(new_node, object_list);
 
-  /* fix up actual string here */ 
-  if (o_attrib_get_name_value(string, &name, &value)) {
-
-    switch(show_name_value) {
-      case(SHOW_NAME_VALUE):
-        text->disp_string = g_strdup(string);
-        break;
-
-      case(SHOW_NAME):
-        if (name[0] != '\0') {
-          text->disp_string = g_strdup(name);
-        } else {
-          /* you probably can remove this now... */
-          /* since improper attributes will never get here */
-          fprintf(stderr, 
-                  "Got an improper attribute: %s\n", 
-                  string);
-          text->disp_string = g_strdup("invalid");
-
-        }
-        break;
-
-      case(SHOW_VALUE):
-        if (value[0] != '\0') {
-          text->disp_string = g_strdup (value);
-        } else {
-          /* you probably can remove this now... */
-          /* since improper attributes will never get here */
-          fprintf(stderr, 
-                  "Got an improper attribute: %s\n", 
-                  string);
-          text->disp_string = g_strdup("invalid");
-        }
-        break;
-    }
-  } else {
-    text->disp_string = g_strdup(string);
-  }
-
+  update_disp_string (new_node);
 
   /* now start working on the complex */
   temp_list = o_text_add_head();
@@ -1275,43 +1276,7 @@ void o_text_recreate(TOPLEVEL *toplevel, OBJECT *o_current)
   char *value = NULL;
   TEXT *text = o_current->text;
 
-  g_free (text->disp_string);
-
-  if (o_attrib_get_name_value (text->string, &name, &value)) {
-    switch(o_current->show_name_value) {
-      case(SHOW_NAME_VALUE):
-        text->disp_string = g_strdup (text->string);
-        break;
-
-      case(SHOW_NAME):
-        if (name[0] != '\0') {
-          text->disp_string = g_strdup(name);
-        } else {
-          /* you probably can remove this now... */
-          /* since improper attributes will never get here */
-          fprintf(stderr, 
-                  "Got an improper attribute: %s\n", 
-                  text->string);
-          text->disp_string = g_strdup ("invalid");
-        }
-        break;
-
-      case(SHOW_VALUE):
-        if (value[0] != '\0') {
-          text->disp_string = g_strdup(value);
-        } else {
-          /* you probably can remove this now... */
-          /* since improper attributes will never get here */
-          fprintf(stderr, 
-                  "Got an improper attribute: %s\n", 
-                  text->string);
-          text->disp_string = g_strdup ("invalid");
-        }
-        break;
-    }
-  } else {
-    text->disp_string = g_strdup (text->string);
-  }
+  update_disp_string (o_current);
 
   o_list_delete_rest (toplevel, text->prim_objs);
 

commit e44826c49a0db40b0c5e981431fd005b6e8d9048
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Sat Aug 16 18:08:31 2008 +0100

    libgeda: Add field to TEXT for storing displayed string.
    
    Sometimes, the string to be displayed is different from the whole
    string contained by a TEXT object (for instance, when an attribute has
    either its name or value unshown). When using "real" fonts we don't
    want to fix this up each and every time the string is rendered, so
    it needs to be stashed somewhere.

diff --git a/libgeda/include/struct.h b/libgeda/include/struct.h
index 51701ba..28f0d64 100644
--- a/libgeda/include/struct.h
+++ b/libgeda/include/struct.h
@@ -152,6 +152,7 @@ struct st_text {
   int x, y;		/* world origin */
 
   char *string;			/* text stuff */
+  char *disp_string;
   int length;
   int size;
   int alignment;	
diff --git a/libgeda/src/o_text_basic.c b/libgeda/src/o_text_basic.c
index 1ac0935..6fdfe6c 100644
--- a/libgeda/src/o_text_basic.c
+++ b/libgeda/src/o_text_basic.c
@@ -894,8 +894,7 @@ OBJECT *o_text_add(TOPLEVEL *toplevel, OBJECT *object_list,
   OBJECT *temp_list=NULL;
   TEXT *text;
   char *name = NULL;
-  char *value = NULL; 
-  char *output_string = NULL;
+  char *value = NULL;
 
   if (string == NULL) {
     return(NULL);
@@ -906,6 +905,7 @@ OBJECT *o_text_add(TOPLEVEL *toplevel, OBJECT *object_list,
   text = (TEXT *) g_malloc(sizeof(TEXT));
 
   text->string = g_strdup (string);
+  text->disp_string = NULL; /* We'll fix this up later */
   text->length = strlen(string);
   text->size = size;
   text->alignment = alignment;
@@ -933,38 +933,38 @@ OBJECT *o_text_add(TOPLEVEL *toplevel, OBJECT *object_list,
 
     switch(show_name_value) {
       case(SHOW_NAME_VALUE):
-        output_string = g_strdup(string);
+        text->disp_string = g_strdup(string);
         break;
 
       case(SHOW_NAME):
         if (name[0] != '\0') {
-          output_string = g_strdup(name);
+          text->disp_string = g_strdup(name);
         } else {
           /* you probably can remove this now... */
           /* since improper attributes will never get here */
           fprintf(stderr, 
                   "Got an improper attribute: %s\n", 
                   string);
-          output_string = g_strdup("invalid");
+          text->disp_string = g_strdup("invalid");
 
         }
         break;
 
       case(SHOW_VALUE):
         if (value[0] != '\0') {
-          output_string = g_strdup (value);
+          text->disp_string = g_strdup (value);
         } else {
           /* you probably can remove this now... */
           /* since improper attributes will never get here */
           fprintf(stderr, 
                   "Got an improper attribute: %s\n", 
                   string);
-          output_string = g_strdup("invalid");
+          text->disp_string = g_strdup("invalid");
         }
         break;
     }
   } else {
-    output_string = g_strdup(string);
+    text->disp_string = g_strdup(string);
   }
 
 
@@ -975,11 +975,11 @@ OBJECT *o_text_add(TOPLEVEL *toplevel, OBJECT *object_list,
       (visibility == INVISIBLE && toplevel->show_hidden_text)) {
     object_list->text->prim_objs = 
       o_text_create_string(toplevel, temp_list,
-                           output_string, size, color,
+                           text->disp_string, size, color,
                            x, y, alignment, angle); 
     object_list->text->displayed_width = o_text_width(toplevel,
-                                                      output_string, size/2);
-    object_list->text->displayed_height = o_text_height(output_string, size);
+                                                      text->disp_string, size/2);
+    object_list->text->displayed_height = o_text_height(text->disp_string, size);
   } else {
     object_list->text->prim_objs = NULL;
     object_list->text->displayed_width = 0;
@@ -992,7 +992,6 @@ OBJECT *o_text_add(TOPLEVEL *toplevel, OBJECT *object_list,
 
   g_free(name);
   g_free(value);
-  g_free(output_string);
   return(object_list);
 }
 
@@ -1275,42 +1274,43 @@ void o_text_recreate(TOPLEVEL *toplevel, OBJECT *o_current)
   char *name = NULL;
   char *value = NULL;
   TEXT *text = o_current->text;
-  char *output_string = NULL;
+
+  g_free (text->disp_string);
 
   if (o_attrib_get_name_value (text->string, &name, &value)) {
     switch(o_current->show_name_value) {
       case(SHOW_NAME_VALUE):
-        output_string = g_strdup (text->string);
+        text->disp_string = g_strdup (text->string);
         break;
 
       case(SHOW_NAME):
         if (name[0] != '\0') {
-          output_string = g_strdup(name);
+          text->disp_string = g_strdup(name);
         } else {
           /* you probably can remove this now... */
           /* since improper attributes will never get here */
           fprintf(stderr, 
                   "Got an improper attribute: %s\n", 
                   text->string);
-          output_string = g_strdup("invalid");
+          text->disp_string = g_strdup ("invalid");
         }
         break;
 
       case(SHOW_VALUE):
         if (value[0] != '\0') {
-          output_string = g_strdup(value);
+          text->disp_string = g_strdup(value);
         } else {
           /* you probably can remove this now... */
           /* since improper attributes will never get here */
           fprintf(stderr, 
                   "Got an improper attribute: %s\n", 
                   text->string);
-          output_string = g_strdup("invalid");
+          text->disp_string = g_strdup ("invalid");
         }
         break;
     }
   } else {
-    output_string = g_strdup (text->string);
+    text->disp_string = g_strdup (text->string);
   }
 
   o_list_delete_rest (toplevel, text->prim_objs);
@@ -1325,7 +1325,7 @@ void o_text_recreate(TOPLEVEL *toplevel, OBJECT *o_current)
 
     text->prim_objs = o_text_create_string (toplevel,
                                             text->prim_objs,
-                                            output_string,
+                                            text->disp_string,
                                             text->size,
                                             o_current->color,
                                             text->x,
@@ -1336,9 +1336,9 @@ void o_text_recreate(TOPLEVEL *toplevel, OBJECT *o_current)
     o_complex_set_saved_color_only(text->prim_objs,
                                    o_current->saved_color);
     text->displayed_width = o_text_width (toplevel,
-                                          output_string,
+                                          text->disp_string,
                                           text->size/2);
-    text->displayed_height = o_text_height (output_string,
+    text->displayed_height = o_text_height (text->disp_string,
                                             text->size);
   } else {
     /* make sure list is truely free */
@@ -1352,7 +1352,6 @@ void o_text_recreate(TOPLEVEL *toplevel, OBJECT *o_current)
 
   g_free(name);
   g_free(value);
-  g_free(output_string);
 }
 
 /*! \todo Finish function documentation!!!
diff --git a/libgeda/src/s_basic.c b/libgeda/src/s_basic.c
index cc36057..258d0d9 100644
--- a/libgeda/src/s_basic.c
+++ b/libgeda/src/s_basic.c
@@ -364,6 +364,7 @@ s_delete_object(TOPLEVEL *toplevel, OBJECT *o_current)
       /*printf("sdeleting text->string\n");*/
       g_free(o_current->text->string); 
       o_current->text->string = NULL;
+      g_free(o_current->text->disp_string);
 
       if (o_current->text->prim_objs) {
 				/*printf("sdeleting text complex\n");*/

commit 89c9af836536c13d97fde7d8b408e084f4b0e1d5
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Sat Aug 16 18:04:22 2008 +0100

    libgeda: Add accessors to get/set a text object's string.
    
    In later commits, direct application accesses to the string in the
    TEXT structure will be removed.

diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 974c97f..b5549ec 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -296,6 +296,8 @@ OBJECT *o_text_copy(TOPLEVEL *toplevel, OBJECT *list_tail, OBJECT *o_current);
 void o_text_freeallfonts(TOPLEVEL *toplevel);
 void o_text_rotate_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object);
 void o_text_mirror_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object);
+void o_text_set_string(TOPLEVEL *toplevel, OBJECT *obj, const gchar *new_string);
+const gchar *o_text_get_string(TOPLEVEL *toplevel, OBJECT *obj);
 
 /* s_attrib.c */
 int s_attrib_add_entry(char *new_attrib);
diff --git a/libgeda/src/o_text_basic.c b/libgeda/src/o_text_basic.c
index f0d1124..1ac0935 100644
--- a/libgeda/src/o_text_basic.c
+++ b/libgeda/src/o_text_basic.c
@@ -1895,3 +1895,71 @@ gdouble o_text_shortest_distance(TEXT *text, gint x, gint y)
   return shortest_distance;
 }
 
+/*! \brief Set the string displayed by a text object.
+ *  \par Function Description
+ *  Updates the text object with a new text string.
+ *
+ *  \param [in]  toplevel              The TOPLEVEL object.
+ *  \param [in]  obj                   The text object.
+ *  \param [in]  new_string            The new value.
+ */
+void o_text_set_string (TOPLEVEL *toplevel, OBJECT *obj,
+                        const gchar *new_string)
+{
+  if (toplevel == NULL) {
+    g_critical ("o_text_set_string: Received NULL TOPLEVEL structure.");
+    return;
+  }
+  if (obj == NULL) {
+    g_critical ("o_text_set_string: Received NULL OBJECT structure.");
+    return;
+  }
+  if (obj->type != OBJ_TEXT) {
+    g_critical ("o_text_set_string: OBJECT type not OBJ_TEXT.");
+    return;
+  }
+  if (obj->text == NULL) {
+    g_critical ("o_text_set_string: Text object without TEXT structure.");
+    return;
+  }
+  if (new_string == NULL) {
+    g_critical ("o_text_set_string: New string was NULL.");
+    return;
+  }
+
+  g_free (obj->text->string);
+  obj->text->string = g_strdup (new_string);
+}
+
+
+
+/*! \brief Get the string displayed by a text object.
+ *  \par Function Description
+ *  Retrieve the text string from a text object. The returned string
+ *  should be treated as constant.
+ *
+ *  \param [in]  toplevel              The TOPLEVEL object.
+ *  \param [in]  obj                   The text object.
+ *  \return The text object's string, or NULL on failure.
+ */
+const gchar *o_text_get_string (TOPLEVEL *toplevel, OBJECT *obj)
+{
+  if (toplevel == NULL) {
+    g_critical ("o_text_get_string: Received NULL TOPLEVEL structure.");
+    return NULL;
+  }
+  if (obj == NULL) {
+    g_critical ("o_text_get_string: Received NULL OBJECT structure.");
+    return NULL;
+  }
+  if (obj->type != OBJ_TEXT) {
+    g_critical ("o_text_get_string: OBJECT type not OBJ_TEXT.");
+    return NULL;
+  }
+  if (obj->text == NULL) {
+    g_critical ("o_text_get_string: Text object without TEXT structure.");
+    return NULL;
+  }
+
+  return obj->text->string;
+}




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