How can I use CSS styling in my GTK# application?


Tags: css,mono,gtk,gtk#,banshee

Problem :

How can I use CSS styling in my GTK# application? I heard before that it is impossible to use CSS themes in GTK#, but after that I found this example of using css styling in GTK#. Besides this I found also the samples of using CSS styling in Banshee project (which uses GTK#). So how is it possible? I already tried to do the same in GTK#, but I didn't find CssProvider class. So how I can find this class in GTK# or how I can using CSS styling in GTK#?



Solution :

CSS Styling is a GTK3 feature.

GTK# for GTK3 is not released as stable yet.

Xamarin (the main force behind mono) have publicly announced that their product (Xamarin Studio/Mono Develop) will not be moving to GTK3. This means that GTK3 support must come from the community and as a result has been very slow in coming.

It is likely that you cannot find the CssProvider class because you are using the GTK2 bindings not the GTK3 bindings.

If you would like to try the beta GTK3 csharp bindings then you can find them here: https://github.com/mono/gtk-sharp/releases

Because Xamarin Studio will not work with GTK3 I would recommend either:

  • Compiling GTK# yourself such that Xamarin Studio can continue to run on the installed GTK2 bindings.
  • Use Visual Studio which has no dependency on GTK#

    CSS Howto..

    How to use sprite image in css?

    How can I hide a button when scrolled to the top of a page?

    How to get H1 content the same height in Firefox and in IE8?

    How to cancel an upstream CSS declaration?

    How can I make DIV 100% height of browser without vertical scrolling of header

    How can I truncate long texts in a table using CSS?

    how i center div elements horizontally in css?

    How can I tell if a particular CSS property is inherited with jQuery?

    How can I center a graphic under a
      -based nav menu?

    How to apply CSS to a Mac Chrome Select Box?

    How to create a card flip effect on DIV using javascript

    how can we use and control Gradient

    how to prevent transformation of text inherited from a skewed parent

    How to change the css and html file at the same time

    How to completely fill screen with smaller elements?

    How can I use Font Awesome (or other font icons) instead of the jQuery sprites in Primefaces DataTable?

    How to create CSS internal style sheet in CakePHP

    css and basket: how to do an “always visible” basket?

    how to create a css attribute swapper between two elements?

    How to CSS border spacing (or) padding background image separately?

    How to remove an invisible space between div tags

    How can I disable the “Up” arrow via CSS

    How to add text to different parts of chart made from css, html, and javascript?

    CSS: how can I force a long string (without any blank) to be wrapped in XUL and/or HTML

    How I write a:hover::before in less file?

    gwt - How to CSS reset a GWT app?

    How to get css height property of an object and add 20px to it?

    How do I override css for a particular control? [closed]

    how can I apply a CSS stylesheet to all page views in my Firefox browser

    How to encapsulate CSS, especially for popups and no iframe involved?