Re: GtkImage changes



On 29 Jun 2000, Federico Mena Quintero wrote:

> Tim Janik <timj@gtk.org> writes:
> 
> > > Can we make the GtkImage structure opaque?  Otherwise some people who
> > 
> > no, that defeats derivation. there's a way to make fields private
> > that are intended to be private:
> > 
> > struct
> > {
> >   /*< public >*/
> >   gint public_int;
> >   /*< private >*/
> >   gint private_int;
> > };
> 
> Uh, I was thinking of
> 
> 	typedef struct {
> 		GtkWidget parent;
> 	
> 		gpointer priv;
> 	} GtkImage;
> 
> 	... plus a bunch of setters/getters for all the interesting attributes
> 
> which is my current favorite way of writing opaque objects :-)

and then you can't access internals from derived widgets.
btw, if you really need to make fields opaque, what's wrong
with:

typedef struct _GtkWidgetPrivate GtkWidgetPrivate;
typedef struct {
  GtkObject parent_instance;
  
  GtkWidgetPrivate *private;
} GtkWidget;

and then put

strcut _GtkWidgetPrivate {
  gint my_really_private_pr0n_field;
};

into your *.c file?

use typesafety where possible, and avoid casts where possible.

> 
>   Federico
> 

---
ciaoTJ





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