]> Pileus Git - ~andy/gtk/commitdiff
Apply a patch by Alexander Nedotsukov to support customized drawing of
authorMatthias Clasen <mclasen@redhat.com>
Mon, 16 Jan 2006 19:53:10 +0000 (19:53 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 16 Jan 2006 19:53:10 +0000 (19:53 +0000)
2006-01-16  Matthias Clasen  <mclasen@redhat.com>

* pixbuf-draw.c:
* pixbuf-rc-style.c:
* pixbuf.h: Apply a patch by Alexander Nedotsukov to
support customized drawing of expanders and resize
grips. (#325289).

modules/engines/pixbuf/ChangeLog
modules/engines/pixbuf/pixbuf-draw.c
modules/engines/pixbuf/pixbuf-rc-style.c
modules/engines/pixbuf/pixbuf.h

index 882fe796a7d4bdd3c7400db6dd0263217664564a..77b47f4befaefac3687034ec41f2cc5b7d50da9c 100644 (file)
@@ -1,5 +1,11 @@
 2006-01-16  Matthias Clasen  <mclasen@redhat.com>
 
+       * pixbuf-draw.c:
+       * pixbuf-rc-style.c:
+       * pixbuf.h: Apply a patch by Alexander Nedotsukov to
+       support customized drawing of expanders and resize 
+       grips. (#325289). 
+
        * pixbuf-draw.c (draw_gap_image): Silence the 
        compiler.
 
index 13b84e029531c18a3c4ad6035ed291fabc6be414..60cbefc9056099806024278c93f3878e1f10d0c1 100644 (file)
@@ -76,6 +76,14 @@ match_theme_image (GtkStyle       *style,
          match_data->gap_side != image->match_data.gap_side)
        continue;
 
+      if ((flags & THEME_MATCH_EXPANDER_STYLE) &&
+         match_data->expander_style != image->match_data.expander_style)
+       continue;
+
+      if ((flags & THEME_MATCH_WINDOW_EDGE) &&
+         match_data->window_edge != image->match_data.window_edge)
+       continue;
+
       if (image->match_data.detail &&
          (!match_data->detail ||
           strcmp (match_data->detail, image->match_data.detail) != 0))
@@ -983,6 +991,83 @@ draw_handle (GtkStyle      *style,
                               x, y, width, height, orientation);
 }
 
+static void
+draw_expander (GtkStyle      *style,
+              GdkWindow     *window,
+              GtkStateType   state,
+              GdkRectangle  *area,
+              GtkWidget     *widget,
+              const gchar   *detail,
+              gint           x,
+              gint           y,
+              GtkExpanderStyle expander_style)
+{
+#define DEFAULT_EXPANDER_SIZE 12
+
+  ThemeMatchData match_data;
+  gint expander_size;
+  gint radius;
+  
+  g_return_if_fail (style != NULL);
+  g_return_if_fail (window != NULL);
+
+  if (widget &&
+      gtk_widget_class_find_style_property (GTK_WIDGET_GET_CLASS (widget),
+                                            "expander-size"))
+    {
+      gtk_widget_style_get (widget,
+                           "expander-size", &expander_size,
+                           NULL);
+    }
+  else
+    expander_size = DEFAULT_EXPANDER_SIZE;
+
+  radius = expander_size/2;
+
+  match_data.function = TOKEN_D_EXPANDER;
+  match_data.detail = (gchar *)detail;
+  match_data.flags = (THEME_MATCH_STATE | 
+                     THEME_MATCH_EXPANDER_STYLE);
+  match_data.state = state;
+  match_data.expander_style = expander_style;
+
+  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+                         x - radius, y - radius, expander_size, expander_size))
+    parent_class->draw_expander (style, window, state, area, widget, detail,
+                                x, y, expander_style);
+}
+
+static void
+draw_resize_grip (GtkStyle      *style,
+                    GdkWindow     *window,
+                    GtkStateType   state,
+                    GdkRectangle  *area,
+                    GtkWidget     *widget,
+                    const gchar   *detail,
+                    GdkWindowEdge  edge,
+                    gint           x,
+                    gint           y,
+                    gint           width,
+                    gint           height)
+{
+  ThemeMatchData match_data;
+  
+  g_return_if_fail (style != NULL);
+  g_return_if_fail (window != NULL);
+
+  match_data.function = TOKEN_D_RESIZE_GRIP;
+  match_data.detail = (gchar *)detail;
+  match_data.flags = (THEME_MATCH_STATE | 
+                     THEME_MATCH_WINDOW_EDGE);
+  match_data.state = state;
+  match_data.window_edge = edge;
+
+  if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
+                         x, y, width, height))
+    parent_class->draw_resize_grip (style, window, state, area, widget, detail,
+                                   edge, x, y, width, height);
+}
+
 GType pixbuf_type_style = 0;
 
 void
