Re: GtkStyleKey / GtkStyle




Umm no, I just changed the order of the symbols. 
The size of _GtkStyleKey and  _GtkStyle remains the same.

gtk_style_find() creates a GtkStyleKey key, fills in the
appropriate values (fg, bg, text, .., depth, cmap), calls
gtk_cache_insert, which then duplicates the key and allocates
more memory at the end of the structure. This key is then casted to
GtkStyle and given to gtk_style_init (GtkStyle *style), which reads some
values (fg, bg) and fills other values into the spaces allocated at the end 
of GtkStyleKey (now GtkStyle).

In other words: GtkStyle /is a/ GtkStyleKey, with some fields added at its end.
So the current implementation is wrong:


struct _GtkStyleKey		struct _GtkStyle
{				{
  GdkColor fg[5];		  GdkColor fg[5];
  GdkColor bg[5];		  GdkColor bg[5];
  GdkColor text[5];		  GdkColor light[5];
  GdkColor base[5];		  GdkColor dark[5];
				  GdkColor mid[5];
  GdkPixmap *bg_pixmap[5];	  GdkColor text[5];
				  GdkColor base[5];
  GdkFont *font;
				  GdkColor black;
  gint depth;			  GdkColor white;
  GdkColormap *colormap;	  GdkFont *font;
  GtkStyleClass *klass;
};				  GdkGC *fg_gc[5];
				  GdkGC *bg_gc[5];
				  GdkGC *light_gc[5];
				  GdkGC *dark_gc[5];
				  GdkGC *mid_gc[5];
				  GdkGC *text_gc[5];
				  GdkGC *base_gc[5];
				  GdkGC *black_gc;
				  GdkGC *white_gc;

				  GdkPixmap *bg_pixmap[5];

				  gint ref_count;
				  gint attach_count;

				  gint depth;
				  GdkColormap *colormap;

				  GtkStyleClass *klass;
				};


See, I can extract fg[] and bg[], but when I try to get text[0], I get *font,
which is nonsense.

So the implementation should be:

struct _GtkStyleKey		struct _GtkStyle
{				{
				  /* inherited from GtkStyleKey */
  GdkColor fg[5];		  GdkColor fg[5];
  GdkColor bg[5];		  GdkColor bg[5];
  GdkColor text[5];		  GdkColor text[5];
  GdkColor base[5];		  GdkColor base[5];

  GdkPixmap *bg_pixmap[5];	  GdkPixmap *bg_pixmap[5];

  GdkFont *font;		  GdkFont *font;

  gint depth;			  gint depth;
  GdkColormap *colormap;	  GdkColormap *colormap;
  GtkStyleClass *klass;		  GtkStyleClass *klass;
};

				  /* New entries */
				  GdkColor light[5];
				  GdkColor dark[5];
				  GdkColor mid[5];

				  GdkColor black;
				  GdkColor white;

				  GdkGC *fg_gc[5];
				  GdkGC *bg_gc[5];
				  GdkGC *light_gc[5];
				  GdkGC *dark_gc[5];
				  GdkGC *mid_gc[5];
				  GdkGC *text_gc[5];
				  GdkGC *base_gc[5];
				  GdkGC *black_gc;
				  GdkGC *white_gc;

				  gint ref_count;
				  gint attach_count;
				};


By the way, is there any documentation available? You've written
nice code, but it is a bit difficult to understand when there is
no comment what a function does.


Jost

















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