Pass by reference...(easy question)

2007-05-03 Thread beginner.c

Hi,

I know how to pass by reference in C normally. But how do I pass by ref a
GTK Widget to a function?
-- 
View this message in context: 
http://www.nabble.com/Pass-by-reference...%28easy-question%29-tf3688934.html#a10313107
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


Re: Pass by reference...(easy question)

2007-05-03 Thread Allin Cottrell
On Thu, 3 May 2007, beginner.c wrote:

 I know how to pass by reference in C normally. But how do I pass by ref a
 GTK Widget to a function?

The same way, by giving the address of the object.  However, with 
a GtkWidget what you have in hand is already a pointer so in most 
cases it suffices to pass that pointer.

Totally useless but hopefully illustrative code follows:

#include gtk/gtk.h

void f1 (GtkWidget *w)
{
gtk_widget_show(w);
gtk_widget_destroy(w);
}

void f2 (GtkWidget **pw)
{
gtk_widget_show(*pw);
gtk_widget_destroy(*pw);
*pw = NULL;
}

int main (int argc, char **argv)
{
GtkWidget *w;

gtk_init(argc, argv);

w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
printf(created new GtkWidget at %p\n, (void *) w);

f1(w);
/* bzzt, invalid pointer below; it has been freed */
printf(After f1(), w = %p\n, (void *) w);

w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
printf(created new GtkWidget at %p\n, (void *) w);

f2(w);
printf(After f2(), w = %p\n, (void *) w);

return 0;
}

Here, the above prints:

created new GtkWidget at 0x8079000
After f1(), w = 0x8079000
created new GtkWidget at 0x80790a8
After f2(), w = (nil)

Allin Cottrell
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


set acceleration key for a pictured button

2007-05-03 Thread Omid Mottaghi
hi all,

how can i set acceleration key for a button that contain a picture widget?
for labeled buttons we use mnemonic feature, but here what should we do?!

-- 
Good Luck
 http://oxygenws.com/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list