[libhandy/msvc: 9/11] src/: Remove g_auto*
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/msvc: 9/11] src/: Remove g_auto*
- Date: Wed, 25 May 2022 08:16:24 +0000 (UTC)
commit 4a3b8763ead558b7b266fc6e8fd9121c159842b8
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Apr 26 18:19:32 2022 +0800
src/: Remove g_auto*
This way, the sources will be buildable on Visual Studio.
src/gtk-window.c | 12 +-
src/hdy-avatar-icon.c | 32 ++--
src/hdy-avatar.c | 309 +++++++++++++++++++++++--------------
src/hdy-carousel-box.c | 12 +-
src/hdy-carousel-indicator-dots.c | 35 +++--
src/hdy-carousel-indicator-lines.c | 36 +++--
src/hdy-combo-row.c | 64 +++++---
src/hdy-expander-row.c | 4 +-
src/hdy-header-bar.c | 4 +-
src/hdy-header-group.c | 17 +-
src/hdy-keypad-button.c | 4 +-
src/hdy-keypad.c | 21 +--
src/hdy-main.c | 15 +-
src/hdy-preferences-group.c | 4 +-
src/hdy-preferences-window.c | 46 +++---
src/hdy-settings.c | 19 ++-
src/hdy-shadow-helper.c | 24 ++-
src/hdy-squeezer.c | 4 +-
src/hdy-stackable-box.c | 8 +-
src/hdy-style-manager.c | 61 +++++---
src/hdy-swipe-tracker.c | 29 +++-
src/hdy-tab-view.c | 8 +-
src/hdy-value-object.c | 34 ++--
src/hdy-view-switcher.c | 23 ++-
src/hdy-window-handle-controller.c | 38 +++--
src/hdy-window-mixin.c | 18 ++-
26 files changed, 571 insertions(+), 310 deletions(-)
---
diff --git a/src/gtk-window.c b/src/gtk-window.c
index bde39e0f..dffcd36a 100644
--- a/src/gtk-window.c
+++ b/src/gtk-window.c
@@ -133,7 +133,7 @@ hdy_gtk_window_get_icon_for_size (GtkWindow *window,
{
GtkWindowIconInfo *info;
const gchar *name;
- g_autoptr (GList) default_icon_list = gtk_window_get_default_icon_list ();
+ GList *default_icon_list;
info = ensure_icon_info (window);
@@ -151,8 +151,14 @@ hdy_gtk_window_get_icon_for_size (GtkWindow *window,
return icon_from_list (info->icon_list, size);
}
- if (default_icon_list != NULL)
- return icon_from_list (default_icon_list, size);
+ default_icon_list = gtk_window_get_default_icon_list ();
+ if (default_icon_list != NULL) {
+ GdkPixbuf *ret = icon_from_list (default_icon_list, size);
+
+ g_object_unref (default_icon_list);
+
+ return ret;
+ }
if (gtk_window_get_default_icon_name () != NULL)
return icon_from_name (gtk_window_get_default_icon_name (), size);
diff --git a/src/hdy-avatar-icon.c b/src/hdy-avatar-icon.c
index 53f4a3e6..93e7d934 100644
--- a/src/hdy-avatar-icon.c
+++ b/src/hdy-avatar-icon.c
@@ -78,22 +78,20 @@ load_pixbuf_cb (GObject *source_object,
GAsyncResult *res,
gpointer data)
{
- g_autoptr (GTask) task = G_TASK (data);
- g_autoptr (GError) error = NULL;
- g_autoptr (GInputStream) stream = NULL;
+ GTask *task = G_TASK (data);
+ GError *error = NULL;
+ GInputStream *stream;
- if (g_task_return_error_if_cancelled (task))
- return;
+ if (!g_task_return_error_if_cancelled (task)) {
+ stream = g_loadable_icon_load_finish (G_LOADABLE_ICON (source_object), res, NULL, &error);
- stream = g_loadable_icon_load_finish (G_LOADABLE_ICON (source_object), res, NULL, &error);
-
- if (stream == NULL) {
- g_task_return_error (task, g_steal_pointer (&error));
-
- return;
+ if (stream != NULL)
+ g_task_return_pointer (task, stream, g_object_unref);
+ else
+ g_task_return_error (task, error);
}
- g_task_return_pointer (task, g_steal_pointer (&stream), g_object_unref);
+ g_object_unref (task);
}
static void
@@ -104,8 +102,8 @@ hdy_avatar_icon_load_async (GLoadableIcon *icon,
gpointer user_data)
{
HdyAvatarIcon *self;
- g_autoptr (GTask) task = NULL;
- g_autoptr (GdkPixbuf) pixbuf = NULL;
+ GTask *task;
+ GdkPixbuf *pixbuf = NULL;
g_return_if_fail (HDY_IS_AVATAR_ICON (icon));
self = HDY_AVATAR_ICON (icon);
@@ -123,12 +121,16 @@ hdy_avatar_icon_load_async (GLoadableIcon *icon,
size,
cancellable,
load_pixbuf_cb,
- g_steal_pointer (&task));
+ task);
+
+ g_object_unref (pixbuf);
} else {
g_task_return_new_error (task,
HDY_AVATAR_ICON_ERROR,
HDY_AVATAR_ICON_ERROR_EMPTY,
"No pixbuf set");
+
+ g_object_unref (task);
}
}
diff --git a/src/hdy-avatar.c b/src/hdy-avatar.c
index d4e0d01d..240d07fc 100644
--- a/src/hdy-avatar.c
+++ b/src/hdy-avatar.c
@@ -115,10 +115,11 @@ static GdkPixbuf *
make_round_image (GdkPixbuf *pixbuf,
gdouble size)
{
- g_autoptr (cairo_surface_t) surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
- g_autoptr (cairo_t) cr = cairo_create (surface);
+ cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
+ cairo_t *cr = cairo_create (surface);
gint width = gdk_pixbuf_get_width (pixbuf);
gint height = gdk_pixbuf_get_height (pixbuf);
+ GdkPixbuf *result;
/* Clip a circle */
cairo_arc (cr, size / 2.0, size / 2.0, size / 2.0, 0, 2 * G_PI);
@@ -128,35 +129,47 @@ make_round_image (GdkPixbuf *pixbuf,
gdk_cairo_set_source_pixbuf (cr, pixbuf, (size - width) / 2, (size - height) / 2);
cairo_paint (cr);
- return gdk_pixbuf_get_from_surface (surface, 0, 0, size, size);
+ result = gdk_pixbuf_get_from_surface (surface, 0, 0, size, size);
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ return result;
}
static gchar *
extract_initials_from_text (const gchar *text)
{
GString *initials;
- g_autofree gchar *p = g_utf8_strup (text, -1);
- g_autofree gchar *normalized = g_utf8_normalize (g_strstrip (p), -1, G_NORMALIZE_DEFAULT_COMPOSE);
+ gchar *p = g_utf8_strup (text, -1);
+ gchar *normalized = g_utf8_normalize (g_strstrip (p), -1, G_NORMALIZE_DEFAULT_COMPOSE);
gunichar unichar;
gchar *q = NULL;
+ gchar *ret;
- if (normalized == NULL)
- return NULL;
+ if (normalized != NULL) {
+ initials = g_string_new ("");
- initials = g_string_new ("");
+ unichar = g_utf8_get_char (normalized);
+ g_string_append_unichar (initials, unichar);
- unichar = g_utf8_get_char (normalized);
- g_string_append_unichar (initials, unichar);
+ q = g_utf8_strrchr (normalized, -1, ' ');
+ if (q != NULL) {
+ unichar = g_utf8_get_char (g_utf8_next_char (q));
- q = g_utf8_strrchr (normalized, -1, ' ');
- if (q != NULL) {
- unichar = g_utf8_get_char (g_utf8_next_char (q));
+ if (unichar != 0)
+ g_string_append_unichar (initials, unichar);
+ }
- if (unichar != 0)
- g_string_append_unichar (initials, unichar);
+ ret = g_string_free (initials, FALSE);
+ } else {
+ ret = NULL;
}
- return g_string_free (initials, FALSE);
+ g_free (normalized);
+ g_free (p);
+
+ return ret;
}
static GdkPixbuf *
@@ -219,49 +232,50 @@ load_from_stream_async_cb (GObject *stream,
GAsyncResult *res,
gpointer data)
{
- g_autoptr (GTask) task = data;
+ GTask *task = data;
GdkPixbufLoader *loader = g_task_get_task_data (task);
- g_autoptr (GBytes) bytes = NULL;
+ GBytes *bytes;
GError *error = NULL;
+ gboolean return_error = FALSE;
+ gboolean is_zero_size = FALSE;
bytes = g_input_stream_read_bytes_finish (G_INPUT_STREAM (stream), res, &error);
if (bytes == NULL) {
- gdk_pixbuf_loader_close (loader, NULL);
- g_task_return_error (task, error);
-
- return;
+ return_error = TRUE;
+ } else if (g_bytes_get_size (bytes) == 0) {
+ is_zero_size = TRUE;
+
+ if (!gdk_pixbuf_loader_close (loader, &error))
+ return_error = TRUE;
+ } else if (!gdk_pixbuf_loader_write (loader,
+ g_bytes_get_data (bytes, NULL),
+ g_bytes_get_size (bytes),
+ &error)) {
+ return_error = TRUE;
}
- if (g_bytes_get_size (bytes) == 0) {
- if (!gdk_pixbuf_loader_close (loader, &error)) {
- g_task_return_error (task, error);
-
- return;
- }
-
- g_task_return_pointer (task,
- g_object_ref (gdk_pixbuf_loader_get_pixbuf (loader)),
- g_object_unref);
-
- return;
- }
+ if (return_error) {
+ if (!is_zero_size)
+ gdk_pixbuf_loader_close (loader, NULL);
- if (!gdk_pixbuf_loader_write (loader,
- g_bytes_get_data (bytes, NULL),
- g_bytes_get_size (bytes),
- &error)) {
- gdk_pixbuf_loader_close (loader, NULL);
g_task_return_error (task, error);
-
- return;
+ } else {
+ if (is_zero_size) {
+ g_task_return_pointer (task,
+ g_object_ref (gdk_pixbuf_loader_get_pixbuf (loader)),
+ g_object_unref);
+ } else {
+ g_input_stream_read_bytes_async (G_INPUT_STREAM (stream),
+ LOAD_BUFFER_SIZE,
+ G_PRIORITY_DEFAULT,
+ g_task_get_cancellable (task),
+ load_from_stream_async_cb,
+ g_object_ref (task));
+ }
}
- g_input_stream_read_bytes_async (G_INPUT_STREAM (stream),
- LOAD_BUFFER_SIZE,
- G_PRIORITY_DEFAULT,
- g_task_get_cancellable (task),
- load_from_stream_async_cb,
- g_object_ref (task));
+ g_bytes_unref (bytes);
+ g_object_unref (task);
}
static void
@@ -270,8 +284,8 @@ icon_load_async_cb (GLoadableIcon *icon,
GTask *task)
{
GdkPixbufLoader *loader = g_task_get_task_data (task);
- g_autoptr (GInputStream) stream = NULL;
- g_autoptr (GError) error = NULL;
+ GInputStream *stream;
+ GError *error = NULL;
stream = g_loadable_icon_load_finish (icon, res, NULL, &error);
if (stream == NULL) {
@@ -279,6 +293,8 @@ icon_load_async_cb (GLoadableIcon *icon,
g_task_return_error (task, g_steal_pointer (&error));
g_object_unref (task);
+ g_clear_error (&error);
+
return;
}
@@ -288,6 +304,8 @@ icon_load_async_cb (GLoadableIcon *icon,
g_task_get_cancellable (task),
load_from_stream_async_cb,
task);
+
+ g_object_unref (stream);
}
static GdkPixbuf *
@@ -304,8 +322,8 @@ load_from_gicon_async_for_display_cb (HdyAvatar *self,
GAsyncResult *res,
gpointer *user_data)
{
- g_autoptr (GError) error = NULL;
- g_autoptr (GdkPixbuf) pixbuf = NULL;
+ GError *error = NULL;
+ GdkPixbuf *pixbuf = NULL;
pixbuf = load_from_gicon_async_finish (res, &error);
@@ -321,7 +339,7 @@ load_from_gicon_async_for_display_cb (HdyAvatar *self,
self->currently_loading_size = -1;
if (pixbuf) {
- g_autoptr (GdkPixbuf) custom_image = NULL;
+ GdkPixbuf *custom_image = NULL;
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (self));
gint width = gtk_widget_get_allocated_width (GTK_WIDGET (self));
gint height = gtk_widget_get_allocated_height (GTK_WIDGET (self));
@@ -339,7 +357,14 @@ load_from_gicon_async_for_display_cb (HdyAvatar *self,
g_set_object (&self->round_image, custom_image);
gtk_widget_queue_draw (GTK_WIDGET (self));
+
+ if (custom_image != NULL)
+ g_object_unref (custom_image);
+
+ g_object_unref (pixbuf);
}
+
+ g_clear_error (&error);
}
static void
@@ -348,8 +373,8 @@ load_from_gicon_async_for_export_cb (HdyAvatar *self,
gpointer *user_data)
{
GTask *task = G_TASK (user_data);
- g_autoptr (GError) error = NULL;
- g_autoptr (GdkPixbuf) pixbuf = NULL;
+ GError *error = NULL;
+ GdkPixbuf *pixbuf;
pixbuf = load_from_gicon_async_finish (res, &error);
@@ -362,6 +387,11 @@ load_from_gicon_async_for_export_cb (HdyAvatar *self,
g_task_return_pointer (task,
g_steal_pointer (&pixbuf),
g_object_unref);
+
+ if (pixbuf != NULL)
+ g_object_unref (pixbuf);
+
+ g_clear_error (&error);
g_object_unref (task);
}
@@ -435,50 +465,61 @@ static GdkPixbuf *
load_icon_sync (GLoadableIcon *icon,
gint size)
{
- g_autoptr (GError) error = NULL;
- g_autoptr (GInputStream) stream = g_loadable_icon_load (icon, size, NULL, NULL, &error);
- g_autoptr (GdkPixbufLoader) loader = gdk_pixbuf_loader_new ();
- g_autoptr (GdkPixbuf) pixbuf = NULL;
+ GError *error = NULL;
+ GInputStream *stream = g_loadable_icon_load (icon, size, NULL, NULL, &error);
+ GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
+ GdkPixbuf *pixbuf = NULL;
+ gboolean failed = FALSE;
if (error) {
g_warning ("Failed to load icon: %s", error->message);
- return NULL;
+ failed = TRUE;
}
- g_signal_connect (loader, "size-prepared",
- G_CALLBACK (size_prepared_cb),
- GINT_TO_POINTER (size));
+ if (!failed) {
+ g_signal_connect (loader, "size-prepared",
+ G_CALLBACK (size_prepared_cb),
+ GINT_TO_POINTER (size));
- pixbuf = load_from_stream (loader, stream, NULL, &error);
+ pixbuf = load_from_stream (loader, stream, NULL, &error);
- if (error) {
- g_warning ("Failed to load pixbuf from GLoadableIcon: %s", error->message);
- return NULL;
+ if (error) {
+ g_warning ("Failed to load pixbuf from GLoadableIcon: %s", error->message);
+ failed = TRUE;
+ }
+
+ g_object_unref (stream);
}
- return g_steal_pointer (&pixbuf);
+ g_object_unref (loader);
+ g_clear_error (&error);
+
+ return pixbuf;
}
static void
set_class_color (HdyAvatar *self)
{
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (self));
- g_autofree GRand *rand = NULL;
- g_autofree gchar *new_class = NULL;
- g_autofree gchar *old_class = g_strdup_printf ("color%d", self->color_class);
+ gchar *new_class;
+ gchar *old_class = g_strdup_printf ("color%d", self->color_class);
gtk_style_context_remove_class (context, old_class);
if (self->text == NULL || strlen (self->text) == 0) {
/* Use a random color if we don't have a text */
- rand = g_rand_new ();
+ GRand *rand = g_rand_new ();
self->color_class = g_rand_int_range (rand, 1, NUMBER_OF_COLORS);
+ g_rand_free (rand);
} else {
self->color_class = (g_str_hash (self->text) % NUMBER_OF_COLORS) + 1;
}
new_class = g_strdup_printf ("color%d", self->color_class);
gtk_style_context_add_class (context, new_class);
+
+ g_free (old_class);
+ g_free (new_class);
}
static void
@@ -502,13 +543,15 @@ clear_pango_layout (HdyAvatar *self)
static void
ensure_pango_layout (HdyAvatar *self)
{
- g_autofree gchar *initials = NULL;
+ gchar *initials;
if (self->layout != NULL || self->text == NULL || strlen (self->text) == 0)
return;
initials = extract_initials_from_text (self->text);
self->layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), initials);
+
+ g_free (initials);
}
static void
@@ -660,10 +703,10 @@ draw_for_size (HdyAvatar *self,
gdouble y = (gdouble)(height - size) / 2.0;
const gchar *icon_name;
GdkRGBA color;
- g_autoptr (GtkIconInfo) icon = NULL;
- g_autoptr (GdkPixbuf) pixbuf = NULL;
- g_autoptr (GError) error = NULL;
- g_autoptr (cairo_surface_t) surface = NULL;
+ GtkIconInfo *icon;
+ GdkPixbuf *pixbuf;
+ GError *error = NULL;
+ cairo_surface_t *surface;
set_class_contrasted (self, size);
@@ -673,6 +716,8 @@ draw_for_size (HdyAvatar *self,
gtk_render_icon_surface (context, cr, surface, x, y);
gtk_render_background (context, cr, x, y, size, size);
gtk_render_frame (context, cr, x, y, size, size);
+
+ cairo_surface_destroy (surface);
return;
}
@@ -707,17 +752,23 @@ draw_for_size (HdyAvatar *self,
pixbuf = gtk_icon_info_load_symbolic (icon, &color, NULL, NULL, NULL, NULL, &error);
if (error != NULL) {
g_critical ("Failed to load icon `%s': %s", icon_name, error->message);
- return;
- }
- surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale_factor,
- gtk_widget_get_window (GTK_WIDGET (self)));
+ g_clear_error (&error);
+ } else {
+ surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale_factor,
+ gtk_widget_get_window (GTK_WIDGET (self)));
- width = cairo_image_surface_get_width (surface);
- height = cairo_image_surface_get_height (surface);
- gtk_render_icon_surface (context, cr, surface,
- (((gdouble) size - ((gdouble) width / (gdouble) scale_factor)) / 2.0) + x,
- (((gdouble) size - ((gdouble) height / (gdouble) scale_factor)) / 2.0) + y);
+ width = cairo_image_surface_get_width (surface);
+ height = cairo_image_surface_get_height (surface);
+ gtk_render_icon_surface (context, cr, surface,
+ (((gdouble) size - ((gdouble) width / (gdouble) scale_factor)) / 2.0) + x,
+ (((gdouble) size - ((gdouble) height / (gdouble) scale_factor)) / 2.0) + y);
+ cairo_surface_destroy (surface);
+ }
+
+ g_object_unref (icon);
+ if (pixbuf != NULL)
+ g_object_unref (pixbuf);
}
static gboolean
@@ -1138,7 +1189,7 @@ hdy_avatar_set_image_load_func (HdyAvatar *self,
gpointer user_data,
GDestroyNotify destroy)
{
- g_autoptr (HdyAvatarIcon) icon = NULL;
+ HdyAvatarIcon *icon = NULL;
g_return_if_fail (HDY_IS_AVATAR (self));
g_return_if_fail (user_data != NULL || (user_data == NULL && destroy == NULL));
@@ -1156,22 +1207,24 @@ hdy_avatar_set_image_load_func (HdyAvatar *self,
g_set_object (&self->load_func_icon, icon);
/* Don't update the custom avatar when we have a user set GLoadableIcon */
- if (self->icon)
- return;
-
- if (self->load_func_icon) {
- gint scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
+ if (!self->icon) {
+ if (self->load_func_icon) {
+ gint scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
- self->cancellable = g_cancellable_new ();
- self->currently_loading_size = self->size * scale_factor;
- load_icon_async (self,
- self->currently_loading_size,
- self->cancellable,
- (GAsyncReadyCallback) load_from_gicon_async_for_display_cb,
- NULL);
- } else {
- gtk_widget_queue_draw (GTK_WIDGET (self));
+ self->cancellable = g_cancellable_new ();
+ self->currently_loading_size = self->size * scale_factor;
+ load_icon_async (self,
+ self->currently_loading_size,
+ self->cancellable,
+ (GAsyncReadyCallback) load_from_gicon_async_for_display_cb,
+ NULL);
+ } else {
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+ }
}
+
+ if (icon != NULL)
+ g_object_unref (icon);
}
/**
@@ -1236,13 +1289,14 @@ hdy_avatar_draw_to_pixbuf (HdyAvatar *self,
gint size,
gint scale_factor)
{
- g_autoptr (cairo_surface_t) surface = NULL;
- g_autoptr (cairo_t) cr = NULL;
- g_autoptr (GdkPixbuf) custom_image = NULL;
- g_autoptr (GdkPixbuf) pixbuf_from_icon = NULL;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ GdkPixbuf *custom_image = NULL;
+ GdkPixbuf *pixbuf_from_icon = NULL;
gint scaled_size = size * scale_factor;
GtkStyleContext *context;
GtkAllocation bounds;
+ GdkPixbuf *result;
g_return_val_if_fail (HDY_IS_AVATAR (self), NULL);
g_return_val_if_fail (size > 0, NULL);
@@ -1274,9 +1328,18 @@ hdy_avatar_draw_to_pixbuf (HdyAvatar *self,
draw_for_size (self, cr, custom_image, size, size, scale_factor);
- return gdk_pixbuf_get_from_surface (surface, 0, 0,
- bounds.width * scale_factor,
- bounds.height * scale_factor);
+ result = gdk_pixbuf_get_from_surface (surface, 0, 0,
+ bounds.width * scale_factor,
+ bounds.height * scale_factor);
+
+ if (custom_image != NULL)
+ g_object_unref (custom_image);
+ if (pixbuf_from_icon != NULL)
+ g_object_unref (pixbuf_from_icon);
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ return result;
}
/**
@@ -1303,7 +1366,7 @@ hdy_avatar_draw_to_pixbuf_async (HdyAvatar *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- g_autoptr (GTask) task = NULL;
+ GTask *task;
gint scaled_size = size * scale_factor;
SizeData *data;
@@ -1327,9 +1390,11 @@ hdy_avatar_draw_to_pixbuf_async (HdyAvatar *self,
scaled_size,
cancellable,
(GAsyncReadyCallback) load_from_gicon_async_for_export_cb,
- g_steal_pointer (&task));
+ task);
else
g_task_return_pointer (task, NULL, NULL);
+
+ g_object_unref (task);
}
/**
@@ -1348,13 +1413,14 @@ hdy_avatar_draw_to_pixbuf_finish (HdyAvatar *self,
GAsyncResult *async_result)
{
GTask *task;
- g_autoptr (GdkPixbuf) pixbuf_from_icon = NULL;
- g_autoptr (GdkPixbuf) custom_image = NULL;
- g_autoptr (cairo_surface_t) surface = NULL;
- g_autoptr (cairo_t) cr = NULL;
+ GdkPixbuf *pixbuf_from_icon;
+ GdkPixbuf *custom_image;
+ cairo_surface_t *surface;
+ cairo_t *cr;
SizeData *data;
GtkStyleContext *context;
GtkAllocation bounds;
+ GdkPixbuf *result;
g_return_val_if_fail (G_IS_TASK (async_result), NULL);
@@ -1381,9 +1447,18 @@ hdy_avatar_draw_to_pixbuf_finish (HdyAvatar *self,
data->size * data->scale_factor);
draw_for_size (self, cr, custom_image, data->size, data->size, data->scale_factor);
- return gdk_pixbuf_get_from_surface (surface, 0, 0,
- bounds.width * data->scale_factor,
- bounds.height * data->scale_factor);
+ result = gdk_pixbuf_get_from_surface (surface, 0, 0,
+ bounds.width * data->scale_factor,
+ bounds.height * data->scale_factor);
+
+ if (custom_image != NULL)
+ g_object_unref (custom_image);
+ if (pixbuf_from_icon != NULL)
+ g_object_unref (pixbuf_from_icon);
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ return result;
}
/**
diff --git a/src/hdy-carousel-box.c b/src/hdy-carousel-box.c
index a31f2040..b13541dc 100644
--- a/src/hdy-carousel-box.c
+++ b/src/hdy-carousel-box.c
@@ -433,7 +433,7 @@ animation_cb (GtkWidget *widget,
gpointer user_data)
{
HdyCarouselBox *self = HDY_CAROUSEL_BOX (widget);
- g_autoptr (GList) children = NULL;
+ GList *children;
GList *l;
gboolean should_continue;
gdouble position_shift;
@@ -471,6 +471,8 @@ animation_cb (GtkWidget *widget,
if (!should_continue)
self->tick_cb_id = 0;
+ g_list_free (children);
+
return should_continue;
}
@@ -569,7 +571,7 @@ hdy_carousel_box_draw (GtkWidget *widget,
continue;
if (info->dirty_region && !info->removing) {
- g_autoptr (cairo_t) surface_cr = NULL;
+ cairo_t *surface_cr;
GtkAllocation child_alloc;
if (!info->surface) {
@@ -605,6 +607,8 @@ hdy_carousel_box_draw (GtkWidget *widget,
cairo_region_destroy (info->dirty_region);
info->dirty_region = NULL;
+
+ cairo_destroy (surface_cr);
}
if (!info->surface)
@@ -960,7 +964,7 @@ hdy_carousel_box_forall (GtkContainer *container,
gpointer callback_data)
{
HdyCarouselBox *self = HDY_CAROUSEL_BOX (container);
- g_autoptr (GList) children = NULL;
+ GList *children;
GList *l;
children = g_list_copy (self->children);
@@ -970,6 +974,8 @@ hdy_carousel_box_forall (GtkContainer *container,
if (!child->removing)
(* callback) (child->widget, callback_data);
}
+
+ g_list_free (children);
}
static void
diff --git a/src/hdy-carousel-indicator-dots.c b/src/hdy-carousel-indicator-dots.c
index a74f977b..018e646b 100644
--- a/src/hdy-carousel-indicator-dots.c
+++ b/src/hdy-carousel-indicator-dots.c
@@ -233,8 +233,8 @@ hdy_carousel_indicator_dots_measure (GtkWidget *widget,
if (orientation == self->orientation) {
gint i, n_points = 0;
gdouble indicator_length, dot_size;
- g_autofree gdouble *points = NULL;
- g_autofree gdouble *sizes = NULL;
+ gdouble *points = NULL;
+ gdouble *sizes;
if (self->carousel)
points = hdy_swipeable_get_snap_points (HDY_SWIPEABLE (self->carousel), &n_points);
@@ -252,6 +252,9 @@ hdy_carousel_indicator_dots_measure (GtkWidget *widget,
indicator_length += dot_size * sizes[i];
size = ceil (indicator_length);
+
+ g_free (sizes);
+ g_free (points);
} else {
size = 2 * DOTS_RADIUS_SELECTED;
}
@@ -296,8 +299,7 @@ hdy_carousel_indicator_dots_draw (GtkWidget *widget,
HdyCarouselIndicatorDots *self = HDY_CAROUSEL_INDICATOR_DOTS (widget);
gint i, n_points;
gdouble position;
- g_autofree gdouble *points = NULL;
- g_autofree gdouble *sizes = NULL;
+ gdouble *points;
if (!self->carousel)
return GDK_EVENT_PROPAGATE;
@@ -305,20 +307,25 @@ hdy_carousel_indicator_dots_draw (GtkWidget *widget,
points = hdy_swipeable_get_snap_points (HDY_SWIPEABLE (self->carousel), &n_points);
position = hdy_carousel_get_position (self->carousel);
- if (n_points < 2)
- return GDK_EVENT_PROPAGATE;
+ if (n_points >= 2) {
+ gdouble *sizes;
+
+ if (self->orientation == GTK_ORIENTATION_HORIZONTAL &&
+ gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ position = points[n_points - 1] - position;
+
+ sizes = g_new0 (gdouble, n_points);
- if (self->orientation == GTK_ORIENTATION_HORIZONTAL &&
- gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- position = points[n_points - 1] - position;
+ sizes[0] = points[0] + 1;
+ for (i = 1; i < n_points; i++)
+ sizes[i] = points[i] - points[i - 1];
- sizes = g_new0 (gdouble, n_points);
+ draw_dots (widget, cr, self->orientation, position, sizes, n_points);
- sizes[0] = points[0] + 1;
- for (i = 1; i < n_points; i++)
- sizes[i] = points[i] - points[i - 1];
+ g_free (sizes);
+ }
- draw_dots (widget, cr, self->orientation, position, sizes, n_points);
+ g_free (points);
return GDK_EVENT_PROPAGATE;
}
diff --git a/src/hdy-carousel-indicator-lines.c b/src/hdy-carousel-indicator-lines.c
index c44bd3e9..344b3ba9 100644
--- a/src/hdy-carousel-indicator-lines.c
+++ b/src/hdy-carousel-indicator-lines.c
@@ -231,8 +231,8 @@ hdy_carousel_indicator_lines_measure (GtkWidget *widget,
if (orientation == self->orientation) {
gint i, n_points = 0;
gdouble indicator_length, line_size;
- g_autofree gdouble *points = NULL;
- g_autofree gdouble *sizes = NULL;
+ gdouble *points = NULL;
+ gdouble *sizes;
if (self->carousel)
points = hdy_swipeable_get_snap_points (HDY_SWIPEABLE (self->carousel), &n_points);
@@ -250,6 +250,10 @@ hdy_carousel_indicator_lines_measure (GtkWidget *widget,
indicator_length += line_size * sizes[i];
size = ceil (indicator_length);
+
+ g_free (sizes);
+ g_free (points);
+
} else {
size = LINE_WIDTH;
}
@@ -294,8 +298,7 @@ hdy_carousel_indicator_lines_draw (GtkWidget *widget,
HdyCarouselIndicatorLines *self = HDY_CAROUSEL_INDICATOR_LINES (widget);
gint i, n_points;
gdouble position;
- g_autofree gdouble *points = NULL;
- g_autofree gdouble *sizes = NULL;
+ gdouble *points;
if (!self->carousel)
return GDK_EVENT_PROPAGATE;
@@ -303,20 +306,25 @@ hdy_carousel_indicator_lines_draw (GtkWidget *widget,
points = hdy_swipeable_get_snap_points (HDY_SWIPEABLE (self->carousel), &n_points);
position = hdy_carousel_get_position (self->carousel);
- if (n_points < 2)
- return GDK_EVENT_PROPAGATE;
+ if (n_points >= 2) {
+ gdouble *sizes;
- if (self->orientation == GTK_ORIENTATION_HORIZONTAL &&
- gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- position = points[n_points - 1] - position;
+ if (self->orientation == GTK_ORIENTATION_HORIZONTAL &&
+ gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ position = points[n_points - 1] - position;
- sizes = g_new0 (gdouble, n_points);
+ sizes = g_new0 (gdouble, n_points);
- sizes[0] = points[0] + 1;
- for (i = 1; i < n_points; i++)
- sizes[i] = points[i] - points[i - 1];
+ sizes[0] = points[0] + 1;
+ for (i = 1; i < n_points; i++)
+ sizes[i] = points[i] - points[i - 1];
+
+ draw_lines (widget, cr, self->orientation, position, sizes, n_points);
+
+ g_free (sizes);
+ }
- draw_lines (widget, cr, self->orientation, position, sizes, n_points);
+ g_free (points);
return GDK_EVENT_PROPAGATE;
}
diff --git a/src/hdy-combo-row.c b/src/hdy-combo-row.c
index e546f77d..fa3c75b6 100644
--- a/src/hdy-combo-row.c
+++ b/src/hdy-combo-row.c
@@ -87,16 +87,21 @@ create_list_label (gpointer item,
gpointer user_data)
{
HdyComboRowGetName *get_name = (HdyComboRowGetName *) user_data;
- g_autofree gchar *name = get_name->func (item, get_name->func_data);
-
- return g_object_new (GTK_TYPE_LABEL,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "label", name,
- "max-width-chars", 20,
- "valign", GTK_ALIGN_CENTER,
- "visible", TRUE,
- "xalign", 0.0,
- NULL);
+ gchar *name = get_name->func (item, get_name->func_data);
+ GtkWidget *widget;
+
+ widget = g_object_new (GTK_TYPE_LABEL,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "label", name,
+ "max-width-chars", 20,
+ "valign", GTK_ALIGN_CENTER,
+ "visible", TRUE,
+ "xalign", 0.0,
+ NULL);
+
+ g_free (name);
+
+ return widget;
}
static GtkWidget *
@@ -104,19 +109,24 @@ create_current_label (gpointer item,
gpointer user_data)
{
HdyComboRowGetName *get_name = (HdyComboRowGetName *) user_data;
- g_autofree gchar *name = NULL;
+ gchar *name = NULL;
+ GtkWidget *widget;
if (get_name->func)
name = get_name->func (item, get_name->func_data);
- return g_object_new (GTK_TYPE_LABEL,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "halign", GTK_ALIGN_END,
- "label", name,
- "valign", GTK_ALIGN_CENTER,
- "visible", TRUE,
- "xalign", 0.0,
- NULL);
+ widget = g_object_new (GTK_TYPE_LABEL,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "halign", GTK_ALIGN_END,
+ "label", name,
+ "valign", GTK_ALIGN_CENTER,
+ "visible", TRUE,
+ "xalign", 0.0,
+ NULL);
+
+ g_free (name);
+
+ return widget;
}
static void
@@ -178,8 +188,7 @@ static void
update (HdyComboRow *self)
{
HdyComboRowPrivate *priv = hdy_combo_row_get_instance_private (self);
- g_autoptr(GObject) item = NULL;
- g_autofree gchar *name = NULL;
+ GObject *item;
GtkWidget *widget;
guint n_items = priv->bound_model ? g_list_model_get_n_items (priv->bound_model) : 0;
gint i;
@@ -209,16 +218,22 @@ update (HdyComboRow *self)
item = g_list_model_get_item (priv->bound_model, priv->selected_index);
if (priv->use_subtitle) {
+ gchar *name = NULL;
+
if (priv->get_name != NULL && priv->get_name->func)
name = priv->get_name->func (item, priv->get_name->func_data);
else if (priv->get_name_internal != NULL && priv->get_name_internal->func)
name = priv->get_name_internal->func (item, priv->get_name_internal->func_data);
hdy_action_row_set_subtitle (HDY_ACTION_ROW (self), name);
+
+ g_free (name);
}
else {
widget = priv->create_current_widget_func (item, priv->create_widget_func_data);
gtk_container_add (GTK_CONTAINER (priv->current), widget);
}
+
+ g_object_unref (item);
}
static void
@@ -653,7 +668,7 @@ hdy_combo_row_set_for_enum (HdyComboRow *self,
gpointer user_data,
GDestroyNotify user_data_free_func)
{
- g_autoptr (GListStore) store = g_list_store_new (HDY_TYPE_ENUM_VALUE_OBJECT);
+ GListStore *store = g_list_store_new (HDY_TYPE_ENUM_VALUE_OBJECT);
/* g_autoptr for GEnumClass would require glib > 2.56 */
GEnumClass *enum_class = NULL;
gsize i;
@@ -663,13 +678,16 @@ hdy_combo_row_set_for_enum (HdyComboRow *self,
enum_class = g_type_class_ref (enum_type);
for (i = 0; i < enum_class->n_values; i++)
{
- g_autoptr(HdyEnumValueObject) obj = hdy_enum_value_object_new (&enum_class->values[i]);
+ HdyEnumValueObject *obj = hdy_enum_value_object_new (&enum_class->values[i]);
g_list_store_append (store, obj);
+
+ g_object_unref (obj);
}
hdy_combo_row_bind_name_model (self, G_LIST_MODEL (store), (HdyComboRowGetNameFunc) get_name_func,
user_data, user_data_free_func);
g_type_class_unref (enum_class);
+ g_object_unref (store);
}
/**
diff --git a/src/hdy-expander-row.c b/src/hdy-expander-row.c
index 92c8dd00..e40c79b3 100644
--- a/src/hdy-expander-row.c
+++ b/src/hdy-expander-row.c
@@ -89,13 +89,15 @@ update_arrow (HdyExpanderRow *self)
GtkWidget *previous_sibling = NULL;
if (parent) {
- g_autoptr (GList) siblings = gtk_container_get_children (GTK_CONTAINER (parent));
+ GList *siblings = gtk_container_get_children (GTK_CONTAINER (parent));
GList *l;
for (l = siblings; l != NULL && l->next != NULL && l->next->data != self; l = l->next);
if (l && l->next && l->next->data == self)
previous_sibling = l->data;
+
+ g_list_free (siblings);
}
if (priv->expanded)
diff --git a/src/hdy-header-bar.c b/src/hdy-header-bar.c
index 9d455e16..279623d3 100644
--- a/src/hdy-header-bar.c
+++ b/src/hdy-header-bar.c
@@ -333,13 +333,15 @@ hdy_header_bar_update_window_icon (HdyHeaderBar *self,
pixbuf = hdy_gtk_window_get_icon_for_size (window, scale * 20);
if (pixbuf) {
- g_autoptr (cairo_surface_t) surface =
+ cairo_surface_t *surface =
gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, gtk_widget_get_window (priv->titlebar_icon));
gtk_image_set_from_surface (GTK_IMAGE (priv->titlebar_icon), surface);
g_object_unref (pixbuf);
gtk_widget_show (priv->titlebar_icon);
+ cairo_surface_destroy (surface);
+
return TRUE;
}
diff --git a/src/hdy-header-group.c b/src/hdy-header-group.c
index 76664144..1138244d 100644
--- a/src/hdy-header-group.c
+++ b/src/hdy-header-group.c
@@ -333,10 +333,10 @@ update_decoration_layouts (HdyHeaderGroup *self)
GSList *children;
GtkSettings *settings;
HdyHeaderGroupChild *start_child = NULL, *end_child = NULL;
- g_autofree gchar *layout = NULL;
- g_autofree gchar *start_layout = NULL;
- g_autofree gchar *end_layout = NULL;
- g_auto(GStrv) ends = NULL;
+ gchar *layout;
+ gchar *start_layout;
+ gchar *end_layout;
+ GStrv ends;
g_return_if_fail (HDY_IS_HEADER_GROUP (self));
@@ -357,6 +357,8 @@ update_decoration_layouts (HdyHeaderGroup *self)
for (; children != NULL; children = children->next)
hdy_header_group_child_set_decoration_layout (HDY_HEADER_GROUP_CHILD (children->data), layout);
+ g_free (layout);
+
return;
}
@@ -380,6 +382,8 @@ update_decoration_layouts (HdyHeaderGroup *self)
if (start_child == end_child) {
hdy_header_group_child_set_decoration_layout (start_child, layout);
+ g_free (layout);
+
return;
}
@@ -393,6 +397,11 @@ update_decoration_layouts (HdyHeaderGroup *self)
}
hdy_header_group_child_set_decoration_layout (start_child, start_layout);
hdy_header_group_child_set_decoration_layout (end_child, end_layout);
+
+ g_free (end_layout);
+ g_free (start_layout);
+ g_strfreev (ends);
+ g_free (layout);
}
static void
diff --git a/src/hdy-keypad-button.c b/src/hdy-keypad-button.c
index 02c6deec..d5a53873 100644
--- a/src/hdy-keypad-button.c
+++ b/src/hdy-keypad-button.c
@@ -41,7 +41,7 @@ G_DEFINE_TYPE (HdyKeypadButton, hdy_keypad_button, GTK_TYPE_BUTTON)
static void
format_label(HdyKeypadButton *self)
{
- g_autofree gchar *text = NULL;
+ gchar *text = NULL;
gchar *secondary_text = NULL;
if (self->symbols != NULL && *(self->symbols) != '\0') {
@@ -51,6 +51,8 @@ format_label(HdyKeypadButton *self)
gtk_label_set_label (self->label, text);
gtk_label_set_label (self->secondary_label, secondary_text);
+
+ g_free (text);
}
static void
diff --git a/src/hdy-keypad.c b/src/hdy-keypad.c
index 36210b7f..88809c7f 100644
--- a/src/hdy-keypad.c
+++ b/src/hdy-keypad.c
@@ -58,17 +58,18 @@ symbol_clicked (HdyKeypad *self,
gchar symbol)
{
HdyKeypadPrivate *priv = hdy_keypad_get_instance_private (self);
- g_autofree gchar *string = g_strdup_printf ("%c", symbol);
-
- if (!priv->entry)
- return;
+ gchar *string = g_strdup_printf ("%c", symbol);
+
+ if (priv->entry) {
+ g_signal_emit_by_name (priv->entry, "insert-at-cursor", string, NULL);
+ /* Set focus to the entry only when it can get focus
+ * https://gitlab.gnome.org/GNOME/gtk/issues/2204
+ */
+ if (gtk_widget_get_can_focus (GTK_WIDGET (priv->entry)))
+ gtk_entry_grab_focus_without_selecting (priv->entry);
+ }
- g_signal_emit_by_name (priv->entry, "insert-at-cursor", string, NULL);
- /* Set focus to the entry only when it can get focus
- * https://gitlab.gnome.org/GNOME/gtk/issues/2204
- */
- if (gtk_widget_get_can_focus (GTK_WIDGET (priv->entry)))
- gtk_entry_grab_focus_without_selecting (priv->entry);
+ g_free (string);
}
diff --git a/src/hdy-main.c b/src/hdy-main.c
index f1c1631c..931428eb 100644
--- a/src/hdy-main.c
+++ b/src/hdy-main.c
@@ -58,8 +58,8 @@ hdy_themes_get_theme_name (gboolean *prefer_dark_theme)
static void
hdy_themes_update (GtkCssProvider *css_provider)
{
- g_autofree gchar *theme_name = NULL;
- g_autofree gchar *resource_path = NULL;
+ gchar *theme_name;
+ gchar *resource_path;
gboolean prefer_dark_theme = FALSE;
g_assert (GTK_IS_CSS_PROVIDER (css_provider));
@@ -85,12 +85,15 @@ hdy_themes_update (GtkCssProvider *css_provider)
}
gtk_css_provider_load_from_resource (css_provider, resource_path);
+
+ g_free (resource_path);
+ g_free (theme_name);
}
static void
load_fallback_style (void)
{
- g_autoptr (GtkCssProvider) css_provider = NULL;
+ GtkCssProvider *css_provider;
css_provider = gtk_css_provider_new ();
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
@@ -98,6 +101,8 @@ load_fallback_style (void)
GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
gtk_css_provider_load_from_resource (css_provider, HDY_THEMES_PATH"fallback.css");
+
+ g_object_unref (css_provider);
}
/**
@@ -112,7 +117,7 @@ static void
hdy_style_init (void)
{
static gsize guard = 0;
- g_autoptr (GtkCssProvider) css_provider = NULL;
+ GtkCssProvider *css_provider;
GtkSettings *settings;
if (!g_once_init_enter (&guard))
@@ -137,6 +142,8 @@ hdy_style_init (void)
load_fallback_style ();
+ g_object_unref (css_provider);
+
g_once_init_leave (&guard, 1);
}
diff --git a/src/hdy-preferences-group.c b/src/hdy-preferences-group.c
index 366b4791..973155df 100644
--- a/src/hdy-preferences-group.c
+++ b/src/hdy-preferences-group.c
@@ -76,7 +76,7 @@ static void
update_listbox_visibility (HdyPreferencesGroup *self)
{
HdyPreferencesGroupPrivate *priv = hdy_preferences_group_get_instance_private (self);
- g_autoptr(GList) children = NULL;
+ GList *children;
/* We must wait until the listbox has been built and added. */
if (priv->listbox == NULL)
@@ -85,6 +85,8 @@ update_listbox_visibility (HdyPreferencesGroup *self)
children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
gtk_widget_set_visible (GTK_WIDGET (priv->listbox), children != NULL);
+
+ g_list_free (children);
}
static gboolean
diff --git a/src/hdy-preferences-window.c b/src/hdy-preferences-window.c
index 294ca08e..ea696ac2 100644
--- a/src/hdy-preferences-window.c
+++ b/src/hdy-preferences-window.c
@@ -69,7 +69,7 @@ static GParamSpec *props[LAST_PROP];
static gchar *
strip_mnemonic (const gchar *src)
{
- g_autofree gchar *new_str = g_new (gchar, strlen (src) + 1);
+ gchar *new_str = g_new (gchar, strlen (src) + 1);
gchar *dest = new_str;
gboolean underscore = FALSE;
@@ -81,6 +81,8 @@ strip_mnemonic (const gchar *src)
if (c == (gunichar) -1) {
g_warning ("Invalid input string");
+ g_free (new_str);
+
return NULL;
}
@@ -104,7 +106,7 @@ strip_mnemonic (const gchar *src)
*dest = 0;
- return g_steal_pointer (&new_str);
+ return new_str;
}
static gboolean
@@ -112,9 +114,10 @@ filter_search_results (HdyActionRow *row,
HdyPreferencesWindow *self)
{
HdyPreferencesWindowPrivate *priv = hdy_preferences_window_get_instance_private (self);
- g_autofree gchar *text = g_utf8_casefold (gtk_entry_get_text (GTK_ENTRY (priv->search_entry)), -1);
- g_autofree gchar *title = g_utf8_casefold (hdy_preferences_row_get_title (HDY_PREFERENCES_ROW (row)), -1);
- g_autofree gchar *subtitle = NULL;
+ gchar *text = g_utf8_casefold (gtk_entry_get_text (GTK_ENTRY (priv->search_entry)), -1);
+ gchar *title = g_utf8_casefold (hdy_preferences_row_get_title (HDY_PREFERENCES_ROW (row)), -1);
+ gchar *subtitle = NULL;
+ gboolean result = FALSE;
/* The CSS engine works in such a way that invisible children are treated as
* visible widgets, which breaks the expectations of the .preferences style
@@ -140,21 +143,24 @@ filter_search_results (HdyActionRow *row,
priv->n_last_search_results++;
gtk_widget_show (GTK_WIDGET (row));
- return TRUE;
- }
-
- subtitle = g_utf8_casefold (hdy_action_row_get_subtitle (row), -1);
+ result = TRUE;
+ } else {
+ subtitle = g_utf8_casefold (hdy_action_row_get_subtitle (row), -1);
- if (!!strstr (subtitle, text)) {
- priv->n_last_search_results++;
- gtk_widget_show (GTK_WIDGET (row));
+ if (!!strstr (subtitle, text)) {
+ priv->n_last_search_results++;
+ gtk_widget_show (GTK_WIDGET (row));
- return TRUE;
+ result = TRUE;
+ } else {
+ gtk_widget_hide (GTK_WIDGET (row));
+ }
}
- gtk_widget_hide (GTK_WIDGET (row));
-
- return FALSE;
+ g_free (subtitle);
+ g_free (title);
+ g_free (text);
+ return result;
}
static GtkWidget *
@@ -194,8 +200,10 @@ new_search_row_for_preference (HdyPreferencesRow *row,
if (group_title && !hdy_view_switcher_title_get_title_visible (priv->view_switcher_title))
hdy_action_row_set_subtitle (widget, group_title);
if (group_title) {
- g_autofree gchar *subtitle = g_strdup_printf ("%s → %s", page_title != NULL ? page_title : _("Untitled
page"), group_title);
+ gchar *subtitle = g_strdup_printf ("%s → %s", page_title != NULL ? page_title : _("Untitled page"),
group_title);
hdy_action_row_set_subtitle (widget, subtitle);
+
+ g_free (subtitle);
} else if (page_title)
hdy_action_row_set_subtitle (widget, page_title);
@@ -211,7 +219,7 @@ static void
update_search_results (HdyPreferencesWindow *self)
{
HdyPreferencesWindowPrivate *priv = hdy_preferences_window_get_instance_private (self);
- g_autoptr (GListStore) model;
+ GListStore *model;
model = g_list_store_new (HDY_TYPE_PREFERENCES_ROW);
gtk_container_foreach (GTK_CONTAINER (priv->pages_stack), (GtkCallback)
hdy_preferences_page_add_preferences_to_model, model);
@@ -219,6 +227,8 @@ update_search_results (HdyPreferencesWindow *self)
for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (model)); i++)
gtk_container_add (GTK_CONTAINER (priv->search_results),
new_search_row_for_preference ((HdyPreferencesRow *) g_list_model_get_item
(G_LIST_MODEL (model), i), self));
+
+ g_object_unref (model);
}
static void
diff --git a/src/hdy-settings.c b/src/hdy-settings.c
index 7e177efe..b946b7c6 100644
--- a/src/hdy-settings.c
+++ b/src/hdy-settings.c
@@ -345,8 +345,8 @@ static void
init_gsettings (HdySettings *self)
{
GSettingsSchemaSource *source;
- g_autoptr (GSettingsSchema) schema = NULL;
- g_autoptr (GSettingsSchema) a11y_schema = NULL;
+ GSettingsSchema *schema;
+ GSettingsSchema *a11y_schema;
#ifndef G_OS_WIN32
/* While we can access gsettings in flatpak, we can't do anything useful with
@@ -384,6 +384,11 @@ init_gsettings (HdySettings *self)
G_CALLBACK (gsettings_high_contrast_changed_cb),
self);
}
+
+ if (a11y_schema != NULL)
+ g_settings_schema_unref (a11y_schema);
+ if (schema != NULL)
+ g_settings_schema_unref (schema);
}
/* Legacy */
@@ -391,7 +396,8 @@ init_gsettings (HdySettings *self)
static gboolean
is_theme_high_contrast (void)
{
- g_autofree gchar *icon_theme_name = NULL;
+ gchar *icon_theme_name;
+ gboolean result;
/* We're using icon theme here as we control gtk-theme-name and it
* interferes with the notifications. */
@@ -399,8 +405,11 @@ is_theme_high_contrast (void)
"gtk-icon-theme-name", &icon_theme_name,
NULL);
- return !g_strcmp0 (icon_theme_name, "HighContrast") ||
- !g_strcmp0 (icon_theme_name, "HighContrastInverse");
+ result = !g_strcmp0 (icon_theme_name, "HighContrast") ||
+ !g_strcmp0 (icon_theme_name, "HighContrastInverse");
+
+ g_free (icon_theme_name);
+ return result;
}
static void
diff --git a/src/hdy-shadow-helper.c b/src/hdy-shadow-helper.c
index 278e88e3..bf9b8736 100644
--- a/src/hdy-shadow-helper.c
+++ b/src/hdy-shadow-helper.c
@@ -60,7 +60,7 @@ create_context (HdyShadowHelper *self,
const gchar *name,
GtkPanDirection direction)
{
- g_autoptr(GtkWidgetPath) path = NULL;
+ GtkWidgetPath *path;
GtkStyleContext *context;
gint pos;
const gchar *direction_name;
@@ -81,6 +81,8 @@ create_context (HdyShadowHelper *self,
g_type_class_unref (enum_class);
+ gtk_widget_path_unref (path);
+
return context;
}
@@ -116,9 +118,9 @@ create_element_pattern (GtkStyleContext *context,
gint height,
gint scale)
{
- g_autoptr (cairo_surface_t) surface =
+ cairo_surface_t *surface =
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width * scale, height * scale);
- g_autoptr (cairo_t) cr = cairo_create (surface);
+ cairo_t *cr = cairo_create (surface);
cairo_pattern_t *pattern;
cairo_surface_set_device_scale (surface, scale, scale);
@@ -128,6 +130,9 @@ create_element_pattern (GtkStyleContext *context,
pattern = cairo_pattern_create_for_surface (surface);
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
return pattern;
}
@@ -137,10 +142,10 @@ cache_shadow (HdyShadowHelper *self,
gint height,
GtkPanDirection direction)
{
- g_autoptr(GtkStyleContext) dim_context = NULL;
- g_autoptr(GtkStyleContext) shadow_context = NULL;
- g_autoptr(GtkStyleContext) border_context = NULL;
- g_autoptr(GtkStyleContext) outline_context = NULL;
+ GtkStyleContext *dim_context;
+ GtkStyleContext *shadow_context;
+ GtkStyleContext *border_context;
+ GtkStyleContext *outline_context = NULL;
gint shadow_size, border_size, outline_size, scale;
scale = gtk_widget_get_scale_factor (self->widget);
@@ -183,6 +188,11 @@ cache_shadow (HdyShadowHelper *self,
self->last_width = width;
self->last_height = height;
self->last_scale = scale;
+
+ g_object_unref (outline_context);
+ g_object_unref (border_context);
+ g_object_unref (shadow_context);
+ g_object_unref (dim_context);
}
static void
diff --git a/src/hdy-squeezer.c b/src/hdy-squeezer.c
index 51188408..ce6c0e36 100644
--- a/src/hdy-squeezer.c
+++ b/src/hdy-squeezer.c
@@ -735,7 +735,7 @@ hdy_squeezer_draw (GtkWidget *widget,
if (gtk_progress_tracker_get_state (&self->tracker) != GTK_PROGRESS_STATE_AFTER) {
if (self->last_visible_surface == NULL &&
self->last_visible_child != NULL) {
- g_autoptr (cairo_t) pattern_cr = NULL;
+ cairo_t *pattern_cr;
gtk_widget_get_allocation (self->last_visible_child->widget,
&self->last_visible_surface_allocation);
@@ -749,6 +749,8 @@ hdy_squeezer_draw (GtkWidget *widget,
* bin_window offset.
*/
gtk_widget_draw (self->last_visible_child->widget, pattern_cr);
+
+ cairo_destroy (pattern_cr);
}
cairo_rectangle (cr,
diff --git a/src/hdy-stackable-box.c b/src/hdy-stackable-box.c
index f866cb60..6b1b5826 100644
--- a/src/hdy-stackable-box.c
+++ b/src/hdy-stackable-box.c
@@ -2302,7 +2302,7 @@ void
hdy_stackable_box_remove (HdyStackableBox *self,
GtkWidget *widget)
{
- g_autoptr (HdyStackableBoxChildInfo) child_info = find_child_info_for_widget (self, widget);
+ HdyStackableBoxChildInfo *child_info = find_child_info_for_widget (self, widget);
gboolean contains_child = child_info != NULL;
g_return_if_fail (contains_child);
@@ -2326,6 +2326,8 @@ hdy_stackable_box_remove (HdyStackableBox *self,
unregister_window (self, child_info);
gtk_widget_unparent (widget);
+
+ free_child_info (child_info);
}
void
@@ -2338,7 +2340,7 @@ hdy_stackable_box_forall (HdyStackableBox *self,
* looping through it, for example by calling hdy_stackable_box_remove() on all
* children when destroying the HdyStackableBox_private_offset.
*/
- g_autoptr (GList) children_copy = g_list_copy (self->children);
+ GList *children_copy = g_list_copy (self->children);
GList *children;
HdyStackableBoxChildInfo *child_info;
@@ -2351,6 +2353,8 @@ hdy_stackable_box_forall (HdyStackableBox *self,
g_list_free (self->children_reversed);
self->children_reversed = g_list_copy (self->children);
self->children_reversed = g_list_reverse (self->children_reversed);
+
+ g_list_free (children);
}
static void
diff --git a/src/hdy-style-manager.c b/src/hdy-style-manager.c
index 4dd7e8fd..1aa06970 100644
--- a/src/hdy-style-manager.c
+++ b/src/hdy-style-manager.c
@@ -109,8 +109,8 @@ find_theme_dir (const gchar *dir,
const gchar *name,
const gchar *variant)
{
- g_autofree gchar *file = NULL;
- g_autofree gchar *base = NULL;
+ gchar *file;
+ gchar *base;
gchar *path;
gint i;
@@ -125,7 +125,8 @@ find_theme_dir (const gchar *dir,
base = g_build_filename (dir, name, NULL);
for (i = MINOR; i >= 0; i = i - 2) {
- g_autofree gchar *subsubdir = NULL;
+ gchar *subsubdir;
+ gboolean do_break = FALSE;
if (i < 14)
i = 0;
@@ -134,12 +135,19 @@ find_theme_dir (const gchar *dir,
path = g_build_filename (base, subsubdir, file, NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS))
- break;
+ do_break = TRUE;
+
+ g_free (subsubdir);
- g_free (path);
- path = NULL;
+ if (do_break)
+ break;
+ else
+ g_free (path);
}
+ g_free (base);
+ g_free (file);
+
return path;
}
@@ -149,7 +157,7 @@ static gchar *
find_theme (const gchar *name,
const gchar *variant)
{
- g_autofree gchar *dir = NULL;
+ gchar *dir;
const gchar *const *dirs;
gchar *path;
gint i;
@@ -176,6 +184,8 @@ find_theme (const gchar *name,
dir = get_theme_dir ();
path = find_theme_dir (dir, NULL, name, variant);
+ g_free (dir);
+
return path;
}
@@ -183,8 +193,9 @@ static gboolean
check_theme_exists (const gchar *name,
const gchar *variant)
{
- g_autofree gchar *resource_path = NULL;
- g_autofree gchar *path = NULL;
+ gchar *resource_path;
+ gchar *path = NULL;
+ gboolean result;
/* try loading the resource for the theme. This is mostly meant for built-in
* themes.
@@ -195,25 +206,35 @@ check_theme_exists (const gchar *name,
resource_path = g_strdup_printf ("/org/gtk/libgtk/theme/%s/gtk.css", name);
if (g_resources_get_info (resource_path, 0, NULL, NULL, NULL))
- return TRUE;
+ result = TRUE;
+ else {
+ /* Next try looking for files in the various theme directories. */
+ path = find_theme (name, variant);
+ result = path != NULL;
+ }
- /* Next try looking for files in the various theme directories. */
- path = find_theme (name, variant);
+ g_free (path);
+ g_free (resource_path);
- return path != NULL;
+ return result;
}
static gchar *
get_system_theme_name (void)
{
GdkScreen *screen = gdk_screen_get_default ();
- g_auto (GValue) value = G_VALUE_INIT;
+ GValue value = G_VALUE_INIT;
+ gchar *ret;
g_value_init (&value, G_TYPE_STRING);
if (!gdk_screen_get_setting (screen, "gtk-theme-name", &value))
- return g_strdup ("Adwaita");
+ ret = g_strdup ("Adwaita");
+ else
+ ret = g_value_dup_string (&value);
- return g_value_dup_string (&value);
+ g_value_unset (&value);
+
+ return ret;
}
static void
@@ -319,7 +340,7 @@ update_stylesheet (HdyStyleManager *self)
self->dark ? "HighContrastInverse" : "HighContrast",
NULL);
} else {
- g_autofree gchar *theme_name = get_system_theme_name ();
+ gchar *theme_name = get_system_theme_name ();
gboolean override_theme = FALSE;
if (g_str_has_suffix (theme_name, "-dark")) {
@@ -333,6 +354,8 @@ update_stylesheet (HdyStyleManager *self)
g_object_set (gtk_settings, "gtk-theme-name", theme_name, NULL);
else
gtk_settings_reset_property (gtk_settings, "gtk-theme-name");
+
+ g_free (theme_name);
}
g_signal_handlers_unblock_by_func (gtk_settings,
@@ -654,7 +677,7 @@ static void
hdy_style_manager_ensure (void)
{
GdkDisplayManager *display_manager = gdk_display_manager_get ();
- g_autoptr (GSList) displays = NULL;
+ GSList *displays;
GSList *l;
if (display_style_managers)
@@ -675,6 +698,8 @@ hdy_style_manager_ensure (void)
"display-opened",
G_CALLBACK (register_display),
NULL);
+
+ g_slist_free (displays);
}
/**
diff --git a/src/hdy-swipe-tracker.c b/src/hdy-swipe-tracker.c
index 7224ecd2..88d5027b 100644
--- a/src/hdy-swipe-tracker.c
+++ b/src/hdy-swipe-tracker.c
@@ -201,13 +201,15 @@ get_range (HdySwipeTracker *self,
gdouble *first,
gdouble *last)
{
- g_autofree gdouble *points = NULL;
+ gdouble *points;
gint n;
points = hdy_swipeable_get_snap_points (self->swipeable, &n);
*first = points[0];
*last = points[n - 1];
+
+ g_free (points);
}
static void
@@ -241,7 +243,7 @@ gesture_prepare (HdySwipeTracker *self,
static void
trim_history (HdySwipeTracker *self)
{
- g_autoptr (GdkEvent) event = gtk_get_current_event ();
+ GdkEvent *event = gtk_get_current_event ();
guint32 threshold_time = gdk_event_get_time (event) - EVENT_HISTORY_THRESHOLD_MS;
guint i;
@@ -255,13 +257,15 @@ trim_history (HdySwipeTracker *self)
if (i > 0)
g_array_remove_range (self->event_history, 0, i);
+
+ gdk_event_free (event);
}
static void
append_to_history (HdySwipeTracker *self,
gdouble delta)
{
- g_autoptr (GdkEvent) event = gtk_get_current_event ();
+ GdkEvent *event = gtk_get_current_event ();
EventHistoryRecord record;
trim_history (self);
@@ -270,6 +274,8 @@ append_to_history (HdySwipeTracker *self,
record.time = gdk_event_get_time (event);
g_array_append_val (self->event_history, record);
+
+ gdk_event_free (event);
}
static gdouble
@@ -400,11 +406,13 @@ gesture_update (HdySwipeTracker *self,
return;
if (!self->allow_long_swipes) {
- g_autofree gdouble *points = NULL;
+ gdouble *points;
gint n;
points = hdy_swipeable_get_snap_points (self->swipeable, &n);
get_bounds (self, points, n, self->initial_progress, &lower, &upper);
+
+ g_free (points);
} else {
get_range (self, &lower, &upper);
}
@@ -423,7 +431,7 @@ get_end_progress (HdySwipeTracker *self,
gboolean is_touchpad)
{
gdouble pos, decel, slope;
- g_autofree gdouble *points = NULL;
+ gdouble *points;
gint n;
gdouble lower, upper;
@@ -432,8 +440,13 @@ get_end_progress (HdySwipeTracker *self,
points = hdy_swipeable_get_snap_points (self->swipeable, &n);
- if (ABS (velocity) < (is_touchpad ? VELOCITY_THRESHOLD_TOUCHPAD : VELOCITY_THRESHOLD_TOUCH))
- return points[find_closest_point (points, n, self->progress)];
+ 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;
@@ -461,6 +474,8 @@ get_end_progress (HdySwipeTracker *self,
pos = CLAMP (pos, lower, upper);
pos = points[find_point_for_projection (self, points, n, pos, velocity)];
+ g_free (points);
+
return pos;
}
diff --git a/src/hdy-tab-view.c b/src/hdy-tab-view.c
index c8999498..dfcabf2f 100644
--- a/src/hdy-tab-view.c
+++ b/src/hdy-tab-view.c
@@ -774,7 +774,7 @@ insert_page (HdyTabView *self,
gint position,
gboolean pinned)
{
- g_autoptr (HdyTabPage) page =
+ HdyTabPage *page =
g_object_new (HDY_TYPE_TAB_PAGE,
"child", child,
"parent", parent,
@@ -787,6 +787,8 @@ insert_page (HdyTabView *self,
if (!self->selected_page)
hdy_tab_view_set_selected_page (self, page);
+ g_object_unref (page);
+
return page;
}
@@ -2389,7 +2391,7 @@ HdyTabPage *
hdy_tab_view_get_nth_page (HdyTabView *self,
gint position)
{
- g_autoptr (HdyTabPage) page = NULL;
+ HdyTabPage *page;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), NULL);
g_return_val_if_fail (position >= 0, NULL);
@@ -2397,6 +2399,8 @@ hdy_tab_view_get_nth_page (HdyTabView *self,
page = g_list_model_get_item (G_LIST_MODEL (self->pages), (guint) position);
+ g_object_unref (page);
+
return page;
}
diff --git a/src/hdy-value-object.c b/src/hdy-value-object.c
index d1a7dbc7..643fd3f8 100644
--- a/src/hdy-value-object.c
+++ b/src/hdy-value-object.c
@@ -72,9 +72,10 @@ hdy_value_object_new (const GValue *value)
HdyValueObject*
hdy_value_object_new_collect (GType type, ...)
{
- g_auto(GValue) value = G_VALUE_INIT;
- g_autofree gchar *error = NULL;
+ GValue value = G_VALUE_INIT;
+ gchar *error = NULL;
va_list var_args;
+ HdyValueObject *ret;
va_start (var_args, type);
@@ -85,9 +86,14 @@ hdy_value_object_new_collect (GType type, ...)
if (error)
g_critical ("%s: %s", G_STRFUNC, error);
- return g_object_new (HDY_TYPE_VALUE_OBJECT,
- "value", &value,
- NULL);
+ ret = g_object_new (HDY_TYPE_VALUE_OBJECT,
+ "value", &value,
+ NULL);
+
+ g_value_unset (&value);
+ g_free (error);
+
+ return ret;
}
/**
@@ -106,11 +112,16 @@ hdy_value_object_new_collect (GType type, ...)
HdyValueObject*
hdy_value_object_new_string (const gchar *string)
{
- g_auto(GValue) value = G_VALUE_INIT;
+ GValue value = G_VALUE_INIT;
+ HdyValueObject *ret;
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, string);
- return hdy_value_object_new (&value);
+ ret = hdy_value_object_new (&value);
+
+ g_value_unset (&value);
+
+ return ret;
}
/**
@@ -129,11 +140,16 @@ hdy_value_object_new_string (const gchar *string)
HdyValueObject*
hdy_value_object_new_take_string (gchar *string)
{
- g_auto(GValue) value = G_VALUE_INIT;
+ GValue value = G_VALUE_INIT;
+ HdyValueObject *ret;
g_value_init (&value, G_TYPE_STRING);
g_value_take_string (&value, string);
- return hdy_value_object_new (&value);
+ ret = hdy_value_object_new (&value);
+
+ g_value_unset (&value);
+
+ return ret;
}
static void
diff --git a/src/hdy-view-switcher.c b/src/hdy-view-switcher.c
index e0525b0c..61e5872f 100644
--- a/src/hdy-view-switcher.c
+++ b/src/hdy-view-switcher.c
@@ -97,8 +97,8 @@ update_button (HdyViewSwitcher *self,
GtkWidget *widget,
HdyViewSwitcherButton *button)
{
- g_autofree gchar *title = NULL;
- g_autofree gchar *icon_name = NULL;
+ gchar *title = NULL;
+ gchar *icon_name = NULL;
gboolean needs_attention;
gtk_container_child_get (GTK_CONTAINER (self->stack), widget,
@@ -116,6 +116,9 @@ update_button (HdyViewSwitcher *self,
gtk_widget_set_visible (GTK_WIDGET (button),
gtk_widget_get_visible (widget) && (title != NULL || icon_name != NULL));
+
+ g_free (icon_name);
+ g_free (title);
}
static void
@@ -226,7 +229,7 @@ static void
add_button_for_stack_child (HdyViewSwitcher *self,
GtkWidget *stack_child)
{
- g_autoptr (GList) children = gtk_container_get_children (GTK_CONTAINER (self->box));
+ GList *children = gtk_container_get_children (GTK_CONTAINER (self->box));
HdyViewSwitcherButton *button = HDY_VIEW_SWITCHER_BUTTON (hdy_view_switcher_button_new ());
g_object_set_data (G_OBJECT (button), "stack-child", stack_child);
@@ -247,6 +250,8 @@ add_button_for_stack_child (HdyViewSwitcher *self,
g_signal_connect (stack_child, "child-notify::position", G_CALLBACK (on_position_updated), self);
g_hash_table_insert (self->buttons, stack_child, button);
+
+ g_list_free (children);
}
static void
@@ -394,7 +399,7 @@ hdy_view_switcher_get_preferred_width (GtkWidget *widget,
gint *nat)
{
HdyViewSwitcher *self = HDY_VIEW_SWITCHER (widget);
- g_autoptr (GList) children = gtk_container_get_children (GTK_CONTAINER (self->box));
+ GList *children = gtk_container_get_children (GTK_CONTAINER (self->box));
gint max_h_min = 0, max_h_nat = 0, max_v_min = 0, max_v_nat = 0;
gint n_children = 0;
@@ -436,13 +441,15 @@ hdy_view_switcher_get_preferred_width (GtkWidget *widget,
}
hdy_css_measure (widget, GTK_ORIENTATION_HORIZONTAL, min, nat);
+
+ g_list_free (children);
}
static gint
is_narrow (HdyViewSwitcher *self,
gint width)
{
- g_autoptr (GList) children = gtk_container_get_children (GTK_CONTAINER (self->box));
+ GList *children;
gint max_h_min = 0;
gint n_children = 0;
@@ -452,6 +459,7 @@ is_narrow (HdyViewSwitcher *self,
if (self->policy == HDY_VIEW_SWITCHER_POLICY_WIDE)
return FALSE;
+ children = gtk_container_get_children (GTK_CONTAINER (self->box));
for (GList *l = children; l != NULL; l = g_list_next (l)) {
gint h_min = 0;
@@ -464,6 +472,7 @@ is_narrow (HdyViewSwitcher *self,
n_children++;
}
+ g_list_free (children);
return (max_h_min * n_children) > width;
}
@@ -473,7 +482,7 @@ hdy_view_switcher_size_allocate (GtkWidget *widget,
{
HdyViewSwitcher *self = HDY_VIEW_SWITCHER (widget);
- g_autoptr (GList) children = gtk_container_get_children (GTK_CONTAINER (self->box));
+ GList *children = gtk_container_get_children (GTK_CONTAINER (self->box));
GtkOrientation orientation;
hdy_css_size_allocate (widget, allocation);
@@ -486,6 +495,8 @@ hdy_view_switcher_size_allocate (GtkWidget *widget,
gtk_orientable_set_orientation (GTK_ORIENTABLE (l->data), orientation);
GTK_WIDGET_CLASS (hdy_view_switcher_parent_class)->size_allocate (widget, allocation);
+
+ g_list_free (children);
}
static void
diff --git a/src/hdy-window-handle-controller.c b/src/hdy-window-handle-controller.c
index 49d9e06a..8d82bb61 100644
--- a/src/hdy-window-handle-controller.c
+++ b/src/hdy-window-handle-controller.c
@@ -322,8 +322,9 @@ titlebar_action (HdyWindowHandleController *self,
guint button)
{
GtkSettings *settings;
- g_autofree gchar *action = NULL;
+ gchar *action;
GtkWindow *window = get_window (self);
+ gboolean result;
if (!window)
return FALSE;
@@ -350,10 +351,9 @@ titlebar_action (HdyWindowHandleController *self,
if (action == NULL)
return FALSE;
- if (g_str_equal (action, "none"))
- return FALSE;
-
- if (g_str_has_prefix (action, "toggle-maximize")) {
+ if (g_str_equal (action, "none")) {
+ result = FALSE;
+ } else if (g_str_has_prefix (action, "toggle-maximize")) {
/*
* gtk header bar won't show the maximize button if the following
* properties are not met, apply the same to title bar actions for
@@ -363,30 +363,28 @@ titlebar_action (HdyWindowHandleController *self,
gtk_window_get_type_hint (window) == GDK_WINDOW_TYPE_HINT_NORMAL)
hdy_gtk_window_toggle_maximized (window);
- return TRUE;
- }
-
- if (g_str_equal (action, "lower")) {
+ result = TRUE;
+ } else if (g_str_equal (action, "lower")) {
gdk_window_lower (gtk_widget_get_window (GTK_WIDGET (window)));
- return TRUE;
- }
-
- if (g_str_equal (action, "minimize")) {
+ result = TRUE;
+ } else if (g_str_equal (action, "minimize")) {
gdk_window_iconify (gtk_widget_get_window (GTK_WIDGET (window)));
- return TRUE;
- }
-
- if (g_str_equal (action, "menu")) {
+ result = TRUE;
+ } else if (g_str_equal (action, "menu")) {
do_popup (self, (GdkEventButton*) event);
- return TRUE;
+ result = TRUE;
+ } else {
+ g_warning ("Unsupported titlebar action %s", action);
+
+ result = FALSE;
}
- g_warning ("Unsupported titlebar action %s", action);
+ g_free (action);
- return FALSE;
+ return result;
}
static void
diff --git a/src/hdy-window-mixin.c b/src/hdy-window-mixin.c
index 4bade07c..bd3320e9 100644
--- a/src/hdy-window-mixin.c
+++ b/src/hdy-window-mixin.c
@@ -77,7 +77,7 @@ update_child_context (HdyWindowMixin *self,
GtkStyleContext *context,
const gchar *name)
{
- g_autoptr (GtkWidgetPath) path = gtk_widget_path_new ();
+ GtkWidgetPath *path = gtk_widget_path_new ();
GtkStyleContext *parent = gtk_widget_get_style_context (GTK_WIDGET (self->window));
gint position;
@@ -87,6 +87,8 @@ update_child_context (HdyWindowMixin *self,
gtk_style_context_set_path (context, path);
gtk_style_context_set_state (context, gtk_style_context_get_state (parent));
+
+ gtk_widget_path_unref (path);
}
static void
@@ -214,7 +216,7 @@ create_masks (HdyWindowMixin *self,
return;
for (i = 0; i < HDY_N_CORNERS; i++) {
- g_autoptr (cairo_t) mask_cr = NULL;
+ cairo_t *mask_cr;
self->masks[i] =
cairo_surface_create_similar_image (cairo_get_target (cr),
@@ -232,6 +234,8 @@ create_masks (HdyWindowMixin *self,
r,
0, G_PI * 2);
cairo_fill (mask_cr);
+
+ cairo_destroy (mask_cr);
}
}
@@ -347,8 +351,8 @@ hdy_window_mixin_draw (HdyWindowMixin *self,
GdkRectangle clip = { 0 };
gint width, height, x, y, w, h, r, scale_factor;
GtkWidget *titlebar;
- g_autoptr (cairo_surface_t) surface = NULL;
- g_autoptr (cairo_t) surface_cr = NULL;
+ cairo_surface_t *surface;
+ cairo_t *surface_cr;
GtkBorder shadow;
/* Use the parent drawing unless we have a reason to use masking */
@@ -452,9 +456,15 @@ hdy_window_mixin_draw (HdyWindowMixin *self,
HDY_CORNER_BOTTOM_RIGHT, x + w - r, y + h - r);
cairo_surface_flush (surface);
+
}
cairo_restore (cr);
+
+ cairo_destroy (surface_cr);
+
+ if (should_mask_corners)
+ cairo_surface_destroy (surface);
}
data.self = self;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]