? metacity_86040.patch
Index: src/theme-parser.c
===================================================================
RCS file: /cvs/gnome/metacity/src/theme-parser.c,v
retrieving revision 1.19
diff -u -r1.19 theme-parser.c
--- src/theme-parser.c	30 May 2003 04:52:12 -0000	1.19
+++ src/theme-parser.c	4 Jan 2004 18:55:57 -0000
@@ -1636,7 +1636,6 @@
       MetaColorSpec *color_spec;
       int dash_on_val;
       int dash_off_val;
-      int width_val;
       
       if (!locate_attributes (context, element_name, attribute_names, attribute_values,
                               error,
@@ -1696,6 +1695,10 @@
       if (!check_expression (y2, FALSE, info->theme, context, error))
         return;
       
+      if (width && 
+          !check_expression (width, FALSE, info->theme, context, error))
+        return;
+
       dash_on_val = 0;
       if (dash_on_length &&
           !parse_positive_integer (dash_on_length, &dash_on_val, context, error))
@@ -1706,11 +1709,6 @@
           !parse_positive_integer (dash_off_length, &dash_off_val, context, error))
         return;
 
-      width_val = 0;
-      if (width &&
-          !parse_positive_integer (width, &width_val, context, error))
-        return;
-
       /* Check last so we don't have to free it when other
        * stuff fails
        */
@@ -1728,7 +1726,11 @@
       op->data.line.y1 = optimize_expression (info->theme, y1);
       op->data.line.x2 = optimize_expression (info->theme, x2);
       op->data.line.y2 = optimize_expression (info->theme, y2);
-      op->data.line.width = width_val;
+      // should "width" stay optional ?
+      if(width)
+        op->data.line.width = optimize_expression (info->theme, width);
+      else
+        op->data.line.width = optimize_expression (info->theme, "0");
       op->data.line.dash_on_length = dash_on_val;
       op->data.line.dash_off_length = dash_off_val;
 
Index: src/theme.c
===================================================================
RCS file: /cvs/gnome/metacity/src/theme.c,v
retrieving revision 1.69
diff -u -r1.69 theme.c
--- src/theme.c	28 Jan 2003 15:07:43 -0000	1.69
+++ src/theme.c	4 Jan 2004 18:56:07 -0000
@@ -18,7 +18,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-
 #include <config.h>
 #include "theme.h"
 #include "theme-parser.h"
@@ -2284,6 +2283,42 @@
     }
 }
 
+gboolean
+meta_parse_weight_expression (const char                *expr,
+                              const MetaPositionExprEnv *env,
+                              int                       *val_return,
+                              GError                   **err)
+{
+  PosToken *tokens;
+  int n_tokens;
+  int val;
+
+  if (!pos_tokenize (expr, &tokens, &n_tokens, err))
+    {
+      g_assert (err == NULL || *err != NULL);
+      return FALSE;
+    }
+
+#if 0
+  g_print ("Tokenized \"%s\" to --->\n", expr);
+  debug_print_tokens (tokens, n_tokens);
+#endif
+
+  if (pos_eval (tokens, n_tokens, env, &val, err))
+    {
+      if (val_return)
+        *val_return = val; /* weight can be 0 */
+      free_tokens (tokens, n_tokens);
+      return TRUE;
+    }
+  else
+    {
+      g_assert (err == NULL || *err != NULL);
+      free_tokens (tokens, n_tokens);
+      return FALSE;
+    }
+}
+
 /* To do this we tokenize, replace variable tokens
  * that are constants, then reassemble. The purpose
  * here is to optimize expressions so we don't do hash
@@ -2435,6 +2470,26 @@
   return retval;
 }
 
+static int
+parse_weight_unchecked (const char          *expr,
+                        MetaPositionExprEnv *env)
+{
+  int retval;
+  GError *error;
+
+  retval = 0;
+  error = NULL;
+  if (!meta_parse_weight_expression (expr, env,
+                                   &retval, &error))
+    {
+      meta_warning (_("Theme contained an expression \"%s\" that resulted in an error: %s\n"),
+                    expr, error->message);
+
+      g_error_free (error);
+    }
+
+  return retval;
+}
 
 MetaDrawOp*
 meta_draw_op_new (MetaDrawType type)
@@ -2523,6 +2578,7 @@
       g_free (op->data.line.y1);
       g_free (op->data.line.x2);
       g_free (op->data.line.y2);
+      g_free (op->data.line.width);
       break;
 
     case META_DRAW_RECTANGLE:
@@ -3221,12 +3277,14 @@
     {
     case META_DRAW_LINE:
       {
-        int x1, x2, y1, y2;
+        int width, x1, x2, y1, y2;
 
+        width = parse_weight_unchecked (op->data.line.width, env);
+        
         gc = get_gc_for_primitive (widget, drawable,
                                    op->data.line.color_spec,
                                    clip,
-                                   op->data.line.width);
+                                   width);
 
         if (op->data.line.dash_on_length > 0 &&
             op->data.line.dash_off_length > 0)
Index: src/theme.h
===================================================================
RCS file: /cvs/gnome/metacity/src/theme.h,v
retrieving revision 1.36
diff -u -r1.36 theme.h
--- src/theme.h	4 Nov 2002 17:55:56 -0000	1.36
+++ src/theme.h	4 Jan 2004 18:56:09 -0000
@@ -262,11 +262,11 @@
       MetaColorSpec *color_spec;
       int dash_on_length;
       int dash_off_length;
-      int width;
       char *x1;
       char *y1;
       char *x2;
       char *y2;
+      char *width;
     } line;
 
     struct {
Index: src/themes/Atlanta/metacity-theme-1.xml
===================================================================
RCS file: /cvs/gnome/metacity/src/themes/Atlanta/metacity-theme-1.xml,v
retrieving revision 1.10
diff -u -r1.10 metacity-theme-1.xml
--- src/themes/Atlanta/metacity-theme-1.xml	17 Nov 2002 11:54:10 -0000	1.10
+++ src/themes/Atlanta/metacity-theme-1.xml	4 Jan 2004 18:56:10 -0000
@@ -89,7 +89,7 @@
         y1="height - ButtonIPad - ThickLineWidth + 1"
         x2="width - ButtonIPad"
         y2="height - ButtonIPad - ThickLineWidth + 1"
-        width="3"/> <!-- FIXME allow a constant here -->
+        width="ThickLineWidth"/>
 </draw_ops>
 
 <draw_ops name="minimize_button_pressed">
