remember that to assign styles in rc files you must always define a style and assign the style to a widget (or widget class).
read about gtkrc formating in the main "resource files" section of the api docs... installing style properties on your widget class is easy as installing normal properties, easier since you dont need to handle property changes, just install it inline with other properties in class_init() using gtk_widget_class_install_style_property() (I think thats the right api, but you'll find it). See some other display widgets to see how they deal with styles also, normaly widgets consult the style information in expose event handlers when ready to draw, you'll want to do things like paint the "foreground color" or paint the flat colour used for dropshadows etc, in order to reuse colours from the theme as much as possible. Cheers, -Tristan On Feb 8, 2008 6:22 AM, <[EMAIL PROTECTED]> wrote: > Hello list. > > I asked this question a few days ago at the generic gtk list, but > unfortunately did not get much of an answer. I'll figure I would try my > luck here instead... > > ------------------------------------ > > In the process of making a bunch of widgets I have stumbled upon this > issue: I need to paint various parts of my widget, but I would like to > make the color of the parts controlled by the theme. I.e. the properties I > want to deal with are extra, self-invented properties besides the usual > style properties. (Note: I am using PyGTK 2.12, GTK 2.10 on Arch Linux) > > I have figured out how to manually load a theme-file accompanying my > application (by setting the environment variable GTK2_RC_FILES to ./gtkrc > before initializing gtk) > However I cannot insert my own property-names in such a file. The > following gives rise to a syntax error: > > # My Properties > scalartrack_segment_handle_size = 5 > > Besides I wouldn't know how to get those properties out again so I can use > them in an expose event > > So... > I am asking for the canonical way to implement new widgets and push the > choice of color, size and pixmap-overlays to the theme-designer. The > alternative is drawing with libcairo and using hardwired style properties. > > ------------------------------------ > > Then I answered my own question in part (but not enough) with this > posting: > > ------------------------------------ > > Possible solution: Use the pixmap engine. It seems to support the "detail" > parameter, so I can specify many additional sections, one for each detail. > Example: > style "track" > { > engine "pixmap" > { > image > { > function = BOX > recolorable = TRUE > detail = "segment" > file = "Extra/track-segment-type1.png" > border = { 5, 5, 5, 5 } > stretch = TRUE > orientation = HORIZONTAL > } > } > } > > .. This style will draw the image "Extra/track-segment-type1.png" when > invoked with this command (in PyGTK): > > self.styleTrack.paint_box (self.window, gtk.STATE_NORMAL, > gtk.SHADOW_IN, None, None, "segment", X,Y,W,H) > > > > But still: How *should* I draw a theme'd box (using gtk_paint_box) in > colors different from what the theme has chosen for my GtkDrawingArea? Do > I have to modify_bg before each call to paint_box, and then reset it again > afterwards? > > Remember that a widget can have several "details" which need not be in the > same color or style. It should not be necessary to make both a "Knob" and > "Trough" widget to make a scrollbar which paint two rectangles in > different colors. > > > Regards, > Rene Jensen, Denmark > > > > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list