From 3db57eb3fc97ab99056893624d92710f3573e00f Mon Sep 17 00:00:00 2001 From: noise Date: Sun, 1 Mar 2026 00:35:36 +0300 Subject: [PATCH] ref: use gnome C style conventions --- src/main.c | 4 ++-- src/moemoji-application.c | 19 +++++++++---------- src/moemoji-window.c | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main.c b/src/main.c index 603c75c..ea5c7c9 100644 --- a/src/main.c +++ b/src/main.c @@ -9,7 +9,7 @@ static void register_with_portal (void) { GDBusConnection *bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (bus == NULL) { g_warning ("portal register: can't get session bus: %s", error->message); - g_error_free (error); + g_clear_error (&error); return; } GVariantBuilder options; @@ -28,7 +28,7 @@ static void register_with_portal (void) { -1, NULL, &error); if (result == NULL) { g_info ("portal register: %s", error->message); - g_error_free (error); + g_clear_error (&error); } else { g_variant_unref (result); } diff --git a/src/moemoji-application.c b/src/moemoji-application.c index c32b567..5663359 100644 --- a/src/moemoji-application.c +++ b/src/moemoji-application.c @@ -93,8 +93,8 @@ static void toggle_window(MoeMojiApplication *self) { } } -static gboolean on_close_request(GtkWindow *window, gpointer user_data) { - (void)user_data; +static gboolean on_close_request(GtkWindow *window, + G_GNUC_UNUSED gpointer user_data) { gtk_widget_set_visible(GTK_WIDGET(window), FALSE); return TRUE; } @@ -297,7 +297,7 @@ static void setup_sni(MoeMojiApplication *self) { g_dbus_node_info_new_for_xml(sni_introspection_xml, &error); if (sni_node == NULL) { g_warning("Failed to parse SNI introspection XML: %s", error->message); - g_error_free(error); + g_clear_error(&error); return; } self->sni_registration_id = g_dbus_connection_register_object( @@ -306,14 +306,14 @@ static void setup_sni(MoeMojiApplication *self) { g_dbus_node_info_unref(sni_node); if (self->sni_registration_id == 0) { g_warning("Failed to register SNI object: %s", error->message); - g_error_free(error); + g_clear_error(&error); return; } GDBusNodeInfo *menu_node = g_dbus_node_info_new_for_xml(dbusmenu_introspection_xml, &error); if (menu_node == NULL) { g_warning("Failed to parse dbusmenu introspection XML: %s", error->message); - g_error_free(error); + g_clear_error(&error); return; } self->menu_registration_id = g_dbus_connection_register_object( @@ -322,7 +322,7 @@ static void setup_sni(MoeMojiApplication *self) { g_dbus_node_info_unref(menu_node); if (self->menu_registration_id == 0) { g_warning("dbusmenu register: %s", error->message); - g_error_free(error); + g_clear_error(&error); } const gchar *unique_name = g_dbus_connection_get_unique_name(self->dbus_conn); g_dbus_connection_call( @@ -332,11 +332,10 @@ static void setup_sni(MoeMojiApplication *self) { NULL, NULL, NULL); } -static void on_shortcuts_activated(GDBusProxy *proxy, const gchar *sender_name, +static void on_shortcuts_activated(G_GNUC_UNUSED GDBusProxy *proxy, + G_GNUC_UNUSED const gchar *sender_name, const gchar *signal_name, GVariant *parameters, gpointer user_data) { - (void)proxy; - (void)sender_name; if (g_strcmp0(signal_name, "Activated") != 0) return; MoeMojiApplication *self = MOEMOJI_APPLICATION(user_data); @@ -481,7 +480,7 @@ static void setup_global_shortcuts(MoeMojiApplication *self) { "org.freedesktop.portal.GlobalShortcuts", NULL, &error); if (self->shortcuts_proxy == NULL) { g_warning("GlobalShortcuts: Failed to create proxy: %s", error->message); - g_error_free(error); + g_clear_error(&error); return; } g_timeout_add(500, (GSourceFunc)begin_create_session, self); diff --git a/src/moemoji-window.c b/src/moemoji-window.c index f646e3e..58b62a0 100644 --- a/src/moemoji-window.c +++ b/src/moemoji-window.c @@ -222,8 +222,8 @@ static void update_spacer_height(MoeMojiWindow *self) { gtk_widget_set_size_request(self->bottom_spacer, -1, spacer_h); } -static void on_scroll_changed(GtkAdjustment *adj, gpointer user_data) { - (void)adj; +static void on_scroll_changed(G_GNUC_UNUSED GtkAdjustment *adj, + gpointer user_data) { MoeMojiWindow *self = MOEMOJI_WINDOW(user_data); update_chip_from_scroll(self); }