Re: Reduce the size of a GtkScale indicator

2018-03-29 Thread Bas Wassink



On 03/29/18 21:19, Stefan Salewski wrote:

On Thu, 2018-03-29 at 18:02 +0200, Bas Wassink wrote:

Any hints?


https://developer.gnome.org/gtk3/stable/chap-css-overview.html

grep -A100 GtkScale ~/.config/gtk-3.0/gtk-default.css

Well, I do provide a colored label example at

https://github.com/StefanSalewski/gintro

Starting from that one, it is easy to get a really big slider:

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: 32pt; min-height: 32pt;}"
   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()

Yes, I know you want a tiny one. But setting nim-width, min-height to
small values does not decrease size, which is not really surprising, as
  that are min and max values. So we have to search for other properties
-- maybe Mr Bassi or Mr Bader will tell us.



I kinda figured I had to go the CSS route, bur I was hoping for 
something like gtk_scale_set_indicator(GTK_INDICATOR_TINY);, alas it was 
not be.


Thanks anyway, I'll see what I can with CSS without breaking themes too 
much.

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Reduce the size of a GtkScale indicator

2018-03-29 Thread Stefan Salewski
On Thu, 2018-03-29 at 18:02 +0200, Bas Wassink wrote:
> Any hints?

https://developer.gnome.org/gtk3/stable/chap-css-overview.html

grep -A100 GtkScale ~/.config/gtk-3.0/gtk-default.css

Well, I do provide a colored label example at

https://github.com/StefanSalewski/gintro

Starting from that one, it is easy to get a really big slider:

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: 32pt; min-height: 32pt;}"
  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()

Yes, I know you want a tiny one. But setting nim-width, min-height to
small values does not decrease size, which is not really surprising, as
 that are min and max values. So we have to search for other properties
-- maybe Mr Bassi or Mr Bader will tell us. 
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Reduce the size of a GtkScale indicator

2018-03-29 Thread Bas Wassink

Hey there,

I'm working on some code the uses a bunch of GtkScale's, but 
unfortunately the indicator (the thing you grab with the mouse) is way 
too large.


