comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GTK strangeness
Date: Thu, 1 Oct 2009 09:39:48 +0200
Date: 2009-10-01T09:38:23+02:00	[thread overview]
Message-ID: <vpwwfm7dhlhw$.rupz6bte04e9$.dlg@40tude.net> (raw)
In-Reply-To: 12f2c1f9-9f42-49f8-9a0d-d565d8ddb8be@l13g2000yqb.googlegroups.com

On Wed, 30 Sep 2009 18:52:15 -0700 (PDT), RasikaSrinivasan@gmail.com wrote:

> I have a strange situation.
> 
> I attempt to set the font to a different font than normal.
> 
> It appears this works fine for gtk.label.gtk_label but
> gtk.button.gtk_button
> 
> Is this expected?

That depends on how are you doing what. There are numerous ways of setting
fonts to particular widgets and the font itself as a parameter/property of
the widget can be of different flavors, e.g. a property, a style, a
property style, bare argument of a call, coming with another widget etc.

> Also I expected that all widgets would inherit some settings like font
> from their container. Is this not so in gtk?

There is no standard mechanism because of the variety of ways a widget may
decide which font to use.

Specifically to Gtk_Button, it is a container and the text in it can be any
sort of thing. You can for example create a tree view and put it into the
button. What would be the font? The answer is, that depends on what font
and whom it actually belongs. In this case certainly not to the button.

In the standard scenario, when the button label is set with Set_Label, the
font is set by the widget style. There are ways to influence that and it
again depends on how are you going to do it (programmatically, using
resource files and schemas etc). Sorry, if that sounds confusing, but it
is.

OK, I didn't want to leave you with that. (:-)) So here is the most simple
way to set the font programmatically. You create a button (Gtk_Button) with
no text or images. Then you create a label (Gtk_Label) with the desired
font and text. Then put that label into the button, which is a mere bin
container. Here you are.

If you need an icon too, create a Gtk_HBox put there the label and the
image, put the box into the button. Done.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2009-10-01  7:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-01  1:52 GTK strangeness RasikaSrinivasan@gmail.com
2009-10-01  2:10 ` Srini -
2009-10-01  7:39 ` Dmitry A. Kazakov [this message]
2009-10-01 13:19   ` Srini -
2009-10-01 15:22     ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox