From aab11610d8c9e393ffcb63daf81d24fe5d0ac640 Mon Sep 17 00:00:00 2001 From: kotontrion Date: Sun, 17 Nov 2024 13:32:02 +0100 Subject: circularprogress: fix size calculations --- lib/astal/gtk3/src/widget/circularprogress.vala | 64 ++++++++++++++++++------- 1 file changed, 46 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/astal/gtk3/src/widget/circularprogress.vala b/lib/astal/gtk3/src/widget/circularprogress.vala index a3ecdf1..3d7e8bd 100644 --- a/lib/astal/gtk3/src/widget/circularprogress.vala +++ b/lib/astal/gtk3/src/widget/circularprogress.vala @@ -44,26 +44,54 @@ public class Astal.CircularProgress : Gtk.Bin { set_css_name("circular-progress"); } + public override Gtk.SizeRequestMode get_request_mode() { + if(get_child() != null) return get_child().get_request_mode(); + return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH; + } + public override void get_preferred_height(out int minh, out int nath) { - var val = get_style_context().get_property("min-height", Gtk.StateFlags.NORMAL); - if (val.get_int() <= 0) { - minh = 40; - nath = 40; + if(get_child() != null) { + int minw, natw; + get_child().get_preferred_height(out minh, out nath); + get_child().get_preferred_width(out minw, out natw); + + minh = int.max(minw, minh); + nath = int.max(natw, nath); } + var w_val = get_style_context().get_property("min-width", Gtk.StateFlags.NORMAL); + var h_val = get_style_context().get_property("min-height", Gtk.StateFlags.NORMAL); + minh = int.max(w_val.get_int(), minh); + nath = int.max(w_val.get_int(), nath); + minh = int.max(h_val.get_int(), minh); + nath = int.max(h_val.get_int(), nath); + } - minh = val.get_int(); - nath = val.get_int(); + public override void get_preferred_height_for_width(int width, out int minh, out int nath) { + minh = width; + nath = width; } public override void get_preferred_width(out int minw, out int natw) { - var val = get_style_context().get_property("min-width", Gtk.StateFlags.NORMAL); - if (val.get_int() <= 0) { - minw = 40; - natw = 40; + // if(get_child() != null) get_child().get_preferred_width(out minw, out natw); + if(get_child() != null) { + int minh, nath; + get_child().get_preferred_height(out minh, out nath); + get_child().get_preferred_width(out minw, out natw); + + minw = int.max(minw, minh); + natw = int.max(natw, nath); } + var w_val = get_style_context().get_property("min-width", Gtk.StateFlags.NORMAL); + var h_val = get_style_context().get_property("min-height", Gtk.StateFlags.NORMAL); + minw = int.max(w_val.get_int(), minw); + natw = int.max(w_val.get_int(), natw); + minw = int.max(h_val.get_int(), minw); + natw = int.max(h_val.get_int(), natw); + } - minw = val.get_int(); - natw = val.get_int(); + public override void get_preferred_width_for_height(int height, out int minw, out int natw) { + minw = height; + natw = height; } private double to_radian(double percentage) { @@ -115,6 +143,12 @@ public class Astal.CircularProgress : Gtk.Bin { Gtk.Allocation allocation; get_allocation(out allocation); + if (get_child() != null) { + get_child().size_allocate(allocation); + propagate_draw(get_child(), cr); + } + + var styles = get_style_context(); var width = allocation.width; var height = allocation.height; @@ -195,12 +229,6 @@ public class Astal.CircularProgress : Gtk.Bin { cr.arc(end_x, end_y, fg_stroke / 2, 0, 0 - 0.01); cr.fill(); } - - if (get_child() != null) { - get_child().size_allocate(allocation); - propagate_draw(get_child(), cr); - } - return true; } } -- cgit v1.2.3 From 7c33269ac956d30cc7a1c9dcadafeabb03b7740d Mon Sep 17 00:00:00 2001 From: kotontrion Date: Sun, 17 Nov 2024 13:41:27 +0100 Subject: circularprogress: remove comment --- lib/astal/gtk3/src/widget/circularprogress.vala | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/astal/gtk3/src/widget/circularprogress.vala b/lib/astal/gtk3/src/widget/circularprogress.vala index 3d7e8bd..df1635d 100644 --- a/lib/astal/gtk3/src/widget/circularprogress.vala +++ b/lib/astal/gtk3/src/widget/circularprogress.vala @@ -72,7 +72,6 @@ public class Astal.CircularProgress : Gtk.Bin { } public override void get_preferred_width(out int minw, out int natw) { - // if(get_child() != null) get_child().get_preferred_width(out minw, out natw); if(get_child() != null) { int minh, nath; get_child().get_preferred_height(out minh, out nath); -- cgit v1.2.3 From 813abcaa49546c10b5bc46c19bac853b6dc9612d Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 17 Nov 2024 16:16:42 +0000 Subject: fix #88: hyprland sync workspaces before signal emission --- lib/hyprland/hyprland.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index ea95cab..195a3f6 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -393,8 +393,8 @@ public class Hyprland : Object { case "closewindow": _clients.get(args[1]).removed(); _clients.remove(args[1]); - client_removed(args[1]); yield sync_workspaces(); + client_removed(args[1]); notify_property("clients"); break; -- cgit v1.2.3 From 48692ff557f5f9e95744f939e3fcd1054badb585 Mon Sep 17 00:00:00 2001 From: Aylur Date: Mon, 18 Nov 2024 00:50:16 +0000 Subject: fix: #110 notifd urgency hint --- lib/notifd/notification.vala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/notifd/notification.vala b/lib/notifd/notification.vala index 29c6c56..c28138f 100644 --- a/lib/notifd/notification.vala +++ b/lib/notifd/notification.vala @@ -142,9 +142,11 @@ public class AstalNotifd.Notification : Object { return 0; var v = hints.get(hint); - if (v.get_type_string() == "b") + // daemon uses byte as per spec + if (v.get_type_string() == "y") return v.get_byte(); + // proxy uses int64 from json if (v.get_type_string() == "x") return (uint8)v.get_int64(); -- cgit v1.2.3 From dc4d5a43f35b5bf09cde3f73f0ea03aa6c822c3d Mon Sep 17 00:00:00 2001 From: kotontrion Date: Wed, 20 Nov 2024 13:20:51 +0100 Subject: mpris: fix typo in dbus property the property is called SupportedUriSchemes not SupportedUriSchemas --- lib/mpris/cli.vala | 4 ++-- lib/mpris/ifaces.vala | 2 +- lib/mpris/player.vala | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/mpris/cli.vala b/lib/mpris/cli.vala index b71def9..7e15c6e 100644 --- a/lib/mpris/cli.vala +++ b/lib/mpris/cli.vala @@ -179,7 +179,7 @@ int main(string[] argv) { Json.Node to_json(Player p) { var uris = new Json.Builder().begin_array(); - foreach (var uri in p.supported_uri_schemas) + foreach (var uri in p.supported_uri_schemes) uris.add_string_value(uri); uris.end_array(); @@ -189,7 +189,7 @@ Json.Node to_json(Player p) { .set_member_name("available").add_boolean_value(p.available) .set_member_name("identity").add_string_value(p.identity) .set_member_name("entry").add_string_value(p.entry) - .set_member_name("supported_uri_schemas").add_value(uris.get_root()) + .set_member_name("supported_uri_schemes").add_value(uris.get_root()) .set_member_name("loop_status").add_string_value(p.loop_status.to_string()) .set_member_name("shuffle_status").add_string_value(p.shuffle_status.to_string()) .set_member_name("rate").add_double_value(p.rate) diff --git a/lib/mpris/ifaces.vala b/lib/mpris/ifaces.vala index 298a288..8755723 100644 --- a/lib/mpris/ifaces.vala +++ b/lib/mpris/ifaces.vala @@ -21,7 +21,7 @@ private interface AstalMpris.IMpris : PropsIface { public abstract bool has_track_list { get; } public abstract string identity { owned get; } public abstract string desktop_entry { owned get; } - public abstract string[] supported_uri_schemas { owned get; } + public abstract string[] supported_uri_schemes { owned get; } public abstract string[] supported_mime_types { owned get; } } diff --git a/lib/mpris/player.vala b/lib/mpris/player.vala index 2050f61..c69eb21 100644 --- a/lib/mpris/player.vala +++ b/lib/mpris/player.vala @@ -87,7 +87,7 @@ public class AstalMpris.Player : Object { * Almost every media player will include support for the "file" scheme. * Other common schemes are "http" and "rtsp". */ - public string[] supported_uri_schemas { owned get; private set; } + public string[] supported_uri_schemes { owned get; private set; } /** * The mime-types supported by the player. @@ -160,7 +160,7 @@ public class AstalMpris.Player : Object { } /** - * uri scheme should be an element of [property@AstalMpris.Player:supported_uri_schemas] + * uri scheme should be an element of [property@AstalMpris.Player:supported_uri_schemes] * and the mime-type should match one of the elements of [property@AstalMpris.Player:supported_mime_types]. * * @param uri Uri of the track to load. @@ -425,7 +425,7 @@ public class AstalMpris.Player : Object { // has_track_list = proxy.has_track_list; identity = proxy.identity; entry = proxy.desktop_entry; - supported_uri_schemas = proxy.supported_uri_schemas; + supported_uri_schemes = proxy.supported_uri_schemes; supported_mime_types = proxy.supported_mime_types; if (position >= 0) -- cgit v1.2.3 From f9a35261aeb8ea135ff0f279acbf2d12164e427a Mon Sep 17 00:00:00 2001 From: Aylur Date: Thu, 21 Nov 2024 12:48:43 +0000 Subject: fix #114 create client on windowtitlev2 --- lib/hyprland/hyprland.vala | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index 195a3f6..17c426c 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -381,13 +381,8 @@ public class Hyprland : Object { break; case "openwindow": - var addr = args[1].split(",")[0]; - var client = new Client(); - _clients.insert(addr, client); yield sync_clients(); yield sync_workspaces(); - client_added(client); - notify_property("clients"); break; case "closewindow": @@ -426,6 +421,17 @@ public class Hyprland : Object { minimize(get_client(argv[0]), argv[1] == "0"); break; + // first event that signals a new window not openwindow + case "windowtitlev2": + var addr = args[1].split(",")[0]; + var client = new Client(); + _clients.insert(addr, client); + yield sync_clients(); + yield sync_workspaces(); + client_added(client); + notify_property("clients"); + break; + case "windowtitle": yield sync_clients(); break; -- cgit v1.2.3 From 3f554403ff92d6603ff04d13f26a71aba41375df Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 24 Nov 2024 20:21:30 +0000 Subject: fix(hyprland): client creation resolve #124 resolve #131 --- lib/hyprland/hyprland.vala | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index 17c426c..663eb19 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -318,8 +318,19 @@ public class Hyprland : Object { focused_workspace = get_workspace_by_name(argv[1]); break; + // first event that signals a new client case "activewindowv2": - focused_client = get_client(args[1]); + if (args[1] != "" && get_client(args[1]) == null) { + var client = new Client(); + _clients.insert(args[1], client); + yield sync_clients(); + yield sync_workspaces(); + client_added(client); + notify_property("clients"); + focused_client = client; + } else { + focused_client = get_client(args[1]); + } break; // TODO: nag vaxry for fullscreenv2 that passes address @@ -421,19 +432,9 @@ public class Hyprland : Object { minimize(get_client(argv[0]), argv[1] == "0"); break; - // first event that signals a new window not openwindow - case "windowtitlev2": - var addr = args[1].split(",")[0]; - var client = new Client(); - _clients.insert(addr, client); - yield sync_clients(); - yield sync_workspaces(); - client_added(client); - notify_property("clients"); - break; - + // nothing to update case "windowtitle": - yield sync_clients(); + case "windowtitlev2": break; // TODO: -- cgit v1.2.3 From ac304ef346be220dd5c5d3c818c8151bdb78d730 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 24 Nov 2024 20:23:59 +0000 Subject: fix(hyprland): sync monitors on activeworkspace close #130 --- lib/hyprland/hyprland.vala | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index 663eb19..803380d 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -309,6 +309,7 @@ public class Hyprland : Object { switch (args[0]) { case "workspacev2": yield sync_workspaces(); + yield sync_monitors(); focused_workspace = get_workspace(int.parse(args[1])); break; -- cgit v1.2.3 From 3d9c50cb8ade0319c33fbd2daefeaaa698141256 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 24 Nov 2024 22:30:21 +0000 Subject: fix(hyprland): update title --- lib/hyprland/hyprland.vala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index 803380d..9825a91 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -433,9 +433,8 @@ public class Hyprland : Object { minimize(get_client(argv[0]), argv[1] == "0"); break; - // nothing to update - case "windowtitle": case "windowtitlev2": + yield sync_clients(); break; // TODO: -- cgit v1.2.3 From 7b4d2ebdf525f98d1fddffb433ab350c335d168f Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 29 Nov 2024 15:35:22 +0100 Subject: fix(hyprland): sync monitors on focusedmon #147 --- lib/hyprland/hyprland.vala | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index 9825a91..5bdff81 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -315,6 +315,7 @@ public class Hyprland : Object { case "focusedmon": var argv = args[1].split(",", 2); + yield sync_monitors(); focused_monitor = get_monitor_by_name(argv[0]); focused_workspace = get_workspace_by_name(argv[1]); break; -- cgit v1.2.3 From 990f031507b21f8a18c0710016fb76b1f260afe8 Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 29 Nov 2024 16:08:15 +0100 Subject: fix(mpris): reset cover_art fix #142 --- lib/mpris/player.vala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mpris/player.vala b/lib/mpris/player.vala index c69eb21..f4ba8ec 100644 --- a/lib/mpris/player.vala +++ b/lib/mpris/player.vala @@ -498,8 +498,10 @@ public class AstalMpris.Player : Object { } private async void cache_cover() { - if (art_url == null || art_url == "") + if (art_url == null || art_url == "") { + cover_art = null; return; + } var file = File.new_for_uri(art_url); if (file.get_path() != null) { -- cgit v1.2.3 From 92ed24778937b454c5a2c37e664cdd5c865820dc Mon Sep 17 00:00:00 2001 From: municorn Date: Wed, 4 Dec 2024 12:39:10 -0700 Subject: fix(network): specify values for State enum --- lib/network/network.vala | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/network/network.vala b/lib/network/network.vala index 96e19c8..b5a6c61 100644 --- a/lib/network/network.vala +++ b/lib/network/network.vala @@ -104,14 +104,14 @@ public enum AstalNetwork.Primary { // alias for NM.State public enum AstalNetwork.State { - UNKNOWN, - ASLEEP, - DISCONNECTED, - DISCONNECTING, - CONNECTING, - CONNECTED_LOCAL, - CONNECTED_SITE, - CONNECTED_GLOBAL; + UNKNOWN = 0, + ASLEEP = 10, + DISCONNECTED = 20, + DISCONNECTING = 30, + CONNECTING = 40, + CONNECTED_LOCAL = 50, + CONNECTED_SITE = 60, + CONNECTED_GLOBAL = 70; public string to_string() { switch (this) { -- cgit v1.2.3 From ae85ea90419401e726262b466a5c67b533f0746c Mon Sep 17 00:00:00 2001 From: danielwerg <35052399+danielwerg@users.noreply.github.com> Date: Fri, 6 Dec 2024 01:41:00 +0300 Subject: fix(mpris): shuffle/loop unsupported --- lib/mpris/player.vala | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/mpris/player.vala b/lib/mpris/player.vala index f4ba8ec..e6d84bf 100644 --- a/lib/mpris/player.vala +++ b/lib/mpris/player.vala @@ -440,6 +440,9 @@ public class AstalMpris.Player : Object { _loop_status = Loop.from_string(proxy.loop_status); notify_property("loop-status"); } + } else { + _loop_status = Loop.UNSUPPORTED; + notify_property("loop-status"); } if (rate != proxy.rate) { @@ -452,6 +455,9 @@ public class AstalMpris.Player : Object { _shuffle_status = Shuffle.from_bool(proxy.shuffle); notify_property("shuffle-status"); } + } else { + _shuffle_status = Shuffle.UNSUPPORTED; + notify_property("shuffle-status"); } if (volume != proxy.volume) { -- cgit v1.2.3 From 4f47b69946dd7127ba66e6333af4945afaba15de Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 13 Dec 2024 13:28:14 +0100 Subject: fix #179: power profiles missing profile key --- lib/powerprofiles/cli.vala | 2 +- lib/powerprofiles/power-profiles.vala | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/powerprofiles/cli.vala b/lib/powerprofiles/cli.vala index 1e5cc70..87ffe82 100644 --- a/lib/powerprofiles/cli.vala +++ b/lib/powerprofiles/cli.vala @@ -100,7 +100,7 @@ string to_json_string(AstalPowerProfiles.PowerProfiles profiles) { foreach (var prof in profiles.profiles) { profs.add_value(new Json.Builder() .begin_object() - .set_member_name("profie").add_string_value(prof.profile) + .set_member_name("profile").add_string_value(prof.profile) .set_member_name("driver").add_string_value(prof.driver) .set_member_name("cpu_driver").add_string_value(prof.cpu_driver) .set_member_name("platform_driver").add_string_value(prof.platform_driver) diff --git a/lib/powerprofiles/power-profiles.vala b/lib/powerprofiles/power-profiles.vala index a104d2e..931fc04 100644 --- a/lib/powerprofiles/power-profiles.vala +++ b/lib/powerprofiles/power-profiles.vala @@ -113,6 +113,11 @@ public class PowerProfiles : Object { owned get { return proxy.performance_degraded; } } + private string? get_hashtable_string(HashTable table, string key) { + var v = table.get(key); + return v == null ? null : v.get_string(); + } + /** * List of each profile. */ @@ -122,10 +127,10 @@ public class PowerProfiles : Object { for (var i = 0; i < proxy.profiles.length; ++i) { var prof = proxy.profiles[i]; profs[i] = Profile() { - profile = prof.get("Profile").get_string(), - cpu_driver = prof.get("CpuDriver").get_string(), - platform_driver = prof.get("PlatformDriver").get_string(), - driver = prof.get("Driver").get_string() + profile = get_hashtable_string(prof, "Profile"), + cpu_driver = get_hashtable_string(prof, "CpuDriver"), + platform_driver = get_hashtable_string(prof, "PlatformDriver"), + driver = get_hashtable_string(prof, "Driver"), }; } return profs; -- cgit v1.2.3 From c12fb05408c1cd1b1bca545fec636abda52f6755 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sat, 14 Dec 2024 20:14:29 +0100 Subject: style: IO.Process constructor --- lib/astal/io/process.vala | 13 +++++++++++-- lib/astal/io/variable.vala | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/astal/io/process.vala b/lib/astal/io/process.vala index cfd05b9..4b77aee 100644 --- a/lib/astal/io/process.vala +++ b/lib/astal/io/process.vala @@ -76,7 +76,7 @@ public class AstalIO.Process : Object { * * The first element of the vector is executed with the remaining elements as the argument list. */ - public Process.subprocessv(string[] cmd) throws Error { + public Process(string[] cmd) throws Error { Object(argv: cmd); process = new Subprocess.newv(cmd, SubprocessFlags.STDIN_PIPE | @@ -90,6 +90,15 @@ public class AstalIO.Process : Object { read_stream(err_stream, false); } + /** + * Start a new subprocess with the given command. + * + * The first element of the vector is executed with the remaining elements as the argument list. + */ + public static Process subprocessv(string[] cmd) throws Error { + return new Process(cmd); + } + /** * Start a new subprocess with the given command * which is parsed using [func@GLib.shell_parse_argv]. @@ -97,7 +106,7 @@ public class AstalIO.Process : Object { public static Process subprocess(string cmd) throws Error { string[] argv; Shell.parse_argv(cmd, out argv); - return new Process.subprocessv(argv); + return Process.subprocessv(argv); } /** diff --git a/lib/astal/io/variable.vala b/lib/astal/io/variable.vala index 312a27a..e4105f8 100644 --- a/lib/astal/io/variable.vala +++ b/lib/astal/io/variable.vala @@ -172,7 +172,7 @@ public class AstalIO.Variable : VariableBase { return_if_fail(watch_proc == null); return_if_fail(watch_exec != null); - watch_proc = new Process.subprocessv(watch_exec); + watch_proc = Process.subprocessv(watch_exec); watch_proc.stdout.connect((str) => set_closure(str, watch_transform)); watch_proc.stderr.connect((str) => this.error(str)); } -- cgit v1.2.3