4

I'm programming a GTK Sharp (v2.12) application using Xamarin Studio 5.4 on MS Windows. The installed Mono version is 3.2.3 (but I'm using the .Net tool chain to compile, because Xamarin doesn't allow me to compile using the Mono toolchain).

The case is that when I run the application from the Xamarin Studio or using Mono, then I have a relatively nice look & feel, but when I run the application using .Net (doing double click on the executable) then the look & feel is horrible.

I've tried to trick the application to load a decent theme... but it does nothing when I do it from .Net (but when I'm using Mono then it's easy to see the changes).

This is the code I've tried but that does not work (I have a local copy of the GTK themes rc files):

// It works on Mono, but not on .Net
Gtk.Rc.Parse("Resources/GTK/windows-theme.gtkrc");

I've also tried to do:

// This does not work at all (on MS Windows)
Gtk.Settings.Default.ThemeName = "MS-Windows";

But this does not change anything, even using the Mono engine.

This is how the application looks using Mono:

enter image description here

And how it looks running under the .Net engine:

enter image description here

Thanks for your attention :) .

castarco
  • 1,368
  • 2
  • 17
  • 33

1 Answers1

4

Well, I've found the answer to my question :D .

I didn't try to load a specific GTK theme, but solved it to make .Net working properly without having to copy all the DLL files in the program directory.

I've found this thread in the Xamarin development forums:

In this thread Xamarin developers explain how they solve the dependencies loading problem. The key is to call the CheckWindowsGTK method before the Application.Init() call. The CheckWindowsGTK is defined in this file from the Monodevelop sources:

HINT: It's important to call CheckWindowsGTK only if the program is running on Windows.

Shawn South
  • 597
  • 3
  • 17
castarco
  • 1,368
  • 2
  • 17
  • 33
  • Very need your help. Can you give the code of loading of theme? Thanks! – konstantin_doncov Oct 13 '14 at 21:57
  • @user2656632 In my question i've posted two methods to load a GTK theme. I hope it will be helpful. – castarco Oct 15 '14 at 07:22
  • Yes, I already tried this. I created `CheckWindowsGTK()` function, called it before `Application.Init()` and after all this I called `Gtk.Rc.AddDefaultFile (Resource_File); Gtk.Rc.Parse (Resource_File);`.If I not use `CheckWindowsGTK()` I get some type of new gtk style, but [it is very bad](http://stackoverflow.com/questions/26349493/how-to-change-gtk-theme-in-gtk-on-windows). And if I use `CheckWindowsGTK()` I just get the default gtk theme (nothing has changed). And how I can change the theme? P. S. I use Xamarin studio, GTK#. – konstantin_doncov Oct 15 '14 at 08:29
  • As far as I can see, you correctly loaded the GTK theme, so these steps are correct. The problem appears after the GTK theme loading, when the theme is not correctly rendered because an unknown reason. Maybe what you should ask is why the theme doesn't work on Windows. Have you tried it on Linux to see if there are differences? – castarco Oct 15 '14 at 08:49