Until there is a decent signal notification scheme for OBJECTS to
communicate with their collaborators, I would prefer to have the
toplevel->page_current->CHANGED = 1; bits as local to the mutations as
possible. This reduces the possibility of forgetting to mark the page
as CHANGED when calling the mutator.
Otherwise I like having more list-independent *_single style functions.
On Fri, Jul 25, 2008 at 5:52 PM, Patrick Bernaud <[EMAIL PROTECTED]> wrote:
> ---
> gschem/include/prototype.h | 2 +-
> gschem/src/i_callbacks.c | 16 +++++++--
> gschem/src/o_attrib.c | 87
> ++++++++++++++++++--------------------------
> 3 files changed, 49 insertions(+), 56 deletions(-)
>
> diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
> index c8c4185..edf3b53 100644
> --- a/gschem/include/prototype.h
> +++ b/gschem/include/prototype.h
> @@ -468,7 +468,7 @@ void o_arc_draw_grips(GSCHEM_TOPLEVEL *w_current, OBJECT
> *o_current);
> 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, GList *list);
> +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);
> OBJECT *o_attrib_add_attrib(GSCHEM_TOPLEVEL *w_current, char *text_string,
> int visibility, int show_name_value, OBJECT *object);
> /* o_basic.c */
> diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
> index d2c2553..245fe1f 100644
> --- a/gschem/src/i_callbacks.c
> +++ b/gschem/src/i_callbacks.c
> @@ -3220,9 +3220,19 @@ DEFINE_I_CALLBACK(attributes_visibility_toggle)
> i_callback_attributes_visibility_toggle,
> _("VisToggle"));
>
> - if (object != NULL) {
> - o_attrib_toggle_visibility(w_current,
> - geda_list_get_glist(
> w_current->toplevel->page_current->selection_list ) );
> + 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_visibility (w_current, object);
> + }
> +
> + toplevel->page_current->CHANGED=1;
> + o_undo_savestate (w_current, UNDO_ALL);
> }
> }
>
> diff --git a/gschem/src/o_attrib.c b/gschem/src/o_attrib.c
> index ab1dd2c..1d9a3d9 100644
> --- a/gschem/src/o_attrib.c
> +++ b/gschem/src/o_attrib.c
> @@ -86,68 +86,51 @@ void o_attrib_add_selected(GSCHEM_TOPLEVEL *w_current,
> SELECTION *selection,
> return;
> }
>
> -/*! \todo Finish function documentation!!!
> - * \brief
> +/*! \brief Change visibility status of attribute object.
> * \par Function Description
> + * This function toggles the visibility status of the attribute \a
> + * object and updates it. The object is erased or redrawn if
> + * necessary.
> *
> + * \param [in] w_current The GSCHEM_TOPLEVEL object.
> + * \param [in] object The attribute object.
> */
> -void o_attrib_toggle_visibility(GSCHEM_TOPLEVEL *w_current, GList *list)
> +void o_attrib_toggle_visibility(GSCHEM_TOPLEVEL *w_current, OBJECT *object)
> {
> TOPLEVEL *toplevel = w_current->toplevel;
> - GList *s_current = NULL;
> - OBJECT *object = NULL;
> -
> - if (list == NULL) {
> - return;
> - }
>
> - s_current = list;
> + g_return_if_fail (object != NULL && object->type == OBJ_TEXT);
>
> - while(s_current != NULL) {
> - object = (OBJECT *) s_current->data;
> - if (object == NULL) {
> - fprintf(stderr, _("Got NULL in o_attrib_toggle_visibility\n"));
> - exit(-1);
> + if (object->visibility == VISIBLE) {
> + /* only erase if we are not showing hidden text */
> + if (!toplevel->show_hidden_text) {
> + o_erase_single(w_current, object);
> }
> -
> - if (object->type == OBJ_TEXT) {
> - if (object->visibility == VISIBLE) {
> -
> - /* only erase if we are not showing hidden text */
> - if (!toplevel->show_hidden_text) {
> - o_erase_single(w_current, object);
> - }
> -
> - object->visibility = INVISIBLE;
> -
> - if (toplevel->show_hidden_text) {
> - /* draw text so that little I is drawn */
> - o_text_draw(w_current, object);
> - }
> -
> - toplevel->page_current->CHANGED=1;
> - } else {
> - /* if we are in the special show hidden mode, then erase text first
> */
> - /* to get rid of the little I */
> - if (toplevel->show_hidden_text) {
> - o_erase_single(w_current, object);
> - }
> -
> - object->visibility = VISIBLE;
> -
> - /* you must do this since real->text->complex */
> - /* might be null when text is invisible */
> - if (object->text->prim_objs == NULL)
> - o_text_recreate(toplevel, object);
> -
> -
> - o_text_draw(w_current, object);
> - toplevel->page_current->CHANGED = 1;
> - }
> +
> + object->visibility = INVISIBLE;
> +
> + if (toplevel->show_hidden_text) {
> + /* draw text so that little I is drawn */
> + o_text_draw(w_current, object);
> }
> - s_current = g_list_next(s_current);
> +
> + } else {
> + /* if we are in the special show hidden mode, then erase text first */
> + /* to get rid of the little I */
> + if (toplevel->show_hidden_text) {
> + o_erase_single(w_current, object);
> + }
> +
> + object->visibility = VISIBLE;
> +
> + /* you must do this since real->text->complex */
> + /* might be null when text is invisible */
> + if (object->text->prim_objs == NULL) {
> + o_text_recreate(toplevel, object);
> + }
> +
> + o_text_draw(w_current, object);
> }
> - o_undo_savestate(w_current, UNDO_ALL);
> }
_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev