diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/astal/gtk3/src/widget/circularprogress.vala | 63 | ||||
-rw-r--r-- | lib/astal/io/process.vala | 13 | ||||
-rw-r--r-- | lib/astal/io/variable.vala | 2 | ||||
-rw-r--r-- | lib/hyprland/hyprland.vala | 24 | ||||
-rw-r--r-- | lib/mpris/cli.vala | 4 | ||||
-rw-r--r-- | lib/mpris/ifaces.vala | 2 | ||||
-rw-r--r-- | lib/mpris/player.vala | 16 | ||||
-rw-r--r-- | lib/network/network.vala | 16 | ||||
-rw-r--r-- | lib/notifd/notification.vala | 4 | ||||
-rw-r--r-- | lib/powerprofiles/cli.vala | 2 | ||||
-rw-r--r-- | lib/powerprofiles/power-profiles.vala | 13 |
11 files changed, 109 insertions, 50 deletions
diff --git a/lib/astal/gtk3/src/widget/circularprogress.vala b/lib/astal/gtk3/src/widget/circularprogress.vala index a3ecdf1..df1635d 100644 --- a/lib/astal/gtk3/src/widget/circularprogress.vala +++ b/lib/astal/gtk3/src/widget/circularprogress.vala @@ -44,26 +44,53 @@ 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) { + 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 +142,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 +228,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; } } 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 | @@ -91,13 +91,22 @@ public class AstalIO.Process : Object { } /** + * 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 [[email protected]_parse_argv]. */ 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)); } diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index ea95cab..5bdff81 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -309,17 +309,30 @@ public class Hyprland : Object { switch (args[0]) { case "workspacev2": yield sync_workspaces(); + yield sync_monitors(); focused_workspace = get_workspace(int.parse(args[1])); break; 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; + // 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 @@ -381,20 +394,15 @@ 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": _clients.get(args[1]).removed(); _clients.remove(args[1]); - client_removed(args[1]); yield sync_workspaces(); + client_removed(args[1]); notify_property("clients"); break; @@ -426,7 +434,7 @@ public class Hyprland : Object { minimize(get_client(argv[0]), argv[1] == "0"); break; - case "windowtitle": + case "windowtitlev2": yield sync_clients(); break; 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..e6d84bf 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 [[email protected]:supported_uri_schemas] + * uri scheme should be an element of [[email protected]:supported_uri_schemes] * and the mime-type should match one of the elements of [[email protected]: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) @@ -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) { @@ -498,8 +504,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) { 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) { 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(); 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<string, Variant> 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; |