LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-01-2008, 11:40 AM   #1
sneha hendre
LQ Newbie
 
Registered: Sep 2008
Posts: 7

Rep: Reputation: 0
Question Signal handlers in glade using C


Hi,
I am designing GUI using glade and C language.
When I catch a signal emitted by a button and call some function "abc"
how can I get the access to other widgets also...
At the most I am getting access to only two widgets
one from which the signal is emitted and the other is again passed through the handler function

g_signal_connect (GTK_OBJECT(button2), "clicked",
GTK_SIGNAL_FUNC(change),label1);

But what if I want to change some other entries also or i want some text entries when the button is clicked....

Can some body help me out....I am stuck up
 
Old 10-01-2008, 12:42 PM   #2
mk27
Member
 
Registered: Sep 2008
Distribution: fedora, gentoo, ubuntu
Posts: 148

Rep: Reputation: 23
The simplest answer is just to declare your widgets globally so you can refer to them anywhere. Otherwise, the only two widgets you can return with g_signal_connect are the connected object (button2) and the one pointer you're allowed, in this case label1.

BUT that pointer can actually be a pointer of any kind, so you could also declare your widgets (locally) in a struct that you can pass as a reference:

Code:
struct {
     GtkWidget *button2;
     GtkWidget *label1;
     GtkWidget *button3;
} bunch_o_widgets;
Used thus:

g_signal_connect (GTK_OBJECT(button2), "clicked",
GTK_SIGNAL_FUNC(change),&bunch_o_widgets);


In your callback function the syntax is:
bunch_o_widgets->button3

Then you can return all instead of a few widgets.

I just learned this a few days ago myself at www.gtkforums.com, which is also a great place and there are glade users there.

I imagine (altho I haven't tried) that if you don't want to put everything in a struct, you could have a smaller struct of pointers (to pointers, since a GtkWidget is such):

Code:
struct {
     GtkWidget *widget[3];
} some_widgets;

some_widgets.widget[0]=&button1;
some_widgets.widget[1]=&button2;
some_widgets.widget[2]=&button3;
Presuming the three buttons already exist. You might need to experiment with the syntax but it should work.

Last edited by mk27; 10-01-2008 at 12:59 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
multiplex I/O (select with signal handlers) tanalam Programming 1 08-03-2008 02:18 PM
signal handlers begi Linux - Newbie 1 03-05-2008 09:28 AM
any partition handlers in linux ? WhiskeyTangoFoxtrot Linux - Software 2 06-29-2006 02:02 PM
Glade 2.5.0 and Perl-Glade-Two - a little help please Lake-end Programming 1 03-07-2005 05:47 AM
multiple SIGALRM handlers in c jwstric2 Programming 2 08-07-2004 02:55 PM


All times are GMT -5. The time now is 08:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration