[Top][All Lists]

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

Re: Status of my GTK efforts.

From: Jan D.
Subject: Re: Status of my GTK efforts.
Date: Mon, 31 Dec 2001 12:33:29 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.7) Gecko/20011221

Richard Stallman wrote:

    GTK uses different syntax from Xdefaults to begin with, here is an example:

    style "eventbox" {
       bg_pixmap[NORMAL] = "<parent>"
       bg_pixmap[INSENSITIVE] = "<parent>"
       bg_pixmap[PRELIGHT] = "<parent>"
       bg_pixmap[SELECTED] = "<parent>"
       bg_pixmap[ACTIVE] = "<parent>"

    class "GtkEventBox" style "eventbox"

I don't understand this example.  What does it mean?
What language is it written in?

Is this text that the user might write in order to customize GTK?  Or
is it a definition that says what information to request from the

As you see, I don't have even the first glimmer of an idea
what that text means.  Please explain to me as a user, not assuming
I know anything about using GTK.

This is the language a user writes in order to customize GTK. The file to do that would by default be the users ~/.gtkrc, so I will refer to this syntax as gtkrc.

In GTK widgets can have one of 5 states. Not all widget support all states. The states are
NORMAL - This is the default.
ACTIVE - The widget is active (for example, a button is pressed).
PRELIGHT - The widget has the focus (for example, mouse over a button)

SELECTED - The widget is selected (for example, a toggle button can be 

INSENSITIVE - The widget cannot be made active, selected or prelight (for example, a menu item not selectable).

For each of these states, the user can specify these five attributes of widgets:

fg - foreground color
bg - background color
bg_pixmap background pixmap
base - base color
text - text color.

Some widgets write there text using text, others use fg, some draw their background with base, some with bg (it is all very confusing).

Another attribute the user can specify is font. This is not per state, but one value:

style "my_font"
  font = "-*-courier-medium-r-normal-*-12-*-*-*-*-*-iso8859-1"

Styles can also inherit from a previous style (colours are spcified in RGB, either floating point 0.0 - 1.0 or integer 0 - 65535):

style "font_and_fg" = "my_font"
  fg[NORMAL] = { 0, 0, 0 }

The user then applies styles to widgets, either by widget class:

class "GtkText" style "my_font"

or by name (names of widget is specified in the program by calling gtk_widget_set_name):

widget "*.my_text" style "my_font"

Wildcards are possible, this would apply the style to all GTK widgets:

class "Gtk*" style "font_and_fg"

or all widgets below "my_top" in the containment tree:

widget "my_top.*" style "font_and_fg"

    Apart from the states, this can also be done in Xdefaults.

What can also be done in Xdefaults?

The user that uses Motif can als customize the things GTK can, but using Xdefaults instead of gtkrc. The equivalent setting to the above in a Motif application would be for the user to write in the ~/.Xdefaults file (assuming GtkText corresponds to a XmText):

!# class "GtkText" style "my_font"

*.XmText.fontList: -*-courier-medium-r-normal-*-12-*-*-*-*-*-iso8859-1

!# widget "*.my_text" style "my_font"
*.my_text.fontList: -*-courier-medium-r-normal-*-12-*-*-*-*-*-iso8859-1

!# class "Gtk*" style "font_and_fg"
!# This is not quite equvivalent, it affects all widgets
!# not just Motif.
*.fontList: -*-courier-medium-r-normal-*-12-*-*-*-*-*-iso8859-1
*.foreground: #000

!# widget "my_top.*" style "font_and_fg"
my_top.*.fontList: -*-courier-medium-r-normal-*-12-*-*-*-*-*-iso8859-1
my_top.*.foreground: #000

Ignoring the second usage, there is nothing new in GTKs way of handling resources. BUT, it is handeled by default and applied to appropriate widgets, whereas Xdefaults is ignored (much as Motif widgets react to Xdefaults automatically).

I don't understand.  "Xdefaults is ignored" is passive--it has no
subject.  So I don't know what you're talking about here.  What
ignores Xdefaults?

Perhaps you mean GTK.  Does GTK ignore Xdefaults?

Yes, GTK ignores Xdefaults.

If so, what do you mean by "this can also be done in Xdefaults"?
Is it possible in some way to use Xdefaults to customize GTK?
If so, how *exactly* would I do this?

Sorry to be unclear. What I mean is that given Motif and Xdefaults a user can do much the same customizations as with GTK and gtkrc.

        Jan D.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]