[libadwaita/msvc: 15/19] src/: Fix code styling issues
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/msvc: 15/19] src/: Fix code styling issues
- Date: Wed, 19 Jan 2022 02:24:48 +0000 (UTC)
commit f888820b4c5ac038200e89520ae4bf9c61d95c08
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Jan 18 12:32:40 2022 +0800
src/: Fix code styling issues
src/adw-avatar.c | 11 +++++-----
src/adw-carousel-indicator-lines.c | 10 ++++-----
src/adw-preferences-window.c | 13 ++++++------
src/adw-settings.c | 42 ++++++++++++++++----------------------
src/adw-style-manager.c | 3 ++-
src/adw-swipe-tracker.c | 13 ++++++------
src/adw-toast.c | 10 ++++-----
7 files changed, 48 insertions(+), 54 deletions(-)
---
diff --git a/src/adw-avatar.c b/src/adw-avatar.c
index 40a01720..8550d387 100644
--- a/src/adw-avatar.c
+++ b/src/adw-avatar.c
@@ -88,11 +88,10 @@ extract_initials_from_text (const char *text)
gunichar unichar;
char *q = NULL;
- if (normalized == NULL)
- {
- g_free (p);
- return NULL;
- }
+ if (normalized == NULL) {
+ g_free (p);
+ return NULL;
+ }
initials = g_string_new ("");
@@ -757,6 +756,8 @@ adw_avatar_draw_to_texture (AdwAvatar *self,
renderer = gtk_native_get_renderer (native);
result = gsk_renderer_render_texture (renderer, node, &GRAPHENE_RECT_INIT (0, 0, size, size));
+
gsk_render_node_unref (node);
+
return result;
}
diff --git a/src/adw-carousel-indicator-lines.c b/src/adw-carousel-indicator-lines.c
index ea45b2df..1a6fd698 100644
--- a/src/adw-carousel-indicator-lines.c
+++ b/src/adw-carousel-indicator-lines.c
@@ -216,11 +216,11 @@ adw_carousel_indicator_lines_snapshot (GtkWidget *widget,
points = adw_swipeable_get_snap_points (ADW_SWIPEABLE (self->carousel), &n_points);
position = adw_carousel_get_position (self->carousel);
- if (n_points < 2)
- {
- g_free (points);
- return;
- }
+ if (n_points < 2) {
+ g_free (points);
+
+ return;
+ }
if (self->orientation == GTK_ORIENTATION_HORIZONTAL &&
gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
diff --git a/src/adw-preferences-window.c b/src/adw-preferences-window.c
index 9d775d67..30c1b37b 100644
--- a/src/adw-preferences-window.c
+++ b/src/adw-preferences-window.c
@@ -151,9 +151,9 @@ filter_search_results (AdwPreferencesRow *row,
}
}
- if (!!strstr (title, terms))
+ if (!!strstr (title, terms)) {
result = TRUE;
-
+ }
else if (ADW_IS_ACTION_ROW (row)) {
char *subtitle = g_utf8_casefold (adw_action_row_get_subtitle (ADW_ACTION_ROW (row)), -1);
@@ -214,11 +214,10 @@ create_search_row_subtitle (AdwPreferencesWindow *self,
else
page_title = g_strdup (title);
- if (g_strcmp0 (page_title, "") == 0)
- {
- g_free (page_title);
- page_title = NULL;
- }
+ if (g_strcmp0 (page_title, "") == 0) {
+ g_free (page_title);
+ page_title = NULL;
+ }
}
if (group_title) {
diff --git a/src/adw-settings.c b/src/adw-settings.c
index 3031c261..344cbe62 100644
--- a/src/adw-settings.c
+++ b/src/adw-settings.c
@@ -92,6 +92,7 @@ get_disable_portal (void)
return disable_portal && disable_portal[0] == '1';
}
+#ifndef G_OS_WIN32
static gboolean
read_portal_setting (AdwSettings *self,
const char *schema,
@@ -114,30 +115,25 @@ read_portal_setting (AdwSettings *self,
NULL,
&error);
if (error) {
-
if (error->domain == G_DBUS_ERROR &&
error->code == G_DBUS_ERROR_SERVICE_UNKNOWN) {
g_debug ("Portal not found: %s", error->message);
- }
-
- else if (error->domain == G_DBUS_ERROR &&
- error->code == G_DBUS_ERROR_UNKNOWN_METHOD) {
+ } else if (error->domain == G_DBUS_ERROR &&
+ error->code == G_DBUS_ERROR_UNKNOWN_METHOD) {
g_debug ("Portal doesn't provide settings: %s", error->message);
- }
-
- else if (g_dbus_error_is_remote_error (error)) {
+ } else if (g_dbus_error_is_remote_error (error)) {
char *remote_error = g_dbus_error_get_remote_error (error);
if (!g_strcmp0 (remote_error, PORTAL_ERROR_NOT_FOUND)) {
g_debug ("Setting %s.%s of type %s not found", schema, name, type);
}
g_free (remote_error);
- }
-
- else
+ } else {
g_critical ("Couldn't read the %s setting: %s", name, error->message);
+ }
g_error_free (error);
+
return FALSE;
}
@@ -150,15 +146,15 @@ read_portal_setting (AdwSettings *self,
schema, name, type, g_variant_get_type_string (child2));
result = FALSE;
g_variant_unref (child2);
- }
- else {
+ } else {
*out = g_steal_pointer (&child2);
- result = TRUE;
+ result = TRUE;
}
g_variant_type_free (out_type);
g_variant_unref (child);
g_variant_unref (ret);
+
return result;
}
@@ -215,20 +211,16 @@ settings_portal_changed_cb (GDBusProxy *proxy,
!g_strcmp0 (name, "color-scheme") &&
self->color_scheme_use_fdo_setting) {
set_color_scheme (self, get_fdo_color_scheme (value));
- }
-
- else if (!g_strcmp0 (namespace, "org.gnome.desktop.interface") &&
+ } else if (!g_strcmp0 (namespace, "org.gnome.desktop.interface") &&
!g_strcmp0 (name, "color-scheme") &&
!self->color_scheme_use_fdo_setting) {
set_color_scheme (self, get_gnome_color_scheme (value));
- }
-
- else if (!g_strcmp0 (namespace, "org.gnome.desktop.interface.a11y") &&
+ } else if (!g_strcmp0 (namespace, "org.gnome.desktop.interface.a11y") &&
!g_strcmp0 (name, "high-contrast")) {
set_high_contrast (self, g_variant_get_boolean (value));
- }
- else
+ } else {
g_variant_unref (value);
+ }
}
static void
@@ -293,6 +285,7 @@ is_running_in_flatpak (void)
{
return g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS);
}
+#endif
static void
gsettings_color_scheme_changed_cb (AdwSettings *self)
@@ -313,10 +306,12 @@ init_gsettings (AdwSettings *self)
GSettingsSchema *schema = NULL;
GSettingsSchema *a11y_schema = NULL;
+#ifndef G_OS_WIN32
/* While we can access gsettings in flatpak, we can't do anything useful with
* them as they aren't propagated from the system. */
if (is_running_in_flatpak ())
return;
+#endif
source = g_settings_schema_source_get_default ();
@@ -358,7 +353,6 @@ is_theme_high_contrast (GdkDisplay *display)
{
GValue value = G_VALUE_INIT;
const char *theme_name;
- gboolean result;
g_value_init (&value, G_TYPE_STRING);
if (!gdk_display_get_setting (display, "gtk-theme-name", &value))
@@ -404,7 +398,7 @@ adw_settings_constructed (GObject *object)
G_OBJECT_CLASS (adw_settings_parent_class)->constructed (object);
-#ifdef G_OS_WIN32
+#ifndef G_OS_WIN32
init_portal (self);
#endif
diff --git a/src/adw-style-manager.c b/src/adw-style-manager.c
index 5bbd3e8e..1c70029d 100644
--- a/src/adw-style-manager.c
+++ b/src/adw-style-manager.c
@@ -526,11 +526,12 @@ adw_style_manager_ensure (void)
for (l = displays; l; l = l->next)
register_display (display_manager, l->data);
- g_slist_free (displays);
g_signal_connect (display_manager,
"display-opened",
G_CALLBACK (register_display),
NULL);
+
+ g_slist_free (displays);
}
/**
diff --git a/src/adw-swipe-tracker.c b/src/adw-swipe-tracker.c
index 8db57964..f3bb2dff 100644
--- a/src/adw-swipe-tracker.c
+++ b/src/adw-swipe-tracker.c
@@ -389,12 +389,13 @@ get_end_progress (AdwSwipeTracker *self,
points = adw_swipeable_get_snap_points (self->swipeable, &n);
- if (ABS (velocity) < (is_touchpad ? VELOCITY_THRESHOLD_TOUCHPAD : VELOCITY_THRESHOLD_TOUCH))
- {
- pos = points[find_closest_point (points, n, self->progress)];
- g_free (points);
- return pos;
- }
+ if (ABS (velocity) < (is_touchpad ? VELOCITY_THRESHOLD_TOUCHPAD : VELOCITY_THRESHOLD_TOUCH)) {
+ pos = points[find_closest_point (points, n, self->progress)];
+
+ g_free (points);
+
+ return pos;
+ }
decel = is_touchpad ? DECELERATION_TOUCHPAD : DECELERATION_TOUCH;
slope = decel / (1.0 - decel) / 1000.0;
diff --git a/src/adw-toast.c b/src/adw-toast.c
index b9d86479..13f51608 100644
--- a/src/adw-toast.c
+++ b/src/adw-toast.c
@@ -675,15 +675,13 @@ adw_toast_set_detailed_action_name (AdwToast *self,
if (g_action_parse_detailed_name (detailed_action_name, &name, &target, &error)) {
adw_toast_set_action_name (self, name);
adw_toast_set_action_target_value (self, target);
- }
- else
+ } else {
g_critical ("Couldn't parse detailed action name: %s", error->message);
- g_clear_error (&error);
-
- if (target != NULL)
- g_variant_unref (target);
+ g_clear_error (&error);
+ }
+ g_clear_pointer (&target, g_variant_unref);
g_free (name);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]