Re: an additional argument flag




Tim Janik <timj@gimp.org> writes:

> On 21 Feb 1998, Owen Taylor wrote:
> 
> > But I'm not sure what people are proposing to do about it.
> > 
> >  ??? Tim's solution: mark all mandatory arguments of the widget
> >      with a flag, then have a special "construct" signal that
> >      does the argument-dependent initialization _after_
> >      the the mandatory arguments have been set. ??? (This is
> >      a bit ugly for people who don't want to do a query_args()
> >      type dynamic thing, though such people should be able
> >      to look a the source code and figure out there own way
> >      of setting the mandatory arguments)
> 
> an extra signal emission isn't neccessary, since the widgets setup
> code (e.g. gtk_clist_construct ()) can be called from the widgets
> *_set_arg function once the mandatory arguments are all set.

How does this work?

That seems to make each widget keep track of whether each
mandatory argument has been set or not.

Code for hypothetical widget's set_arg:

 case NUM_ROWS:
   g_return_if_fail (doodad->num_rows != -1);
   doodad->num_rows = GTK_VALUE_INT (*arg);

   if (doodad->num_cols != -1)
      gtk_doodad_construct (doodad, num_rows, num_cols)
 
   break;

 case NUM_COLS:
   g_return_if_fail (doodad->num_cols != -1);
   doodad->num_cols = GTK_VALUE_INT (*arg);

   if (doodad->num_rows != -1)
      gtk_doodad_construct (doodad, num_rows, num_cols)
 
   break;

Is this what you mean? (It could conceivably get considerably
more complex.)
  

That seems a bit complicated. Maybe its acceptable complexity,
since only a few widgets need to deal with it, and many only
have a single mandatory argument... 

I don't see a better solution right now, anyways.

Regards,
                                        Owne



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