Blame doc/theme-format.txt

Packit 5e0819
Themes are in a simple XML-subset format. There are multiple versions
Packit 5e0819
of the theme format, and a given theme can support more than one format.
Packit 5e0819
Packit 5e0819
Version 1:     THEMEDIR/metacity-1/metacity-theme-1.xml
Packit 5e0819
  (original metacity format)
Packit 5e0819
Version 2:     THEMEDIR/metacity-1/metacity-theme-2.xml
Packit 5e0819
Version 3:     THEMEDIR/metacity-1/metacity-theme-3.xml
Packit 5e0819
Packit 5e0819
The subdirectory name is "metacity-1" in all versions.
Packit 5e0819
Packit 5e0819
As you might expect, older versions of metacity will not understand
Packit 5e0819
newer theme formats. However, newer versions will use old themes.
Packit 5e0819
Metacity will always use the newest theme format it understands that
Packit 5e0819
the X server supports. Some format versions are only supported if you
Packit 5e0819
have the right X server features.
Packit 5e0819
Packit 5e0819
Each format *requires* the corresponding filename. If you put version
Packit 5e0819
2 format features in the metacity-1/metacity-theme-1.xml file, then
Packit 5e0819
metacity will get angry.
Packit 5e0819
Packit 5e0819
This document has separate sections for each format version. You may
Packit 5e0819
want to read the document in reverse order, since the base features
Packit 5e0819
are discussed under version 1.
Packit 5e0819
Packit 5e0819
New Features in Theme Format Version 3.5
Packit 5e0819
========================================
Packit 5e0819
Packit 5e0819
Add support for app-menu button in window decorations. This was only
Packit 5e0819
used by Mutter and here is only to support this Theme Format Version.
Packit 5e0819
Packit 5e0819
New Features in Theme Format Version 3.4
Packit 5e0819
========================================
Packit 5e0819
Packit 5e0819
An additional color type is added to pick up custom colors defined
Packit 5e0819
in the GTK+ theme's CSS:
Packit 5e0819
Packit 5e0819
  gtk:custom(name,fallback)
Packit 5e0819
Packit 5e0819
where <name> refers to a custom color defined with @define-color in
Packit 5e0819
the GTK+ theme, and <fallback> provides an alternative color definition
Packit 5e0819
in case the color referenced by <name> is not found.
Packit 5e0819
Packit 5e0819
New Features in Theme Format Version 3.3
Packit 5e0819
========================================
Packit 5e0819
Packit 5e0819
Add two additional button background functions - left_single_background and
Packit 5e0819
right_single_background - for button groups with just a single button.
Packit 5e0819
Packit 5e0819
There are now additional frame states to style left/right tiled windows
Packit 5e0819
differently ("tiled_left", "tiled_right", "tiled_left_and_shaded",
Packit 5e0819
"tiled_right_and_shaded")
Packit 5e0819
Packit 5e0819
New Features in Theme Format Version 3.2
Packit 5e0819
========================================
Packit 5e0819
Packit 5e0819
A new window type 'attached' is added for modal dialogs which are
Packit 5e0819
attached to their parent window. (When the attach_modal_dialogs preference
Packit 5e0819
is turned on.) If no style is defined for the 'attached' window type,
Packit 5e0819
the 'border' window type will be used instead.
Packit 5e0819
Packit 5e0819
New Features in Theme Format Version 3.1
Packit 5e0819
========================================
Packit 5e0819
Packit 5e0819
Additional predefined variables are added for positioning expressions:
Packit 5e0819
Packit 5e0819
  frame_x_center: the X center of the entire frame, with respect to the
Packit 5e0819
      piece currently being drawn.
Packit 5e0819
  frame_y_center: the Y center of the entire frame, with respect to the
Packit 5e0819
      piece currently being drawn.
Packit 5e0819
Packit 5e0819
The <title/> element now supports an "ellipsize_width" attribute. When
Packit 5e0819
specified, this gives a width at which to ellipsize the title. If not
Packit 5e0819
specified, the title will simply be clipped to the title area.
Packit 5e0819
Packit 5e0819
New Features in Theme Format Version 3
Packit 5e0819
======================================
Packit 5e0819
Packit 5e0819
Format version 3 has exactly one new feature; any element in the file
Packit 5e0819
can now have a version attribute:
Packit 5e0819
Packit 5e0819
  version="[<|<=|=>|>] MAJOR.MINOR"
