[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: Makefile.am
User: sdb
Date: 05/07/14 13:29:25
Modified: . Makefile.am s_object.c s_table.c s_toplevel.c
x_window.c
Added: . s_visibility.c
Log:
Numerous changes made to implement ability to change attribute
visibility settings from within gattrib.
Revision Changes Path
1.5 +2 -0 eda/geda/devel/gattrib/src/Makefile.am
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Makefile.am
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gattrib/src/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- Makefile.am 21 Feb 2005 05:29:33 -0000 1.4
+++ Makefile.am 14 Jul 2005 17:29:24 -0000 1.5
@@ -32,6 +32,7 @@
s_object.c \
s_attrib.c \
s_toplevel.c \
+ s_visibility.c \
gattrib.c
else
gattrib_SOURCES = \
@@ -56,6 +57,7 @@
s_object.c \
s_attrib.c \
s_toplevel.c \
+ s_visibility.c \
gattrib.c
endif
1.6 +27 -13 eda/geda/devel/gattrib/src/s_object.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: s_object.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gattrib/src/s_object.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- s_object.c 5 Feb 2005 16:03:53 -0000 1.5
+++ s_object.c 14 Jul 2005 17:29:24 -0000 1.6
@@ -61,17 +61,21 @@
* to attrib_graphic.
* 3. It calls o_attrib_add to wrap attrib_graphic with (ATTRIB )
*------------------------------------------------------------------ */
-void s_object_add_comp_attrib_to_object(OBJECT *o_current, char *new_attrib_name,
- char *new_attrib_value)
+void s_object_add_comp_attrib_to_object(OBJECT *o_current,
+ char *new_attrib_name,
+ char *new_attrib_value,
+ gint visibility,
+ gint show_name_value)
{
char *name_value_pair;
OBJECT *attrib_graphic_object;
- /* One last sanity check */
+
+ /* One last sanity check, then add attrib */
if (strlen(new_attrib_value) != 0) {
name_value_pair = g_strconcat(new_attrib_name, "=", new_attrib_value, NULL);
- attrib_graphic_object = s_object_attrib_add_attrib_in_object(pr_current, name_value_pair, INVISIBLE,
- SHOW_NAME_VALUE, o_current);
+ attrib_graphic_object = s_object_attrib_add_attrib_in_object(pr_current, name_value_pair, visibility,
+ show_name_value, o_current);
}
return;
@@ -107,6 +111,7 @@
char *name_value_pair;
OBJECT *attrib_graphic_object;
+
/* One last sanity check */
if (strlen(new_attrib_value) != 0) {
name_value_pair = g_strconcat(new_attrib_name, "=", new_attrib_value, NULL);
@@ -126,14 +131,18 @@
* This fcn finds the instance of attrib_name on o_current, and
* replaces it's value wiht new_attrib_value.
*------------------------------------------------------------------*/
-void s_object_replace_attrib_in_object(OBJECT *o_current, char *new_attrib_name,
- char *new_attrib_value)
+void s_object_replace_attrib_in_object(OBJECT *o_current,
+ char *new_attrib_name,
+ char *new_attrib_value,
+ gint visibility,
+ gint show_name_value)
{
ATTRIB *a_current;
char *old_attrib_text;
char *old_attrib_name;
char *new_attrib_text;
+
a_current = o_current->attribs;
while (a_current != NULL) {
if (a_current->object->type == OBJ_TEXT
@@ -148,17 +157,22 @@
new_attrib_text = g_strconcat(new_attrib_name, "=", new_attrib_value, NULL);
free(a_current->object->text->string); /* remove old attrib string */
a_current->object->text->string = g_strdup(new_attrib_text); /* insert new attrib string */
+ if (visibility != LEAVE_VISIBILITY_ALONE)
+ a_current->object->visibility = visibility;
+ if (show_name_value != LEAVE_NAME_VALUE_ALONE)
+ a_current->object->show_name_value = show_name_value;
free(new_attrib_text);
free(old_attrib_text);
free(old_attrib_name);
return; /* we are done -- leave. */
- }
+ } else {
free(old_attrib_text);
free(old_attrib_name);
+ } /* if (strcmp . . . . */
} /* if (a_current . . . . */
a_current = a_current->next;
- }
+ } /* while */
/* if we get here, it's because we have failed to find the attrib on the component.
* This is an error condition. */
1.10 +11 -2 eda/geda/devel/gattrib/src/s_table.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: s_table.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gattrib/src/s_table.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- s_table.c 6 Mar 2005 19:17:26 -0000 1.9
+++ s_table.c 14 Jul 2005 17:29:24 -0000 1.10
@@ -76,7 +76,8 @@
(new_table[i][j]).col_name = NULL;
(new_table[i][j]).row = i;
(new_table[i][j]).col = j;
- (new_table[i][j]).visibility = 3; /* both name & value visible */
+ (new_table[i][j]).visibility = VISIBLE;
+ (new_table[i][j]).show_name_value = SHOW_VALUE;
}
}
@@ -111,7 +112,9 @@
(new_table[i][j]).col_name = NULL;
(new_table[i][j]).row = i;
(new_table[i][j]).col = j;
- (new_table[i][j]).visibility = 3; /* both name & value visible */
+ (new_table[i][j]).visibility = VISIBLE;
+ (new_table[i][j]).show_name_value = SHOW_VALUE;
+
}
}
@@ -231,6 +234,8 @@
gchar *attrib_name;
gchar *attrib_value;
ATTRIB *a_current;
+ gint old_visibility, old_show_name_value;
+
if (verbose_mode) {
printf("- Starting internal component TABLE creation\n");
@@ -275,6 +280,8 @@
attrib_text = g_strdup(a_current->object->text->string);
attrib_name = u_basic_breakup_string(attrib_text, '=', 0);
attrib_value = u_basic_breakup_string(attrib_text, '=', 1);
+ old_visibility = a_current->object->visibility;
+ old_show_name_value = a_current->object->show_name_value;
/* Don't include "refdes" or "slot" because they form the row name. */
if ( (strcmp(attrib_name, "refdes") != 0)
@@ -294,6 +301,8 @@
((sheet_head->component_table)[row][col]).row_name = g_strdup(temp_uref);
((sheet_head->component_table)[row][col]).col_name = g_strdup(attrib_name);
((sheet_head->component_table)[row][col]).attrib_value = g_strdup(attrib_value);
+ ((sheet_head->component_table)[row][col]).visibility = old_visibility;
+ ((sheet_head->component_table)[row][col]).show_name_value = old_show_name_value;
}
free(attrib_name);
free(attrib_text);
1.13 +34 -6 eda/geda/devel/gattrib/src/s_toplevel.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: s_toplevel.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gattrib/src/s_toplevel.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- s_toplevel.c 21 Feb 2005 05:29:33 -0000 1.12
+++ s_toplevel.c 14 Jul 2005 17:29:24 -0000 1.13
@@ -682,8 +682,11 @@
char *new_attrib_value;
char *old_attrib_name;
char *old_attrib_value;
+ gchar *refdes;
ATTRIB *a_current;
int count = 0; /* This is to fake out a fcn called later */
+ gint row, col;
+ gint visibility, show_name_value;
#if DEBUG
printf("----- Entering s_toplevel_update_component_attribs_in_toplevel.\n");
@@ -767,6 +770,16 @@
new_attrib_value);
#endif
+ /* Now get row and col where this new attrib lives. Then get
+ * visibility of the new attrib stored in the component table */
+ /* We'll need this later */
+ refdes = g_strdup(s_attrib_get_refdes(o_current));
+ row = s_table_get_index(sheet_head->master_comp_list_head, refdes);
+ col = s_table_get_index(sheet_head->master_comp_attrib_list_head, new_attrib_name);
+ visibility = sheet_head->component_table[row][col].visibility;
+ show_name_value = sheet_head->component_table[row][col].show_name_value;
+ free(refdes);
+
/* ------- Four cases to consider: Case 1 ----- */
if ( (old_attrib_value != NULL) && (new_attrib_value != NULL) && (strlen(new_attrib_value) != 0) ) {
@@ -775,7 +788,11 @@
printf(" -- In s_toplevel_update_component_attribs_in_toplevel, about to replace old attrib with name= %s, value= %s\n",
new_attrib_name, new_attrib_value);
#endif
- s_object_replace_attrib_in_object(o_current, new_attrib_name, new_attrib_value);
+ s_object_replace_attrib_in_object(o_current,
+ new_attrib_name,
+ new_attrib_value,
+ visibility,
+ show_name_value);
}
/* ------- Four cases to consider: Case 2 ----- */
@@ -797,7 +814,11 @@
new_attrib_name, new_attrib_value);
#endif
- s_object_add_comp_attrib_to_object(o_current, new_attrib_name, new_attrib_value);
+ s_object_add_comp_attrib_to_object(o_current,
+ new_attrib_name,
+ new_attrib_value,
+ visibility,
+ show_name_value);
/* ------- Four cases to consider: Case 4 ----- */
} else {
@@ -807,6 +828,9 @@
#endif
}
+ /* Toggle attribute visibility and name/value setting */
+
+
/* free everything and iterate */
if (new_attrib_name != NULL) {
free(new_attrib_name); /* Be careful, this can be NULL */
@@ -977,17 +1001,21 @@
}
old_attrib_value = o_attrib_search_name_single_count(o_pin, new_attrib_name, 0);
- /* ------- Four cases to consider: Case 1 ----- */
+ /* ------- Four cases to consider: Case 1: old and new attribs exist ----- */
if ( (old_attrib_value != NULL) && (new_attrib_value != NULL) && (strlen(new_attrib_value) != 0) ) {
/* simply write new attrib into place of old one. */
#if DEBUG
printf("In s_toplevel_update_pin_attribs_in_toplevel, about to replace old attrib with new one: name= %s, value= %s\n",
new_attrib_name, new_attrib_value);
#endif
- s_object_replace_attrib_in_object(o_pin, new_attrib_name, new_attrib_value);
+ s_object_replace_attrib_in_object(o_pin,
+ new_attrib_name,
+ new_attrib_value,
+ LEAVE_VISIBILITY_ALONE,
+ LEAVE_NAME_VALUE_ALONE);
}
- /* ------- Four cases to consider: Case 2 ----- */
+ /* ------- Four cases to consider: Case 2: old attrib exists, new one doesn't ----- */
else if ( (old_attrib_value != NULL) && (new_attrib_value == NULL) ) {
/* remove attrib from pin */
#if DEBUG
@@ -997,7 +1025,7 @@
s_object_remove_attrib_in_object(o_pin, new_attrib_name);
}
- /* ------- Four cases to consider: Case 3 ----- */
+ /* ------- Four cases to consider: Case 3: No old attrib, new one exists. ----- */
else if ( (old_attrib_value == NULL) && (new_attrib_value != NULL) ) {
/* add new attrib to pin. */
1.7 +6 -6 eda/geda/devel/gattrib/src/x_window.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: x_window.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gattrib/src/x_window.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- x_window.c 11 Mar 2005 17:50:56 -0000 1.6
+++ x_window.c 14 Jul 2005 17:29:24 -0000 1.7
@@ -87,7 +87,7 @@
void
x_window_init()
{
- /* note that the graphical widgets themselves (window, vbox, menu_bar)
+ /* note that the graphical widgets themselves (window, main_vbox, menu_bar)
* are globals defined in ../include/globals.h On pr_current I
* attach pointers to some of them here for future reference. */
@@ -122,16 +122,16 @@
GTK_SIGNAL_FUNC (gattrib_quit), NULL);
- /* ----- Now create vbox. This is a container which organizes child ----- */
+ /* ----- Now create main_vbox. This is a container which organizes child ----- */
/* ----- widgets into a vertical column. ----- */
/* main_vbox is a global defined in globals.h */
#ifdef DEBUG
printf("In x_window_init, about to set up vobx.\n");
#endif
- main_vbox=gtk_vbox_new(FALSE,1);
+ main_vbox = gtk_vbox_new(FALSE,1);
gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 1);
- gtk_container_add(GTK_CONTAINER(window), main_vbox);
- gtk_widget_show(main_vbox);
+ gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(main_vbox) );
+ gtk_widget_show(GTK_WIDGET(main_vbox) );
/* ----- Now create menu bar ----- */
@@ -359,7 +359,7 @@
}
gtk_widget_show( GTK_WIDGET(notebook) );
- gtk_widget_show( GTK_WIDGET(main_vbox) );
+ /* gtk_widget_show( GTK_WIDGET(main_vbox) ); */
gtk_widget_show( GTK_WIDGET(window) );
return;
1.1 eda/geda/devel/gattrib/src/s_visibility.c
Index: s_visibility.c
===================================================================
/* gEDA - GPL Electronic Design Automation
* gattrib -- gEDA component and net attribute manipulation using spreadsheet.
* Copyright (C) 2003 Stuart D. Brorson.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
*/
/*------------------------------------------------------------------
* This file holds widgets and fcns used in conjunction
* with setting attribute visibility.
*------------------------------------------------------------------*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/*------------------------------------------------------------------
* Includes required to run graphical widgets.
*------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <glib.h>
#ifdef HAS_GTK22
#include <glib-object.h>
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAS_GTK22
#include "gtksheet_2_2.h"
#include "gtkitementry_2_2.h"
#else
#include "gtksheet_1_2.h"
#include "gtkitementry_1_2.h"
#endif
/*------------------------------------------------------------------
* Gattrib specific includes
*------------------------------------------------------------------*/
#include <libgeda/libgeda.h> /* geda library fcns */
#include "../include/struct.h" /* typdef and struct declarations */
#include "../include/prototype.h" /* function prototypes */
#include "../include/globals.h"
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
#endif
/* ----- s_visibility stuff begins here ----- */
/* ---------------------------------------------------------------------- *
* s_visibility_set_invisible -- This sets the selected cells to INVISIBLE.
* ---------------------------------------------------------------------- */
void s_visibility_set_invisible() {
gint i, j;
gint row_start, row_end, col_start, col_end;
GtkSheet *sheet;
gint cur_page;
cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
sheet = sheets[cur_page];
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
switch (sheet->state) {
case GTK_SHEET_RANGE_SELECTED:
case GTK_SHEET_COLUMN_SELECTED:
case GTK_SHEET_ROW_SELECTED:
#ifdef DEBUG
printf("In s_visibility_set_invisible, range/col/row selected.\n");
#endif
row_start = sheet->range.row0;
row_end = sheet->range.rowi;
col_start = sheet->range.col0;
col_end = sheet->range.coli;
for (i=row_start; i<=row_end; i++) {
for (j=col_start; j<=col_end; j++) {
s_visibility_set_cell(cur_page, i, j,
INVISIBLE,
LEAVE_NAME_VALUE_ALONE);
}
}
break;
case GTK_SHEET_NORMAL:
#ifdef DEBUG
printf("In s_visibility_set_invisible, normal selection.\n");
#endif
s_visibility_set_cell(cur_page,
sheet->active_cell.row,
sheet->active_cell.col,
INVISIBLE,
LEAVE_NAME_VALUE_ALONE);
break;
}
}
/* ---------------------------------------------------------------------- *
* s_visibility_set_name_only -- This sets the selected cells to NAME_ONLY.
* ---------------------------------------------------------------------- */
void s_visibility_set_name_only() {
gint i, j;
gint row_start, row_end, col_start, col_end;
GtkSheet *sheet;
gint cur_page;
cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
sheet = sheets[cur_page];
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
switch (sheet->state) {
case GTK_SHEET_RANGE_SELECTED:
case GTK_SHEET_COLUMN_SELECTED:
case GTK_SHEET_ROW_SELECTED:
#ifdef DEBUG
printf("In s_visibility_set_name_only, range/col/row selected.\n");
#endif
row_start = sheet->range.row0;
row_end = sheet->range.rowi;
col_start = sheet->range.col0;
col_end = sheet->range.coli;
for (i=row_start; i<=row_end; i++) {
for (j=col_start; j<=col_end; j++) {
s_visibility_set_cell(cur_page, i, j, VISIBLE, SHOW_NAME);
}
}
break;
case GTK_SHEET_NORMAL:
s_visibility_set_cell(cur_page,
sheet->active_cell.row,
sheet->active_cell.col,
VISIBLE, SHOW_NAME);
break;
}
}
/* ---------------------------------------------------------------------- *
* s_visibility_set_value_only -- This sets the selected cells to VALUE_ONLY.
* ---------------------------------------------------------------------- */
void s_visibility_set_value_only() {
gint i, j;
gint row_start, row_end, col_start, col_end;
GtkSheet *sheet;
gint cur_page;
cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
sheet = sheets[cur_page];
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
switch (sheet->state) {
case GTK_SHEET_RANGE_SELECTED:
case GTK_SHEET_COLUMN_SELECTED:
case GTK_SHEET_ROW_SELECTED:
#ifdef DEBUG
printf("In s_visibility_set_value_only, range/col/row selected.\n");
#endif
row_start = sheet->range.row0;
row_end = sheet->range.rowi;
col_start = sheet->range.col0;
col_end = sheet->range.coli;
for (i=row_start; i<=row_end; i++) {
for (j=col_start; j<=col_end; j++) {
s_visibility_set_cell(cur_page, i, j, VISIBLE, SHOW_VALUE);
}
}
break;
case GTK_SHEET_NORMAL:
#ifdef DEBUG
printf("In s_visibility_set_value_only, sheet normal selected.\n");
#endif
s_visibility_set_cell(cur_page,
sheet->active_cell.row,
sheet->active_cell.col,
VISIBLE, SHOW_VALUE);
break;
}
}
/* ---------------------------------------------------------------------- *
* s_visibility_set_name_and_value -- This sets the selected cells to NAME_AND_VALUE
* ---------------------------------------------------------------------- */
void s_visibility_set_name_and_value() {
gint i, j;
gint row_start, row_end, col_start, col_end;
GtkSheet *sheet;
gint cur_page;
cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
sheet = sheets[cur_page];
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
switch (sheet->state) {
case GTK_SHEET_RANGE_SELECTED:
case GTK_SHEET_COLUMN_SELECTED:
case GTK_SHEET_ROW_SELECTED:
row_start = sheet->range.row0;
row_end = sheet->range.rowi;
col_start = sheet->range.col0;
col_end = sheet->range.coli;
for (i=row_start; i<=row_end; i++) {
for (j=col_start; j<=col_end; j++) {
s_visibility_set_cell(cur_page, i, j, VISIBLE, SHOW_NAME_VALUE);
}
}
break;
case GTK_SHEET_NORMAL:
s_visibility_set_cell(cur_page,
sheet->active_cell.row,
sheet->active_cell.col,
VISIBLE,
SHOW_NAME_VALUE);
break;
}
}
/* ================== Private functions =================== */
/* ---------------------------------------------------------------------- *
* s_visibility_set_cell -- this sets the visibility of an individual cell
* to "state". The cell is identified by (row, col)
* ---------------------------------------------------------------------- */
void s_visibility_set_cell(gint cur_page, gint row, gint col,
gint visibility,
gint show_name_value) {
TABLE **local_table;
#ifdef DEBUG
printf("In s_visibility_set_cell, setting row = %d, col = %d.\n",
row, col);
#endif
switch (cur_page) {
case 0:
local_table = sheet_head->component_table;
break;
case 1:
local_table = sheet_head->net_table;
break;
case 2:
local_table = sheet_head->pin_table;
break;
}
/* Question: how to sanity check (row, col) selection? */
if (visibility != LEAVE_VISIBILITY_ALONE) {
local_table[row][col].visibility = visibility;
sheet_head->CHANGED = 1; /* cell has been updated. */
}
if (show_name_value != LEAVE_NAME_VALUE_ALONE) {
local_table[row][col].show_name_value = show_name_value;
sheet_head->CHANGED = 1; /* cell has been updated. */
}
}