[mutter/wip/cb2eb3: 16/55] theme: Parse window radiuses from CSS



commit cc3be6da4d9ded5bd2107b1239313a67adc8cdce
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Apr 26 19:28:16 2012 -0400

    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.

 src/ui/theme-parser.c  |   73 ------------------------------------------------
 src/ui/theme-private.h |    9 ------
 src/ui/theme.c         |   20 +++++++++----
 3 files changed, 14 insertions(+), 88 deletions(-)
---
diff --git a/src/ui/theme-parser.c b/src/ui/theme-parser.c
index 06ef3ea..3825e22 100644
--- a/src/ui/theme-parser.c
+++ b/src/ui/theme-parser.c
@@ -686,41 +686,6 @@ parse_boolean (const char          *str,
 }
 
 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
 parse_angle (const char          *str,
              double              *val,
              GMarkupParseContext *context,
@@ -961,16 +926,8 @@ parse_toplevel_element (GMarkupParseContext  *context,
       const char *parent = NULL;
       const char *has_title = 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;
       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;
       double title_scale_val;
       MetaFrameLayout *parent_layout;
@@ -979,10 +936,6 @@ parse_toplevel_element (GMarkupParseContext  *context,
                               error,
                               "!name", &name, "parent", &parent,
                               "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,
                               NULL))
         return;
@@ -994,20 +947,6 @@ parse_toplevel_element (GMarkupParseContext  *context,
       hide_buttons_val = FALSE;
       if (hide_buttons && !parse_boolean (hide_buttons, &hide_buttons_val, context, error))
         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;
       if (title_scale && !parse_title_scale (title_scale, &title_scale_val, context, error))
@@ -1050,18 +989,6 @@ parse_toplevel_element (GMarkupParseContext  *context,
       if (title_scale)
        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);
 
       push_state (info, STATE_FRAME_GEOMETRY);
diff --git a/src/ui/theme-private.h b/src/ui/theme-private.h
index 8a36a7e..5d389a1 100644
--- a/src/ui/theme-private.h
+++ b/src/ui/theme-private.h
@@ -188,15 +188,6 @@ struct _MetaFrameLayout
 
   /** Whether we should hide the buttons */
   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;
 };
 
 /**
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 96c37c6..f53293a 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -531,6 +531,7 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
   int width, height;
   int button_width, button_height;
   int min_size_for_rounding;
+  double tl, tr, bl, br;
   
   /* the left/right rects in order; the max # of rects
    * is the number of button functions
@@ -865,21 +866,28 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
     min_size_for_rounding = 0;
   else
     min_size_for_rounding = 5;
-  
+
   fgeom->top_left_corner_rounded_radius = 0;
   fgeom->top_right_corner_rounded_radius = 0;
   fgeom->bottom_left_corner_rounded_radius = 0;
   fgeom->bottom_right_corner_rounded_radius = 0;
 
+  gtk_style_context_get (ctx,
+                         GTK_STATE_ACTIVE,
+                         "border-top-left-radius", &tl,
+                         "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 = layout->top_left_corner_rounded_radius;
+    fgeom->top_left_corner_rounded_radius = tl;
   if (borders.visible.top + borders.visible.right >= min_size_for_rounding)
-    fgeom->top_right_corner_rounded_radius = layout->top_right_corner_rounded_radius;
-
+    fgeom->top_right_corner_rounded_radius = tr;
   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)
-    fgeom->bottom_right_corner_rounded_radius = layout->bottom_right_corner_rounded_radius;
+    fgeom->bottom_right_corner_rounded_radius = br;
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]