@@ -1036,4 +1121,6 @@ pixbuf_style_class_init (PixbufStyleClass *klass)
   style_class->draw_focus = draw_focus;
   style_class->draw_slider = draw_slider;
   style_class->draw_handle = draw_handle;
+  style_class->draw_expander = draw_expander;
+  style_class->draw_resize_grip = draw_resize_grip;
 }
index e688927c580b134027d39e24091033c3f768fb6f..29019f7c3cc9ad1ebcb85659315f7f5d4c2da1db 100644 (file)
@@ -64,6 +64,8 @@ theme_symbols[] =
   { "overlay_stretch",         TOKEN_OVERLAY_STRETCH },
   { "arrow_direction",         TOKEN_ARROW_DIRECTION },
   { "orientation",     TOKEN_ORIENTATION },
+  { "expander_style",  TOKEN_EXPANDER_STYLE },
+  { "window_edge",     TOKEN_WINDOW_EDGE },
 
   { "HLINE",           TOKEN_D_HLINE },
   { "VLINE",           TOKEN_D_VLINE },
@@ -88,6 +90,8 @@ theme_symbols[] =
   { "ENTRY",           TOKEN_D_ENTRY },
   { "HANDLE",          TOKEN_D_HANDLE },
   { "STEPPER",         TOKEN_D_STEPPER },
+  { "EXPANDER",                TOKEN_D_EXPANDER },
+  { "RESIZE_GRIP",     TOKEN_D_RESIZE_GRIP },
 
   { "TRUE",            TOKEN_TRUE },
   { "FALSE",           TOKEN_FALSE },
@@ -110,8 +114,23 @@ theme_symbols[] =
   { "OUT",             TOKEN_OUT },
   { "ETCHED_IN",       TOKEN_ETCHED_IN },
   { "ETCHED_OUT",      TOKEN_ETCHED_OUT },
+
   { "HORIZONTAL",      TOKEN_HORIZONTAL },
   { "VERTICAL",                TOKEN_VERTICAL },
+
+  { "COLLAPSED",       TOKEN_COLLAPSED },
+  { "SEMI_COLLAPSED",  TOKEN_SEMI_COLLAPSED },
+  { "SEMI_EXPANDED",   TOKEN_SEMI_EXPANDED },
+  { "EXPANDED",                TOKEN_EXPANDED },
+
+  { "NORTH_WEST",      TOKEN_NORTH_WEST },
+  { "NORTH",           TOKEN_NORTH },
+  { "NORTH_EAST",      TOKEN_NORTH_EAST },
+  { "WEST",            TOKEN_WEST },
+  { "EAST",            TOKEN_EAST },
+  { "SOUTH_WEST",      TOKEN_SOUTH_WEST },
+  { "SOUTH",           TOKEN_SOUTH },
+  { "SOUTH_EAST",      TOKEN_SOUTH_EAST }
 };
 
 static GtkRcStyleClass *parent_class;
