gattrib

globals.h File Reference

Global variable declarations. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define DEFAULT_PRECISION   2
#define DEFAULT_SPACE   8
#define NUM_SHEETS   3
#define BLACK   0
#define WHITE   1
#define RED   2
#define GREEN   3
#define BLUE   4
#define YELLOW   5
#define CYAN   6
#define GREY   7

Variables

TOPLEVEL * pr_current
SHEET_DATAsheet_head
GtkWidget * window
GtkWidget * notebook
GtkSheet ** sheets
GtkWidget ** scrolled_windows
GtkWidget * entry
GtkWidget * location
GtkWidget * left_button
GtkWidget * center_button
GtkWidget * right_button
GtkWidget * label
int verbose_mode
 Reflects the value of the command line flag.
int quiet_mode
 Reflects the value of the command line flag.

Detailed Description

SDB note about philosophy behind globals

I made the "TOPLEVEL project" and all the GTK window stuff into global variables. I know that this is supposedly bad programming form. However, here are some observations:

  • I wanted to use gEDA's TOPLEVEL structure as much as possible, at least to hold info about the design's netlist & components. The TOPLEVEL strucuture is architected to hold info about gschem's window also. HOwever, gschem's windows are architected differently than mine in gattrib. This is because my windowing system does completely different things, and also uses the GtkSheet widget, which is architected completely differently from TOPLEVEL.
  • Since I couldn't easily or naturally cram my windowing scheme into TOPLEVEL (or so I think), I decided to use a separate set of windows from those defined under TOPLEVEL for my application.
  • The problem arises when using callbacks. Callbacks from GTK allow only one argument to be passed. Given the way I set up the menu bar, I didn't have easy acces to the information inside both the GtkSHeet objects *and* the TOPLEVEL stuff while only having one callback argument. This makes it hard to have access to e.g. a GtkSheet window and a list of files (in TOPLEVEL) simultaneously.
  • Therefore, I decided to make both the window stuff and TOPLEVEL globals.
  • Similarly, because I couldn't cram the SHEET_DATA struct into any hook in TOPLEVEL, I just made it a global also.
  • Finally, in my defense, in gschem and gnetlist, (TOPLEVEL *w_current or pr_current) is passed to almost every function. Since it is just a pointer to a huge struct of stuff, manipulating the stuff in the struct has a global effect. That is, manipulating w_current (or pr_current) has side effects, so it is basically a global anyway. The real problem with globals occurs when you have a global variable caled "i" or "temp" which conflicts with a global in a module written by somebody else. Since pr_current is a very uncommon name, this should not be a problem here. Therefore, I decided to make life easy for myself dealing with callbacks by making both the windows and TOPLEVEL global variables.

If there is a better way to solve this problem, I'd like to hear it.

Definition in file globals.h.


Define Documentation

#define DEFAULT_PRECISION   2

Definition at line 93 of file globals.h.

#define DEFAULT_SPACE   8

Definition at line 94 of file globals.h.

#define NUM_SHEETS   3

Definition at line 95 of file globals.h.

#define BLACK   0

Definition at line 115 of file globals.h.

#define WHITE   1

Definition at line 116 of file globals.h.

#define RED   2

Definition at line 117 of file globals.h.

#define GREEN   3

Definition at line 118 of file globals.h.

#define BLUE   4

Definition at line 119 of file globals.h.

#define YELLOW   5

Definition at line 120 of file globals.h.

#define CYAN   6

Definition at line 121 of file globals.h.

#define GREY   7

Definition at line 122 of file globals.h.


Variable Documentation

TOPLEVEL* pr_current

The main data structure from gEDA. I made it a global since it was treated that way anyway. It is defined in structs.h

Definition at line 79 of file globals.h.

My own data structure which I made a global because it was easier to deal with when handing callbacks. It is defined in structs.h

Definition at line 88 of file globals.h.

GtkWidget* window

Definition at line 97 of file globals.h.

GtkWidget* notebook

Definition at line 98 of file globals.h.

Definition at line 100 of file globals.h.

GtkWidget** scrolled_windows

Definition at line 102 of file globals.h.

GtkWidget* entry

Definition at line 103 of file globals.h.

GtkWidget* location

Definition at line 104 of file globals.h.

GtkWidget* left_button

Definition at line 105 of file globals.h.

GtkWidget* center_button

Definition at line 106 of file globals.h.

GtkWidget* right_button

Definition at line 107 of file globals.h.

GtkWidget* label

Definition at line 108 of file globals.h.

Definition at line 42 of file globals.c.

Definition at line 43 of file globals.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines