Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load custom icons from GResource instead of the absolute path #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/com.github.gijsgoudzwaard.image-optimizer.gresource.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/github/gijsgoudzwaard/image-optimizer">

<gresource prefix="/com/github/gijsgoudzwaard/image-optimizer/icons">
<file compressed="true" preprocess="xml-stripblanks" alias="upload_icon.svg">icons/upload_icon.svg</file>
</gresource>
</gresources>
5 changes: 0 additions & 5 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ foreach i : icon_sizes
)
endforeach

install_data(
join_paths('icons', 'upload_icon.svg'),
install_dir: 'share/icons/hicolor/scalable/apps'
)

i18n.merge_file(
input: meson.project_name() + '.desktop.in',
output: meson.project_name() + '.desktop',
Expand Down
12 changes: 2 additions & 10 deletions src/Widgets/UploadScreen.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ public class UploadScreen : Gtk.Box {
upload_area.set_valign (Gtk.Align.CENTER);
upload_area.set_halign (Gtk.Align.CENTER);

Gtk.Image icon = new Gtk.Image ();

try {
var icon_pixbuf = new Gdk.Pixbuf.from_file_at_scale ("/usr/share/icons/hicolor/scalable/apps/upload_icon.svg", 64, 64, true);
icon = new Gtk.Image.from_pixbuf (icon_pixbuf);
} catch (Error e) {}
var icon = new Gtk.Image.from_resource ("/com/github/gijsgoudzwaard/image-optimizer/icons/upload_icon.svg");

var title = new Gtk.Label (_("Drag and drop images here"));
title.get_style_context ().add_class ("h1");
Expand All @@ -33,10 +28,7 @@ public class UploadScreen : Gtk.Box {
this.upload_button.set_halign (Gtk.Align.CENTER);
((Gtk.Widget) this.upload_button).set_focus_on_click (false);

if (icon != null) {
upload_area.pack_start (icon, false, false, 0);
}

upload_area.pack_start (icon, false, false, 0);
upload_area.pack_start (title, false, false, 0);
upload_area.pack_start (otherwise, false, false, 0);
upload_area.pack_start (this.upload_button, false, false, 0);
Expand Down