Re: GTK3 Frame Border - Bug #659926

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

 



thanks for the explanation and path forward.

and so i understand absolutely:

i now have to wrap my app's execution in order to specify the CSS snippet?
or can i embed that CSS snippet into the binary itself, executed at execution startup (i.e., internally coded)?

obviously i prefer the 2nd since having to specify in two different places how the widgets should look inside a binary app is annoying.

and one more question:

documentation for gtk_style_context_add_class() indicates i should fetch the context from the widget i am wishing to add the class to.  my app has upwards of 50 drawing areas, each contained within a frame.  must i fetch a context and add the class for each frame individually, or is there a shorthand method to applying a single context and class to all frames containing my drawing areas?

thanks again,

richard


On Thu, Sep 10, 2015 at 9:28 AM, Emmanuele Bassi <ebassi@xxxxxxxxx> wrote:
Hi;

On 10 September 2015 at 15:06, richard boaz <ivor.boaz@xxxxxxxxx> wrote:

After some google-reading, it seems that with GTK-3, control of frame decorations has been 100% given over to whatever WM is running whatever theme.

The WM is not involved in the least. The theme involved is the GTK+ one.

To be fair, the shadow style was always left to the theme, even in the GTK+ 2.x days. These days, mapping all possible border size, shadow, and color combinations to a simple flat enumeration is impossible without having a combinatorial explosion of values. We have a better way, with CSS, to express that.

My first question to the general list is to wonder if anyone has found a work-around for this.  Investigating the documentation turns up nothing obvious in possible alternatives.

You can add your own CSS styling to get the border you wish.
 
Barring some other way of achieving what's required for my app, I'm dying to know how this evolution of functionality is a good idea.  A bug was reported for this (https://bugzilla.gnome.org/show_bug.cgi?id=659926) where this has been marked as WONTFIX, since this seems to have been simply given over to the theme engine's own nefarious intent.

Please, let's not be overly melodramatic. No need to infer "nefarious" intents.

The theme is responsible for the styling of everything you see on the screen; it makes sense to have the theme in charge of the border of a frame.

Since it's part of the theme, it also means you can override it with a custom set of CSS rules, instead of having to patch GTK or your application.
 
But I don't entirely understand this: the above two plots are generated using the same WM on the same box, at exactly the same time, so something has obviously changed between GTK-2 and GTK-3, where program control of how an app's internal widgets must be displayed has simply vanished.

The whole theme system has changed between GTK 2.x and GTK 3.x, so, yes: you could say that something has changed.
 
So, how am I supposed to provide a GtkGrid of drawing areas where I'm actually able to distinguish to the user the borders between them?

Add a style class to your GtkFrame, using the gtk_style_context_add_class() API on the GtkStyleContext of your widget, or by by using the <style><class name=''/></style> stanza in the GtkBuilder XML, depending on what you use to build your UI.

When launching your application, create a GtkCssProvider and load a CSS snippet; something like:

.my-drawing-area-frame {
  border: 1px red;
  padding: 6px;
}

and use gtk_style_context_add_provider_for_screen() to associate the GtkCssProvider to the default screen. This will ensure that all widgets with a style class of 'my-drawing-area-frame' will have a red, 1 pixel border, and a padding of 6 pixels.

Ciao,
 Emmanuele.

--

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux