[Gtk-sharp-list] How to change theme settings?

Anset mono at anset.org
Fri Nov 24 05:51:49 EST 2006


Hi,

Sorry of my reply is not what you are looking for, I did not read the 
previous emails in this thread.

If you want to use a specific theme just for your application and not 
change the users' default theme then you must write your own resource 
file and in your program do something like:


private void Init_Global_Resource_File() {
   // make Sure the Resource file is Read!
   if (System.IO.File.Exists(Resource_File)) {
     Gtk.Rc.AddDefaultFile(Resource_File);
     Gtk.Rc.Parse(Resource_File);
   } else {
     Console.WriteLine("THE RESOURCE FILE " + _config.Resource_File + " 
COULD NOT BE READ!");
   }
}

Here is an example of a piece of a resource file:


##################
# Startup Dialog #
##################

style "Startup_Dialog_Title_Style"
{
         font_name  = "Times new Roman Bold 12"
         fg[NORMAL] = "#000000"

}
widget "*.Startup_Dialog_Title" style "Startup_Dialog_Title_Style"

style "Startup_Dialog_Title_Bg_Style"
{
         bg_pixmap[NORMAL] = ""
         bg[NORMAL] = "#cccccc"
}
widget "*.Startup_Dialog_Title_Bg"      style 
"Startup_Dialog_Title_Bg_Style"

##########################
# Main Window Tab Labels #
##########################
# Menu_nb_Inventory_Label
# Menu_nb_Army_Builder_Label
# Menu_nb_Config_Label

style "Menu_nb_tab_Style"
{
         font_name  = "Times new Roman Bold 12"
}

widget "*.Menu_nb_Inventory_Label"              style "Menu_nb_tab_Style"
widget "*.Menu_nb_Army_Builder_Label"   style "Menu_nb_tab_Style"
widget "*.Menu_nb_Config_Label"         style "Menu_nb_tab_Style"


Read up on GTK resource files if you need more.

You can also specify the resource text in your program and parse the 
string, but that makes it difficult to give your users a choice of themes.

wkr,

Anset

David Philippi wrote:
> Am Freitag 24 November 2006 00:05 schrieben Sie:
>> There is an application that ships with the Mono Installer for Windows
>> as well as with the Gtk# Installer for .NET that allows you to change
>> the default Windows theme that is the culprit of you not seeing your
>> icons on the buttons of your app.  In a worst case scenario you could to
>> %GTK_BASEPATH%\etc\gtk-2.0\gtkrc file and remove the line that specifies
>> the theme.
> 
> If found that application and changing the theme does indeed give me the icons 
> back. But if I want to convey meaning through the icons in a button I can't 
> very well tell everyone to change their default theme. From what I gathered 
> it should be possible to change this from within my application through an 
> API call but gtk# simply doesn't provide it. If this information is correct 
> I'd like to know wheter there's a reasoning behind it. I for one would be 
> much happier if I could use some API from within my application to change it 
> just for this program. It's obvious that one shouldn't change the theme 
> settings done by the user lightly but if it's required for an application it 
> should be possible. If I do it without good reason people might be annoyed 
> with the program and use something else but that'd be my problem alone. I 
> can't see any reason why gtk# shouldn't offer me this possibility except that 
> nobody had the time and need to code those API calls yet. In this case I can 
> only hope that this changes soon and exploit workarounds.
> 
> Bye David
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list



More information about the Gtk-sharp-list mailing list