Re: Reduce the size of a GtkScale indicator



On Fri, 2018-03-30 at 21:01 +0200, Stefan Salewski wrote:
I have the impression there is no CSS property to make GtkScale
slider
smaller.

Finally I have a working solution. The trick is, that we have to set
margin also. Margin is negative in default, which does not work with
tiny min-width and max-width. margin is the size of the colored bar.

Here is the Nim code for a tiny slider, code for other languages should
be similar:

import gintro/[gtk, glib, gobject, gio]

proc appActivate(app: Application) =
  let window = newApplicationWindow(app)
  let scale = newScaleWithRange(Orientation.horizontal, 0.0, 100.0, 10.0)
  let cssProvider = newCssProvider()
  let data = "scale slider {min-width: 4px; min-height: 4px; margin: 0px}"
  discard cssProvider.loadFromData(data)
  let styleContext = scale.getStyleContext
  assert styleContext != nil
  addProvider(styleContext, cssProvider, STYLE_PROVIDER_PRIORITY_USER)
  window.add(scale)
  showAll(window)

proc main =
  let app = newApplication("org.gtk.example")
  connect(app, "activate", appActivate)
  discard run(app)

main()

Note that this CSS code does affect only the widgets of your tool, not
other Gnome widgets. You may even name your widgets and then can set
CSS properties of single widgets.


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