From dcc5b6c719bec84fe90c64037fa9a69f53095c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Mon, 25 Jul 2022 14:25:14 +0200 Subject: Use GSettings for a new native window toggle Also, redo desktop files handling. --- README.adoc | 4 ++-- docs/fiv.html | 9 +++++++++ fiv-view.c | 4 +++- fiv.gschema.xml | 14 ++++++++++++++ meson.build | 35 ++++++++++++++++++++++++++--------- 5 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 fiv.gschema.xml diff --git a/README.adoc b/README.adoc index 0ace297..13d92ba 100644 --- a/README.adoc +++ b/README.adoc @@ -50,9 +50,9 @@ ExifTool, resvg (unstable API, needs to be requested explicitly) $ meson compile Considering the vast amount of dynamically-linked dependencies, do not attempt -direct installations. To test the program, help it find its custom thumbnailer: +direct installations via `ninja install`. To test the program: - $ PATH=$(pwd):$PATH ./fiv + $ meson devenv fiv The lossless JPEG cropper is intended to be invoked from a context menu. diff --git a/docs/fiv.html b/docs/fiv.html index 79bf8a6..ffa575d 100644 --- a/docs/fiv.html +++ b/docs/fiv.html @@ -94,6 +94,15 @@ rm -rf ~/.cache/thumbnails/wide-*

Configuration

+

The few configuration options fiv has can be adjusted using +dconf-editor or gsettings. + +

+gsettings list-recursively name.janouch.fiv
+
+ +

Theming

+

The standard means to adjust the looks of the program is through GTK+ 3 CSS. As an example, to tightly pack browser items, put the following in your ~/.config/gtk-3.0/gtk.css: diff --git a/fiv-view.c b/fiv-view.c index c570f35..66944b6 100644 --- a/fiv-view.c +++ b/fiv-view.c @@ -547,7 +547,9 @@ fiv_view_realize(GtkWidget *widget) // // If GTK+'s OpenGL integration fails to deliver, we need to use the window // directly, sidestepping the toolkit entirely. - if (GDK_IS_X11_WINDOW(window)) + GSettings *settings = g_settings_new(PROJECT_NS PROJECT_NAME); + if (GDK_IS_X11_WINDOW(window) && + g_settings_get_boolean(settings, "native-view-window")) gdk_window_ensure_native(window); #endif // GDK_WINDOWING_X11 diff --git a/fiv.gschema.xml b/fiv.gschema.xml new file mode 100644 index 0000000..d52eb46 --- /dev/null +++ b/fiv.gschema.xml @@ -0,0 +1,14 @@ + + + + + true +

Use a native window for the view + + On X11, using native GdkWindows enables use of 30-bit Visuals + (that is, 10 bits per channel), at the cost of disabling + double buffering. + + + + diff --git a/meson.build b/meson.build index 689fa2d..5bdbbd8 100644 --- a/meson.build +++ b/meson.build @@ -70,10 +70,12 @@ endif # XXX: https://github.com/mesonbuild/meson/issues/825 docdir = get_option('datadir') / 'doc' / meson.project_name() +application_ns = 'name.janouch.' conf = configuration_data() conf.set_quoted('PROJECT_NAME', meson.project_name()) conf.set_quoted('PROJECT_VERSION', meson.project_version()) +conf.set_quoted('PROJECT_NS', application_ns) conf.set_quoted('PROJECT_DOCDIR', get_option('prefix') / docdir) conf.set('HAVE_JPEG_QS', libjpegqs.found()) conf.set('HAVE_LCMS2', lcms2.found()) @@ -103,6 +105,7 @@ tiff_tables = custom_target('tiff-tables.h', capture : true, ) +desktops = ['fiv-browse.desktop'] exe = executable('fiv', 'fiv.c', 'fiv-view.c', 'fiv-io.c', 'fiv-context-menu.c', 'fiv-browser.c', 'fiv-sidebar.c', 'fiv-thumbnail.c', 'xdg.c', resources, install : true, @@ -113,14 +116,13 @@ if gdkpixbuf.found() dependencies : [dependencies, gdkpixbuf]) endif +desktops += 'fiv-jpegcrop.desktop' jpegcrop = executable('fiv-jpegcrop', 'fiv-jpegcrop.c', install : true, dependencies : [ dependency('gtk+-3.0'), dependency('libturbojpeg'), ]) -install_data('fiv-jpegcrop.desktop', - install_dir : get_option('datadir') / 'applications') if get_option('tools').enabled() # libjq 1.6 lacks a pkg-config file, and there is no release in sight. @@ -135,15 +137,25 @@ if get_option('tools').enabled() endforeach endif -# XXX: With gdk-pixbuf, this even depends on currently installed modules. +gsettings_schemas = ['fiv.gschema.xml'] +install_data(gsettings_schemas, + rename : [application_ns + gsettings_schemas[0]], + install_dir : get_option('datadir') / 'glib-2.0' / 'schemas') + +# For the purposes of development: make the program find its GSettings schemas. +gnome.compile_schemas(depend_files : files(gsettings_schemas)) + +# TODO(p): With gdk-pixbuf, this even depends on currently installed modules, +# and the package manager needs to be told to keep fiv's desktop file in sync. +# add_install_script() with skip_if_destdir might be a mild improvement. +# In any case, we need to install a script for updating this desktop file. if meson.is_cross_build() - install_data('fiv.desktop', - install_dir : get_option('datadir') / 'applications') + desktops += 'fiv.desktop' else # XXX: The exe path may not contain spaces--quoting is a bitch in Meson. - desktop = custom_target('desktop', - output : 'fiv.desktop', + custom_target( input : 'fiv.desktop', + output : application_ns + 'fiv.desktop', command : ['sh', '-c', '''awk '/^MimeType=/ { $0 = "MimeType="; while (((exe " --list-supported-media-types") | getline type) > 0) $0 = $0 type ";" } 1' "exe=$1" "$2"''', 'sh', exe, '@INPUT@'], @@ -152,9 +164,14 @@ else install_dir : get_option('datadir') / 'applications', ) endif +if host_machine.system() != 'windows' + foreach desktop : desktops + install_data(desktop, + rename : application_ns + desktop, + install_dir : get_option('datadir') / 'applications') + endforeach +endif -install_data('fiv-browse.desktop', - install_dir : get_option('datadir') / 'applications') install_data('fiv.svg', install_dir : get_option('datadir') / 'icons/hicolor/scalable/apps') install_subdir('docs', install_dir : docdir, strip_directory : true) -- cgit v1.2.3