Re: multiple data args to gtk_signal_connect



John R Sheets wrote:
> 
> fritz jetzek wrote:
> >
> > to make the question clear by code:
> >
> > (example)
> >
> > bla = g_string_new("asdf");
> > blub = g_string_new("hi");
> >
> > gtk_signal_connect(GTK_OBJECT(some_button), "clicked",
> > GTK_SIGNAL_FUNC(my_func), bla, blub);
> >
> > ^^^^^^^^^
> >
> > illegal
> 
> Why not use a struct?
> 
>  typedef _MyParams MyParams;
>  struct _MyParams
>  {
>    GString *str1;
>    GString *str2;
>  };
> 
>  ....
> 
>  MyParams bla;
>  bla.str1 = g_string_new("asdf");
>  bla.str2 = g_string_new("hi");
> 
>  gtk_signal_connect(GTK_OBJECT(some_button), "clicked",
>  GTK_SIGNAL_FUNC(my_func), &bla);
> 
> John
> 

hm... yes i thought of that, too, but i would expect that a function
which is as basic as gtk_signal_connect should provide some way of
passing multiple args. i have this problem quite often and defining a
struct every time doesn't seem the most elegant way... however, i'll
make use of your suggestion as i can't think for a better solution for
myself. by the way, is it possible creating and passing a struct on the
fly (in the call of gtk_signal_func)? it wouldn't probably look that
nice but saves lines ;)

at least it seems my question wasn't that silly =)

best wishes,
fritz



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