[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-devel
Subject:    Re: GtkLabel patch
From:       Tim Janik <timj () gtk ! org>
Date:       2001-02-28 23:48:17
[Download RAW message or body]

On Wed, 28 Feb 2001, Alexander Larsson wrote:


> Can I commit this?
> 
> / Alex
> 

> @@ -119,24 +128,80 @@ gtk_label_get_type (void)
> static void
> gtk_label_class_init (GtkLabelClass *class)
> {
> -  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
> +  GObjectClass *gobject_class;
> GtkObjectClass *object_class;
> GtkWidgetClass *widget_class;
> 
> +  gobject_class = (GObjectClass*) class;
> object_class = (GtkObjectClass*) class;
> widget_class = (GtkWidgetClass*) class;

he, there was a reason that i put a G_OBJECT_CLASS() cast there originally.
actually, all class assignments should use the provided casting macros instead
of direct c casts, it's the same as for widget casts, i.e. they do additional
checking for debugging code.

> +  gobject_class->set_property = gtk_label_set_property;
> +  gobject_class->get_property = gtk_label_get_property;
> +
> +  g_object_class_install_property (G_OBJECT_CLASS(object_class),
> +                                   PROP_TEXT,
> +                                   g_param_spec_string ("text",
> +                                                        _("Text"),
> +                                                        _("The text that this \
> label displays."), +                                                        NULL,
> +                                                        G_PARAM_READABLE | \
> G_PARAM_WRITABLE));
[...]

you can use G_PARAM_READWRITE as a convenience.

> +  g_object_class_install_property (gobject_class,
> +                                   PROP_SELECTABLE,
> +                                   g_param_spec_boolean ("selectable",
> +                                                        _("Selectable"),
> +                                                        _("Whether the label text \
> can be selected with the mouse."), +                                                \
> FALSE, +                                                        G_PARAM_READABLE | \
> G_PARAM_WRITABLE)); gobject_class->finalize = gtk_label_finalize;
> -
> -  object_class->set_arg = gtk_label_set_arg;
> -  object_class->get_arg = gtk_label_get_arg;
> 
> widget_class->size_request = gtk_label_size_request;
> widget_class->size_allocate = gtk_label_size_allocate;
> @@ -152,59 +217,82 @@ gtk_label_class_init (GtkLabelClass *cla
> widget_class->motion_notify_event = gtk_label_motion;
> }

ideally, you'd first setup all pointers in the class and then
add signals and properties.


> +  switch (prop_id)
> {
> -    case ARG_LABEL:
> -      gtk_label_set_text (label, GTK_VALUE_STRING (*arg));
> +    case PROP_TEXT:
> +      gtk_label_set_text (label, g_value_get_string (value));
> break;
> -    case ARG_PATTERN:
> -      gtk_label_set_pattern (label, GTK_VALUE_STRING (*arg));
> +    case PROP_ATTRIBUTES:
> +      {
> +	PangoAttrList *attrs = g_value_get_as_pointer (value);
> +	gtk_label_set_attributes (label, attrs);
> +	break;
> +      }

g_value_get_as_pointer() is mainly meant as an internal function for the
signal code. for boxed types, g_value_get_boxed() is there for you.
<sigh> i probably need to prefix g_value_get_as_pointer() with a "_".


---
ciaoTJ


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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic