From 18c0a31fa41f925e3324042bea940155ae6bf774 Mon Sep 17 00:00:00 2001 From: kotontrion Date: Wed, 18 Sep 2024 11:50:29 +0200 Subject: device id null check --- lib/wireplumber/src/endpoint.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/wireplumber/src/endpoint.c b/lib/wireplumber/src/endpoint.c index 8d5411d..9ae62e2 100644 --- a/lib/wireplumber/src/endpoint.c +++ b/lib/wireplumber/src/endpoint.c @@ -345,6 +345,7 @@ static void astal_wp_endpoint_set_property(GObject *object, guint property_id, c } static void astal_wp_endpoint_update_properties(AstalWpEndpoint *self) { + AstalWpEndpointPrivate *priv = astal_wp_endpoint_get_instance_private(self); if (priv->node == NULL) return; self->id = wp_proxy_get_bound_id(WP_PROXY(priv->node)); @@ -379,9 +380,11 @@ static void astal_wp_endpoint_update_properties(AstalWpEndpoint *self) { case ASTAL_WP_MEDIA_CLASS_AUDIO_MICROPHONE: const gchar *dev = wp_pipewire_object_get_property(WP_PIPEWIRE_OBJECT(priv->node), "device.id"); - guint device_id = g_ascii_strtoull(dev, NULL, 10); - AstalWpDevice *device = astal_wp_wp_get_device(priv->wp, device_id); - icon = astal_wp_device_get_icon(device); + if (dev != NULL) { + guint device_id = g_ascii_strtoull(dev, NULL, 10); + AstalWpDevice *device = astal_wp_wp_get_device(priv->wp, device_id); + icon = astal_wp_device_get_icon(device); + } if (icon == NULL) { icon = self->type == ASTAL_WP_MEDIA_CLASS_AUDIO_SPEAKER ? "audio-card-symbolic" -- cgit v1.2.3 From de096e16da8a76c60b97ca0238a1cd1b545fa295 Mon Sep 17 00:00:00 2001 From: kotontrion Date: Wed, 18 Sep 2024 12:55:40 +0200 Subject: wireplumber: rename get_default_wp to get_default --- examples/js/simple-bar/widget/Bar.tsx | 2 +- examples/lua/simple-bar/widget/Bar.lua | 2 +- lib/wireplumber/include/astal/wireplumber/wp.h | 2 +- lib/wireplumber/src/wireplumber.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/js/simple-bar/widget/Bar.tsx b/examples/js/simple-bar/widget/Bar.tsx index 492ab1d..19e1133 100644 --- a/examples/js/simple-bar/widget/Bar.tsx +++ b/examples/js/simple-bar/widget/Bar.tsx @@ -39,7 +39,7 @@ function Wifi() { } function AudioSlider() { - const speaker = Wp.get_default_wp()?.audio.defaultSpeaker! + const speaker = Wp.get_default()?.audio.defaultSpeaker! return diff --git a/examples/lua/simple-bar/widget/Bar.lua b/examples/lua/simple-bar/widget/Bar.lua index bf70cd5..56cb060 100644 --- a/examples/lua/simple-bar/widget/Bar.lua +++ b/examples/lua/simple-bar/widget/Bar.lua @@ -72,7 +72,7 @@ local function Wifi() end local function AudioSlider() - local speaker = Wp.get_default_wp().audio.default_speaker + local speaker = Wp.get_default().audio.default_speaker return Widget.Box({ class_name = "AudioSlider", diff --git a/lib/wireplumber/include/astal/wireplumber/wp.h b/lib/wireplumber/include/astal/wireplumber/wp.h index 1ff341c..8d1ea83 100644 --- a/lib/wireplumber/include/astal/wireplumber/wp.h +++ b/lib/wireplumber/include/astal/wireplumber/wp.h @@ -22,7 +22,7 @@ typedef enum { G_DECLARE_FINAL_TYPE(AstalWpWp, astal_wp_wp, ASTAL_WP, WP, GObject) AstalWpWp* astal_wp_wp_get_default(); -AstalWpWp* astal_wp_get_default_wp(); +AstalWpWp* astal_wp_get_default(); AstalWpAudio* astal_wp_wp_get_audio(AstalWpWp* self); AstalWpVideo* astal_wp_wp_get_video(AstalWpWp* self); diff --git a/lib/wireplumber/src/wireplumber.c b/lib/wireplumber/src/wireplumber.c index cc3aa82..6babed1 100644 --- a/lib/wireplumber/src/wireplumber.c +++ b/lib/wireplumber/src/wireplumber.c @@ -352,13 +352,13 @@ AstalWpWp *astal_wp_wp_get_default() { } /** - * astal_wp_get_default_wp + * astal_wp_get_default * * gets the default wireplumber object. * * Returns: (nullable) (transfer none): gets the default wireplumber object. */ -AstalWpWp *astal_wp_get_default_wp() { return astal_wp_wp_get_default(); } +AstalWpWp *astal_wp_get_default() { return astal_wp_wp_get_default(); } static void astal_wp_wp_dispose(GObject *object) { AstalWpWp *self = ASTAL_WP_WP(object); -- cgit v1.2.3 From 10b9cde328947d038029f2496f43da75138abb3d Mon Sep 17 00:00:00 2001 From: kotontrion Date: Wed, 18 Sep 2024 20:29:21 +0200 Subject: add version constants to auth, river and wireplumber libs --- lib/auth/include/astal-auth.h | 32 ----------------- lib/auth/include/astal-auth.h.in | 38 ++++++++++++++++++++ lib/auth/include/meson.build | 17 +++++++-- lib/river/include/astal-river.h | 59 ------------------------------- lib/river/include/astal-river.h.in | 66 +++++++++++++++++++++++++++++++++++ lib/river/include/meson.build | 19 +++++++--- lib/wireplumber/include/astal-wp.h | 4 --- lib/wireplumber/include/astal-wp.h.in | 14 ++++++++ lib/wireplumber/include/meson.build | 16 +++++++-- 9 files changed, 161 insertions(+), 104 deletions(-) delete mode 100644 lib/auth/include/astal-auth.h create mode 100644 lib/auth/include/astal-auth.h.in delete mode 100644 lib/river/include/astal-river.h create mode 100644 lib/river/include/astal-river.h.in delete mode 100644 lib/wireplumber/include/astal-wp.h create mode 100644 lib/wireplumber/include/astal-wp.h.in diff --git a/lib/auth/include/astal-auth.h b/lib/auth/include/astal-auth.h deleted file mode 100644 index a3073ff..0000000 --- a/lib/auth/include/astal-auth.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef ASTAL_AUTH_PAM_H -#define ASTAL_AUTH_PAM_H - -#include -#include - -G_BEGIN_DECLS - -#define ASTAL_AUTH_TYPE_PAM (astal_auth_pam_get_type()) - -G_DECLARE_FINAL_TYPE(AstalAuthPam, astal_auth_pam, ASTAL_AUTH, PAM, GObject) - -void astal_auth_pam_set_username(AstalAuthPam *self, const gchar *username); - -const gchar *astal_auth_pam_get_username(AstalAuthPam *self); - -void astal_auth_pam_set_service(AstalAuthPam *self, const gchar *service); - -const gchar *astal_auth_pam_get_service(AstalAuthPam *self); - -gboolean astal_auth_pam_start_authenticate(AstalAuthPam *self); - -void astal_auth_pam_supply_secret(AstalAuthPam *self, const gchar *secret); - -gboolean astal_auth_pam_authenticate(const gchar *password, GAsyncReadyCallback result_callback, - gpointer user_data); - -gssize astal_auth_pam_authenticate_finish(GAsyncResult *res, GError **error); - -G_END_DECLS - -#endif // !ASTAL_AUTH_PAM_H diff --git a/lib/auth/include/astal-auth.h.in b/lib/auth/include/astal-auth.h.in new file mode 100644 index 0000000..c8a0ece --- /dev/null +++ b/lib/auth/include/astal-auth.h.in @@ -0,0 +1,38 @@ +#ifndef ASTAL_AUTH_PAM_H +#define ASTAL_AUTH_PAM_H + +#include +#include + + +#define ASTAL_AUTH_MAJOR_VERSION @MAJOR_VERSION@ +#define ASTAL_AUTH_MINOR_VERSION @MINOR_VERSION@ +#define ASTAL_AUTH_MICRO_VERSION @MICRO_VERSION@ +#define ASTAL_AUTH_VERSION "@VERSION@" + +G_BEGIN_DECLS + +#define ASTAL_AUTH_TYPE_PAM (astal_auth_pam_get_type()) + +G_DECLARE_FINAL_TYPE(AstalAuthPam, astal_auth_pam, ASTAL_AUTH, PAM, GObject) + +void astal_auth_pam_set_username(AstalAuthPam *self, const gchar *username); + +const gchar *astal_auth_pam_get_username(AstalAuthPam *self); + +void astal_auth_pam_set_service(AstalAuthPam *self, const gchar *service); + +const gchar *astal_auth_pam_get_service(AstalAuthPam *self); + +gboolean astal_auth_pam_start_authenticate(AstalAuthPam *self); + +void astal_auth_pam_supply_secret(AstalAuthPam *self, const gchar *secret); + +gboolean astal_auth_pam_authenticate(const gchar *password, GAsyncReadyCallback result_callback, + gpointer user_data); + +gssize astal_auth_pam_authenticate_finish(GAsyncResult *res, GError **error); + +G_END_DECLS + +#endif // !ASTAL_AUTH_PAM_H diff --git a/lib/auth/include/meson.build b/lib/auth/include/meson.build index 0575998..9c92caf 100644 --- a/lib/auth/include/meson.build +++ b/lib/auth/include/meson.build @@ -1,4 +1,17 @@ + +config = configure_file( + input: 'astal-auth.h.in', + output: 'astal-auth.h', + configuration: { + 'VERSION': meson.project_version(), + 'MAJOR_VERSION': version_split[0], + 'MINOR_VERSION': version_split[1], + 'MICRO_VERSION': version_split[2], + }, +) + + astal_auth_inc = include_directories('.') -astal_auth_headers = files('astal-auth.h') +astal_auth_headers = config -install_headers('astal-auth.h') +install_headers(astal_auth_headers) diff --git a/lib/river/include/astal-river.h b/lib/river/include/astal-river.h deleted file mode 100644 index 6bedd94..0000000 --- a/lib/river/include/astal-river.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef ASTAL_RIVER_H -#define ASTAL_RIVER_H - -#include - -G_BEGIN_DECLS - -#define ASTAL_RIVER_TYPE_OUTPUT (astal_river_output_get_type()) - -G_DECLARE_FINAL_TYPE(AstalRiverOutput, astal_river_output, ASTAL_RIVER, OUTPUT, GObject) - -guint astal_river_output_get_id(AstalRiverOutput *self); - -gchar *astal_river_output_get_name(AstalRiverOutput *self); - -gchar *astal_river_output_get_layout_name(AstalRiverOutput *self); - -gchar *astal_river_output_get_focused_view(AstalRiverOutput *self); - -guint astal_river_output_get_focused_tags(AstalRiverOutput *self); - -guint astal_river_output_get_urgent_tags(AstalRiverOutput *self); - -guint astal_river_output_get_occupied_tags(AstalRiverOutput *self); - -#define ASTAL_RIVER_TYPE_RIVER (astal_river_river_get_type()) - -G_DECLARE_FINAL_TYPE(AstalRiverRiver, astal_river_river, ASTAL_RIVER, RIVER, GObject) - -AstalRiverRiver *astal_river_river_new(); - -AstalRiverRiver *astal_river_river_get_default(); -AstalRiverRiver *astal_river_get_default(); - -GList *astal_river_river_get_outputs(AstalRiverRiver *self); - -AstalRiverOutput *astal_river_river_get_output(AstalRiverRiver *self, gchar *name); - -gchar *astal_river_river_get_focused_view(AstalRiverRiver *self); - -gchar *astal_river_river_get_focused_output(AstalRiverRiver *self); - -gchar *astal_river_river_get_mode(AstalRiverRiver *self); - -/** - * AstalRiverCommandCallback: - * @success: a #gboolean indicating whether the command was executed successfully - * @msg: a string containing the result of the command - * - * A callback function that is called after a river command is run. - */ -typedef void (*AstalRiverCommandCallback)(gboolean success, const gchar *msg); - -void astal_river_river_run_command_async(AstalRiverRiver *self, gint length, const gchar **cmd, - AstalRiverCommandCallback callback); - -G_END_DECLS - -#endif // !ASTAL_RIVER_H diff --git a/lib/river/include/astal-river.h.in b/lib/river/include/astal-river.h.in new file mode 100644 index 0000000..d2b769c --- /dev/null +++ b/lib/river/include/astal-river.h.in @@ -0,0 +1,66 @@ +#ifndef ASTAL_RIVER_H +#define ASTAL_RIVER_H + +#include + + +#define ASTAL_RIVER_MAJOR_VERSION @MAJOR_VERSION@ +#define ASTAL_RIVER_MINOR_VERSION @MINOR_VERSION@ +#define ASTAL_RIVER_MICRO_VERSION @MICRO_VERSION@ +#define ASTAL_RIVER_VERSION "@VERSION@" + + +G_BEGIN_DECLS + +#define ASTAL_RIVER_TYPE_OUTPUT (astal_river_output_get_type()) + +G_DECLARE_FINAL_TYPE(AstalRiverOutput, astal_river_output, ASTAL_RIVER, OUTPUT, GObject) + +guint astal_river_output_get_id(AstalRiverOutput *self); + +gchar *astal_river_output_get_name(AstalRiverOutput *self); + +gchar *astal_river_output_get_layout_name(AstalRiverOutput *self); + +gchar *astal_river_output_get_focused_view(AstalRiverOutput *self); + +guint astal_river_output_get_focused_tags(AstalRiverOutput *self); + +guint astal_river_output_get_urgent_tags(AstalRiverOutput *self); + +guint astal_river_output_get_occupied_tags(AstalRiverOutput *self); + +#define ASTAL_RIVER_TYPE_RIVER (astal_river_river_get_type()) + +G_DECLARE_FINAL_TYPE(AstalRiverRiver, astal_river_river, ASTAL_RIVER, RIVER, GObject) + +AstalRiverRiver *astal_river_river_new(); + +AstalRiverRiver *astal_river_river_get_default(); +AstalRiverRiver *astal_river_get_default(); + +GList *astal_river_river_get_outputs(AstalRiverRiver *self); + +AstalRiverOutput *astal_river_river_get_output(AstalRiverRiver *self, gchar *name); + +gchar *astal_river_river_get_focused_view(AstalRiverRiver *self); + +gchar *astal_river_river_get_focused_output(AstalRiverRiver *self); + +gchar *astal_river_river_get_mode(AstalRiverRiver *self); + +/** + * AstalRiverCommandCallback: + * @success: a #gboolean indicating whether the command was executed successfully + * @msg: a string containing the result of the command + * + * A callback function that is called after a river command is run. + */ +typedef void (*AstalRiverCommandCallback)(gboolean success, const gchar *msg); + +void astal_river_river_run_command_async(AstalRiverRiver *self, gint length, const gchar **cmd, + AstalRiverCommandCallback callback); + +G_END_DECLS + +#endif // !ASTAL_RIVER_H diff --git a/lib/river/include/meson.build b/lib/river/include/meson.build index 4b08a89..d91be23 100644 --- a/lib/river/include/meson.build +++ b/lib/river/include/meson.build @@ -1,6 +1,17 @@ -astal_river_inc = include_directories('.') -astal_river_headers = files( - 'astal-river.h', + +config = configure_file( + input: 'astal-river.h.in', + output: 'astal-river.h', + configuration: { + 'VERSION': meson.project_version(), + 'MAJOR_VERSION': version_split[0], + 'MINOR_VERSION': version_split[1], + 'MICRO_VERSION': version_split[2], + }, ) -install_headers('astal-river.h') + +astal_river_inc = include_directories('.') +astal_river_headers = config + +install_headers(astal_river_headers) diff --git a/lib/wireplumber/include/astal-wp.h b/lib/wireplumber/include/astal-wp.h deleted file mode 100644 index 6c48211..0000000 --- a/lib/wireplumber/include/astal-wp.h +++ /dev/null @@ -1,4 +0,0 @@ - -#include "astal/wireplumber/audio.h" -#include "astal/wireplumber/endpoint.h" -#include "astal/wireplumber/wp.h" diff --git a/lib/wireplumber/include/astal-wp.h.in b/lib/wireplumber/include/astal-wp.h.in new file mode 100644 index 0000000..7d9d997 --- /dev/null +++ b/lib/wireplumber/include/astal-wp.h.in @@ -0,0 +1,14 @@ + +#ifndef WP_H +#define WP_H + +#include "astal/wireplumber/audio.h" +#include "astal/wireplumber/endpoint.h" +#include "astal/wireplumber/wp.h" + +#define ASTAL_WP_MAJOR_VERSION @MAJOR_VERSION@ +#define ASTAL_WP_MINOR_VERSION @MINOR_VERSION@ +#define ASTAL_WP_MICRO_VERSION @MICRO_VERSION@ +#define ASTAL_WP_VERSION "@VERSION@" + +#endif // WP_H diff --git a/lib/wireplumber/include/meson.build b/lib/wireplumber/include/meson.build index afe00eb..cae0d6e 100644 --- a/lib/wireplumber/include/meson.build +++ b/lib/wireplumber/include/meson.build @@ -1,8 +1,18 @@ -astal_wireplumber_inc = include_directories('.', 'astal/wireplumber', 'private') -astal_wireplumber_headers = files( - 'astal-wp.h', + +config = configure_file( + input: 'astal-wp.h.in', + output: 'astal-wp.h', + configuration: { + 'VERSION': meson.project_version(), + 'MAJOR_VERSION': version_split[0], + 'MINOR_VERSION': version_split[1], + 'MICRO_VERSION': version_split[2], + }, ) +astal_wireplumber_inc = include_directories('.', 'astal/wireplumber', 'private') +astal_wireplumber_headers = config + install_headers(astal_wireplumber_headers) subdir('astal/wireplumber') -- cgit v1.2.3