Packit 5e0819
Packit 5e0819
(< and > should be to be entity escaped as < and >). If this
Packit 5e0819
version check is not met, then the element and its children will be
Packit 5e0819
ignored. This allows having alternate sections of the theme file for
Packit 5e0819
older and newer version of the Metacity theme format.
Packit 5e0819
Packit 5e0819
When placed on the toplevel <metacity_theme> element, an unsatisfied
Packit 5e0819
version check will not just cause the contents of the file to be
Packit 5e0819
ignored, it will also cause the lookup of a theme file to proceed on
Packit 5e0819
and look for an older format 2 or format 1 file. This allows making a
Packit 5e0819
metacity-theme-3.xml file that is only used the format version 3.2 or
Packit 5e0819
newer is supported, and using metacity-theme-1.xml for older window
Packit 5e0819
managers.
Packit 5e0819
Packit 5e0819
New Features in Theme Format Version 2
Packit 5e0819
======================================
Packit 5e0819
Packit 5e0819
The optional attributes rounded_top_left, rounded_top_right,
Packit 5e0819
rounded_bottom_left and rounded_bottom_right on <frame_geometry>
Packit 5e0819
should now be the radius of the corner in pixels. You may still use
Packit 5e0819
the values "false" for 0 and "true" for 5, which means v1 values will
Packit 5e0819
still work just fine.
Packit 5e0819
Packit 5e0819
<frame_geometry> has a new optional attribute, hide_buttons. If this
Packit 5e0819
is true, no buttons will be displayed on the titlebar.
Packit 5e0819
Packit 5e0819
Anywhere you can use a positive integer, you can use an integer constant.
Packit 5e0819
Packit 5e0819
As well as constant integers and reals, you may define constant colours,
Packit 5e0819
thus:
Packit 5e0819
  <constant name="RevoltingPink" value="#FF00FF"/>
Packit 5e0819
  <constant name="Background" value="gtk:bg[NORMAL]"/>
Packit 5e0819
Packit 5e0819
<frame_style> has two new optional attributes, background and alpha.
Packit 5e0819
If you specify alpha, you must specify background. background is a
Packit 5e0819
colour used for the background of the frame. alpha is the transparency
Packit 5e0819
as a real between 0.0 and 1.0. If the current X server does not support
Packit 5e0819
alpha channels, the value is ignored.
Packit 5e0819
Packit 5e0819
The filename attribute of <image> may begin with "theme:". If so, the
Packit 5e0819
rest of the string is the name of a theme icon. The 64x64 version of the
Packit 5e0819
icon is used, except for fallback mini_icons, which use the 16x16 version.
Packit 5e0819
This does not affect ordinary resizing. For example:
Packit 5e0819
  <button function="close" state="normal">
Packit 5e0819
    <draw_ops>
Packit 5e0819
      <include name="active_button"/>
Packit 5e0819
      
Packit 5e0819
          width="width-4" height="height-4"/>
Packit 5e0819
      
Packit 5e0819
    </draw_ops>
Packit 5e0819
  </button>
Packit 5e0819
Packit 5e0819
<menu_icon>s are parsed but ignored.
Packit 5e0819
Packit 5e0819
Fallback icons can be specified using <fallback>. There are two
Packit 5e0819
optional arguments, icon and mini_icon. The values of these arguments
Packit 5e0819
are identical to that of the filename attribute of <image>. Fallback
Packit 5e0819
icons are used when a window does not supply its own icon. If a fallback
Packit 5e0819
icon is not specified with <fallback>, Metacity will use a built-in
Packit 5e0819
icon, as in metacity-theme-1.
Packit 5e0819
Packit 5e0819
The <arc> element, as well as the original start_angle and end_angle
Packit 5e0819
attributes, may be given from and to attributes. The values of these
Packit 5e0819
attributes are given in degrees clockwise, with 0 being straight up.
Packit 5e0819
For example:
Packit 5e0819
  
Packit 5e0819
      x="0" y="5" width="15" height="15"/>
Packit 5e0819
Packit 5e0819
<frame state="shaded"> may now take an optional resize attribute, with
Packit 5e0819
the same interpretation as the resize attribute on <frame state="normal">.
Packit 5e0819
If this attribute is omitted for state="shaded", it defaults to "both".
Packit 5e0819
(If it is omitted for state="normal", it remains an error.)
Packit 5e0819
Packit 5e0819
In addition to the four <button> functions which are required in
Packit 5e0819
metacity-theme-1, there are six new functions in metacity-theme-2:
Packit 5e0819
shade, unshade, above, unabove, stick and unstick.
Packit 5e0819
      
