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-02-18 20:41:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/swappy (Old) and /work/SRC/openSUSE:Factory/.swappy.new.28504 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "swappy" Thu Feb 18 20:41:14 2021 rev:3 rq:873299 version:1.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/swappy/swappy.changes 2020-07-14 08:01:04.822137536 +0200 +++ /work/SRC/openSUSE:Factory/.swappy.new.28504/swappy.changes 2021-02-18 20:53:06.491478667 +0100 @@ -1,0 +2,19 @@ +Thu Feb 18 08:12:00 UTC 2021 - Michael Vetter <[email protected]> + +- Updat to 1.3.0: + Features: + * cli: add configure options for filename save (597f005) + * i18n: add brazilian portuguese translations (4a0eb82) + * i18n: add german translations (b4be847) + * i18n: add turkish translations (c8419da) + Bug Fixes: + * application: unlink temp file coming from stdin (c24e56a), closes #80 + * blur: optimize blur to only render after commit (27fcece) + * blur: rgb24 is properly handled (c04ed63) + * clipboard: wl-copy mimetype should be png (a931acb), closes #68 + * notification: notification shows the image icon (eb53e5c) + * ui: adjust rendering surface with proper scaling (9b72571), closes #54 + * ui: commit state before copying or saving (46e5854), closes #52 + * ui: compute window sizes and buffers properly (5bcffdb), closes #56 + +------------------------------------------------------------------- Old: ---- swappy-1.2.1.tar.gz.sig v1.2.1.tar.gz New: ---- swappy-1.3.0.tar.gz.sig v1.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ swappy.spec ++++++ --- /var/tmp/diff_new_pack.Zi14QD/_old 2021-02-18 20:53:08.759480796 +0100 +++ /var/tmp/diff_new_pack.Zi14QD/_new 2021-02-18 20:53:08.763480800 +0100 @@ -1,7 +1,7 @@ # # spec file for package swappy # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: swappy -Version: 1.2.1 +Version: 1.3.0 Release: 0 Summary: Wayland compositor screenshot editor License: MIT ++++++ swappy-desktopfile.patch ++++++ --- /var/tmp/diff_new_pack.Zi14QD/_old 2021-02-18 20:53:08.795480830 +0100 +++ /var/tmp/diff_new_pack.Zi14QD/_new 2021-02-18 20:53:08.795480830 +0100 @@ -1,7 +1,7 @@ -diff -urEbw swappy-1.2.0/src/po/swappy.desktop.in swappy-1.2.0.new/src/po/swappy.desktop.in ---- swappy-1.2.0/src/po/swappy.desktop.in 2020-07-05 20:54:03.000000000 +0200 -+++ swappy-1.2.0.new/src/po/swappy.desktop.in 2020-07-06 12:50:01.506063620 +0200 -@@ -8,6 +8,6 @@ +diff -urEbw swappy-1.3.0/src/po/swappy.desktop.in swappy-1.3.0.new/src/po/swappy.desktop.in +--- swappy-1.3.0/src/po/swappy.desktop.in 2021-02-18 01:45:00.000000000 +0100 ++++ swappy-1.3.0.new/src/po/swappy.desktop.in 2021-02-18 09:15:09.541907785 +0100 +@@ -10,6 +10,6 @@ Type=Application Keywords=wayland;snapshot;annotation;editing; Icon=swappy @@ -9,4 +9,3 @@ +Categories=Utility;Graphics;X-Annotation; StartupNotify=true MimeType=image/png; -\ No newline at end of file ++++++ v1.2.1.tar.gz -> v1.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/.clang-format new/swappy-1.3.0/.clang-format --- old/swappy-1.2.1/.clang-format 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/.clang-format 2021-02-18 01:45:00.000000000 +0100 @@ -3,4 +3,4 @@ IndentWidth: 2 DerivePointerAlignment: false -PointerAlignment: Right \ No newline at end of file +PointerAlignment: Right diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/.github/workflows/build.yml new/swappy-1.3.0/.github/workflows/build.yml --- old/swappy-1.2.1/.github/workflows/build.yml 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/.github/workflows/build.yml 2021-02-18 01:45:00.000000000 +0100 @@ -10,7 +10,7 @@ - name: GCC run: | sudo apt-get update - sudo apt --yes install libgtk-3-dev libnotify-dev meson ninja-build scdoc + sudo apt --yes install libgtk-3-dev meson ninja-build scdoc pkg-config --list-all CC=gcc meson build ninja -C build @@ -21,7 +21,7 @@ - uses: actions/checkout@v1 - name: Clang run: | - sudo apt --yes install libgtk-3-dev libnotify-dev meson ninja-build scdoc clang clang-format clang-tidy + sudo apt --yes install libgtk-3-dev meson ninja-build scdoc clang clang-format clang-tidy CC=clang meson build ninja -C build echo "Making sure clang-format is correct..." diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/.vscode/c_cpp_properties.json new/swappy-1.3.0/.vscode/c_cpp_properties.json --- old/swappy-1.2.1/.vscode/c_cpp_properties.json 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/.vscode/c_cpp_properties.json 2021-02-18 01:45:00.000000000 +0100 @@ -16,7 +16,7 @@ "/usr/include/glib-2.0/", "/usr/include/gtk-3.0/", "/usr/include/pango-1.0/", - "/usr/lib/clang/10.0.0/include/" + "/usr/lib/clang/11.0.1/include/" ] } ], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/CHANGELOG.md new/swappy-1.3.0/CHANGELOG.md --- old/swappy-1.2.1/CHANGELOG.md 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/CHANGELOG.md 2021-02-18 01:45:00.000000000 +0100 @@ -2,6 +2,28 @@ 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.3.0](https://github.com/jtheoof/swappy/compare/v1.2.1...v1.3.0) (2021-02-18) + + +### Features + +* **cli:** add configure options for filename save ([597f005](https://github.com/jtheoof/swappy/commit/597f0055b9c6230b25a7f7a7bf3f4e14c06b1fbb)) +* **i18n:** add brazilian portuguese translations ([4a0eb82](https://github.com/jtheoof/swappy/commit/4a0eb82369a0859fafdcce9d242c086cd2360a84)) +* **i18n:** add german translations ([b4be847](https://github.com/jtheoof/swappy/commit/b4be8476350771454b29b9ce29c62a3337acc736)) +* **i18n:** add turkish translations ([c8419da](https://github.com/jtheoof/swappy/commit/c8419da7faef14223ada6853942a6d11e2acf92f)) + + +### Bug Fixes + +* **application:** unlink temp file coming from stdin ([c24e56a](https://github.com/jtheoof/swappy/commit/c24e56a165394e60b37534287e168e5d8e69627c)), closes [#80](https://github.com/jtheoof/swappy/issues/80) +* **blur:** optimize blur to only render after commit ([27fcece](https://github.com/jtheoof/swappy/commit/27fcecedaeea49aaec6acdecbc51cbd865a13363)) +* **blur:** rgb24 is properly handled ([c04ed63](https://github.com/jtheoof/swappy/commit/c04ed63d26e5012215198f7b41a7f2232dac1ebe)) +* **clipboard:** wl-copy mimetype should be png ([a931acb](https://github.com/jtheoof/swappy/commit/a931acb2cff615badc63294ed121aba008f32ef8)), closes [#68](https://github.com/jtheoof/swappy/issues/68) +* **notification:** notification shows the image icon ([eb53e5c](https://github.com/jtheoof/swappy/commit/eb53e5c2b28717f509dd58eab6da85897c0d6d9d)) +* **ui:** adjust rendering surface with proper scaling ([9b72571](https://github.com/jtheoof/swappy/commit/9b72571596f9313d4efd94a4b17da8b3733fd2de)), closes [#54](https://github.com/jtheoof/swappy/issues/54) +* **ui:** commit state before copying or saving ([46e5854](https://github.com/jtheoof/swappy/commit/46e5854b3cce93a82984b19ca90e3f3337952fe2)), closes [#52](https://github.com/jtheoof/swappy/issues/52) +* **ui:** compute window sizes and buffers properly ([5bcffdb](https://github.com/jtheoof/swappy/commit/5bcffdbb01cc6e56f9c0f37de899b46efe68ed4a)), closes [#56](https://github.com/jtheoof/swappy/issues/56) + ### [1.2.1](https://github.com/jtheoof/swappy/compare/v1.2.0...v1.2.1) (2020-07-11) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/README.md new/swappy-1.3.0/README.md --- old/swappy-1.2.1/README.md 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/README.md 2021-02-18 01:45:00.000000000 +0100 @@ -43,6 +43,7 @@ ``` [Default] save_dir=$HOME/Desktop +save_filename_format=swappy-%Y%m%d-%H%M%S.png show_panel=false line_size=5 text_size=20 @@ -50,6 +51,7 @@ ``` - `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) @@ -98,6 +100,7 @@ - [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) ## Building from source @@ -114,7 +117,6 @@ Optional dependencies: - `wl-clipboard` (to make sure the copy is saved if you close swappy) -- `libnotify` (not get notified when swappshot is copied or saved) - `otf-font-awesome` (to draw the paint icons properly) Then run: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/include/application.h new/swappy-1.3.0/include/application.h --- old/swappy-1.2.1/include/application.h 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/include/application.h 2021-02-18 01:45:00.000000000 +0100 @@ -56,4 +56,4 @@ void text_size_decrease_handler(GtkWidget *widget, struct swappy_state *state); void text_size_reset_handler(GtkWidget *widget, struct swappy_state *state); -void text_size_increase_handler(GtkWidget *widget, struct swappy_state *state); \ No newline at end of file +void text_size_increase_handler(GtkWidget *widget, struct swappy_state *state); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/include/buffer.h new/swappy-1.3.0/include/buffer.h --- old/swappy-1.2.1/include/buffer.h 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/include/buffer.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +0,0 @@ -#pragma once - -#include "swappy.h" - -bool buffer_init_from_file(struct swappy_state *state); -void buffer_resize_patterns(struct swappy_state *state); -void buffer_free_all(struct swappy_state *state); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/include/clipboard.h new/swappy-1.3.0/include/clipboard.h --- old/swappy-1.2.1/include/clipboard.h 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/include/clipboard.h 2021-02-18 01:45:00.000000000 +0100 @@ -2,4 +2,4 @@ #include "swappy.h" -bool clipboard_copy_drawing_area_to_selection(struct swappy_state *state); \ No newline at end of file +bool clipboard_copy_drawing_area_to_selection(struct swappy_state *state); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/include/config.h new/swappy-1.3.0/include/config.h --- old/swappy-1.2.1/include/config.h 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/include/config.h 2021-02-18 01:45:00.000000000 +0100 @@ -4,6 +4,7 @@ #define CONFIG_TEXT_FONT_DEFAULT "sans-serif" #define CONFIG_TEXT_SIZE_DEFAULT 20 #define CONFIG_SHOW_PANEL_DEFAULT false +#define CONFIG_SAVE_FILENAME_FORMAT_DEFAULT "swappy-%Y%m%d_%H%M%S.png" void config_load(struct swappy_state *state); -void config_free(struct swappy_state *state); \ No newline at end of file +void config_free(struct swappy_state *state); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/include/notification.h new/swappy-1.3.0/include/notification.h --- old/swappy-1.2.1/include/notification.h 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/include/notification.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -#pragma once - -void notification_send(char *title, char *message); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/include/pixbuf.h new/swappy-1.3.0/include/pixbuf.h --- old/swappy-1.2.1/include/pixbuf.h 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/include/pixbuf.h 2021-02-18 01:45:00.000000000 +0100 @@ -2,7 +2,11 @@ #include "swappy.h" +GdkPixbuf *pixbuf_init_from_file(struct swappy_state *state); GdkPixbuf *pixbuf_get_from_state(struct swappy_state *state); -void pixbuf_save_state_to_folder(GdkPixbuf *pixbuf, char *folder); +void pixbuf_save_state_to_folder(GdkPixbuf *pixbuf, char *folder, + char *filename_format); void pixbuf_save_to_file(GdkPixbuf *pixbuf, char *file); -void pixbuf_save_to_stdout(GdkPixbuf *pixbuf); \ No newline at end of file +void pixbuf_save_to_stdout(GdkPixbuf *pixbuf); +void pixbuf_scale_surface_from_widget(struct swappy_state *state, + GtkWidget *widget); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/include/render.h new/swappy-1.3.0/include/render.h --- old/swappy-1.2.1/include/render.h 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/include/render.h 2021-02-18 01:45:00.000000000 +0100 @@ -2,4 +2,4 @@ #include "swappy.h" -void render_state(struct swappy_state *state); \ No newline at end of file +void render_state(struct swappy_state *state); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/include/swappy.h new/swappy-1.3.0/include/swappy.h --- old/swappy-1.2.1/include/swappy.h 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/include/swappy.h 2021-02-18 01:45:00.000000000 +0100 @@ -23,6 +23,11 @@ SWAPPY_PAINT_MODE_BLUR, /* Blur mode */ }; +enum swappy_paint_shape_operation { + SWAPPY_PAINT_SHAPE_OPERATION_STROKE = 0, /* Used to stroke the shape */ + SWAPPY_PAINT_SHAPE_OPERATION_FILL, /* Used to fill the shape */ +}; + enum swappy_text_mode { SWAPPY_TEXT_MODE_EDIT = 0, SWAPPY_TEXT_MODE_DONE, @@ -56,6 +61,7 @@ struct swappy_point from; struct swappy_point to; enum swappy_paint_type type; + enum swappy_paint_shape_operation operation; }; struct swappy_paint_brush { @@ -135,6 +141,7 @@ struct swappy_config { char *config_file; char *save_dir; + char *save_filename_format; gboolean show_panel; guint32 line_size; guint32 text_size; @@ -147,11 +154,11 @@ struct swappy_state_ui *ui; struct swappy_config *config; + GdkPixbuf *original_image; cairo_surface_t *original_image_surface; - cairo_surface_t *scaled_image_surface; - cairo_surface_t *rendered_surface; + cairo_surface_t *rendering_surface; - GList *patterns; // List of cairo_pattern_t + gdouble scaling_factor; enum swappy_paint_type mode; @@ -159,11 +166,11 @@ char *file_str; char *output_file; + char *temp_file_str; + struct swappy_box *window; struct swappy_box *geometry; - cairo_rectangle_int_t *drawing_area_rect; - GList *paints; GList *redo_paints; struct swappy_paint *temp_paint; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/meson.build new/swappy-1.3.0/meson.build --- old/swappy-1.2.1/meson.build 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/meson.build 2021-02-18 01:45:00.000000000 +0100 @@ -1,7 +1,7 @@ project( 'swappy', 'c', - version: '1.2.1', + version: '1.3.0', license: 'MIT', meson_version: '>=0.48.0', default_options: [ @@ -43,12 +43,6 @@ gtk = dependency('gtk+-3.0', version: '>=3.20.0') gio = dependency('gio-2.0') -libnotify = dependency('libnotify', required: get_option('libnotify')) - -if libnotify.found() - add_project_arguments('-DHAVE_LIBNOTIFY', language: 'c') -endif - subdir('res') subdir('src/po') @@ -59,7 +53,6 @@ 'src/main.c', 'src/algebra.c', 'src/application.c', - 'src/buffer.c', 'src/box.c', 'src/config.c', 'src/clipboard.c', @@ -67,7 +60,6 @@ 'src/paint.c', 'src/pixbuf.c', 'src/render.c', - 'src/notification.c', 'src/util.c', ]), dependencies: [ @@ -75,7 +67,6 @@ pango, gio, gtk, - libnotify, math, ], link_args: '-rdynamic', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/meson_options.txt new/swappy-1.3.0/meson_options.txt --- old/swappy-1.2.1/meson_options.txt 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/meson_options.txt 2021-02-18 01:45:00.000000000 +0100 @@ -1,2 +1 @@ option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages') -option('libnotify', type: 'feature', value: 'auto', description: 'Send desktop notifications') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/res/meson.build new/swappy-1.3.0/res/meson.build --- old/swappy-1.2.1/res/meson.build 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/res/meson.build 2021-02-18 01:45:00.000000000 +0100 @@ -9,4 +9,4 @@ swappy_resources = gnome.compile_resources('swappy', 'swappy.gresource.xml' -) \ No newline at end of file +) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/res/swappy.gresource.xml new/swappy-1.3.0/res/swappy.gresource.xml --- old/swappy-1.2.1/res/swappy.gresource.xml 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/res/swappy.gresource.xml 2021-02-18 01:45:00.000000000 +0100 @@ -4,4 +4,4 @@ <file>style/swappy.css</file> <file>swappy.glade</file> </gresource> -</gresources> \ No newline at end of file +</gresources> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/application.c new/swappy-1.3.0/src/application.c --- old/swappy-1.2.1/src/application.c 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/application.c 2021-02-18 01:45:00.000000000 +0100 @@ -1,10 +1,10 @@ #include <gdk/gdk.h> #include <glib-2.0/glib.h> +#include <glib/gstdio.h> #include <gtk/gtk.h> #include <stdio.h> #include <time.h> -#include "buffer.h" #include "clipboard.h" #include "config.h" #include "file.h" @@ -184,7 +184,8 @@ GdkPixbuf *pixbuf = pixbuf_get_from_state(state); if (file == NULL) { - pixbuf_save_state_to_folder(pixbuf, state->config->save_dir); + pixbuf_save_state_to_folder(pixbuf, state->config->save_dir, + state->config->save_filename_format); } else { pixbuf_save_to_file(pixbuf, file); } @@ -198,6 +199,32 @@ } } +static void screen_coordinates_to_image_coordinates(struct swappy_state *state, + gdouble screen_x, + gdouble screen_y, + gdouble *image_x, + gdouble *image_y) { + gdouble x, y; + + gint w = gdk_pixbuf_get_width(state->original_image); + gint h = gdk_pixbuf_get_height(state->original_image); + + // Clamp coordinates to original image properties to avoid side effects in + // rendering pipeline + x = CLAMP(screen_x / state->scaling_factor, 0, w); + y = CLAMP(screen_y / state->scaling_factor, 0, h); + + *image_x = x; + *image_y = y; +} + +static void commit_state(struct swappy_state *state) { + paint_commit_temporary(state); + paint_free_list(&state->redo_paints); + render_state(state); + update_ui_undo_redo(state); +} + void on_destroy(GtkApplication *application, gpointer data) { struct swappy_state *state = (struct swappy_state *)data; maybe_save_output_file(state); @@ -229,21 +256,28 @@ void application_finish(struct swappy_state *state) { paint_free_all(state); - buffer_free_all(state); - g_free(state->drawing_area_rect); - cairo_surface_destroy(state->rendered_surface); + cairo_surface_destroy(state->rendering_surface); cairo_surface_destroy(state->original_image_surface); - cairo_surface_destroy(state->scaled_image_surface); + if (state->temp_file_str) { + g_info("deleting temporary file: %s", state->temp_file_str); + if (g_unlink(state->temp_file_str) != 0) { + g_warning("unable to delete temporary file: %s", state->temp_file_str); + } + g_free(state->temp_file_str); + } g_free(state->file_str); 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); } void save_clicked_handler(GtkWidget *widget, struct swappy_state *state) { + // Commit a potential paint (e.g. text being written) + commit_state(state); save_state_to_file_or_folder(state, NULL); } @@ -252,6 +286,8 @@ } void copy_clicked_handler(GtkWidget *widget, struct swappy_state *state) { + // Commit a potential paint (e.g. text being written) + commit_state(state); clipboard_copy_drawing_area_to_selection(state); } @@ -376,7 +412,17 @@ gboolean draw_area_handler(GtkWidget *widget, cairo_t *cr, struct swappy_state *state) { - cairo_set_source_surface(cr, state->rendered_surface, 0, 0); + GtkAllocation *alloc = g_new(GtkAllocation, 1); + gtk_widget_get_allocation(widget, alloc); + + GdkPixbuf *image = state->original_image; + gint image_width = gdk_pixbuf_get_width(image); + gint image_height = gdk_pixbuf_get_height(image); + double scale_x = (double)alloc->width / image_width; + double scale_y = (double)alloc->height / image_height; + + cairo_scale(cr, scale_x, scale_y); + cairo_set_source_surface(cr, state->rendering_surface, 0, 0); cairo_paint(cr); return FALSE; @@ -385,27 +431,9 @@ gboolean draw_area_configure_handler(GtkWidget *widget, GdkEventConfigure *event, struct swappy_state *state) { - g_debug("received configure_event handler"); - cairo_surface_destroy(state->rendered_surface); - g_free(state->drawing_area_rect); - - cairo_surface_t *surface = gdk_window_create_similar_surface( - gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR_ALPHA, - gtk_widget_get_allocated_width(widget), - gtk_widget_get_allocated_height(widget)); - - state->rendered_surface = surface; - - GtkAllocation *alloc = g_new(GtkAllocation, 1); - gtk_widget_get_allocation(widget, alloc); - state->drawing_area_rect = alloc; - buffer_resize_patterns(state); + g_debug("received configure_event callback"); - g_info("size of cairo_surface: %ux%u with type: %d", - cairo_image_surface_get_width(surface), - cairo_image_surface_get_height(surface), - cairo_image_surface_get_format(surface)); - g_info("size of area to render: %ux%u", alloc->width, alloc->height); + pixbuf_scale_surface_from_widget(state, widget); render_state(state); @@ -414,6 +442,10 @@ void draw_area_button_press_handler(GtkWidget *widget, GdkEventButton *event, struct swappy_state *state) { + gdouble x, y; + + screen_coordinates_to_image_coordinates(state, event->x, event->y, &x, &y); + if (event->button == 1) { switch (state->mode) { case SWAPPY_PAINT_MODE_BLUR: @@ -422,7 +454,7 @@ case SWAPPY_PAINT_MODE_ELLIPSE: case SWAPPY_PAINT_MODE_ARROW: case SWAPPY_PAINT_MODE_TEXT: - paint_add_temporary(state, event->x, event->y, state->mode); + paint_add_temporary(state, x, y, state->mode); render_state(state); update_ui_undo_redo(state); break; @@ -433,8 +465,10 @@ } void draw_area_motion_notify_handler(GtkWidget *widget, GdkEventMotion *event, struct swappy_state *state) { - gdouble x = event->x; - gdouble y = event->y; + gdouble x, y; + + screen_coordinates_to_image_coordinates(state, event->x, event->y, &x, &y); + GdkDisplay *display = gdk_display_get_default(); GdkWindow *window = event->window; GdkCursor *crosshair = gdk_cursor_new_for_display(display, GDK_CROSSHAIR); @@ -476,10 +510,7 @@ case SWAPPY_PAINT_MODE_RECTANGLE: case SWAPPY_PAINT_MODE_ELLIPSE: case SWAPPY_PAINT_MODE_ARROW: - paint_commit_temporary(state); - paint_free_list(&state->redo_paints); - render_state(state); - update_ui_undo_redo(state); + commit_state(state); break; case SWAPPY_PAINT_MODE_TEXT: if (state->temp_paint && !state->temp_paint->can_draw) { @@ -538,7 +569,7 @@ action_text_size_increase(state); } -static void compute_window_size(struct swappy_state *state) { +static void compute_window_size_and_scaling_factor(struct swappy_state *state) { GdkRectangle workarea = {0}; GdkDisplay *display = gdk_display_get_default(); GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(state->ui->window)); @@ -548,23 +579,46 @@ g_assert(workarea.width > 0); g_assert(workarea.height > 0); + if (state->window) { + g_free(state->window); + state->window = NULL; + } + state->window = g_new(struct swappy_box, 1); state->window->x = workarea.x; state->window->y = workarea.y; double threshold = 0.75; - double scaling = 1.0; + double scaling_factor = 1.0; - if (state->geometry->width > workarea.width * threshold) { - scaling = workarea.width * threshold / state->geometry->width; - } else if (state->geometry->height > workarea.height * threshold) { - scaling = workarea.height * threshold / state->geometry->height; - } + int image_width = gdk_pixbuf_get_width(state->original_image); + int image_height = gdk_pixbuf_get_height(state->original_image); - state->window->width = state->geometry->width * scaling; - state->window->height = state->geometry->height * scaling; + int max_width = workarea.width * threshold; + int max_height = workarea.height * threshold; + g_info("size of image: %ux%u", image_width, image_height); g_info("size of monitor at window: %ux%u", workarea.width, workarea.height); + g_info("maxium size allowed for window: %ux%u", max_width, max_height); + + int scaled_width = image_width; + int scaled_height = image_height; + + double scaling_factor_width = (double)max_width / image_width; + double scaling_factor_height = (double)max_height / image_height; + + if (scaling_factor_height < 1.0 || scaling_factor_width < 1.0) { + scaling_factor = MIN(scaling_factor_width, scaling_factor_height); + scaled_width = image_width * scaling_factor; + scaled_height = image_height * scaling_factor; + g_info("rendering area will be scaled by a factor of: %.2lf", + scaling_factor); + } + + state->scaling_factor = scaling_factor; + state->window->width = scaled_width; + state->window->height = scaled_height; + g_info("size of window to render: %ux%u", state->window->width, state->window->height); } @@ -655,7 +709,7 @@ state->ui->area = area; state->ui->window = window; - compute_window_size(state); + compute_window_size_and_scaling_factor(state); gtk_widget_set_size_request(area, state->window->width, state->window->height); action_toggle_painting_panel(state, &state->config->show_panel); @@ -666,8 +720,8 @@ } static bool init_gtk_window(struct swappy_state *state) { - if (!state->geometry) { - g_critical("no geometry found, did you use -f option?"); + if (!state->original_image) { + g_critical("original image not loaded"); return false; } @@ -712,12 +766,11 @@ if (has_option_file(state)) { if (is_file_from_stdin(state->file_str)) { - char *new_file_str = file_dump_stdin_into_a_temp_file(); - g_free(state->file_str); - state->file_str = new_file_str; + char *temp_file_str = file_dump_stdin_into_a_temp_file(); + state->temp_file_str = temp_file_str; } - if (!buffer_init_from_file(state)) { + if (!pixbuf_init_from_file(state)) { return EXIT_FAILURE; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/buffer.c new/swappy-1.3.0/src/buffer.c --- old/swappy-1.2.1/src/buffer.c 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/buffer.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,91 +0,0 @@ -#include "buffer.h" - -#include <cairo.h> - -#include "box.h" -#include "swappy.h" - -bool buffer_init_from_file(struct swappy_state *state) { - char *file = state->file_str; - - cairo_surface_t *surface = cairo_image_surface_create_from_png(file); - cairo_status_t status = cairo_surface_status(surface); - - if (status) { - g_warning("error while loading png file: %s - cairo status: %s", file, - cairo_status_to_string(status)); - return false; - } - - int width = cairo_image_surface_get_width(surface); - int height = cairo_image_surface_get_height(surface); - - struct swappy_box *geometry = g_new(struct swappy_box, 1); - - geometry->x = 0; - geometry->y = 0; - geometry->width = (int32_t)width; - geometry->height = (int32_t)height; - - g_info("size of image: %dx%d", width, height); - - state->geometry = geometry; - - cairo_pattern_t *output_pattern = cairo_pattern_create_for_surface(surface); - state->patterns = g_list_append(state->patterns, output_pattern); - state->original_image_surface = surface; - - return true; -} - -static void scale_pattern(gpointer data, gpointer user_data) { - struct swappy_state *state = (struct swappy_state *)user_data; - cairo_pattern_t *pattern = (cairo_pattern_t *)data; - int image_width, image_height; - int rendered_width, rendered_height; - - image_width = state->geometry->width; - image_height = state->geometry->height; - - rendered_width = state->drawing_area_rect->width; - rendered_height = state->drawing_area_rect->height; - - cairo_surface_t *scaled = cairo_surface_create_similar( - state->rendered_surface, CAIRO_CONTENT_COLOR_ALPHA, rendered_width, - rendered_height); - cairo_t *cr = cairo_create(scaled); - - double sx = (double)rendered_width / image_width; - double sy = (double)rendered_height / image_height; - - cairo_matrix_t matrix; - cairo_matrix_init_scale(&matrix, 1.0 / sx, 1.0 / sy); - cairo_pattern_set_matrix(pattern, &matrix); - cairo_set_source_surface(cr, state->original_image_surface, 0, 0); - cairo_set_source(cr, pattern); - cairo_paint(cr); - - cairo_destroy(cr); - - if (state->scaled_image_surface) { - cairo_surface_destroy(state->scaled_image_surface); - } - - state->scaled_image_surface = scaled; -} - -void buffer_resize_patterns(struct swappy_state *state) { - g_list_foreach(state->patterns, scale_pattern, state); -} - -static void free_pattern(gpointer data) { - cairo_pattern_t *pattern = data; - cairo_pattern_destroy(pattern); -} - -void buffer_free_all(struct swappy_state *state) { - if (state->patterns) { - g_list_free_full(state->patterns, free_pattern); - state->patterns = NULL; - } -} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/clipboard.c new/swappy-1.3.0/src/clipboard.c --- old/swappy-1.2.1/src/clipboard.c 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/clipboard.c 2021-02-18 01:45:00.000000000 +0100 @@ -4,7 +4,6 @@ #include <sys/wait.h> #include <unistd.h> -#include "notification.h" #include "pixbuf.h" #include "util.h" @@ -33,7 +32,7 @@ close(pipefd[1]); dup2(pipefd[0], STDIN_FILENO); close(pipefd[0]); - execlp("wl-copy", "wl-copy", NULL); + execlp("wl-copy", "wl-copy", "-t", "image/png", NULL); g_warning( "Unable to copy contents to clipboard. Please make sure you have " "`wl-clipboard`, `xclip`, or `xsel` installed."); @@ -81,10 +80,7 @@ send_pixbuf_to_gdk_clipboard(pixbuf); } - char message[MAX_PATH]; - g_snprintf(message, MAX_PATH, "Swappshot copied to clipboard\n"); - notification_send("Swappy", message); g_object_unref(pixbuf); return true; -} \ No newline at end of file +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/config.c new/swappy-1.3.0/src/config.c --- old/swappy-1.2.1/src/config.c 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/config.c 2021-02-18 01:45:00.000000000 +0100 @@ -14,6 +14,7 @@ g_info("printing config:"); g_info("config_dir: %s", config->config_file); g_info("save_dir: %s", config->save_dir); + g_info("save_filename_format: %s", config->save_filename_format); g_info("show_panel: %d", config->show_panel); g_info("line_size: %d", config->line_size); g_info("text_font: %s", config->text_font); @@ -69,6 +70,7 @@ GKeyFile *gkf; const gchar *group = "Default"; gchar *save_dir = NULL; + gchar *save_filename_format = NULL; gboolean show_panel; gchar *save_dir_expanded = NULL; guint64 line_size, text_size; @@ -108,6 +110,17 @@ error = NULL; } + save_filename_format = + g_key_file_get_string(gkf, group, "save_filename_format", &error); + + if (error == NULL) { + config->save_filename_format = save_filename_format; + } else { + g_info("save_filename_format is missing in %s (%s)", file, error->message); + g_error_free(error); + error = NULL; + } + line_size = g_key_file_get_uint64(gkf, group, "line_size", &error); if (error == NULL) { @@ -172,6 +185,7 @@ } config->save_dir = get_default_save_dir(); + config->save_filename_format = g_strdup(CONFIG_SAVE_FILENAME_FORMAT_DEFAULT); config->line_size = CONFIG_LINE_SIZE_DEFAULT; config->text_font = g_strdup(CONFIG_TEXT_FONT_DEFAULT); config->text_size = CONFIG_TEXT_SIZE_DEFAULT; @@ -200,6 +214,7 @@ if (state->config) { g_free(state->config->config_file); g_free(state->config->save_dir); + g_free(state->config->save_filename_format); g_free(state->config->text_font); g_free(state->config); state->config = NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/file.c new/swappy-1.3.0/src/file.c --- old/swappy-1.2.1/src/file.c 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/file.c 2021-02-18 01:45:00.000000000 +0100 @@ -66,4 +66,4 @@ } return ret; -} \ No newline at end of file +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/notification.c new/swappy-1.3.0/src/notification.c --- old/swappy-1.2.1/src/notification.c 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/notification.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,16 +0,0 @@ -#include "notification.h" - -#ifdef HAVE_LIBNOTIFY -#include <libnotify/notify.h> -#endif - -void notification_send(char *title, char *message) { -#ifdef HAVE_LIBNOTIFY - notify_init("Hello world!"); - NotifyNotification *notification = - notify_notification_new(title, message, "dialog-information"); - notify_notification_show(notification, NULL); - g_object_unref(G_OBJECT(notification)); - notify_uninit(); -#endif -} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/paint.c new/swappy-1.3.0/src/paint.c --- old/swappy-1.2.1/src/paint.c 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/paint.c 2021-02-18 01:45:00.000000000 +0100 @@ -118,6 +118,7 @@ paint->content.shape.a = a; paint->content.shape.w = w; paint->content.shape.type = type; + paint->content.shape.operation = SWAPPY_PAINT_SHAPE_OPERATION_STROKE; break; case SWAPPY_PAINT_MODE_TEXT: paint->can_draw = false; @@ -154,14 +155,6 @@ return; } - int32_t width = state->window->width; - int32_t height = state->window->height; - - // Bounding x and y to the window dimensions to avoid side effects in - // rendering. - x = MIN(MAX(x, 0), width); - y = MIN(MAX(y, 0), height); - switch (paint->type) { case SWAPPY_PAINT_MODE_BLUR: paint->can_draw = true; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/pixbuf.c new/swappy-1.3.0/src/pixbuf.c --- old/swappy-1.2.1/src/pixbuf.c 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/pixbuf.c 2021-02-18 01:45:00.000000000 +0100 @@ -3,13 +3,11 @@ #include <cairo/cairo.h> #include <gio/gunixoutputstream.h> -#include "notification.h" - GdkPixbuf *pixbuf_get_from_state(struct swappy_state *state) { - guint width = cairo_image_surface_get_width(state->rendered_surface); - guint height = cairo_image_surface_get_height(state->rendered_surface); - GdkPixbuf *pixbuf = - gdk_pixbuf_get_from_surface(state->rendered_surface, 0, 0, width, height); + guint width = cairo_image_surface_get_width(state->rendering_surface); + guint height = cairo_image_surface_get_height(state->rendering_surface); + GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface(state->rendering_surface, 0, + 0, width, height); return pixbuf; } @@ -22,26 +20,20 @@ g_critical("unable to save drawing area to pixbuf: %s", error->message); g_error_free(error); } - - char *msg = "Saved Swappshot to: "; - size_t len = strlen(msg) + strlen(path) + 1; - char *message = g_new(char, len); - g_snprintf(message, len, "%s%s", msg, path); - notification_send("Swappy", message); - g_free(message); } -void pixbuf_save_state_to_folder(GdkPixbuf *pixbuf, char *folder) { - time_t current_time; +void pixbuf_save_state_to_folder(GdkPixbuf *pixbuf, char *folder, + char *filename_format) { + time_t current_time = time(NULL); char *c_time_string; - - time(¤t_time); + char filename[strlen(filename_format) + 3]; 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]; - g_snprintf(path, MAX_PATH, "%s/%s %s.png", folder, "Swappshot", - c_time_string); + g_snprintf(path, MAX_PATH, "%s/%s", folder, filename); write_file(pixbuf, path); } @@ -62,6 +54,21 @@ g_object_unref(out); } +GdkPixbuf *pixbuf_init_from_file(struct swappy_state *state) { + GError *error = NULL; + char *file = + state->temp_file_str != NULL ? state->temp_file_str : state->file_str; + GdkPixbuf *image = gdk_pixbuf_new_from_file(file, &error); + + if (error != NULL) { + g_error("unable to load file: %s - reason: %s", file, error->message); + return NULL; + } + + state->original_image = image; + return image; +} + void pixbuf_save_to_file(GdkPixbuf *pixbuf, char *file) { if (g_strcmp0(file, "-") == 0) { pixbuf_save_to_stdout(pixbuf); @@ -69,3 +76,54 @@ write_file(pixbuf, file); } } + +void pixbuf_scale_surface_from_widget(struct swappy_state *state, + GtkWidget *widget) { + GtkAllocation *alloc = g_new(GtkAllocation, 1); + GdkPixbuf *image = state->original_image; + gtk_widget_get_allocation(widget, alloc); + + gboolean has_alpha = gdk_pixbuf_get_has_alpha(image); + cairo_format_t format = has_alpha ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24; + gint image_width = gdk_pixbuf_get_width(image); + gint image_height = gdk_pixbuf_get_height(image); + + cairo_surface_t *original_image_surface = + cairo_image_surface_create(format, image_width, image_height); + + if (!original_image_surface) { + g_error("unable to create cairo original surface from pixbuf"); + goto finish; + } else { + cairo_t *cr; + cr = cairo_create(original_image_surface); + gdk_cairo_set_source_pixbuf(cr, image, 0, 0); + cairo_paint(cr); + cairo_destroy(cr); + } + + cairo_surface_t *rendering_surface = + cairo_image_surface_create(format, image_width, image_height); + + if (!rendering_surface) { + g_error("unable to create rendering surface"); + goto finish; + } + + g_info("size of area to render: %ux%u", alloc->width, alloc->height); + +finish: + if (state->original_image_surface) { + cairo_surface_destroy(state->original_image_surface); + state->original_image_surface = NULL; + } + state->original_image_surface = original_image_surface; + + if (state->rendering_surface) { + cairo_surface_destroy(state->rendering_surface); + state->rendering_surface = NULL; + } + state->rendering_surface = rendering_surface; + + g_free(alloc); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/po/LINGUAS new/swappy-1.3.0/src/po/LINGUAS --- old/swappy-1.2.1/src/po/LINGUAS 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/po/LINGUAS 2021-02-18 01:45:00.000000000 +0100 @@ -1,2 +1,5 @@ # Set of available languages. -en \ No newline at end of file +en +de +tr +pt_BR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/po/POTFILES new/swappy-1.3.0/src/po/POTFILES --- old/swappy-1.2.1/src/po/POTFILES 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/po/POTFILES 2021-02-18 01:45:00.000000000 +0100 @@ -1 +1 @@ -res/swappy.glade \ No newline at end of file +res/swappy.glade diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/po/de.po new/swappy-1.3.0/src/po/de.po --- old/swappy-1.2.1/src/po/de.po 1970-01-01 01:00:00.000000000 +0100 +++ new/swappy-1.3.0/src/po/de.po 2021-02-18 01:45:00.000000000 +0100 @@ -0,0 +1,50 @@ +# German translations for swappy package. +# Copyright (C) 2020 THE swappy'S COPYRIGHT HOLDER +# This file is distributed under the same license as the swappy package. +# Brodi <[email protected]>, 2020. +# +msgid "" +msgstr "" +"Project-Id-Version: swappy\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-06-21 21:57-0400\n" +"PO-Revision-Date: 2020-11-19 18:03+0300\n" +"Last-Translator: Brodi <[email protected]>\n" +"Language-Team: none\n" +"Language: de\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 "Linienst??rke" + +#: res/swappy.glade:525 +msgid "Text Size" +msgstr "Textgr????e" + +#: res/swappy.glade:641 +msgid "Toggle Paint Panel" +msgstr "Farbtafel umschalten" + +#: res/swappy.glade:667 +msgid "Undo Last Paint" +msgstr "Letzte Bemalung r??ckg??ngig machen" + +#: res/swappy.glade:686 +msgid "Redo Previous Paint" +msgstr "Vorherige Bemalung wiederherstellen" + +#: res/swappy.glade:705 +msgid "Clear Paints" +msgstr "Bemalung l??schen" + +#: res/swappy.glade:733 +msgid "Copy Surface" +msgstr "Fl??che kopieren" + +#: res/swappy.glade:749 +msgid "Save Surface" +msgstr "Fl??che speichern" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/po/pt_BR.po new/swappy-1.3.0/src/po/pt_BR.po --- old/swappy-1.2.1/src/po/pt_BR.po 1970-01-01 01:00:00.000000000 +0100 +++ new/swappy-1.3.0/src/po/pt_BR.po 2021-02-18 01:45:00.000000000 +0100 @@ -0,0 +1,51 @@ +# Brazilian Portuguese translation for swappy +# Copyright (C) 2020 Jeremy Attali +# This file is distributed under the MIT License +# Gustavo Costa <[email protected]>, 2021. +# +msgid "" +msgstr "" +"Project-Id-Version: swappy\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-06-21 21:57-0400\n" +"PO-Revision-Date: 2021-02-14 20:38-0300\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.4.2\n" +"Last-Translator: Gustavo Costa <[email protected]>\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Language: pt_BR\n" + +#: res/swappy.glade:455 +msgid "Line Width" +msgstr "Espessura da linha" + +#: res/swappy.glade:525 +msgid "Text Size" +msgstr "Tamanho do texto" + +#: res/swappy.glade:641 +msgid "Toggle Paint Panel" +msgstr "Alternar painel de pintura" + +#: res/swappy.glade:667 +msgid "Undo Last Paint" +msgstr "Desfazer ??ltima pintura" + +#: res/swappy.glade:686 +msgid "Redo Previous Paint" +msgstr "Refazer pintura anterior" + +#: res/swappy.glade:705 +msgid "Clear Paints" +msgstr "Limpar pinturas" + +#: res/swappy.glade:733 +msgid "Copy Surface" +msgstr "Copiar superf??cie" + +#: res/swappy.glade:749 +msgid "Save Surface" +msgstr "Salvar superf??cie" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/po/swappy.desktop.in new/swappy-1.3.0/src/po/swappy.desktop.in --- old/swappy-1.2.1/src/po/swappy.desktop.in 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/po/swappy.desktop.in 2021-02-18 01:45:00.000000000 +0100 @@ -1,7 +1,9 @@ [Desktop Entry] Name=Swappy GenericName=Annotation Tool +GenericName[pt_BR]=Ferramenta de Anota????o Comment=A Wayland native snapshot editing tool +Comment[pt_BR]=Uma ferramenta de edi????o de snapshot nativa do Wayland TryExec=swappy Exec=swappy -f %F Terminal=true @@ -10,4 +12,4 @@ Icon=swappy Categories=Utility;Graphics;Annotation; StartupNotify=true -MimeType=image/png; \ No newline at end of file +MimeType=image/png; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/po/tr.po new/swappy-1.3.0/src/po/tr.po --- old/swappy-1.2.1/src/po/tr.po 1970-01-01 01:00:00.000000000 +0100 +++ new/swappy-1.3.0/src/po/tr.po 2021-02-18 01:45:00.000000000 +0100 @@ -0,0 +1,50 @@ +# Turkish translations for swappy package. +# Copyright (C) 2020 THE swappy'S COPYRIGHT HOLDER +# This file is distributed under the same license as the swappy package. +# O??uz Ersen <[email protected]>, 2020. +# +msgid "" +msgstr "" +"Project-Id-Version: swappy\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-06-21 21:57-0400\n" +"PO-Revision-Date: 2020-10-16 22:00+0300\n" +"Last-Translator: O??uz Ersen <[email protected]>\n" +"Language-Team: none\n" +"Language: tr\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 "??izgi Geni??li??i" + +#: res/swappy.glade:525 +msgid "Text Size" +msgstr "Metin Boyutu" + +#: res/swappy.glade:641 +msgid "Toggle Paint Panel" +msgstr "Boyama Panelini A??/Kapat" + +#: res/swappy.glade:667 +msgid "Undo Last Paint" +msgstr "Son Boyamay?? Geri Al" + +#: res/swappy.glade:686 +msgid "Redo Previous Paint" +msgstr "??nceki Boyamay?? Tekrarla" + +#: res/swappy.glade:705 +msgid "Clear Paints" +msgstr "Boyamalar?? Temizle" + +#: res/swappy.glade:733 +msgid "Copy Surface" +msgstr "Y??zeyi Kopyala" + +#: res/swappy.glade:749 +msgid "Save Surface" +msgstr "Y??zeyi Kaydet" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/src/render.c new/swappy-1.3.0/src/render.c --- old/swappy-1.2.1/src/render.c 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/src/render.c 2021-02-18 01:45:00.000000000 +0100 @@ -45,10 +45,10 @@ switch (src_format) { case CAIRO_FORMAT_A1: case CAIRO_FORMAT_A8: - case CAIRO_FORMAT_RGB24: default: g_warning("source surface format: %d is not supported", src_format); return NULL; + case CAIRO_FORMAT_RGB24: case CAIRO_FORMAT_ARGB32: break; } @@ -315,7 +315,18 @@ cairo_rectangle(cr, x, y, w, h); cairo_close_path(cr); - cairo_stroke(cr); + + switch (shape.operation) { + case SWAPPY_PAINT_SHAPE_OPERATION_STROKE: + cairo_stroke(cr); + break; + case SWAPPY_PAINT_SHAPE_OPERATION_FILL: + cairo_fill(cr); + break; + default: + cairo_stroke(cr); + break; + } } static void render_shape(cairo_t *cr, struct swappy_paint_shape shape) { @@ -346,9 +357,6 @@ cairo_surface_t *target = cairo_get_target(cr); - double a, b; - cairo_surface_get_device_scale(target, &a, &b); - double x = MIN(blur.from.x, blur.to.x); double y = MIN(blur.from.y, blur.to.y); double w = ABS(blur.from.x - blur.to.x); @@ -356,18 +364,29 @@ cairo_save(cr); - if (!paint->is_committed) { - cairo_surface_t *blurred = blur_surface(target, x, y, w, h); - - if (blurred && cairo_surface_status(blurred) == CAIRO_STATUS_SUCCESS) { - cairo_set_source_surface(cr, blurred, x, y); - cairo_paint(cr); - if (blur.surface) { - cairo_surface_destroy(blur.surface); + if (paint->is_committed) { + // Surface has already been blurred, reuse it in future passes + if (blur.surface) { + cairo_surface_t *surface = blur.surface; + if (surface && cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS) { + cairo_set_source_surface(cr, surface, x, y); + cairo_paint(cr); + } + } else { + // Blur surface and reuse it in future passes + g_info( + "blurring surface on following image coordinates: %.2lf,%.2lf size: " + "%.2lfx%.2lf", + x, y, w, h); + cairo_surface_t *blurred = blur_surface(target, x, y, w, h); + + if (blurred && cairo_surface_status(blurred) == CAIRO_STATUS_SUCCESS) { + cairo_set_source_surface(cr, blurred, x, y); + cairo_paint(cr); + paint->content.blur.surface = blurred; } - paint->content.blur.surface = blurred; } - + } else { // Blur not committed yet, draw bounding rectangle struct swappy_paint_shape rect = { .r = 0, @@ -378,15 +397,9 @@ .from = blur.from, .to = blur.to, .type = SWAPPY_PAINT_MODE_RECTANGLE, + .operation = SWAPPY_PAINT_SHAPE_OPERATION_FILL, }; render_shape_rectangle(cr, rect); - - } else { - cairo_surface_t *surface = blur.surface; - if (surface && cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS) { - cairo_set_source_surface(cr, surface, x, y); - cairo_paint(cr); - } } cairo_restore(cr); @@ -413,7 +426,7 @@ } static void render_image(cairo_t *cr, struct swappy_state *state) { - cairo_surface_t *surface = state->scaled_image_surface; + cairo_surface_t *surface = state->original_image_surface; cairo_save(cr); @@ -462,7 +475,7 @@ } void render_state(struct swappy_state *state) { - cairo_surface_t *surface = state->rendered_surface; + cairo_surface_t *surface = state->rendering_surface; cairo_t *cr = cairo_create(surface); render_background(cr, state); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/swappy-1.2.1/swappy.1.scd new/swappy-1.3.0/swappy.1.scd --- old/swappy-1.2.1/swappy.1.scd 2020-07-11 18:17:09.000000000 +0200 +++ new/swappy-1.3.0/swappy.1.scd 2021-02-18 01:45:00.000000000 +0100 @@ -37,7 +37,7 @@ *-o, --output-file <file>* Print the final surface to *<file>* when exiting the application. - + If set to *-*, prints the final surface to *stdout*. Note that the *Save* button will save the image to the config *save_dir* @@ -58,6 +58,7 @@ ``` [Default] save_dir=$HOME/Desktop + save_filename_format=swappy-%Y%m%d-%H%M%S.png show_panel=false line_size=5 text_size=20 @@ -65,6 +66,7 @@ ``` - *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). 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)
