diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0187b3d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +*~ diff --git a/README.md b/README.md index 813cad6..7e43736 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,26 @@ # Wallpaperize -Turn your oddly sized wallpapers into a piece of beauty. On elementary os, simply right click on your picture's file, and select "Wallpaperize" from the drop down menu. +Turn your oddly sized wallpapers into a piece of beauty. Simply right click on your picture's file, and select "Wallpaperize" from the drop down menu. -![Screenshot](Example.png) +![Screenshot](Screenshot.png) ## Instalation -1. cd to this directory -2. Execute the make.sh file + +You can find this app on AppCenter, on elementary OS + +## Build the App + +Run `meson build` to configure the build environment and then change to the build directory and run `ninja` to build + + meson build + cd build + mesonconf -Dprefix=/usr + ninja + +To install, use `ninja install`, then execute with `com.github.danrabbit.nimbus` + + sudo ninja install + com.github.philip-scott.wallpaperize ### Credits Original app: http://backgroundifier.archagon.net diff --git a/Screenshot.png b/Screenshot.png new file mode 100644 index 0000000..a5dccb1 Binary files /dev/null and b/Screenshot.png differ diff --git a/data/com.github.philip-scott.wallpaperize.appdata.xml b/data/com.github.philip-scott.wallpaperize.appdata.xml new file mode 100644 index 0000000..617fc2d --- /dev/null +++ b/data/com.github.philip-scott.wallpaperize.appdata.xml @@ -0,0 +1,33 @@ + + + + com.github.philip-scott.wallpaperize.desktop + CC0-1.0 + GPL-3.0+ + Wallpaperize + Beautify your oddly-sized wallpapers + +

+ Turn your oddly sized wallpapers into a piece of beauty. Simply right click on your picture's file, and select "Wallpaperize" from the drop down menu, or open the app and drag-and-drop the images you wish yo wallpaperize +