Packit 5e0819
Overview of Theme Format Version 1
Packit 5e0819
==================================
Packit 5e0819
Packit 5e0819
Packit 5e0819
<metacity_theme>
Packit 5e0819
Packit 5e0819
<info>
Packit 5e0819
  <name>Foo</name>
Packit 5e0819
  <author>Foo P. Bar</author>
Packit 5e0819
  <copyright>whoever, 2002</copyright>
Packit 5e0819
  <date>Jan 31 2005</date>
Packit 5e0819
  <description>A sentence about the theme.</description>
Packit 5e0819
</info>
Packit 5e0819
Packit 5e0819
Packit 5e0819
Packit 5e0819
     determines whether the title text height is included in the 
Packit 5e0819
     height calculation. if not specified, defaults to true.
Packit 5e0819
     It also has an optional text_size="medium" attribute
Packit 5e0819
     (same sizes as with Pango markup, xx-small thru medium thru
Packit 5e0819
     xx-large) 
Packit 5e0819
Packit 5e0819
     Finally it has optional args rounded_top_left=true, 
Packit 5e0819
     rounded_top_right=true, rounded_bottom_left=true,
Packit 5e0819
     rounded_bottom_right=true.
Packit 5e0819
Packit 5e0819
     -->
Packit 5e0819
<frame_geometry name="normal" has_title="true" title_scale="medium">
Packit 5e0819
  <distance name="left_width" value="6"/>
Packit 5e0819
  <distance name="right_width" value="6"/>
Packit 5e0819
  <distance name="bottom_height" value="7"/>
Packit 5e0819
  <distance name="left_titlebar_edge" value="6"/>
Packit 5e0819
  <distance name="right_titlebar_edge" value="6"/>
Packit 5e0819
  <distance name="button_width" value="17"/>
Packit 5e0819
  <distance name="button_height" value="17"/>
Packit 5e0819
  
Packit 5e0819
  <aspect_ratio name="button" value="1.0"/>
Packit 5e0819
  <distance name="title_vertical_pad" value="4"/>
Packit 5e0819
  <border name="title_border" left="3" right="12" top="4" bottom="3"/>
Packit 5e0819
  <border name="button_border" left="0" right="0" top="1" bottom="1"/>
Packit 5e0819
</frame_geometry>
Packit 5e0819
Packit 5e0819
Packit 5e0819
<frame_geometry name="borderless" parent="normal">
Packit 5e0819
  <distance name="left_width" value="0"/>
Packit 5e0819
  <distance name="right_width" value="0"/>
Packit 5e0819
  <distance name="bottom_height" value="0"/>
Packit 5e0819
  <distance name="left_titlebar_edge" value="0"/>
Packit 5e0819
  <distance name="right_titlebar_edge" value="0"/>
Packit 5e0819
</frame_geometry>
Packit 5e0819
Packit 5e0819
Packit 5e0819
     constant names must start with a capital letter.
Packit 5e0819
  -->
Packit 5e0819
<constant name="LineOffset" value="3"/>
Packit 5e0819
Packit 5e0819
Packit 5e0819
     these draw-op lists can also be placed inline. 
Packit 5e0819
Packit 5e0819
     Positions/lengths are given as expressions.
Packit 5e0819
     Operators are: +,-,*,/,%,`max`,`min`
Packit 5e0819
     All operators are infix including `max` and `min`, 
Packit 5e0819
      i.e. "2 `max` 5"
Packit 5e0819
     
Packit 5e0819
     Some variables are predefined, and constants can also 
Packit 5e0819
     be used. Variables are:
Packit 5e0819
Packit 5e0819
       width - width of target area
Packit 5e0819
       height - height of target area
Packit 5e0819
       object_width - natural width of object being drawn
Packit 5e0819
       object_height - natural height of object being drawn
Packit 5e0819
       left_width - distance from left of frame to client window
Packit 5e0819
       right_width - distance from right of frame to client window
Packit 5e0819
       top_height - distance from top of frame to client window
Packit 5e0819
       bottom_height - distance from bottom of frame to client window
Packit 5e0819
       mini_icon_width - width of mini icon for window
Packit 5e0819
       mini_icon_height - height of mini icon
Packit 5e0819
       icon_width - width of large icon
