Re: GTK3 Frame Border - Bug #659926



thanks, i'll get it working in some manner of form, you've provided me lots of possibilities.

my ignorance is historical, i'm an old guy who wrote GUI's back in the day using X11 calls directly, where my preference has remained to simply code everything by hand, a level of control i prefer, even if it's ultimately an illusion at this point.

(old dogs and all that...)

r-

On Thu, Sep 10, 2015 at 10:21 AM, Emmanuele Bassi <ebassi gmail com> wrote:
Hi;

On 10 September 2015 at 16:08, richard boaz <ivor boaz gmail com> wrote:
> 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)?

You can:

  1. use an ancillary file that you install on disk, and load at
application start
  2. embed the CSS as a string inside your application
  3. use GResource[1] to keep the CSS as a separate file and only
embed it into the application's binary when building it

[1] https://developer.gnome.org/gio/stable/GResource.html

> 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?

Yes, you need to add the style class to the GtkStyleContext of each
widget that should use that style class.

If you have 50 drawing areas and frames, then why are you not using
GtkBuilder? Then it would be a simple matter of adding the style class
in the XML.

Alternatively, you can create your own composite widget by subclassing
GtkFrame and adding a GtkDrawingArea to it; then you could set the CSS
style class in your subclass. My strong suggestion is to use GtkWidget
templates[2].

[2] https://developer.gnome.org/gtk3/stable/GtkWidget.html#composite-templates

Ciao,
 Emmanuele.

> On Thu, Sep 10, 2015 at 9:28 AM, Emmanuele Bassi <ebassi gmail com> wrote:
>>
>> Hi;
>>
>> On 10 September 2015 at 15:06, richard boaz <ivor boaz gmail com> 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.
>>
>> --
>> https://www.bassi.io
>> [ ] ebassi [@gmail.com]
>
>



--
https://www.bassi.io
[ ] ebassi [@gmail.com]



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