RE: Finding which row is selected in a CList



I (personally) dont like the use of global variables because on a large
scale program with many GtkCList's you then start having rediculously long
names in order to make them globally unique.  I also believe its a little
messy, the way I usually do it, is have a structure and have them all
defined there - I use a structure per window, eg:

struct {

GtkWidget *window;
GtkWidget *clist1;
GtkWidget *clist2;

.
.
.

} controlsSQLWindow;

I define this struct in the C file and dont make it externally available,
this way you can write functions to access it externally (which is a little
like the C++ / classes approach with classes get/set... for member data).

Martyn

-----Original Message-----
From: TP Muller [mailto:tpm01 aber ac uk]
Sent: Saturday, May 25, 2002 9:10 AM
To: ridefast ozemail com au
Cc: gtk-app-devel-list gnome org
Subject: Re: Finding which row is selected in a CList


On Thursday 01 January 1970 00:59, you wrote:

My next problem is this. (...)  I have
an interface containing (among other things) two clists, a text box and
a button. What I would like to do is, when the button is clicked, get
the data from the selected rows in both of the clists and use this data
in an sql query, pumping results/errors into the text box. I only know
how to pass one widget in the user_data of signal connects. How do I
access other widgets from the window? I have the gtk+ docs here, but I
am also new to C which doesn't help. Sorry again if this is something
really simple and stupid, I just don't get it ( yet ;-) and need a few
pointers.

you could make the variables containing the clists and the text box widgets 
global instead of local to the function constructing the clists/text box. 

Alternatively, you could pass a pointer to a structure/array that contains 
the variables with the needed widgets. I'd probably go for the first
approach 
though:

in somefile.h:

extern GtkCList *list1;
extern GtkCList *list2;
extern GtkText *textbox;
(of course those could all be GtkWidget * as well instead)


then in somefile.c at the top before any functions start:

GtkCList *list1;
GtkCList *list2;
GtkText *textbox;

void
my_first_function (void)
{
 ...
}

etc.. This way every routine in every file can directly access the variables

list1, list2, and textbox as long as those files have a
#include "somefile.h"
at the beginning.

Hope this helps.

Cheers
-Tim


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]