Packit 5e0819
       icon_height - height of large icon
Packit 5e0819
       title_width - width of title text
Packit 5e0819
       title_height - height of title text
Packit 5e0819
Packit 5e0819
    All these are always defined, except object_width/object_height 
Packit 5e0819
    which only exists for <image> right now.
Packit 5e0819
Packit 5e0819
  -->
Packit 5e0819
Packit 5e0819
<draw_ops name="demo_all_ops">
Packit 5e0819
  <line color="#00FF00" x1="LineOffset" y1="0" x2="0" y2="height"/>
Packit 5e0819
  
Packit 5e0819
        x1="width - 1" y1="0" x2="width - 1" y2="height" 
Packit 5e0819
        width="3" dash_on_length="2" dash_off_length="3"/>
Packit 5e0819
  
Packit 5e0819
             x="0" y="0" width="width - 1" height="height - 1" filled="true"/>
Packit 5e0819
  
Packit 5e0819
       filled="false" start_angle="30" extent_angle="180"/>
Packit 5e0819
  <tint color="orange" alpha="0.5" x="0" y="0" width="width" height="height"/>
Packit 5e0819
 
Packit 5e0819
  
Packit 5e0819
            x="10" y="30" width="width / 3" height="height / 4">
Packit 5e0819
    
Packit 5e0819
         a color name like "blue" (look at gcolorsel), a hex color
