1

I am developing some Gtk based application using Vala. In my application I want to add some custom styles.

I want to retain my styles for both Gtk 3.20- and Gtk 3.20+ versions. As we are aware, Gtk3 has changed widget classes beginning from Gtk 3.20.

So, how can I check the gtk version and apply custom style accordingly? I know that, I can apply both styles together. But don't want to overload the app with unnecessary styles.

I'm looking for something like this

string style = null;
If (GTK_VERSION >= 3.20) {
    style = "window {border : none}";
} else {
    style = "GtkWindow {border : none}";
}
niyasc
  • 4,440
  • 1
  • 23
  • 50

1 Answers1

4

You can use Gtk.get_major_versoin() and Gtk.get_minor_version() for getting major and minor versions respectively.

string style = null;
if (((Gtk.get_major_version() * 100) + (Gtk.get_minor_version())) >= 320)
  style = "window {border : none}";
} else {
  style = "GtkWindow {border : none}";
}

Reference:

niyasc
  • 4,440
  • 1
  • 23
  • 50
nemequ
  • 16,623
  • 1
  • 43
  • 62