Remove all support for the metacity format

Rest in peace you magnificent format, love-child of arcane X11 drawing
API and markup craze, you will not be missed.
We do remember however the bravery of a many men and women, who fearlessly
descended into the guts of your intrinsics and turned ugliness into beauty;
their work will still be spoken of when you will long have been forgotten.

https://bugzilla.gnome.org/show_bug.cgi?id=741917
This commit is contained in:
Florian Müllner 2014-09-24 01:09:09 +02:00 committed by Jasper St. Pierre
parent 662dd6a289
commit 5e9db422c9
10 changed files with 24 additions and 10196 deletions

View File

@ -22,7 +22,6 @@
<title>Mutter Core Reference</title>
<xi:include href="xml/main.xml"/>
<xi:include href="xml/common.xml"/>
<xi:include href="xml/gradient.xml"/>
<xi:include href="xml/prefs.xml"/>
<xi:include href="xml/util.xml"/>
<xi:include href="xml/errors.xml"/>

View File

@ -172,15 +172,6 @@ meta_error_trap_push_with_return
meta_error_trap_pop_with_return
</SECTION>
<SECTION>
<FILE>gradient</FILE>
MetaGradientType
meta_gradient_create_simple
meta_gradient_create_multi
meta_gradient_create_interwoven
meta_gradient_add_alpha
</SECTION>
<SECTION>
<FILE>group</FILE>
MetaGroup

View File

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

View File

@ -200,7 +200,6 @@ libmutter_la_SOURCES = \
ui/frames.h \
ui/resizepopup.c \
ui/resizepopup.h \
ui/theme-parser.c \
ui/theme.c \
meta/theme.h \
ui/theme-private.h \

View File