Packit 5e0819
         as in HTML (#FFBB99), or a color from the gtk theme 
Packit 5e0819
         given as "gtk:base[NORMAL]", "gtk:fg[ACTIVE]", etc.
Packit 5e0819
       -->
Packit 5e0819
    <color value="gtk:fg[SELECTED]"/>
Packit 5e0819
    
Packit 5e0819
    <color value="blend/gtk:bg[SELECTED]/gtk:fg[SELECTED]/0.5"/>
Packit 5e0819
  </gradient>
Packit 5e0819
  
Packit 5e0819
       image a certain color -->
Packit 5e0819
  
Packit 5e0819
         x="10" y="30" width="width / 3" height="height / 4"/>
Packit 5e0819
  
Packit 5e0819
             filled="true"
Packit 5e0819
             x="2" y="2" width="width - 4" height="height - 4"/>
Packit 5e0819
  
Packit 5e0819
           x="2" y="2" width="width - 4" height="height - 4"/>
Packit 5e0819
  <gtk_vline state="normal" x="2" y1="0" y2="height"/>
Packit 5e0819
  
Packit 5e0819
  
Packit 5e0819
        x="10" y="30" width="width / 3" height="height / 4"/>
Packit 5e0819
  
Packit 5e0819
  <title color="gtk:text[NORMAL]" x="20" y="30"/>
Packit 5e0819
  
Packit 5e0819
  <include name="some_other_draw_ops"/>
Packit 5e0819
  
Packit 5e0819
       x/y/width/height/tile_xoffset/tile_yoffset -->
Packit 5e0819
  <tile name="some_other_draw_ops" tile_width="10" tile_height="10"/>
Packit 5e0819
</draw_ops>
Packit 5e0819
Packit 5e0819
<frame_style name="normal" geometry="normal">
Packit 5e0819
  
Packit 5e0819
       For each piece, a draw_ops can be given inline or referenced 
Packit 5e0819
       by name. If a piece is omitted, then nothing will be drawn 
Packit 5e0819
       for that piece.
Packit 5e0819
Packit 5e0819
       For each piece, the "width" and "height" variables in 
Packit 5e0819
       coordinate expressions refers to the dimensions of the piece, 
Packit 5e0819
       the origin is at the top left of the piece.
Packit 5e0819
  
Packit 5e0819
       So <rectangle x="0" y="0" width="width-1" height="height-1"/>
Packit 5e0819
       will outline a piece.
Packit 5e0819
    -->
Packit 5e0819
Packit 5e0819
  <piece position="entire_background" draw_ops="demo_all_ops"/>
Packit 5e0819
  <piece position="left_titlebar_edge">
Packit 5e0819
    <draw_ops>
Packit 5e0819
      <line color="#00FF00" x1="0" y1="0" x2="0" y2="height"/>
Packit 5e0819
    </draw_ops>
Packit 5e0819
  </piece>
Packit 5e0819
Packit 5e0819
  
Packit 5e0819
Packit 5e0819
       entire_background: whole frame
Packit 5e0819
       titlebar: entire area above the app's window 
Packit 5e0819
       titlebar_middle: area of titlebar_background not considered
Packit 5e0819
                        part of an edge
Packit 5e0819
       left_titlebar_edge: left side of titlebar background
Packit 5e0819
       right_titlebar_edge: right side of titlebar background
Packit 5e0819
       top_titlebar_edge: top side of titlebar background
Packit 5e0819
       bottom_titlebar_edge: bottom side of titlebar background 
Packit 5e0819
       title: the title area (doesn't include buttons)
Packit 5e0819
       left_edge: left edge of the frame
Packit 5e0819
       right_edge: right edge of the frame
Packit 5e0819
       bottom_edge: bottom edge of the frame
Packit 5e0819
       overlay: same area as entire_background, but drawn after 
Packit 5e0819
                drawing all sub-pieces instead of before
Packit 5e0819
Packit 5e0819
   -->
Packit 5e0819
Packit 5e0819
  
Packit 5e0819
       each of three states: 
Packit 5e0819
          normal, pressed, prelight
Packit 5e0819
       and the button function or position must be provided:
Packit 5e0819
          close, maximize, minimize, menu, 
Packit 5e0819
          left_left_background, left_middle_background,
Packit 5e0819
          left_right_background, right_left_background, 
Packit 5e0819
          right_middle_background, right_right_background
Packit 5e0819
       So a working theme needs 3*4 = 12 button declarations
Packit 5e0819
       and a theme may have up to 3*10 = 30 button declarations
Packit 5e0819
       in order to handle button-rearrangement preferences.
Packit 5e0819
 
Packit 5e0819
       (The name "function" for the attribute is from before the 
Packit 5e0819
        background values existed.)
Packit 5e0819
    -->
Packit 5e0819
Packit 5e0819
  <button function="close" state="normal" draw_ops="previously_named"/>
Packit 5e0819
  <button function="menu" state="normal">
Packit 5e0819
    <draw_ops>
Packit 5e0819
      
Packit 5e0819
            x="0" y="0" width="object_width" height="object_height"/>
Packit 5e0819
    </draw_ops>
Packit 5e0819
  </button>
Packit 5e0819
Packit 5e0819
</frame_style>
Packit 5e0819
Packit 5e0819
Packit 5e0819
     In a subclass anything can be re-specified to override 
Packit 5e0819
     the parent style. -->
Packit 5e0819
<frame_style name="focused" parent="normal">
Packit 5e0819
  <piece position="title">
Packit 5e0819
    <draw_ops>
Packit 5e0819
      
Packit 5e0819
                 x="0" y="0" width="width-1" height="height-1"/>
Packit 5e0819
      
Packit 5e0819
                                      y="(height - title_height) / 2"/>
Packit 5e0819
    </draw_ops>
Packit 5e0819
  </piece>
Packit 5e0819
</frame_style>
Packit 5e0819
Packit 5e0819
Packit 5e0819
Packit 5e0819
     Focus: yes (focused), no (not focused)
Packit 5e0819
     Window states: normal, maximized, shaded, maximized_and_shaded
Packit 5e0819
     Window resizability: none, vertical, horizontal, both
Packit 5e0819
Packit 5e0819
     Everything unspecified just does the same as
Packit 5e0819
     unfocused/normal/both.
Packit 5e0819
Packit 5e0819
     only state="normal" needs a resize="" attribute.
Packit 5e0819
 -->
Packit 5e0819
<frame_style_set name="normal">
Packit 5e0819
<frame focus="yes" state="normal" resize="both" style="focused"/>
Packit 5e0819
<frame focus="no" state="normal" resize="both" style="normal"/>
Packit 5e0819
</frame_style_set>
Packit 5e0819
Packit 5e0819
Packit 5e0819
     Types: normal, dialog, modal_dialog, menu, utility, border
Packit 5e0819
  -->
Packit 5e0819
<window type="normal" style_set="normal"/>
Packit 5e0819
Packit 5e0819
Packit 5e0819
Packit 5e0819
     four types as the buttons, and GTK states
Packit 5e0819
     (insensitive,prelight,normal,etc.)
Packit 5e0819
  -->
Packit 5e0819
Packit 5e0819
<menu_icon function="close" state="normal" draw_ops="previously_named"/>
Packit 5e0819
Packit 5e0819
Packit 5e0819
</metacity_theme>
Packit 5e0819
Packit 5e0819