Commit 4c1f3bab authored by Julian Sparber's avatar Julian Sparber Committed by Zander

Read symbolic and hicolor from same file

parent bf7ae4a5
Pipeline #81368 passed with stage
in 2 minutes and 38 seconds
......@@ -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);
}
......
......@@ -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">
<title
id="title4162">Adwaita Icon Template</title>
<defs
......@@ -346,25 +346,6 @@
offset="1"
id="stop1243" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient1697"
id="linearGradient1694"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(2,-22)"
x1="50"
y1="238"
x2="74"
y2="238" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient1245"
id="linearGradient1696"
gradientUnits="userSpaceOnUse"
x1="65"
y1="204"
x2="65"
y2="200" />
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath1289">
......@@ -580,6 +561,25 @@
y1="619.96387"
x2="568"
y2="619.96387" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient1697"
id="linearGradient1278"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(2,-22)"
x1="50"
y1="238"
x2="74"
y2="238" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient1245"
id="linearGradient1280"
gradientUnits="userSpaceOnUse"
x1="65"
y1="204"
x2="65"
y2="200" />
</defs>
<sodipodi:namedview
stroke="#ef2929"
......@@ -590,10 +590,10 @@
borderopacity="0.25490196"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1"
inkscape:cx="-51.790628"
inkscape:cy="-54.117604"
inkscape:current-layer="layer9"
inkscape:zoom="2.8284271"
inkscape:cx="-16.018274"
inkscape:cy="11.797527"
inkscape:current-layer="layer3"
showgrid="false"
inkscape:grid-bbox="true"
inkscape:document-units="px"
......@@ -623,12 +623,13 @@
inkscape:snap-intersection-paths="true"
inkscape:snap-bbox-edge-midpoints="true"
inkscape:snap-bbox-midpoints="true"
showborder="false"
showborder="true"
inkscape:snap-center="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-midpoints="true"
inkscape:snap-smooth-nodes="true"
inkscape:snap-text-baseline="true">
inkscape:snap-text-baseline="true"
borderlayer="true">
<inkscape:grid
type="xygrid"
id="grid5883"
......@@ -637,59 +638,59 @@
enabled="true"
visible="true"
empspacing="4"
originx="0"
originy="0" />
originx="8"
originy="8" />
<sodipodi:guide
position="64,8"
position="72,16"
orientation="0,1"
id="guide1073"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="12,64"
position="20,72"
orientation="1,0"
id="guide1075"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="64,104"
position="72,112"
orientation="0,1"
id="guide1099"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="64,128"
position="72,136"
orientation="0,1"
id="guide993"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="104,64"
position="112,72"
orientation="1,0"
id="guide995"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="9.2651362e-08,64"
position="8.0000001,72"
orientation="1,0"
id="guide867"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="120,64"
position="128,72"
orientation="1,0"
id="guide869"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="64,116"
position="72,124"
orientation="0,1"
id="guide871"
inkscape:locked="false"
......@@ -705,72 +706,74 @@
opacity="0.49019608"
empcolor="#000000"
empopacity="0.08627451"
dotted="true" />
dotted="true"
originx="8"
originy="8" />
<sodipodi:guide
position="24,64"
position="32,72"
orientation="1,0"
id="guide877"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="116,64"
position="124,72"
orientation="1,0"
id="guide879"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="64,120"
position="72,128"
orientation="0,1"
id="guide881"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="64,12"
position="72,20"
orientation="0,1"
id="guide883"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="8,64"
position="16,72"
orientation="1,0"
id="guide885"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="128,64"
position="136,72"
orientation="1,0"
id="guide887"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="64,0"
position="72,8"
orientation="0,1"
id="guide897"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="64,24"
position="72,32"
orientation="0,1"
id="guide899"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="256,256"
position="264,264"
orientation="-0.70710678,0.70710678"
id="guide950"
inkscape:locked="false"
inkscape:label=""
inkscape:color="rgb(0,0,255)" />
<sodipodi:guide
position="64,64"
position="72,72"
orientation="0.70710678,0.70710678"
id="guide952"
inkscape:locked="false"
......@@ -841,7 +844,30 @@
inkscape:label="App Icon"
inkscape:groupmode="layer"
style="display:inline"
transform="translate(0,-172)">
transform="translate(8,-156)">
<g
inkscape:groupmode="layer"
id="layer4"
inkscape:label="template"
style="display:inline"
sodipodi:insensitive="true">
<rect
inkscape:label="0"
y="172"
x="9.2651362e-08"
height="128"
width="128"
id="hicolor"
style="display:inline;overflow:visible;visibility:visible;fill:#f0f0f0;fill-opacity:0;fill-rule:nonzero;stroke:none;stroke-width:0.5;marker:none;enable-background:accumulate" />
<rect
style="display:inline;overflow:visible;visibility:visible;fill:#f0f0f0;fill-opacity:0;fill-rule:nonzero;stroke:none;stroke-width:0.5;marker:none;enable-background:accumulate"
id="symbolic"
width="16"
height="16"
x="160"
y="172"
inkscape:label="0" />
</g>
<g
inkscape:groupmode="layer"
id="layer2"
......@@ -1010,12 +1036,12 @@
inkscape:export-ydpi="12" />
<rect
style="display:inline;overflow:visible;visibility:visible;fill:#f0f0f0;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.5;marker:none;enable-background:accumulate"
id="rect13805"
id="128"
width="128"
height="128"
x="9.2651362e-08"
y="172"
inkscape:label="512x512" />
inkscape:label="0" />
<g
id="g883"
style="fill:none;fill-opacity:0.25098039;stroke:#a579b3;stroke-opacity:1"
......@@ -1025,33 +1051,33 @@
style="fill:none;fill-opacity:0.25098039;stroke:#a579b3;stroke-opacity:1"
transform="translate(-24,24)" />
<rect
inkscape:label="512x512"
inkscape:label=""
y="172"
x="160"
height="16"
width="16"
id="rect859"
id="16"
style="display:inline;overflow:visible;visibility:visible;fill:#f0f0f0;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.5;marker:none;enable-background:accumulate" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4px;line-height:125%;font-family:Cantarell;-inkscape-font-specification:'Cantarell, Bold';text-align:start;writing-mode:lr-tb;text-anchor:start;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.33264872;enable-background:new"
x="0"
y="164"
y="167"
id="text863"
inkscape:label="icon-name"><tspan
style="font-size:4px;stroke-width:0.33264872"
sodipodi:role="line"
id="tspan861"
x="0"
y="164">Hicolor</tspan></text>
y="167">Hicolor</tspan></text>
<text
inkscape:label="icon-name"
id="text867"
y="164"
y="167"
x="160"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4px;line-height:125%;font-family:Cantarell;-inkscape-font-specification:'Cantarell, Bold';text-align:start;writing-mode:lr-tb;text-anchor:start;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.33264872;enable-background:new"
xml:space="preserve"><tspan
y="164"
y="167"
x="160"
id="tspan865"
sodipodi:role="line"
......@@ -1361,51 +1387,6 @@
</g>
</g>
</g>
<g
inkscape:groupmode="layer"
id="layer3"
inkscape:label="hairlines"
style="display:inline"
sodipodi:insensitive="true">
<circle
cx="64.000031"
cy="236"
r="59.504131"
id="circle2892"
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
<rect
ry="7.9292889"
rx="8.701004"
y="180.49496"
x="20.495007"
height="111.01005"
width="87.009987"
id="rect2894"
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
<rect
ry="7.9238095"
rx="7.9238095"
y="184.49524"
x="12.495266"
height="103.00952"
width="103.00952"
id="rect2896"
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
<rect
ry="8.701005"
rx="7.9292889"
y="200.49496"
x="8.4950066"
height="87.010048"
width="111.01004"
id="rect2898"
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
<path
inkscape:connector-curvature="0"
id="path2900"
d="M 2.6203015e-5,288.99999 H 128.00003"
style="display:inline;fill:none;stroke:#62a0ea;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new" />
</g>
<g
inkscape:groupmode="layer"
id="layer9"
......@@ -2860,6 +2841,51 @@
</g>
</g>
</g>
<g
inkscape:groupmode="layer"
id="layer3"
inkscape:label="grid"
style="display:inline"
sodipodi:insensitive="true">
<circle
cx="64.000031"
cy="236"
r="59.504131"
id="circle2892"
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
<rect
ry="7.9292889"
rx="8.701004"
y="180.49496"
x="20.495007"
height="111.01005"
width="87.009987"
id="rect2894"
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
<rect
ry="7.9238095"
rx="7.9238095"
y="184.49524"
x="12.495266"
height="103.00952"
width="103.00952"
id="rect2896"
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
<rect
ry="8.701005"
rx="7.9292889"
y="200.49496"
x="8.4950066"
height="87.010048"
width="111.01004"
id="rect2898"
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
<path
inkscape:connector-curvature="0"
id="path2900"
d="M 2.6203015e-5,288.99999 H 128.00003"
style="display:inline;fill:none;stroke:#62a0ea;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new" />
</g>
<g
id="g1648"
transform="translate(-120.50005,-26)">
......@@ -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" />
<rect
style="opacity:0.1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect1059"
......@@ -2939,7 +2965,7 @@
ry="1.5"
rx="1.5" />
<path
style="opacity:1;fill:url(#linearGradient1696);fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:1;fill:url(#linearGradient1280);fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 55,200 c -1.662,0 -3,1.338 -3,3 v 1 h 4 v -2 h 16 v 2 h 4 v -1 c 0,-1.662 -1.338,-3 -3,-3 z"
id="rect1061"
inkscape:connector-curvature="0"
......
......@@ -16,7 +16,18 @@ namespace IconPreview {
}
set {
_icon = value;
light.icon = dark.icon = new FileIcon(_icon);
var svg = new Rsvg.Handle.from_gfile_sync(_icon, FLAGS_NONE);
var hicolor = split_svg(svg, "#hicolor");
var symbolic = split_svg(svg, "#symbolic");
light.name = dark.name = _icon.get_basename();
if (hicolor != null) {
light.hicolor = dark.hicolor = hicolor;
} else {
light.hicolor = dark.hicolor = _icon;
}
light.symbolic = dark.symbolic = symbolic;
}
}
......@@ -54,10 +65,10 @@ namespace IconPreview {
public void shuffle () {
var samples_names = random_selection(colours, 6);
var samples = new Icon[6];
var samples = new File[6];
for (var j = 0; j < 6; j++) {
samples[j] = new FileIcon(File.new_for_uri("resource:/" + RES_PATH + samples_names[j]));
samples[j] = File.new_for_uri("resource:/" + RES_PATH + samples_names[j]);
}
light.load_samples(samples);
......@@ -117,5 +128,22 @@ namespace IconPreview {
return Gdk.pixbuf_get_from_surface (surface, 0, 0, w, h);
}
private File? split_svg(Rsvg.Handle svg, string id) {
if (svg.has_sub(id)) {
FileIOStream stream;
var temp_file = File.new_tmp("XXXXXX-" + id.substring(1, -1) +".svg", out stream);
Rsvg.Rectangle size;
Rsvg.Rectangle viewport = { 0.0, 0.0, svg.width, svg.height };
svg.get_geometry_for_element(id, viewport, null, out size);
var surface = new Cairo.SvgSurface(temp_file.get_path(), 128, 128);
var cr = new Cairo.Context(surface);
cr.scale(128/size.width, 128/size.height);
cr.translate(-size.x, -size.y);
svg.render_cairo(cr);
return temp_file;
}
return null;
}
}
}
......@@ -25,10 +25,21 @@
<property name="icon_name">org.gnome.IconPreview</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="left_attach">3</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">128</property>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
......@@ -39,10 +50,21 @@
<property name="icon_name">org.gnome.IconPreview</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">64</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
......@@ -53,7 +75,7 @@
<property name="icon_name">org.gnome.IconPreview</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
......@@ -64,29 +86,35 @@
<property name="label">32</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">128</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="pixel_size">16</property>
<property name="icon_name">org.gnome.IconPreview-symbolic</property>
<style>
<class name="symbolic"/>
</style>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">64</property>
<property name="label">symbolic</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
......
......@@ -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<DemoIcon> 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++;
}
}
......
......@@ -37,7 +37,10 @@ namespace IconPreview {
return _theme;
}
set {