[gnome-builder/wip/chergert/project-list-view: 3/4] libide/gtk: cleanup clearing of list row on expander
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/project-list-view: 3/4] libide/gtk: cleanup clearing of list row on expander
- Date: Tue, 20 Sep 2022 10:23:04 +0000 (UTC)
commit eb35a5679581eeebfeaf2e75f3e340a9f994b31f
Author: Christian Hergert <chergert redhat com>
Date: Tue Sep 20 03:20:31 2022 -0700
libide/gtk: cleanup clearing of list row on expander
src/libide/gtk/ide-tree-expander.c | 69 +++++++++++++++++++++++++++-----------
1 file changed, 49 insertions(+), 20 deletions(-)
---
diff --git a/src/libide/gtk/ide-tree-expander.c b/src/libide/gtk/ide-tree-expander.c
index cac2f5588..f4a8c0e82 100644
--- a/src/libide/gtk/ide-tree-expander.c
+++ b/src/libide/gtk/ide-tree-expander.c
@@ -647,6 +647,34 @@ ide_tree_expander_get_list_row (IdeTreeExpander *self)
return self->list_row;
}
+static void
+ide_tree_expander_clear_list_row (IdeTreeExpander *self)
+{
+ GtkWidget *child;
+
+ g_assert (IDE_IS_TREE_EXPANDER (self));
+
+ if (self->list_row == NULL)
+ return;
+
+ g_clear_signal_handler (&self->list_row_notify_depth, self->list_row);
+ g_clear_signal_handler (&self->list_row_notify_expanded, self->list_row);
+
+ g_clear_object (&self->list_row);
+
+ gtk_label_set_label (GTK_LABEL (self->title), NULL);
+ gtk_image_set_from_icon_name (GTK_IMAGE (self->image), NULL);
+
+ child = gtk_widget_get_prev_sibling (self->image);
+
+ while (child)
+ {
+ GtkWidget *prev = gtk_widget_get_prev_sibling (child);
+ gtk_widget_unparent (child);
+ child = prev;
+ }
+}
+
void
ide_tree_expander_set_list_row (IdeTreeExpander *self,
GtkTreeListRow *list_row)
@@ -657,31 +685,32 @@ ide_tree_expander_set_list_row (IdeTreeExpander *self,
if (self->list_row == list_row)
return;
- if (self->list_row != NULL)
- {
- g_clear_signal_handler (&self->list_row_notify_depth, self->list_row);
- g_clear_signal_handler (&self->list_row_notify_expanded, self->list_row);
- }
+ g_object_freeze_notify (G_OBJECT (self));
- g_set_object (&self->list_row, list_row);
+ ide_tree_expander_clear_list_row (self);
- if (self->list_row != NULL)
+ if (list_row != NULL)
{
- self->list_row_notify_expanded = g_signal_connect_object (self->list_row,
- "notify::expanded",
- G_CALLBACK
(ide_tree_expander_notify_expanded_cb),
- self,
- G_CONNECT_SWAPPED);
- self->list_row_notify_depth = g_signal_connect_object (self->list_row,
- "notify::depth",
- G_CALLBACK (ide_tree_expander_notify_depth_cb),
- self,
- G_CONNECT_SWAPPED);
+ self->list_row = g_object_ref (list_row);
+ self->list_row_notify_expanded =
+ g_signal_connect_object (self->list_row,
+ "notify::expanded",
+ G_CALLBACK (ide_tree_expander_notify_expanded_cb),
+ self,
+ G_CONNECT_SWAPPED);
+ self->list_row_notify_depth =
+ g_signal_connect_object (self->list_row,
+ "notify::depth",
+ G_CALLBACK (ide_tree_expander_notify_depth_cb),
+ self,
+ G_CONNECT_SWAPPED);
+ ide_tree_expander_update_depth (self);
+ ide_tree_expander_update_icon (self);
}
- ide_tree_expander_update_depth (self);
- ide_tree_expander_update_icon (self);
-
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LIST_ROW]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ITEM]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_EXPANDED]);
+
+ g_object_thaw_notify (G_OBJECT (self));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]