@@ -332,7 +351,7 @@ theme_parse_function(GScanner * scanner,
     return G_TOKEN_EQUAL_SIGN;
 
   token = g_scanner_get_next_token(scanner);
-  if ((token >= TOKEN_D_HLINE) && (token <= TOKEN_D_STEPPER))
+  if ((token >= TOKEN_D_HLINE) && (token <= TOKEN_D_RESIZE_GRIP))
     data->match_data.function = token;
 
   return G_TOKEN_NONE;
@@ -521,6 +540,76 @@ theme_parse_orientation(GScanner * scanner,
   return G_TOKEN_NONE;
 }
 
+static guint
+theme_parse_expander_style(GScanner * scanner,
+                          ThemeImage * data)
+{
+  guint               token;
+
+  token = g_scanner_get_next_token(scanner);
+  if (token != TOKEN_EXPANDER_STYLE)
+    return TOKEN_EXPANDER_STYLE;
+
+  token = g_scanner_get_next_token(scanner);
+  if (token != G_TOKEN_EQUAL_SIGN)
+    return G_TOKEN_EQUAL_SIGN;
+
+  token = g_scanner_get_next_token(scanner);
+  if (token == TOKEN_COLLAPSED)
+    data->match_data.expander_style = GTK_EXPANDER_COLLAPSED;
+  else if (token == TOKEN_SEMI_COLLAPSED)
+    data->match_data.expander_style = GTK_EXPANDER_SEMI_COLLAPSED;
+  else if (token == TOKEN_SEMI_EXPANDED)
+    data->match_data.expander_style = GTK_EXPANDER_SEMI_EXPANDED;
+  else if (token == TOKEN_EXPANDED)
+    data->match_data.expander_style = GTK_EXPANDER_EXPANDED;
+  else
+    return TOKEN_COLLAPSED;
+
+  data->match_data.flags |= THEME_MATCH_EXPANDER_STYLE;
+
+  return G_TOKEN_NONE;
+}
+
+static guint
+theme_parse_window_edge(GScanner * scanner,
+                       ThemeImage * data)
+{
+  guint               token;
+
+  token = g_scanner_get_next_token(scanner);
+  if (token != TOKEN_WINDOW_EDGE)
+    return TOKEN_WINDOW_EDGE;
+
+  token = g_scanner_get_next_token(scanner);
+  if (token != G_TOKEN_EQUAL_SIGN)
+    return G_TOKEN_EQUAL_SIGN;
+
+  token = g_scanner_get_next_token(scanner);
+  if (token == TOKEN_NORTH_WEST)
+    data->match_data.window_edge = GDK_WINDOW_EDGE_NORTH_WEST;
+  else if (token == TOKEN_NORTH)
+    data->match_data.window_edge = GDK_WINDOW_EDGE_NORTH;
+  else if (token == TOKEN_NORTH_EAST)
+    data->match_data.window_edge = GDK_WINDOW_EDGE_NORTH_EAST;
+  else if (token == TOKEN_WEST)
+    data->match_data.window_edge = GDK_WINDOW_EDGE_WEST;
+  else if (token == TOKEN_EAST)
+    data->match_data.window_edge = GDK_WINDOW_EDGE_EAST;
+  else if (token == TOKEN_SOUTH_WEST)
+    data->match_data.window_edge = GDK_WINDOW_EDGE_SOUTH_WEST;
+  else if (token == TOKEN_SOUTH)
+    data->match_data.window_edge = GDK_WINDOW_EDGE_SOUTH;
+  else if (token == TOKEN_SOUTH_EAST)
+    data->match_data.window_edge = GDK_WINDOW_EDGE_SOUTH_EAST;
+  else
+    return TOKEN_NORTH_WEST;
+
+  data->match_data.flags |= THEME_MATCH_WINDOW_EDGE;
+
+  return G_TOKEN_NONE;
+}
+
 static void
 theme_image_ref (ThemeImage *data)
 {
@@ -648,6 +737,12 @@ theme_parse_image(GtkSettings  *settings,
        case TOKEN_OVERLAY_STRETCH:
          token = theme_parse_stretch(scanner, &data->overlay);
          break;
+       case TOKEN_EXPANDER_STYLE:
+         token = theme_parse_expander_style(scanner, data);
+         break;
+       case TOKEN_WINDOW_EDGE:
+         token = theme_parse_window_edge(scanner, data);
+         break;
        default:
          g_scanner_get_next_token(scanner);
          token = G_TOKEN_RIGHT_CURLY;
index 5d3b32e126d59323f6926f549f6b80f4ac14d702..e0289955aaba7e3712b9001767f891bbcc012f5c 100644 (file)
@@ -52,6 +52,8 @@ enum
   TOKEN_OVERLAY_BORDER,
   TOKEN_OVERLAY_STRETCH,
   TOKEN_ARROW_DIRECTION,
+  TOKEN_EXPANDER_STYLE,
+  TOKEN_WINDOW_EDGE,
   TOKEN_D_HLINE,
   TOKEN_D_VLINE,
   TOKEN_D_SHADOW,
@@ -75,6 +77,8 @@ enum
   TOKEN_D_ENTRY,
   TOKEN_D_HANDLE,
   TOKEN_D_STEPPER,
+  TOKEN_D_EXPANDER,
+  TOKEN_D_RESIZE_GRIP,
   TOKEN_TRUE,
   TOKEN_FALSE,
   TOKEN_TOP,
@@ -95,7 +99,19 @@ enum
   TOKEN_ETCHED_OUT,
   TOKEN_ORIENTATION,
   TOKEN_HORIZONTAL,
-  TOKEN_VERTICAL
+  TOKEN_VERTICAL,
+  TOKEN_COLLAPSED,
+  TOKEN_SEMI_COLLAPSED,
+  TOKEN_SEMI_EXPANDED,
+  TOKEN_EXPANDED,
+  TOKEN_NORTH_WEST,
+  TOKEN_NORTH,
+  TOKEN_NORTH_EAST,
+  TOKEN_WEST,
+  TOKEN_EAST,
+  TOKEN_SOUTH_WEST,
+  TOKEN_SOUTH,
+  TOKEN_SOUTH_EAST
 };
 
 typedef enum
@@ -117,7 +133,9 @@ typedef enum {
   THEME_MATCH_ORIENTATION     = 1 << 1,
   THEME_MATCH_STATE           = 1 << 2,
   THEME_MATCH_SHADOW          = 1 << 3,
-  THEME_MATCH_ARROW_DIRECTION = 1 << 4
+  THEME_MATCH_ARROW_DIRECTION = 1 << 4,
+  THEME_MATCH_EXPANDER_STYLE  = 1 << 5,
+  THEME_MATCH_WINDOW_EDGE     = 1 << 6
 } ThemeMatchFlags;
 
 typedef enum {
@@ -140,16 +158,18 @@ struct _ThemePixbuf
 
 struct _ThemeMatchData
 {
-  guint           function;    /* Mandatory */
-  gchar          *detail;
-
-  ThemeMatchFlags flags;
-
-  GtkPositionType gap_side;
-  GtkOrientation  orientation;
-  GtkStateType    state;
-  GtkShadowType   shadow;
-  GtkArrowType    arrow_direction;
+  guint            function;   /* Mandatory */
+  gchar           *detail;
+
+  ThemeMatchFlags  flags;
+
+  GtkPositionType  gap_side;
+  GtkOrientation   orientation;
+  GtkStateType     state;
+  GtkShadowType    shadow;
+  GtkArrowType     arrow_direction;
+  GtkExpanderStyle expander_style;
+  GdkWindowEdge    window_edge;
 };
 
 struct _ThemeImage