Gtk theme in GTK# (Windows)

2019-02-23 10:18发布

问题:

I'm trying to change the theme in GTK# (OS: Windows, IDE: Xamarin). But I get next issues:

  1. I was able to find only one theme which correctly render, it is "Orta". All was well, except for lags and freezes. Here is my code:

    string Resource_File = "Orta\\gtk-2.0\\gtkrc"; Application.Init (); Gtk.Rc.AddDefaultFile (Resource_File); Gtk.Rc.Parse (Resource_File); MainWindow win = new MainWindow (); win.Show (); Application.Run ();

    When I changing the size of the Paned or clicking on button I get GUI freezes(I already asked about this). This problem occurs only when using this theme, with the other themes all works tolerably. I used the search and found a couple of opinions, about that this is due to the use of Cairo to render graphics (one of them).

  2. if I try to use a different theme, a lot of GUI elements not correctly rendered in my GTK# application, but they are correctly render in the GTK Theme Selector. If the theme is displayed correctly in GTK Theme Selector, then I try to use the selected gtkrc file in my Gtk# app(as shown in Example with "Orta"), but almost always, most widgets are not displayed correctly(here is an example)

So I have a few questions:

  1. How to choose a work theme?
  2. How to set a theme for GTK# (Windows)?
  3. What Gtk# open source application using the theme and how?
  4. What other way to change the style of GUI in the GTK# app?
  5. Why "Orta" theme freezes?

So I need any your help! Thanks!

回答1:

I know it's an old question, but I've been fighting with themes lately.

It turns out that when running a Gtk# app build with Xamarin, theme issues will appear because it seems that some "Windows-like" theme is forced into the code.

When running the application from Xamarin Studio, depending on the .Net framework (Microsoft .NET 4.5, Mono 3.3.0, Mono 4.0.1) the behaviour was different. And I had a warning with Mono 3.3.0, telling me the 'Xamarin' engine could not be found.

I ended up with the following code :

Application.Init ();
Gtk.Settings.Default.ThemeName = "Theme/gtk-2.0/gtkrc";
Gtk.Rc.Parse ("./Theme/gtk-2.0/gtkrc");

Where gtkrc is my theme. Without setting the default theme name, nothing worked correctly. I didn't go very far into customizing my theme, so I can't tell if it solves every theme issue.