application icongmusicbrowser

no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


Previous revision
Next revision
customization:themes [2010/01/26 01:14] squentin
Line 1: Line 1:
 +A few notes to explain how to theme gmusicbrowser using customs gtk themes. \\
 +Feel free to improve this page.
 +
 +First you need to have some knowledge about how gtk themes works, [[http://library.gnome.org/devel/gtk/2.14/gtk-Resource-Files.html|this page have all the technical details]], but there is also some [[http://www.google.com/search?q=gtk+theme+tutorial|tutorials]].
 +
 +To launch gmusicbrowser with a custom gtkrc file, you can type this :
 +<code>GTK2_RC_FILES=gtkrc gmusicbrowser</code>
 +replace gtkrc by the full or relative path and filename.
 +
 +To help finding the path of widgets you want to theme, I've added some functions to my Debug.pm plugin, you can find it [[/gmusicbrowser/debug.pm|there]] (put it in ''~/.config/gmusicbrowser/plugins/'').
 +Note that some things will not work with version older than 1.0.2 (widget names and the WB container).
 +
 +
 +Example of what you can put in a gtkrc file :
 +<code>
 +style "test"
 +{      bg[NORMAL]   = "#000000"
 +       fg[NORMAL]   = "#ffffff"
 +       base[NORMAL] = "#000000"
 +       text[NORMAL] = "#ffffff"
 +}
 +
 +widget_class "*" style "test"
 +</code>
 +This define the style "test", the style simply defines the 4 colors bg, fg, base, and text in the "NORMAL" state. Widgets use some or all of these colors to draw themselves. A widget can be in 5 states : NORMAL, ACTIVE, PRELIGHT, SELECTED and INSENSITIVE.
 +
 +The theme is applied to all widgets which class_path match "*", that is all widgets.
 +The class_path is a string made of the class name of all widget and all of its parents, joined by a period ".", the character "*" match 0 or more characters.
 +
 +For example, the "Total" gmb widget is made up of a gtkbutton containing a gtklabel. In the Browser layout the gtk_label of Total has this class_path : ''GtkWindow.SVBox.SHBox.GtkButton.GtkLabel''
 +So to apply the style "test" to only the gtklabel of the Total widget, you would have to use :
 +<code>
 +widget_class "GtkWindow.SVBox.SHBox.GtkButton.GtkLabel" style "test"
 +</code>
 +
 +But, this has a few problems :
 +  - the class path is very generic and is likely to match another widget. So I've made gmusicbrowser give names to some of the gtk widgets. The windows have the name of the layout id, and the toplevel gtk widgets of gmb widgets get the name of the gmb widget. So for example, with the "Total" widget in the Browser layout, its path becomes : ''Browser.VBmain.HBstatus.Total.GtkLabel''
 +  - the "Total"'s gtkbutton is set to use the relief 'none', which means that the button part is not drawn when in NORMAL state, so the background of the button is drawn by its parents. And as HBoxes and VBoxes do not draw anything either, the background of the button in NORMAL state is drawn by the gtkwindow. So I've added a new Container in gmb : WB, W because its purpose is to have its own gdkWindow, not a very good name, but the namespace is getting more crowded than anticipated. It's actually an gtk_eventbox.
 +  - the composition of gmb widgets could change in the future, that, sadly, will always be a possibility, making good use of "*" helps a bit.
 +
 +So by modifying the Browser layout like this :
 +  - replace Total by WBTotal
 +  - WBTotal = Total
 +the path of "Total"'s gtklabel becomes :  ''Browser.VBmain.HBstatus.WBTotal.Total.GtkLabel'' \\
 +And with a gtkrc of :
 +<code>
 +style "test" = "theme-default"
 +{      bg[NORMAL]   = "#000000"
 +       fg[NORMAL]   = "#ffffff"
 +       base[NORMAL] = "#000000"
 +       text[NORMAL] = "#ffffff"
 +}
 +
 +widget "Browser.*WBTotal*" style "test"
 +</code>
 +Note that this time it uses "widget" instead of "widget_class" to match against the path of the widget instead of its class_path.
 +The style "test" is applied to all gtk widgets named WBTotal and their children, only in a the "Browser" Layout. And the background of the button is black in NORMAL state.
 +
  
customization/themes.txt · Last modified: 2022/05/23 01:30 by 127.0.0.1
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0