I'd rather not break the user's theme but still provide a smaller 
indicator to save vertical space. So how do I go about this? Are there 
CSS properties to set this, or do I provide my own image for the 
indicator (breaking the user's theme)?


I've looked at the Gtk3 docs and googled for setting the indicator size, 
but did not come up with a satisfying answer.


(I should probably also note this application is supposed to run on 
Linux, BSD, MacOS and Windows)


Any hints?

--Compyx
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Get the default font in Gtk3

2018-03-29 Thread rastersoft

Ok, now I thing I got it. Thank you very much!


El 29/03/18 a las 16:28, Emmanuele Bassi escribió:
On 29 March 2018 at 15:12, rastersoft > wrote:



[get the Gtk font type and size]

Ops, sorry: I'm reworking a backup utility that I wrote
(cronopete), and
I added a timeline with the backups (you can see an
screenshot at
http://www.rastersoft.com/cronopete_screenshot.png
 ). As
you can see, at
the left is the timeline and it has the days, months and
years. I think
those should use the same typography than the standard Gtk
widgets, but
reducing the size to 2/3. The same for the titles in each
"pseudowindow"
(they have a visual effect: they go forward and backwards
when you move
through the timeline).

...I must be missing something here...
You can change font size in a layout. The scrolling might be
tricky, but
just eyeballing it, sounds like something that can be done by
showing
the layout twice at different coords in different clips
(cairo_save/cairo_restore brackets).

So...?

(Only thing I'm not quite sure about right now is if gtk fully
initializes
font description in a layout, cause I vaguely recall that it might
not... though maybe that was just wrt. theming API...)


Mainly the problem is that I'm using cairo_show_text... 



That's the Cairo toy text API; you should only use it for tests or 
small examples; it's basically useless for anything user-facing.


I presume that what you say is that I should replace all that with
Pango... Now I have some problems: first, I'm using vala and I
can't find the "get_pango_layout" from a widget. It exists
"create_pango_layout", so I suppose that this is the call I need
to create a layout.


Yes, the function is `gtk_widget_create_pango_layout()`: 
https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-create-pango-layout


Now the big question is: does ANY widget return the right layout,
or I must use a widget designed to contain text (like a Gtk.Label)
to get that layout, paint into it, and paste it in the final Cairo
canvas (which won't be the same canvas than the Gtk.Label from
which I created the layout)?


All widgets that need to render text call 
gtk_widget_create_pango_layout() internally, including GtkLabel.


Ciao,
 Emmanuele.

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


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Get the default font in Gtk3

2018-03-29 Thread Emmanuele Bassi
On 29 March 2018 at 15:12, rastersoft  wrote:

>
> [get the Gtk font type and size]
>>>
>>> Ops, sorry: I'm reworking a backup utility that I wrote (cronopete), and
>>> I added a timeline with the backups (you can see an screenshot at
>>> http://www.rastersoft.com/cronopete_screenshot.png ). As you can see, at
>>> the left is the timeline and it has the days, months and years. I think
>>> those should use the same typography than the standard Gtk widgets, but
>>> reducing the size to 2/3. The same for the titles in each "pseudowindow"
>>> (they have a visual effect: they go forward and backwards when you move
>>> through the timeline).
>>>
>>> ...I must be missing something here...
>> You can change font size in a layout. The scrolling might be tricky, but
>> just eyeballing it, sounds like something that can be done by showing
>> the layout twice at different coords in different clips
>> (cairo_save/cairo_restore brackets).
>>
>> So...?
>>
>> (Only thing I'm not quite sure about right now is if gtk fully initializes
>> font description in a layout, cause I vaguely recall that it might
>> not... though maybe that was just wrt. theming API...)
>>
>>
> Mainly the problem is that I'm using cairo_show_text...


That's the Cairo toy text API; you should only use it for tests or small
examples; it's basically useless for anything user-facing.


> I presume that what you say is that I should replace all that with
> Pango... Now I have some problems: first, I'm using vala and I can't find
> the "get_pango_layout" from a widget. It exists "create_pango_layout", so I
> suppose that this is the call I need to create a layout.


Yes, the function is `gtk_widget_create_pango_layout()`:
https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-create-pango-layout


> Now the big question is: does ANY widget return the right layout, or I
> must use a widget designed to contain text (like a Gtk.Label) to get that
> layout, paint into it, and paste it in the final Cairo canvas (which won't
> be the same canvas than the Gtk.Label from which I created the layout)?
>

All widgets that need to render text call gtk_widget_create_pango_layout()
internally, including GtkLabel.

Ciao,
 Emmanuele.

-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Get the default font in Gtk3

2018-03-29 Thread rastersoft



[get the Gtk font type and size]

Ops, sorry: I'm reworking a backup utility that I wrote (cronopete), and
I added a timeline with the backups (you can see an screenshot at
http://www.rastersoft.com/cronopete_screenshot.png ). As you can see, at
the left is the timeline and it has the days, months and years. I think
those should use the same typography than the standard Gtk widgets, but
reducing the size to 2/3. The same for the titles in each "pseudowindow"
(they have a visual effect: they go forward and backwards when you move
through the timeline).


...I must be missing something here...
You can change font size in a layout. The scrolling might be tricky, but
just eyeballing it, sounds like something that can be done by showing
the layout twice at different coords in different clips
(cairo_save/cairo_restore brackets).

So...?

(Only thing I'm not quite sure about right now is if gtk fully initializes
font description in a layout, cause I vaguely recall that it might
not... though maybe that was just wrt. theming API...)



Mainly the problem is that I'm using cairo_show_text... I presume that 
what you say is that I should replace all that with Pango... Now I have 
some problems: first, I'm using vala and I can't find the 
"get_pango_layout" from a widget. It exists "create_pango_layout", so I 
suppose that this is the call I need to create a layout. Now the big 
question is: does ANY widget return the right layout, or I must use a 
widget designed to contain text (like a Gtk.Label) to get that layout, 
paint into it, and paste it in the final Cairo canvas (which won't be 
the same canvas than the Gtk.Label from which I created the layout)?


Thanks.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Get the default font in Gtk3

2018-03-29 Thread Rafał Mużyło
On Thu, Mar 29, 2018 at 12:58:44PM +0200, rastersoft wrote:
> Hi:
> 
> [get the Gtk font type and size]
> 
> >>> No, you seriously don't.
> >>> Unless you want to do something fancy, all you need to do would be (in
> >>>"draw" handler):
> 
> >> Well, that's the point: I want to do "something fancy". That's the
> >> problem O:)
> 
> > Describe your usecase then - my crystal ball is *still* out of order.
> > Perhaps what you think as "fancy" actually isn't.
> 
> Ops, sorry: I'm reworking a backup utility that I wrote (cronopete), and 
> I added a timeline with the backups (you can see an screenshot at 
> http://www.rastersoft.com/cronopete_screenshot.png ). As you can see, at 
> the left is the timeline and it has the days, months and years. I think 
> those should use the same typography than the standard Gtk widgets, but 
> reducing the size to 2/3. The same for the titles in each "pseudowindow" 
> (they have a visual effect: they go forward and backwards when you move 
> through the timeline).
>
...I must be missing something here...
You can change font size in a layout. The scrolling might be tricky, but
just eyeballing it, sounds like something that can be done by showing
the layout twice at different coords in different clips
(cairo_save/cairo_restore brackets).

So...?

(Only thing I'm not quite sure about right now is if gtk fully initializes
font description in a layout, cause I vaguely recall that it might
not... though maybe that was just wrt. theming API...)

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Get the default font in Gtk3

2018-03-29 Thread rastersoft

Hi:

[get the Gtk font type and size]


No, you seriously don't.
Unless you want to do something fancy, all you need to do would be (in
   "draw" handler):



Well, that's the point: I want to do "something fancy". That's the
problem O:)



Describe your usecase then - my crystal ball is *still* out of order.
Perhaps what you think as "fancy" actually isn't.


Ops, sorry: I'm reworking a backup utility that I wrote (cronopete), and 
I added a timeline with the backups (you can see an screenshot at 
http://www.rastersoft.com/cronopete_screenshot.png ). As you can see, at 
the left is the timeline and it has the days, months and years. I think 
those should use the same typography than the standard Gtk widgets, but 
reducing the size to 2/3. The same for the titles in each "pseudowindow" 
(they have a visual effect: they go forward and backwards when you move 
through the timeline).


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list