+
+ + com.github.philip-scott.wallpaperize + + + + + + https://raw.githubusercontent.com/Philip-Scott/wallpaperize/master/Screenshot.png + + + Felipe Escoto + https://github.com/Philip-Scott + https://github.com/Philip-Scott/wallpaperize/issues + https://github.com/Philip-Scott/wallpaperize/issues + felescoto@hotmail.com + + #FFE8B9 + #333333 + +
diff --git a/src/wapaperize.contract b/data/com.github.philip-scott.wallpaperize.contract similarity index 75% rename from src/wapaperize.contract rename to data/com.github.philip-scott.wallpaperize.contract index 5ee457f..2e19036 100644 --- a/src/wapaperize.contract +++ b/data/com.github.philip-scott.wallpaperize.contract @@ -3,5 +3,5 @@ Name=Wallpaperize Icon=preferences-desktop-wallpaper Description=Beautify your oddly-sized wallpapers MimeType=image -Exec=/usr/share/wallpaperize/Wallpaperize %F +Exec=com.github.philip-scott.wallpaperize %F diff --git a/data/com.github.philip-scott.wallpaperize.desktop b/data/com.github.philip-scott.wallpaperize.desktop new file mode 100644 index 0000000..86bfdce --- /dev/null +++ b/data/com.github.philip-scott.wallpaperize.desktop @@ -0,0 +1,14 @@ +[Desktop Entry] +Name=Wallpaperize +Comment=Beautify your oddly-sized wallpapers +Exec=com.github.philip-scott.wallpaperize %u +Icon=com.github.philip-scott.wallpaperize +Terminal=false +Type=Application +StartupNotify=true +Categories=Graphics; +Actions=AboutDialog; + +[Desktop Action AboutDialog] +Exec=com.github.philip-scott.wallpaperize --about +Name=About Wallpaperize diff --git a/data/icons/128/com.github.philip-scott.wallpaperize.svg b/data/icons/128/com.github.philip-scott.wallpaperize.svg new file mode 100644 index 0000000..93a944a --- /dev/null +++ b/data/icons/128/com.github.philip-scott.wallpaperize.svg @@ -0,0 +1,1893 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/icons/32/com.github.philip-scott.wallpaperize.svg b/data/icons/32/com.github.philip-scott.wallpaperize.svg new file mode 100644 index 0000000..93a944a --- /dev/null +++ b/data/icons/32/com.github.philip-scott.wallpaperize.svg @@ -0,0 +1,1893 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/icons/48/com.github.philip-scott.wallpaperize.svg b/data/icons/48/com.github.philip-scott.wallpaperize.svg new file mode 100644 index 0000000..93a944a --- /dev/null +++ b/data/icons/48/com.github.philip-scott.wallpaperize.svg @@ -0,0 +1,1893 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/icons/64/com.github.philip-scott.wallpaperize.svg b/data/icons/64/com.github.philip-scott.wallpaperize.svg new file mode 100644 index 0000000..93a944a --- /dev/null +++ b/data/icons/64/com.github.philip-scott.wallpaperize.svg @@ -0,0 +1,1893 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..efd1df3 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,23 @@ +icon_sizes = ['32', '48', '64', '128'] + +foreach i : icon_sizes +install_data( +join_paths('icons', i, meson.project_name() + '.svg'), +install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', i + 'x' + i, 'apps') +) +endforeach + +install_data( +meson.project_name() + '.desktop', +install_dir: join_paths(get_option('datadir'), 'applications') +) + +install_data( +meson.project_name() + '.appdata.xml', +install_dir: join_paths(get_option('datadir'), 'metainfo') +) + +install_data( +meson.project_name() + '.contract', +install_dir: join_paths(get_option('datadir'), 'contractor') +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..aa1a99f --- /dev/null +++ b/meson.build @@ -0,0 +1,32 @@ +project('com.github.philip-scott.wallpaperize', ['vala', 'c'], + version: '0.2.0' +) + +gnome = import('gnome') +i18n = import('i18n') + +conf = configuration_data() +conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) +configure_file(output: 'config.h', configuration: conf) +config_h_dir = include_directories('.') + +c_args = [ + '-include', 'config.h', +] + +executable( + 'com.github.philip-scott.wallpaperize', + 'src/Application.vala', + 'src/Wallpaperize.vala', + 'src/Window.vala', + c_args: c_args, + dependencies: [ + dependency('glib-2.0'), + dependency('gobject-2.0'), + dependency('gtk+-3.0'), + dependency('granite'), + ], + install : true +) + +subdir('data') diff --git a/src/Application.vala b/src/Application.vala new file mode 100644 index 0000000..cf96f3a --- /dev/null +++ b/src/Application.vala @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2017 Felipe Escoto (https://github.com/Philip-Scott) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA 02111-1307, USA. +* +* Authored by: Felipe Escoto +*/ + +public class Wallpaperize.Application : Granite.Application { + public const string PROGRAM_ID = "com.github.philip-scott.wallpaperize"; + public const string PROGRAM_NAME = "Wallpaperize"; + + construct { + flags |= ApplicationFlags.HANDLES_OPEN; + + application_id = PROGRAM_ID; + program_name = PROGRAM_NAME; + app_years = "2016-2017"; + exec_name = PROGRAM_ID; + app_launcher = PROGRAM_ID; + + build_version = "1.0"; + app_icon = PROGRAM_ID; + main_url = "https://github.com/Philip-Scott/%s/".printf (PROGRAM_NAME); + bug_url = "https://github.com/Philip-Scott/%s/issues".printf (PROGRAM_NAME); + help_url = "https://github.com/Philip-Scott/%s/issues".printf (PROGRAM_NAME); + translate_url = "https://github.com/Philip-Scott/%s/tree/master/po".printf (PROGRAM_NAME); + about_authors = {"Felipe Escoto ", null}; + about_translators = _("translator-credits"); + + about_license_type = Gtk.License.GPL_3_0; + } + + public override void open (File[] files, string hint) { + foreach (var file in files) { + Wallpaperize.Wallpaperiser.from_file (file); + } + } + + public override void activate () { + var window = new Wallpaperize.Window (this); + this.add_window (window); + window.show (); + } + + public static int main (string[] args) { + /* Initiliaze gettext support */ + Intl.setlocale (LocaleCategory.MESSAGES, Intl.get_language_names ()[0]); + Intl.setlocale (LocaleCategory.NUMERIC, "en_US"); + //Intl.textdomain (Config.GETTEXT_PACKAGE); + + Environment.set_application_name (PROGRAM_NAME); + Environment.set_prgname (PROGRAM_NAME); + + var application = new Wallpaperize.Application (); + + return application.run (args); + } +} diff --git a/src/Wallpaperize.vala b/src/Wallpaperize.vala index 2edf603..9ae7fc5 100644 --- a/src/Wallpaperize.vala +++ b/src/Wallpaperize.vala @@ -1,23 +1,35 @@ using Cairo; -public class Wallpaperize : Object { - private const int W = 1920; - private const int H = 1080; +public class Wallpaperize.Wallpaperiser : Object { + public static int W = 1920; + public static int H = 1080; private const int RADIUS = 12; - private Gdk.Pixbuf image; + private static Gdk.Pixbuf image; - private int width; - private int height; - private double zoom; + private static int width; + private static int height; + private static double zoom; - public int make_image (string input, string output) { + public static void from_file (File file) { + var path = file.get_path (); + + string output_name = path.replace (".png", "").replace (".jpg", "") + ".wp.png"; + make_image (path, output_name); + } + + public static void make_image (string input, string output) { + var surface = make_surface (input); + surface.surface.write_to_png (output); + } + + public static Granite.Drawing.BufferSurface? make_surface (string input) { var surface = new Granite.Drawing.BufferSurface (W, H); try { image = new Gdk.Pixbuf.from_file (input); } catch (Error e) { stderr.printf ("Error on input: %s", e.message); - return 1; + return null; } width = image.get_width(); @@ -78,26 +90,6 @@ public class Wallpaperize : Object { Gdk.cairo_set_source_pixbuf (surface.context, image, center_w, center_h); surface.context.fill_preserve (); - surface.surface.write_to_png (output); - - return 0; - } - - public static int main (string[] argv) { - var wallpaper_maker = new Wallpaperize (); - if (argv.length >= 2) { - int n = 0; - foreach (string file in argv) { - if (n++ == 0) { - continue; - } - string output_name = file.replace (".png", "").replace (".jpg", "") + ".wp.png"; - wallpaper_maker.make_image (file, output_name); - } - } else { - stderr.printf ("Usage: %s %d\n", argv[1], argv.length); - return 1; - } - return 0; + return surface; } } diff --git a/src/Window.vala b/src/Window.vala new file mode 100644 index 0000000..55b8ae6 --- /dev/null +++ b/src/Window.vala @@ -0,0 +1,169 @@ +/* +* Copyright (c) 2017 Felipe Escoto (https://github.com/Philip-Scott) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA 02111-1307, USA. +* +* Authored by: Felipe Escoto +*/ + +public class Wallpaperize.Window : Gtk.ApplicationWindow { + const int MIN_WIDTH = 450; + const int MIN_HEIGHT = 600; + const int IMAGE_HEIGHT = 200; + + const Gtk.TargetEntry[] DRAG_TARGETS = {{ "text/uri-list", 0, 0 }}; + + const string STYLESHEET = """ + .titlebar { + background-color: @bg_color; + background-image: none; + border: none; + } + """; + + public Gtk.Image image; + public Gtk.Button run_button; + public Gtk.Label drag_label; + + public Gtk.Entry width; + public Gtk.Entry height; + + private File _file; + public File file { + get { + return _file; + } + + set { + _file = value; + var surface = Wallpaperize.Wallpaperiser.make_surface (value.get_path ()); + + if (surface != null) { + var pixbuf = surface.load_to_pixbuf (); + pixbuf = pixbuf.scale_simple (image.get_allocated_width (), image.get_allocated_height (), Gdk.InterpType.BILINEAR); + + image.set_from_pixbuf (pixbuf); + run_button.sensitive = true; + run_button.label = "Wallpaperize!"; + drag_label.visible = false; + drag_label.no_show_all = true; + } + } + } + + public Window (Gtk.Application app) { + Object (application: app); + } + + construct { + Granite.Widgets.Utils.set_theming_for_screen (this.get_screen (), STYLESHEET, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + get_style_context ().add_class ("rounded"); + set_size_request(MIN_WIDTH, MIN_HEIGHT); + + Gtk.drag_dest_set (this, Gtk.DestDefaults.MOTION | Gtk.DestDefaults.DROP, DRAG_TARGETS, Gdk.DragAction.COPY); + drag_data_received.connect (on_drag_data_received); + + resizable = false; + set_keep_above (true); + + var grid = new Gtk.Grid (); + grid.orientation = Gtk.Orientation.VERTICAL; + grid.margin = 12; + grid.expand = true; + grid.row_spacing = 12; + + var image_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + image_box.get_style_context ().add_class ("frame"); + + image = new Gtk.Image (); + image.get_style_context ().add_class ("card"); + image.hexpand = true; + image.height_request = 200; + + image_box.add (image); + + drag_label = new Gtk.Label (_("Drop Image Here")); + drag_label.get_style_context ().add_class ("h1"); + drag_label.justify = Gtk.Justification.CENTER; + drag_label.sensitive = false; + + var overlay = new Gtk.Overlay (); + overlay.add (image_box); + overlay.add_overlay (drag_label); + + width = new Gtk.Entry (); + height = new Gtk.Entry (); + + width.set_tooltip_text ("Width"); + height.set_tooltip_text ("Height"); + + width.changed.connect (() => { + Wallpaperize.Wallpaperiser.W = int.parse (width.text); + }); + + height.changed.connect (() => { + Wallpaperize.Wallpaperiser.H = int.parse (height.text); + }); + + var reset_button = new Gtk.Button.from_icon_name ("video-display-symbolic"); + reset_button.clicked.connect (get_screen_size); + reset_button.set_tooltip_text ("Get resolution"); + + var resolution_box = new Gtk.Grid (); + resolution_box.column_spacing = 6; + resolution_box.add (width); + resolution_box.add (new Gtk.Label ("x")); + resolution_box.add (height); + resolution_box.add (reset_button); + + run_button = new Gtk.Button.with_label ("Wallpaperize!"); + run_button.get_style_context ().add_class ("suggested-action"); + run_button.expand = true; + run_button.halign = Gtk.Align.END; + run_button.valign = Gtk.Align.END; + + run_button.sensitive = false; + + run_button.clicked.connect (() => { + run_button.sensitive = false; + Wallpaperize.Wallpaperiser.from_file (file); + run_button.label = _("Done"); + }); + + grid.add (overlay); + grid.add (resolution_box); + grid.add (run_button); + add (grid); + show_all (); + + get_screen_size (); + } + + private void get_screen_size () { + Wallpaperize.Wallpaperiser.H = Gdk.Screen.height (); + Wallpaperize.Wallpaperiser.W = Gdk.Screen.width (); + + width.text = Wallpaperize.Wallpaperiser.W.to_string (); + height.text = Wallpaperize.Wallpaperiser.H.to_string (); + } + + private void on_drag_data_received (Gdk.DragContext drag_context, int x, int y, Gtk.SelectionData data, uint info, uint time) { + stderr.printf (data.get_uris ()[0]); + Gtk.drag_finish (drag_context, true, false, time); + + file = File.new_for_uri (data.get_uris ()[0]); + } +}