From e6571bcc1358ab13a2304b7644f0690ba9810ab2 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 19 Feb 2023 00:46:00 +0900 Subject: [PATCH 1/6] Remove some deprecations and fix compile warnings --- lib/DragDropAction.vala | 2 ++ lib/Utils.vala | 6 ++-- meson.build | 2 +- src/AccentColor/AccentColorManager.vala | 7 ++++- src/Main.vala | 6 ++-- src/PluginManager.vala | 4 ++- src/ScreenshotManager.vala | 41 ++++++++++++++----------- src/Widgets/WindowCloneContainer.vala | 2 ++ src/Widgets/WindowSwitcher.vala | 2 +- src/WindowTracker.vala | 1 - 10 files changed, 44 insertions(+), 29 deletions(-) diff --git a/lib/DragDropAction.vala b/lib/DragDropAction.vala index 65879276a..91315a60d 100644 --- a/lib/DragDropAction.vala +++ b/lib/DragDropAction.vala @@ -375,6 +375,8 @@ namespace Gala { return true; } + break; + default: break; } diff --git a/lib/Utils.vala b/lib/Utils.vala index 40a6ca9dd..818effdbd 100644 --- a/lib/Utils.vala +++ b/lib/Utils.vala @@ -151,7 +151,7 @@ namespace Gala { // Construct a new "application-default-icon" and store it in the cache try { var icon = Gtk.IconTheme.get_default ().load_icon_for_scale ("application-default-icon", icon_size, scale, 0); - unknown_icon_cache.add (new CachedIcon () { icon = icon, icon_size = icon_size, scale = scale }); + unknown_icon_cache.add (CachedIcon () { icon = icon, icon_size = icon_size, scale = scale }); return icon; } catch (Error e) { var icon = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, icon_size * scale, icon_size * scale); @@ -227,7 +227,7 @@ namespace Gala { try { var pixbuf = icon_info.load_icon (); - icon_cache.@set (desktop, new CachedIcon () { icon = pixbuf, icon_size = icon_size, scale = scale }); + icon_cache.@set (desktop, CachedIcon () { icon = pixbuf, icon_size = icon_size, scale = scale }); return pixbuf; } catch (Error e) { return null; @@ -237,7 +237,7 @@ namespace Gala { var size_with_scale = icon_size * scale; try { var pixbuf = new Gdk.Pixbuf.from_stream_at_scale (file.read (), size_with_scale, size_with_scale, true); - icon_cache.@set (desktop, new CachedIcon () { icon = pixbuf, icon_size = icon_size, scale = scale }); + icon_cache.@set (desktop, CachedIcon () { icon = pixbuf, icon_size = icon_size, scale = scale }); return pixbuf; } catch (Error e) { return null; diff --git a/meson.build b/meson.build index 575c27ef4..85440c87b 100644 --- a/meson.build +++ b/meson.build @@ -14,7 +14,7 @@ cc = meson.get_compiler('c') gala_version = meson.project_version() -vala_version_required = '0.28.0' +vala_version_required = '0.40.0' vala = meson.get_compiler('vala') if not vala.version().version_compare('>= @0@'.format(vala_version_required)) error('Valac >= @0@ required!'.format(vala_version_required)) diff --git a/src/AccentColor/AccentColorManager.vala b/src/AccentColor/AccentColorManager.vala index a89a91474..9d981315f 100644 --- a/src/AccentColor/AccentColorManager.vala +++ b/src/AccentColor/AccentColorManager.vala @@ -151,7 +151,12 @@ public class Gala.AccentColorManager : Object { return null; } - return metadata.get_tag_string (TAG_ACCENT_COLOR); + try { + return metadata.try_get_tag_string (TAG_ACCENT_COLOR); + } catch (Error e) { + warning (e.message); + return null; + } } private NamedColor? get_accent_color (ColorExtractor color_extractor) { diff --git a/src/Main.vala b/src/Main.vala index 86a09108e..640ee5c2e 100644 --- a/src/Main.vala +++ b/src/Main.vala @@ -51,15 +51,15 @@ namespace Gala { act.sa_mask = empty_mask; act.sa_flags = 0; - if (Posix.sigaction (Posix.SIGPIPE, act, null) < 0) { + if (Posix.sigaction (Posix.Signal.PIPE, act, null) < 0) { warning ("Failed to register SIGPIPE handler: %s", GLib.strerror (GLib.errno)); } - if (Posix.sigaction (Posix.SIGXFSZ, act, null) < 0) { + if (Posix.sigaction (Posix.Signal.XFSZ, act, null) < 0) { warning ("Failed to register SIGXFSZ handler: %s", GLib.strerror (GLib.errno)); } - GLib.Unix.signal_add (Posix.SIGTERM, () => { + GLib.Unix.signal_add (Posix.Signal.TERM, () => { ctx.terminate (); return GLib.Source.REMOVE; }); diff --git a/src/PluginManager.vala b/src/PluginManager.vala index cb87ed390..522c1f5e5 100644 --- a/src/PluginManager.vala +++ b/src/PluginManager.vala @@ -86,7 +86,7 @@ namespace Gala { bool load_module (string plugin_name) { var path = Module.build_path (plugin_dir.get_path (), plugin_name); - var module = Module.open (path, ModuleFlags.BIND_LOCAL); + var module = Module.open (path, ModuleFlags.LOCAL); if (module == null) { warning (Module.error ()); return false; @@ -170,6 +170,8 @@ namespace Gala { } window_switcher_provider = name; return true; + default: + break; } return true; diff --git a/src/ScreenshotManager.vala b/src/ScreenshotManager.vala index 19f294cd8..0fbdf02eb 100644 --- a/src/ScreenshotManager.vala +++ b/src/ScreenshotManager.vala @@ -354,25 +354,30 @@ namespace Gala { paint_flags |= Clutter.PaintFlag.FORCE_CURSORS; } - if (GLib.ByteOrder.HOST == GLib.ByteOrder.LITTLE_ENDIAN) { - wm.stage.paint_to_buffer ( - {x, y, width, height}, - scale, - image.get_data (), - image.get_stride (), - Cogl.PixelFormat.BGRA_8888_PRE, - paint_flags - ); - } else { - wm.stage.paint_to_buffer ( - {x, y, width, height}, - scale, - image.get_data (), - image.get_stride (), - Cogl.PixelFormat.ARGB_8888_PRE, - paint_flags - ); + try { + if (GLib.ByteOrder.HOST == GLib.ByteOrder.LITTLE_ENDIAN) { + wm.stage.paint_to_buffer ( + {x, y, width, height}, + scale, + image.get_data (), + image.get_stride (), + Cogl.PixelFormat.BGRA_8888_PRE, + paint_flags + ); + } else { + wm.stage.paint_to_buffer ( + {x, y, width, height}, + scale, + image.get_data (), + image.get_stride (), + Cogl.PixelFormat.ARGB_8888_PRE, + paint_flags + ); + } + } catch (Error e) { + warning (e.message); } + #else Clutter.Capture[] captures; wm.stage.capture (false, {x, y, width, height}, out captures); diff --git a/src/Widgets/WindowCloneContainer.vala b/src/Widgets/WindowCloneContainer.vala index 91ed9e21e..ee520e6d5 100644 --- a/src/Widgets/WindowCloneContainer.vala +++ b/src/Widgets/WindowCloneContainer.vala @@ -277,6 +277,8 @@ namespace Gala { closest = (WindowClone) window; } break; + default: + break; } } diff --git a/src/Widgets/WindowSwitcher.vala b/src/Widgets/WindowSwitcher.vala index b913c59a8..6db51e8cb 100644 --- a/src/Widgets/WindowSwitcher.vala +++ b/src/Widgets/WindowSwitcher.vala @@ -128,7 +128,7 @@ namespace Gala { container.motion_event.connect (container_motion_event); var rgba = InternalUtils.get_theme_accent_color (); - var accent_color = new Clutter.Color (); + var accent_color = Clutter.Color (); accent_color.init ( (uint8) (rgba.red * 255), (uint8) (rgba.green * 255), diff --git a/src/WindowTracker.vala b/src/WindowTracker.vala index 3a73ea2aa..7e640f278 100644 --- a/src/WindowTracker.vala +++ b/src/WindowTracker.vala @@ -5,7 +5,6 @@ */ public class Gala.WindowTracker : GLib.Object { - private Gala.App? focused_app = null; private GLib.HashTable window_to_app; public signal void windows_changed (); From 0bec8e3f091ab8df6502e15e6239a8a55acb4266 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 19 Feb 2023 00:48:45 +0900 Subject: [PATCH 2/6] Remove blank line --- src/ScreenshotManager.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ScreenshotManager.vala b/src/ScreenshotManager.vala index 0fbdf02eb..020901099 100644 --- a/src/ScreenshotManager.vala +++ b/src/ScreenshotManager.vala @@ -377,7 +377,6 @@ namespace Gala { } catch (Error e) { warning (e.message); } - #else Clutter.Capture[] captures; wm.stage.capture (false, {x, y, width, height}, out captures); From 3faa1492698c16d99ed2a0d7b32fe922e6fa1f12 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 19 Feb 2023 00:53:04 +0900 Subject: [PATCH 3/6] Bump vala version required --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 85440c87b..21d952b7e 100644 --- a/meson.build +++ b/meson.build @@ -14,7 +14,7 @@ cc = meson.get_compiler('c') gala_version = meson.project_version() -vala_version_required = '0.40.0' +vala_version_required = '0.46.0' vala = meson.get_compiler('vala') if not vala.version().version_compare('>= @0@'.format(vala_version_required)) error('Valac >= @0@ required!'.format(vala_version_required)) From e1a890619d423b03f4cdb3b2beca3b5ab784fbaf Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 19 Feb 2023 00:53:07 +0900 Subject: [PATCH 4/6] Bump vala version in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e44a6ec83..662abb647 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ You'll need the following dependencies: * libgtk-3-dev (>= 3.10.0) * libmutter-6-dev (>= 3.35.1) | libmutter-dev (>= 3.18.3) * libxml2-utils -* valac (>= 0.28.0) +* valac (>= 0.46.0) Run `meson build` to configure the build environment. Change to the build directory and run `ninja` to build From ce82719f73eacae5915e661f2cee7c9658abf865 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 19 Feb 2023 12:34:30 +0900 Subject: [PATCH 5/6] Simplify --- src/AccentColor/AccentColorManager.vala | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/AccentColor/AccentColorManager.vala b/src/AccentColor/AccentColorManager.vala index 9d981315f..f6b04c8ce 100644 --- a/src/AccentColor/AccentColorManager.vala +++ b/src/AccentColor/AccentColorManager.vala @@ -146,15 +146,10 @@ public class Gala.AccentColorManager : Object { path = Filename.from_uri (picture_uri); metadata = new GExiv2.Metadata (); metadata.open_path (path); - } catch (Error e) { - warning ("Error parsing exif metadata of \"%s\": %s", path, e.message); - return null; - } - try { return metadata.try_get_tag_string (TAG_ACCENT_COLOR); } catch (Error e) { - warning (e.message); + warning ("Error parsing exif metadata of \"%s\": %s", path, e.message); return null; } } From da79bac2c195e54b374815f28f239f60614a82ca Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 19 Feb 2023 13:16:18 +0900 Subject: [PATCH 6/6] Remove meson deprecations --- data/meson.build | 8 ++++---- docs/meson.build | 2 +- lib/meson.build | 4 ++-- meson.build | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/data/meson.build b/data/meson.build index e958318a2..833d077b4 100644 --- a/data/meson.build +++ b/data/meson.build @@ -12,7 +12,7 @@ install_data( i18n.merge_file( input: 'gala.appdata.xml.in', output: meson.project_name() + '.appdata.xml', - po_dir: join_paths(meson.source_root(), 'po'), + po_dir: join_paths(meson.global_source_root(), 'po'), type: 'xml', install: true, install_dir: join_paths(get_option('datadir'), 'metainfo'), @@ -21,7 +21,7 @@ i18n.merge_file( i18n.merge_file( input: 'gala-multitaskingview.desktop.in', output: 'gala-multitaskingview.desktop', - po_dir: join_paths(meson.source_root (), 'po'), + po_dir: join_paths(meson.global_source_root (), 'po'), type: 'desktop', install: true, install_dir: join_paths(data_dir, 'applications') @@ -30,7 +30,7 @@ i18n.merge_file( i18n.merge_file( input: 'gala-other.desktop.in', output: 'gala-other.desktop', - po_dir: join_paths(meson.source_root (), 'po'), + po_dir: join_paths(meson.global_source_root (), 'po'), type: 'desktop', install: true, install_dir: join_paths(data_dir, 'applications') @@ -42,7 +42,7 @@ if get_option('systemd') dep_systemd = dependency('systemd', required: true) systemd_userunitdir = get_option('systemduserunitdir') if systemd_userunitdir == '' - systemd_userunitdir = dep_systemd.get_pkgconfig_variable('systemduserunitdir', define_variable: ['prefix', get_option('prefix')]) + systemd_userunitdir = dep_systemd.get_variable('systemduserunitdir', pkgconfig_define: ['prefix', get_option('prefix')]) endif bindir = join_paths(get_option('prefix'), get_option('bindir')) diff --git a/docs/meson.build b/docs/meson.build index c234b86f0..afc761375 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -23,7 +23,7 @@ basic_command = [ '--pkg', 'config', vala_flags, '--vapidir=' + join_paths(meson.build_root(), 'lib'), - '--vapidir=' + join_paths(meson.source_root(), 'vapi'), + '--vapidir=' + join_paths(meson.global_source_root(), 'vapi'), '--doclet=html', '--use-svg-images' ] diff --git a/lib/meson.build b/lib/meson.build index cb4051026..00d1bfe42 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -16,8 +16,8 @@ gala_lib_sources = files( gala_resources = gnome.compile_resources( 'gala-resources', - join_paths(meson.source_root(), 'data', 'gala.gresource.xml'), - source_dir: join_paths(meson.source_root(), 'data'), + join_paths(meson.global_source_root(), 'data', 'gala.gresource.xml'), + source_dir: join_paths(meson.global_source_root(), 'data'), c_name: 'gala', ) diff --git a/meson.build b/meson.build index 21d952b7e..2c7147345 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('gala', 'c', 'vala', version: '7.0.0', - meson_version: '>= 0.50.0', + meson_version: '>= 0.58.0', license: 'GPL3', ) @@ -182,7 +182,7 @@ if mutter_dep.length() == 0 error ('No supported mutter library found!') endif -mutter_typelib_dir = libmutter_dep.get_pkgconfig_variable('typelibdir') +mutter_typelib_dir = libmutter_dep.get_variable('typelibdir') if get_option('systemd') vala_flags += ['--define', 'WITH_SYSTEMD']