Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package swappy for openSUSE:Factory checked in at 2021-09-07 21:21:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/swappy (Old) and /work/SRC/openSUSE:Factory/.swappy.new.1899 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "swappy" Tue Sep 7 21:21:21 2021 rev:5 rq:917151 version:1.4.0 Changes: -------- --- /work/SRC/openSUSE:Factory/swappy/swappy.changes 2021-02-22 14:41:16.444678453 +0100 +++ /work/SRC/openSUSE:Factory/.swappy.new.1899/swappy.changes 2021-09-07 21:22:00.881345989 +0200 @@ -1,0 +2,19 @@ +Mon Sep 6 15:31:43 UTC 2021 - Michael Vetter <[email protected]> + +- Update to 1.4.0: + Features: + * draw: draw shape from center if holding control (d80c361) + * i18n: add french translations (cacb283) + Bug Fixes: + * desktop: remove annotation from desktop categories (0d383f6) + * desktop: various fixes (42425c0) + * i18n: add german translations to desktop file (c6b09e5) + * i18n: add turkish translation to desktop file (fa5769e) + * i18n: properly set translation domain during layout init (5301aeb), closes #92 + * pixbuf: handle invalid input file (cdbd06d) + * pixbuf: handle overflow when filename_format is too long (185575b), closes #74 + * po: update GETTEXT_PACKAGE value with project name (7fd552e) + * release: properly check sha256 remote content (91985c7), closes #90 +- Remove swappy-desktopfile.patch + +------------------------------------------------------------------- Old: ---- swappy-1.3.1.tar.gz.sig swappy-desktopfile.patch v1.3.1.tar.gz New: ---- swappy-1.4.0.tar.gz.sig v1.4.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ swappy.spec ++++++ --- /var/tmp/diff_new_pack.ng0Amc/_old 2021-09-07 21:22:01.689346965 +0200 +++ /var/tmp/diff_new_pack.ng0Amc/_new 2021-09-07 21:22:01.693346970 +0200 @@ -17,7 +17,7 @@ Name: swappy -Version: 1.3.1 +Version: 1.4.0 Release: 0 Summary: Wayland compositor screenshot editor License: MIT @@ -25,9 +25,6 @@ URL: https://github.com/jtheoof/swappy Source: https://github.com/jtheoof/swappy/archive/v%{version}.tar.gz Source1: https://github.com/jtheoof/swappy/releases/download/v%{version}/swappy-%{version}.tar.gz.sig -Patch0: swappy-desktopfile.patch -Requires: fontawesome-fonts -Requires: wl-clipboard BuildRequires: meson BuildRequires: pkgconfig BuildRequires: scdoc @@ -35,6 +32,8 @@ BuildRequires: pkgconfig(gtk+-3.0) BuildRequires: pkgconfig(libnotify) BuildRequires: pkgconfig(pango) +Requires: fontawesome-fonts +Requires: wl-clipboard %description A Wayland native snapshot and editor tool @@ -43,7 +42,6 @@ %prep %setup -q -%patch0 -p1 %build %meson ++++++ v1.3.1.tar.gz -> v1.4.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/.github/workflows/build.yml new/swappy-1.4.0/.github/workflows/build.yml --- old/swappy-1.3.1/.github/workflows/build.yml 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/.github/workflows/build.yml 2021-09-06 16:36:15.000000000 +0200 @@ -21,6 +21,7 @@ - uses: actions/checkout@v1 - name: Clang run: | + sudo apt-get update sudo apt --yes install libgtk-3-dev meson ninja-build scdoc clang clang-format clang-tidy CC=clang meson build ninja -C build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/CHANGELOG.md new/swappy-1.4.0/CHANGELOG.md --- old/swappy-1.3.1/CHANGELOG.md 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/CHANGELOG.md 2021-09-06 16:36:15.000000000 +0200 @@ -2,6 +2,27 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.4.0](https://github.com/jtheoof/swappy/compare/v1.3.1...v1.4.0) (2021-09-06) + + +### Features + +* **draw:** draw shape from center if holding control ([d80c361](https://github.com/jtheoof/swappy/commit/d80c3614895d3b5da479831c651cc1afa2fcf916)) +* **i18n:** add french translations ([cacb283](https://github.com/jtheoof/swappy/commit/cacb2830e4cc41010d6ab96655054d2eb1651651)) + + +### Bug Fixes + +* **desktop:** remove annotation from desktop categories ([0d383f6](https://github.com/jtheoof/swappy/commit/0d383f690b99026c340eab1efa590c48d54e7368)) +* **desktop:** various fixes ([42425c0](https://github.com/jtheoof/swappy/commit/42425c0657a65b3f66ba4f64b1727c8198a70684)) +* **i18n:** add german translations to desktop file ([c6b09e5](https://github.com/jtheoof/swappy/commit/c6b09e56399369b14a8de090a2239350dbe4aca8)) +* **i18n:** add turkish translation to desktop file ([fa5769e](https://github.com/jtheoof/swappy/commit/fa5769e9406b8ab1b67aca3bff2656850362491e)) +* **i18n:** properly set translation domain during layout init ([5301aeb](https://github.com/jtheoof/swappy/commit/5301aebd5e5534453621db7168b8afac5d7810f2)), closes [#92](https://github.com/jtheoof/swappy/issues/92) +* **pixbuf:** handle invalid input file ([cdbd06d](https://github.com/jtheoof/swappy/commit/cdbd06d7af94b4aedfc2bda2231da8853f775f3a)) +* **pixbuf:** handle overflow when filename_format is too long ([185575b](https://github.com/jtheoof/swappy/commit/185575bf75281eba8a0bc49b3da59225bdd9e1c7)), closes [#74](https://github.com/jtheoof/swappy/issues/74) +* **po:** update GETTEXT_PACKAGE value with project name ([7fd552e](https://github.com/jtheoof/swappy/commit/7fd552e8c41f29711212d7f70edf61ac6ada7a7d)) +* **release:** properly check sha256 remote content ([91985c7](https://github.com/jtheoof/swappy/commit/91985c7994764f52c8e9d864db8ec9cf2eb1df5c)), closes [#90](https://github.com/jtheoof/swappy/issues/90) + ### [1.3.1](https://github.com/jtheoof/swappy/compare/v1.3.0...v1.3.1) (2021-02-20) ## [1.3.0](https://github.com/jtheoof/swappy/compare/v1.2.1...v1.3.0) (2021-02-18) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/README.md new/swappy-1.4.0/README.md --- old/swappy-1.3.1/README.md 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/README.md 2021-09-06 16:36:15.000000000 +0200 @@ -1,6 +1,6 @@ # swappy -A Wayland native snapshot and editor tool, inspired by [Snappy] on macOS. Works great with [grim], [slurp] and [sway]. But can easily work with other screen copy tools that can output a final PNG image to `stdout`. See [below](#example-usage). +A Wayland native snapshot and editor tool, inspired by [Snappy] on macOS. Works great with [grim], [slurp] and [sway]. But can easily work with other screen copy tools that can output a final image to `stdout`. See [below](#example-usage). ## Screenshot @@ -8,7 +8,7 @@ ## Example usage -Output of `grim` (or any tool outputing a PNG file): +Output of `grim` (or any tool outputing an image file): ```sh grim -g "$(slurp)" - | swappy -f - @@ -50,74 +50,78 @@ text_font=sans-serif ``` -- `save_dir` is where swappshots will be saved, can contain env variables and must exist in your filesystem -- `save_filename_format`: is the filename template, if it contains a date format, this will be parsed into a timestamp. Format is detailed in [strftime(3)](https://linux.die.net/man/3/strftime). If this date format is missing, filename will have no timestamp -- `show_panel` is used to toggle the paint panel on or off upon startup -- `line_size` is the default line size (must be between 1 and 50) -- `text_size` is the default text size (must be between 10 and 50) -- `text_font` is the font used to render text, its format is pango friendly +- `save_dir` is where swappshots will be saved, can contain env variables and must exist in your filesystem +- `save_filename_format`: is the filename template, if it contains a date format, this will be parsed into a timestamp. Format is detailed in [strftime(3)](https://man.archlinux.org/man/strftime.3). If this date format is missing, filename will have no timestamp +- `show_panel` is used to toggle the paint panel on or off upon startup +- `line_size` is the default line size (must be between 1 and 50) +- `text_size` is the default text size (must be between 10 and 50) +- `text_font` is the font used to render text, its format is pango friendly ## Keyboard Shortcuts -- `Ctrl+b`: Toggle Paint Panel +- `Ctrl+b`: Toggle Paint Panel <hr> -- `b`: Switch to Brush -- `t`: Switch to Text -- `r`: Switch to Rectangle -- `o`: Switch to Ellipse -- `a`: Switch to Arrow -- `d`: Switch to Blur (`d` stands for droplet) +- `b`: Switch to Brush +- `t`: Switch to Text +- `r`: Switch to Rectangle +- `o`: Switch to Ellipse +- `a`: Switch to Arrow +- `d`: Switch to Blur (`d` stands for droplet) <hr> -- `R`: Use Red Color -- `G`: Use Green Color -- `B`: Use Blue Color -- `C`: Use Custom Color -- `Minus`: Reduce Stroke Size -- `Plus`: Increase Stroke Size -- `Equal`: Reset Stroke Size -- `k`: Clear Paints (cannot be undone) +- `R`: Use Red Color +- `G`: Use Green Color +- `B`: Use Blue Color +- `C`: Use Custom Color +- `Minus`: Reduce Stroke Size +- `Plus`: Increase Stroke Size +- `Equal`: Reset Stroke Size +- `k`: Clear Paints (cannot be undone) <hr> -- `Ctrl+z`: Undo -- `Ctrl+Shift+z` or `Ctrl+y`: Redo -- `Ctrl+s`: Save to file (see man page) -- `Ctrl+c`: Copy to clipboard -- `Escape` or `q` or `Ctrl+w`: Quit swappy +- `Ctrl`: Center Shape (Rectangle & Ellipse) based on draw start + +<hr> + +- `Ctrl+z`: Undo +- `Ctrl+Shift+z` or `Ctrl+y`: Redo +- `Ctrl+s`: Save to file (see man page) +- `Ctrl+c`: Copy to clipboard +- `Escape` or `q` or `Ctrl+w`: Quit swappy ## Limitations -- **Copy**: If you don't have [wl-clipboard] installed, copy to clipboard won't work if you close swappy (the content of the clipboard is lost). This because GTK 3.24 [has not implemented persistent storage on wayland backend yet](https://gitlab.gnome.org/GNOME/gtk/blob/3.24.13/gdk/wayland/gdkdisplay-wayland.c#L857). We need to do it on the [Wayland level](https://github.com/swaywm/wlr-protocols/blob/master/unstable/wlr-data-control-unstable-v1.xml), or wait for GTK 4. For now, we use `wl-copy` if installed and revert to `gtk` clipboard if not found. -- **Fonts**: Swappy relies on Font Awesome 5 being present to properly render the icons. On Arch you can simply install those with: `sudo pacman -S otf-font-awesome` +- **Copy**: If you don't have [wl-clipboard] installed, copy to clipboard won't work if you close swappy (the content of the clipboard is lost). This because GTK 3.24 [has not implemented persistent storage on wayland backend yet](https://gitlab.gnome.org/GNOME/gtk/blob/3.24.13/gdk/wayland/gdkdisplay-wayland.c#L857). We need to do it on the [Wayland level](https://github.com/swaywm/wlr-protocols/blob/master/unstable/wlr-data-control-unstable-v1.xml), or wait for GTK 4. For now, we use `wl-copy` if installed and revert to `gtk` clipboard if not found. +- **Fonts**: Swappy relies on Font Awesome 5 being present to properly render the icons. On Arch you can simply install those with: `sudo pacman -S otf-font-awesome` ## Installation -- [Arch Linux](https://aur.archlinux.org/packages/swappy) -- [Arch Linux (git)](https://aur.archlinux.org/packages/swappy-git) -- [Fedora 31/32](https://copr.fedorainfracloud.org/coprs/wef/swappy) -- [openSUSE](https://build.opensuse.org/package/show/X11:Wayland/swappy) -- [Void Linux](https://github.com/void-linux/void-packages/tree/master/srcpkgs/swappy) +- [Arch Linux](https://archlinux.org/packages/community/x86_64/swappy/) +- [Arch Linux (git)](https://aur.archlinux.org/packages/swappy-git) +- [Fedora](https://src.fedoraproject.org/rpms/swappy) +- [openSUSE](https://build.opensuse.org/package/show/X11:Wayland/swappy) +- [Void Linux](https://github.com/void-linux/void-packages/tree/master/srcpkgs/swappy) ## Building from source Install dependencies (on Arch, name can vary for other distros): -- meson -- ninja -- cairo -- pango -- gtk -- glib2 -- scdoc +- meson +- ninja +- cairo +- pango +- gtk +- glib2 +- scdoc Optional dependencies: -- `wl-clipboard` (to make sure the copy is saved if you close swappy) -- `otf-font-awesome` (to draw the paint icons properly) +- `wl-clipboard` (to make sure the copy is saved if you close swappy) +- `otf-font-awesome` (to draw the paint icons properly) Then run: @@ -128,19 +132,32 @@ ### i18n -To build the translation files: +This section is for developers, maintainers and translators. + +To add support to a new locale or when translations are updated: + +1. Update `src/po/LINGUAS` (when new locales are added) +2. Generate a new `po` file (ignore and do not commit potential noise in other files): + +```sh +ninja -C build swappy-update-po +``` + +To rebuild the base template (should happen less often): ```sh ninja -C build swappy-pot ``` +See the [meson documentation](https://mesonbuild.com/Localisation.html) for details. + ## Contributing Pull requests are welcome. This project uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) to automate changelog generation. -## Generating a new release +## Release -This is only for maintainers, to create a new release. We rely on [standard-version](https://github.com/conventional-changelog/standard-version) which is part of the JavaScript ecosystem but works well with any project. +We rely on [standard-version](https://github.com/conventional-changelog/standard-version) which is part of the JavaScript ecosystem but works well with any project. ``` npx standard-version --sign @@ -149,6 +166,8 @@ ./script/sign-post-release ``` +Release tarballs are signed with this PGP key: `F44D05A50F6C9EB5C81BCF966A6B35DBE9442683` + ## License MIT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/include/paint.h new/swappy-1.4.0/include/paint.h --- old/swappy-1.3.1/include/paint.h 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/include/paint.h 2021-09-06 16:36:15.000000000 +0200 @@ -7,7 +7,7 @@ void paint_add_temporary(struct swappy_state *state, double x, double y, enum swappy_paint_type type); void paint_update_temporary_shape(struct swappy_state *state, double x, - double y); + double y, gboolean is_control_pressed); void paint_update_temporary_text(struct swappy_state *state, GdkEventKey *event); void paint_update_temporary_text_clip(struct swappy_state *state, gdouble x, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/include/pixbuf.h new/swappy-1.4.0/include/pixbuf.h --- old/swappy-1.3.1/include/pixbuf.h 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/include/pixbuf.h 2021-09-06 16:36:15.000000000 +0200 @@ -10,3 +10,4 @@ void pixbuf_save_to_stdout(GdkPixbuf *pixbuf); void pixbuf_scale_surface_from_widget(struct swappy_state *state, GtkWidget *widget); +void pixbuf_free(struct swappy_state *state); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/include/swappy.h new/swappy-1.4.0/include/swappy.h --- old/swappy-1.3.1/include/swappy.h 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/include/swappy.h 2021-09-06 16:36:15.000000000 +0200 @@ -58,6 +58,7 @@ double b; double a; double w; + bool should_center_at_from; struct swappy_point from; struct swappy_point to; enum swappy_paint_type type; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/meson.build new/swappy-1.4.0/meson.build --- old/swappy-1.3.1/meson.build 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/meson.build 2021-09-06 16:36:15.000000000 +0200 @@ -1,7 +1,7 @@ project( 'swappy', 'c', - version: '1.3.1', + version: '1.4.0', license: 'MIT', meson_version: '>=0.48.0', default_options: [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/res/style/swappy.css new/swappy-1.4.0/res/style/swappy.css --- old/swappy-1.3.1/res/style/swappy.css 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/res/style/swappy.css 2021-09-06 16:36:15.000000000 +0200 @@ -9,21 +9,21 @@ } .color-box button { - padding: 6px 10px; + padding: 6px 10px; } .color-box image { - border-radius: 50px; + border-radius: 50px; } .color-box .color-red image { - background-color: rgb(255, 0, 0); + background-color: rgb(255, 0, 0); } .color-box .color-green image { - background-color: rgb(0, 255, 0); + background-color: rgb(0, 255, 0); } .color-box .color-blue image { - background-color: rgb(0, 0, 255); + background-color: rgb(0, 0, 255); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/res/swappy.glade new/swappy-1.4.0/res/swappy.glade --- old/swappy-1.3.1/res/swappy.glade 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/res/swappy.glade 2021-09-06 16:36:15.000000000 +0200 @@ -65,6 +65,7 @@ <property name="show_menubar">False</property> <signal name="delete-event" handler="window_delete_handler" swapped="no"/> <signal name="key-press-event" handler="window_keypress_handler" swapped="no"/> + <signal name="key-release-event" handler="window_keyrelease_handler" swapped="no"/> <child> <object class="GtkOverlay"> <property name="visible">True</property> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/script/sign-post-release new/swappy-1.4.0/script/sign-post-release --- old/swappy-1.3.1/script/sign-post-release 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/script/sign-post-release 2021-09-06 16:36:15.000000000 +0200 @@ -17,7 +17,6 @@ command -v gh >/dev/null 2>&1 || { echo >&2 "github cli tool required: pacman -S github-cli"; exit 1; } mkdir -p $release_folder - cd $release_folder } get_release_version() { @@ -25,24 +24,41 @@ echo "found latest version: $version" } +build_archives_from_source() { + echo "building source archives..." + cd $git_root + git archive -o "$release_folder/local-$app_name-$version.tar.gz" --format tar.gz --prefix "$app_name-$version/" "v$version" +} + + download_source_for_release() { echo "downloading source assets..." - curl --output $app_name-$version.zip https://github.com/jtheoof/$app_name/archive/v$version.zip - curl --output $app_name-$version.tar.gz https://github.com/jtheoof/$app_name/archive/v$version.tar.gz + cd $release_folder + curl --location --output github-$app_name-$version.tar.gz https://github.com/jtheoof/$app_name/archive/v$version.tar.gz +} + +verify_sha256_checksums() { + echo "verifying signatures..." + cd $release_folder + sha256sum local-$app_name-$version.tar.gz | awk '{ print $1 }' > local-$app_name-$version.tar.gz.sha256 + + # sha256sum --check will exit if the checksums do not match + echo "$(cat local-$app_name-$version.tar.gz.sha256) github-$app_name-$version.tar.gz" | sha256sum --check } sign_release_source() { echo "signing source assets..." - gpg --detach-sign $app_name-$version.zip - gpg --detach-sign $app_name-$version.tar.gz + cd $release_folder + gpg --output $app_name-$version.tar.gz.sig --detach-sign github-$app_name-$version.tar.gz } upload_signed_assets_to_release() { echo "uploading signatures to github release..." - gh release upload v$version $app_name-$version.zip.sig --clobber - gh release upload v$version $app_name-$version.tar.gz.sig --clobber + cd $release_folder + gh release upload v$version $app_name-$version.tar.gz.sig --clobber } + main() { init get_release_version @@ -52,7 +68,9 @@ die "version not found, is the git tag valid?" fi + build_archives_from_source download_source_for_release + verify_sha256_checksums sign_release_source upload_signed_assets_to_release } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/src/application.c new/swappy-1.4.0/src/application.c --- old/swappy-1.3.1/src/application.c 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/src/application.c 2021-09-06 16:36:15.000000000 +0200 @@ -256,6 +256,7 @@ void application_finish(struct swappy_state *state) { paint_free_all(state); + pixbuf_free(state); cairo_surface_destroy(state->rendering_surface); cairo_surface_destroy(state->original_image_surface); if (state->temp_file_str) { @@ -269,7 +270,7 @@ g_free(state->geometry); g_free(state->window); g_free(state->ui); - g_object_unref(state->original_image); + g_object_unref(state->app); config_free(state); @@ -291,6 +292,22 @@ clipboard_copy_drawing_area_to_selection(state); } +void control_modifier_changed(bool pressed, struct swappy_state *state) { + if (state->temp_paint != NULL) { + switch (state->temp_paint->type) { + case SWAPPY_PAINT_MODE_ELLIPSE: + case SWAPPY_PAINT_MODE_RECTANGLE: + paint_update_temporary_shape( + state, state->temp_paint->content.shape.to.x, + state->temp_paint->content.shape.to.y, pressed); + render_state(state); + break; + default: + break; + } + } +} + void window_keypress_handler(GtkWidget *widget, GdkEventKey *event, struct swappy_state *state) { if (state->temp_paint && state->mode == SWAPPY_PAINT_MODE_TEXT) { @@ -384,6 +401,27 @@ case GDK_KEY_plus: action_stroke_size_increase(state); break; + case GDK_KEY_Control_L: + control_modifier_changed(true, state); + break; + default: + break; + } + } +} + +void window_keyrelease_handler(GtkWidget *widget, GdkEventKey *event, + struct swappy_state *state) { + if (event->state & GDK_CONTROL_MASK) { + switch (event->keyval) { + case GDK_KEY_Control_L: + control_modifier_changed(false, state); + break; + default: + break; + } + } else { + switch (event->keyval) { default: break; } @@ -475,6 +513,7 @@ gdk_window_set_cursor(window, crosshair); gboolean is_button1_pressed = event->state & GDK_BUTTON1_MASK; + gboolean is_control_pressed = event->state & GDK_CONTROL_MASK; switch (state->mode) { case SWAPPY_PAINT_MODE_BLUR: @@ -483,7 +522,7 @@ case SWAPPY_PAINT_MODE_ELLIPSE: case SWAPPY_PAINT_MODE_ARROW: if (is_button1_pressed) { - paint_update_temporary_shape(state, x, y); + paint_update_temporary_shape(state, x, y, is_control_pressed); render_state(state); } break; @@ -646,6 +685,10 @@ /* Construct a GtkBuilder instance and load our UI description */ GtkBuilder *builder = gtk_builder_new(); + + // Set translation domain for the application based on `src/po/meson.build` + gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE); + if (gtk_builder_add_from_resource(builder, "/me/jtheoof/swappy/swappy.glade", &error) == 0) { g_printerr("Error loading file: %s", error->message); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/src/paint.c new/swappy-1.4.0/src/paint.c --- old/swappy-1.3.1/src/paint.c 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/src/paint.c 2021-09-06 16:36:15.000000000 +0200 @@ -146,7 +146,7 @@ } void paint_update_temporary_shape(struct swappy_state *state, double x, - double y) { + double y, gboolean is_control_pressed) { struct swappy_paint *paint = state->temp_paint; struct swappy_point *point; GList *points; @@ -171,6 +171,12 @@ break; case SWAPPY_PAINT_MODE_RECTANGLE: case SWAPPY_PAINT_MODE_ELLIPSE: + paint->can_draw = true; // all set + + paint->content.shape.should_center_at_from = is_control_pressed; + paint->content.shape.to.x = x; + paint->content.shape.to.y = y; + break; case SWAPPY_PAINT_MODE_ARROW: paint->can_draw = true; // all set diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/src/pixbuf.c new/swappy-1.4.0/src/pixbuf.c --- old/swappy-1.3.1/src/pixbuf.c 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/src/pixbuf.c 2021-09-06 16:36:15.000000000 +0200 @@ -26,14 +26,23 @@ char *filename_format) { time_t current_time = time(NULL); char *c_time_string; - char filename[strlen(filename_format) + 3]; + char filename[255]; + char path[MAX_PATH]; + size_t bytes_formated; c_time_string = ctime(¤t_time); c_time_string[strlen(c_time_string) - 1] = '\0'; - strftime(filename, sizeof(filename), filename_format, - localtime(¤t_time)); - char path[MAX_PATH]; + bytes_formated = strftime(filename, sizeof(filename), filename_format, + localtime(¤t_time)); + if (!bytes_formated) { + g_warning( + "filename_format: %s overflows filename limit - file cannot be saved", + filename_format); + return; + } + g_snprintf(path, MAX_PATH, "%s/%s", folder, filename); + g_info("saving surface to path: %s", path); write_file(pixbuf, path); } @@ -61,7 +70,8 @@ GdkPixbuf *image = gdk_pixbuf_new_from_file(file, &error); if (error != NULL) { - g_error("unable to load file: %s - reason: %s", file, error->message); + g_printerr("unable to load file: %s - reason: %s\n", file, error->message); + g_error_free(error); return NULL; } @@ -127,3 +137,9 @@ g_free(alloc); } + +void pixbuf_free(struct swappy_state *state) { + if (G_IS_OBJECT(state->original_image)) { + g_object_unref(state->original_image); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/src/po/LINGUAS new/swappy-1.4.0/src/po/LINGUAS --- old/swappy-1.3.1/src/po/LINGUAS 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/src/po/LINGUAS 2021-09-06 16:36:15.000000000 +0200 @@ -1,5 +1,6 @@ # Set of available languages. -en de -tr +fr +en pt_BR +tr diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/src/po/fr.po new/swappy-1.4.0/src/po/fr.po --- old/swappy-1.3.1/src/po/fr.po 1970-01-01 01:00:00.000000000 +0100 +++ new/swappy-1.4.0/src/po/fr.po 2021-09-06 16:36:15.000000000 +0200 @@ -0,0 +1,50 @@ +# French translations for swappy package. +# Copyright (C) 2021 THE swappy'S COPYRIGHT HOLDER +# This file is distributed under the same license as the swappy package. +# Jeremy Attali <[email protected]>, 2021. +# +msgid "" +msgstr "" +"Project-Id-Version: swappy\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-02-20 21:17-0500\n" +"PO-Revision-Date: 2021-02-20 21:00-0500\n" +"Last-Translator: Jeremy Attali <[email protected]>\n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: res/swappy.glade:455 +msgid "Line Width" +msgstr "Epaisseur de ligne" + +#: res/swappy.glade:525 +msgid "Text Size" +msgstr "Taille du texte" + +#: res/swappy.glade:641 +msgid "Toggle Paint Panel" +msgstr "Afficher/Cacher le panneau de peinture" + +#: res/swappy.glade:667 +msgid "Undo Last Paint" +msgstr "Annuler la derni??re peinture" + +#: res/swappy.glade:686 +msgid "Redo Previous Paint" +msgstr "R??tablir la derni??re peinture" + +#: res/swappy.glade:705 +msgid "Clear Paints" +msgstr "Supprimer les peintures" + +#: res/swappy.glade:733 +msgid "Copy Surface" +msgstr "Copier la surface" + +#: res/swappy.glade:749 +msgid "Save Surface" +msgstr "Sauvegarder la surface" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/src/po/meson.build new/swappy-1.4.0/src/po/meson.build --- old/swappy-1.3.1/src/po/meson.build 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/src/po/meson.build 2021-09-06 16:36:15.000000000 +0200 @@ -1,7 +1,7 @@ i18n = import('i18n') # define GETTEXT_PACKAGE -add_project_arguments('-DGETTEXT_PACKAGE="intltest"', language:'c') +add_project_arguments('-DGETTEXT_PACKAGE="swappy"', language:'c') i18n.gettext(meson.project_name(), args: '--directory=' + meson.source_root() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/src/po/swappy.desktop.in new/swappy-1.4.0/src/po/swappy.desktop.in --- old/swappy-1.3.1/src/po/swappy.desktop.in 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/src/po/swappy.desktop.in 2021-09-06 16:36:15.000000000 +0200 @@ -1,15 +1,22 @@ [Desktop Entry] Name=Swappy GenericName=Annotation Tool +GenericName[de]=Anmerkungswerkzeug +GenericName[fr]=Outil d'annotation GenericName[pt_BR]=Ferramenta de Anota????o +GenericName[tr]=A????klama Arac?? Comment=A Wayland native snapshot editing tool +Comment[de]=Ein natives Wayland Bildschirmfoto-Bearbeitungswerkzeug +Comment[fr]=Un outil d'??dition de capture d'??cran avec support natif pour Wayland Comment[pt_BR]=Uma ferramenta de edi????o de snapshot nativa do Wayland +Comment[tr]=Wayland i??in anl??k g??r??nt?? d??zenleme arac?? TryExec=swappy -Exec=swappy -f %F -Terminal=true +Exec=swappy -f %f +Terminal=false +NoDisplay=true Type=Application Keywords=wayland;snapshot;annotation;editing; Icon=swappy -Categories=Utility;Graphics;Annotation; +Categories=Utility;Graphics; StartupNotify=true -MimeType=image/png; +MimeType=image/png;image/jpeg; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/src/render.c new/swappy-1.4.0/src/render.c --- old/swappy-1.3.1/src/render.c 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/src/render.c 2021-09-06 16:36:15.000000000 +0200 @@ -284,11 +284,22 @@ static void render_shape_ellipse(cairo_t *cr, struct swappy_paint_shape shape) { double x = fabs(shape.from.x - shape.to.x); double y = fabs(shape.from.y - shape.to.y); - double xc = shape.from.x + ((shape.to.x - shape.from.x) / 2); - double yc = shape.from.y + ((shape.to.y - shape.from.y) / 2); double n = sqrt(x * x + y * y); - double r = n / 2; + + double xc, yc, r; + + if (shape.should_center_at_from) { + xc = shape.from.x; + yc = shape.from.y; + + r = n; + } else { + xc = shape.from.x + ((shape.to.x - shape.from.x) / 2); + yc = shape.from.y + ((shape.to.y - shape.from.y) / 2); + + r = n / 2; + } cairo_set_source_rgba(cr, shape.r, shape.g, shape.b, shape.a); cairo_set_line_width(cr, shape.w); @@ -305,10 +316,19 @@ static void render_shape_rectangle(cairo_t *cr, struct swappy_paint_shape shape) { - double x = fmin(shape.from.x, shape.to.x); - double y = fmin(shape.from.y, shape.to.y); - double w = fabs(shape.from.x - shape.to.x); - double h = fabs(shape.from.y - shape.to.y); + double x, y, w, h; + + if (shape.should_center_at_from) { + x = shape.from.x - fabs(shape.from.x - shape.to.x); + y = shape.from.y - fabs(shape.from.y - shape.to.y); + w = fabs(shape.from.x - shape.to.x) * 2; + h = fabs(shape.from.y - shape.to.y) * 2; + } else { + x = fmin(shape.from.x, shape.to.x); + y = fmin(shape.from.y, shape.to.y); + w = fabs(shape.from.x - shape.to.x); + h = fabs(shape.from.y - shape.to.y); + } cairo_set_source_rgba(cr, shape.r, shape.g, shape.b, shape.a); cairo_set_line_width(cr, shape.w); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.3.1/swappy.1.scd new/swappy-1.4.0/swappy.1.scd --- old/swappy-1.3.1/swappy.1.scd 2021-02-20 18:54:26.000000000 +0100 +++ new/swappy-1.4.0/swappy.1.scd 2021-09-06 16:36:15.000000000 +0200 @@ -12,7 +12,7 @@ swappy is a command-line utility to take and edit screenshots of Wayland desktops. Works great with grim, slurp and sway. But can easily work with -other screen copy tools that can output a final PNG image to *stdout*. +other screen copy tools that can output a final image to *stdout*. swappy will save the annotated images to the config *save_dir*, see below. @@ -30,7 +30,7 @@ Show version and quit. *-f, --file* <file> - A PNG file to load for editing. + An image file to load for editing. If set to *-*, read the file from standard input instead. This is grim friendly. @@ -96,6 +96,10 @@ - *Equal*: Reset Stroke Size - *k*: Clear Paints (cannot be undone) +## MODIFIERS + +- *Ctrl*: Center Shape (Rectangle & Ellipse) based on draw start + ## HEADER BAR - *Ctrl+z*: Undo
