File: gtk-rs-0.10.patch

package info (click to toggle)
swayosd 0.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 552 kB
  • sloc: xml: 26; makefile: 20
file content (98 lines) | stat: -rw-r--r-- 3,269 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
From 77b81d569aaf58da97dae7626cd88ddee9451e11 Mon Sep 17 00:00:00 2001
From: Ferdinand Bachmann <ferdinand.bachmann@yrlf.at>
Date: Fri, 5 Sep 2025 20:42:16 +0200
Subject: [PATCH] Update gtk4 to 0.10.0 and gtk4-layer-shell to 0.6.3

gtk4 0.10.0 changed exit code handling so it now needs to be wrapped in
a std::ops::ControlFlow::Break(glib::ExitCode::new(... as u8)).
Create a new utility method on HandleLocalStatus to reduce clutter.

Fixes #171
---
 Cargo.toml                |  4 +-
 src/client/main.rs        |  8 ++--
 src/global_utils.rs       |  9 +++-
 src/server/application.rs |  4 +-
 5 files changed, 63 insertions(+), 56 deletions(-)

--- a/src/client/main.rs
+++ b/src/client/main.rs
@@ -241,19 +241,19 @@
 		let variant = args.to_variant();
 		if variant.n_children() == 0 {
 			eprintln!("No args provided...");
-			return HandleLocalStatus::FAILURE as i32;
+			return HandleLocalStatus::FAILURE.as_return_code();
 		}
 		let actions = match handle_application_args(variant) {
 			(HandleLocalStatus::SUCCESS, actions) => actions,
-			(status @ HandleLocalStatus::FAILURE, _) => return status as i32,
-			(status @ HandleLocalStatus::CONTINUE, _) => return status as i32,
+			(status @ HandleLocalStatus::FAILURE, _) => return status.as_return_code(),
+			(status @ HandleLocalStatus::CONTINUE, _) => return status.as_return_code(),
 		};
 		// execute the sorted actions
 		for (arg_type, data) in actions {
 			let _ = proxy.handle_action(arg_type.to_string(), data.unwrap_or(String::new()));
 		}
 
-		HandleLocalStatus::SUCCESS as i32
+		HandleLocalStatus::SUCCESS.as_return_code()
 	});
 
 	std::process::exit(app.run().into());
--- a/src/global_utils.rs
+++ b/src/global_utils.rs
@@ -1,4 +1,5 @@
-use gtk::glib::{variant::DictEntry, Variant};
+use gtk::glib::{variant::DictEntry, ExitCode, Variant};
+use std::ops::ControlFlow;
 
 use crate::argtypes::ArgTypes;
 
@@ -8,6 +9,12 @@
 	CONTINUE = -1,
 }
 
+impl HandleLocalStatus {
+	pub fn as_return_code(self) -> ControlFlow<ExitCode> {
+		ControlFlow::Break(ExitCode::new(self as u8))
+	}
+}
+
 pub(crate) fn handle_application_args(
 	variant: Variant,
 ) -> (HandleLocalStatus, Vec<(ArgTypes, Option<String>)>) {
--- a/src/server/application.rs
+++ b/src/server/application.rs
@@ -97,7 +97,7 @@
 			move |_app, args| {
 				let actions = match handle_application_args(args.to_variant()) {
 					(HandleLocalStatus::SUCCESS | HandleLocalStatus::CONTINUE, actions) => actions,
-					(status @ HandleLocalStatus::FAILURE, _) => return status as i32,
+					(status @ HandleLocalStatus::FAILURE, _) => return status.as_return_code(),
 				};
 				for (arg_type, data) in actions {
 					match (arg_type, data) {
@@ -128,7 +128,7 @@
 					}
 				}
 
-				HandleLocalStatus::CONTINUE as i32
+				HandleLocalStatus::CONTINUE.as_return_code()
 			}
 		));
 
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,8 +23,8 @@
 serde = "1"
 serde_derive = "1"
 # GUI Dependencies
-gtk = { package = "gtk4", version = "0.9.7" }
-gtk-layer-shell = { package = "gtk4-layer-shell", version = "0.5.0" }
+gtk = { package = "gtk4", version = "0.10" }
+gtk-layer-shell = { package = "gtk4-layer-shell", version = "0.6.0" }
 shrinkwraprs = "0.3.0"
 cascade = "1.0.1"
 pulse = { version = "2.30.1", package = "libpulse-binding" }