[gnome-themes-standard] menuitem: use SVG assets to draw menuitem radio/check



commit b521bb784a2080eb75f0131b24f26c1dc954ee64
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Jun 10 15:17:00 2011 -0400

    menuitem: use SVG assets to draw menuitem radio/check

 src/adwaita_engine.c                               |   90 --------------------
 themes/Adwaita/gtk-3.0/assets/Makefile.am          |    4 +
 .../assets/checkbox-menuitem-checked-selected.svg  |   63 ++++++++++++++
 .../gtk-3.0/assets/checkbox-menuitem-checked.svg   |   63 ++++++++++++++
 .../assets/radio-menuitem-checked-selected.svg     |   67 +++++++++++++++
 .../gtk-3.0/assets/radio-menuitem-checked.svg      |   67 +++++++++++++++
 themes/Adwaita/gtk-3.0/gtk-widgets.css             |   20 +++--
 7 files changed, 276 insertions(+), 98 deletions(-)
---
diff --git a/src/adwaita_engine.c b/src/adwaita_engine.c
index 0c84d8d..4a22871 100644
--- a/src/adwaita_engine.c
+++ b/src/adwaita_engine.c
@@ -213,41 +213,6 @@ adwaita_engine_render_focus (GtkThemingEngine *engine,
 }
 
 static void
