1 /* gEDA - GPL Electronic Design Automation
2 * gattrib -- gEDA component and net attribute manipulation using spreadsheet.
3 * Copyright (C) 2003-2010 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * \brief Global variable declarations
25 * \section sdb_note SDB note about philosophy behind globals
27 * I made the "TOPLEVEL project" and all the GTK window stuff into
28 * global variables. I know that this is supposedly bad programming form.
29 * However, here are some observations:
30 * - I wanted to use gEDA's TOPLEVEL structure as much as possible, at
31 * least to hold info about the design's netlist & components.
32 * The TOPLEVEL strucuture is architected to hold info about gschem's
33 * window also. HOwever, gschem's windows are architected differently
34 * than mine in gattrib. This is because my windowing system does
35 * completely different things, and also uses the GtkSheet widget, which
36 * is architected completely differently from TOPLEVEL.
37 * - Since I couldn't easily or naturally cram my windowing scheme into
38 * TOPLEVEL (or so I think), I decided to use a separate set of windows
39 * from those defined under TOPLEVEL for my application.
40 * - The problem arises when using callbacks. Callbacks from GTK allow
41 * only one argument to be passed. Given the way I set up the menu bar,
42 * I didn't have easy acces to the information inside both the GtkSHeet
43 * objects *and* the TOPLEVEL stuff while only having one callback
44 * argument. This makes it hard to have access to e.g. a GtkSheet window
45 * and a list of files (in TOPLEVEL) simultaneously.
46 * - Therefore, I decided to make both the window stuff and TOPLEVEL
48 * - Similarly, because I couldn't cram the SHEET_DATA struct into any
49 * hook in TOPLEVEL, I just made it a global also.
50 * - Finally, in my defense, in gschem and gnetlist, (TOPLEVEL *w_current
51 * or pr_current) is passed to almost every function. Since it
52 * is just a pointer to a huge struct of stuff, manipulating
53 * the stuff in the struct has a global
54 * effect. That is, manipulating w_current (or pr_current) has side
55 * effects, so it is basically a global anyway. The real problem with
56 * globals occurs when you have a global variable caled "i" or "temp"
57 * which conflicts with a global in a module written by somebody else.
58 * Since pr_current is a very uncommon name, this should not be a
59 * problem here. Therefore, I decided
60 * to make life easy for myself dealing with callbacks by making both
61 * the windows and TOPLEVEL global variables.
63 * If there is a better way to solve this problem, I'd like to hear it.
66 /* ------------------------------------------------------------------ */
75 # define N_(String) gettext_noop (String)
77 # define N_(String) (String)
80 # define N_(String) (String)
84 /*------------------------------------------------------------------*/
86 * The main data structure from gEDA. I made it a
87 * global since it was treated that way anyway. It is defined in
90 /*------------------------------------------------------------------*/
91 extern TOPLEVEL
*pr_current
;
93 /*------------------------------------------------------------------*/
95 * My own data structure which I made
96 * a global because it was easier to deal with when handing
97 * callbacks. It is defined in structs.h
99 /*------------------------------------------------------------------*/
100 extern SHEET_DATA
*sheet_head
;
102 /*------------------------------------------------------------------
103 * GTKsheet includes: stuff for dealing with windows.
104 *------------------------------------------------------------------*/
105 #define DEFAULT_PRECISION 2
106 #define DEFAULT_SPACE 8
107 #define NUM_SHEETS 3 /* Components, Nets, and Pins */
109 extern GtkWidget
*window
; /* Main window */
110 extern GtkWidget
*notebook
;
112 extern GtkSheet
**sheets
; /* These are the spreadsheet widgets themselves */
114 extern GtkWidget
**scrolled_windows
;
115 extern GtkWidget
*entry
;
116 extern GtkWidget
*location
;
117 extern GtkWidget
*left_button
;
118 extern GtkWidget
*center_button
;
119 extern GtkWidget
*right_button
;
120 extern GtkWidget
*label
;
122 /* command line switch settings */
123 extern int verbose_mode
;
124 extern int quiet_mode
;
126 /* Used to identify colors */