@ -82,7 +82,6 @@ static GDesktopFocusNewWindows focus_new_windows = G_DESKTOP_FOCUS_NEW_WINDOWS_S
static gboolean raise_on_click = TRUE;
static gboolean center_new_windows = FALSE;
static gboolean attach_modal_dialogs = FALSE;
static char* current_theme = NULL;
static int num_workspaces = 4;
static GDesktopTitlebarAction action_double_click_titlebar = G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE;
static GDesktopTitlebarAction action_middle_click_titlebar = G_DESKTOP_TITLEBAR_ACTION_LOWER;
@ -144,7 +143,6 @@ static void queue_changed (MetaPreference pref);
static void maybe_give_disable_workarounds_warning (void);
static gboolean titlebar_handler (GVariant*, gpointer*, gpointer);
static gboolean theme_name_handler (GVariant*, gpointer*, gpointer);
static gboolean mouse_button_mods_handler (GVariant*, gpointer*, gpointer);
static gboolean button_layout_handler (GVariant*, gpointer*, gpointer);
static gboolean overlay_key_handler (GVariant*, gpointer*, gpointer);
@ -401,14 +399,6 @@ static MetaStringPreference preferences_string[] =
mouse_button_mods_handler,
NULL,
},
{
{ "theme",
SCHEMA_GENERAL,
META_PREF_THEME,
},
theme_name_handler,
NULL,
},
{
{ KEY_TITLEBAR_FONT,
SCHEMA_GENERAL,
@ -1309,12 +1299,6 @@ meta_prefs_get_show_fallback_app_menu (void)
return show_fallback_app_menu;
}
const char*
meta_prefs_get_theme (void)
{
return current_theme;
}
const char*
meta_prefs_get_cursor_theme (void)
{
@ -1371,29 +1355,6 @@ titlebar_handler (GVariant *value,
return TRUE;
}
static gboolean
theme_name_handler (GVariant *value,
gpointer *result,
gpointer data)
{
const gchar *string_value;
*result = NULL; /* ignored */
string_value = g_variant_get_string (value, NULL);
if (!string_value || !*string_value)
return FALSE;
if (g_strcmp0 (current_theme, string_value) != 0)
{
g_free (current_theme);
current_theme = g_strdup (string_value);
queue_changed (META_PREF_THEME);
}
return TRUE;
}
static gboolean
mouse_button_mods_handler (GVariant *value,
gpointer *result,
@ -1818,9 +1779,6 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_RAISE_ON_CLICK:
return "RAISE_ON_CLICK";
case META_PREF_THEME:
return "THEME";
case META_PREF_TITLEBAR_FONT:
return "TITLEBAR_FONT";

View File

@ -43,7 +43,6 @@
* @META_PREF_AUTO_RAISE: auto-raise
* @META_PREF_AUTO_RAISE_DELAY: auto-raise delay
* @META_PREF_FOCUS_CHANGE_ON_POINTER_REST: focus change on pointer rest
* @META_PREF_THEME: theme
* @META_PREF_TITLEBAR_FONT: title-bar font
* @META_PREF_NUM_WORKSPACES: number of workspaces
* @META_PREF_DYNAMIC_WORKSPACES: dynamic workspaces
@ -81,7 +80,6 @@ typedef enum
META_PREF_AUTO_RAISE,
META_PREF_AUTO_RAISE_DELAY,
META_PREF_FOCUS_CHANGE_ON_POINTER_REST,
META_PREF_THEME,
META_PREF_TITLEBAR_FONT,
META_PREF_NUM_WORKSPACES,
META_PREF_DYNAMIC_WORKSPACES,
@ -128,7 +126,6 @@ GDesktopFocusMode meta_prefs_get_focus_mode (void);
GDesktopFocusNewWindows meta_prefs_get_focus_new_windows (void);
gboolean meta_prefs_get_attach_modal_dialogs (void);
gboolean meta_prefs_get_raise_on_click (void);
const char* meta_prefs_get_theme (void);
/* returns NULL if GTK default should be used */
const PangoFontDescription* meta_prefs_get_titlebar_font (void);
int meta_prefs_get_num_workspaces (void);

View File

@ -34,10 +34,4 @@ MetaTheme* meta_theme_get_default (void);
MetaTheme* meta_theme_new (void);
void meta_theme_free (MetaTheme *theme);
gboolean meta_theme_validate (MetaTheme *theme,
GError **error);
MetaTheme* meta_theme_load (const char *theme_name,
GError **err);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -42,31 +42,6 @@ typedef struct _MetaFrameStyle MetaFrameStyle;
*
*/
typedef struct _MetaFrameStyleSet MetaFrameStyleSet;
/**
* MetaDrawOp: (skip)
*
*/
typedef struct _MetaDrawOp MetaDrawOp;
/**
* MetaDrawOpList: (skip)
*
*/
typedef struct _MetaDrawOpList MetaDrawOpList;
/**
* MetaGradientSpec: (skip)
*
*/
typedef struct _MetaGradientSpec MetaGradientSpec;
/**
* MetaAlphaGradientSpec: (skip)
*
*/
typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec;
/**
* MetaColorSpec: (skip)
*
*/
typedef struct _MetaColorSpec MetaColorSpec;
/**
* MetaFrameLayout: (skip)
*
@ -83,53 +58,10 @@ typedef struct _MetaButtonSpace MetaButtonSpace;
*/
typedef struct _MetaFrameGeometry MetaFrameGeometry;
/**
* MetaPositionExprEnv: (skip)
*
*/
typedef struct _MetaPositionExprEnv MetaPositionExprEnv;
/**
* MetaDrawInfo: (skip)
*
*/
typedef struct _MetaDrawInfo MetaDrawInfo;
#define META_THEME_ERROR (g_quark_from_static_string ("meta-theme-error"))
typedef enum
{
META_THEME_ERROR_FRAME_GEOMETRY,
META_THEME_ERROR_BAD_CHARACTER,
META_THEME_ERROR_BAD_PARENS,
META_THEME_ERROR_UNKNOWN_VARIABLE,
META_THEME_ERROR_DIVIDE_BY_ZERO,
META_THEME_ERROR_MOD_ON_FLOAT,
META_THEME_ERROR_FAILED
} MetaThemeError;
/**
* Whether a button's size is calculated from the area around it (aspect
* sizing) or is given as a fixed height and width in pixels (fixed sizing).
*
* \bug This could be done away with; see the comment at the top of
* MetaFrameLayout.
*/
typedef enum
{
META_BUTTON_SIZING_ASPECT,
META_BUTTON_SIZING_FIXED,
META_BUTTON_SIZING_LAST
} MetaButtonSizing;
/**
* Various parameters used to calculate the geometry of a frame.
* They are used inside a MetaFrameStyle.
* This corresponds closely to the <frame_geometry> tag in a theme file.
*
* \bug button_sizing isn't really necessary, because we could easily say
* that if button_aspect is zero, the height and width are fixed values.
* This would also mean that MetaButtonSizing didn't need to exist, and
* save code.
**/
struct _MetaFrameLayout
{
@ -156,22 +88,6 @@ struct _MetaFrameLayout
/** Left indent of buttons from edges of frame */
int left_titlebar_edge;
/**
* Sizing rule of buttons, either META_BUTTON_SIZING_ASPECT
* (in which case button_aspect will be honoured, and
* button_width and button_height set from it), or
* META_BUTTON_SIZING_FIXED (in which case we read the width
* and height directly).
*/
MetaButtonSizing button_sizing;
/**
* Ratio of height/width. Honoured only if
* button_sizing==META_BUTTON_SIZING_ASPECT.
* Otherwise we figure out the height from the button_border.
*/
double button_aspect;
/** Width of a button; set even when we are using aspect sizing */
int button_width;
@ -239,7 +155,7 @@ struct _MetaFrameGeometry
/* used for a memset hack */
#define ADDRESS_OF_BUTTON_RECTS(fgeom) (((char*)(fgeom)) + G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
#define LENGTH_OF_BUTTON_RECTS (G_STRUCT_OFFSET (MetaFrameGeometry, right_single_background) + sizeof (GdkRectangle) - G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
#define LENGTH_OF_BUTTON_RECTS (G_STRUCT_OFFSET (MetaFrameGeometry, unstick_rect) + sizeof (GdkRectangle) - G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
/* The button rects (if changed adjust memset hack) */
MetaButtonSpace close_rect;
@ -253,16 +169,6 @@ struct _MetaFrameGeometry
MetaButtonSpace unshade_rect;
MetaButtonSpace unabove_rect;
MetaButtonSpace unstick_rect;
#define MAX_MIDDLE_BACKGROUNDS (MAX_BUTTONS_PER_CORNER - 2)
GdkRectangle left_left_background;
GdkRectangle left_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS];
GdkRectangle left_right_background;
GdkRectangle left_single_background;
GdkRectangle right_left_background;
GdkRectangle right_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS];
GdkRectangle right_right_background;
GdkRectangle right_single_background;
/* End of button rects (if changed adjust memset hack) */
/* Saved button layout */
@ -277,380 +183,6 @@ struct _MetaFrameGeometry
guint bottom_right_corner_rounded_radius;
};
typedef enum
{
META_IMAGE_FILL_SCALE, /* default, needs to be all-bits-zero for g_new0 */
META_IMAGE_FILL_TILE
} MetaImageFillType;
typedef enum
{
META_GRADIENT_VERTICAL,
META_GRADIENT_HORIZONTAL,
META_GRADIENT_DIAGONAL,
META_GRADIENT_LAST
} MetaGradientType;
typedef enum
{
META_COLOR_SPEC_BASIC,
META_COLOR_SPEC_GTK,
META_COLOR_SPEC_GTK_CUSTOM,
META_COLOR_SPEC_BLEND,
META_COLOR_SPEC_SHADE
} MetaColorSpecType;
typedef enum
{
META_GTK_COLOR_FG,
META_GTK_COLOR_BG,
META_GTK_COLOR_LIGHT,
META_GTK_COLOR_DARK,
META_GTK_COLOR_MID,
META_GTK_COLOR_TEXT,
META_GTK_COLOR_BASE,
META_GTK_COLOR_TEXT_AA,
META_GTK_COLOR_LAST
} MetaGtkColorComponent;
struct _MetaColorSpec
{
MetaColorSpecType type;
union
{
struct {
GdkRGBA color;
} basic;
struct {
MetaGtkColorComponent component;
GtkStateFlags state;
} gtk;
struct {
char *color_name;
MetaColorSpec *fallback;
} gtkcustom;
struct {
MetaColorSpec *foreground;
MetaColorSpec *background;
double alpha;
GdkRGBA color;
} blend;
struct {
MetaColorSpec *base;
double factor;
GdkRGBA color;
} shade;
} data;
};
struct _MetaGradientSpec
{
MetaGradientType type;
GSList *color_specs;
};
struct _MetaAlphaGradientSpec
{
MetaGradientType type;
unsigned char *alphas;
int n_alphas;
};
struct _MetaDrawInfo
{
GdkPixbuf *mini_icon;
GdkPixbuf *icon;
PangoLayout *title_layout;
int title_layout_width;
int title_layout_height;
const MetaFrameGeometry *fgeom;
};
/**
* A drawing operation in our simple vector drawing language.
*/
typedef enum
{
/** Basic drawing-- line */
META_DRAW_LINE,
/** Basic drawing-- rectangle */
META_DRAW_RECTANGLE,
/** Basic drawing-- arc */
META_DRAW_ARC,
/** Clip to a rectangle */
META_DRAW_CLIP,
/* Texture thingies */
/** Just a filled rectangle with alpha */
META_DRAW_TINT,
META_DRAW_GRADIENT,
META_DRAW_IMAGE,
/** GTK theme engine stuff */
META_DRAW_GTK_ARROW,
META_DRAW_GTK_BOX,
META_DRAW_GTK_VLINE,
/** App's window icon */
META_DRAW_ICON,
/** App's window title */
META_DRAW_TITLE,
/** a draw op list */
META_DRAW_OP_LIST,
/** tiled draw op list */
META_DRAW_TILE
} MetaDrawType;
typedef enum
{
POS_TOKEN_INT,
POS_TOKEN_DOUBLE,
POS_TOKEN_OPERATOR,
POS_TOKEN_VARIABLE,
POS_TOKEN_OPEN_PAREN,
POS_TOKEN_CLOSE_PAREN
} PosTokenType;
typedef enum
{
POS_OP_NONE,
POS_OP_ADD,
POS_OP_SUBTRACT,
POS_OP_MULTIPLY,
POS_OP_DIVIDE,
POS_OP_MOD,
POS_OP_MAX,
POS_OP_MIN
} PosOperatorType;
/**
* A token, as output by the tokeniser.
*
* \ingroup tokenizer
*/
typedef struct
{
PosTokenType type;
union
{
struct {
int val;
} i;
struct {
double val;
} d;
struct {
PosOperatorType op;
} o;
struct {
char *name;
GQuark name_quark;
} v;
} d;
} PosToken;
/**
* MetaDrawSpec: (skip)
*
* A computed expression in our simple vector drawing language.
* While it appears to take the form of a tree, this is actually
* merely a list; concerns such as precedence of operators are
* currently recomputed on every recalculation.
*
* Created by meta_draw_spec_new(), destroyed by meta_draw_spec_free().
* pos_eval() fills this with ...FIXME. Are tokens a tree or a list?
* \ingroup parser
*/
typedef struct _MetaDrawSpec MetaDrawSpec;
struct _MetaDrawSpec
{
/**
* If this spec is constant, this is the value of the constant;
* otherwise it is zero.
*/
int value;
/** A list of tokens in the expression. */
PosToken *tokens;
/** How many tokens are in the tokens list. */
int n_tokens;
/** Does the expression contain any variables? */
gboolean constant : 1;
};
/**
* A single drawing operation in our simple vector drawing language.
*/
struct _MetaDrawOp
{
MetaDrawType type;
/* Positions are strings because they can be expressions */
union
{
struct {
MetaColorSpec *color_spec;
int dash_on_length;
int dash_off_length;
int width;
MetaDrawSpec *x1;
MetaDrawSpec *y1;
MetaDrawSpec *x2;
MetaDrawSpec *y2;
} line;
struct {
MetaColorSpec *color_spec;
gboolean filled;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} rectangle;
struct {
MetaColorSpec *color_spec;
gboolean filled;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
double start_angle;
double extent_angle;
} arc;
struct {
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} clip;
struct {
MetaColorSpec *color_spec;
MetaAlphaGradientSpec *alpha_spec;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} tint;
struct {
MetaGradientSpec *gradient_spec;
MetaAlphaGradientSpec *alpha_spec;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} gradient;
struct {
MetaAlphaGradientSpec *alpha_spec;
GdkPixbuf *pixbuf;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
MetaImageFillType fill_type;
unsigned int vertical_stripes : 1;
unsigned int horizontal_stripes : 1;
} image;
struct {
GtkStateFlags state;
GtkShadowType shadow;
GtkArrowType arrow;
gboolean filled;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} gtk_arrow;
struct {
GtkStateFlags state;
GtkShadowType shadow;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} gtk_box;
struct {
GtkStateFlags state;
MetaDrawSpec *x;
MetaDrawSpec *y1;
MetaDrawSpec *y2;
} gtk_vline;
struct {
MetaAlphaGradientSpec *alpha_spec;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
MetaImageFillType fill_type;
} icon;
struct {
MetaColorSpec *color_spec;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *ellipsize_width;
} title;
struct {
MetaDrawOpList *op_list;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
} op_list;
struct {
MetaDrawOpList *op_list;
MetaDrawSpec *x;
MetaDrawSpec *y;
MetaDrawSpec *width;
MetaDrawSpec *height;
MetaDrawSpec *tile_xoffset;
MetaDrawSpec *tile_yoffset;
MetaDrawSpec *tile_width;
MetaDrawSpec *tile_height;
} tile;
} data;
};
/**
* A list of MetaDrawOp objects. Maintains a reference count.
* Grows as necessary and allows the allocation of unused spaces
* to keep reallocations to a minimum.
*
* \bug Do we really win anything from not using the equivalent
* GLib structures?
*/
struct _MetaDrawOpList
{
int refcount;
MetaDrawOp **ops;
int n_ops;
int n_allocated;
};
typedef enum
{
META_BUTTON_STATE_NORMAL,
@ -661,15 +193,6 @@ typedef enum
typedef enum
{
/* Ordered so that background is drawn first */
META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND,
META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND,
META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND,
META_BUTTON_TYPE_LEFT_SINGLE_BACKGROUND,
META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND,
META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND,
META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND,
META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND,
META_BUTTON_TYPE_CLOSE,
META_BUTTON_TYPE_MAXIMIZE,
META_BUTTON_TYPE_MINIMIZE,
@ -701,51 +224,6 @@ struct _MetaStyleInfo
GtkStyleContext *styles[META_STYLE_ELEMENT_LAST];
};
typedef enum
{
/* Listed in the order in which the textures are drawn.
* (though this only matters for overlaps of course.)
* Buttons are drawn after the frame textures.
*
* On the corners, horizontal pieces are arbitrarily given the
* corner area:
*
* ===== |====
* | |
* | rather than |
*
*/
/* entire frame */
META_FRAME_PIECE_ENTIRE_BACKGROUND,
/* entire titlebar background */
META_FRAME_PIECE_TITLEBAR,
/* portion of the titlebar background inside the titlebar
* background edges
*/
META_FRAME_PIECE_TITLEBAR_MIDDLE,
/* left end of titlebar */
META_FRAME_PIECE_LEFT_TITLEBAR_EDGE,
/* right end of titlebar */
META_FRAME_PIECE_RIGHT_TITLEBAR_EDGE,
/* top edge of titlebar */
META_FRAME_PIECE_TOP_TITLEBAR_EDGE,
/* bottom edge of titlebar */
META_FRAME_PIECE_BOTTOM_TITLEBAR_EDGE,
/* render over title background (text area) */
META_FRAME_PIECE_TITLE,
/* left edge of the frame */
META_FRAME_PIECE_LEFT_EDGE,
/* right edge of the frame */
META_FRAME_PIECE_RIGHT_EDGE,
/* bottom edge of the frame */
META_FRAME_PIECE_BOTTOM_EDGE,
/* place over entire frame, after drawing everything else */
META_FRAME_PIECE_OVERLAY,
/* Used to get size of the enum */
META_FRAME_PIECE_LAST
} MetaFramePiece;
/**
* How to draw a frame in a particular state (say, a focussed, non-maximised,
* resizable frame). This corresponds closely to the <frame_style> tag
@ -760,24 +238,11 @@ struct _MetaFrameStyle
* Settings which are unspecified here will be taken from there.
*/
MetaFrameStyle *parent;
/** Operations for drawing each kind of button in each state. */
MetaDrawOpList *buttons[META_BUTTON_TYPE_LAST][META_BUTTON_STATE_LAST];
/** Operations for drawing each piece of the frame. */
MetaDrawOpList *pieces[META_FRAME_PIECE_LAST];
/**
* Details such as the height and width of each edge, the corner rounding,
* and the aspect ratio of the buttons.
*/
MetaFrameLayout *layout;
/**
* Background colour of the window. Only present in theme formats
* 2 and above. Can be NULL to use the standard GTK theme engine.
*/
MetaColorSpec *window_background_color;
/**
* Transparency of the window background. 0=transparent; 255=opaque.
*/
guint8 window_background_alpha;
};
/* Kinds of frame...
@ -851,92 +316,11 @@ struct _MetaFrameStyleSet
/**
* A theme. This is a singleton class which groups all settings from a theme
* on disk together.
*
* \bug It is rather useless to keep the metadata fields in core, I think.
* together.
*/
struct _MetaTheme
{
/** Name of the theme (on disk), e.g. "Crux" */
char *name;
/** Path to the files associated with the theme */
char *dirname;
/**
* Filename of the XML theme file.
* \bug Kept lying around for no discernable reason.
*/
char *filename;
/** Metadata: Human-readable name of the theme. */
char *readable_name;
/** Metadata: Author of the theme. */
char *author;
/** Metadata: Copyright holder. */
char *copyright;
/** Metadata: Date of the theme. */
char *date;
/** Metadata: Description of the theme. */
char *description;
/** Version of the theme format. Older versions cannot use the features
* of newer versions even if they think they can (this is to allow forward
* and backward compatibility.
*/
guint format_version;
/** Symbol table of integer constants. */
GHashTable *integer_constants;
/** Symbol table of float constants. */
GHashTable *float_constants;
/**
* Symbol table of colour constants (hex triples, and triples
* plus alpha).
* */
GHashTable *color_constants;
GHashTable *images_by_filename;
GHashTable *layouts_by_name;
GHashTable *draw_op_lists_by_name;
GHashTable *styles_by_name;
GHashTable *style_sets_by_name;
MetaFrameStyleSet *style_sets_by_type[META_FRAME_TYPE_LAST];
GQuark quark_width;
GQuark quark_height;
GQuark quark_object_width;
GQuark quark_object_height;
GQuark quark_left_width;
GQuark quark_right_width;
GQuark quark_top_height;
GQuark quark_bottom_height;
GQuark quark_mini_icon_width;
GQuark quark_mini_icon_height;
GQuark quark_icon_width;
GQuark quark_icon_height;
GQuark quark_title_width;
GQuark quark_title_height;
GQuark quark_frame_x_center;
GQuark quark_frame_y_center;
};
struct _MetaPositionExprEnv
{
MetaRectangle rect;
/* size of an object being drawn, if it has a natural size */
int object_width;
int object_height;
/* global object sizes, always available */
int left_width;
int right_width;
int top_height;
int bottom_height;
int title_width;
int title_height;
int frame_x_center;
int frame_y_center;
int mini_icon_width;
int mini_icon_height;
int icon_width;
int icon_height;
/* Theme so we can look up constants */
MetaTheme *theme;
};
MetaFrameLayout* meta_frame_layout_new (void);
@ -948,77 +332,6 @@ void meta_frame_layout_get_borders (const MetaFrameLayout *layout,
MetaFrameFlags flags,
MetaFrameType type,
MetaFrameBorders *borders);
gboolean meta_frame_layout_validate (const MetaFrameLayout *layout,
GError **error);
gboolean meta_parse_position_expression (MetaDrawSpec *spec,
const MetaPositionExprEnv *env,
int *x_return,
int *y_return,
GError **err);
gboolean meta_parse_size_expression (MetaDrawSpec *spec,
const MetaPositionExprEnv *env,
int *val_return,
GError **err);
MetaDrawSpec* meta_draw_spec_new (MetaTheme *theme,
const char *expr,
GError **error);
void meta_draw_spec_free (MetaDrawSpec *spec);
MetaColorSpec* meta_color_spec_new (MetaColorSpecType type);
MetaColorSpec* meta_color_spec_new_from_string (const char *str,
GError **err);
MetaColorSpec* meta_color_spec_new_gtk (MetaGtkColorComponent component,
GtkStateFlags state);
void meta_color_spec_free (MetaColorSpec *spec);
void meta_color_spec_render (MetaColorSpec *spec,
GtkStyleContext *style_gtk,
GdkRGBA *color);
MetaDrawOp* meta_draw_op_new (MetaDrawType type);
void meta_draw_op_free (MetaDrawOp *op);
void meta_draw_op_draw_with_style (const MetaDrawOp *op,
GtkStyleContext *style_gtk,
cairo_t *cr,
const MetaDrawInfo *info,
/* logical region being drawn */
MetaRectangle logical_region);
MetaDrawOpList* meta_draw_op_list_new (int n_preallocs);
void meta_draw_op_list_ref (MetaDrawOpList *op_list);
void meta_draw_op_list_unref (MetaDrawOpList *op_list);
void meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
GtkStyleContext *style_gtk,
cairo_t *cr,
const MetaDrawInfo *info,
MetaRectangle rect);
void meta_draw_op_list_append (MetaDrawOpList *op_list,
MetaDrawOp *op);
gboolean meta_draw_op_list_validate (MetaDrawOpList *op_list,
GError **error);
gboolean meta_draw_op_list_contains (MetaDrawOpList *op_list,
MetaDrawOpList *child);
MetaGradientSpec* meta_gradient_spec_new (MetaGradientType type);
void meta_gradient_spec_free (MetaGradientSpec *desc);
void meta_gradient_spec_render (const MetaGradientSpec *spec,
const MetaAlphaGradientSpec *alpha_spec,
cairo_t *cr,
GtkStyleContext *style,
int x,
int y,
int width,
int height);
gboolean meta_gradient_spec_validate (MetaGradientSpec *spec,
GError **error);
MetaAlphaGradientSpec* meta_alpha_gradient_spec_new (MetaGradientType type,
int n_alphas);
void meta_alpha_gradient_spec_free (MetaAlphaGradientSpec *spec);
MetaFrameStyle* meta_frame_style_new (MetaFrameStyle *parent);
void meta_frame_style_ref (MetaFrameStyle *style);
@ -1027,22 +340,10 @@ void meta_frame_style_unref (MetaFrameStyle *style);
void meta_frame_style_apply_scale (const MetaFrameStyle *style,
PangoFontDescription *font_desc);
gboolean meta_frame_style_validate (MetaFrameStyle *style,
guint current_theme_version,
GError **error);
MetaFrameStyleSet* meta_frame_style_set_new (MetaFrameStyleSet *parent);
void meta_frame_style_set_ref (MetaFrameStyleSet *style_set);
void meta_frame_style_set_unref (MetaFrameStyleSet *style_set);
gboolean meta_frame_style_set_validate (MetaFrameStyleSet *style_set,
GError **error);
GdkPixbuf* meta_theme_load_image (MetaTheme *theme,
const char *filename,
guint size_of_theme_icons,
GError **error);
MetaFrameStyle* meta_theme_get_frame_style (MetaTheme *theme,
MetaFrameType type,
MetaFrameFlags flags);
@ -1087,91 +388,11 @@ void meta_theme_calc_geometry (MetaTheme *theme,
const MetaButtonLayout *button_layout,
MetaFrameGeometry *fgeom);
MetaFrameLayout* meta_theme_lookup_layout (MetaTheme *theme,
const char *name);
void meta_theme_insert_layout (MetaTheme *theme,
const char *name,
MetaFrameLayout *layout);
MetaDrawOpList* meta_theme_lookup_draw_op_list (MetaTheme *theme,
const char *name);
void meta_theme_insert_draw_op_list (MetaTheme *theme,
const char *name,
MetaDrawOpList *op_list);
MetaFrameStyle* meta_theme_lookup_style (MetaTheme *theme,
const char *name);
void meta_theme_insert_style (MetaTheme *theme,
const char *name,
MetaFrameStyle *style);
MetaFrameStyleSet* meta_theme_lookup_style_set (MetaTheme *theme,
const char *name);
void meta_theme_insert_style_set (MetaTheme *theme,
const char *name,
MetaFrameStyleSet *style_set);
gboolean meta_theme_define_int_constant (MetaTheme *theme,
const char *name,
int value,
GError **error);
gboolean meta_theme_lookup_int_constant (MetaTheme *theme,
const char *name,
int *value);
gboolean meta_theme_define_float_constant (MetaTheme *theme,
const char *name,
double value,
GError **error);
gboolean meta_theme_lookup_float_constant (MetaTheme *theme,
const char *name,
double *value);
gboolean meta_theme_define_color_constant (MetaTheme *theme,
const char *name,
const char *value,
GError **error);
gboolean meta_theme_lookup_color_constant (MetaTheme *theme,
const char *name,
char **value);
gboolean meta_theme_replace_constants (MetaTheme *theme,
PosToken *tokens,
int n_tokens,
GError **err);
/* random stuff */
int meta_pango_font_desc_get_text_height (const PangoFontDescription *font_desc,
PangoContext *context);
/* Enum converters */
MetaGtkColorComponent meta_color_component_from_string (const char *str);
MetaButtonState meta_button_state_from_string (const char *str);
const char* meta_button_state_to_string (MetaButtonState state);
MetaButtonType meta_button_type_from_string (const char *str,
MetaTheme *theme);
const char* meta_button_type_to_string (MetaButtonType type);
MetaFramePiece meta_frame_piece_from_string (const char *str);
MetaFrameState meta_frame_state_from_string (const char *str);
const char* meta_frame_state_to_string (MetaFrameState state);
MetaFrameResize meta_frame_resize_from_string (const char *str);
const char* meta_frame_resize_to_string (MetaFrameResize resize);
MetaFrameFocus meta_frame_focus_from_string (const char *str);
const char* meta_frame_focus_to_string (MetaFrameFocus focus);
MetaFrameType meta_frame_type_from_string (const char *str);
MetaGradientType meta_gradient_type_from_string (const char *str);
GtkStateFlags meta_gtk_state_from_string (const char *str);
GtkShadowType meta_gtk_shadow_from_string (const char *str);
GtkArrowType meta_gtk_arrow_from_string (const char *str);
MetaImageFillType meta_image_fill_type_from_string (const char *str);
void meta_gtk_style_get_light_color (GtkStyleContext *style,
GtkStateFlags state,
GdkRGBA *color);
void meta_gtk_style_get_dark_color (GtkStyleContext *style,
GtkStateFlags state,
GdkRGBA *color);
guint meta_theme_earliest_version_with_button (MetaButtonType type);
#define META_THEME_ALLOWS(theme, feature) (theme->format_version >= feature)
/* What version of the theme file format were various features introduced in? */

File diff suppressed because it is too large Load Diff