-render_check_menuitem (GtkThemingEngine *engine,
-                       cairo_t *cr,
-                       gdouble x,
-                       gdouble y,
-                       gdouble width,
-                       gdouble height)
-{
-  GdkRGBA color;
-  GtkStateFlags state;
-
-  state = gtk_theming_engine_get_state (engine);
-  gtk_theming_engine_get_color (engine, state, &color);
-
-  if (!(state & GTK_STATE_FLAG_ACTIVE))
-    return;
-
-  cairo_save (cr);
-
-  cairo_translate (cr, x, y);
-
-  cairo_set_line_width (cr, 2.0);
-  cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
-  cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
-
-  cairo_move_to (cr, 0.5 + (width * 0.08), (height * 0.67));
-  cairo_line_to (cr, 0.5 + (width * 0.32), (height * 0.90));
-  cairo_line_to (cr, 0.5 + (width * 0.80), (height * 0.33));
-
-  gdk_cairo_set_source_rgba (cr, &color);
-  cairo_stroke (cr);
-
-  cairo_restore (cr);
-}
-
-static void
 adwaita_engine_render_check (GtkThemingEngine *engine,
                              cairo_t          *cr,
                              gdouble           x,
@@ -255,57 +220,11 @@ adwaita_engine_render_check (GtkThemingEngine *engine,
                              gdouble           width,
                              gdouble           height)
 {
-  gboolean res;
-
-  if (gtk_theming_engine_has_class (engine,
-                                    GTK_STYLE_CLASS_MENUITEM))
-    {
-      render_check_menuitem (engine, cr,
-                             x, y, width, height);
-
-      return;
-    }
-
   GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
     (engine, cr, x, y, width, height);
 }
 
 static void
-render_radio_menuitem (GtkThemingEngine *engine,
-                       cairo_t *cr,
-                       gdouble x,
-                       gdouble y,
-                       gdouble width,
-                       gdouble height)
-{
-  GdkRGBA color;
-  GtkStateFlags state;
-  double radius;
-
-  state = gtk_theming_engine_get_state (engine);
-
-  if (!(state & GTK_STATE_FLAG_ACTIVE))
-    return;
-
-  gtk_theming_engine_get_color (engine, state, &color);
-
-  radius = MAX (height / 2.0, width / 2.0) * 0.58;
-
-  cairo_save (cr);
-
-  cairo_translate (cr, x + width / 2.0, y + height * 0.67);
-  cairo_arc (cr,
-             0, 0,
-             radius,
-             0, 4 * G_PI);
-
-  gdk_cairo_set_source_rgba (cr, &color);
-  cairo_fill (cr);
-
-  cairo_restore (cr);
-}
-
-static void
 adwaita_engine_render_option (GtkThemingEngine *engine,
                               cairo_t          *cr,
                               gdouble           x,
@@ -313,15 +232,6 @@ adwaita_engine_render_option (GtkThemingEngine *engine,
                               gdouble           width,
                               gdouble           height)
 {
-  gboolean res;
-
-  if (gtk_theming_engine_has_class (engine,
-                                    GTK_STYLE_CLASS_MENUITEM))
-    {
-      render_radio_menuitem (engine, cr, x, y, width, height);
-      return;
-    }
-
   GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
       (engine, cr, x, y, width, height);
 }
diff --git a/themes/Adwaita/gtk-3.0/assets/Makefile.am b/themes/Adwaita/gtk-3.0/assets/Makefile.am
index 5efdec0..b13d3b0 100644
--- a/themes/Adwaita/gtk-3.0/assets/Makefile.am
+++ b/themes/Adwaita/gtk-3.0/assets/Makefile.am
@@ -10,6 +10,8 @@ assets_DATA = 		\
 	checkbox-unchecked-insensitive-dark.svg \
 	checkbox-mixed.svg \
 	checkbox-mixed-dark.svg \
+	checkbox-menuitem-checked.svg \
+	checkbox-menuitem-checked-selected.svg \
 	entry-border-focused.svg \
 	entry-border-focused-dark.svg \
 	entry-border-normal.svg \
@@ -27,6 +29,8 @@ assets_DATA = 		\
 	radio-unselected-insensitive-dark.svg \
 	radio-mixed.svg \
 	radio-mixed-dark.svg \
+	radio-menuitem-checked.svg \
+	radio-menuitem-checked-selected.svg \
 	scale-slider-horizontal.svg \
 	scale-slider-horizontal-dark.svg \
 	scale-slider-horizontal-insensitive.svg \
diff --git a/themes/Adwaita/gtk-3.0/assets/checkbox-menuitem-checked-selected.svg b/themes/Adwaita/gtk-3.0/assets/checkbox-menuitem-checked-selected.svg
new file mode 100644
index 0000000..721c4d2
--- /dev/null
+++ b/themes/Adwaita/gtk-3.0/assets/checkbox-menuitem-checked-selected.svg
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="12"
+   height="12"
+   id="svg26761"
+   version="1.1"
+   inkscape:version="0.48.1 r9760"
+   sodipodi:docname="checkbox-menuitem-checked-selected.svg">
+  <defs
+     id="defs26763" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="22.197802"
+     inkscape:cx="-0.15396047"
+     inkscape:cy="8"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:grid-bbox="true"
+     inkscape:document-units="px"
+     inkscape:window-width="1280"
+     inkscape:window-height="743"
+     inkscape:window-x="0"
+     inkscape:window-y="26"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata26766">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="layer1"
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     transform="translate(0,-4)">
+    <path
+       sodipodi:nodetypes="ccc"
+       d="M 1,11.785715 3.9948567,15 11,7.5000002"
+       style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline;enable-background:new"
+       id="path6301-5"
+       inkscape:connector-curvature="0" />
+  </g>
+</svg>
diff --git a/themes/Adwaita/gtk-3.0/assets/checkbox-menuitem-checked.svg b/themes/Adwaita/gtk-3.0/assets/checkbox-menuitem-checked.svg
new file mode 100644
index 0000000..6143ce3
--- /dev/null
+++ b/themes/Adwaita/gtk-3.0/assets/checkbox-menuitem-checked.svg
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="12"
+   height="12"
+   id="svg26761"
+   version="1.1"
+   inkscape:version="0.48.1 r9760"
+   sodipodi:docname="checkbox-menuitem-checked.svg">
+  <defs
+     id="defs26763" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="22.197802"
+     inkscape:cx="-0.15396047"
+     inkscape:cy="8"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:grid-bbox="true"
+     inkscape:document-units="px"
+     inkscape:window-width="1280"
+     inkscape:window-height="743"
+     inkscape:window-x="0"
+     inkscape:window-y="26"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata26766">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="layer1"
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     transform="translate(0,-4)">
+    <path
+       sodipodi:nodetypes="ccc"
+       d="M 1,11.785715 3.9948567,15 11,7.5000002"
+       style="fill:none;stroke:#aaaaaa;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline;enable-background:new"
+       id="path6301-5"
+       inkscape:connector-curvature="0" />
+  </g>
+</svg>
diff --git a/themes/Adwaita/gtk-3.0/assets/radio-menuitem-checked-selected.svg b/themes/Adwaita/gtk-3.0/assets/radio-menuitem-checked-selected.svg
new file mode 100644
index 0000000..162a142
--- /dev/null
+++ b/themes/Adwaita/gtk-3.0/assets/radio-menuitem-checked-selected.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="12"
+   height="12"
+   id="svg27352"
+   version="1.1"
+   inkscape:version="0.48.1 r9760"
+   sodipodi:docname="radio-menuitem-checked-selected.svg">
+  <defs
+     id="defs27354" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="22.197802"
+     inkscape:cx="-0.15396047"
+     inkscape:cy="8"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:grid-bbox="true"
+     inkscape:document-units="px"
+     inkscape:window-width="1280"
+     inkscape:window-height="743"
+     inkscape:window-x="0"
+     inkscape:window-y="26"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata27357">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="layer1"
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     transform="translate(0,-4)">
+    <path
+       sodipodi:type="arc"
+       style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.27423298;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+       id="path5784-4"
+       sodipodi:cx="660.96808"
+       sodipodi:cy="255.0668"
+       sodipodi:rx="4.5078058"
+       sodipodi:ry="7.2937827"
+       d="m 665.47588,255.0668 a 4.5078058,7.2937827 0 1 1 -9.01561,0 4.5078058,7.2937827 0 1 1 9.01561,0 z"
+       transform="matrix(0.77643096,0,0,0.47986074,-508.19608,-110.89654)" />
+  </g>
+</svg>
diff --git a/themes/Adwaita/gtk-3.0/assets/radio-menuitem-checked.svg b/themes/Adwaita/gtk-3.0/assets/radio-menuitem-checked.svg
new file mode 100644
index 0000000..ee3c65f
--- /dev/null
+++ b/themes/Adwaita/gtk-3.0/assets/radio-menuitem-checked.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="12"
+   height="12"
+   id="svg27352"
+   version="1.1"
+   inkscape:version="0.48.1 r9760"
+   sodipodi:docname="radio-menuitem-checked.svg">
+  <defs
+     id="defs27354" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="22.197802"
+     inkscape:cx="-0.15396047"
+     inkscape:cy="8"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:grid-bbox="true"
+     inkscape:document-units="px"
+     inkscape:window-width="1280"
+     inkscape:window-height="743"
+     inkscape:window-x="0"
+     inkscape:window-y="26"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata27357">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="layer1"
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     transform="translate(0,-4)">
+    <path
+       sodipodi:type="arc"
+       style="color:#000000;fill:#aaa8ac;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.27423298;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+       id="path5784-4"
+       sodipodi:cx="660.96808"
+       sodipodi:cy="255.0668"
+       sodipodi:rx="4.5078058"
+       sodipodi:ry="7.2937827"
+       d="m 665.47588,255.0668 a 4.5078058,7.2937827 0 1 1 -9.01561,0 4.5078058,7.2937827 0 1 1 9.01561,0 z"
+       transform="matrix(0.77643096,0,0,0.47986074,-508.19608,-110.89654)" />
+  </g>
+</svg>
diff --git a/themes/Adwaita/gtk-3.0/gtk-widgets.css b/themes/Adwaita/gtk-3.0/gtk-widgets.css
index 8d9aedb..aa15166 100644
--- a/themes/Adwaita/gtk-3.0/gtk-widgets.css
+++ b/themes/Adwaita/gtk-3.0/gtk-widgets.css
@@ -628,21 +628,25 @@ GtkTreeMenu .menuitem * {
     -GtkWidget-separator-height: 1;
 }
 
-/* menu radio and check items are drawn differently */
+.menuitem.check,
+.menuitem.radio {
+    background-image: none;
+}
+
 .menuitem.check:active {
-    color: @menu_controls_color;
+    background-image: url("assets/checkbox-menuitem-checked.svg");
 }
 
-.menuitem.radio:active {
-    color: @menu_controls_color;
+.menuitem.check:active:prelight {
+    background-image: url("assets/checkbox-menuitem-checked-selected.svg");
 }
 
-.menuitem.check:prelight {
-    color: @theme_selected_fg_color;
+.menuitem.radio:active {
+    background-image: url("assets/radio-menuitem-checked.svg");
 }
 
-.menuitem.radio:prelight {
-    color: @theme_selected_fg_color;
+.menuitem.radio:active:prelight {
+    background-image: url("assets/radio-menuitem-checked-selected.svg");
 }
 
 /****************



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