1 /* gEDA - GNU Electronic Design Automation
2 * gattrib -- gEDA component and net attribute manipulation using spreadsheet.
3 * Copyright (C) 2003 Stuart D. Brorson.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
21 /* ----------- SDB note about philosophy behind globals -------------- *
22 * I made the "TOPLEVEL project" and all the GTK window stuff into
23 * global variables. I know that this is supposedly bad programming form.
24 * However, here are some observations:
25 * -- I wanted to use gEDA's TOPLEVEL structure as much as possible, at
26 * least to hold info about the design's netlist & components.
27 * The TOPLEVEL strucuture is architected to hold info about gschem's
28 * window also. HOwever, gschem's windows are architected differently
29 * than mine in gattrib. This is because my windowing system does
30 * completely different things, and also uses the GtkSheet widget, which
31 * is architected completely differently from TOPLEVEL.
32 * -- Since I couldn't easily or naturally cram my windowing scheme into
33 * TOPLEVEL (or so I think), I decided to use a separate set of windows
34 * from those defined under TOPLEVEL for my application.
35 * -- The problem arises when using callbacks. Callbacks from GTK allow
36 * only one argument to be passed. Given the way I set up the menu bar,
37 * I didn't have easy acces to the information inside both the GtkSHeet
38 * objects *and* the TOPLEVEL stuff while only having one callback
39 * argument. This makes it hard to have access to e.g. a GtkSheet window
40 * and a list of files (in TOPLEVEL) simultaneously.
41 * -- Therefore, I decided to make both the window stuff and TOPLEVEL
43 * -- Similarly, because I couldn't cram the SHEET_DATA struct into any
44 * hook in TOPLEVEL, I just made it a global also.
45 * -- Finally, in my defense, in gschem and gnetlist, (TOPLEVEL *w_current
46 * or pr_current) is passed to almost every function. Since it
47 * is just a pointer to a huge struct of stuff, manipulating
48 * the stuff in the struct has a global
49 * effect. That is, manipulating w_current (or pr_current) has side
50 * effects, so it is basically a global anyway. The real problem with
51 * globals occurs when you have a global variable caled "i" or "temp"
52 * which conflicts with a global in a module written by somebody else.
53 * Since pr_current is a very uncommon name, this should not be a
54 * problem here. Therefore, I decided
55 * to make life easy for myself dealing with callbacks by making both
56 * the windows and TOPLEVEL global variables.
57 * If there is a better way to solve this problem, I'd like to hear it.
58 * ------------------------------------------------------------------ */
64 /*------------------------------------------------------------------
65 * pr_current -- the main data structure from gEDA. I made it a
66 * global since it was treated that way anyway. It is defined in
68 *------------------------------------------------------------------*/
71 /*------------------------------------------------------------------
72 * (SHEET_DATA *sheet_head) -- my own data structure which I made
73 * a global because it was easier to deal with when handing
74 * callbacks. It is defined in structs.h
75 *------------------------------------------------------------------*/
76 SHEET_DATA
*sheet_head
;
78 /*------------------------------------------------------------------
79 * GTKsheet includes: stuff for dealing with windows.
80 *------------------------------------------------------------------*/
81 #define DEFAULT_PRECISION 2
82 #define DEFAULT_SPACE 8
83 #define NUM_SHEETS 3 /* Components, Nets, and Pins */
85 GtkWidget
*window
; /* Main window */
88 GtkSheet
**sheets
; /* These are the spreadsheet widgets themselves */
90 GtkWidget
**scrolled_windows
;
93 GtkWidget
*left_button
;
94 GtkWidget
*center_button
;
95 GtkWidget
*right_button
;
98 /* command line switch settings */
99 extern int verbose_mode
;
100 extern int quiet_mode
;