[libhandy/tabs: 22/62] Destroy tab contents




commit 757ddb001eb6bde34a5e434d941e1224b74cabce
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Sep 6 16:27:31 2020 +0500

    Destroy tab contents

 src/hdy-tab-box.c |  6 +++---
 src/hdy-tab.c     | 11 +++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/hdy-tab-box.c b/src/hdy-tab-box.c
index 9c41241c..69f8e524 100644
--- a/src/hdy-tab-box.c
+++ b/src/hdy-tab-box.c
@@ -1911,6 +1911,9 @@ create_drag_icon (HdyTabBox      *self,
   icon->window = gtk_window_new (GTK_WINDOW_POPUP);
   icon->context = context;
 
+  gtk_window_set_screen (GTK_WINDOW (icon->window),
+                         gtk_widget_get_screen (GTK_WIDGET (self)));
+
   icon->width = predict_tab_width (self, self->reordered_tab, FALSE);
   icon->target_width = icon->width;
 
@@ -1937,9 +1940,6 @@ create_drag_icon (HdyTabBox      *self,
                                icon->width + icon->tab_margin.left + icon->tab_margin.right,
                                -1);
 
-  gtk_window_set_screen (GTK_WINDOW (icon->window),
-                         gtk_widget_get_screen (GTK_WIDGET (self)));
-
   icon->hotspot_x = (gint) self->drag_offset_x;
   icon->hotspot_y = (gint) self->drag_offset_y;
 
diff --git a/src/hdy-tab.c b/src/hdy-tab.c
index 93e43f79..eb482d98 100644
--- a/src/hdy-tab.c
+++ b/src/hdy-tab.c
@@ -202,6 +202,16 @@ secondary_icon_clicked_cb (HdyTab *self)
   g_signal_emit_by_name (self->view, "secondary-icon-activated", self->page);
 }
 
+static void
+hdy_tab_destroy (GtkWidget *widget)
+{
+  HdyTab *self = HDY_TAB (widget);
+
+  g_clear_pointer (&self->child, gtk_widget_unparent);
+
+  GTK_WIDGET_CLASS (hdy_tab_parent_class)->destroy (widget);
+}
+
 static void
 hdy_tab_measure (GtkWidget      *widget,
                  GtkOrientation  orientation,
@@ -570,6 +580,7 @@ hdy_tab_class_init (HdyTabClass *klass)
   object_class->get_property = hdy_tab_get_property;
   object_class->set_property = hdy_tab_set_property;
 
+  widget_class->destroy = hdy_tab_destroy;
   widget_class->get_preferred_width = hdy_tab_get_preferred_width;
   widget_class->get_preferred_height = hdy_tab_get_preferred_height;
   widget_class->get_preferred_width_for_height = hdy_tab_get_preferred_width_for_height;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]