diff --git a/src/style.css b/src/style.css index 25359beedff93450a4d55a9e3eb178941b8d355d..990b00d81929c5c74a9f7bfea4983ae0331aa6a9 100644 --- a/src/style.css +++ b/src/style.css @@ -45,7 +45,7 @@ colour-view .wallpaper label:backdrop { background-image: url('resource://org/gnome/IconPreview/wallpapers/Adwaita-dark.jpg'); } -colour-view image, .initial-state .shadow-icon { +colour-view image:not(.symbolic), .initial-state .shadow-icon { -gtk-icon-shadow: 0 1px 2px rgba(0,0,0,0.4), 0 1px 8px rgba(0,0,0,0.2); } diff --git a/src/templates/colour.svg b/src/templates/colour.svg index c68576bfc45522d6187ce226552b1f0e081d68e5..328a68b3163cc5d97d1825f514060b59330fc572 100644 --- a/src/templates/colour.svg +++ b/src/templates/colour.svg @@ -13,16 +13,16 @@ inkscape:export-ydpi="96" inkscape:export-xdpi="96" inkscape:export-filename="Template.png" - width="128" - height="128" + width="192" + height="152" id="svg11300" sodipodi:version="0.32" - inkscape:version="0.92.3 (2405546, 2018-03-11)" + inkscape:version="0.92.4 (5da689c313, 2019-01-14)" sodipodi:docname="template.svg" inkscape:output_extension="org.inkscape.output.svg.inkscape" version="1.0" style="display:inline;enable-background:new" - viewBox="0 0 128 128"> + viewBox="0 0 192 152"> Adwaita Icon Template - - @@ -580,6 +561,25 @@ y1="619.96387" x2="568" y2="619.96387" /> + + + inkscape:snap-text-baseline="true" + borderlayer="true"> + originx="8" + originy="8" /> + dotted="true" + originx="8" + originy="8" /> + transform="translate(8,-156)"> + + + + + inkscape:label="0" /> Hicolor + y="167">Hicolor - - - - - - - + + + + + + + @@ -2928,7 +2954,7 @@ inkscape:connector-curvature="0" id="path26035" d="m 55,196 h 18 c 1.662,0 3,1 3,3 v 5 H 72.03125 L 72,200 H 56 l 0.03125,4 H 52 v -5 c 0,-1.662 1.338,-3 3,-3 z" - style="opacity:1;vector-effect:none;fill:url(#linearGradient1694);fill-opacity:1;stroke:none;stroke-width:0.01184966px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal" /> + style="opacity:1;vector-effect:none;fill:url(#linearGradient1278);fill-opacity:1;stroke:none;stroke-width:0.01184966px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal" /> org.gnome.IconPreview - 2 + 3 0 + + + True + False + 128 + + + 3 + 1 + + True @@ -39,10 +50,21 @@ org.gnome.IconPreview - 1 + 2 0 + + + True + False + 64 + + + 2 + 1 + + True @@ -53,7 +75,7 @@ org.gnome.IconPreview - 0 + 1 0 @@ -64,29 +86,35 @@ 32 - 0 + 1 1 - + True False - 128 + center + end + 16 + org.gnome.IconPreview-symbolic + - 2 - 1 + 0 + 0 True False - 64 + symbolic - 1 + 0 1 diff --git a/src/views/colourpane.vala b/src/views/colourpane.vala index e872f137160822dac6a99fb8cec2a479432f4b45..8c9d08d4f2f2d8d4ad08bd52db0ccda961077398 100644 --- a/src/views/colourpane.vala +++ b/src/views/colourpane.vala @@ -4,10 +4,10 @@ namespace IconPreview { public class DemoIcon : Box { private Image image = new Image(); private Label label = new Label(null); + public File ?file { get; construct set; } + public string ?name { get; set; } - public Icon icon { get; set; } public int size { get; construct set; default = 96; } - class construct { set_css_name("demo-icon"); } @@ -21,13 +21,14 @@ namespace IconPreview { label.ellipsize = END; label.max_width_chars = 30; - bind_property("icon", image, "gicon"); bind_property("size", image, "pixel_size"); - notify["icon"].connect(() => { - var basename = Path.get_basename(IconTheme.get_default().lookup_by_gicon(icon, 96, FORCE_SVG).get_filename()); - var parts = basename.split("."); - label.label = parts[parts.length - 2]; - label.tooltip_text = basename; + notify["file"].connect((s, p) => { + if (name != null) { + var parts = name.split("."); + label.label = parts[parts.length - 2]; + label.tooltip_text = name; + image.gicon = new FileIcon(file); + } }); pack_start(image); @@ -53,7 +54,9 @@ namespace IconPreview { CssProvider provider = null; List randoms; - public Icon icon { get; set; default = new ThemedIcon("start-here-symbolic");} + public File hicolor { get; set; } + public File ?symbolic { get; set; } + public string name { get; set; } private string _theme = "Adwaita"; public string theme { @@ -83,9 +86,33 @@ namespace IconPreview { construct { DemoIcon ico; - for (var i = 0; i < 3; i++) { - bind_property("icon", sizes.get_child_at(i, 0), "gicon"); - } + notify["hicolor"].connect(() => { + if (symbolic == null) { + //hide the symbolic icon in the preview + sizes.get_child_at(0, 0).hide(); + sizes.get_child_at(0, 1).hide(); + } + FileIcon icon = new FileIcon(hicolor); + // Three different sizes {32, 64, 128}; + for (var i = 0; i < 3; i++) { + var image = sizes.get_child_at(i + 1, 0) as Image; + image.set_from_gicon(icon, BUTTON); + } + }); + + notify["symbolic"].connect(() => { + if (symbolic != null) { + sizes.get_child_at(0, 1).show(); + var image = sizes.get_child_at(0, 0) as Image; + image.show(); + FileIcon icon = new FileIcon(symbolic); + image.set_from_gicon(icon, BUTTON); + } else { + //hide the symbolic icon in the preview + sizes.get_child_at(0, 0).hide(); + sizes.get_child_at(0, 1).hide(); + } + }); /* 64px */ for (var i = 0; i < 2; i++) { @@ -94,8 +121,10 @@ namespace IconPreview { randoms.append(ico); } + /* add 64x64 users icon preivew */ ico = new DemoIcon(64); - bind_property("icon", ico, "icon"); + bind_property("hicolor", ico, "file"); + bind_property("name", ico, "name"); small.add(ico); for (var i = 3; i < 5; i++) { @@ -112,8 +141,10 @@ namespace IconPreview { grid.add(ico); randoms.append(ico); + /* add 96x96 users icon preivew */ ico = new DemoIcon(96); - bind_property("icon", ico, "icon"); + bind_property("hicolor", ico, "file"); + bind_property("name", ico, "name"); grid.add(ico); ico = new DemoIcon(96); @@ -125,11 +156,12 @@ namespace IconPreview { theme = theme; } - public void load_samples (Icon[] samples) requires (samples.length == randoms.length()) { + public void load_samples (File[] samples) requires (samples.length == randoms.length()) { // Don't like how much of this is hardcoded var idx = 0; foreach (var sample in randoms) { - sample.icon = samples[idx]; + sample.name = samples[idx].get_basename(); + sample.file = samples[idx]; idx++; } } diff --git a/src/views/symbolicpane.vala b/src/views/symbolicpane.vala index 1a36b43ed411d25a0fa4887a6f25ef647f42acb6..a9e5157e04a1ea08ac3671f5eb0209b17c5f5777 100644 --- a/src/views/symbolicpane.vala +++ b/src/views/symbolicpane.vala @@ -37,7 +37,10 @@ namespace IconPreview { return _theme; } set { + var context = get_style_context(); + context.remove_class("theme-" + _theme); _theme = value; + context.add_class("theme-" + _theme); var parts = _theme.split("-"); if (parts.length > 1 && parts[1] == "dark") { provider = CssProvider.get_named(parts[0], "dark"); diff --git a/src/window.vala b/src/window.vala index c35537593fd1dc59655b9a0cba7a8b29a82457df..c1a27b1102412d437ca11fd5b78e92596f2b7166 100644 --- a/src/window.vala +++ b/src/window.vala @@ -37,20 +37,19 @@ namespace IconPreview { // Hopefully this doesn't render the SVG? var svg = new Rsvg.Handle.from_gfile_sync(value, FLAGS_NONE); - var width = 0; - var height = 0; + Rsvg.Rectangle hicolor = { 0.0, 0.0, svg.width, svg.height }; - // Rsvg.Rectangle logical; - // svg.get_geometry_sub(null, out logical, null); - - width = svg.width; - height = svg.height; + Rsvg.Rectangle viewport = { 0.0, 0.0, svg.width, svg.height }; + if (svg.has_sub("#hicolor")) { + svg.get_geometry_for_element("#hicolor", viewport, null ,out hicolor); + } - // Colour (App) icons must be 128 by 128 - if (height == 128 && width == 128) { + // Colour (App) icons must be 128 by 128 and + // and can contain a simbolic icon + if (hicolor.height == 128 && hicolor.width == 128) { mode = COLOUR; // Whereas symbolics are 16 by 16 - } else if (height == 16 && width == 16) { + } else if (svg.height == 16 && svg.width == 16) { mode = SYMBOLIC; // And anything else is unsupported } else {