summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-05-09 10:33:02 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-05-11 12:20:59 -0400
commit025375ff5f244bbf22b9bd932148dfefc3dce82d (patch)
tree0516525f4463778f4c7577d63da6cda2af64486c /gtk
parentcd0081d08ab9abccc3bddc8b597413d17f2af709 (diff)
downloadgtk+-025375ff5f244bbf22b9bd932148dfefc3dce82d.tar.gz
Replace gtk_widget_destroy everywhere
Replace all remaining uses of gtk_widget_destroy by gtk_container_remove or g_object_unref.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkcontainer.c9
-rw-r--r--gtk/gtkemojicompletion.c8
-rw-r--r--gtk/gtkfilechoosernativeportal.c4
-rw-r--r--gtk/gtkfilechooserwidget.c4
-rw-r--r--gtk/gtkflowbox.c6
-rw-r--r--gtk/gtkfontchooserwidget.c9
-rw-r--r--gtk/gtkmain.c4
-rw-r--r--gtk/gtknotebook.c6
-rw-r--r--gtk/gtkplacesview.c13
-rw-r--r--gtk/gtkprinteroptionwidget.c40
-rw-r--r--gtk/gtkprintoperation-win32.c4
-rw-r--r--gtk/gtkprintunixdialog.c46
-rw-r--r--gtk/gtkshortcutsgroup.c10
-rw-r--r--gtk/gtkshortcutssection.c18
-rw-r--r--gtk/gtkshow.c2
-rw-r--r--gtk/gtksidebarrow.c7
-rw-r--r--gtk/gtktext.c6
-rw-r--r--gtk/gtktextchild.c2
-rw-r--r--gtk/gtktextview.c9
-rw-r--r--gtk/gtktreepopover.c10
-rw-r--r--gtk/gtktreeview.c2
-rw-r--r--gtk/gtkwindow.c3
-rw-r--r--gtk/gtkwindowhandle.c4
-rw-r--r--gtk/inspector/actions.c4
-rw-r--r--gtk/inspector/css-node-tree.c2
-rw-r--r--gtk/inspector/general.c4
-rw-r--r--gtk/inspector/misc-info.c5
-rw-r--r--gtk/inspector/prop-list.c4
-rw-r--r--gtk/inspector/recorder.c2
-rw-r--r--gtk/inspector/strv-editor.c13
30 files changed, 108 insertions, 152 deletions
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index f9aaae6df4..94c201a043 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -221,11 +221,18 @@ gtk_container_init (GtkContainer *container)
}
static void
+gtk_container_remove_cb (GtkWidget *child,
+ GtkContainer *container)
+{
+ gtk_container_remove (container, child);
+}
+
+static void
gtk_container_dispose (GObject *object)
{
GtkContainer *container = GTK_CONTAINER (object);
- gtk_container_foreach (container, (GtkCallback) gtk_widget_destroy, NULL);
+ gtk_container_foreach (container, (GtkCallback) gtk_container_remove_cb, container);
G_OBJECT_CLASS (gtk_container_parent_class)->dispose (object);
}
diff --git a/gtk/gtkemojicompletion.c b/gtk/gtkemojicompletion.c
index 810d6c1729..9f5fe235c6 100644
--- a/gtk/gtkemojicompletion.c
+++ b/gtk/gtkemojicompletion.c
@@ -548,7 +548,7 @@ populate_completion (GtkEmojiCompletion *completion,
const char *text,
guint offset)
{
- GList *children, *l;
+ GtkWidget *child;
guint n_matches;
guint n_added;
GVariantIter iter;
@@ -562,10 +562,8 @@ populate_completion (GtkEmojiCompletion *completion,
}
completion->offset = offset;
- children = gtk_container_get_children (GTK_CONTAINER (completion->list));
- for (l = children; l; l = l->next)
- gtk_widget_destroy (GTK_WIDGET (l->data));
- g_list_free (children);
+ while ((child = gtk_widget_get_first_child (completion->list)))
+ gtk_container_remove (GTK_CONTAINER (completion->list), child);
completion->active = NULL;
diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c
index 8d58dc253d..f87a974c89 100644
--- a/gtk/gtkfilechoosernativeportal.c
+++ b/gtk/gtkfilechoosernativeportal.c
@@ -75,7 +75,7 @@ filechooser_portal_data_free (FilechooserPortalData *data)
if (data->grab_widget)
{
gtk_grab_remove (data->grab_widget);
- gtk_widget_destroy (data->grab_widget);
+ g_object_unref (data->grab_widget);
}
g_clear_object (&data->self);
@@ -397,7 +397,7 @@ window_handle_exported (GtkWindow *window,
if (data->modal)
{
- data->grab_widget = gtk_label_new ("");
+ data->grab_widget = g_object_ref_sink (gtk_label_new (""));
gtk_grab_add (GTK_WIDGET (data->grab_widget));
}
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 0a694d5d18..4c61e180f8 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -2360,7 +2360,7 @@ save_widgets_destroy (GtkFileChooserWidget *impl)
if (impl->save_widgets == NULL)
return;
- gtk_widget_destroy (impl->save_widgets);
+ gtk_container_remove (GTK_CONTAINER (impl->box), impl->save_widgets);
impl->save_widgets = NULL;
impl->save_widgets_table = NULL;
impl->location_entry = NULL;
@@ -3091,7 +3091,7 @@ gtk_file_chooser_widget_dispose (GObject *object)
cancel_all_operations (impl);
g_clear_pointer (&impl->rename_file_popover, gtk_widget_unparent);
- g_clear_pointer (&impl->browse_files_popover, gtk_widget_destroy);
+ g_clear_pointer (&impl->browse_files_popover, gtk_widget_unparent);
g_clear_object (&impl->extra_widget);
g_clear_pointer (&impl->bookmarks_manager, _gtk_bookmarks_manager_free);
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index 8f331734ca..36d534f459 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -3911,7 +3911,7 @@ gtk_flow_box_bound_model_changed (GListModel *list,
GtkFlowBoxChild *child;
child = gtk_flow_box_get_child_at_index (box, position);
- gtk_widget_destroy (GTK_WIDGET (child));
+ gtk_container_remove (GTK_CONTAINER (box), GTK_WIDGET (child));
}
for (i = 0; i < added; i++)
@@ -4196,6 +4196,7 @@ gtk_flow_box_bind_model (GtkFlowBox *box,
GDestroyNotify user_data_free_func)
{
GtkFlowBoxPrivate *priv = BOX_PRIV (box);
+ GtkWidget *child;
g_return_if_fail (GTK_IS_FLOW_BOX (box));
g_return_if_fail (model == NULL || G_IS_LIST_MODEL (model));
@@ -4210,7 +4211,8 @@ gtk_flow_box_bind_model (GtkFlowBox *box,
g_clear_object (&priv->bound_model);
}
- gtk_flow_box_forall (GTK_CONTAINER (box), (GtkCallback) gtk_widget_destroy, NULL);
+ while ((child = gtk_widget_get_first_child (GTK_WIDGET (box))))
+ gtk_container_remove (GTK_CONTAINER (box), child);
if (model == NULL)
return;
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index 5956b2bbd1..ab0a890671 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -836,11 +836,12 @@ axis_remove (gpointer key,
gpointer value,
gpointer data)
{
+ GtkFontChooserWidget *fontchooser = data;
Axis *a = value;
- gtk_widget_destroy (a->label);
- gtk_widget_destroy (a->scale);
- gtk_widget_destroy (a->spin);
+ gtk_container_remove (GTK_CONTAINER (fontchooser->axis_grid), a->label);
+ gtk_container_remove (GTK_CONTAINER (fontchooser->axis_grid), a->scale);
+ gtk_container_remove (GTK_CONTAINER (fontchooser->axis_grid), a->spin);
}
static void
@@ -1606,7 +1607,7 @@ gtk_font_chooser_widget_update_font_variations (GtkFontChooserWidget *fontchoose
if (fontchooser->updating_variations)
return FALSE;
- g_hash_table_foreach (fontchooser->axes, axis_remove, NULL);
+ g_hash_table_foreach (fontchooser->axes, axis_remove, fontchooser);
g_hash_table_remove_all (fontchooser->axes);
if ((fontchooser->level & GTK_FONT_CHOOSER_LEVEL_VARIATIONS) == 0)
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 518f3aefbf..ffc3aebfd1 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1716,9 +1716,9 @@ gtk_main_do_event (GdkEvent *event)
if (!gtk_window_group_get_current_grab (window_group) ||
GTK_WIDGET (gtk_widget_get_root (gtk_window_group_get_current_grab (window_group))) == target_widget)
{
- if (!GTK_IS_WINDOW (target_widget) ||
+ if (GTK_IS_WINDOW (target_widget) &&
!gtk_window_emit_close_request (GTK_WINDOW (target_widget)))
- gtk_widget_destroy (target_widget);
+ gtk_window_destroy (GTK_WINDOW (target_widget));
}
g_object_unref (target_widget);
break;
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 0b9ba6e6f2..eb5ac27d7d 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -4229,7 +4229,7 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
g_object_ref (tab_label);
gtk_notebook_remove_tab_label (notebook, page);
if (destroying)
- gtk_widget_destroy (tab_label);
+ gtk_widget_unparent (tab_label);
g_object_unref (tab_label);
}
@@ -6100,7 +6100,7 @@ gtk_notebook_set_show_tabs (GtkNotebook *notebook,
children = children->next;
if (page->default_tab)
{
- gtk_widget_destroy (page->tab_label);
+ gtk_widget_unparent (page->tab_label);
page->tab_label = NULL;
}
else
@@ -6391,7 +6391,7 @@ gtk_notebook_popup_disable (GtkNotebook *notebook)
gtk_container_foreach (GTK_CONTAINER (notebook->menu_box),
(GtkCallback) gtk_notebook_menu_label_unparent, NULL);
- gtk_widget_destroy (notebook->menu);
+
notebook->menu = NULL;
notebook->menu_box = NULL;
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index 8522372a43..6ea06f65bb 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -526,7 +526,7 @@ static void
populate_servers (GtkPlacesView *view)
{
GBookmarkFile *server_list;
- GList *children;
+ GtkWidget *child;
gchar **uris;
gsize num_uris;
gint i;
@@ -548,8 +548,8 @@ populate_servers (GtkPlacesView *view)
}
/* clear previous items */
- children = gtk_container_get_children (GTK_CONTAINER (view->recent_servers_listbox));
- g_list_free_full (children, (GDestroyNotify) gtk_widget_destroy);
+ while ((child = gtk_widget_get_first_child (view->recent_servers_listbox)))
+ gtk_container_remove (GTK_CONTAINER (view->recent_servers_listbox), child);
gtk_list_store_clear (view->completion_store);
@@ -1084,17 +1084,18 @@ fetch_networks (GtkPlacesView *view)
static void
update_places (GtkPlacesView *view)
{
- GList *children;
GList *mounts;
GList *volumes;
GList *drives;
GList *l;
GIcon *icon;
GFile *file;
+ GtkWidget *child;
/* Clear all previously added items */
- children = gtk_container_get_children (GTK_CONTAINER (view->listbox));
- g_list_free_full (children, (GDestroyNotify) gtk_widget_destroy);
+ while ((child = gtk_widget_get_first_child (view->listbox)))
+ gtk_container_remove (GTK_CONTAINER (view->listbox), child);
+
view->network_placeholder = NULL;
/* Inform clients that we started loading */
gtk_places_view_set_loading (view, TRUE);
diff --git a/gtk/gtkprinteroptionwidget.c b/gtk/gtkprinteroptionwidget.c
index d8819cb6d5..694fec9e48 100644
--- a/gtk/gtkprinteroptionwidget.c
+++ b/gtk/gtkprinteroptionwidget.c
@@ -430,40 +430,12 @@ deconstruct_widgets (GtkPrinterOptionWidget *widget)
{
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
- if (priv->check)
- {
- gtk_widget_destroy (priv->check);
- priv->check = NULL;
- }
-
- if (priv->combo)
- {
- gtk_widget_destroy (priv->combo);
- priv->combo = NULL;
- }
-
- if (priv->entry)
- {
- gtk_widget_destroy (priv->entry);
- priv->entry = NULL;
- }
-
- if (priv->image)
- {
- gtk_widget_destroy (priv->image);
- priv->image = NULL;
- }
-
- if (priv->label)
- {
- gtk_widget_destroy (priv->label);
- priv->label = NULL;
- }
- if (priv->info_label)
- {
- gtk_widget_destroy (priv->info_label);
- priv->info_label = NULL;
- }
+ g_clear_pointer (&priv->check, gtk_widget_unparent);
+ g_clear_pointer (&priv->combo, gtk_widget_unparent);
+ g_clear_pointer (&priv->entry, gtk_widget_unparent);
+ g_clear_pointer (&priv->image, gtk_widget_unparent);
+ g_clear_pointer (&priv->label, gtk_widget_unparent);
+ g_clear_pointer (&priv->info_label, gtk_widget_unparent);
}
static void
diff --git a/gtk/gtkprintoperation-win32.c b/gtk/gtkprintoperation-win32.c
index 56abcbaf25..009dffcde4 100644
--- a/gtk/gtkprintoperation-win32.c
+++ b/gtk/gtkprintoperation-win32.c
@@ -1440,7 +1440,7 @@ pageDlgProc (HWND wnd, UINT message, WPARAM wparam, LPARAM lparam)
op_win32 = op->priv->platform_data;
g_signal_emit_by_name (op, "custom-widget-apply", op->priv->custom_widget);
- gtk_widget_destroy (op_win32->embed_widget);
+ g_object_unref (g_object_ref_sink (op_win32->embed_widget));
op_win32->embed_widget = NULL;
op->priv->custom_widget = NULL;
}
@@ -1961,7 +1961,7 @@ gtk_print_operation_run_with_dialog (GtkPrintOperation *op,
GlobalFree (printdlgex);
if (invisible)
- gtk_widget_destroy (invisible);
+ gtk_window_destroy (GTK_WINDOW (invisible));
return result;
}
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index bb5df78053..a4a6db0559 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -1624,16 +1624,14 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog)
nrows = grid_rows (GTK_GRID (table));
if (nrows == 0)
- gtk_widget_destroy (table);
+ {
+ g_object_unref (g_object_ref_sink (table));
+ }
else
{
has_advanced = TRUE;
frame = wrap_in_frame (group, table);
- gtk_widget_show (table);
- gtk_widget_show (frame);
-
- gtk_container_add (GTK_CONTAINER (dialog->advanced_vbox),
- frame);
+ gtk_container_add (GTK_CONTAINER (dialog->advanced_vbox), frame);
}
}
@@ -1941,35 +1939,23 @@ options_changed_cb (GtkPrintUnixDialog *dialog)
}
static void
-remove_custom_widget (GtkWidget *widget,
- GtkContainer *container)
-{
- gtk_container_remove (container, widget);
-}
-
-static void
-extension_point_clear_children (GtkContainer *container)
-{
- gtk_container_foreach (container,
- (GtkCallback)remove_custom_widget,
- container);
-}
-
-static void
clear_per_printer_ui (GtkPrintUnixDialog *dialog)
{
+ GtkWidget *child;
+
if (dialog->finishing_table == NULL)
return;
- gtk_container_foreach (GTK_CONTAINER (dialog->finishing_table),
- (GtkCallback)gtk_widget_destroy, NULL);
- gtk_container_foreach (GTK_CONTAINER (dialog->image_quality_table),
- (GtkCallback)gtk_widget_destroy, NULL);
- gtk_container_foreach (GTK_CONTAINER (dialog->color_table),
- (GtkCallback)gtk_widget_destroy, NULL);
- gtk_container_foreach (GTK_CONTAINER (dialog->advanced_vbox),
- (GtkCallback)gtk_widget_destroy, NULL);
- extension_point_clear_children (GTK_CONTAINER (dialog->extension_point));
+ while ((child = gtk_widget_get_first_child (dialog->finishing_table)))
+ gtk_container_remove (GTK_CONTAINER (dialog->finishing_table), child);
+ while ((child = gtk_widget_get_first_child (dialog->image_quality_table)))
+ gtk_container_remove (GTK_CONTAINER (dialog->image_quality_table), child);
+ while ((child = gtk_widget_get_first_child (dialog->color_table)))
+ gtk_container_remove (GTK_CONTAINER (dialog->color_table), child);
+ while ((child = gtk_widget_get_first_child (dialog->advanced_vbox)))
+ gtk_container_remove (GTK_CONTAINER (dialog->advanced_vbox), child);
+ while ((child = gtk_widget_get_first_child (dialog->extension_point)))
+ gtk_container_remove (GTK_CONTAINER (dialog->extension_point), child);
}
static void
diff --git a/gtk/gtkshortcutsgroup.c b/gtk/gtkshortcutsgroup.c
index 60fa41048f..a44a37d84d 100644
--- a/gtk/gtkshortcutsgroup.c
+++ b/gtk/gtkshortcutsgroup.c
@@ -268,15 +268,7 @@ gtk_shortcuts_group_dispose (GObject *object)
{
GtkShortcutsGroup *self = GTK_SHORTCUTS_GROUP (object);
- /*
- * Since we overload forall(), the inherited destroy() won't work as normal.
- * Remove internal widgets ourself.
- */
- if (self->title)
- {
- gtk_widget_destroy (GTK_WIDGET (self->title));
- self->title = NULL;
- }
+ g_clear_pointer ((GtkWidget **)&self->title, gtk_widget_unparent);
G_OBJECT_CLASS (gtk_shortcuts_group_parent_class)->dispose (object);
}
diff --git a/gtk/gtkshortcutssection.c b/gtk/gtkshortcutssection.c
index 4df299fe1f..69eefce89a 100644
--- a/gtk/gtkshortcutssection.c
+++ b/gtk/gtkshortcutssection.c
@@ -200,17 +200,8 @@ gtk_shortcuts_section_dispose (GObject *object)
{
GtkShortcutsSection *self = GTK_SHORTCUTS_SECTION (object);
- if (self->stack)
- {
- gtk_widget_destroy (GTK_WIDGET (self->stack));
- self->stack = NULL;
- }
-
- if (self->footer)
- {
- gtk_widget_destroy (GTK_WIDGET (self->footer));
- self->footer = NULL;
- }
+ g_clear_pointer ((GtkWidget **)&self->stack, gtk_widget_unparent);
+ g_clear_pointer (&self->footer, gtk_widget_unparent);
g_list_free (self->groups);
self->groups = NULL;
@@ -573,6 +564,7 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self)
guint n_columns;
guint n_pages;
GtkWidget *current_page, *current_column;
+ GtkWidget *child;
/* collect all groups from the current pages */
groups = NULL;
@@ -712,8 +704,8 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self)
}
/* replace the current pages with the new pages */
- children = gtk_container_get_children (GTK_CONTAINER (self->stack));
- g_list_free_full (children, (GDestroyNotify)gtk_widget_destroy);
+ while ((child = gtk_widget_get_first_child (GTK_WIDGET (self->stack))))
+ gtk_container_remove (GTK_CONTAINER (self->stack), child);
for (p = pages, n_pages = 0; p; p = p->next, n_pages++)
{
diff --git a/gtk/gtkshow.c b/gtk/gtkshow.c
index f688f79ad2..5ce7994bf9 100644
--- a/gtk/gtkshow.c
+++ b/gtk/gtkshow.c
@@ -187,7 +187,7 @@ show_uri_done (GObject *object,
"%s", error->message);
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_window_present (GTK_WINDOW (dialog));
diff --git a/gtk/gtksidebarrow.c b/gtk/gtksidebarrow.c
index 8e1f5aa392..9b7c19d86a 100644
--- a/gtk/gtksidebarrow.c
+++ b/gtk/gtksidebarrow.c
@@ -330,6 +330,8 @@ gtk_sidebar_row_set_property (GObject *object,
self->placeholder = g_value_get_boolean (value);
if (self->placeholder)
{
+ GtkWidget *child;
+
g_clear_object (&self->start_icon);
g_clear_object (&self->end_icon);
g_free (self->label);
@@ -347,9 +349,8 @@ gtk_sidebar_row_set_property (GObject *object,
g_clear_object (&self->mount);
g_clear_object (&self->cloud_provider_account);
- gtk_container_foreach (GTK_CONTAINER (self),
- (GtkCallback) gtk_widget_destroy,
- NULL);
+ while ((child = gtk_widget_get_first_child (GTK_WIDGET (self))))
+ gtk_container_remove (GTK_CONTAINER (self), child);
gtk_widget_add_css_class (GTK_WIDGET (self), "sidebar-placeholder-row");
}
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index fb50485772..cad6044f42 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -1958,6 +1958,9 @@ gtk_text_dispose (GObject *object)
g_clear_pointer ((GtkWidget **) &priv->text_handles[TEXT_HANDLE_SELECTION_BOUND], gtk_widget_unparent);
g_clear_object (&priv->extra_menu);
+ g_clear_pointer (&priv->magnifier_popover, gtk_widget_unparent);
+ g_clear_pointer (&priv->placeholder, gtk_widget_unparent);
+
G_OBJECT_CLASS (gtk_text_parent_class)->dispose (object);
}
@@ -1972,11 +1975,8 @@ gtk_text_finalize (GObject *object)
g_clear_object (&priv->history);
g_clear_object (&priv->cached_layout);
g_clear_object (&priv->im_context);
- g_clear_pointer (&priv->magnifier_popover, gtk_widget_destroy);
g_free (priv->im_module);
- g_clear_pointer (&priv->placeholder, gtk_widget_unparent);
-
if (priv->tabs)
pango_tab_array_free (priv->tabs);
diff --git a/gtk/gtktextchild.c b/gtk/gtktextchild.c
index 9ef3184673..e5963b9177 100644
--- a/gtk/gtktextchild.c
+++ b/gtk/gtktextchild.c
@@ -236,7 +236,7 @@ child_segment_delete_func (GtkTextLineSegment *seg,
{
GtkWidget *child = tmp_list->data;
- gtk_widget_destroy (child);
+ gtk_widget_unparent (child);
tmp_list = tmp_list->next;
}
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 0f1eef567c..549e792087 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -2067,7 +2067,7 @@ gtk_text_view_set_buffer (GtkTextView *text_view,
while (priv->anchored_children.length)
{
AnchoredChild *ac = g_queue_peek_head (&priv->anchored_children);
- gtk_widget_destroy (ac->widget);
+ gtk_widget_unparent (ac->widget);
/* ac is now invalid! */
}
@@ -3804,6 +3804,9 @@ gtk_text_view_dispose (GObject *object)
g_clear_pointer ((GtkWidget **) &priv->text_handles[TEXT_HANDLE_CURSOR], gtk_widget_unparent);
g_clear_pointer ((GtkWidget **) &priv->text_handles[TEXT_HANDLE_SELECTION_BOUND], gtk_widget_unparent);
+ g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent);
+ g_clear_pointer (&priv->magnifier_popover, gtk_widget_unparent);
+
G_OBJECT_CLASS (gtk_text_view_parent_class)->dispose (object);
}
@@ -3842,10 +3845,6 @@ gtk_text_view_finalize (GObject *object)
text_window_free (priv->text_window);
- g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent);
-
- if (priv->magnifier_popover)
- gtk_widget_destroy (priv->magnifier_popover);
g_object_unref (priv->im_context);
g_free (priv->im_module);
diff --git a/gtk/gtktreepopover.c b/gtk/gtktreepopover.c
index c60ec32aa0..636cb5180d 100644
--- a/gtk/gtktreepopover.c
+++ b/gtk/gtktreepopover.c
@@ -376,7 +376,7 @@ row_deleted_cb (GtkTreeModel *model,
if (item)
{
- gtk_widget_destroy (item);
+ gtk_widget_unparent (item);
gtk_cell_area_context_reset (popover->context);
}
}
@@ -405,9 +405,9 @@ row_changed_cb (GtkTreeModel *model,
if (is_separator != GTK_IS_SEPARATOR (item))
{
- GtkWidget *box= gtk_widget_get_parent (item);
+ GtkWidget *box = gtk_widget_get_parent (item);
- gtk_widget_destroy (item);
+ gtk_container_remove (GTK_CONTAINER (box), item);
item = gtk_tree_popover_create_item (popover, path, iter, FALSE);
@@ -732,9 +732,11 @@ static void
rebuild_menu (GtkTreePopover *popover)
{
GtkWidget *stack;
+ GtkWidget *child;
stack = gtk_popover_get_child (GTK_POPOVER (popover));
- gtk_container_foreach (GTK_CONTAINER (stack), (GtkCallback) gtk_widget_destroy, NULL);
+ while ((child = gtk_widget_get_first_child (stack)))
+ gtk_container_remove (GTK_CONTAINER (stack), child);
if (popover->model)
gtk_tree_popover_populate (popover);
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index efa2c9d712..db96a38965 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -2073,7 +2073,7 @@ gtk_tree_view_free_rbtree (GtkTreeView *tree_view)
static void
gtk_tree_view_destroy_search_popover (GtkTreeView *tree_view)
{
- gtk_widget_destroy (tree_view->search_popover);
+ gtk_widget_unparent (tree_view->search_popover);
tree_view->search_popover = NULL;
tree_view->search_entry = NULL;
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index e400f80062..4daa725427 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -197,7 +197,6 @@ typedef struct
gint title_height;
GtkWidget *title_box;
GtkWidget *titlebar;
- GtkWidget *popup_menu;
GtkWidget *key_press_focus;
GdkMonitor *initial_fullscreen_monitor;
@@ -2416,7 +2415,7 @@ gtk_window_transient_parent_destroyed (GtkWindow *parent,
GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (window));
if (priv->destroy_with_parent)
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (window);
else
priv->transient_parent = NULL;
}
diff --git a/gtk/gtkwindowhandle.c b/gtk/gtkwindowhandle.c
index 18a2d4f12e..99b6b01de8 100644
--- a/gtk/gtkwindowhandle.c
+++ b/gtk/gtkwindowhandle.c
@@ -188,7 +188,7 @@ do_popup_fallback (GtkWindowHandle *self,
GtkWindow *window;
gboolean maximized, resizable, deletable;
- g_clear_pointer (&self->fallback_menu, gtk_widget_destroy);
+ g_clear_pointer (&self->fallback_menu, gtk_widget_unparent);
window = get_window (self);
@@ -506,7 +506,7 @@ gtk_window_handle_unrealize (GtkWidget *widget)
{
GtkWindowHandle *self = GTK_WINDOW_HANDLE (widget);
- g_clear_pointer (&self->fallback_menu, gtk_widget_destroy);
+ g_clear_pointer (&self->fallback_menu, gtk_widget_unparent);
GTK_WIDGET_CLASS (gtk_window_handle_parent_class)->unrealize (widget);
}
diff --git a/gtk/inspector/actions.c b/gtk/inspector/actions.c
index c50b71cd46..d7018078ba 100644
--- a/gtk/inspector/actions.c
+++ b/gtk/inspector/actions.c
@@ -167,7 +167,7 @@ action_removed_cb (GActionGroup *group,
row = find_row (sl, action_name);
if (row)
- gtk_widget_destroy (row);
+ gtk_container_remove (GTK_CONTAINER (sl->priv->list), row);
}
static void
@@ -312,7 +312,7 @@ gtk_inspector_actions_set_object (GtkInspectorActions *sl,
remove_group (sl, page, sl->priv->group);
while ((child = gtk_widget_get_first_child (sl->priv->list)))
- gtk_widget_destroy (child);
+ gtk_container_remove (GTK_CONTAINER (sl->priv->list), child);
if (GTK_IS_APPLICATION (object))
add_group (sl, page, G_ACTION_GROUP (object));
diff --git a/gtk/inspector/css-node-tree.c b/gtk/inspector/css-node-tree.c
index 8894a370f8..3fb1221b17 100644
--- a/gtk/inspector/css-node-tree.c
+++ b/gtk/inspector/css-node-tree.c
@@ -112,7 +112,7 @@ show_node_prop_editor (NodePropEditor *npe)
gtk_popover_popup (GTK_POPOVER (popover));
- g_signal_connect (popover, "unmap", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (popover, "unmap", G_CALLBACK (gtk_widget_unparent), NULL);
}
static void
diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
index 5bffd5b1b7..5e52fcd63a 100644
--- a/gtk/inspector/general.c
+++ b/gtk/inspector/general.c
@@ -532,7 +532,7 @@ populate_display (GdkDisplay *display, GtkInspectorGeneral *gen)
gtk_widget_is_ancestor (gen->priv->display_composited, child))
continue;
- gtk_widget_destroy (child);
+ gtk_container_remove (GTK_CONTAINER (list), child);
}
g_list_free (children);
@@ -797,7 +797,7 @@ populate_seats (GtkInspectorGeneral *gen)
list = gtk_container_get_children (GTK_CONTAINER (gen->priv->device_box));
for (l = list; l; l = l->next)
- gtk_widget_destroy (GTK_WIDGET (l->data));
+ gtk_container_remove (GTK_CONTAINER (gen->priv->device_box), GTK_WIDGET (l->data));
g_list_free (list);
list = gdk_display_list_seats (gen->priv->display);
diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c
index 7810854941..e7dd6df908 100644
--- a/gtk/inspector/misc-info.c
+++ b/gtk/inspector/misc-info.c
@@ -326,11 +326,14 @@ update_info (gpointer data)
if (GTK_IS_WIDGET (sl->priv->object))
{
+ GtkWidget *child;
AtkObject *accessible;
AtkRole role;
GList *list, *l;
- gtk_container_forall (GTK_CONTAINER (sl->priv->mnemonic_label), (GtkCallback)gtk_widget_destroy, NULL);
+ while ((child = gtk_widget_get_first_child (sl->priv->mnemonic_label)))
+ gtk_container_remove (GTK_CONTAINER (sl->priv->mnemonic_label), child);
+
list = gtk_widget_list_mnemonic_labels (GTK_WIDGET (sl->priv->object));
for (l = list; l; l = l->next)
{
diff --git a/gtk/inspector/prop-list.c b/gtk/inspector/prop-list.c
index 53600015a5..b26c0fc70e 100644
--- a/gtk/inspector/prop-list.c
+++ b/gtk/inspector/prop-list.c
@@ -600,8 +600,8 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
pl->priv->object = object;
- while ((w = gtk_widget_get_first_child (pl->priv->list2)) != NULL)
- gtk_widget_destroy (w);
+ while ((w = gtk_widget_get_first_child (pl->priv->list2)))
+ gtk_container_remove (GTK_CONTAINER (pl->priv->list2), w);
for (i = 0; i < num_properties; i++)
{
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index 448898b57f..784e66b269 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -1179,7 +1179,7 @@ node_property_activated (GtkTreeView *tv,
gtk_popover_set_child (GTK_POPOVER (popover), image);
gtk_popover_popup (GTK_POPOVER (popover));
- g_signal_connect (popover, "unmap", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (popover, "unmap", G_CALLBACK (gtk_widget_unparent), NULL);
g_object_unref (texture);
}
diff --git a/gtk/inspector/strv-editor.c b/gtk/inspector/strv-editor.c
index 2f8528abc9..2471251fd8 100644
--- a/gtk/inspector/strv-editor.c
+++ b/gtk/inspector/strv-editor.c
@@ -49,7 +49,10 @@ static void
remove_string (GtkButton *button,
GtkInspectorStrvEditor *editor)
{
- gtk_widget_destroy (gtk_widget_get_parent (GTK_WIDGET (button)));
+ GtkWidget *row;
+
+ row = gtk_widget_get_parent (GTK_WIDGET (button));
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (row)), row);
emit_changed (editor);
}
@@ -128,15 +131,13 @@ void
gtk_inspector_strv_editor_set_strv (GtkInspectorStrvEditor *editor,
gchar **strv)
{
- GList *children, *l;
+ GtkWidget *child;
gint i;
editor->blocked = TRUE;
- children = gtk_container_get_children (GTK_CONTAINER (editor->box));
- for (l = children; l; l = l->next)
- gtk_widget_destroy (GTK_WIDGET (l->data));
- g_list_free (children);
+ while ((child = gtk_widget_get_first_child (editor->box)))
+ gtk_container_remove (GTK_CONTAINER (editor->box), child);
if (strv)
{