[Pkg-lxde-maintainers] Bug#984585: gpicview: make zoom factor steps configurable
hikaru.debian at web.de
hikaru.debian at web.de
Fri Mar 5 13:15:54 GMT 2021
Package: gpicview
Version: 0.2.5-3+b1
Severity: wishlist
Tags: patch upstream
X-Debbugs-Cc: hikaru.debian at web.de
Dear Gpicview Maintainers,
I found gpicview's default zoom factor steps to be too large for my liking, so I
wrote a small patch to make the steps configurable via the configuration file
(but not via GUI).
Please consider including this patch (or something similar) in future versions
of gpicview!
Thanks!
hikaru
-- System Information:
Debian Release: bullseye/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 5.10.0-4-amd64 (SMP w/8 CPU threads)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages gpicview depends on:
ii libatk1.0-0 2.36.0-2
ii libc6 2.31-9
ii libcairo2 1.16.0-5
ii libfontconfig1 2.13.1-4.2
ii libfreetype6 2.10.4+dfsg-1
ii libgdk-pixbuf2.0-0 2.40.2-2
ii libglib2.0-0 2.66.7-1
ii libgtk2.0-0 2.24.33-1
ii libjpeg62-turbo 1:2.0.6-2
ii libpango-1.0-0 1.46.2-3
ii libpangocairo-1.0-0 1.46.2-3
ii libpangoft2-1.0-0 1.46.2-3
ii libx11-6 2:1.7.0-2
Versions of packages gpicview recommends:
ii xdg-utils 1.1.3-4
gpicview suggests no packages.
-- no debconf information
-------------- next part --------------
Description: Make zoom_factor configurable
.
gpicview (0.2.5-3.1) UNRELEASED; urgency=medium
.
* Non-maintainer upload.
* Add option 'zoom_factor=1.05' (old hard-coded default) in gpicview.conf
Author: <hikaru at debian>
---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:
Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2021-03-05
--- /dev/null
+++ gpicview-0.2.5/.vimrc
@@ -0,0 +1,2 @@
+source /usr/share/vim/vim82/defaults.vim
+set mouse=
--- gpicview-0.2.5.orig/src/main-win.c
+++ gpicview-0.2.5/src/main-win.c
@@ -372,9 +372,6 @@ static void update_btns(MainWin* mw)
gboolean main_win_open( MainWin* mw, const char* file_path, ZoomMode zoom )
{
- if(!file_path)
- return FALSE;
-
if (g_file_test(file_path, G_FILE_TEST_IS_DIR))
{
image_list_open_dir( mw->img_list, file_path, NULL );
@@ -935,14 +932,14 @@ void on_open( GtkWidget* btn, MainWin* m
void on_zoom_in( GtkWidget* btn, MainWin* mw )
{
double scale = mw->scale;
- scale *= 1.05;
+ scale *= pref.zoom_factor;
main_win_set_zoom_scale(mw, scale);
}
void on_zoom_out( GtkWidget* btn, MainWin* mw )
{
double scale = mw->scale;
- scale /= 1.05;
+ scale /= pref.zoom_factor;
main_win_set_zoom_scale(mw, scale);
}
--- gpicview-0.2.5.orig/src/pref.c
+++ gpicview-0.2.5/src/pref.c
@@ -27,6 +27,7 @@
#include <glib/gstdio.h>
#include <stdio.h>
+#include <math.h>
#include "pref.h"
#include "main-win.h"
@@ -63,6 +64,20 @@ static int kf_get_int(GKeyFile* kf, cons
return TRUE;
}
+static double kf_get_double(GKeyFile* kf, const char* grp, const char* name, double* ret )
+{
+ GError* err = NULL;
+ double val = g_key_file_get_double(kf, grp, name, &err);
+ if( G_UNLIKELY(err) )
+ {
+ g_error_free(err);
+ return FALSE;
+ }
+ if(G_LIKELY(ret))
+ *ret = val;
+ return TRUE;
+}
+
void load_preferences()
{
/* FIXME: GKeyFile is not fast enough.
@@ -83,6 +98,8 @@ void load_preferences()
pref.jpg_quality = 90;
pref.png_compression = 9;
+ pref.zoom_factor = 1.05;
+
pref.show_toolbar = TRUE;
kf = g_key_file_new();
@@ -99,6 +116,8 @@ void load_preferences()
kf_get_int( kf, "General", "jpg_quality", &pref.jpg_quality);
kf_get_int( kf, "General", "png_compression", &pref.png_compression );
+ kf_get_double( kf, "General", "zoom_factor", &pref.zoom_factor );
+
kf_get_bool( kf, "General", "show_toolbar", &pref.show_toolbar );
color = g_key_file_get_string(kf, "General", "bg", NULL);
@@ -149,6 +168,10 @@ void save_preferences()
fprintf( f, "jpg_quality=%d\n", pref.jpg_quality );
fprintf( f, "png_compression=%d\n", pref.png_compression );
+ /* fprintf honors the locale setting for decimal delimiters and will write a comma instead of a point in some locales (e.g. de_DE).
+ GLib doesn't seem to be able to cope with that and won't accept doubles with a comma. So we need to make sure to always write a point: */
+ fprintf( f, "zoom_factor=%d.%03d\n", (int)pref.zoom_factor, (int) (round((pref.zoom_factor - (int) pref.zoom_factor ) * 1000)) );
+
fprintf( f, "show_toolbar=%d\n", pref.show_toolbar );
fclose( f );
--- gpicview-0.2.5.orig/src/pref.h
+++ gpicview-0.2.5/src/pref.h
@@ -40,6 +40,8 @@ typedef struct _Pref
int jpg_quality;
int png_compression;
+ double zoom_factor;
+
gboolean show_toolbar;
}Pref;
More information about the Pkg-lxde-maintainers
mailing list