mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
theme: Parse window radiuses from CSS
This requires a local hack to GTK+ that's ugly and I'm not sharing it. We'll do things properly soon enough.
This commit is contained in:
parent
fef2a061a8
commit
cc3be6da4d
@ -685,41 +685,6 @@ parse_boolean (const char *str,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
parse_rounding (const char *str,
|
|
||||||
guint *val,
|
|
||||||
GMarkupParseContext *context,
|
|
||||||
MetaTheme *theme,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
if (strcmp ("true", str) == 0)
|
|
||||||
*val = 5; /* historical "true" value */
|
|
||||||
else if (strcmp ("false", str) == 0)
|
|
||||||
*val = 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int tmp;
|
|
||||||
gboolean result;
|
|
||||||
if (!META_THEME_ALLOWS (theme, META_THEME_VARIED_ROUND_CORNERS))
|
|
||||||
{
|
|
||||||
/* Not known in this version, so bail. */
|
|
||||||
set_error (error, context, G_MARKUP_ERROR,
|
|
||||||
G_MARKUP_ERROR_PARSE,
|
|
||||||
_("Boolean values must be \"true\" or \"false\" not \"%s\""),
|
|
||||||
str);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = parse_positive_integer (str, &tmp, context, theme, error);
|
|
||||||
|
|
||||||
*val = tmp;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
parse_angle (const char *str,
|
parse_angle (const char *str,
|
||||||
double *val,
|
double *val,
|
||||||
@ -961,16 +926,8 @@ parse_toplevel_element (GMarkupParseContext *context,
|
|||||||
const char *parent = NULL;
|
const char *parent = NULL;
|
||||||
const char *has_title = NULL;
|
const char *has_title = NULL;
|
||||||
const char *title_scale = NULL;
|
const char *title_scale = NULL;
|
||||||
const char *rounded_top_left = NULL;
|
|
||||||
const char *rounded_top_right = NULL;
|
|
||||||
const char *rounded_bottom_left = NULL;
|
|
||||||
const char *rounded_bottom_right = NULL;
|
|
||||||
const char *hide_buttons = NULL;
|
const char *hide_buttons = NULL;
|
||||||
gboolean has_title_val;
|
gboolean has_title_val;
|
||||||
guint rounded_top_left_val;
|
|
||||||
guint rounded_top_right_val;
|
|
||||||
guint rounded_bottom_left_val;
|
|
||||||
guint rounded_bottom_right_val;
|
|
||||||
gboolean hide_buttons_val;
|
gboolean hide_buttons_val;
|
||||||
double title_scale_val;
|
double title_scale_val;
|
||||||
MetaFrameLayout *parent_layout;
|
MetaFrameLayout *parent_layout;
|
||||||
@ -979,10 +936,6 @@ parse_toplevel_element (GMarkupParseContext *context,
|
|||||||
error,
|
error,
|
||||||
"!name", &name, "parent", &parent,
|
"!name", &name, "parent", &parent,
|
||||||
"has_title", &has_title, "title_scale", &title_scale,
|
"has_title", &has_title, "title_scale", &title_scale,
|
||||||
"rounded_top_left", &rounded_top_left,
|
|
||||||
"rounded_top_right", &rounded_top_right,
|
|
||||||
"rounded_bottom_left", &rounded_bottom_left,
|
|
||||||
"rounded_bottom_right", &rounded_bottom_right,
|
|
||||||
"hide_buttons", &hide_buttons,
|
"hide_buttons", &hide_buttons,
|
||||||
NULL))
|
NULL))
|
||||||
return;
|
return;
|
||||||
@ -995,20 +948,6 @@ parse_toplevel_element (GMarkupParseContext *context,
|
|||||||
if (hide_buttons && !parse_boolean (hide_buttons, &hide_buttons_val, context, error))
|
if (hide_buttons && !parse_boolean (hide_buttons, &hide_buttons_val, context, error))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rounded_top_left_val = 0;
|
|
||||||
rounded_top_right_val = 0;
|
|
||||||
rounded_bottom_left_val = 0;
|
|
||||||
rounded_bottom_right_val = 0;
|
|
||||||
|
|
||||||
if (rounded_top_left && !parse_rounding (rounded_top_left, &rounded_top_left_val, context, info->theme, error))
|
|
||||||
return;
|
|
||||||
if (rounded_top_right && !parse_rounding (rounded_top_right, &rounded_top_right_val, context, info->theme, error))
|
|
||||||
return;
|
|
||||||
if (rounded_bottom_left && !parse_rounding (rounded_bottom_left, &rounded_bottom_left_val, context, info->theme, error))
|
|
||||||
return;
|
|
||||||
if (rounded_bottom_right && !parse_rounding (rounded_bottom_right, &rounded_bottom_right_val, context, info->theme, error))
|
|
||||||
return;
|
|
||||||
|
|
||||||
title_scale_val = 1.0;
|
title_scale_val = 1.0;
|
||||||
if (title_scale && !parse_title_scale (title_scale, &title_scale_val, context, error))
|
if (title_scale && !parse_title_scale (title_scale, &title_scale_val, context, error))
|
||||||
return;
|
return;
|
||||||
@ -1050,18 +989,6 @@ parse_toplevel_element (GMarkupParseContext *context,
|
|||||||
if (title_scale)
|
if (title_scale)
|
||||||
info->layout->title_scale = title_scale_val;
|
info->layout->title_scale = title_scale_val;
|
||||||
|
|
||||||
if (rounded_top_left)
|
|
||||||
info->layout->top_left_corner_rounded_radius = rounded_top_left_val;
|
|
||||||
|
|
||||||
if (rounded_top_right)
|
|
||||||
info->layout->top_right_corner_rounded_radius = rounded_top_right_val;
|
|
||||||
|
|
||||||
if (rounded_bottom_left)
|
|
||||||
info->layout->bottom_left_corner_rounded_radius = rounded_bottom_left_val;
|
|
||||||
|
|
||||||
if (rounded_bottom_right)
|
|
||||||
info->layout->bottom_right_corner_rounded_radius = rounded_bottom_right_val;
|
|
||||||
|
|
||||||
meta_theme_insert_layout (info->theme, name, info->layout);
|
meta_theme_insert_layout (info->theme, name, info->layout);
|
||||||
|
|
||||||
push_state (info, STATE_FRAME_GEOMETRY);
|
push_state (info, STATE_FRAME_GEOMETRY);
|
||||||
|
@ -188,15 +188,6 @@ struct _MetaFrameLayout
|
|||||||
|
|
||||||
/** Whether we should hide the buttons */
|
/** Whether we should hide the buttons */
|
||||||
guint hide_buttons : 1;
|
guint hide_buttons : 1;
|
||||||
|
|
||||||
/** Radius of the top left-hand corner; 0 if not rounded */
|
|
||||||
guint top_left_corner_rounded_radius;
|
|
||||||
/** Radius of the top right-hand corner; 0 if not rounded */
|
|
||||||
guint top_right_corner_rounded_radius;
|
|
||||||
/** Radius of the bottom left-hand corner; 0 if not rounded */
|
|
||||||
guint bottom_left_corner_rounded_radius;
|
|
||||||
/** Radius of the bottom right-hand corner; 0 if not rounded */
|
|
||||||
guint bottom_right_corner_rounded_radius;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -531,6 +531,7 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
|
|||||||
int width, height;
|
int width, height;
|
||||||
int button_width, button_height;
|
int button_width, button_height;
|
||||||
int min_size_for_rounding;
|
int min_size_for_rounding;
|
||||||
|
double tl, tr, bl, br;
|
||||||
|
|
||||||
/* the left/right rects in order; the max # of rects
|
/* the left/right rects in order; the max # of rects
|
||||||
* is the number of button functions
|
* is the number of button functions
|
||||||
@ -871,15 +872,22 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
|
|||||||
fgeom->bottom_left_corner_rounded_radius = 0;
|
fgeom->bottom_left_corner_rounded_radius = 0;
|
||||||
fgeom->bottom_right_corner_rounded_radius = 0;
|
fgeom->bottom_right_corner_rounded_radius = 0;
|
||||||
|
|
||||||
if (borders.visible.top + borders.visible.left >= min_size_for_rounding)
|
gtk_style_context_get (ctx,
|
||||||
fgeom->top_left_corner_rounded_radius = layout->top_left_corner_rounded_radius;
|
GTK_STATE_ACTIVE,
|
||||||
if (borders.visible.top + borders.visible.right >= min_size_for_rounding)
|
"border-top-left-radius", &tl,
|
||||||
fgeom->top_right_corner_rounded_radius = layout->top_right_corner_rounded_radius;
|
"border-top-right-radius", &tr,
|
||||||
|
"border-bottom-left-radius", &bl,
|
||||||
|
"border-bottom-right-radius", &br,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (borders.visible.top + borders.visible.left >= min_size_for_rounding)
|
||||||
|
fgeom->top_left_corner_rounded_radius = tl;
|
||||||
|
if (borders.visible.top + borders.visible.right >= min_size_for_rounding)
|
||||||
|
fgeom->top_right_corner_rounded_radius = tr;
|
||||||
if (borders.visible.bottom + borders.visible.left >= min_size_for_rounding)
|
if (borders.visible.bottom + borders.visible.left >= min_size_for_rounding)
|
||||||
fgeom->bottom_left_corner_rounded_radius = layout->bottom_left_corner_rounded_radius;
|
fgeom->bottom_left_corner_rounded_radius = bl;
|
||||||
if (borders.visible.bottom + borders.visible.right >= min_size_for_rounding)
|
if (borders.visible.bottom + borders.visible.right >= min_size_for_rounding)
|
||||||
fgeom->bottom_right_corner_rounded_radius = layout->bottom_right_corner_rounded_radius;
|
fgeom->bottom_right_corner_rounded_radius = br;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user