From a3455303aaa4bef8844b0d7c94f4de13aa2fee29 Mon Sep 17 00:00:00 2001 From: Peter Uithoven Date: Sun, 25 Jul 2021 22:19:05 +0200 Subject: [PATCH 01/10] Build for flatpak --- .gitignore | 1 + com.github.peteruithoven.resizer.yml | 31 ++++++++++++++++++++++++++++ meson.build | 8 ++++--- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 com.github.peteruithoven.resizer.yml diff --git a/.gitignore b/.gitignore index 6bc1d4e..d745815 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/* debian/build/* debian/debhelper-build-stamp *debhelper.log +.flatpak-builder diff --git a/com.github.peteruithoven.resizer.yml b/com.github.peteruithoven.resizer.yml new file mode 100644 index 0000000..a90f7bd --- /dev/null +++ b/com.github.peteruithoven.resizer.yml @@ -0,0 +1,31 @@ +# This is the same ID that you've used in meson.build and other files +app-id: com.github.peteruithoven.resizer + +# Instead of manually specifying a long list of build and runtime dependencies, +# we can use a convenient pre-made runtime and SDK. For this example, we'll be +# using the runtime and SDK provided by elementary. +runtime: io.elementary.Platform +runtime-version: '6' +sdk: io.elementary.Sdk + +# This should match the exec line in your .desktop file and usually is the same +# as your app ID +command: com.github.peteruithoven.resizer + +# Here we can specify the kinds of permissions our app needs to run. Since we're +# not using hardware like webcams, making sound, or reading external files, we +# only need permission to draw our app on screen using either X11 or Wayland. +finish-args: + - '--share=ipc' + - '--socket=fallback-x11' + - '--socket=wayland' + +# This section is where you list all the source code required to build your app. +# If we had external dependencies that weren't included in our SDK, we would list +# them here. +modules: + - name: resizer + buildsystem: meson + sources: + - type: dir + path: . diff --git a/meson.build b/meson.build index 3c33c29..819939f 100644 --- a/meson.build +++ b/meson.build @@ -13,12 +13,14 @@ add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), la # replacing variables like PROJECT_NAME conf_data = configuration_data() conf_data.set_quoted('PROJECT_NAME', meson.project_name()) -configure_file( +config_file = configure_file( input : 'src/config.vala.in', output : 'config.vala', configuration : conf_data ) +meson.build_root() + executable( meson.project_name(), 'src/Application.vala', @@ -29,7 +31,7 @@ executable( 'src/Resizer.vala', 'src/DropArea.vala', 'src/MessageCenter.vala', - 'build/config.vala', + config_file, dependencies: [ dependency('gtk+-3.0'), dependency('granite') @@ -40,4 +42,4 @@ executable( meson.add_install_script('meson/post_install.py') subdir('data') -subdir('po') \ No newline at end of file +subdir('po') From 58c5548ab4457e17557b8f73d7da9691d5a8da4a Mon Sep 17 00:00:00 2001 From: Peter Uithoven Date: Sun, 25 Jul 2021 22:44:17 +0200 Subject: [PATCH 02/10] Get access to files --- com.github.peteruithoven.resizer.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/com.github.peteruithoven.resizer.yml b/com.github.peteruithoven.resizer.yml index a90f7bd..945faa9 100644 --- a/com.github.peteruithoven.resizer.yml +++ b/com.github.peteruithoven.resizer.yml @@ -19,6 +19,7 @@ finish-args: - '--share=ipc' - '--socket=fallback-x11' - '--socket=wayland' + - '--filesystem=home' # This section is where you list all the source code required to build your app. # If we had external dependencies that weren't included in our SDK, we would list From 3533f650b5ad9a68ff6ca0b7b9e53b83b430bc69 Mon Sep 17 00:00:00 2001 From: Peter Uithoven Date: Sun, 25 Jul 2021 23:40:28 +0200 Subject: [PATCH 03/10] Imagemagick dependency --- com.github.peteruithoven.resizer.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/com.github.peteruithoven.resizer.yml b/com.github.peteruithoven.resizer.yml index 945faa9..e2258f9 100644 --- a/com.github.peteruithoven.resizer.yml +++ b/com.github.peteruithoven.resizer.yml @@ -30,3 +30,26 @@ modules: sources: - type: dir path: . + # Inspiration: https://github.com/ImageMagick/ImageMagick6/releases/tag/6.9.12-19 + - name: imagemagick + config-opts: + - --enable-shared + - --disable-static + - --with-modules + - --with-x + - --with-threads + - --with-magick_plus_plus + - --with-gslib + - --with-wmf + - --with-webp + - --with-openexr + - --with-rsvg + - --with-xml + - --with-jbig + - --with-openjp2 + sources: + - type: archive + url: https://github.com/ImageMagick/ImageMagick6/archive/6.9.12-19.tar.gz + sha256: 2f184f1f5c3e19849347b2b4acb6dd074290903d36fa5924956ee06c85ddf783 + cleanup: + - /share/doc From 405ec467475d3da3014a4728482bea7d5d33183a Mon Sep 17 00:00:00 2001 From: Peter Uithoven Date: Mon, 26 Jul 2021 00:15:05 +0200 Subject: [PATCH 04/10] Using Hdy.window and Gtk.Application --- meson.build | 3 ++- src/Application.vala | 2 +- src/HeaderBar.vala | 2 +- src/ResizePage.vala | 2 +- src/Window.vala | 7 ++++--- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 819939f..86180a9 100644 --- a/meson.build +++ b/meson.build @@ -34,7 +34,8 @@ executable( config_file, dependencies: [ dependency('gtk+-3.0'), - dependency('granite') + dependency('granite'), + dependency('libhandy-1', version: '>=1.0.0') ], install : true ) diff --git a/src/Application.vala b/src/Application.vala index a6e09d6..5733893 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -20,7 +20,7 @@ */ namespace Resizer { - public class Application : Granite.Application { + public class Application : Gtk.Application { private Window window = null; public Application () { diff --git a/src/HeaderBar.vala b/src/HeaderBar.vala index 9dee519..ee8b000 100644 --- a/src/HeaderBar.vala +++ b/src/HeaderBar.vala @@ -20,7 +20,7 @@ */ namespace Resizer { - public class HeaderBar : Gtk.HeaderBar { + public class HeaderBar : Hdy.HeaderBar { construct { show_close_button = true; diff --git a/src/ResizePage.vala b/src/ResizePage.vala index 37ae867..8ad7f11 100644 --- a/src/ResizePage.vala +++ b/src/ResizePage.vala @@ -30,7 +30,7 @@ namespace Resizer { private Gtk.Button cancel_btn; private Gtk.Button resize_btn; - public ResizePage (Gtk.ApplicationWindow app) { + public ResizePage (Window app) { var spacing = 12; intro_label = new Gtk.Label (""); diff --git a/src/Window.vala b/src/Window.vala index 0577c61..b4e4a0a 100644 --- a/src/Window.vala +++ b/src/Window.vala @@ -20,7 +20,7 @@ */ namespace Resizer { - public class Window : Gtk.ApplicationWindow { + public class Window : Hdy.Window { private Gtk.Stack pages; const Gtk.TargetEntry[] DRAG_TARGETS = { { "text/uri-list", 0, 0 } }; @@ -32,10 +32,10 @@ namespace Resizer { ); } construct { - this.get_style_context ().add_class ("rounded"); + Hdy.init (); + // this.get_style_context ().add_class ("rounded"); var header = new HeaderBar (); - this.set_titlebar (header); var resize_page = new ResizePage (this); var resizing_page = new ResizingPage (); @@ -53,6 +53,7 @@ namespace Resizer { var grid = new Gtk.Grid(); grid.orientation = Gtk.Orientation.VERTICAL; grid.row_spacing = 12; + grid.add(header); grid.add(message_center); grid.add(pages); this.add(grid); From 6b4751328f27414f72f91fb574b38e0242218c9a Mon Sep 17 00:00:00 2001 From: Peter Uithoven Date: Mon, 26 Jul 2021 00:22:15 +0200 Subject: [PATCH 05/10] Remove spacing below header --- src/Window.vala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Window.vala b/src/Window.vala index b4e4a0a..dca93e2 100644 --- a/src/Window.vala +++ b/src/Window.vala @@ -50,12 +50,16 @@ namespace Resizer { var message_center = MessageCenter.get_default(); + var innerGrid = new Gtk.Grid(); + innerGrid.orientation = Gtk.Orientation.VERTICAL; + innerGrid.row_spacing = 12; + innerGrid.add(message_center); + innerGrid.add(pages); + var grid = new Gtk.Grid(); grid.orientation = Gtk.Orientation.VERTICAL; - grid.row_spacing = 12; grid.add(header); - grid.add(message_center); - grid.add(pages); + grid.add(innerGrid); this.add(grid); Resizer.get_default ().state_changed.connect((r, state) => { From b316596e7742ce3b4275f577e2c23cc34107300d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A8peteruithoven=C2=A8?= <¨peter@peteruithoven.nl¨> Date: Sun, 25 Jul 2021 23:06:35 +0000 Subject: [PATCH 06/10] Using style constants --- src/DropArea.vala | 6 +++--- src/HeaderBar.vala | 4 ++-- src/Window.vala | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/DropArea.vala b/src/DropArea.vala index e0408de..3f9083d 100644 --- a/src/DropArea.vala +++ b/src/DropArea.vala @@ -28,14 +28,14 @@ namespace Resizer { construct { image = new Gtk.Image (); - image.get_style_context ().add_class ("card"); + image.get_style_context ().add_class (Granite.STYLE_CLASS_CARD); image.hexpand = true; image.width_request = 300; image.height_request = 200; image.margin = 6; image2 = new Gtk.Image (); - image2.get_style_context ().add_class ("card"); + image2.get_style_context ().add_class (Granite.STYLE_CLASS_CARD); image2.margin = 6; image2.margin_start = 6+6; image2.margin_top = 6; @@ -45,7 +45,7 @@ namespace Resizer { drag_label.justify = Gtk.Justification.CENTER; var drag_label_style_context = drag_label.get_style_context (); - drag_label_style_context.add_class ("h2"); + drag_label_style_context.add_class (Granite.STYLE_CLASS_H2_LABEL); drag_label_style_context.add_class (Gtk.STYLE_CLASS_DIM_LABEL); var images = new Gtk.Fixed(); diff --git a/src/HeaderBar.vala b/src/HeaderBar.vala index ee8b000..2a1db1d 100644 --- a/src/HeaderBar.vala +++ b/src/HeaderBar.vala @@ -25,8 +25,8 @@ namespace Resizer { construct { show_close_button = true; var header_context = get_style_context (); - header_context.add_class ("titlebar"); - header_context.add_class ("default-decoration"); + header_context.add_class (Gtk.STYLE_CLASS_TITLEBAR); + header_context.add_class (Granite.STYLE_CLASS_DEFAULT_DECORATION); header_context.add_class (Gtk.STYLE_CLASS_FLAT); var info_text = new Gtk.Label (_("Resizer will never upscale and always maintain the aspect ratio of your images.")); diff --git a/src/Window.vala b/src/Window.vala index dca93e2..e8a1921 100644 --- a/src/Window.vala +++ b/src/Window.vala @@ -33,7 +33,6 @@ namespace Resizer { } construct { Hdy.init (); - // this.get_style_context ().add_class ("rounded"); var header = new HeaderBar (); From 33195b61c634d20828851ef8aa3dd00761e99ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A8peteruithoven=C2=A8?= <¨peter@peteruithoven.nl¨> Date: Sat, 4 Sep 2021 20:06:59 +0000 Subject: [PATCH 07/10] Have exec accept multiple files --- data/com.github.peteruithoven.resizer.desktop.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/com.github.peteruithoven.resizer.desktop.in b/data/com.github.peteruithoven.resizer.desktop.in index 135107a..9b94fc8 100644 --- a/data/com.github.peteruithoven.resizer.desktop.in +++ b/data/com.github.peteruithoven.resizer.desktop.in @@ -3,7 +3,7 @@ Name=Resizer GenericName=Resizer App Comment=Image resizer Categories=Graphics;2DGraphics;RasterGraphics; -Exec=com.github.peteruithoven.resizer %f +Exec=com.github.peteruithoven.resizer %F Icon=com.github.peteruithoven.resizer Terminal=false Type=Application From dc400b869451e35f0bcd7e5c130024c88ee5eed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A8peteruithoven=C2=A8?= <¨peter@peteruithoven.nl¨> Date: Sat, 4 Sep 2021 20:07:19 +0000 Subject: [PATCH 08/10] Define Mimetype --- data/com.github.peteruithoven.resizer.desktop.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/com.github.peteruithoven.resizer.desktop.in b/data/com.github.peteruithoven.resizer.desktop.in index 9b94fc8..2097c20 100644 --- a/data/com.github.peteruithoven.resizer.desktop.in +++ b/data/com.github.peteruithoven.resizer.desktop.in @@ -8,4 +8,5 @@ Icon=com.github.peteruithoven.resizer Terminal=false Type=Application X-GNOME-Gettext-Domain=resizer -Keywords=Image;resize; \ No newline at end of file +Keywords=Image;resize; +MimeType=image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-png;image/webp; From 3ea0c4b2809cd143cfffbeeeafd8ccd3f2444980 Mon Sep 17 00:00:00 2001 From: Peter Uithoven Date: Sat, 4 Sep 2021 22:17:59 +0200 Subject: [PATCH 09/10] RIP context menu --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b51b783..cb0fda5 100644 --- a/README.md +++ b/README.md @@ -6,19 +6,17 @@

-Quickly resize images from the context menu. +Quickly resize images. Features: -- Use from context menu: right click on image(s), and select "Resize images". -- Use from Applications menu: Drag and drop image(s). +- Open images with Resizer or open Reizer and Drag and drop images - Maintains aspect ratio. - Keyboard control: Change the sizes using the up and down keys, press enter to resize. - Settings are stored for next time. -![Screenshot 1](screenshot.png) -![Screenshot 2](screenshot2.png) -![Screenshot 3](screenshot3.png) -![Screenshot 4](screenshot4.png) -![Screenshot 5](screenshot5.png) +![Screenshot resize image](screenshot.png) +![Screenshot without images](screenshot2.png) +![Screenshot resize multiple images](screenshot3.png) +![Screenshot error](screenshot4.png) ## Building, Testing, and Installation @@ -50,5 +48,5 @@ Generate / update `.po` files: ## Credits -A lot of the code is inspired by the [elementary Screenshot tool](https://github.com/elementary/screenshot-tool) and Felipe Escoto's [wallpaperize](https://github.com/Philip-Scott/wallpaperize). +A lot of the code is inspired by the [elementary Screenshot tool](https://github.com/elementary/screenshot-tool) and Felipe Escoto's [wallpaperize](https://github.com/Philip-Scott/wallpaperize). The icon is based on the [elementary Photos icon](https://github.com/elementary/icons/blob/master/apps/128/multimedia-photo-manager.svgs) and was greatly improved by [TraumaD](https://github.com/TraumaD). From f3246c0c93846a29b8a87a41973487b6fa7f8b70 Mon Sep 17 00:00:00 2001 From: Peter Uithoven Date: Sat, 4 Sep 2021 22:20:19 +0200 Subject: [PATCH 10/10] RIP context menu #2 --- ...ithub.peteruithoven.resizer.appdata.xml.in | 10 +++------- screenshot2.png | Bin 65828 -> 60675 bytes screenshot3.png | Bin 60675 -> 194555 bytes screenshot4.png | Bin 194555 -> 40652 bytes screenshot5.png | Bin 40652 -> 0 bytes 5 files changed, 3 insertions(+), 7 deletions(-) delete mode 100644 screenshot5.png diff --git a/data/com.github.peteruithoven.resizer.appdata.xml.in b/data/com.github.peteruithoven.resizer.appdata.xml.in index 1d40fce..3ef9c27 100644 --- a/data/com.github.peteruithoven.resizer.appdata.xml.in +++ b/data/com.github.peteruithoven.resizer.appdata.xml.in @@ -5,17 +5,16 @@ CC0 GPL-3.0+ Resizer - Quickly resize images from the context menu + Quickly resize images

- A simple image resizer that resizes one or more images, usable from the context menu or as a standalone app. + A simple image resizer that resizes one or more images.

Features: