Re: GtkStyle arguments for GtkWidget



Quoting Tim Janik (timj@gtk.org):

> button =
>   gtk_widget_new (GTK_TYPE_ENTRY,
>		    "visible", TRUE,
>		    "style_fg::normal", 0xffff00 /* yellow */,
>		    "style_base::normal", 0xff00ff /* purple */,
>		    "style_fg::selected", 0x000000 /* black */,
>		    "style_base::normal", 0xffffff /* white */,
>		    "style_font", "-freefont-brushstroke-*-*-*-*-*-*-*-*-*-*-*-*",
>		    NULL);
>
> without going through all the hassle of copying and attaching new styles
> (especially in language bindings).
> the actuall code requirements to implement this in gtk (name_parameter_type
> needs to be done anyways) is pretty small, and imho the advantages we gain
> are more than worth it.

Please use #defines for the strings. There are several advantages if you
do so:

a) The compiler can check for typos.

b) You can put the strings in a table and reuse them without runtime
overhead:

    #define G_WidgetStyle_fg	gWidgetStyleStrings[5]

--
Dipl. Inf. (FH) Aaron "Optimizer" Digulla     Assistent im BIKS Labor, FB WI
"(to) optimize: Make a program faster by      FH Konstanz, Brauneggerstr. 55
improving the algorithms rather than by       Tel:+49-7531-206-514
buying a faster machine."                     EMail: digulla@fh-konstanz.de



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