The proper way to integrate self-made widgets with themes
- From: centipede takhis net
- To: gtk-app-devel-list gnome org
- Subject: The proper way to integrate self-made widgets with themes
- Date: Fri, 8 Feb 2008 09:22:46 +0100 (CET)
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]