[Gtk-sharp-list] Embed Gtk+ theme into app

Wolfgang Silbermayr wolfgang at silbermayr.at
Wed Oct 2 07:05:30 UTC 2013


On 2013-10-01 19:05, Weston Weems wrote:
> I'd like to embed a gtk+ theme, so I can effectively skin my app and
> look the same way regardless of what default gtk+ theme is setup.
> 
> Is this something I can do? I've read people make comments of using
> resource files etc... but I have yet to hear specific details on this...
> or better yet an example.
> 
> Anyone have any pointers?

You can deploy your own gtkrc file and load the data from there:

Gtk.Application.Init();
string filename = "/the/path/to/my.gtkrc";
Gtk.Rc.Parse(filename);

or my preferred method: you include the gtkrc file as a resource inside
your assembly:

Gtk.Application.Init();
using (Stream stream =
  GetType().Assembly.GetManifestResourceStream("my.gtkrc"))
{
  using (TextReader reader = new StreamReader(stream))
  {
    Gtk.Rc.ParseString (reader.ReadToEnd());
  }
}

Hope this helps.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
URL: <http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20131002/bc9f01db/attachment.pgp>


More information about the Gtk-sharp-list mailing list