mvz / gir_ffi-gtk

GirFFI-based bindings for Gtk+. Supports both Gtk+ 2 and Gtk+ 3
GNU Lesser General Public License v2.1
19 stars 7 forks source link

Missing constants? How to proceed in this case? Example: Gtk::StyleProvider::PRIORITY_APPLICATION #105

Open rubyFeedback opened 2 years ago

rubyFeedback commented 2 years ago

Hi,

I am experimenting with gir_ffi-gtk right now.

One thing I want to get to work is CSS support. I have a lot of CSS that allows me to tweak a lot, starting this from the www era before I used ruby, and then also for ruby-gtk3 lateron.

I had this code in ruby-gtk3:

screen = Gdk::Screen.default

in gir_ffi-gtk this also works but I have to use this:

screen = Gdk::Screen.get_default

Not a big change/difference so this is fine.

I solved this issue, but now I have another problem.

In ruby-gtk3 I would use this to initialize a new style context:

::Gtk::StyleContext.add_provider_for_screen(
  screen,
  provider,
  ::Gtk::StyleProvider::PRIORITY_APPLICATION
)

But the last part, aka:

Gtk::StyleProvider::PRIORITY_APPLICATION

is not known by gir_ffi-gtk.

It is a constant.

So my next idea was to use pp:

pp ::Gtk::StyleProvider.constants.sort

But only three constants are shown via Array here:

[:GIR_FFI_BUILDER, :GIR_INFO, :G_TYPE]

No PRIORITY_APPLICATION. Perhaps the name is different or I have to use constants differently - I really don't know right now. Or perhaps there is a bug with gir_ffi-gtk so I report this here just in case. Others may also find this via a google search.

mvz commented 2 years ago

Hi @rubyFeedback, due to how these constants are defined in Gtk's introspection data, this constant is called Gtk::STYLE_PROVIDER_PRIORITY_APPLICATION.

mvz commented 2 years ago

Such constant names can be found in /usr/share/gir-1.0/Gtk-3.0.gir.