Commit 836d2d4b authored by Julian Sparber's avatar Julian Sparber Committed by Zander

export: add exporter

This gives functionality to the exporter dialog.
We still don't generated a nightly icon there fore it is the same as
hicolor.
parent 65d0e73c
Pipeline #110270 passed with stage
in 1 minute and 30 seconds
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="IconPreviewColourExporter" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">10</property>
<property name="label" translatable="yes">Export the icon for production use.
Off-canvas objects are removed and the SVG is optimised for size</property>
<property name="wrap">True</property>
<property name="max_width_chars">35</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">15</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage" id="regular_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="pixel_size">128</property>
<property name="icon_name">start-here-symbolic</property>
<style>
<class name="thumbnail"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="regular_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="label" translatable="yes">&lt;b&gt;Regular&lt;/b&gt; (34 kB)</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Save Regular As…</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="margin_top">10</property>
<signal name="activate" handler="regular" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage" id="nightly_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="pixel_size">128</property>
<property name="icon_name">start-here-symbolic</property>
<style>
<class name="thumbnail"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="nightly_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="label" translatable="yes">&lt;b&gt;Nightly&lt;/b&gt; (39 kB)</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Save Nightly As…</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="margin_top">10</property>
<signal name="activate" handler="nightly" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="exporter"/>
</style>
</template>
</interface>
using Gtk;
namespace IconPreview {
[GtkTemplate (ui = "/org/gnome/IconPreview/exporter/colour.ui")]
public class ColourExporter : Box, Exporter {
[GtkChild]
Image regular_image;
/*[GtkChild]
Label regular_label;*/
[GtkChild]
Image nightly_image;
/*[GtkChild]
Label nightly_label;*/
public File file { get; set; }
construct {
notify["file"].connect(() => {
regular_image.gicon = nightly_image.gicon = new FileIcon(file);
});
}
[GtkCallback]
private void regular () {
close();
}
[GtkCallback]
private void nightly () {
close();
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="IconPreviewExporter" parent="GtkPopover">
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="orientation">vertical</property>
<property name="margin">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_bottom">10</property>
<property name="label" translatable="yes">Export the icon for production use. Off-canvas objects are removed and the SVG is optimised for size</property>
<property name="justify">center</property>
<property name="wrap">True</property>
<property name="max_width_chars">28</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">15</property>
<child>
<object class="GtkBox" id="regular_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<property name="expand">True</property>
<child>
<object class="GtkImage" id="regular_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="pixel_size">128</property>
<property name="icon_name">start-here-symbolic</property>
<style>
<class name="thumbnail"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="halign">center</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Regular</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel" id="regular_size">
<property name="visible">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Save Regular as...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="margin_top">10</property>
<property name="action_name">win.export-save</property>
<property name="action_target">'regular'</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="nightly_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<property name="expand">True</property>
<child>
<object class="GtkImage" id="nightly_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="pixel_size">128</property>
<property name="icon_name">start-here-symbolic</property>
<style>
<class name="thumbnail"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="halign">center</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Nightly</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel" id="nightly_size">
<property name="visible">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Save Nightly as...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="margin_top">10</property>
<property name="action_name">win.export-save</property>
<property name="action_target">'nightly'</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="symbolic_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<property name="expand">True</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Save Symbolic as...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="margin_top">10</property>
<property name="action_name">win.export-save</property>
<property name="action_target">'symbolic'</property>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="halign">center</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Symbolic</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel" id="symbolic_size">
<property name="visible">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="symbolic_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="pixel_size">16</property>
<property name="icon_name">start-here-symbolic</property>
<style>
<class name="thumbnail"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<style>
<class name="exporter"/>
</style>
</template>
</interface>
using Gtk;
namespace IconPreview {
[GtkTemplate (ui = "/org/gnome/IconPreview/exporter/exporter.ui")]
public class Exporter : Popover {
public string name { get; set; }
[GtkChild]
Image regular_image;
[GtkChild]
Box regular_box;
[GtkChild]
Label regular_size;
[GtkChild]
Image nightly_image;
[GtkChild]
Box nightly_box;
[GtkChild]
Label nightly_size;
[GtkChild]
Image symbolic_image;
[GtkChild]
Box symbolic_box;
[GtkChild]
Label symbolic_size;
public void update_regolar(File? source) {
if (source != null) {
regular_box.show();
FileIcon icon = new FileIcon(source);
regular_image.set_from_gicon(icon, BUTTON);
regular_size.set_label (get_file_size (source));
regular_size.hide ();
} else {
regular_box.hide();
}
}
public void update_nightly(File? source) {
if (source != null) {
nightly_box.show();
FileIcon icon = new FileIcon(source);
nightly_image.set_from_gicon(icon, BUTTON);
nightly_size.set_label (get_file_size (source));
nightly_size.hide ();
} else {
nightly_box.hide();
}
}
public void update_symbolic(File? source) {
if (source != null) {
symbolic_box.show();
FileIcon icon = new FileIcon(source);
symbolic_image.set_from_gicon(icon, BUTTON);
symbolic_size.set_label (get_file_size (source));
symbolic_size.hide ();
} else {
symbolic_box.hide();
}
}
private string get_file_size (File file) {
string result = "";
try {
FileInfo info = file.query_info ("standard", 0);
result = "(" + format_size (info.get_size ()) + ")";
} catch (Error e) {
debug ("Couldn't get file size");
}
return result;
}
public File get_regular() {
return (regular_image.gicon as FileIcon).get_file();
}
public File get_nightly() {
return (nightly_image.gicon as FileIcon).get_file();
}
public File get_symbolic() {
return (symbolic_image.gicon as FileIcon).get_file();
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="IconPreviewSymbolicExporter" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">10</property>
<property name="label" translatable="yes">Export the icon for production use.
Off-canvas objects are removed and the SVG is optimised for size</property>
<property name="wrap">True</property>
<property name="max_width_chars">35</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="pixel_size">16</property>
<property name="icon_name">start-here-symbolic</property>
<style>
<class name="thumbnail"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="label" translatable="yes">&lt;b&gt;Symbolic&lt;/b&gt; (4 kB)</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Save Symbolic As…</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="margin_top">10</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<style>
<class name="exporter"/>
</style>
</template>
</interface>
using Gtk;
namespace IconPreview {
[GtkTemplate (ui = "/org/gnome/IconPreview/exporter/symbolic.ui")]
public class SymbolicExporter : Box, Exporter {
}
}
......@@ -23,7 +23,6 @@ namespace IconPreview {
public interface Previewer : Widget {
public abstract File previewing { get; set; }
public abstract Exporter exporter { owned get; }
public abstract void shuffle();
public virtual Gdk.Pixbuf screenshot () {
var w = get_allocated_width();
......@@ -35,10 +34,6 @@ namespace IconPreview {
}
}
public interface Exporter : Widget {
public signal void close();
}
public class Application : Dazzle.Application {
const GLib.ActionEntry[] entries = {
{ "new-window", new_window },
......
......@@ -16,8 +16,7 @@ sources = [
'views/colour.vala',
'views/symbolicpane.vala',
'views/symbolic.vala',
'exporter/colour.vala',
'exporter/symbolic.vala',
'exporter/exporter.vala',
'wizard.vala',
'saver.vala',
'common.vala',
......
......@@ -8,10 +8,10 @@
<file>window.ui</file>
<file alias="colourpane.ui">views/colourpane.ui</file>
<file alias="symbolicpane.ui">views/symbolicpane.ui</file>
<file>exporter/symbolic.ui</file>
<file>exporter/colour.ui</file>
<file>exporter/exporter.ui</file>
<file>templates/symbolic.svg</file>
<file>templates/colour.svg</file>
<file>templates/stripes.svg</file>
<file alias="badge.svg">../data/org.gnome.IconPreview-symbolic.svg</file>
</gresource>
<gresource prefix="/org/gnome/IconPreview/gtk/">
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="128"
height="128"
version="1.1"
id="svg16"
sodipodi:docname="strips.svg"
inkscape:version="0.92.4 5da689c313, 2019-01-14">
<metadata
id="metadata20">
<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></dc:title>