Re: [gtk-list] Args



On Sun, 10 May 1998, Olli Helenius wrote:

> Noticed that most of the widgets don't have any GtkArgGet/SetFuncs
> defined.  I could try and work on that if there is need and if no one else
> is already doing it...?

i occasionally get around to do that, but don't really have enough time.
so any help in this area would be apprechiated.
there are some gnits you have to care about when implementing this
functionality though - i'm still not completely sure that the current
argument parsing will work perfectly ok on all platforms.

type hassle:
frame =
  gtk_widget_new (gtk_frame_get_type (),
                  "GtkFrame::label", "MyFrame",
                  "GtkFrame::label_xalign", 0.5 /* <- this works ok here,
                                                 * eventhough this argument is
                                                 * defined to be of type
                                                 * GTK_TYPE_DOUBLE
                                                 */,
                  "GtkFrame::label_yalign", 7   /* this will always produce
                  				 * incorrect results since the
                  				 * compiler passes an int and
                  				 * the argument parser fetches
                  				 * a double
                  				 */,
                  "GtkFrame::shadow", GTK_SHADOW_ETCHED_OUT /* this argument
                                                 * is defined as GTK_TYPE_ENUM
                                                 * wich should work out mostly
                                                 * correct as an alias for
                                                 * integer
                                                 */,
                  NULL);

if someone else could try this out on platforms that don't have
sizeof(int)=sizeof(long)=4; that would be much aprechiated (and maybe even
produce problems....).

the other thing i noticed is that a lot of widget writers implement
functions incorrectly like:

void
gtk_frame_set_shadow_type (GtkFrame      *frame,
                           GtkShadowType  type)
{
  g_return_if_fail (frame != NULL);
  g_return_if_fail (GTK_IS_FRAME (frame));

  frame->shadow_type = type;
}

which will produce correct results for arguments set only upon creation
of a widget, but will actually fail (or appear somwhat delayed) for
changes that should immediately affect a widgets appearance.
so the correct version of this function should be (and currently also
is ;):

void
gtk_frame_set_shadow_type (GtkFrame      *frame,
                           GtkShadowType  type)
{
  g_return_if_fail (frame != NULL);
  g_return_if_fail (GTK_IS_FRAME (frame));

  if (frame->shadow_type != type)
    {
      frame->shadow_type = type;

      if (GTK_WIDGET_DRAWABLE (frame))
        {
          gdk_window_clear_area (GTK_WIDGET (frame)->window,
                                 GTK_WIDGET (frame)->allocation.x,
                                 GTK_WIDGET (frame)->allocation.y,
                                 GTK_WIDGET (frame)->allocation.width,
                                 GTK_WIDGET (frame)->allocation.height);
        }
      gtk_widget_queue_resize (GTK_WIDGET (frame));
    }
}

(note that the gtk_widget_queue_resize() is neccessary even if the widget
is not drawable, since the widget's size might be affected by this change
and a widget's allocation needs to be correct eventhough it is not
(currently) realized).


so if you are still with me ;), please provide patches for the widget
argument implementations and occasional fixes to functions like the
above. feel also free to mail me personally if you have any further
problems ;)

> 
> -- 
> And now for something completely different.
> 

and that would be?

---
ciaoTJ




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