From edc4848b11753f67657b633363c9524bc833954f Mon Sep 17 00:00:00 2001 From: kotontrion Date: Wed, 17 Jul 2024 08:26:14 +0200 Subject: move header to astal-river.h --- include/astal-river.h | 150 ++++++++++++++++++++++++++++++++++++++++++++++++ include/meson.build | 4 +- include/river-private.h | 2 +- include/river.h | 150 ------------------------------------------------ src/astal-river.c | 10 ++-- src/river.c | 24 ++++---- 6 files changed, 168 insertions(+), 172 deletions(-) create mode 100644 include/astal-river.h delete mode 100644 include/river.h diff --git a/include/astal-river.h b/include/astal-river.h new file mode 100644 index 0000000..e8576a3 --- /dev/null +++ b/include/astal-river.h @@ -0,0 +1,150 @@ +#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) + +/** + * astal_river_output_get_nid + * @self: the AstalRiverOutput object + * + * Returns: the id of the output + */ +guint astal_river_output_get_id(AstalRiverOutput *self); + +/** + * astal_river_output_get_name + * @self: the AstalRiverOutput object + * + * Returns: (transfer none) (nullable): the name of the output + */ +gchar *astal_river_output_get_name(AstalRiverOutput *self); + +/** + * astal_river_output_get_layout_name + * @self: the AstalRiverOutput object + * + * Returns: (transfer none) (nullable): the currently used layout name of the output + */ +gchar *astal_river_output_get_layout_name(AstalRiverOutput *self); + +/** + * astal_river_output_get_focused_view + * @self: the AstalRiverOutput object + * + * Returns: (transfer none) (nullable): the focused view on the output + */ +gchar *astal_river_output_get_focused_view(AstalRiverOutput *self); + +/** + * astal_river_output_get_focused_tags + * @self: the AstalRiverOutput object + * + * Returns: the focused tags of the output + */ +guint astal_river_output_get_focused_tags(AstalRiverOutput *self); + +/** + * astal_river_output_get_urgent_tags + * @self: the AstalRiverOutput object + * + * Returns: the urgent tags of the output + */ +guint astal_river_output_get_urgent_tags(AstalRiverOutput *self); + +/** + * astal_river_output_get_occupied_tags + * @self: the AstalRiverOutput object + * + * Returns: the occupied tags of the output + */ +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) + +/** + * astal_river_river_new + * + * Returns: (nullable): a newly created connection to river + */ +AstalRiverRiver *astal_river_river_new(); + +/** + * astal_river_river_get_default + * + * Returns: (nullable) (transfer none): gets the default River object. + */ +AstalRiverRiver *astal_river_river_get_default(); +/** + * astal_river_river_get_outputs + * @self: the AstalRiverRiver object + * + * Returns: (transfer none) (element-type AstalRiver.Output): a list of all outputs + * + */ +GList *astal_river_river_get_outputs(AstalRiverRiver *self); + +/** + * astal_river_river_get_output + * @self: the AstalRiverRiver object + * @name: the name of the output + * + * Returns: (transfer none) (nullable): the output with the given name or null + */ +AstalRiverOutput *astal_river_river_get_output(AstalRiverRiver *self, gchar *name); + +/** + * astal_river_river_get_focused_view + * @self: the AstalRiverOutput object + * + * Returns: (transfer none) (nullable): the currently focused view + */ +gchar *astal_river_river_get_focused_view(AstalRiverRiver *self); + +/** + * astal_river_river_get_focused_output + * @self: the AstalRiverOutput object + * + * Returns: (transfer none) (nullable): the name of the currently focused output + */ +gchar *astal_river_river_get_focused_output(AstalRiverRiver *self); + +/** + * astal_river_river_get_mode + * @self: the AstalRiverOutput object + * + * Returns: (transfer none) (nullable): the currently active mode + */ +gchar *astal_river_river_get_mode(AstalRiverRiver *self); + +/** + * AstalRiverCommandCallback: + * @success: a #gboolean. + * @msg: a string. + * + * A callback function that gets a #GObject, a #gboolean, and a string. + */ +typedef void (*AstalRiverCommandCallback)(gboolean success, const gchar *msg); + +/** + * astal_river_river_run_command_async: + * @self: the AstalRiverRiver object + * @length: the length of the cmd array + * @cmd: (array length=length): the command to execute + * @callback: (scope async) (nullable): the callback to invoke. + * + * Calls the given callback with the provided parameters. + */ +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/include/meson.build b/include/meson.build index a835e6b..28a51f6 100644 --- a/include/meson.build +++ b/include/meson.build @@ -1,6 +1,6 @@ astal_river_inc = include_directories('.') astal_river_headers = files( - 'river.h', + 'astal-river.h', ) -install_headers('river.h', subdir : 'astal') +install_headers('astal-river.h') diff --git a/include/river-private.h b/include/river-private.h index d32e074..dae36be 100644 --- a/include/river-private.h +++ b/include/river-private.h @@ -4,7 +4,7 @@ #include #include "river-status-unstable-v1-client.h" -#include "river.h" +#include "astal-river.h" G_BEGIN_DECLS diff --git a/include/river.h b/include/river.h deleted file mode 100644 index e8576a3..0000000 --- a/include/river.h +++ /dev/null @@ -1,150 +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) - -/** - * astal_river_output_get_nid - * @self: the AstalRiverOutput object - * - * Returns: the id of the output - */ -guint astal_river_output_get_id(AstalRiverOutput *self); - -/** - * astal_river_output_get_name - * @self: the AstalRiverOutput object - * - * Returns: (transfer none) (nullable): the name of the output - */ -gchar *astal_river_output_get_name(AstalRiverOutput *self); - -/** - * astal_river_output_get_layout_name - * @self: the AstalRiverOutput object - * - * Returns: (transfer none) (nullable): the currently used layout name of the output - */ -gchar *astal_river_output_get_layout_name(AstalRiverOutput *self); - -/** - * astal_river_output_get_focused_view - * @self: the AstalRiverOutput object - * - * Returns: (transfer none) (nullable): the focused view on the output - */ -gchar *astal_river_output_get_focused_view(AstalRiverOutput *self); - -/** - * astal_river_output_get_focused_tags - * @self: the AstalRiverOutput object - * - * Returns: the focused tags of the output - */ -guint astal_river_output_get_focused_tags(AstalRiverOutput *self); - -/** - * astal_river_output_get_urgent_tags - * @self: the AstalRiverOutput object - * - * Returns: the urgent tags of the output - */ -guint astal_river_output_get_urgent_tags(AstalRiverOutput *self); - -/** - * astal_river_output_get_occupied_tags - * @self: the AstalRiverOutput object - * - * Returns: the occupied tags of the output - */ -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) - -/** - * astal_river_river_new - * - * Returns: (nullable): a newly created connection to river - */ -AstalRiverRiver *astal_river_river_new(); - -/** - * astal_river_river_get_default - * - * Returns: (nullable) (transfer none): gets the default River object. - */ -AstalRiverRiver *astal_river_river_get_default(); -/** - * astal_river_river_get_outputs - * @self: the AstalRiverRiver object - * - * Returns: (transfer none) (element-type AstalRiver.Output): a list of all outputs - * - */ -GList *astal_river_river_get_outputs(AstalRiverRiver *self); - -/** - * astal_river_river_get_output - * @self: the AstalRiverRiver object - * @name: the name of the output - * - * Returns: (transfer none) (nullable): the output with the given name or null - */ -AstalRiverOutput *astal_river_river_get_output(AstalRiverRiver *self, gchar *name); - -/** - * astal_river_river_get_focused_view - * @self: the AstalRiverOutput object - * - * Returns: (transfer none) (nullable): the currently focused view - */ -gchar *astal_river_river_get_focused_view(AstalRiverRiver *self); - -/** - * astal_river_river_get_focused_output - * @self: the AstalRiverOutput object - * - * Returns: (transfer none) (nullable): the name of the currently focused output - */ -gchar *astal_river_river_get_focused_output(AstalRiverRiver *self); - -/** - * astal_river_river_get_mode - * @self: the AstalRiverOutput object - * - * Returns: (transfer none) (nullable): the currently active mode - */ -gchar *astal_river_river_get_mode(AstalRiverRiver *self); - -/** - * AstalRiverCommandCallback: - * @success: a #gboolean. - * @msg: a string. - * - * A callback function that gets a #GObject, a #gboolean, and a string. - */ -typedef void (*AstalRiverCommandCallback)(gboolean success, const gchar *msg); - -/** - * astal_river_river_run_command_async: - * @self: the AstalRiverRiver object - * @length: the length of the cmd array - * @cmd: (array length=length): the command to execute - * @callback: (scope async) (nullable): the callback to invoke. - * - * Calls the given callback with the provided parameters. - */ -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/src/astal-river.c b/src/astal-river.c index 000f26c..37f34d5 100644 --- a/src/astal-river.c +++ b/src/astal-river.c @@ -3,7 +3,7 @@ #include #include "gio/gio.h" -#include "river.h" +#include "astal-river.h" GMainLoop* loop; @@ -34,11 +34,11 @@ int main(int argc, char** argv) { } } - GError *error = NULL; + GError* error = NULL; AstalRiverRiver* river = g_initable_new(ASTAL_RIVER_TYPE_RIVER, NULL, &error, NULL); - if(error) { - g_critical("%s\n", error->message); - exit(EXIT_FAILURE); + if (error) { + g_critical("%s\n", error->message); + exit(EXIT_FAILURE); } if (daemon) { loop = g_main_loop_new(NULL, FALSE); diff --git a/src/river.c b/src/river.c index c00a8c7..feb5e49 100644 --- a/src/river.c +++ b/src/river.c @@ -44,14 +44,14 @@ typedef enum { ASTAL_RIVER_RIVER_PROP_MODE, ASTAL_RIVER_RIVER_PROP_OUTPUTS, ASTAL_RIVER_RIVER_N_PROPERTIES -} AstalRiverOutputProperties; +} AstalRiverRiverProperties; typedef enum { ASTAL_RIVER_RIVER_SIGNAL_CHANGED, ASTAL_RIVER_RIVER_SIGNAL_OUTPUT_ADDED, ASTAL_RIVER_RIVER_SIGNAL_OUTPUT_REMOVED, ASTAL_RIVER_RIVER_N_SIGNALS -} AstalRiverOutputSignals; +} AstalRiverRiverSignals; static guint astal_river_river_signals[ASTAL_RIVER_RIVER_N_SIGNALS] = { 0, @@ -196,7 +196,7 @@ static void global_registry_handler(void* data, struct wl_registry* registry, ui AstalRiverRiver* self = ASTAL_RIVER_RIVER(data); AstalRiverRiverPrivate* priv = astal_river_river_get_instance_private(self); if (strcmp(interface, wl_output_interface.name) == 0) { - if(priv->river_status_manager == NULL) return; + if (priv->river_status_manager == NULL) return; struct wl_output* wl_out = wl_registry_bind(registry, id, &wl_output_interface, 4); AstalRiverOutput* output = astal_river_output_new(id, wl_out, priv->river_status_manager, priv->display); @@ -280,8 +280,8 @@ static gboolean astal_river_river_initable_init(GInitable* initable, GCancellabl GError** error) { AstalRiverRiver* self = ASTAL_RIVER_RIVER(initable); AstalRiverRiverPrivate* priv = astal_river_river_get_instance_private(self); - - if(priv->init) return TRUE; + + if (priv->init) return TRUE; priv->wl_source = wl_source_new(NULL, NULL); @@ -322,19 +322,14 @@ static void astal_river_river_initable_iface_init(GInitableIface* iface) { iface->init = astal_river_river_initable_init; } -static void astal_river_river_init(AstalRiverRiver* self) { - +static void astal_river_river_init(AstalRiverRiver* self) { AstalRiverRiverPrivate* priv = astal_river_river_get_instance_private(self); - - self->outputs = NULL; - + self->outputs = NULL; priv->init = FALSE; priv->seat = NULL; priv->display = NULL; priv->river_status_manager = NULL; priv->signal_ids = g_hash_table_new(g_direct_hash, g_direct_equal); - - } AstalRiverRiver* astal_river_river_new() { @@ -368,8 +363,9 @@ static void astal_river_river_finalize(GObject* object) { g_clear_list(&self->outputs, g_object_unref); self->outputs = NULL; - if (priv->wl_registry != NULL) wl_registry_destroy(priv->wl_registry); - if (priv->river_status_manager != NULL) zriver_status_manager_v1_destroy(priv->river_status_manager); + if (priv->wl_registry != NULL) wl_registry_destroy(priv->wl_registry); + if (priv->river_status_manager != NULL) + zriver_status_manager_v1_destroy(priv->river_status_manager); if (priv->river_seat_status != NULL) zriver_seat_status_v1_destroy(priv->river_seat_status); if (priv->seat != NULL) wl_seat_destroy(priv->seat); if (priv->display != NULL) wl_display_flush(priv->display); -- cgit v1.2.3