diff --git a/demos/constraint-editor/constraint-editor-window.c b/demos/constraint-editor/constraint-editor-window.c
index 1a78092994..2a7b228028 100644
--- a/demos/constraint-editor/constraint-editor-window.c
+++ b/demos/constraint-editor/constraint-editor-window.c
@@ -317,7 +317,7 @@ save_response_cb (GtkNativeDialog *dialog,
"Saving failed");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
"%s", error->message);
- g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (message_dialog);
g_error_free (error);
}
@@ -403,7 +403,7 @@ constraint_editor_done (ConstraintEditor *editor,
g_clear_object (&old_constraint);
- gtk_widget_destroy (gtk_widget_get_ancestor (GTK_WIDGET (editor), GTK_TYPE_WINDOW));
+ gtk_window_destroy (GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (editor), GTK_TYPE_WINDOW)));
}
static void
@@ -444,7 +444,7 @@ guide_editor_done (GuideEditor *editor,
GtkConstraintGuide *guide,
ConstraintEditorWindow *win)
{
- gtk_widget_destroy (gtk_widget_get_ancestor (GTK_WIDGET (editor), GTK_TYPE_WINDOW));
+ gtk_window_destroy (GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (editor), GTK_TYPE_WINDOW)));
}
static void
diff --git a/demos/gtk-demo/application.c b/demos/gtk-demo/application.c
index 53be2b10d0..64cf105a4e 100644
--- a/demos/gtk-demo/application.c
+++ b/demos/gtk-demo/application.c
@@ -47,7 +47,7 @@ show_action_dialog (GSimpleAction *action)
name);
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
}
@@ -120,7 +120,7 @@ open_response_cb (GtkNativeDialog *dialog,
"Error loading file: \"%s\"",
error->message);
g_signal_connect (message_dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (message_dialog);
g_error_free (error);
}
@@ -234,7 +234,7 @@ activate_quit (GSimpleAction *action,
win = list->data;
next = list->next;
- gtk_widget_destroy (GTK_WIDGET (win));
+ gtk_window_destroy (GTK_WINDOW (win));
list = next;
}
diff --git a/demos/gtk-demo/application_demo.c b/demos/gtk-demo/application_demo.c
index 8f36568464..087ea3ff8f 100644
--- a/demos/gtk-demo/application_demo.c
+++ b/demos/gtk-demo/application_demo.c
@@ -31,12 +31,7 @@ on_name_vanished (GDBusConnection *connection,
if (!name_seen)
return;
- if (placeholder)
- {
- gtk_widget_destroy (placeholder);
- g_object_unref (placeholder);
- placeholder = NULL;
- }
+ g_clear_object (&placeholder);
}
#ifdef G_OS_WIN32
diff --git a/demos/gtk-demo/assistant.c b/demos/gtk-demo/assistant.c
index b1c285f0e8..c1da7b02e6 100644
--- a/demos/gtk-demo/assistant.c
+++ b/demos/gtk-demo/assistant.c
@@ -26,7 +26,7 @@ apply_changes_gradually (gpointer data)
else
{
/* Close automatically once changes are fully applied. */
- gtk_widget_destroy (data);
+ gtk_window_destroy (GTK_WINDOW (data));
return G_SOURCE_REMOVE;
}
}
@@ -41,7 +41,7 @@ on_assistant_apply (GtkWidget *widget, gpointer data)
static void
on_assistant_close_cancel (GtkWidget *widget, gpointer data)
{
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
static void
@@ -178,8 +178,7 @@ do_assistant (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (assistant),
gtk_widget_get_display (do_widget));
- g_signal_connect (assistant, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &assistant);
+ g_object_add_weak_pointer (G_OBJECT (assistant), (gpointer *)&assistant);
create_page1 (assistant);
create_page2 (assistant);
@@ -199,7 +198,7 @@ do_assistant (GtkWidget *do_widget)
if (!gtk_widget_get_visible (assistant))
gtk_widget_show (assistant);
else
- gtk_widget_destroy (assistant);
+ gtk_window_destroy (GTK_WINDOW (assistant));
return assistant;
}
diff --git a/demos/gtk-demo/builder.c b/demos/gtk-demo/builder.c
index 35714f2351..b0c3f3cdc3 100644
--- a/demos/gtk-demo/builder.c
+++ b/demos/gtk-demo/builder.c
@@ -12,7 +12,7 @@ quit_activate (GSimpleAction *action,
{
GtkWidget *window = user_data;
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static void
@@ -74,8 +74,7 @@ do_builder (GtkWidget *do_widget)
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
actions = (GActionGroup*)g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (actions),
win_entries, G_N_ELEMENTS (win_entries),
@@ -88,7 +87,7 @@ do_builder (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c
index 801baaa173..fbecef7506 100644
--- a/demos/gtk-demo/clipboard.c
+++ b/demos/gtk-demo/clipboard.c
@@ -69,7 +69,7 @@ paste_received (GObject *source_object,
"Could not paste text: %s",
error->message);
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
g_error_free (error);
@@ -108,9 +108,7 @@ do_clipboard (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Clipboard");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_margin_start (vbox, 8);
@@ -187,7 +185,7 @@ do_clipboard (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/combobox.c b/demos/gtk-demo/combobox.c
index 946267cc66..2be94b3c8c 100644
--- a/demos/gtk-demo/combobox.c
+++ b/demos/gtk-demo/combobox.c
@@ -315,9 +315,7 @@ do_combobox (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Combo Boxes");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
gtk_widget_set_margin_start (vbox, 10);
@@ -450,7 +448,7 @@ do_combobox (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/constraints.c b/demos/gtk-demo/constraints.c
index 306d4b340c..b6c5df0bd3 100644
--- a/demos/gtk-demo/constraints.c
+++ b/demos/gtk-demo/constraints.c
@@ -25,9 +25,9 @@ simple_grid_dispose (GObject *object)
{
SimpleGrid *self = SIMPLE_GRID (object);
- g_clear_pointer (&self->button1, gtk_widget_destroy);
- g_clear_pointer (&self->button2, gtk_widget_destroy);
- g_clear_pointer (&self->button3, gtk_widget_destroy);
+ g_clear_pointer (&self->button1, gtk_widget_unparent);
+ g_clear_pointer (&self->button2, gtk_widget_unparent);
+ g_clear_pointer (&self->button3, gtk_widget_unparent);
G_OBJECT_CLASS (simple_grid_parent_class)->dispose (object);
}
@@ -263,8 +263,7 @@ do_constraints (GtkWidget *do_widget)
header = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_window_set_child (GTK_WINDOW (window), box);
@@ -278,13 +277,13 @@ do_constraints (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (box), button);
gtk_widget_set_hexpand (grid, TRUE);
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy), window);
+ G_CALLBACK (gtk_window_destroy), window);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/constraints2.c b/demos/gtk-demo/constraints2.c
index bd2f373e0f..2a9477e048 100644
--- a/demos/gtk-demo/constraints2.c
+++ b/demos/gtk-demo/constraints2.c
@@ -26,9 +26,9 @@ interactive_grid_dispose (GObject *object)
{
InteractiveGrid *self = INTERACTIVE_GRID (object);
- g_clear_pointer (&self->button1, gtk_widget_destroy);
- g_clear_pointer (&self->button2, gtk_widget_destroy);
- g_clear_pointer (&self->button3, gtk_widget_destroy);
+ g_clear_pointer (&self->button1, gtk_widget_unparent);
+ g_clear_pointer (&self->button2, gtk_widget_unparent);
+ g_clear_pointer (&self->button3, gtk_widget_unparent);
G_OBJECT_CLASS (interactive_grid_parent_class)->dispose (object);
}
@@ -219,8 +219,7 @@ do_constraints2 (GtkWidget *do_widget)
header = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_window_set_child (GTK_WINDOW (window), box);
@@ -234,13 +233,13 @@ do_constraints2 (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (box), button);
gtk_widget_set_hexpand (grid, TRUE);
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy), window);
+ G_CALLBACK (gtk_window_destroy), window);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/constraints3.c b/demos/gtk-demo/constraints3.c
index a534a905f7..0edc5b8ebd 100644
--- a/demos/gtk-demo/constraints3.c
+++ b/demos/gtk-demo/constraints3.c
@@ -24,9 +24,9 @@ vfl_grid_dispose (GObject *object)
{
VflGrid *self = VFL_GRID (object);
- g_clear_pointer (&self->button1, gtk_widget_destroy);
- g_clear_pointer (&self->button2, gtk_widget_destroy);
- g_clear_pointer (&self->button3, gtk_widget_destroy);
+ g_clear_pointer (&self->button1, gtk_widget_unparent);
+ g_clear_pointer (&self->button2, gtk_widget_unparent);
+ g_clear_pointer (&self->button3, gtk_widget_unparent);
G_OBJECT_CLASS (vfl_grid_parent_class)->dispose (object);
}
@@ -139,8 +139,7 @@ do_constraints3 (GtkWidget *do_widget)
header = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_window_set_child (GTK_WINDOW (window), box);
@@ -154,13 +153,13 @@ do_constraints3 (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (box), button);
gtk_widget_set_hexpand (grid, TRUE);
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy), window);
+ G_CALLBACK (gtk_window_destroy), window);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/css_accordion.c b/demos/gtk-demo/css_accordion.c
index d28262def0..c81047b3cc 100644
--- a/demos/gtk-demo/css_accordion.c
+++ b/demos/gtk-demo/css_accordion.c
@@ -28,8 +28,7 @@ do_css_accordion (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "CSS Accordion");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 600, 300);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
@@ -63,7 +62,7 @@ do_css_accordion (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/css_basics.c b/demos/gtk-demo/css_basics.c
index 2f46c4f38b..fed09bb1e5 100644
--- a/demos/gtk-demo/css_basics.c
+++ b/demos/gtk-demo/css_basics.c
@@ -76,8 +76,7 @@ do_css_basics (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "CSS Basics");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
text = gtk_text_buffer_new (NULL);
gtk_text_buffer_create_tag (text,
@@ -113,7 +112,7 @@ do_css_basics (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/css_blendmodes.c b/demos/gtk-demo/css_blendmodes.c
index 86fc0ecc91..7031039225 100644
--- a/demos/gtk-demo/css_blendmodes.c
+++ b/demos/gtk-demo/css_blendmodes.c
@@ -125,7 +125,7 @@ do_css_blendmodes (GtkWidget *do_widget)
window = WID ("window");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
/* Setup the CSS provider for window */
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
@@ -140,7 +140,7 @@ do_css_blendmodes (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/css_multiplebgs.c b/demos/gtk-demo/css_multiplebgs.c
index 5e29060d85..4a9dd81792 100644
--- a/demos/gtk-demo/css_multiplebgs.c
+++ b/demos/gtk-demo/css_multiplebgs.c
@@ -90,8 +90,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Multiple Backgrounds");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
container = gtk_overlay_new ();
gtk_window_set_child (GTK_WINDOW (window), container);
@@ -153,7 +152,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/css_pixbufs.c b/demos/gtk-demo/css_pixbufs.c
index 9d88ef76fa..2617c76280 100644
--- a/demos/gtk-demo/css_pixbufs.c
+++ b/demos/gtk-demo/css_pixbufs.c
@@ -76,8 +76,7 @@ do_css_pixbufs (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Animated Backgrounds");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
gtk_window_set_child (GTK_WINDOW (window), paned);
@@ -120,7 +119,7 @@ do_css_pixbufs (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/css_shadows.c b/demos/gtk-demo/css_shadows.c
index de21cfae29..b41e7eb16f 100644
--- a/demos/gtk-demo/css_shadows.c
+++ b/demos/gtk-demo/css_shadows.c
@@ -95,8 +95,7 @@ do_css_shadows (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Shadows");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
gtk_window_set_child (GTK_WINDOW (window), paned);
@@ -138,7 +137,7 @@ do_css_shadows (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/cursors.c b/demos/gtk-demo/cursors.c
index e5c00d19b2..78bd12f8b8 100644
--- a/demos/gtk-demo/cursors.c
+++ b/demos/gtk-demo/cursors.c
@@ -36,7 +36,7 @@ do_cursors (GtkWidget *do_widget)
gtk_widget_show (window);
else
{
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
return window;
diff --git a/demos/gtk-demo/dialog.c b/demos/gtk-demo/dialog.c
index 6b965b9d84..673a6e21f2 100644
--- a/demos/gtk-demo/dialog.c
+++ b/demos/gtk-demo/dialog.c
@@ -26,7 +26,7 @@ message_dialog_clicked (GtkButton *button,
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%d", i);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
i++;
}
@@ -89,7 +89,7 @@ interactive_dialog_clicked (GtkButton *button,
gtk_editable_set_text (GTK_EDITABLE (entry2), gtk_editable_get_text (GTK_EDITABLE (local_entry2)));
}
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
GtkWidget *
@@ -109,9 +109,7 @@ do_dialog (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Dialogs and Message Boxes");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
frame = gtk_frame_new ("Dialogs");
gtk_widget_set_margin_start (frame, 8);
@@ -170,7 +168,7 @@ do_dialog (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c
index 30bae48e17..06addd854d 100644
--- a/demos/gtk-demo/dnd.c
+++ b/demos/gtk-demo/dnd.c
@@ -138,7 +138,7 @@ edit_label_done (GtkWidget *entry, gpointer data)
gtk_label_set_text (GTK_LABEL (label), gtk_editable_get_text (GTK_EDITABLE (entry)));
gtk_widget_show (label);
- gtk_widget_destroy (entry);
+ gtk_container_remove (GTK_CONTAINER (canvas), entry);
}
static void
@@ -170,7 +170,9 @@ edit_cb (GtkWidget *button, GtkWidget *child)
static void
delete_cb (GtkWidget *button, GtkWidget *child)
{
- gtk_widget_destroy (child);
+ GtkWidget *canvas = gtk_widget_get_parent (child);
+
+ gtk_container_remove (GTK_CONTAINER (canvas), child);
gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER)));
}
@@ -419,7 +421,6 @@ do_dnd (GtkWidget *do_widget)
{
GtkWidget *sw;
GtkWidget *canvas;
- GtkWidget *widget;
GtkWidget *box, *box2, *box3;
const char *colors[] = {
"red", "green", "blue", "magenta", "orange", "gray", "black", "yellow",
@@ -430,17 +431,14 @@ do_dnd (GtkWidget *do_widget)
int i;
int x, y;
- widget = gtk_color_button_new ();
- gtk_widget_destroy (widget);
-
+ g_type_ensure (GTK_TYPE_COLOR_BUTTON);
+
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Drag-and-Drop");
gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child (GTK_WINDOW (window), box);
@@ -494,7 +492,7 @@ do_dnd (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/drawingarea.c b/demos/gtk-demo/drawingarea.c
index 5404f53a1c..4309d99573 100644
--- a/demos/gtk-demo/drawingarea.c
+++ b/demos/gtk-demo/drawingarea.c
@@ -260,7 +260,7 @@ do_drawingarea (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/editable_cells.c b/demos/gtk-demo/editable_cells.c
index cb0ff0abfa..05ed5fe7ba 100644
--- a/demos/gtk-demo/editable_cells.c
+++ b/demos/gtk-demo/editable_cells.c
@@ -352,8 +352,7 @@ do_editable_cells (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Editable Cells");
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
@@ -410,7 +409,7 @@ do_editable_cells (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/entry_completion.c b/demos/gtk-demo/entry_completion.c
index d371afc451..6a23b78d67 100644
--- a/demos/gtk-demo/entry_completion.c
+++ b/demos/gtk-demo/entry_completion.c
@@ -50,9 +50,7 @@ do_entry_completion (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Entry Completion");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
@@ -88,7 +86,7 @@ do_entry_completion (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/entry_undo.c b/demos/gtk-demo/entry_undo.c
index 9d069aeafb..39bebb8d30 100644
--- a/demos/gtk-demo/entry_undo.c
+++ b/demos/gtk-demo/entry_undo.c
@@ -25,8 +25,7 @@ do_entry_undo (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Entry Undo");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
@@ -49,7 +48,7 @@ do_entry_undo (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/expander.c b/demos/gtk-demo/expander.c
index 78cb3fb271..63ef27081d 100644
--- a/demos/gtk-demo/expander.c
+++ b/demos/gtk-demo/expander.c
@@ -15,7 +15,7 @@ static GtkWidget *window = NULL;
static void
response_cb (GtkDialog *dialog, gint response_id)
{
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
window = NULL;
}
@@ -90,7 +90,7 @@ do_expander (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/filtermodel.c b/demos/gtk-demo/filtermodel.c
index 0cb87d6a4e..e3a55c4f99 100644
--- a/demos/gtk-demo/filtermodel.c
+++ b/demos/gtk-demo/filtermodel.c
@@ -125,8 +125,7 @@ do_filtermodel (GtkWidget *do_widget)
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
store = (GtkListStore*)gtk_builder_get_object (builder, "liststore1");
@@ -199,7 +198,7 @@ do_filtermodel (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/fishbowl.c b/demos/gtk-demo/fishbowl.c
index 60ec2b5c28..6cc2dfc1a2 100644
--- a/demos/gtk-demo/fishbowl.c
+++ b/demos/gtk-demo/fishbowl.c
@@ -273,15 +273,13 @@ do_fishbowl (GtkWidget *do_widget)
builder = gtk_builder_new_from_resource ("/fishbowl/fishbowl.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
+
bowl = GTK_WIDGET (gtk_builder_get_object (builder, "bowl"));
selected_widget_type = -1;
set_widget_type (GTK_FISHBOWL (bowl), 0);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
gtk_widget_realize (window);
g_object_unref (builder);
@@ -290,7 +288,7 @@ do_fishbowl (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/fixed.c b/demos/gtk-demo/fixed.c
index dcdf253596..81c503261c 100644
--- a/demos/gtk-demo/fixed.c
+++ b/demos/gtk-demo/fixed.c
@@ -161,7 +161,7 @@ do_fixed (GtkWidget *do_widget)
if (!gtk_widget_get_visible (demo_window))
gtk_widget_show (demo_window);
else
- gtk_widget_destroy (demo_window);
+ gtk_window_destroy (GTK_WINDOW (demo_window));
return demo_window;
}
diff --git a/demos/gtk-demo/flowbox.c b/demos/gtk-demo/flowbox.c
index fd87463b89..8340923be5 100644
--- a/demos/gtk-demo/flowbox.c
+++ b/demos/gtk-demo/flowbox.c
@@ -724,9 +724,7 @@ do_flowbox (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Flow Box");
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
@@ -745,7 +743,7 @@ do_flowbox (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/font_features.c b/demos/gtk-demo/font_features.c
index f009da03f1..818164d5f3 100644
--- a/demos/gtk-demo/font_features.c
+++ b/demos/gtk-demo/font_features.c
@@ -1025,7 +1025,7 @@ denorm_coord (hb_ot_var_axis_info_t *axis, int coord)
static void
update_font_variations (void)
{
- GtkWidget *child, *next;
+ GtkWidget *child;
PangoFont *pango_font = NULL;
hb_font_t *hb_font;
hb_face_t *hb_face;
@@ -1037,12 +1037,8 @@ update_font_variations (void)
int i;
child = gtk_widget_get_first_child (variations_grid);
- while (child != NULL)
- {
- next = gtk_widget_get_next_sibling (child);
- gtk_widget_destroy (child);
- child = next;
- }
+ while ((child = gtk_widget_get_first_child (variations_grid)))
+ gtk_container_remove (GTK_CONTAINER (variations_grid), child);
instance_combo = NULL;
@@ -1333,8 +1329,7 @@ do_font_features (GtkWidget *do_widget)
font_features_font_changed ();
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_object_unref (builder);
@@ -1344,7 +1339,7 @@ do_font_features (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_window_present (GTK_WINDOW (window));
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/fontrendering.c b/demos/gtk-demo/fontrendering.c
index b10b7929a5..a56b242ad5 100644
--- a/demos/gtk-demo/fontrendering.c
+++ b/demos/gtk-demo/fontrendering.c
@@ -281,7 +281,7 @@ do_fontrendering (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/gears.c b/demos/gtk-demo/gears.c
index bf455b3901..e7a198e55b 100644
--- a/demos/gtk-demo/gears.c
+++ b/demos/gtk-demo/gears.c
@@ -85,7 +85,7 @@ do_gears (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Gears");
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 640);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
overlay = gtk_overlay_new ();
gtk_widget_set_margin_start (overlay, 12);
@@ -131,7 +131,7 @@ do_gears (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/gestures.c b/demos/gtk-demo/gestures.c
index f238da1666..99dccaa9a5 100644
--- a/demos/gtk-demo/gestures.c
+++ b/demos/gtk-demo/gestures.c
@@ -149,8 +149,7 @@ do_gestures (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
gtk_window_set_title (GTK_WINDOW (window), "Gestures");
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
drawing_area = gtk_drawing_area_new ();
gtk_window_set_child (GTK_WINDOW (window), drawing_area);
@@ -210,7 +209,7 @@ do_gestures (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/glarea.c b/demos/gtk-demo/glarea.c
index 0a5f965a07..8de86d1765 100644
--- a/demos/gtk-demo/glarea.c
+++ b/demos/gtk-demo/glarea.c
@@ -427,7 +427,7 @@ create_glarea_window (GtkWidget *do_widget)
button = gtk_button_new_with_label ("Quit");
gtk_widget_set_hexpand (button, TRUE);
gtk_container_add (GTK_CONTAINER (box), button);
- g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
return window;
}
@@ -441,7 +441,7 @@ do_glarea (GtkWidget *do_widget)
if (!gtk_widget_get_visible (demo_window))
gtk_widget_show (demo_window);
else
- gtk_widget_destroy (demo_window);
+ gtk_window_destroy (GTK_WINDOW (demo_window));
return demo_window;
}
diff --git a/demos/gtk-demo/headerbar.c b/demos/gtk-demo/headerbar.c
index e8a0ead1a9..7f1acfa652 100644
--- a/demos/gtk-demo/headerbar.c
+++ b/demos/gtk-demo/headerbar.c
@@ -25,8 +25,8 @@ do_headerbar (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Welcome to Facebook - Log in, sign up or learn more");
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
+
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
header = gtk_header_bar_new ();
@@ -58,7 +58,7 @@ do_headerbar (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/hypertext.c b/demos/gtk-demo/hypertext.c
index 9191cabe49..b52c4b4875 100644
--- a/demos/gtk-demo/hypertext.c
+++ b/demos/gtk-demo/hypertext.c
@@ -237,9 +237,7 @@ do_hypertext (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
view = gtk_text_view_new ();
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
@@ -275,7 +273,7 @@ do_hypertext (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/iconscroll.c b/demos/gtk-demo/iconscroll.c
index 2254aa0bef..e53e06c2e3 100644
--- a/demos/gtk-demo/iconscroll.c
+++ b/demos/gtk-demo/iconscroll.c
@@ -209,12 +209,10 @@ do_iconscroll (GtkWidget *do_widget)
builder = gtk_builder_new_from_resource ("/iconscroll/iconscroll.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+
scrolledwindow = GTK_WIDGET (gtk_builder_get_object (builder, "scrolledwindow"));
gtk_widget_realize (window);
hadjustment = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "hadjustment"));
@@ -225,7 +223,7 @@ do_iconscroll (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/iconview.c b/demos/gtk-demo/iconview.c
index 0b80aafae1..45dc455e41 100644
--- a/demos/gtk-demo/iconview.c
+++ b/demos/gtk-demo/iconview.c
@@ -228,7 +228,7 @@ home_clicked (GtkButton *item,
static void close_window(void)
{
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
window = NULL;
g_object_unref (file_pixbuf);
@@ -320,7 +320,7 @@ do_iconview (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/iconview_edit.c b/demos/gtk-demo/iconview_edit.c
index 6e5c52d2a6..f04a6361e8 100644
--- a/demos/gtk-demo/iconview_edit.c
+++ b/demos/gtk-demo/iconview_edit.c
@@ -111,9 +111,7 @@ do_iconview_edit (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Editing and Drag-and-Drop");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
store = create_store ();
fill_store (store);
@@ -152,7 +150,7 @@ do_iconview_edit (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/images.c b/demos/gtk-demo/images.c
index b0efca8a1b..8dc68de316 100644
--- a/demos/gtk-demo/images.c
+++ b/demos/gtk-demo/images.c
@@ -91,7 +91,7 @@ progressive_timeout (gpointer data)
g_error_free (error);
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
g_object_unref (image_stream);
image_stream = NULL;
@@ -119,7 +119,7 @@ progressive_timeout (gpointer data)
g_error_free (error);
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
g_object_unref (image_stream);
image_stream = NULL;
@@ -152,7 +152,7 @@ progressive_timeout (gpointer data)
g_error_free (error);
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
@@ -189,7 +189,7 @@ progressive_timeout (gpointer data)
g_error_free (error);
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
@@ -223,7 +223,7 @@ progressive_timeout (gpointer data)
g_error_free (error);
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
@@ -335,9 +335,8 @@ do_images (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Images");
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
g_signal_connect (window, "destroy",
G_CALLBACK (cleanup_callback), NULL);
@@ -472,7 +471,7 @@ do_images (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/infobar.c b/demos/gtk-demo/infobar.c
index 92fc46b26c..12fbe71c5b 100644
--- a/demos/gtk-demo/infobar.c
+++ b/demos/gtk-demo/infobar.c
@@ -29,10 +29,8 @@ on_bar_response (GtkInfoBar *info_bar,
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"Your response has id %d", response_id);
- g_signal_connect_swapped (dialog,
- "response",
- G_CALLBACK (gtk_widget_destroy),
- dialog);
+ g_signal_connect_swapped (dialog, "response",
+ G_CALLBACK (gtk_window_destroy), dialog);
gtk_widget_show (dialog);
}
@@ -58,8 +56,7 @@ do_infobar (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Info Bars");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
-
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_margin_start (vbox, 8);
@@ -149,7 +146,7 @@ do_infobar (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/links.c b/demos/gtk-demo/links.c
index 219f096346..72cab2c22e 100644
--- a/demos/gtk-demo/links.c
+++ b/demos/gtk-demo/links.c
@@ -12,7 +12,7 @@ response_cb (GtkWidget *dialog,
gint response_id,
gpointer data)
{
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static gboolean
@@ -59,8 +59,7 @@ do_links (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Links");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
label = gtk_label_new ("Some text may be marked up "
@@ -88,7 +87,7 @@ do_links (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/list_store.c b/demos/gtk-demo/list_store.c
index 941548318c..da9e9d18d8 100644
--- a/demos/gtk-demo/list_store.c
+++ b/demos/gtk-demo/list_store.c
@@ -257,9 +257,7 @@ do_list_store (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "List Store");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_widget_set_margin_start (vbox, 8);
@@ -309,7 +307,7 @@ do_list_store (GtkWidget *do_widget)
}
else
{
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
window = NULL;
if (timeout != 0)
{
diff --git a/demos/gtk-demo/listbox.c b/demos/gtk-demo/listbox.c
index fe9c3e2fd3..9221cab837 100644
--- a/demos/gtk-demo/listbox.c
+++ b/demos/gtk-demo/listbox.c
@@ -351,13 +351,8 @@ do_listbox (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "List Box");
- gtk_window_set_default_size (GTK_WINDOW (window),
- 400, 600);
-
- /* NULL window variable when window is closed */
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_window_set_child (GTK_WINDOW (window), vbox);
@@ -392,7 +387,7 @@ do_listbox (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index a16c9398ff..f8ef62d915 100644
--- a/demos/gtk-demo/main.c
+++ b/demos/gtk-demo/main.c
@@ -101,7 +101,7 @@ activate_quit (GSimpleAction *action,
win = list->data;
next = list->next;
- gtk_widget_destroy (GTK_WIDGET (win));
+ gtk_window_destroy (GTK_WINDOW (win));
list = next;
}
diff --git a/demos/gtk-demo/markup.c b/demos/gtk-demo/markup.c
index 7b23ec9252..ff62521b36 100644
--- a/demos/gtk-demo/markup.c
+++ b/demos/gtk-demo/markup.c
@@ -58,8 +58,7 @@ do_markup (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
stack = gtk_stack_new ();
gtk_widget_show (stack);
@@ -126,7 +125,7 @@ do_markup (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/modelbutton.c b/demos/gtk-demo/modelbutton.c
index a0299228b5..055189a1f5 100644
--- a/demos/gtk-demo/modelbutton.c
+++ b/demos/gtk-demo/modelbutton.c
@@ -43,8 +43,7 @@ do_modelbutton (GtkWidget *do_widget)
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
actions = (GActionGroup*)g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (actions),
@@ -59,7 +58,7 @@ do_modelbutton (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
diff --git a/demos/gtk-demo/overlay.c b/demos/gtk-demo/overlay.c
index ae1391a96d..61037b3401 100644
--- a/demos/gtk-demo/overlay.c
+++ b/demos/gtk-demo/overlay.c
@@ -79,15 +79,13 @@ do_overlay (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), entry);
gtk_window_set_child (GTK_WINDOW (window), overlay);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/overlay2.c b/demos/gtk-demo/overlay2.c
index 1cfc2d1798..8740e4b80d 100644
--- a/demos/gtk-demo/overlay2.c
+++ b/demos/gtk-demo/overlay2.c
@@ -60,9 +60,7 @@ do_overlay2 (GtkWidget *do_widget)
gtk_window_set_child (GTK_WINDOW (window), overlay);
gtk_overlay_set_child (GTK_OVERLAY (overlay), sw);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), text);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
image = gtk_picture_new_for_resource ("/overlay2/decor1.png");
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), image);
@@ -97,7 +95,7 @@ do_overlay2 (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/pagesetup.c b/demos/gtk-demo/pagesetup.c
index f169bae5c5..45f6982f6a 100644
--- a/demos/gtk-demo/pagesetup.c
+++ b/demos/gtk-demo/pagesetup.c
@@ -11,7 +11,7 @@
static void
done_cb (GtkDialog *dialog, gint response, gpointer data)
{
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
GtkWidget *
@@ -22,14 +22,14 @@ do_pagesetup (GtkWidget *do_widget)
if (!window)
{
window = gtk_page_setup_unix_dialog_new ("Page Setup", GTK_WINDOW (do_widget));
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_signal_connect (window, "response", G_CALLBACK (done_cb), NULL);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/paint.c b/demos/gtk-demo/paint.c
index a13750801e..a7a7c4eddf 100644
--- a/demos/gtk-demo/paint.c
+++ b/demos/gtk-demo/paint.c
@@ -405,16 +405,13 @@ do_paint (GtkWidget *toplevel)
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), colorbutton);
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
gtk_window_set_title (GTK_WINDOW (window), "Paint");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
-
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/paintable.c b/demos/gtk-demo/paintable.c
index 63fef5d5c8..982697ed7c 100644
--- a/demos/gtk-demo/paintable.c
+++ b/demos/gtk-demo/paintable.c
@@ -171,7 +171,7 @@ do_paintable (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/paintable_animated.c b/demos/gtk-demo/paintable_animated.c
index 4c71512b1e..f7571c08b2 100644
--- a/demos/gtk-demo/paintable_animated.c
+++ b/demos/gtk-demo/paintable_animated.c
@@ -203,7 +203,7 @@ do_paintable_animated (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/paintable_mediastream.c b/demos/gtk-demo/paintable_mediastream.c
index 4b1cde9e2d..20ae54bb6c 100644
--- a/demos/gtk-demo/paintable_mediastream.c
+++ b/demos/gtk-demo/paintable_mediastream.c
@@ -306,7 +306,7 @@ do_paintable_mediastream (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/panes.c b/demos/gtk-demo/panes.c
index 6a5c9bc59e..7d94ae5cbe 100644
--- a/demos/gtk-demo/panes.c
+++ b/demos/gtk-demo/panes.c
@@ -152,9 +152,7 @@ do_panes (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
@@ -204,7 +202,7 @@ do_panes (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/password_entry.c b/demos/gtk-demo/password_entry.c
index f8246dd4a4..478bcf2c08 100644
--- a/demos/gtk-demo/password_entry.c
+++ b/demos/gtk-demo/password_entry.c
@@ -45,8 +45,7 @@ do_password_entry (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Choose a Password");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_deletable (GTK_WINDOW (window), FALSE);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_widget_set_margin_start (box, 18);
@@ -75,7 +74,7 @@ do_password_entry (GtkWidget *do_widget)
button = gtk_button_new_with_mnemonic ("_Done");
gtk_widget_add_css_class (button, "suggested-action");
- g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
gtk_widget_set_sensitive (button, FALSE);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
@@ -85,7 +84,7 @@ do_password_entry (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/peg_solitaire.c b/demos/gtk-demo/peg_solitaire.c
index 00fdca3d56..61fddf9874 100644
--- a/demos/gtk-demo/peg_solitaire.c
+++ b/demos/gtk-demo/peg_solitaire.c
@@ -284,8 +284,7 @@ do_peg_solitaire (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Peg Solitaire");
gtk_window_set_titlebar (GTK_WINDOW (window), header);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
grid = gtk_grid_new ();
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
@@ -349,7 +348,7 @@ do_peg_solitaire (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/pickers.c b/demos/gtk-demo/pickers.c
index 5f6b3f8497..92e3786644 100644
--- a/demos/gtk-demo/pickers.c
+++ b/demos/gtk-demo/pickers.c
@@ -18,9 +18,7 @@ do_pickers (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Pickers");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
table = gtk_grid_new ();
gtk_widget_set_margin_start (table, 20);
@@ -77,7 +75,7 @@ do_pickers (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/pixbufs.c b/demos/gtk-demo/pixbufs.c
index aece1dfb4a..1c67404e0d 100644
--- a/demos/gtk-demo/pixbufs.c
+++ b/demos/gtk-demo/pixbufs.c
@@ -179,9 +179,7 @@ do_pixbufs (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Pixbufs");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
error = NULL;
if (!load_pixbufs (&error))
@@ -198,7 +196,7 @@ do_pixbufs (GtkWidget *do_widget)
g_error_free (error);
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
}
@@ -222,7 +220,7 @@ do_pixbufs (GtkWidget *do_widget)
gtk_widget_show (window);
else
{
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (frame);
}
diff --git a/demos/gtk-demo/printing.c b/demos/gtk-demo/printing.c
index 4604311494..bca12a0572 100644
--- a/demos/gtk-demo/printing.c
+++ b/demos/gtk-demo/printing.c
@@ -188,7 +188,7 @@ do_printing (GtkWidget *do_widget)
g_error_free (error);
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
}
diff --git a/demos/gtk-demo/revealer.c b/demos/gtk-demo/revealer.c
index befa2ddc75..25f5fcd40b 100644
--- a/demos/gtk-demo/revealer.c
+++ b/demos/gtk-demo/revealer.c
@@ -85,7 +85,7 @@ do_revealer (GtkWidget *do_widget)
}
else
{
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
diff --git a/demos/gtk-demo/rotated_text.c b/demos/gtk-demo/rotated_text.c
index b86a5e6944..a387a6cf7f 100644
--- a/demos/gtk-demo/rotated_text.c
+++ b/demos/gtk-demo/rotated_text.c
@@ -180,8 +180,7 @@ do_rotated_text (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Rotated Text");
gtk_window_set_default_size (GTK_WINDOW (window), 4 * RADIUS, 2 * RADIUS);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous (GTK_BOX (box), TRUE);
@@ -213,7 +212,7 @@ do_rotated_text (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/scale.c b/demos/gtk-demo/scale.c
index 55304e890e..bb6b5119ed 100644
--- a/demos/gtk-demo/scale.c
+++ b/demos/gtk-demo/scale.c
@@ -21,8 +21,7 @@ do_scale (GtkWidget *do_widget)
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_object_unref (builder);
}
@@ -30,7 +29,7 @@ do_scale (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
diff --git a/demos/gtk-demo/search_entry.c b/demos/gtk-demo/search_entry.c
index a072aa0962..c48e88b3b3 100644
--- a/demos/gtk-demo/search_entry.c
+++ b/demos/gtk-demo/search_entry.c
@@ -319,7 +319,7 @@ do_search_entry (GtkWidget *do_widget)
else
{
g_clear_object (&actions);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
return window;
diff --git a/demos/gtk-demo/search_entry2.c b/demos/gtk-demo/search_entry2.c
index 5e8cb6ac8b..a2033d1e8b 100644
--- a/demos/gtk-demo/search_entry2.c
+++ b/demos/gtk-demo/search_entry2.c
@@ -73,9 +73,7 @@ do_search_entry2 (GtkWidget *do_widget)
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_widget_set_size_request (window, 200, -1);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child (GTK_WINDOW (window), vbox);
@@ -145,7 +143,7 @@ do_search_entry2 (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/shortcut_triggers.c b/demos/gtk-demo/shortcut_triggers.c
index 509a7f5514..126b9f051d 100644
--- a/demos/gtk-demo/shortcut_triggers.c
+++ b/demos/gtk-demo/shortcut_triggers.c
@@ -56,9 +56,7 @@ do_shortcut_triggers (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Shortcuts");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
list = gtk_list_box_new ();
gtk_widget_set_margin_top (list, 6);
@@ -88,7 +86,7 @@ do_shortcut_triggers (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/shortcuts.c b/demos/gtk-demo/shortcuts.c
index 8182035499..941ef77481 100644
--- a/demos/gtk-demo/shortcuts.c
+++ b/demos/gtk-demo/shortcuts.c
@@ -89,8 +89,7 @@ do_shortcuts (GtkWidget *do_widget)
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_object_unref (builder);
}
@@ -98,7 +97,7 @@ do_shortcuts (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/sidebar.c b/demos/gtk-demo/sidebar.c
index 420861f225..965c6d7598 100644
--- a/demos/gtk-demo/sidebar.c
+++ b/demos/gtk-demo/sidebar.c
@@ -43,9 +43,7 @@ do_sidebar (GtkWidget *do_widget)
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR(header), TRUE);
gtk_window_set_titlebar (GTK_WINDOW(window), header);
gtk_window_set_title (GTK_WINDOW(window), "Stack Sidebar");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
sidebar = gtk_stack_sidebar_new ();
@@ -80,7 +78,7 @@ do_sidebar (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/sizegroup.c b/demos/gtk-demo/sizegroup.c
index 9d12dd3551..e61d5ac758 100644
--- a/demos/gtk-demo/sizegroup.c
+++ b/demos/gtk-demo/sizegroup.c
@@ -104,8 +104,7 @@ do_sizegroup (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Size Groups");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
@@ -161,7 +160,7 @@ do_sizegroup (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/sliding_puzzle.c b/demos/gtk-demo/sliding_puzzle.c
index b564e200b5..09e8c4bdbd 100644
--- a/demos/gtk-demo/sliding_puzzle.c
+++ b/demos/gtk-demo/sliding_puzzle.c
@@ -460,8 +460,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Sliding Puzzle");
gtk_window_set_titlebar (GTK_WINDOW (window), header);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
frame = gtk_aspect_frame_new (0.5, 0.5, (float) gdk_paintable_get_intrinsic_aspect_ratio (puzzle), FALSE);
gtk_window_set_child (GTK_WINDOW (window), frame);
@@ -472,7 +471,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/spinbutton.c b/demos/gtk-demo/spinbutton.c
index e50379a8db..307bb52dc1 100644
--- a/demos/gtk-demo/spinbutton.c
+++ b/demos/gtk-demo/spinbutton.c
@@ -196,8 +196,7 @@ do_spinbutton (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Spin Buttons");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
adj = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "basic_adjustment"));
label = GTK_WIDGET (gtk_builder_get_object (builder, "basic_label"));
@@ -238,7 +237,7 @@ do_spinbutton (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/spinner.c b/demos/gtk-demo/spinner.c
index 563438a04c..4582728646 100644
--- a/demos/gtk-demo/spinner.c
+++ b/demos/gtk-demo/spinner.c
@@ -45,9 +45,8 @@ do_spinner (GtkWidget *do_widget)
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_signal_connect (window, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ G_CALLBACK (gtk_window_destroy), NULL);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
@@ -93,7 +92,7 @@ do_spinner (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/stack.c b/demos/gtk-demo/stack.c
index 22969906f0..96c7503ffc 100644
--- a/demos/gtk-demo/stack.c
+++ b/demos/gtk-demo/stack.c
@@ -21,8 +21,7 @@ do_stack (GtkWidget *do_widget)
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_object_unref (builder);
}
@@ -30,7 +29,7 @@ do_stack (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
diff --git a/demos/gtk-demo/tabs.c b/demos/gtk-demo/tabs.c
index 0a046a594e..e4616c71a5 100644
--- a/demos/gtk-demo/tabs.c
+++ b/demos/gtk-demo/tabs.c
@@ -23,9 +23,7 @@ do_tabs (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
view = gtk_text_view_new ();
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
@@ -53,7 +51,7 @@ do_tabs (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/tagged_entry.c b/demos/gtk-demo/tagged_entry.c
index 26795421bc..a17e2d1188 100644
--- a/demos/gtk-demo/tagged_entry.c
+++ b/demos/gtk-demo/tagged_entry.c
@@ -72,8 +72,7 @@ do_tagged_entry (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "A tagged entry");
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_deletable (GTK_WINDOW (window), FALSE);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_widget_set_margin_start (box, 18);
@@ -99,7 +98,7 @@ do_tagged_entry (GtkWidget *do_widget)
button = gtk_button_new_with_mnemonic ("_Done");
gtk_widget_add_css_class (button, "suggested-action");
- g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
@@ -108,7 +107,7 @@ do_tagged_entry (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/textmask.c b/demos/gtk-demo/textmask.c
index ff66ce2961..2869304704 100644
--- a/demos/gtk-demo/textmask.c
+++ b/demos/gtk-demo/textmask.c
@@ -63,9 +63,7 @@ do_textmask (GtkWidget *do_widget)
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_widget_set_size_request (window, 400, 200);
gtk_window_set_title (GTK_WINDOW (window), "Text Mask");
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
da = gtk_drawing_area_new ();
@@ -76,7 +74,7 @@ do_textmask (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/textscroll.c b/demos/gtk-demo/textscroll.c
index 02df96c7a9..6e2b4045fc 100644
--- a/demos/gtk-demo/textscroll.c
+++ b/demos/gtk-demo/textscroll.c
@@ -182,8 +182,7 @@ do_textscroll (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Automatic Scrolling");
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -197,7 +196,7 @@ do_textscroll (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/textundo.c b/demos/gtk-demo/textundo.c
index d7e35e0851..f60aa4d189 100644
--- a/demos/gtk-demo/textundo.c
+++ b/demos/gtk-demo/textundo.c
@@ -26,11 +26,8 @@ do_textundo (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
- gtk_window_set_default_size (GTK_WINDOW (window),
- 450, 450);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "TextView Undo");
@@ -63,7 +60,7 @@ do_textundo (GtkWidget *do_widget)
}
else
{
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
window = NULL;
}
diff --git a/demos/gtk-demo/textview.c b/demos/gtk-demo/textview.c
index 68e0b35c20..bb90358b0c 100644
--- a/demos/gtk-demo/textview.c
+++ b/demos/gtk-demo/textview.c
@@ -477,11 +477,8 @@ do_textview (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
- gtk_window_set_default_size (GTK_WINDOW (window),
- 450, 450);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "Multiple Views");
@@ -526,7 +523,7 @@ do_textview (GtkWidget *do_widget)
}
else
{
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
window = NULL;
}
diff --git a/demos/gtk-demo/themes.c b/demos/gtk-demo/themes.c
index 88191aa157..1560dae952 100644
--- a/demos/gtk-demo/themes.c
+++ b/demos/gtk-demo/themes.c
@@ -178,12 +178,10 @@ do_themes (GtkWidget *do_widget)
builder = gtk_builder_new_from_resource ("/themes/themes.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+
header = GTK_WIDGET (gtk_builder_get_object (builder, "header"));
gesture = gtk_gesture_click_new ();
g_signal_connect (gesture, "pressed", G_CALLBACK (clicked), builder);
@@ -195,7 +193,7 @@ do_themes (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/theming_style_classes.c b/demos/gtk-demo/theming_style_classes.c
index db91d92c5c..011951df32 100644
--- a/demos/gtk-demo/theming_style_classes.c
+++ b/demos/gtk-demo/theming_style_classes.c
@@ -25,8 +25,7 @@ do_theming_style_classes (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Style Classes");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
builder = gtk_builder_new_from_resource ("/theming_style_classes/theming.ui");
@@ -38,7 +37,7 @@ do_theming_style_classes (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/transparent.c b/demos/gtk-demo/transparent.c
index 6d2c010c10..263806e814 100644
--- a/demos/gtk-demo/transparent.c
+++ b/demos/gtk-demo/transparent.c
@@ -22,9 +22,7 @@ do_transparent (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "Transparency");
@@ -64,7 +62,7 @@ do_transparent (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/tree_store.c b/demos/gtk-demo/tree_store.c
index f39b409718..d37d7d2b7d 100644
--- a/demos/gtk-demo/tree_store.c
+++ b/demos/gtk-demo/tree_store.c
@@ -394,8 +394,7 @@ do_tree_store (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Tree Store");
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_widget_set_margin_start (vbox, 8);
@@ -437,7 +436,7 @@ do_tree_store (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/gtk-demo/video_player.c b/demos/gtk-demo/video_player.c
index 6a40204c24..3054f63c8c 100644
--- a/demos/gtk-demo/video_player.c
+++ b/demos/gtk-demo/video_player.c
@@ -23,7 +23,7 @@ open_dialog_response_cb (GtkWidget *dialog,
g_object_unref (file);
}
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -67,8 +67,7 @@ do_video_player (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Video Player");
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
video = gtk_video_new ();
gtk_window_set_child (GTK_WINDOW (window), video);
@@ -89,7 +88,7 @@ do_video_player (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return window;
}
diff --git a/demos/node-editor/node-editor-window.c b/demos/node-editor/node-editor-window.c
index 06214d282c..0c036a4965 100644
--- a/demos/node-editor/node-editor-window.c
+++ b/demos/node-editor/node-editor-window.c
@@ -375,7 +375,7 @@ open_response_cb (GtkWidget *dialog,
g_object_unref (file);
}
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -441,7 +441,7 @@ save_response_cb (GtkWidget *dialog,
"Saving failed");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
"%s", error->message);
- g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (message_dialog);
g_error_free (error);
}
@@ -450,7 +450,7 @@ save_response_cb (GtkWidget *dialog,
g_object_unref (file);
}
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -558,14 +558,14 @@ export_image_response_cb (GtkWidget *dialog,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Exporting to image failed");
- g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (message_dialog);
}
g_object_unref (file);
}
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
g_object_unref (texture);
}
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 9b7cde1946..c394886b9a 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -311,7 +311,7 @@ activate_quit (GSimpleAction *action,
win = list->data;
next = list->next;
- gtk_widget_destroy (GTK_WIDGET (win));
+ gtk_window_destroy (GTK_WINDOW (win));
list = next;
}
diff --git a/docs/reference/gtk/getting_started.xml.in b/docs/reference/gtk/getting_started.xml.in
index 758b4f0d9d..d8e638f6e1 100644
--- a/docs/reference/gtk/getting_started.xml.in
+++ b/docs/reference/gtk/getting_started.xml.in
@@ -194,12 +194,13 @@
a g_signal_connect() with the difference lying in how the callback function is
treated. g_signal_connect_swapped() allows you to specify what the callback
function should take as parameter by letting you pass it as data. In this case
- the function being called back is gtk_widget_destroy() and the
- window pointer is passed to it. This has the effect that when
- the button is clicked, the whole GTK window is destroyed. In contrast, if a normal
- g_signal_connect() were used to connect the "clicked" signal with
- gtk_widget_destroy(), then the button itself would have been
- destroyed, not the window. More information about creating buttons can be found
+ the function being called back is gtk_window_destroy() and the window
+ pointer is passed to it. This has the effect that when the button is clicked,
+ the whole GTK window is destroyed. In contrast if a normal g_signal_connect() were used
+ to connect the "clicked" signal with gtk_window_destroy(), then the function
+ would be called on button (which would not go well, since
+ the function expects a GtkWindow as argument).
+ More information about creating buttons can be found
here.
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 807d92b3a9..8ae806dae1 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -3955,9 +3955,7 @@ GtkCallback
GtkRequisition
GtkAllocation
gtk_widget_new
-gtk_widget_destroy
gtk_widget_in_destruction
-gtk_widget_destroyed
gtk_widget_unparent
gtk_widget_show
gtk_widget_hide
@@ -4191,6 +4189,7 @@ gtk_requisition_get_type
GtkWindow
GtkWindowClass
gtk_window_new
+gtk_window_destroy
gtk_window_get_child
gtk_window_set_child
gtk_window_set_title
@@ -4246,7 +4245,6 @@ gtk_window_get_focus_visible
gtk_window_set_focus_visible
gtk_window_get_application
gtk_window_set_application
-gtk_window_set_has_user_ref_count
gtk_window_set_titlebar
gtk_window_get_titlebar
gtk_window_set_interactive_debugging
diff --git a/docs/reference/gtk/question_index.xml b/docs/reference/gtk/question_index.xml
index 0cd8062185..3353b754f0 100644
--- a/docs/reference/gtk/question_index.xml
+++ b/docs/reference/gtk/question_index.xml
@@ -123,8 +123,8 @@ after creating it ?
If GtkFoo isn't a toplevel window, then
- foo = gtk_foo_new ();
- gtk_widget_destroy (foo);
+ foo = gtk_foo_new ();
+ g_object_unref (foo);
is a memory leak, because no one assumed the initial floating
reference. If you are using a widget and you aren't immediately
@@ -137,19 +137,12 @@ To get this, you must acquire a reference to the widget and drop the
floating reference (ref and sink
in GTK parlance) after
creating it:
- foo = gtk_foo_new ();
+ foo = gtk_foo_new ();
g_object_ref_sink (foo);
-When you want to get rid of the widget, you must call gtk_widget_destroy()
-to break any external connections to the widget before dropping your
-reference:
-
- gtk_widget_destroy (foo);
- g_object_unref (foo);
-
When you immediately add a widget to a container, it takes care of
assuming the initial floating reference and you don't have to worry
-about reference counting at all ... just call gtk_widget_destroy()
+about reference counting at all ... just call gtk_container_remove()
to get rid of the widget.
diff --git a/docs/tools/shooter.c b/docs/tools/shooter.c
index 8f2fff6f16..ae2dc14f92 100644
--- a/docs/tools/shooter.c
+++ b/docs/tools/shooter.c
@@ -247,7 +247,7 @@ shoot_one (WidgetInfo *info)
{
g_warning ("unable to save shot of %s", info->name);
}
- gtk_widget_destroy (info->window);
+ gtk_window_destroy (GTK_WINDOW (info->window));
shot_id = 0;
diff --git a/examples/action-namespace.c b/examples/action-namespace.c
index 642b7c8fca..aa4074e9d9 100644
--- a/examples/action-namespace.c
+++ b/examples/action-namespace.c
@@ -16,7 +16,7 @@ action_activated (GSimpleAction *action,
g_action_get_name (G_ACTION (action)));
g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
+ G_CALLBACK (gtk_window_destroy), dialog);
gtk_widget_show (dialog);
}
diff --git a/examples/bp/bloatpad.c b/examples/bp/bloatpad.c
index be6bee5aa6..0da7402374 100644
--- a/examples/bp/bloatpad.c
+++ b/examples/bp/bloatpad.c
@@ -374,7 +374,7 @@ response (GtkDialog *dialog,
if (response_id == GTK_RESPONSE_CLOSE)
{
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
return;
}
diff --git a/examples/grid-packing.c b/examples/grid-packing.c
index dcee10f712..7d98c9a1db 100644
--- a/examples/grid-packing.c
+++ b/examples/grid-packing.c
@@ -42,7 +42,7 @@ activate (GtkApplication *app,
gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 1);
button = gtk_button_new_with_label ("Quit");
- g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
/* Place the Quit button in the grid cell (0, 1), and make it
* span 2 columns.
diff --git a/examples/hello-world.c b/examples/hello-world.c
index ebafc735c6..5ee7062788 100644
--- a/examples/hello-world.c
+++ b/examples/hello-world.c
@@ -24,7 +24,7 @@ activate (GtkApplication *app,
button = gtk_button_new_with_label ("Hello World");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
- g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
gtk_container_add (GTK_CONTAINER (box), button);
gtk_widget_show (window);
diff --git a/examples/plugman.c b/examples/plugman.c
index 752e2b9649..0e0882fcb5 100644
--- a/examples/plugman.c
+++ b/examples/plugman.c
@@ -173,7 +173,7 @@ quit_app (GSimpleAction *action,
win = list->data;
next = list->next;
- gtk_widget_destroy (GTK_WIDGET (win));
+ gtk_window_destroy (GTK_WINDOW (win));
list = next;
}
@@ -382,7 +382,7 @@ configure_plugins (GSimpleAction *action,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), plugin_enabled ("black"));
g_signal_connect (check, "toggled", G_CALLBACK (enable_or_disable_plugin), (char *) "black");
- g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_window_present (GTK_WINDOW (dialog));
diff --git a/examples/sunny.c b/examples/sunny.c
index acb1341e0a..1bb3284eeb 100644
--- a/examples/sunny.c
+++ b/examples/sunny.c
@@ -101,7 +101,7 @@ quit_app (GSimpleAction *action,
win = list->data;
next = list->next;
- gtk_widget_destroy (GTK_WIDGET (win));
+ gtk_window_destroy (GTK_WINDOW (win));
list = next;
}
diff --git a/gtk/gtkappchooserbutton.c b/gtk/gtkappchooserbutton.c
index d8a8e66e3c..2622b3bb72 100644
--- a/gtk/gtkappchooserbutton.c
+++ b/gtk/gtkappchooserbutton.c
@@ -249,13 +249,13 @@ other_application_dialog_response_cb (GtkDialog *dialog,
* 'Other application…'
*/
gtk_combo_box_set_active (GTK_COMBO_BOX (self->combobox), self->last_active);
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
return;
}
info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
/* refresh the combobox to get the new application */
gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
diff --git a/gtk/gtkappchooserdialog.c b/gtk/gtkappchooserdialog.c
index 095b024d5d..be0e9c6c4d 100644
--- a/gtk/gtkappchooserdialog.c
+++ b/gtk/gtkappchooserdialog.c
@@ -400,7 +400,7 @@ show_error_dialog (const gchar *primary,
gtk_widget_show (message_dialog);
g_signal_connect (message_dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
}
static void
diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c
index 76172684b2..9f13ef1799 100644
--- a/gtk/gtkapplicationwindow.c
+++ b/gtk/gtkapplicationwindow.c
@@ -724,7 +724,7 @@ gtk_application_window_dispose (GObject *object)
if (priv->help_overlay)
{
- gtk_widget_destroy (GTK_WIDGET (priv->help_overlay));
+ gtk_window_destroy (GTK_WINDOW (priv->help_overlay));
g_clear_object (&priv->help_overlay);
}
@@ -922,7 +922,7 @@ gtk_application_window_set_help_overlay (GtkApplicationWindow *window,
g_return_if_fail (help_overlay == NULL || GTK_IS_SHORTCUTS_WINDOW (help_overlay));
if (priv->help_overlay)
- gtk_widget_destroy (GTK_WIDGET (priv->help_overlay));
+ gtk_window_destroy (GTK_WINDOW (priv->help_overlay));
g_set_object (&priv->help_overlay, help_overlay);
if (!priv->help_overlay)
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index a4351bade1..803180c65f 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -39,14 +39,14 @@
* and drops these references when it is finalized. This finalization can
* cause the destruction of non-widget objects or widgets which are not
* contained in a toplevel window. For toplevel windows constructed by a
- * builder, it is the responsibility of the user to call gtk_widget_destroy()
+ * builder, it is the responsibility of the user to call gtk_window_destroy()
* to get rid of them and all the widgets they contain.
*
* The functions gtk_builder_get_object() and gtk_builder_get_objects()
* can be used to access the widgets in the interface by the names assigned
* to them inside the UI description. Toplevel windows returned by these
* functions will stay around until the user explicitly destroys them
- * with gtk_widget_destroy(). Other widgets will either be part of a
+ * with gtk_window_destroy(). Other widgets will either be part of a
* larger hierarchy constructed by the builder (in which case you should
* not have to worry about their lifecycle), or without a parent, in which
* case they have to be added to some container to make use of them.
diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c
index 865c239abf..2058a44951 100644
--- a/gtk/gtkcolorbutton.c
+++ b/gtk/gtkcolorbutton.c
@@ -309,7 +309,7 @@ gtk_color_button_finalize (GObject *object)
GtkColorButton *button = GTK_COLOR_BUTTON (object);
if (button->cs_dialog != NULL)
- gtk_widget_destroy (button->cs_dialog);
+ gtk_window_destroy (GTK_WINDOW (button->cs_dialog));
g_free (button->title);
gtk_widget_unparent (button->button);
diff --git a/gtk/gtkcolorchooserdialog.c b/gtk/gtkcolorchooserdialog.c
index 4e3659c0e4..7e748400b7 100644
--- a/gtk/gtkcolorchooserdialog.c
+++ b/gtk/gtkcolorchooserdialog.c
@@ -191,12 +191,23 @@ gtk_color_chooser_dialog_set_property (GObject *object,
}
}
+static void
+gtk_color_chooser_dialog_dispose (GObject *object)
+{
+ GtkColorChooserDialog *cc = GTK_COLOR_CHOOSER_DIALOG (object);
+
+ g_clear_pointer (&cc->chooser, gtk_widget_unparent);
+
+ G_OBJECT_CLASS (gtk_color_chooser_dialog_parent_class)->dispose (object);
+}
+
static void
gtk_color_chooser_dialog_class_init (GtkColorChooserDialogClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+ object_class->dispose = gtk_color_chooser_dialog_dispose;
object_class->get_property = gtk_color_chooser_dialog_get_property;
object_class->set_property = gtk_color_chooser_dialog_set_property;
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index f9aaae6df4..3d1a4b7071 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -220,12 +220,19 @@ 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);
}
@@ -281,14 +288,12 @@ gtk_container_add (GtkContainer *container,
* @widget: a current child of @container
*
* Removes @widget from @container. @widget must be inside @container.
+ *
* Note that @container will own a reference to @widget, and that this
* may be the last reference held; so removing a widget from its
* container can destroy that widget. If you want to use @widget
* again, you need to add a reference to it before removing it from
- * a container, using g_object_ref(). If you don’t want to use @widget
- * again it’s usually more efficient to simply destroy it directly
- * using gtk_widget_destroy() since this will remove it from the
- * container and help break any circular reference count cycles.
+ * a container, using g_object_ref().
**/
void
gtk_container_remove (GtkContainer *container,
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index f0c73d67f9..106e1e0ee7 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -118,7 +118,7 @@
*
* g_signal_connect_swapped (dialog,
* "response",
- * G_CALLBACK (gtk_widget_destroy),
+ * G_CALLBACK (gtk_window_destroy),
* dialog);
*
* // Add the label, and show everything we’ve added
@@ -1141,7 +1141,7 @@ run_destroy_handler (GtkDialog *dialog, gpointer data)
* // do_nothing_since_dialog_was_cancelled ();
* break;
* }
- * gtk_widget_destroy (dialog);
+ * gtk_window_destroy (dialog);
* ]|
*
* Note that even though the recursive main loop gives the effect of a
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/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index 130276ed3a..29cc1e467f 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -1094,7 +1094,7 @@ gtk_file_chooser_button_dispose (GObject *object)
g_clear_object (&button->model);
}
- g_clear_pointer (&button->dialog, gtk_widget_destroy);
+ g_clear_pointer ((GtkWindow **)&button->dialog, gtk_window_destroy);
if (button->native)
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (button->native));
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c
index 4f5e9f6ca4..1eae65ae18 100644
--- a/gtk/gtkfilechooserdialog.c
+++ b/gtk/gtkfilechooserdialog.c
@@ -91,7 +91,7 @@
* open_file (file);
* }
*
- * gtk_widget_destroy (dialog);
+ * gtk_window_destroy (dialog);
* ]|
*
* To use a dialog for saving, you can use this:
@@ -124,7 +124,7 @@
* save_to_file (file);
* }
*
- * gtk_widget_destroy (dialog);
+ * gtk_window_destroy (dialog);
* ]|
*
* ## Setting up a file chooser dialog ## {#gtkfilechooserdialog-setting-up}
@@ -221,6 +221,7 @@ struct _GtkFileChooserDialogPrivate
gboolean has_entry;
};
+static void gtk_file_chooser_dialog_dispose (GObject *object);
static void gtk_file_chooser_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -262,6 +263,7 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class)
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+ gobject_class->dispose = gtk_file_chooser_dialog_dispose;
gobject_class->set_property = gtk_file_chooser_dialog_set_property;
gobject_class->get_property = gtk_file_chooser_dialog_get_property;
gobject_class->notify = gtk_file_chooser_dialog_notify;
@@ -387,6 +389,16 @@ file_chooser_widget_response_requested (GtkWidget *widget,
priv->response_requested = FALSE;
}
+static void
+gtk_file_chooser_dialog_dispose (GObject *object)
+{
+ GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (GTK_FILE_CHOOSER_DIALOG (object));
+
+ g_clear_pointer ((GtkWidget **)&priv->widget, gtk_widget_unparent);
+
+ G_OBJECT_CLASS (gtk_file_chooser_dialog_parent_class)->dispose (object);
+}
+
static void
gtk_file_chooser_dialog_set_property (GObject *object,
guint prop_id,
diff --git a/gtk/gtkfilechoosernative.c b/gtk/gtkfilechoosernative.c
index 184f6d268f..0abb9201ab 100644
--- a/gtk/gtkfilechoosernative.c
+++ b/gtk/gtkfilechoosernative.c
@@ -493,7 +493,7 @@ gtk_file_chooser_native_finalize (GObject *object)
g_clear_pointer (&self->accept_label, g_free);
g_clear_pointer (&self->cancel_label, g_free);
- gtk_widget_destroy (self->dialog);
+ gtk_window_destroy (GTK_WINDOW (self->dialog));
g_slist_free_full (self->custom_files, g_object_unref);
g_slist_free_full (self->choices, (GDestroyNotify)gtk_file_chooser_native_choice_free);
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 6dae50bb0d..4c61e180f8 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -766,7 +766,7 @@ error_message (GtkFileChooserWidget *impl,
GTK_WINDOW (dialog));
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
@@ -1261,7 +1261,7 @@ confirm_delete (GtkFileChooserWidget *impl,
response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
return (response == GTK_RESPONSE_ACCEPT);
}
@@ -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);
@@ -5761,7 +5761,7 @@ confirm_dialog_should_accept_filename (GtkFileChooserWidget *impl,
* file list (will be restablished on next map()). Fixes data loss bug #2288 */
impl->browse_files_interaction_frozen = TRUE;
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
return (response == GTK_RESPONSE_ACCEPT);
}
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/gtkfontbutton.c b/gtk/gtkfontbutton.c
index 01fa0bf0c7..a0a9e0162f 100644
--- a/gtk/gtkfontbutton.c
+++ b/gtk/gtkfontbutton.c
@@ -586,8 +586,8 @@ gtk_font_button_finalize (GObject *object)
{
GtkFontButton *font_button = GTK_FONT_BUTTON (object);
- if (font_button->font_dialog != NULL)
- gtk_widget_destroy (font_button->font_dialog);
+ if (font_button->font_dialog != NULL)
+ gtk_window_destroy (GTK_WINDOW (font_button->font_dialog));
g_free (font_button->title);
diff --git a/gtk/gtkfontchooserdialog.c b/gtk/gtkfontchooserdialog.c
index 11d17c9668..9083806f89 100644
--- a/gtk/gtkfontchooserdialog.c
+++ b/gtk/gtkfontchooserdialog.c
@@ -48,7 +48,6 @@ struct _GtkFontChooserDialog
GtkDialog parent_instance;
GtkWidget *fontchooser;
-
GtkWidget *select_button;
GtkWidget *cancel_button;
GtkWidget *tweak_button;
@@ -200,12 +199,49 @@ gtk_font_chooser_dialog_map (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_font_chooser_dialog_parent_class)->map (widget);
}
+static void
+update_button (GtkFontChooserDialog *dialog)
+{
+ PangoFontDescription *desc;
+
+ desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (dialog->fontchooser));
+
+ gtk_widget_set_sensitive (dialog->select_button, desc != NULL);
+
+ if (desc)
+ pango_font_description_free (desc);
+}
+
+static void
+gtk_font_chooser_dialog_dispose (GObject *object)
+{
+ GtkFontChooserDialog *dialog = GTK_FONT_CHOOSER_DIALOG (object);
+
+ if (dialog->fontchooser)
+ {
+ g_signal_handlers_disconnect_by_func (dialog->fontchooser,
+ update_button,
+ dialog);
+ g_signal_handlers_disconnect_by_func (dialog->fontchooser,
+ update_tweak_button,
+ dialog);
+ }
+
+ g_clear_pointer (&dialog->select_button, gtk_widget_unparent);
+ g_clear_pointer (&dialog->cancel_button, gtk_widget_unparent);
+ g_clear_pointer (&dialog->tweak_button, gtk_widget_unparent);
+ g_clear_pointer (&dialog->fontchooser, gtk_widget_unparent);
+
+ G_OBJECT_CLASS (gtk_font_chooser_dialog_parent_class)->dispose (object);
+}
+
static void
gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ gobject_class->dispose = gtk_font_chooser_dialog_dispose;
gobject_class->get_property = gtk_font_chooser_dialog_get_property;
gobject_class->set_property = gtk_font_chooser_dialog_set_property;
@@ -225,20 +261,6 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
gtk_widget_class_bind_template_callback (widget_class, dialog_forward_key);
}
-static void
-update_button (GtkFontChooserDialog *dialog)
-{
- PangoFontDescription *desc;
-
- desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (dialog->fontchooser));
-
- gtk_widget_set_sensitive (dialog->select_button, desc != NULL);
-
- if (desc)
- pango_font_description_free (desc);
-}
-
-
static void
gtk_font_chooser_dialog_init (GtkFontChooserDialog *dialog)
{
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/gtkmessagedialog.c b/gtk/gtkmessagedialog.c
index 5b434049b3..1f6abc9e9f 100644
--- a/gtk/gtkmessagedialog.c
+++ b/gtk/gtkmessagedialog.c
@@ -65,7 +65,7 @@
* filename,
* g_strerror (errno));
* gtk_dialog_run (GTK_DIALOG (dialog));
- * gtk_widget_destroy (dialog);
+ * gtk_window_destroy (GTK_WINDOW (dialog));
* ]|
*
* You might do a non-modal #GtkMessageDialog as follows:
@@ -85,7 +85,7 @@
* // (e.g. clicks a button)
*
* g_signal_connect_swapped (dialog, "response",
- * G_CALLBACK (gtk_widget_destroy),
+ * G_CALLBACK (gtk_window_destroy),
* dialog);
* ]|
*
diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c
index e58bae6ac6..8b91dc6dbb 100644
--- a/gtk/gtkmountoperation.c
+++ b/gtk/gtkmountoperation.c
@@ -218,6 +218,13 @@ gtk_mount_operation_init (GtkMountOperation *operation)
g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (operation->priv->handler), G_MAXINT);
}
+static void
+parent_destroyed (GtkWidget *parent,
+ gpointer **pointer)
+{
+ *pointer = NULL;
+}
+
static void
gtk_mount_operation_finalize (GObject *object)
{
@@ -230,7 +237,7 @@ gtk_mount_operation_finalize (GObject *object)
if (priv->parent_window)
{
g_signal_handlers_disconnect_by_func (priv->parent_window,
- gtk_widget_destroyed,
+ parent_destroyed,
&priv->parent_window);
g_object_unref (priv->parent_window);
}
@@ -392,7 +399,7 @@ pw_dialog_got_response (GtkDialog *dialog,
priv->dialog = NULL;
g_object_notify (G_OBJECT (op), "is-showing");
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
g_object_unref (op);
}
@@ -921,7 +928,7 @@ question_dialog_button_clicked (GtkDialog *dialog,
priv->dialog = NULL;
g_object_notify (G_OBJECT (operation), "is-showing");
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
g_object_unref (op);
}
@@ -1076,7 +1083,7 @@ show_processes_button_clicked (GtkDialog *dialog,
priv->dialog = NULL;
g_object_notify (G_OBJECT (operation), "is-showing");
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
g_object_unref (op);
}
@@ -1396,7 +1403,7 @@ on_end_process_activated (GtkModelButton *button,
* destroy the dialog in that case
*/
if (response != GTK_RESPONSE_NONE)
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
g_error_free (error);
}
@@ -1759,7 +1766,7 @@ gtk_mount_operation_aborted (GMountOperation *op)
if (priv->dialog != NULL)
{
- gtk_widget_destroy (GTK_WIDGET (priv->dialog));
+ gtk_window_destroy (GTK_WINDOW (priv->dialog));
priv->dialog = NULL;
g_object_notify (G_OBJECT (op), "is-showing");
g_object_unref (op);
@@ -1835,7 +1842,7 @@ gtk_mount_operation_set_parent (GtkMountOperation *op,
if (priv->parent_window)
{
g_signal_handlers_disconnect_by_func (priv->parent_window,
- gtk_widget_destroyed,
+ parent_destroyed,
&priv->parent_window);
g_object_unref (priv->parent_window);
}
@@ -1844,8 +1851,7 @@ gtk_mount_operation_set_parent (GtkMountOperation *op,
{
g_object_ref (priv->parent_window);
g_signal_connect (priv->parent_window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &priv->parent_window);
+ G_CALLBACK (parent_destroyed), &priv->parent_window);
}
if (priv->dialog)
diff --git a/gtk/gtknativedialog.c b/gtk/gtknativedialog.c
index c97c6c0697..1a060be27a 100644
--- a/gtk/gtknativedialog.c
+++ b/gtk/gtknativedialog.c
@@ -168,12 +168,21 @@ gtk_native_dialog_get_property (GObject *object,
}
}
+static void parent_destroyed (GtkWidget *parent,
+ GtkNativeDialog *self);
+
static void
gtk_native_dialog_dispose (GObject *object)
{
GtkNativeDialog *self = GTK_NATIVE_DIALOG (object);
GtkNativeDialogPrivate *priv = gtk_native_dialog_get_instance_private (self);
+ if (priv->transient_for)
+ {
+ g_signal_handlers_disconnect_by_func (priv->transient_for, parent_destroyed, self);
+ priv->transient_for = NULL;
+ }
+
if (priv->visible)
gtk_native_dialog_hide (self);
@@ -486,6 +495,15 @@ gtk_native_dialog_get_title (GtkNativeDialog *self)
return priv->title;
}
+static void
+parent_destroyed (GtkWidget *parent,
+ GtkNativeDialog *self)
+{
+ GtkNativeDialogPrivate *priv = gtk_native_dialog_get_instance_private (self);
+
+ priv->transient_for = NULL;
+}
+
/**
* gtk_native_dialog_set_transient_for:
* @self: a #GtkNativeDialog
@@ -501,14 +519,24 @@ gtk_native_dialog_get_title (GtkNativeDialog *self)
*/
void
gtk_native_dialog_set_transient_for (GtkNativeDialog *self,
- GtkWindow *parent)
+ GtkWindow *parent)
{
GtkNativeDialogPrivate *priv = gtk_native_dialog_get_instance_private (self);
g_return_if_fail (GTK_IS_NATIVE_DIALOG (self));
- if (g_set_object (&priv->transient_for, parent))
- g_object_notify_by_pspec (G_OBJECT (self), native_props[PROP_TRANSIENT_FOR]);
+ if (parent == priv->transient_for)
+ return;
+
+ if (priv->transient_for)
+ g_signal_handlers_disconnect_by_func (priv->transient_for, parent_destroyed, self);
+
+ priv->transient_for = parent;
+
+ if (parent)
+ g_signal_connect (parent, "destroy", G_CALLBACK (parent_destroyed), self);
+
+ g_object_notify_by_pspec (G_OBJECT (self), native_props[PROP_TRANSIENT_FOR]);
}
/**
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/gtkpagesetupunixdialog.c b/gtk/gtkpagesetupunixdialog.c
index 030b5a9b4b..a0a0f3c4c9 100644
--- a/gtk/gtkpagesetupunixdialog.c
+++ b/gtk/gtkpagesetupunixdialog.c
@@ -762,7 +762,7 @@ custom_paper_dialog_response_cb (GtkDialog *custom_paper_dialog,
/* Update printer page list */
printer_changed_callback (GTK_COMBO_BOX (priv->printer_combo), dialog);
- gtk_widget_destroy (GTK_WIDGET (custom_paper_dialog));
+ gtk_window_destroy (GTK_WINDOW (custom_paper_dialog));
}
static void
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/gtkpopover.c b/gtk/gtkpopover.c
index ccf55e48f3..8a0d3e9e3d 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -1025,6 +1025,7 @@ gtk_popover_dispose (GObject *object)
GtkPopover *popover = GTK_POPOVER (object);
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
+ g_clear_object (&priv->default_widget);
g_clear_pointer (&priv->contents_widget, gtk_widget_unparent);
g_clear_pointer (&priv->arrow_render_node, gsk_render_node_unref);
diff --git a/gtk/gtkprintbackend.c b/gtk/gtkprintbackend.c
index 878d2d0dd5..9ec37814f0 100644
--- a/gtk/gtkprintbackend.c
+++ b/gtk/gtkprintbackend.c
@@ -622,7 +622,7 @@ password_dialog_response (GtkWidget *dialog,
g_clear_pointer (&priv->auth_info, g_free);
g_clear_pointer (&priv->auth_info_required, g_strfreev);
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
g_object_unref (backend);
}
diff --git a/gtk/gtkprinteroptionwidget.c b/gtk/gtkprinteroptionwidget.c
index 7cff48186d..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
@@ -512,7 +484,7 @@ dialog_response_callback (GtkDialog *dialog,
g_object_unref (new_location);
}
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
if (new_location)
uri = g_file_get_uri (new_location);
diff --git a/gtk/gtkprintoperation-unix.c b/gtk/gtkprintoperation-unix.c
index 45584d28bd..ba79ea0bca 100644
--- a/gtk/gtkprintoperation-unix.c
+++ b/gtk/gtkprintoperation-unix.c
@@ -656,7 +656,7 @@ handle_print_response (GtkWidget *dialog,
if (settings)
g_object_unref (settings);
- gtk_widget_destroy (GTK_WIDGET (pd));
+ gtk_window_destroy (GTK_WINDOW (pd));
}
@@ -922,7 +922,7 @@ handle_page_setup_response (GtkWidget *dialog,
if (response == GTK_RESPONSE_OK)
rdata->page_setup = gtk_page_setup_unix_dialog_get_page_setup (psd);
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
if (rdata->done_cb)
rdata->done_cb (rdata->page_setup, rdata->data);
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/gtkprintoperation.c b/gtk/gtkprintoperation.c
index 0a8647f64a..9f21634fc4 100644
--- a/gtk/gtkprintoperation.c
+++ b/gtk/gtkprintoperation.c
@@ -2203,7 +2203,7 @@ print_pages_idle_done (gpointer user_data)
}
if (data->progress)
- gtk_widget_destroy (data->progress);
+ gtk_window_destroy (GTK_WINDOW (data->progress));
if (priv->rloop && !data->is_preview)
g_main_loop_quit (priv->rloop);
@@ -2899,7 +2899,7 @@ print_pages (GtkPrintOperation *op,
GTK_WINDOW (error_dialog));
g_signal_connect (error_dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (error_dialog);
@@ -3022,7 +3022,7 @@ gtk_print_operation_get_error (GtkPrintOperation *op,
* "Error printing file:\n%s",
* error->message);
* g_signal_connect (error_dialog, "response",
- * G_CALLBACK (gtk_widget_destroy), NULL);
+ * G_CALLBACK (gtk_window_destroy), NULL);
* gtk_widget_show (error_dialog);
* g_error_free (error);
* }
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index 3d755fff78..a4a6db0559 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -684,7 +684,7 @@ error_dialogs (GtkPrintUnixDialog *dialog,
response = gtk_dialog_run (GTK_DIALOG (message_dialog));
- gtk_widget_destroy (message_dialog);
+ gtk_window_destroy (GTK_WINDOW (message_dialog));
g_free (dirname);
g_free (basename);
@@ -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);
}
}
@@ -1940,36 +1938,24 @@ options_changed_cb (GtkPrintUnixDialog *dialog)
dialog->waiting_for_printer = NULL;
}
-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
@@ -3220,7 +3206,7 @@ custom_paper_dialog_response_cb (GtkDialog *custom_paper_dialog,
}
}
- gtk_widget_destroy (GTK_WIDGET (custom_paper_dialog));
+ gtk_window_destroy (GTK_WINDOW (custom_paper_dialog));
}
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/gtktooltip.c b/gtk/gtktooltip.c
index fc9e665444..4af709f19e 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -990,3 +990,17 @@ gtk_tooltip_maybe_allocate (GtkNative *native)
gtk_native_check_resize (GTK_NATIVE (tooltip->window));
}
+
+void
+gtk_tooltip_unset_surface (GtkNative *native)
+{
+ GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (native));
+ GtkTooltip *tooltip;
+
+ tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
+ if (!tooltip || GTK_NATIVE (tooltip->native) != native)
+ return;
+
+ gtk_tooltip_set_surface (tooltip, NULL);
+}
+
diff --git a/gtk/gtktooltipprivate.h b/gtk/gtktooltipprivate.h
index ca63406b2c..8f48433775 100644
--- a/gtk/gtktooltipprivate.h
+++ b/gtk/gtktooltipprivate.h
@@ -44,6 +44,7 @@ GtkWidget * _gtk_widget_find_at_coords (GdkSurface *surface,
gint *widget_y);
void gtk_tooltip_maybe_allocate (GtkNative *native);
+void gtk_tooltip_unset_surface (GtkNative *native);
G_END_DECLS
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/gtkwidget.c b/gtk/gtkwidget.c
index b7c14e5223..d1476d3828 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2610,78 +2610,6 @@ gtk_widget_unparent (GtkWidget *widget)
g_object_unref (widget);
}
-/**
- * gtk_widget_destroy:
- * @widget: a #GtkWidget
- *
- * Destroys a widget.
- *
- * When a widget is destroyed all references it holds on other objects
- * will be released:
- *
- * - if the widget is inside a container, it will be removed from its
- * parent
- * - if the widget is a container, all its children will be destroyed,
- * recursively
- * - if the widget is a top level, it will be removed from the list
- * of top level widgets that GTK+ maintains internally
- *
- * It's expected that all references held on the widget will also
- * be released; you should connect to the #GtkWidget::destroy signal
- * if you hold a reference to @widget and you wish to remove it when
- * this function is called. It is not necessary to do so if you are
- * implementing a #GtkContainer, as you'll be able to use the
- * #GtkContainerClass.remove() virtual function for that.
- *
- * It's important to notice that gtk_widget_destroy() will only cause
- * the @widget to be finalized if no additional references, acquired
- * using g_object_ref(), are held on it. In case additional references
- * are in place, the @widget will be in an "inert" state after calling
- * this function; @widget will still point to valid memory, allowing you
- * to release the references you hold, but you may not query the widget's
- * own state.
- *
- * You should typically call this function on top level widgets, and
- * rarely on child widgets.
- *
- * See also: gtk_container_remove()
- */
-void
-gtk_widget_destroy (GtkWidget *widget)
-{
- GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- if (!priv->in_destruction)
- g_object_run_dispose (G_OBJECT (widget));
-}
-
-/**
- * gtk_widget_destroyed:
- * @widget: a #GtkWidget
- * @widget_pointer: (inout) (transfer none): address of a variable that contains @widget
- *
- * This function sets *@widget_pointer to %NULL if @widget_pointer !=
- * %NULL. It’s intended to be used as a callback connected to the
- * “destroy” signal of a widget. You connect gtk_widget_destroyed()
- * as a signal handler, and pass the address of your widget variable
- * as user data. Then when the widget is destroyed, the variable will
- * be set to %NULL. Useful for example to avoid multiple copies
- * of the same dialog.
- **/
-void
-gtk_widget_destroyed (GtkWidget *widget,
- GtkWidget **widget_pointer)
-{
- /* Don't make any assumptions about the
- * value of widget!
- * Even check widget_pointer.
- */
- if (widget_pointer)
- *widget_pointer = NULL;
-}
-
static void
gtk_widget_update_paintables (GtkWidget *widget)
{
@@ -7349,7 +7277,7 @@ gtk_widget_real_destroy (GtkWidget *object)
FinalizeAssertion *assertion = l->data;
if (!assertion->did_finalize)
- g_critical ("Automated component '%s' of class '%s' did not finalize in gtk_widget_destroy(). "
+ g_critical ("Automated component '%s' of class '%s' did not finalize in dispose()"
"Current reference count is %d",
assertion->child_class->name,
g_type_name (assertion->widget_type),
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index f18ae9899e..85f8bedb9c 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -300,11 +300,6 @@ GtkWidget* gtk_widget_new (GType type,
const gchar *first_property_name,
...);
GDK_AVAILABLE_IN_ALL
-void gtk_widget_destroy (GtkWidget *widget);
-GDK_AVAILABLE_IN_ALL
-void gtk_widget_destroyed (GtkWidget *widget,
- GtkWidget **widget_pointer);
-GDK_AVAILABLE_IN_ALL
void gtk_widget_unparent (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_widget_show (GtkWidget *widget);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index fc949183cc..ce94190e44 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;
@@ -219,7 +218,6 @@ typedef struct
guint deletable : 1;
guint destroy_with_parent : 1;
guint fullscreen_initially : 1;
- guint has_user_ref_count : 1;
guint minimize_initially : 1;
guint is_active : 1;
guint maximize_initially : 1;
@@ -1204,7 +1202,7 @@ gtk_window_close (GtkWindow *window)
g_object_ref (window);
if (!gtk_window_emit_close_request (window))
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (window);
g_object_unref (window);
}
@@ -1555,7 +1553,6 @@ gtk_window_init (GtkWindow *window)
priv->initial_fullscreen_monitor = NULL;
g_object_ref_sink (window);
- priv->has_user_ref_count = TRUE;
#ifdef GDK_WINDOWING_X11
g_signal_connect (gtk_settings_get_for_display (priv->display),
@@ -1981,7 +1978,7 @@ gtk_window_native_interface_init (GtkNativeInterface *iface)
* the window internally, gtk_window_new() does not return a reference
* to the caller.
*
- * To delete a #GtkWindow, call gtk_widget_destroy().
+ * To delete a #GtkWindow, call gtk_window_destroy().
*
* Returns: a new #GtkWindow.
**/
@@ -2368,31 +2365,12 @@ gtk_window_dispose (GObject *object)
{
GtkWindow *window = GTK_WINDOW (object);
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- guint i;
gtk_window_release_application (window);
- for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (toplevel_list)); i++)
- {
- gpointer item = g_list_model_get_item (G_LIST_MODEL (toplevel_list), i);
- if (item == window)
- {
- g_list_store_remove (toplevel_list, i);
- break;
- }
- else
- g_object_unref (item);
- }
-
if (priv->transient_parent)
gtk_window_set_transient_for (window, NULL);
- if (priv->has_user_ref_count)
- {
- priv->has_user_ref_count = FALSE;
- g_object_unref (window);
- }
-
if (priv->group)
gtk_window_group_remove_window (priv->group, window);
@@ -2410,41 +2388,20 @@ gtk_window_dispose (GObject *object)
}
static void
-parent_destroyed_callback (GtkWindow *parent, GtkWindow *child)
+gtk_window_transient_parent_destroyed (GtkWindow *parent,
+ GtkWindow *window)
{
- gtk_widget_destroy (GTK_WIDGET (child));
-}
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (window));
-static void
-connect_parent_destroyed (GtkWindow *window)
-{
- GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
-
- if (priv->transient_parent)
- {
- g_signal_connect (priv->transient_parent,
- "destroy",
- G_CALLBACK (parent_destroyed_callback),
- window);
- }
-}
-
-static void
-disconnect_parent_destroyed (GtkWindow *window)
-{
- GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
-
- if (priv->transient_parent)
- {
- g_signal_handlers_disconnect_by_func (priv->transient_parent,
- parent_destroyed_callback,
- window);
- }
+ if (priv->destroy_with_parent)
+ gtk_window_destroy (window);
+ else
+ priv->transient_parent = NULL;
}
static void
gtk_window_transient_parent_realized (GtkWidget *parent,
- GtkWidget *window)
+ GtkWidget *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (window));
GtkWindowPrivate *parent_priv = gtk_window_get_instance_private (GTK_WINDOW (parent));
@@ -2454,7 +2411,7 @@ gtk_window_transient_parent_realized (GtkWidget *parent,
static void
gtk_window_transient_parent_unrealized (GtkWidget *parent,
- GtkWidget *window)
+ GtkWidget *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (window));
if (_gtk_widget_get_realized (window))
@@ -2462,7 +2419,7 @@ gtk_window_transient_parent_unrealized (GtkWidget *parent,
}
static void
-gtk_window_transient_parent_display_changed (GtkWindow *parent,
+gtk_window_transient_parent_display_changed (GtkWindow *parent,
GParamSpec *pspec,
GtkWindow *window)
{
@@ -2471,7 +2428,7 @@ gtk_window_transient_parent_display_changed (GtkWindow *parent,
gtk_window_set_display (window, parent_priv->display);
}
-static void
+static void
gtk_window_unset_transient_for (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
@@ -2479,29 +2436,25 @@ gtk_window_unset_transient_for (GtkWindow *window)
if (priv->transient_parent)
{
g_signal_handlers_disconnect_by_func (priv->transient_parent,
- gtk_window_transient_parent_realized,
- window);
+ gtk_window_transient_parent_realized,
+ window);
g_signal_handlers_disconnect_by_func (priv->transient_parent,
- gtk_window_transient_parent_unrealized,
- window);
+ gtk_window_transient_parent_unrealized,
+ window);
g_signal_handlers_disconnect_by_func (priv->transient_parent,
- gtk_window_transient_parent_display_changed,
- window);
+ gtk_window_transient_parent_display_changed,
+ window);
g_signal_handlers_disconnect_by_func (priv->transient_parent,
- gtk_widget_destroyed,
- &priv->transient_parent);
-
- if (priv->destroy_with_parent)
- disconnect_parent_destroyed (window);
+ gtk_window_transient_parent_destroyed,
+ window);
priv->transient_parent = NULL;
if (priv->transient_parent_group)
- {
- priv->transient_parent_group = FALSE;
- gtk_window_group_remove_window (priv->group,
- window);
- }
+ {
+ priv->transient_parent_group = FALSE;
+ gtk_window_group_remove_window (priv->group, window);
+ }
}
}
@@ -2524,8 +2477,8 @@ gtk_window_unset_transient_for (GtkWindow *window)
* much as the window manager would have done on X.
*/
void
-gtk_window_set_transient_for (GtkWindow *window,
- GtkWindow *parent)
+gtk_window_set_transient_for (GtkWindow *window,
+ GtkWindow *parent)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
@@ -2538,9 +2491,8 @@ gtk_window_set_transient_for (GtkWindow *window,
if (_gtk_widget_get_realized (GTK_WIDGET (window)) &&
_gtk_widget_get_realized (GTK_WIDGET (priv->transient_parent)) &&
(!parent || !_gtk_widget_get_realized (GTK_WIDGET (parent))))
- gtk_window_transient_parent_unrealized (GTK_WIDGET (priv->transient_parent),
- GTK_WIDGET (window));
-
+ gtk_window_transient_parent_unrealized (GTK_WIDGET (priv->transient_parent),
+ GTK_WIDGET (window));
gtk_window_unset_transient_for (window);
}
@@ -2549,34 +2501,27 @@ gtk_window_set_transient_for (GtkWindow *window,
if (parent)
{
GtkWindowPrivate *parent_priv = gtk_window_get_instance_private (parent);
- g_signal_connect (parent, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &priv->transient_parent);
g_signal_connect (parent, "realize",
- G_CALLBACK (gtk_window_transient_parent_realized),
- window);
+ G_CALLBACK (gtk_window_transient_parent_realized), window);
g_signal_connect (parent, "unrealize",
- G_CALLBACK (gtk_window_transient_parent_unrealized),
- window);
+ G_CALLBACK (gtk_window_transient_parent_unrealized), window);
g_signal_connect (parent, "notify::display",
- G_CALLBACK (gtk_window_transient_parent_display_changed),
- window);
+ G_CALLBACK (gtk_window_transient_parent_display_changed), window);
+ g_signal_connect (parent, "destroy",
+ G_CALLBACK (gtk_window_transient_parent_destroyed), window);
gtk_window_set_display (window, parent_priv->display);
- if (priv->destroy_with_parent)
- connect_parent_destroyed (window);
-
+
if (_gtk_widget_get_realized (GTK_WIDGET (window)) &&
- _gtk_widget_get_realized (GTK_WIDGET (parent)))
- gtk_window_transient_parent_realized (GTK_WIDGET (parent),
- GTK_WIDGET (window));
+ _gtk_widget_get_realized (GTK_WIDGET (parent)))
+ gtk_window_transient_parent_realized (GTK_WIDGET (parent), GTK_WIDGET (window));
if (parent_priv->group)
- {
- gtk_window_group_add_window (parent_priv->group, window);
- priv->transient_parent_group = TRUE;
- }
+ {
+ gtk_window_group_add_window (parent_priv->group, window);
+ priv->transient_parent_group = TRUE;
+ }
}
update_window_actions (window);
@@ -2710,8 +2655,8 @@ gtk_window_set_application (GtkWindow *window,
* associated with, for example.
**/
void
-gtk_window_set_destroy_with_parent (GtkWindow *window,
- gboolean setting)
+gtk_window_set_destroy_with_parent (GtkWindow *window,
+ gboolean setting)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
@@ -2720,15 +2665,6 @@ gtk_window_set_destroy_with_parent (GtkWindow *window,
if (priv->destroy_with_parent == (setting != FALSE))
return;
- if (priv->destroy_with_parent)
- {
- disconnect_parent_destroyed (window);
- }
- else
- {
- connect_parent_destroyed (window);
- }
-
priv->destroy_with_parent = setting;
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_DESTROY_WITH_PARENT]);
@@ -6929,30 +6865,6 @@ gtk_window_set_focus_visible (GtkWindow *window,
}
}
-/**
- * gtk_window_set_has_user_ref_count:
- * @window: a #GtkWindow
- * @setting: the new value
- *
- * Tells GTK+ whether to drop its extra reference to the window
- * when gtk_widget_destroy() is called.
- *
- * This function is only exported for the benefit of language
- * bindings which may need to keep the window alive until their
- * wrapper object is garbage collected. There is no justification
- * for ever calling this function in an application.
- */
-void
-gtk_window_set_has_user_ref_count (GtkWindow *window,
- gboolean setting)
-{
- GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
-
- g_return_if_fail (GTK_IS_WINDOW (window));
-
- priv->has_user_ref_count = setting;
-}
-
static void
ensure_state_flag_backdrop (GtkWidget *widget)
{
@@ -6996,7 +6908,7 @@ warn_response (GtkDialog *dialog,
check = g_object_get_data (G_OBJECT (dialog), "check");
remember = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
g_object_set_data (G_OBJECT (inspector_window), "warning_dialog", NULL);
if (response == GTK_RESPONSE_NO)
@@ -7558,3 +7470,35 @@ gtk_window_get_child (GtkWindow *window)
return priv->child;
}
+
+/**
+ * gtk_window_destroy:
+ * @window: The window to destroy
+ *
+ * Drop the internal reference GTK holds on toplevel windows.
+ */
+void
+gtk_window_destroy (GtkWindow *window)
+{
+ int i;
+
+ g_return_if_fail (GTK_IS_WINDOW (window));
+
+ gtk_tooltip_unset_surface (GTK_NATIVE (window));
+
+ for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (toplevel_list)); i++)
+ {
+ gpointer item = g_list_model_get_item (G_LIST_MODEL (toplevel_list), i);
+ if (item == window)
+ {
+ g_list_store_remove (toplevel_list, i);
+ break;
+ }
+ else
+ g_object_unref (item);
+ }
+
+ gtk_widget_unrealize (GTK_WIDGET (window));
+
+ g_object_unref (window);
+}
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index 488a37c792..b64c11ee7e 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -180,9 +180,6 @@ GDK_AVAILABLE_IN_ALL
GListModel *gtk_window_get_toplevels (void);
GDK_AVAILABLE_IN_ALL
GList* gtk_window_list_toplevels (void);
-GDK_AVAILABLE_IN_ALL
-void gtk_window_set_has_user_ref_count (GtkWindow *window,
- gboolean setting);
GDK_AVAILABLE_IN_ALL
void gtk_window_present (GtkWindow *window);
@@ -254,6 +251,9 @@ GtkWidget *gtk_window_get_titlebar (GtkWindow *window);
GDK_AVAILABLE_IN_ALL
gboolean gtk_window_is_maximized (GtkWindow *window);
+GDK_AVAILABLE_IN_ALL
+void gtk_window_destroy (GtkWindow *window);
+
GDK_AVAILABLE_IN_ALL
void gtk_window_set_interactive_debugging (gboolean enable);
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-editor.c b/gtk/inspector/css-editor.c
index 85028fc7e7..e30a6184b0 100644
--- a/gtk/inspector/css-editor.c
+++ b/gtk/inspector/css-editor.c
@@ -211,7 +211,7 @@ save_to_file (GtkInspectorCssEditor *ce,
_("Saving CSS failed"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s", error->message);
- g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
g_error_free (error);
}
@@ -233,7 +233,7 @@ save_response (GtkWidget *dialog,
g_object_unref (file);
}
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
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 da78f3b6e9..784e66b269 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -998,7 +998,7 @@ render_node_save_response (GtkWidget *dialog,
_("Saving RenderNode failed"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
"%s", error->message);
- g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (message_dialog);
g_error_free (error);
}
@@ -1006,7 +1006,7 @@ render_node_save_response (GtkWidget *dialog,
g_bytes_unref (bytes);
}
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -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)
{
diff --git a/tests/gdkgears.c b/tests/gdkgears.c
index e40460c495..28dd15cc5a 100644
--- a/tests/gdkgears.c
+++ b/tests/gdkgears.c
@@ -99,7 +99,7 @@ less_gears (GtkButton *button, gpointer data)
gears = gtk_widget_get_last_child (GTK_WIDGET (container));
if (gears)
- gtk_widget_destroy (gears);
+ gtk_container_remove (container, gears);
}
static void
@@ -235,8 +235,7 @@ main (int argc, char *argv[])
button = gtk_button_new_with_label ("Quit");
gtk_widget_set_hexpand (button, TRUE);
gtk_container_add (GTK_CONTAINER (bbox), button);
- g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
-
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
gtk_widget_show (window);
while (!done)
diff --git a/tests/print-editor.c b/tests/print-editor.c
index 8b90af1efe..2ae6f6609f 100644
--- a/tests/print-editor.c
+++ b/tests/print-editor.c
@@ -141,7 +141,7 @@ load_file (GFile *open_filename)
if (error_dialog)
{
- g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (error_dialog);
}
}
@@ -186,7 +186,7 @@ save_file (GFile *save_filename)
display_name,
error->message);
- g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (error_dialog);
g_error_free (error);
@@ -389,7 +389,7 @@ print_done (GtkPrintOperation *op,
GTK_BUTTONS_CLOSE,
"Error printing file:\n%s",
error ? error->message : "no details");
- g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (error_dialog);
}
else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
@@ -519,7 +519,7 @@ activate_save_as (GSimpleAction *action,
g_object_unref (save_filename);
}
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -557,7 +557,7 @@ activate_open (GSimpleAction *action,
g_object_unref (open_filename);
}
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -604,7 +604,7 @@ activate_quit (GSimpleAction *action,
win = list->data;
next = list->next;
- gtk_widget_destroy (GTK_WIDGET (win));
+ gtk_window_destroy (GTK_WINDOW (win));
list = next;
}
diff --git a/tests/testappchooser.c b/tests/testappchooser.c
index 7735cdec80..281f96e9bb 100644
--- a/tests/testappchooser.c
+++ b/tests/testappchooser.c
@@ -51,7 +51,7 @@ dialog_response (GtkDialog *d,
g_print ("No application selected\n");
}
- gtk_widget_destroy (GTK_WIDGET (d));
+ gtk_window_destroy (GTK_WINDOW (d));
dialog = NULL;
}
@@ -144,7 +144,7 @@ button_clicked (GtkButton *b,
path = g_file_get_path (file);
gtk_button_set_label (GTK_BUTTON (file_l), path);
- gtk_widget_destroy (w);
+ gtk_window_destroy (GTK_WINDOW (w));
gtk_widget_set_sensitive (open, TRUE);
diff --git a/tests/testassistant.c b/tests/testassistant.c
index 83cc9d5c44..ea6daf9361 100644
--- a/tests/testassistant.c
+++ b/tests/testassistant.c
@@ -179,7 +179,7 @@ create_simple_assistant (GtkWidget *widget)
gtk_widget_show (assistant);
else
{
- gtk_widget_destroy (assistant);
+ gtk_window_destroy (GTK_WINDOW (assistant));
assistant = NULL;
}
}
@@ -219,7 +219,7 @@ create_anonymous_assistant (GtkWidget *widget)
gtk_widget_show (assistant);
else
{
- gtk_widget_destroy (assistant);
+ gtk_window_destroy (GTK_WINDOW (assistant));
assistant = NULL;
}
}
@@ -310,7 +310,7 @@ create_generous_assistant (GtkWidget *widget)
gtk_widget_show (assistant);
else
{
- gtk_widget_destroy (assistant);
+ gtk_window_destroy (GTK_WINDOW (assistant));
assistant = NULL;
}
}
@@ -403,7 +403,7 @@ create_nonlinear_assistant (GtkWidget *widget)
gtk_widget_show (assistant);
else
{
- gtk_widget_destroy (assistant);
+ gtk_window_destroy (GTK_WINDOW (assistant));
assistant = NULL;
}
}
@@ -495,7 +495,7 @@ create_looping_assistant (GtkWidget *widget)
gtk_widget_show (assistant);
else
{
- gtk_widget_destroy (assistant);
+ gtk_window_destroy (GTK_WINDOW (assistant));
assistant = NULL;
}
}
@@ -563,7 +563,7 @@ create_full_featured_assistant (GtkWidget *widget)
gtk_widget_show (assistant);
else
{
- gtk_widget_destroy (assistant);
+ gtk_window_destroy (GTK_WINDOW (assistant));
assistant = NULL;
}
}
@@ -646,7 +646,7 @@ create_page_flipping_assistant (GtkWidget *widget)
gtk_widget_show (assistant);
else
{
- gtk_widget_destroy (assistant);
+ gtk_window_destroy (GTK_WINDOW (assistant));
assistant = NULL;
}
}
diff --git a/tests/testborderdrawing.c b/tests/testborderdrawing.c
index 68bba95902..96c3246bb3 100644
--- a/tests/testborderdrawing.c
+++ b/tests/testborderdrawing.c
@@ -171,5 +171,5 @@ main (int argc, char **argv)
while (!done)
g_main_context_iteration (NULL, TRUE);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
diff --git a/tests/testcombo.c b/tests/testcombo.c
index 2fb35f8186..2ae3ceb6e0 100644
--- a/tests/testcombo.c
+++ b/tests/testcombo.c
@@ -79,7 +79,7 @@ create_tree_blaat (void)
2, FALSE,
-1);
- gtk_widget_destroy (cellview);
+ g_object_unref (g_object_ref_sink (cellview));
return GTK_TREE_MODEL (store);
}
@@ -101,7 +101,7 @@ create_empty_list_blaat (void)
1, "dialog-warning",
-1);
- gtk_widget_destroy (cellview);
+ g_object_unref (g_object_ref_sink (cellview));
return GTK_TREE_MODEL (store);
}
@@ -153,7 +153,7 @@ populate_list_blaat (gpointer data)
1, "document-open",
-1);
- gtk_widget_destroy (cellview);
+ g_object_unref (g_object_ref_sink (cellview));
}
static GtkTreeModel *
@@ -203,7 +203,7 @@ create_list_blaat (void)
1, "document-open",
-1);
- gtk_widget_destroy (cellview);
+ g_object_unref (g_object_ref_sink (cellview));
return GTK_TREE_MODEL (store);
}
diff --git a/tests/testdialog.c b/tests/testdialog.c
index 14d35a261f..e1ed78a13f 100644
--- a/tests/testdialog.c
+++ b/tests/testdialog.c
@@ -17,7 +17,7 @@ show_message_dialog1 (GtkWindow *parent)
"Unhandled error message: SSH program unexpectedly exited");
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -34,7 +34,7 @@ show_message_dialog1a (GtkWindow *parent)
"The system network services are not compatible with this version."));
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -57,7 +57,7 @@ show_message_dialog2 (GtkWindow *parent)
NULL);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -68,7 +68,7 @@ show_color_chooser (GtkWindow *parent)
dialog = gtk_color_chooser_dialog_new ("Builtin", parent);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -82,7 +82,7 @@ show_color_chooser_generic (GtkWindow *parent)
NULL);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -121,7 +121,7 @@ show_dialog (GtkWindow *parent)
add_content (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -137,7 +137,7 @@ show_dialog_with_header (GtkWindow *parent)
add_content (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -154,7 +154,7 @@ show_dialog_with_buttons (GtkWindow *parent)
add_content (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -171,7 +171,7 @@ show_dialog_with_header_buttons (GtkWindow *parent)
add_content (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -185,7 +185,7 @@ show_dialog_with_header_buttons2 (GtkWindow *parent)
g_object_unref (builder);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
typedef struct {
@@ -233,7 +233,7 @@ show_dialog_from_template (GtkWindow *parent)
add_content (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -254,7 +254,7 @@ show_dialog_flex_template (GtkWindow *parent)
add_content (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
typedef struct {
@@ -307,7 +307,7 @@ show_dialog_from_template_with_header (GtkWindow *parent)
add_content (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
int
diff --git a/tests/testdnd3.c b/tests/testdnd3.c
index 06f8c77bc0..ac73b5bee4 100644
--- a/tests/testdnd3.c
+++ b/tests/testdnd3.c
@@ -266,8 +266,8 @@ int main (int argc, char *argv[])
gtk_init ();
widget = gtk_color_button_new ();
- gtk_widget_destroy (widget);
-
+ g_object_unref (g_object_ref_sink (widget));
+
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c
index 0558dab5b0..e5db029e4d 100644
--- a/tests/testfilechooser.c
+++ b/tests/testfilechooser.c
@@ -157,7 +157,7 @@ set_current_folder (GtkFileChooser *chooser,
"Could not set the folder to %s",
name);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
g_object_unref (file);
}
@@ -192,7 +192,7 @@ set_filename (GtkFileChooser *chooser,
"Could not select %s",
name);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
g_object_unref (file);
}
@@ -266,8 +266,7 @@ unmap_and_remap_cb (GtkButton *button,
static void
kill_dependent (GtkWindow *win, GtkWidget *dep)
{
- gtk_widget_destroy (dep);
- g_object_unref (dep);
+ gtk_window_destroy (GTK_WINDOW (dep));
}
static void
@@ -504,7 +503,6 @@ main (int argc, char **argv)
gtk_widget_show (control_window);
- g_object_ref (control_window);
g_signal_connect (dialog, "destroy",
G_CALLBACK (kill_dependent), control_window);
@@ -514,7 +512,7 @@ main (int argc, char **argv)
g_object_ref (dialog);
while (!done)
g_main_context_iteration (NULL, TRUE);
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
g_object_unref (dialog);
return 0;
diff --git a/tests/testglarea.c b/tests/testglarea.c
index 3fa0bcbf37..7ef8022222 100644
--- a/tests/testglarea.c
+++ b/tests/testglarea.c
@@ -442,7 +442,7 @@ main (int argc, char *argv[])
button = gtk_button_new_with_label ("Quit");
gtk_widget_set_hexpand (button, TRUE);
gtk_container_add (GTK_CONTAINER (box), button);
- g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
gtk_widget_show (window);
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 0d2b9b3a91..645d2045c6 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -227,20 +227,17 @@ create_alpha_window (GtkWidget *widget)
g_signal_connect (display, "notify::composited", G_CALLBACK (on_composited_changed), label);
gtk_container_add (GTK_CONTAINER (vbox), build_alpha_widgets ());
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_signal_connect (window, "response",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
NULL);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -274,11 +271,8 @@ create_buttons (GtkWidget *widget)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "GtkButton");
@@ -328,7 +322,7 @@ create_buttons (GtkWidget *widget)
gtk_widget_set_margin_start (button[9], 10);
gtk_widget_set_margin_end (button[9], 10);
g_signal_connect_swapped (button[9], "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button[9]);
gtk_window_set_default_widget (GTK_WINDOW (window), button[9]);
@@ -337,7 +331,7 @@ create_buttons (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -357,11 +351,8 @@ create_toggle_buttons (GtkWidget *widget)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "GtkToggleButton");
@@ -388,7 +379,7 @@ create_toggle_buttons (GtkWidget *widget)
button = gtk_button_new_with_label ("close");
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
@@ -397,7 +388,7 @@ create_toggle_buttons (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static GtkWidget *
@@ -476,13 +467,10 @@ create_check_buttons (GtkWidget *widget)
NULL);
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_signal_connect (window, "response",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
NULL);
box1 = gtk_dialog_get_content_area (GTK_DIALOG (window));
@@ -519,7 +507,7 @@ create_check_buttons (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -545,13 +533,10 @@ create_radio_buttons (GtkWidget *widget)
NULL);
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_signal_connect (window, "response",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
NULL);
box1 = gtk_dialog_get_content_area (GTK_DIALOG (window));
@@ -609,7 +594,7 @@ create_radio_buttons (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -734,11 +719,8 @@ create_statusbar (GtkWidget *widget)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "statusbar");
@@ -799,7 +781,7 @@ create_statusbar (GtkWidget *widget)
button = gtk_button_new_with_label ("close");
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
@@ -808,7 +790,7 @@ create_statusbar (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -896,7 +878,7 @@ dialog_response (GtkWidget *dialog, gint response_id, GtkLabel *label)
{
const gchar *text;
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
text = "Some text may be marked up\n"
"as hyperlinks, which can be clicked\n"
@@ -944,11 +926,8 @@ static void create_labels (GtkWidget *widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "Label");
@@ -1091,7 +1070,7 @@ static void create_labels (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
#define DEFAULT_TEXT_RADIUS 200
@@ -1186,9 +1165,8 @@ create_rotated_text (GtkWidget *widget)
gtk_widget_get_display (widget));
g_signal_connect (window, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &window);
+ G_CALLBACK (gtk_window_destroy), NULL);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
@@ -1213,7 +1191,7 @@ create_rotated_text (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
@@ -1239,11 +1217,8 @@ create_pixbuf (GtkWidget *widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "GtkPixmap");
gtk_widget_realize(window);
@@ -1288,7 +1263,7 @@ create_pixbuf (GtkWidget *widget)
button = gtk_button_new_with_label ("close");
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
@@ -1297,7 +1272,7 @@ create_pixbuf (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static void
@@ -1376,7 +1351,7 @@ create_tooltips (GtkWidget *widget)
button = gtk_button_new_with_label ("close");
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
@@ -1387,7 +1362,7 @@ create_tooltips (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -1426,9 +1401,7 @@ create_image (GtkWidget *widget)
*/
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
@@ -1447,7 +1420,7 @@ create_image (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -1549,7 +1522,7 @@ create_listbox (GtkWidget *widget)
gtk_window_set_hide_on_close (GTK_WINDOW (window), TRUE);
gtk_window_set_display (GTK_WINDOW (window), display);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "listbox");
@@ -1609,7 +1582,7 @@ create_listbox (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
@@ -1649,7 +1622,6 @@ static void
create_key_lookup (GtkWidget *widget)
{
static GtkWidget *window = NULL;
- gpointer window_ptr;
if (!window)
{
@@ -1702,14 +1674,13 @@ create_key_lookup (GtkWidget *widget)
button = accel_button_new ("Button 14", "a");
gtk_container_add (GTK_CONTAINER (box), button);
- window_ptr = &window;
- g_object_add_weak_pointer (G_OBJECT (window), window_ptr);
- g_signal_connect (window, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
+ g_signal_connect (window, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (window);
}
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
@@ -1739,7 +1710,7 @@ cmw_color (GtkWidget *widget, GtkWidget *parent)
g_signal_connect (csd, "destroy",
G_CALLBACK (cmw_destroy_cb), NULL);
g_signal_connect (csd, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
/* wait until destroy calls gtk_main_quit */
gtk_widget_show (csd);
@@ -1764,7 +1735,7 @@ cmw_file (GtkWidget *widget, GtkWidget *parent)
g_signal_connect (fs, "destroy",
G_CALLBACK (cmw_destroy_cb), NULL);
g_signal_connect_swapped (fs, "response",
- G_CALLBACK (gtk_widget_destroy), fs);
+ G_CALLBACK (gtk_window_destroy), fs);
/* wait until destroy calls gtk_main_quit */
gtk_widget_show (fs);
@@ -1811,7 +1782,7 @@ create_modal_window (GtkWidget *widget)
/* connect signals */
g_signal_connect_swapped (btnClose, "clicked",
- G_CALLBACK (gtk_widget_destroy), window);
+ G_CALLBACK (gtk_window_destroy), window);
g_signal_connect (window, "destroy",
G_CALLBACK (cmw_destroy_cb), NULL);
@@ -1842,7 +1813,7 @@ make_message_dialog (GdkDisplay *display,
{
if (*dialog)
{
- gtk_widget_destroy (*dialog);
+ gtk_window_destroy (GTK_WINDOW (*dialog));
return;
}
@@ -1854,13 +1825,10 @@ make_message_dialog (GdkDisplay *display,
g_signal_connect_swapped (*dialog,
"response",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
*dialog);
- g_signal_connect (*dialog,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- dialog);
+ g_object_add_weak_pointer (G_OBJECT (*dialog), (gpointer)dialog);
gtk_dialog_set_default_response (GTK_DIALOG (*dialog), default_response);
@@ -1910,7 +1878,7 @@ scrolled_windows_delete_cb (GtkWidget *widget,
static void
scrolled_windows_destroy_cb (GtkWidget *widget, GtkWidget *scrollwin)
{
- gtk_widget_destroy (sw_float_parent);
+ gtk_window_destroy (GTK_WINDOW (sw_float_parent));
sw_float_parent = NULL;
sw_parent = NULL;
@@ -1922,7 +1890,7 @@ scrolled_windows_remove (GtkWidget *dialog, gint response, GtkWidget *scrollwin)
{
if (response != GTK_RESPONSE_APPLY)
{
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
return;
}
@@ -1934,7 +1902,7 @@ scrolled_windows_remove (GtkWidget *dialog, gint response, GtkWidget *scrollwin)
g_object_unref (scrollwin);
- gtk_widget_destroy (sw_float_parent);
+ gtk_window_destroy (GTK_WINDOW (sw_float_parent));
g_signal_handler_disconnect (sw_parent, sw_destroyed_handler);
sw_float_parent = NULL;
@@ -1982,11 +1950,8 @@ create_scrolled_windows (GtkWidget *widget)
window = gtk_dialog_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
@@ -2032,7 +1997,7 @@ create_scrolled_windows (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -2132,11 +2097,8 @@ create_entry (GtkWidget *widget)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "entry");
@@ -2214,7 +2176,7 @@ create_entry (GtkWidget *widget)
button = gtk_button_new_with_label ("close");
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
@@ -2223,7 +2185,7 @@ create_entry (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static void
@@ -2238,11 +2200,8 @@ create_expander (GtkWidget *widget)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "expander");
@@ -2261,7 +2220,7 @@ create_expander (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
@@ -2317,7 +2276,7 @@ create_size_group_window (GdkDisplay *display,
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
g_signal_connect (window, "response",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
NULL);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
@@ -2419,27 +2378,21 @@ create_size_groups (GtkWidget *widget)
if (!window1)
{
window1 = create_size_group_window (gtk_widget_get_display (widget),
- master_size_group);
-
- g_signal_connect (window1, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window1);
+ master_size_group);
+ g_object_add_weak_pointer (G_OBJECT (window1), (gpointer *)&window1);
}
if (!window2)
{
window2 = create_size_group_window (gtk_widget_get_display (widget),
- master_size_group);
-
- g_signal_connect (window2, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window2);
+ master_size_group);
+ g_object_add_weak_pointer (G_OBJECT (window2), (gpointer *)&window2);
}
if (gtk_widget_get_visible (window1) && gtk_widget_get_visible (window2))
{
- gtk_widget_destroy (window1);
- gtk_widget_destroy (window2);
+ gtk_window_destroy (GTK_WINDOW (window1));
+ gtk_window_destroy (GTK_WINDOW (window2));
}
else
{
@@ -2639,11 +2592,8 @@ create_spins (GtkWidget *widget)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "GtkSpinButton");
@@ -2833,7 +2783,7 @@ create_spins (GtkWidget *widget)
button = gtk_button_new_with_label ("Close");
gtk_widget_set_hexpand (button, TRUE);
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (hbox), button);
}
@@ -2841,7 +2791,7 @@ create_spins (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
@@ -3089,11 +3039,8 @@ create_cursors (GtkWidget *widget)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "Cursors");
@@ -3201,7 +3148,7 @@ create_cursors (GtkWidget *widget)
button = gtk_button_new_with_label ("Close");
gtk_widget_set_hexpand (button, TRUE);
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (hbox), button);
@@ -3210,7 +3157,7 @@ create_cursors (GtkWidget *widget)
gtk_editable_set_text (GTK_EDITABLE (entry), "arrow");
}
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -3227,14 +3174,11 @@ create_color_selection (GtkWidget *widget)
GtkWidget *picker;
GtkWidget *hbox;
GtkWidget *label;
-
+
window = gtk_window_new ();
- gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_window_set_display (GTK_WINDOW (window),
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "GtkColorButton");
@@ -3256,7 +3200,7 @@ create_color_selection (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static void
@@ -3350,11 +3294,8 @@ create_flipping (GtkWidget *widget)
window = gtk_dialog_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
@@ -3385,13 +3326,13 @@ create_flipping (GtkWidget *widget)
create_forward_back ("Right-to-Left", GTK_TEXT_DIR_RTL));
gtk_dialog_add_button (GTK_DIALOG (window), "Close", GTK_RESPONSE_CLOSE);
- g_signal_connect (window, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (window, "response", G_CALLBACK (gtk_window_destroy), NULL);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -3411,11 +3352,8 @@ create_font_selection (GtkWidget *widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "GtkFontButton");
@@ -3437,7 +3375,7 @@ create_font_selection (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -3496,12 +3434,8 @@ create_dialog (GtkWidget *widget)
dialog_window = gtk_dialog_new ();
gtk_window_set_display (GTK_WINDOW (dialog_window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (dialog_window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &dialog_window);
-
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (dialog_window), (gpointer *)&dialog_window);
gtk_window_set_title (GTK_WINDOW (dialog_window), "GtkDialog");
@@ -3521,7 +3455,7 @@ create_dialog (GtkWidget *widget)
if (!gtk_widget_get_visible (dialog_window))
gtk_widget_show (dialog_window);
else
- gtk_widget_destroy (dialog_window);
+ gtk_window_destroy (GTK_WINDOW (dialog_window));
}
/* Display & Screen test
@@ -3558,7 +3492,7 @@ screen_display_check (GtkWidget *widget, ScreenDisplaySelection *data)
gtk_window_set_display (GTK_WINDOW (dialog), current_display);
gtk_widget_show (dialog);
g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
NULL);
}
else
@@ -3582,14 +3516,14 @@ screen_display_check (GtkWidget *widget, ScreenDisplaySelection *data)
new_display = display;
gtk_window_set_display (GTK_WINDOW (data->toplevel), new_display);
- gtk_widget_destroy (data->dialog_window);
+ gtk_window_destroy (GTK_WINDOW (data->dialog_window));
}
}
static void
screen_display_destroy_diag (GtkWidget *widget, GtkWidget *data)
{
- gtk_widget_destroy (data);
+ gtk_window_destroy (GTK_WINDOW (data));
}
static void
@@ -3606,7 +3540,7 @@ create_display_screen (GtkWidget *widget)
"title", "Screen or Display selection",
NULL);
g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
gtk_window_set_child (GTK_WINDOW (window), vbox);
@@ -3683,11 +3617,8 @@ create_range_controls (GtkWidget *widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "range controls");
@@ -3753,7 +3684,7 @@ create_range_controls (GtkWidget *widget)
button = gtk_button_new_with_label ("close");
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
@@ -3762,7 +3693,7 @@ create_range_controls (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -4046,11 +3977,8 @@ create_notebook (GtkWidget *widget)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "notebook");
@@ -4128,7 +4056,7 @@ create_notebook (GtkWidget *widget)
button = gtk_button_new_with_label ("close");
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (box1), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
@@ -4137,7 +4065,7 @@ create_notebook (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -4246,11 +4174,8 @@ create_panes (GtkWidget *widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "Panes");
@@ -4296,7 +4221,7 @@ create_panes (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -4605,61 +4530,53 @@ create_paned_keyboard_navigation (GtkWidget *widget)
if (window1 &&
(gtk_widget_get_display (window1) != gtk_widget_get_display (widget)))
{
- gtk_widget_destroy (window1);
- gtk_widget_destroy (window2);
- gtk_widget_destroy (window3);
- gtk_widget_destroy (window4);
+ gtk_window_destroy (GTK_WINDOW (window1));
+ gtk_window_destroy (GTK_WINDOW (window2));
+ gtk_window_destroy (GTK_WINDOW (window3));
+ gtk_window_destroy (GTK_WINDOW (window4));
}
if (!window1)
{
window1 = paned_keyboard_window1 (widget);
- g_signal_connect (window1, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window1);
+ g_object_add_weak_pointer (G_OBJECT (window1), (gpointer *)&window1);
}
if (!window2)
{
window2 = paned_keyboard_window2 (widget);
- g_signal_connect (window2, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window2);
+ g_object_add_weak_pointer (G_OBJECT (window2), (gpointer *)&window2);
}
if (!window3)
{
window3 = paned_keyboard_window3 (widget);
- g_signal_connect (window3, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window3);
+ g_object_add_weak_pointer (G_OBJECT (window3), (gpointer *)&window3);
}
if (!window4)
{
window4 = paned_keyboard_window4 (widget);
- g_signal_connect (window4, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window4);
+ g_object_add_weak_pointer (G_OBJECT (window4), (gpointer *)&window4);
}
if (gtk_widget_get_visible (window1))
- gtk_widget_destroy (GTK_WIDGET (window1));
+ gtk_window_destroy (GTK_WINDOW (window1));
else
gtk_widget_show (GTK_WIDGET (window1));
if (gtk_widget_get_visible (window2))
- gtk_widget_destroy (GTK_WIDGET (window2));
+ gtk_window_destroy (GTK_WINDOW (window2));
else
gtk_widget_show (GTK_WIDGET (window2));
if (gtk_widget_get_visible (window3))
- gtk_widget_destroy (GTK_WIDGET (window3));
+ gtk_window_destroy (GTK_WINDOW (window3));
else
gtk_widget_show (GTK_WIDGET (window3));
if (gtk_widget_get_visible (window4))
- gtk_widget_destroy (GTK_WIDGET (window4));
+ gtk_window_destroy (GTK_WINDOW (window4));
else
gtk_widget_show (GTK_WIDGET (window4));
}
@@ -4686,11 +4603,8 @@ create_wmhints (GtkWidget *widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "WM Hints");
@@ -4724,7 +4638,7 @@ create_wmhints (GtkWidget *widget)
button = gtk_button_new_with_label ("close");
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (box2), button);
@@ -4734,7 +4648,7 @@ create_wmhints (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -4783,7 +4697,7 @@ tracking_label (GtkWidget *window)
g_signal_connect_object (hbox,
"destroy",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window,
G_CONNECT_SWAPPED);
@@ -4921,11 +4835,8 @@ create_surface_states (GtkWidget *widget)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
- gtk_widget_get_display (widget));
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ gtk_widget_get_display (widget));
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "Surface states");
@@ -4938,7 +4849,7 @@ create_surface_states (GtkWidget *widget)
gtk_widget_get_display (widget));
g_signal_connect_object (iconified, "destroy",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window,
G_CONNECT_SWAPPED);
gtk_window_minimize (GTK_WINDOW (iconified));
@@ -4952,7 +4863,7 @@ create_surface_states (GtkWidget *widget)
gtk_widget_get_display (widget));
g_signal_connect_object (normal, "destroy",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window,
G_CONNECT_SWAPPED);
@@ -4976,7 +4887,7 @@ create_surface_states (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -5081,7 +4992,7 @@ window_controls (GtkWidget *window)
g_signal_connect_object (control_window,
"destroy",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window,
G_CONNECT_SWAPPED);
@@ -5193,17 +5104,12 @@ create_window_sizing (GtkWidget *widget)
gtk_label_set_markup (GTK_LABEL (label), "Window being resized\nBlah blah blah blah\nblah blah blah\nblah blah blah blah blah");
gtk_window_set_child (GTK_WINDOW (target_window), label);
gtk_widget_show (target_window);
-
- g_signal_connect (target_window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &target_window);
+
+ g_object_add_weak_pointer (G_OBJECT (target_window), (gpointer *)&target_window);
window = window_controls (target_window);
-
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
-
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
+
gtk_window_set_title (GTK_WINDOW (target_window), "Window to size");
}
@@ -5214,7 +5120,7 @@ create_window_sizing (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -5498,14 +5404,14 @@ create_progress_bar (GtkWidget *widget)
gtk_dialog_add_button (GTK_DIALOG (pdata->window), "Close", GTK_RESPONSE_CLOSE);
g_signal_connect (pdata->window, "response",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
NULL);
}
if (!gtk_widget_get_visible (pdata->window))
gtk_widget_show (pdata->window);
else
- gtk_widget_destroy (pdata->window);
+ gtk_window_destroy (GTK_WINDOW (pdata->window));
}
/*
@@ -5589,7 +5495,7 @@ create_timeout_test (GtkWidget *widget)
button = gtk_button_new_with_label ("close");
g_signal_connect_swapped (button, "clicked",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
window);
gtk_container_add (GTK_CONTAINER (action_area), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
@@ -5610,7 +5516,7 @@ create_timeout_test (GtkWidget *widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static void
@@ -5947,15 +5853,13 @@ create_native_dialogs (GtkWidget *widget)
g_signal_connect (native, "notify::visible",
G_CALLBACK (native_visible_notify_hide), hide_button);
- g_signal_connect (window, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
+ g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/*
@@ -5965,7 +5869,7 @@ create_native_dialogs (GtkWidget *widget)
static void
do_exit (GtkWidget *widget, GtkWidget *window)
{
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
done = TRUE;
g_main_context_wakeup (NULL);
}
diff --git a/tests/testheaderbar.c b/tests/testheaderbar.c
index 9d3bcd2ba1..8094b29183 100644
--- a/tests/testheaderbar.c
+++ b/tests/testheaderbar.c
@@ -29,7 +29,7 @@ on_bookmark_clicked (GtkButton *button, gpointer data)
NULL);
g_signal_connect (chooser, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
+ G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (chooser);
}
@@ -161,7 +161,7 @@ main (int argc, char *argv[])
while (!done)
g_main_context_iteration (NULL, TRUE);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return 0;
}
diff --git a/tests/testlist2.c b/tests/testlist2.c
index 9c284417be..90a6fe1539 100644
--- a/tests/testlist2.c
+++ b/tests/testlist2.c
@@ -40,7 +40,7 @@ row_revealed (GObject *revealer, GParamSpec *pspec, gpointer data)
child = gtk_revealer_get_child (GTK_REVEALER (revealer));
g_object_ref (child);
gtk_revealer_set_child (GTK_REVEALER (revealer), NULL);
- gtk_widget_destroy (GTK_WIDGET (revealer));
+ gtk_widget_unparent (GTK_WIDGET (revealer));
gtk_container_add (GTK_CONTAINER (row), child);
g_object_unref (child);
}
diff --git a/tests/testrevealer.c b/tests/testrevealer.c
index ce6cfb231a..a36080f21e 100644
--- a/tests/testrevealer.c
+++ b/tests/testrevealer.c
@@ -166,7 +166,7 @@ main (gint argc,
while (TRUE)
g_main_context_iteration (NULL, TRUE);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return 0;
}
diff --git a/tests/teststack.c b/tests/teststack.c
index dbbb219467..561eb0373e 100644
--- a/tests/teststack.c
+++ b/tests/teststack.c
@@ -260,7 +260,7 @@ main (gint argc,
while (TRUE)
g_main_context_iteration (NULL, TRUE);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
return 0;
}
diff --git a/tests/testvolumebutton.c b/tests/testvolumebutton.c
index 22997d6d93..9c5424ed50 100644
--- a/tests/testvolumebutton.c
+++ b/tests/testvolumebutton.c
@@ -30,7 +30,7 @@ response_cb (GtkDialog *dialog,
gint arg1,
gpointer user_data)
{
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static gboolean
diff --git a/tests/testwindowsize.c b/tests/testwindowsize.c
index 0d3fc8ccbb..13f78d21ed 100644
--- a/tests/testwindowsize.c
+++ b/tests/testwindowsize.c
@@ -68,7 +68,7 @@ show_dialog (void)
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
diff --git a/testsuite/a11y/accessibility-dump.c b/testsuite/a11y/accessibility-dump.c
index 422d150414..f77a9bc152 100644
--- a/testsuite/a11y/accessibility-dump.c
+++ b/testsuite/a11y/accessibility-dump.c
@@ -781,7 +781,7 @@ dump_ui_file (const char *ui_file,
gtk_widget_show (window);
dump_accessible (gtk_widget_get_accessible (window), 0, string);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static void
diff --git a/testsuite/a11y/misc.c b/testsuite/a11y/misc.c
index b2895fadbe..aabbf3f26a 100644
--- a/testsuite/a11y/misc.c
+++ b/testsuite/a11y/misc.c
@@ -41,8 +41,8 @@ test_popover_parent (void)
g_assert (atk_object_get_parent (a) != NULL);
- gtk_widget_destroy (w);
- gtk_widget_destroy (p);
+ gtk_widget_unparent (w);
+ g_object_unref (g_object_ref_sink (p));
}
int
diff --git a/testsuite/a11y/state/state-record.c b/testsuite/a11y/state/state-record.c
index 5f094dce20..3a11c8bee2 100644
--- a/testsuite/a11y/state/state-record.c
+++ b/testsuite/a11y/state/state-record.c
@@ -101,7 +101,7 @@ do_action (GtkBuilder *builder, const gchar *action, GString *string)
GObject *o;
o = gtk_builder_get_object (builder, parts[i]);
- gtk_widget_destroy (GTK_WIDGET (o));
+ g_object_unref (o);
}
}
else if (strcmp (parts[0], "show") == 0)
diff --git a/testsuite/gtk/action.c b/testsuite/gtk/action.c
index a07526cbf6..768de600d3 100644
--- a/testsuite/gtk/action.c
+++ b/testsuite/gtk/action.c
@@ -99,7 +99,7 @@ test_action (void)
g_assert_cmpint (win_activated, ==, 2);
g_assert_cmpint (box_activated, ==, 1);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (win_actions);
g_object_unref (box_actions);
}
@@ -185,7 +185,7 @@ test_text (void)
g_assert_cmpint (visibility_changed, ==, 1);
- gtk_widget_destroy (box);
+ g_object_unref (g_object_ref_sink (box));
g_object_unref (clipboard_actions);
}
@@ -240,7 +240,7 @@ test_overlap (void)
g_assert_cmpint (win_activated, ==, 1);
g_assert_cmpint (box_activated, ==, 1);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (win_actions);
g_object_unref (box_actions);
}
@@ -335,9 +335,11 @@ test_overlap2 (void)
g_assert_cmpint (act1, ==, 0);
g_assert_cmpint (act2, ==, 1);
- gtk_widget_destroy (text);
g_object_unref (group1);
g_object_unref (group2);
+
+ gtk_widget_unparent (child);
+ g_object_unref (g_object_ref_sink (text));
}
/* Test that gtk_widget_class_query_action
@@ -423,7 +425,7 @@ test_enabled (void)
g_assert_cmpint (toggled, ==, 1);
- gtk_widget_destroy (text);
+ g_object_unref (g_object_ref_sink (text));
}
int
diff --git a/testsuite/gtk/builder.c b/testsuite/gtk/builder.c
index 14d5a4adc8..d545b3a667 100644
--- a/testsuite/gtk/builder.c
+++ b/testsuite/gtk/builder.c
@@ -253,7 +253,7 @@ test_connect_signals (void)
g_assert_cmpint (object, ==, 1);
g_assert_cmpint (object_after, ==, 1);
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
builder = builder_new_from_string (buffer_order, -1, NULL);
@@ -262,7 +262,7 @@ test_connect_signals (void)
gtk_window_set_title (GTK_WINDOW (window), "test");
g_assert (normal == 20);
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
gtk_builder_add_from_string (builder, buffer_extra,
strlen (buffer_extra), NULL);
@@ -272,11 +272,11 @@ test_connect_signals (void)
gtk_window_set_title (GTK_WINDOW (window), "test");
g_assert (normal == 30);
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
window = gtk_builder_get_object (builder, "window3");
gtk_window_set_title (GTK_WINDOW (window), "test");
g_assert (normal == 40);
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
@@ -289,7 +289,7 @@ test_connect_signals (void)
gtk_window_set_title (GTK_WINDOW (window), "test");
g_assert (normal == 1);
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
}
@@ -344,7 +344,7 @@ test_translation (void)
g_assert (strcmp (gtk_label_get_text (label), "Arkiv") == 0);
window = gtk_builder_get_object (builder, "window1");
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
}
#endif
@@ -445,7 +445,7 @@ test_sizegroup (void)
{
GObject *window;
window = gtk_builder_get_object (builder, "window1");
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
}
#endif
g_object_unref (builder);
@@ -684,20 +684,20 @@ test_types (void)
GError *error;
builder = builder_new_from_string (buffer, -1, NULL);
- gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "dialog")));
- gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "window")));
+ gtk_window_destroy (GTK_WINDOW (gtk_builder_get_object (builder, "dialog")));
+ gtk_window_destroy (GTK_WINDOW (gtk_builder_get_object (builder, "window")));
g_object_unref (builder);
builder = builder_new_from_string (buffer2, -1, NULL);
window = gtk_builder_get_object (builder, "window");
g_assert (GTK_IS_WINDOW (window));
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
builder = builder_new_from_string (buffer3, -1, NULL);
window = gtk_builder_get_object (builder, "window");
g_assert (GTK_IS_WINDOW (window));
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
error = NULL;
@@ -844,7 +844,7 @@ test_construct_only_property (void)
widget = gtk_builder_get_object (builder, "window1");
g_assert_cmpstr (gtk_widget_get_css_name (GTK_WIDGET (widget)), ==, "amazing");
- gtk_widget_destroy (GTK_WIDGET (widget));
+ gtk_window_destroy (GTK_WINDOW (widget));
g_object_unref (builder);
builder = builder_new_from_string (buffer2, -1, NULL);
@@ -894,7 +894,7 @@ test_object_properties (void)
gtk_builder_add_from_string (builder, buffer2, -1, NULL);
window = gtk_builder_get_object (builder, "window2");
g_assert (window != NULL);
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
}
@@ -947,7 +947,7 @@ test_children (void)
g_assert (gtk_widget_get_parent (GTK_WIDGET(button)) != NULL);
g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (gtk_widget_get_parent (GTK_WIDGET (button)))), "window1") == 0);
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
builder = builder_new_from_string (buffer2, -1, NULL);
@@ -974,7 +974,7 @@ test_children (void)
g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (action_area)) == GTK_ORIENTATION_HORIZONTAL);
g_assert (gtk_widget_get_parent (GTK_WIDGET (action_area)) != NULL);
g_assert (gtk_buildable_get_name (GTK_BUILDABLE (action_area)) != NULL);
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
g_object_unref (builder);
}
@@ -1087,7 +1087,7 @@ test_treeview_column (void)
g_list_free (renderers);
window = gtk_builder_get_object (builder, "window1");
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
}
@@ -1134,7 +1134,7 @@ test_icon_view (void)
g_assert (GTK_IS_ICON_VIEW (iconview));
window = gtk_builder_get_object (builder, "window1");
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
}
@@ -1188,7 +1188,7 @@ test_combo_box (void)
g_assert (combobox);
window = gtk_builder_get_object (builder, "window1");
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
}
@@ -1260,7 +1260,7 @@ test_combo_box_entry (void)
g_free (text);
window = gtk_builder_get_object (builder, "window1");
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
}
@@ -1320,7 +1320,7 @@ test_cell_view (void)
window = gtk_builder_get_object (builder, "window1");
g_assert (window);
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
}
@@ -1366,7 +1366,7 @@ test_dialog (void)
button_cancel = gtk_builder_get_object (builder, "button_cancel");
g_assert (gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog1), GTK_WIDGET (button_cancel)) == -5);
- gtk_widget_destroy (GTK_WIDGET (dialog1));
+ gtk_window_destroy (GTK_WINDOW (dialog1));
g_object_unref (builder);
}
@@ -1397,7 +1397,7 @@ test_message_dialog (void)
g_assert (GTK_IS_EXPANDER (expander));
g_assert (gtk_widget_get_parent (GTK_WIDGET (expander)) == gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog1)));
- gtk_widget_destroy (GTK_WIDGET (dialog1));
+ gtk_window_destroy (GTK_WINDOW (dialog1));
g_object_unref (builder);
}
@@ -1479,7 +1479,7 @@ test_widget (void)
g_assert (gtk_widget_has_focus (GTK_WIDGET (button1)));
window1 = gtk_builder_get_object (builder, "window1");
- gtk_widget_destroy (GTK_WIDGET (window1));
+ gtk_window_destroy (GTK_WINDOW (window1));
g_object_unref (builder);
@@ -1508,7 +1508,7 @@ test_widget (void)
g_assert_cmpstr (name, ==, "A Label");
g_free (name);
- gtk_widget_destroy (GTK_WIDGET (window1));
+ gtk_window_destroy (GTK_WINDOW (window1));
g_object_unref (builder);
builder = builder_new_from_string (buffer4, -1, NULL);
@@ -1543,12 +1543,12 @@ test_window (void)
g_object_get (window1, "title", &title, NULL);
g_assert (strcmp (title, "") == 0);
g_free (title);
- gtk_widget_destroy (GTK_WIDGET (window1));
+ gtk_window_destroy (GTK_WINDOW (window1));
g_object_unref (builder);
builder = builder_new_from_string (buffer2, -1, NULL);
window1 = gtk_builder_get_object (builder, "window1");
- gtk_widget_destroy (GTK_WIDGET (window1));
+ gtk_window_destroy (GTK_WINDOW (window1));
g_object_unref (builder);
}
@@ -1735,7 +1735,7 @@ test_reference_counting (void)
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), NULL);
g_assert (model_freed == TRUE);
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
builder = builder_new_from_string (buffer2, -1, NULL);
g_object_unref (builder);
@@ -1936,7 +1936,7 @@ test_add_objects (void)
g_assert (obj == NULL);
obj = gtk_builder_get_object (builder, "window2");
g_assert (GTK_IS_WINDOW (obj));
- gtk_widget_destroy (GTK_WIDGET (obj));
+ gtk_window_destroy (GTK_WINDOW (obj));
obj = gtk_builder_get_object (builder, "mainbox");
g_assert (GTK_IS_WIDGET (obj));
g_object_unref (builder);
@@ -2255,7 +2255,7 @@ test_property_bindings (void)
g_assert (gtk_widget_get_sensitive (GTK_WIDGET (button3)));
window = gtk_builder_get_object (builder, "window");
- gtk_widget_destroy (GTK_WIDGET (window));
+ gtk_window_destroy (GTK_WINDOW (window));
g_object_unref (builder);
}
diff --git a/testsuite/gtk/displayclose.c b/testsuite/gtk/displayclose.c
index e6093dcf9e..55da35c0f8 100644
--- a/testsuite/gtk/displayclose.c
+++ b/testsuite/gtk/displayclose.c
@@ -27,7 +27,7 @@ main (int argc, char **argv)
but = gtk_button_new_with_label ("Try to Exit");
g_signal_connect_swapped (but, "clicked",
- G_CALLBACK (gtk_widget_destroy), win);
+ G_CALLBACK (gtk_window_destroy), win);
gtk_window_set_child (GTK_WINDOW (win), but);
gtk_widget_show (win);
diff --git a/testsuite/gtk/filtermodel.c b/testsuite/gtk/filtermodel.c
index 99a3e8ed32..53c1d93b6f 100644
--- a/testsuite/gtk/filtermodel.c
+++ b/testsuite/gtk/filtermodel.c
@@ -483,7 +483,7 @@ filter_test_teardown (FilterTest *fixture,
{
signal_monitor_free (fixture->monitor);
- gtk_widget_destroy (fixture->tree_view);
+ g_object_unref (g_object_ref_sink (fixture->tree_view));
g_object_unref (fixture->filter);
g_object_unref (fixture->store);
@@ -2421,7 +2421,7 @@ insert_before (void)
g_object_unref (filter);
g_object_unref (store);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
}
static void
@@ -2484,7 +2484,7 @@ insert_child (void)
g_object_unref (filter);
g_object_unref (store);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
}
@@ -2514,7 +2514,7 @@ remove_node (void)
gtk_list_store_remove (list, &iter3);
gtk_list_store_remove (list, &iter2);
- gtk_widget_destroy (view);
+ g_object_unref (g_object_ref_sink (view));
g_object_unref (filter);
g_object_unref (list);
}
@@ -2552,7 +2552,7 @@ remove_node_vroot (void)
gtk_tree_store_remove (tree, &iter3);
gtk_tree_store_remove (tree, &iter2);
- gtk_widget_destroy (view);
+ g_object_unref (g_object_ref_sink (view));
g_object_unref (filter);
g_object_unref (tree);
}
@@ -2588,7 +2588,7 @@ remove_vroot_ancestor (void)
gtk_tree_store_remove (tree, &parent);
- gtk_widget_destroy (view);
+ g_object_unref (g_object_ref_sink (view));
g_object_unref (filter);
g_object_unref (tree);
}
@@ -2622,7 +2622,7 @@ ref_count_single_level (void)
assert_node_ref_count (ref_model, &iter[3], 1);
assert_node_ref_count (ref_model, &iter[4], 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_node_ref_count (ref_model, &iter[0], 1);
assert_node_ref_count (ref_model, &iter[1], 0);
@@ -2692,7 +2692,7 @@ ref_count_two_levels (void)
assert_node_ref_count (ref_model, &iter_first, 1);
assert_node_ref_count (ref_model, &iter, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_root_level_referenced (ref_model, 1);
assert_node_ref_count (ref_model, &iter_first, 1);
@@ -2864,7 +2864,7 @@ ref_count_three_levels (void)
assert_node_ref_count (ref_model, &iter_parent2_first, 0);
assert_node_ref_count (ref_model, &iter_parent2, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model));
@@ -2963,7 +2963,7 @@ ref_count_delete_row (void)
assert_node_ref_count (ref_model, &grandparent1, 2);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model));
assert_node_ref_count (ref_model, &grandparent1, 1);
@@ -3068,7 +3068,7 @@ ref_count_filter_row_length_1 (void)
assert_node_ref_count (ref_model, &level3_1, 0);
assert_node_ref_count (ref_model, &level4_1, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model));
assert_node_ref_count (ref_model, &level1_1, 2);
@@ -3145,7 +3145,7 @@ ref_count_filter_row_length_1_remove_in_root_level (void)
assert_node_ref_count (ref_model, &level3_1, 0);
assert_node_ref_count (ref_model, &level4_1, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model));
assert_node_ref_count (ref_model, &level1_1, 2);
@@ -3227,7 +3227,7 @@ ref_count_filter_row_length_1_remove_in_child_level (void)
assert_node_ref_count (ref_model, &level3_1, 0);
assert_node_ref_count (ref_model, &level4_1, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model));
assert_node_ref_count (ref_model, &level1_1, 2);
@@ -3370,7 +3370,7 @@ ref_count_filter_row_length_gt_1 (void)
assert_node_ref_count (ref_model, &level4_1, 0);
assert_node_ref_count (ref_model, &level4_2, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model));
assert_node_ref_count (ref_model, &level1_1, 1);
@@ -3470,7 +3470,7 @@ ref_count_filter_row_length_gt_1_visible_children (void)
assert_node_ref_count (ref_model, &level4_1, 0);
assert_node_ref_count (ref_model, &level4_2, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model));
assert_node_ref_count (ref_model, &level1_1, 1);
@@ -3539,7 +3539,7 @@ ref_count_cleanup (void)
assert_node_ref_count (ref_model, &iter_parent2_first, 2);
assert_node_ref_count (ref_model, &iter_parent2, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_node_ref_count (ref_model, &grandparent1, 1);
assert_node_ref_count (ref_model, &grandparent2, 1);
@@ -3651,7 +3651,7 @@ ref_count_row_ref (void)
assert_node_ref_count (ref_model, &parent1, 1);
assert_node_ref_count (ref_model, &iter_parent1, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
gtk_tree_model_filter_clear_cache (GTK_TREE_MODEL_FILTER (filter_model));
@@ -3704,7 +3704,7 @@ ref_count_transfer_root_level_insert (void)
assert_node_ref_count (ref_model, &grandparent2, 1);
assert_node_ref_count (ref_model, &grandparent3, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -3746,7 +3746,7 @@ ref_count_transfer_root_level_remove (void)
assert_node_ref_count (ref_model, &grandparent3, 2);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -3823,7 +3823,7 @@ ref_count_transfer_root_level_remove_filtered (void)
check_level_length (GTK_TREE_MODEL_FILTER (filter_model), NULL, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -3864,7 +3864,7 @@ ref_count_transfer_root_level_reordered (void)
assert_node_ref_count (ref_model, &grandparent3, 1);
assert_node_ref_count (ref_model, &grandparent1, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -3965,7 +3965,7 @@ ref_count_transfer_root_level_reordered_filtered (void)
assert_node_ref_count (ref_model, &grandparent2, 0);
assert_node_ref_count (ref_model, &grandparent1, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -4099,7 +4099,7 @@ ref_count_transfer_root_level_filter (void)
gtk_tree_store_set (GTK_TREE_STORE (model), &grandparent4, 0, TRUE, -1);
gtk_tree_store_remove (GTK_TREE_STORE (model), &grandparent2);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -4145,7 +4145,7 @@ ref_count_transfer_child_level_insert (void)
assert_node_ref_count (ref_model, &parent2, 0);
assert_node_ref_count (ref_model, &parent3, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -4193,7 +4193,7 @@ ref_count_transfer_child_level_remove (void)
assert_node_ref_count (ref_model, &grandparent1, 3);
assert_node_ref_count (ref_model, &parent3, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -4280,7 +4280,7 @@ ref_count_transfer_child_level_remove_filtered (void)
check_level_length (GTK_TREE_MODEL_FILTER (filter_model), "0", 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -4326,7 +4326,7 @@ ref_count_transfer_child_level_reordered (void)
assert_node_ref_count (ref_model, &parent3, 0);
assert_node_ref_count (ref_model, &parent1, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -4436,7 +4436,7 @@ ref_count_transfer_child_level_reordered_filtered (void)
assert_node_ref_count (ref_model, &parent2, 0);
assert_node_ref_count (ref_model, &parent1, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -4574,7 +4574,7 @@ ref_count_transfer_child_level_filter (void)
gtk_tree_store_set (GTK_TREE_STORE (model), &grandparent4, 0, TRUE, -1);
gtk_tree_store_remove (GTK_TREE_STORE (model), &grandparent2);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -5012,7 +5012,7 @@ specific_has_child_filter (void)
g_object_unref (fixture.filter);
g_object_unref (fixture.store);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
}
@@ -5176,7 +5176,7 @@ specific_root_has_child_filter (void)
g_object_unref (fixture.filter);
g_object_unref (fixture.store);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
}
static void
@@ -5286,7 +5286,7 @@ specific_has_child_filter_on_sort_model (void)
g_object_unref (fixture.filter);
g_object_unref (fixture.store);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
}
static gboolean
@@ -5407,7 +5407,7 @@ specific_at_least_2_children_filter (void)
g_object_unref (fixture.filter);
g_object_unref (fixture.store);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
}
static void
@@ -5488,7 +5488,7 @@ specific_at_least_2_children_filter_on_sort_model (void)
gtk_tree_row_reference_free (ref);
g_object_unref (fixture.filter);
g_object_unref (fixture.store);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
}
@@ -5948,7 +5948,7 @@ specific_bug_311955_clean (void)
check_level_length (GTK_TREE_MODEL_FILTER (filter), "0", 3);
check_level_length (GTK_TREE_MODEL_FILTER (filter), "0:2", 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
}
static void
@@ -6467,7 +6467,7 @@ specific_bug_657353_related (void)
assert_node_ref_count (ref_model, &node2, 2);
assert_node_ref_count (ref_model, &node4, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (ref_model);
}
@@ -6545,7 +6545,7 @@ specific_bug_657353 (void)
*/
gtk_list_store_set (store, &iter_c, 0, "CCC hidden", -1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter_model);
g_object_unref (sort_model);
g_object_unref (store);
@@ -6624,7 +6624,7 @@ specific_bug_659022_row_changed_emission (void)
gtk_tree_model_row_changed (model, path, &child);
gtk_tree_path_free (path);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter);
g_object_unref (model);
}
@@ -6660,7 +6660,7 @@ specific_bug_659022_row_deleted_node_invisible (void)
gtk_tree_store_remove (GTK_TREE_STORE (model), &parent);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter);
g_object_unref (model);
}
@@ -6723,7 +6723,7 @@ specific_bug_659022_row_deleted_free_level (void)
gtk_tree_store_remove (GTK_TREE_STORE (model), &parent2);
gtk_tree_store_remove (GTK_TREE_STORE (model), &parent);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (filter);
g_object_unref (model);
}
diff --git a/testsuite/gtk/gestures.c b/testsuite/gtk/gestures.c
index b515470697..1a98400309 100644
--- a/testsuite/gtk/gestures.c
+++ b/testsuite/gtk/gestures.c
@@ -457,7 +457,7 @@ test_phases (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -516,7 +516,7 @@ test_mixed (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -571,7 +571,7 @@ test_early_exit (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -618,7 +618,7 @@ test_claim_capture (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -665,7 +665,7 @@ test_claim_target (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -718,7 +718,7 @@ test_claim_bubble (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -775,7 +775,7 @@ test_early_claim_capture (void)
point_release (&mouse_state, 1);
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -834,7 +834,7 @@ test_late_claim_capture (void)
point_release (&mouse_state, 1);
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -886,7 +886,7 @@ test_group (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -945,8 +945,8 @@ test_gestures_outside_grab (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
- gtk_widget_destroy (D);
+ gtk_window_destroy (A);
+ gtk_window_destroy (D);
}
static void
@@ -1006,7 +1006,7 @@ test_gestures_inside_grab (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -1057,7 +1057,7 @@ test_multitouch_on_single (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -1132,7 +1132,7 @@ test_multitouch_activation (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
static void
@@ -1225,7 +1225,7 @@ test_multitouch_interaction (void)
g_string_free (str, TRUE);
- gtk_widget_destroy (A);
+ gtk_window_destroy (A);
}
int
diff --git a/testsuite/gtk/grid-layout.c b/testsuite/gtk/grid-layout.c
index 2b97c7c9b7..c3655185ff 100644
--- a/testsuite/gtk/grid-layout.c
+++ b/testsuite/gtk/grid-layout.c
@@ -188,7 +188,7 @@ test_simple_row (void)
gtk_widget_unparent (GTK_WIDGET (child2));
gtk_widget_unparent (GTK_WIDGET (child3));
- gtk_widget_destroy (parent);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/* same as the previous test, with a column
@@ -281,7 +281,7 @@ test_simple_column (void)
gtk_widget_unparent (GTK_WIDGET (child2));
gtk_widget_unparent (GTK_WIDGET (child3));
- gtk_widget_destroy (parent);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/* Create a grid with spanning children
@@ -406,7 +406,7 @@ test_spans (void)
gtk_widget_unparent (GTK_WIDGET (child3));
gtk_widget_unparent (GTK_WIDGET (child4));
- gtk_widget_destroy (parent);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/* Create a 2x2 homogeneous grid and verify
@@ -522,7 +522,7 @@ test_homogeneous (void)
gtk_widget_unparent (GTK_WIDGET (child3));
gtk_widget_unparent (GTK_WIDGET (child4));
- gtk_widget_destroy (parent);
+ gtk_window_destroy (GTK_WINDOW (window));
}
/* Create a layout with three children
@@ -634,7 +634,7 @@ test_simple_layout (void)
gtk_widget_unparent (GTK_WIDGET (child2));
gtk_widget_unparent (GTK_WIDGET (child3));
- gtk_widget_destroy (parent);
+ gtk_window_destroy (GTK_WINDOW (window));
}
int
diff --git a/testsuite/gtk/meson.build b/testsuite/gtk/meson.build
index b7440b5529..9df9b0c0d8 100644
--- a/testsuite/gtk/meson.build
+++ b/testsuite/gtk/meson.build
@@ -66,6 +66,7 @@ tests = [
['displayclose'],
['revealer-size'],
['widgetorder'],
+ ['widget-refcount'],
]
# Tests that are expected to fail
diff --git a/testsuite/gtk/modelrefcount.c b/testsuite/gtk/modelrefcount.c
index 2d39d9c227..b3e48ce6ec 100644
--- a/testsuite/gtk/modelrefcount.c
+++ b/testsuite/gtk/modelrefcount.c
@@ -61,7 +61,7 @@ test_list_reference_during_creation (void)
assert_root_level_referenced (ref_model, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_root_level_unreferenced (ref_model);
@@ -96,7 +96,7 @@ test_list_reference_after_creation (void)
assert_root_level_referenced (ref_model, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_root_level_unreferenced (ref_model);
@@ -136,7 +136,7 @@ test_list_reference_reordered (void)
assert_root_level_referenced (ref_model, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_root_level_unreferenced (ref_model);
@@ -199,7 +199,7 @@ test_tree_reference_during_creation (void)
assert_not_entire_model_referenced (ref_model, 1);
assert_level_unreferenced (ref_model, &child);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_entire_model_unreferenced (ref_model);
@@ -237,7 +237,7 @@ test_tree_reference_after_creation (void)
assert_not_entire_model_referenced (ref_model, 1);
assert_level_unreferenced (ref_model, &child);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_entire_model_unreferenced (ref_model);
@@ -280,7 +280,7 @@ test_tree_reference_reordered (void)
assert_entire_model_referenced (ref_model, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_entire_model_unreferenced (ref_model);
@@ -330,7 +330,7 @@ test_tree_reference_expand_all (void)
assert_not_entire_model_referenced (ref_model, 1);
assert_level_unreferenced (ref_model, &child);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_entire_model_unreferenced (ref_model);
@@ -373,7 +373,7 @@ test_tree_reference_collapse_all (void)
assert_not_entire_model_referenced (ref_model, 1);
assert_level_unreferenced (ref_model, &child);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_entire_model_unreferenced (ref_model);
@@ -440,7 +440,7 @@ test_tree_reference_expand_collapse (void)
gtk_tree_path_free (path1);
gtk_tree_path_free (path2);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (ref_model);
}
@@ -486,7 +486,7 @@ test_row_reference_list (void)
assert_node_ref_count (ref_model, &iter1, 2);
assert_node_ref_count (ref_model, &iter2, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_node_ref_count (ref_model, &iter0, 0);
assert_node_ref_count (ref_model, &iter1, 1);
@@ -670,7 +670,7 @@ test_row_reference_tree (void)
assert_node_ref_count (ref_model, &child2, 0);
assert_node_ref_count (ref_model, &grandchild2, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_node_ref_count (ref_model, &iter0, 0);
assert_node_ref_count (ref_model, &child0, 0);
@@ -927,7 +927,7 @@ test_row_reference_tree_expand (void)
gtk_tree_row_reference_free (row_ref1);
gtk_tree_row_reference_free (row_ref2);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (ref_model);
}
diff --git a/testsuite/gtk/object.c b/testsuite/gtk/object.c
index 8bfc09b39e..d542df130c 100644
--- a/testsuite/gtk/object.c
+++ b/testsuite/gtk/object.c
@@ -291,7 +291,8 @@ widget_property_tests (gconstpointer test_data)
widget_test_properties (widget, 1); /* test maximum */
widget_test_properties (widget, -1); /* test random value */
/* cleanup */
- gtk_widget_destroy (widget);
+ if (GTK_IS_WINDOW (widget))
+ gtk_window_destroy (GTK_WINDOW (widget));
g_object_unref (widget);
}
diff --git a/testsuite/gtk/objects-finalize.c b/testsuite/gtk/objects-finalize.c
index 2622168bf5..5e13c1ad39 100644
--- a/testsuite/gtk/objects-finalize.c
+++ b/testsuite/gtk/objects-finalize.c
@@ -97,7 +97,7 @@ test_finalize_object (gconstpointer data)
/* Toplevels are owned by GTK+, just tell GTK+ to destroy it */
if (GTK_IS_WINDOW (object))
- gtk_widget_destroy (GTK_WIDGET (object));
+ gtk_window_destroy (GTK_WINDOW (object));
else
g_object_unref (object);
diff --git a/testsuite/gtk/propertylookuplistmodel.c b/testsuite/gtk/propertylookuplistmodel.c
index 13c129feff..d835295af5 100644
--- a/testsuite/gtk/propertylookuplistmodel.c
+++ b/testsuite/gtk/propertylookuplistmodel.c
@@ -126,7 +126,7 @@ create_widget_tree (void)
static void
destroy_widgets (void)
{
- g_slist_free_full (widgets, (GDestroyNotify) gtk_widget_destroy);
+ g_slist_free_full (widgets, (GDestroyNotify) gtk_window_destroy);
widgets = NULL;
}
diff --git a/testsuite/gtk/regression-tests.c b/testsuite/gtk/regression-tests.c
index 6ab853ffcb..306333e4cd 100644
--- a/testsuite/gtk/regression-tests.c
+++ b/testsuite/gtk/regression-tests.c
@@ -35,7 +35,7 @@ test_9d6da33ff5c5e41e3521e1afd63d2d67bc915753 (void)
g_assert (gtk_widget_get_sensitive (label));
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static void
@@ -53,7 +53,7 @@ test_94f00eb04dd1433cf1cc9a3341f485124e38abd1 (void)
g_assert (!gtk_widget_is_sensitive (label));
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
int
diff --git a/testsuite/gtk/sortmodel.c b/testsuite/gtk/sortmodel.c
index 4cf57a07cb..3fbe0f2549 100644
--- a/testsuite/gtk/sortmodel.c
+++ b/testsuite/gtk/sortmodel.c
@@ -46,7 +46,7 @@ ref_count_single_level (void)
assert_entire_model_referenced (ref_model, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_entire_model_unreferenced (ref_model);
@@ -97,7 +97,7 @@ ref_count_two_levels (void)
assert_root_level_referenced (ref_model, 1);
assert_node_ref_count (ref_model, &iter, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_entire_model_unreferenced (ref_model);
@@ -238,7 +238,7 @@ ref_count_three_levels (void)
assert_node_ref_count (ref_model, &iter_parent1, 0);
assert_node_ref_count (ref_model, &iter_parent2, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_entire_model_unreferenced (ref_model);
@@ -323,7 +323,7 @@ ref_count_delete_row (void)
assert_node_ref_count (ref_model, &grandparent1, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_entire_model_unreferenced (ref_model);
@@ -366,7 +366,7 @@ ref_count_cleanup (void)
gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
assert_node_ref_count (ref_model, &grandparent1, 0);
assert_node_ref_count (ref_model, &grandparent2, 1);
@@ -471,7 +471,7 @@ ref_count_row_ref (void)
assert_node_ref_count (ref_model, &parent1, 0);
assert_node_ref_count (ref_model, &iter_parent1, 0);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (sort_model);
assert_entire_model_unreferenced (ref_model);
@@ -563,7 +563,7 @@ ref_count_reorder_single (void)
assert_entire_model_referenced (ref_model, 1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (sort_model);
assert_entire_model_unreferenced (ref_model);
@@ -724,7 +724,7 @@ ref_count_reorder_two (void)
assert_level_referenced (ref_model, 1, &iter1);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (sort_model);
assert_entire_model_unreferenced (ref_model);
@@ -843,7 +843,7 @@ rows_reordered_single_level (void)
gtk_tree_path_free (path);
signal_monitor_free (monitor);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (sort_model);
assert_entire_model_unreferenced (ref_model);
@@ -951,7 +951,7 @@ rows_reordered_two_levels (void)
gtk_tree_path_free (child_path);
signal_monitor_free (monitor);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (sort_model);
g_object_unref (ref_model);
@@ -1023,7 +1023,7 @@ sorted_insert (void)
gtk_tree_path_free (path);
signal_monitor_free (monitor);
- gtk_widget_destroy (tree_view);
+ g_object_unref (g_object_ref_sink (tree_view));
g_object_unref (sort_model);
g_object_unref (ref_model);
diff --git a/testsuite/gtk/templates.c b/testsuite/gtk/templates.c
index 80cd084c10..5e2e657852 100644
--- a/testsuite/gtk/templates.c
+++ b/testsuite/gtk/templates.c
@@ -50,11 +50,11 @@ test_dialog_basic (void)
{
GtkWidget *dialog;
- dialog = gtk_dialog_new();
+ dialog = gtk_dialog_new ();
g_assert (GTK_IS_DIALOG (dialog));
g_assert (gtk_dialog_get_content_area (GTK_DIALOG (dialog)) != NULL);
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -67,7 +67,7 @@ test_dialog_override_property (void)
NULL);
g_assert (GTK_IS_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -76,11 +76,11 @@ test_message_dialog_basic (void)
GtkWidget *dialog;
dialog = gtk_message_dialog_new (NULL, 0,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE,
- "Do it hard !");
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CLOSE,
+ "Do it hard !");
g_assert (GTK_IS_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -90,7 +90,7 @@ test_about_dialog_basic (void)
dialog = gtk_about_dialog_new ();
g_assert (GTK_IS_ABOUT_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -101,7 +101,7 @@ test_about_dialog_show (void)
dialog = gtk_about_dialog_new ();
g_assert (GTK_IS_ABOUT_DIALOG (dialog));
show_and_wait (dialog);
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -111,7 +111,7 @@ test_info_bar_basic (void)
infobar = gtk_info_bar_new ();
g_assert (GTK_IS_INFO_BAR (infobar));
- gtk_widget_destroy (infobar);
+ g_object_unref (g_object_ref_sink (infobar));
}
static void
@@ -123,7 +123,7 @@ test_lock_button_basic (void)
permission = g_simple_permission_new (TRUE);
button = gtk_lock_button_new (permission);
g_assert (GTK_IS_LOCK_BUTTON (button));
- gtk_widget_destroy (button);
+ g_object_unref (g_object_ref_sink (button));
g_object_unref (permission);
}
@@ -134,7 +134,7 @@ test_assistant_basic (void)
widget = gtk_assistant_new ();
g_assert (GTK_IS_ASSISTANT (widget));
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
static void
@@ -145,7 +145,7 @@ test_assistant_show (void)
widget = gtk_assistant_new ();
g_assert (GTK_IS_ASSISTANT (widget));
show_and_wait (widget);
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
static void
@@ -155,7 +155,7 @@ test_scale_button_basic (void)
widget = gtk_scale_button_new (0, 100, 10, NULL);
g_assert (GTK_IS_SCALE_BUTTON (widget));
- gtk_widget_destroy (widget);
+ g_object_unref (g_object_ref_sink (widget));
}
static void
@@ -165,7 +165,7 @@ test_volume_button_basic (void)
widget = gtk_volume_button_new ();
g_assert (GTK_IS_VOLUME_BUTTON (widget));
- gtk_widget_destroy (widget);
+ g_object_unref (g_object_ref_sink (widget));
}
static void
@@ -175,7 +175,7 @@ test_statusbar_basic (void)
widget = gtk_statusbar_new ();
g_assert (GTK_IS_STATUSBAR (widget));
- gtk_widget_destroy (widget);
+ g_object_unref (g_object_ref_sink (widget));
}
static void
@@ -185,7 +185,7 @@ test_search_bar_basic (void)
widget = gtk_search_bar_new ();
g_assert (GTK_IS_SEARCH_BAR (widget));
- gtk_widget_destroy (widget);
+ g_object_unref (g_object_ref_sink (widget));
}
static void
@@ -195,7 +195,7 @@ test_action_bar_basic (void)
widget = gtk_action_bar_new ();
g_assert (GTK_IS_ACTION_BAR (widget));
- gtk_widget_destroy (widget);
+ g_object_unref (g_object_ref_sink (widget));
}
static void
@@ -205,7 +205,7 @@ test_app_chooser_widget_basic (void)
widget = gtk_app_chooser_widget_new (NULL);
g_assert (GTK_IS_APP_CHOOSER_WIDGET (widget));
- gtk_widget_destroy (widget);
+ g_object_unref (g_object_ref_sink (widget));
}
static void
@@ -224,7 +224,7 @@ test_app_chooser_dialog_basic (void)
g_timeout_add (500, main_loop_quit_cb, &done);
while (!done)
g_main_context_iteration (NULL, TRUE);
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
static void
@@ -235,7 +235,7 @@ test_color_chooser_dialog_basic (void)
/* This test also tests the internal GtkColorEditor widget */
widget = gtk_color_chooser_dialog_new (NULL, NULL);
g_assert (GTK_IS_COLOR_CHOOSER_DIALOG (widget));
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
static void
@@ -247,15 +247,15 @@ test_color_chooser_dialog_show (void)
widget = gtk_color_chooser_dialog_new (NULL, NULL);
g_assert (GTK_IS_COLOR_CHOOSER_DIALOG (widget));
show_and_wait (widget);
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
/* Avoid warnings from GVFS-RemoteVolumeMonitor */
static gboolean
ignore_gvfs_warning (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer user_data)
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
{
if (g_strcmp0 (log_domain, "GVFS-RemoteVolumeMonitor") == 0)
return FALSE;
@@ -288,7 +288,7 @@ test_file_chooser_widget_basic (void)
while (!done)
g_main_context_iteration (NULL, TRUE);
- gtk_widget_destroy (widget);
+ g_object_unref (g_object_ref_sink (widget));
}
static void
@@ -300,9 +300,9 @@ test_file_chooser_dialog_basic (void)
g_test_log_set_fatal_handler (ignore_gvfs_warning, NULL);
widget = gtk_file_chooser_dialog_new ("The Dialog", NULL,
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- "_OK", GTK_RESPONSE_OK,
- NULL);
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ "_OK", GTK_RESPONSE_OK,
+ NULL);
g_assert (GTK_IS_FILE_CHOOSER_DIALOG (widget));
done = FALSE;
@@ -310,7 +310,7 @@ test_file_chooser_dialog_basic (void)
while (!done)
g_main_context_iteration (NULL, TRUE);
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
static void
@@ -327,7 +327,7 @@ test_file_chooser_dialog_show (void)
g_assert (GTK_IS_FILE_CHOOSER_DIALOG (widget));
show_and_wait (widget);
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
static void
@@ -344,7 +344,7 @@ test_file_chooser_button_basic (void)
while (!done)
g_main_context_iteration (NULL, TRUE);
- gtk_widget_destroy (widget);
+ g_object_unref (g_object_ref_sink (widget));
}
static void
@@ -354,7 +354,7 @@ test_font_button_basic (void)
widget = gtk_font_button_new ();
g_assert (GTK_IS_FONT_BUTTON (widget));
- gtk_widget_destroy (widget);
+ g_object_unref (g_object_ref_sink (widget));
}
static void
@@ -364,7 +364,7 @@ test_font_chooser_widget_basic (void)
widget = gtk_font_chooser_widget_new ();
g_assert (GTK_IS_FONT_CHOOSER_WIDGET (widget));
- gtk_widget_destroy (widget);
+ g_object_unref (g_object_ref_sink (widget));
}
static void
@@ -374,7 +374,7 @@ test_font_chooser_dialog_basic (void)
widget = gtk_font_chooser_dialog_new ("Choose a font !", NULL);
g_assert (GTK_IS_FONT_CHOOSER_DIALOG (widget));
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
static void
@@ -385,7 +385,7 @@ test_font_chooser_dialog_show (void)
widget = gtk_font_chooser_dialog_new ("Choose a font !", NULL);
g_assert (GTK_IS_FONT_CHOOSER_DIALOG (widget));
show_and_wait (widget);
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
#ifdef HAVE_UNIX_PRINT_WIDGETS
@@ -396,7 +396,7 @@ test_page_setup_unix_dialog_basic (void)
widget = gtk_page_setup_unix_dialog_new ("Setup your Page !", NULL);
g_assert (GTK_IS_PAGE_SETUP_UNIX_DIALOG (widget));
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
static void
@@ -407,7 +407,7 @@ test_page_setup_unix_dialog_show (void)
widget = gtk_page_setup_unix_dialog_new ("Setup your Page !", NULL);
g_assert (GTK_IS_PAGE_SETUP_UNIX_DIALOG (widget));
show_and_wait (widget);
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
static void
@@ -417,7 +417,7 @@ test_print_unix_dialog_basic (void)
widget = gtk_print_unix_dialog_new ("Go Print !", NULL);
g_assert (GTK_IS_PRINT_UNIX_DIALOG (widget));
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
static void
@@ -428,7 +428,7 @@ test_print_unix_dialog_show (void)
widget = gtk_print_unix_dialog_new ("Go Print !", NULL);
g_assert (GTK_IS_PRINT_UNIX_DIALOG (widget));
show_and_wait (widget);
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
}
#endif
@@ -442,7 +442,7 @@ main (int argc, char **argv)
/* initialize test program */
gtk_test_init (&argc, &argv);
- /* This environment variable cooperates with gtk_widget_destroy()
+ /* This environment variable cooperates with widget dispose()
* to assert that all automated compoenents are properly finalized
* when a given composite widget is destroyed.
*/
diff --git a/testsuite/gtk/treeview.c b/testsuite/gtk/treeview.c
index 0d7b1222bc..c8b0a5fe14 100644
--- a/testsuite/gtk/treeview.c
+++ b/testsuite/gtk/treeview.c
@@ -68,7 +68,7 @@ test_bug_546005 (void)
NULL, FALSE);
gtk_tree_path_free (path);
- gtk_widget_destroy (view);
+ g_object_unref (g_object_ref_sink (view));
}
static void
@@ -99,7 +99,7 @@ test_bug_539377 (void)
g_assert (gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (view), 10, 10,
&path, NULL) == FALSE);
- gtk_widget_destroy (view);
+ g_object_unref (g_object_ref_sink (view));
}
static void
@@ -155,7 +155,7 @@ test_select_collapsed_row (void)
gtk_tree_path_free (path);
- gtk_widget_destroy (view);
+ g_object_unref (g_object_ref_sink (view));
}
static gboolean
@@ -192,7 +192,6 @@ test_row_separator_height (void)
gtk_list_store_insert_with_values (store, &iter, 3, 0, "Row content", -1);
gtk_list_store_insert_with_values (store, &iter, 4, 0, "Row content", -1);
- /*window = gtk_invisible_new ();*/
window = gtk_window_new ();
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
@@ -225,7 +224,7 @@ test_row_separator_height (void)
g_assert_cmpint (rect.height, ==, height);
g_assert_cmpint (cell_rect.height, ==, height);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static void
@@ -278,7 +277,7 @@ test_selection_count (void)
g_assert_cmpint (gtk_tree_selection_count_selected_rows (selection), ==, 0);
- gtk_widget_destroy (view);
+ g_object_unref (g_object_ref_sink (view));
}
static void
@@ -332,7 +331,7 @@ test_selection_empty (void)
gtk_tree_path_free (path);
- gtk_widget_destroy (view);
+ g_object_unref (g_object_ref_sink (view));
}
int
diff --git a/testsuite/gtk/widget-refcount.c b/testsuite/gtk/widget-refcount.c
new file mode 100644
index 0000000000..d4fc5d8be6
--- /dev/null
+++ b/testsuite/gtk/widget-refcount.c
@@ -0,0 +1,101 @@
+#include
+
+static void
+check_finalized (gpointer data,
+ GObject *where_the_object_was)
+{
+ gboolean *did_finalize = (gboolean *)data;
+
+ *did_finalize = TRUE;
+}
+
+static void
+popover (void)
+{
+ GtkWidget *button = gtk_menu_button_new ();
+ GtkWidget *p = gtk_popover_new ();
+ gboolean finalized = FALSE;
+
+ gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), p);
+
+ /* GtkButton is a normal widget and thus floating */
+ g_assert (g_object_is_floating (button));
+ /* GtkPopver sinks itself */
+ g_assert (!g_object_is_floating (p));
+
+ g_object_weak_ref (G_OBJECT (p), check_finalized, &finalized);
+
+ g_object_ref_sink (button);
+ g_object_unref (button);
+ /* We do NOT unref p since the only reference held to it gets
+ * removed when the button gets disposed. */
+ g_assert (finalized);
+}
+
+static void
+popover2 (void)
+{
+ GtkWidget *button = gtk_menu_button_new ();
+ GtkWidget *p = gtk_popover_new ();
+ gboolean finalized = FALSE;
+
+ gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), p);
+
+ g_assert (g_object_is_floating (button));
+ g_assert (!g_object_is_floating (p));
+
+ g_object_weak_ref (G_OBJECT (p), check_finalized, &finalized);
+
+ g_object_ref_sink (button);
+
+ gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), NULL);
+
+ g_assert (finalized);
+
+ g_object_unref (button);
+}
+
+static void
+filechooserwidget (void)
+{
+ /* We use GtkFileChooserWidget simply because it's a complex widget, that's it. */
+ GtkWidget *w = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
+ gboolean finalized = FALSE;
+
+ g_assert (g_object_is_floating (w));
+ g_object_ref_sink (w);
+ g_object_weak_ref (G_OBJECT (w), check_finalized, &finalized);
+
+ g_object_unref (w);
+
+ g_assert (finalized);
+}
+
+static void
+window (void)
+{
+ GtkWidget *w = gtk_window_new ();
+ gboolean finalized = FALSE;
+
+ /* GTK holds a ref */
+ g_assert (!g_object_is_floating (w));
+ g_object_weak_ref (G_OBJECT (w), check_finalized, &finalized);
+
+ gtk_window_destroy (GTK_WINDOW (w));
+
+ g_assert (finalized);
+}
+
+int
+main (int argc, char **argv)
+{
+ g_test_init (&argc, &argv, NULL);
+ gtk_init ();
+
+ g_test_add_func ("/gtk/widget-refcount/popover", popover);
+ g_test_add_func ("/gtk/widget-refcount/popover2", popover2);
+ g_test_add_func ("/gtk/widget-refcount/filechoosewidget", filechooserwidget);
+ g_test_add_func ("/gtk/widget-refcount/window", window);
+
+ return g_test_run ();
+}
diff --git a/testsuite/gtk/window.c b/testsuite/gtk/window.c
index 847d458f80..c67dfb745b 100644
--- a/testsuite/gtk/window.c
+++ b/testsuite/gtk/window.c
@@ -144,7 +144,7 @@ test_default_size (void)
g_assert_cmpint (w, ==, 300);
g_assert_cmpint (h, ==, 300);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static void
@@ -207,7 +207,7 @@ test_resize (void)
g_assert_cmpint (w, ==, 200);
g_assert_cmpint (h, ==, 400);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static void
@@ -237,7 +237,7 @@ test_resize_popup (void)
g_assert_cmpint (w, ==, 1);
g_assert_cmpint (h, ==, 1);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
static void
@@ -287,7 +287,7 @@ test_show_hide (void)
g_assert_cmpint (w, ==, w1);
g_assert_cmpint (h, ==, h1);
- gtk_widget_destroy (window);
+ gtk_window_destroy (GTK_WINDOW (window));
}
int
diff --git a/testsuite/reftests/reftest-snapshot.c b/testsuite/reftests/reftest-snapshot.c
index 6d9ca10cde..0e2800ec06 100644
--- a/testsuite/reftests/reftest-snapshot.c
+++ b/testsuite/reftests/reftest-snapshot.c
@@ -276,7 +276,7 @@ snapshot_widget (GtkWidget *widget)
g_main_loop_unref (loop);
g_object_unref (paintable);
- gtk_widget_destroy (widget);
+ gtk_window_destroy (GTK_WINDOW (widget));
return surface;
}