[gtk/wip/matthiasc/popup5: 12/75] Adapt to new popover lifecycle
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup5: 12/75] Adapt to new popover lifecycle
- Date: Mon, 29 Apr 2019 19:42:56 +0000 (UTC)
commit c2b41c0729dc746d3e305a2ffa8c568e5d5f398d
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Mar 21 22:12:22 2019 -0400
Adapt to new popover lifecycle
We need to unparent popovers in dispose.
gtk/gtkentry.c | 22 ++++++++++++----------
gtk/gtkplacesview.c | 2 ++
gtk/gtkscalebutton.c | 6 +-----
gtk/gtktext.c | 9 ++++++---
4 files changed, 21 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 04d955cea0..d1deda5fd2 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -159,6 +159,7 @@ struct _GtkEntryPrivate
GtkWidget *text;
GtkWidget *progress_widget;
+ GtkWidget *emoji_chooser;
guint show_emoji_icon : 1;
guint editing_canceled : 1; /* Only used by GtkCellRendererText */
@@ -1289,6 +1290,8 @@ gtk_entry_dispose (GObject *object)
}
g_clear_pointer (&priv->text, gtk_widget_unparent);
+ g_clear_pointer (&priv->emoji_chooser, gtk_widget_unparent);
+
gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
gtk_entry_set_icon_tooltip_markup (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
@@ -3448,28 +3451,27 @@ static void
gtk_entry_insert_emoji (GtkEntry *entry)
{
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
- GtkWidget *chooser;
- GdkRectangle rect;
if (gtk_widget_get_ancestor (GTK_WIDGET (entry), GTK_TYPE_EMOJI_CHOOSER) != NULL)
return;
- chooser = GTK_WIDGET (g_object_get_data (G_OBJECT (entry), "gtk-emoji-chooser"));
- if (!chooser)
+ if (!priv->emoji_chooser)
{
- chooser = gtk_emoji_chooser_new ();
- g_object_set_data (G_OBJECT (entry), "gtk-emoji-chooser", chooser);
+ GdkRectangle rect;
+
+ priv->emoji_chooser = gtk_emoji_chooser_new ();
- gtk_popover_set_relative_to (GTK_POPOVER (chooser), GTK_WIDGET (entry));
+ gtk_popover_set_relative_to (GTK_POPOVER (priv->emoji_chooser), GTK_WIDGET (entry));
if (priv->show_emoji_icon)
{
gtk_entry_get_icon_area (entry, GTK_ENTRY_ICON_SECONDARY, &rect);
- gtk_popover_set_pointing_to (GTK_POPOVER (chooser), &rect);
+ gtk_popover_set_pointing_to (GTK_POPOVER (priv->emoji_chooser), &rect);
}
- g_signal_connect_swapped (chooser, "emoji-picked", G_CALLBACK (gtk_entry_enter_text), entry);
+ g_signal_connect_swapped (priv->emoji_chooser, "emoji-picked",
+ G_CALLBACK (gtk_entry_enter_text), entry);
}
- gtk_popover_popup (GTK_POPOVER (chooser));
+ gtk_popover_popup (GTK_POPOVER (priv->emoji_chooser));
}
static void
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index dabb486046..abfcb1278f 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -398,6 +398,8 @@ gtk_places_view_destroy (GtkWidget *widget)
g_cancellable_cancel (priv->cancellable);
g_cancellable_cancel (priv->networks_fetching_cancellable);
+ g_clear_pointer (&priv->server_adresses_popover, gtk_widget_unparent);
+
GTK_WIDGET_CLASS (gtk_places_view_parent_class)->destroy (widget);
}
diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c
index 61a0ed011b..7e76ea9fdd 100644
--- a/gtk/gtkscalebutton.c
+++ b/gtk/gtkscalebutton.c
@@ -491,11 +491,7 @@ gtk_scale_button_dispose (GObject *object)
GtkScaleButton *button = GTK_SCALE_BUTTON (object);
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
- if (priv->dock)
- {
- gtk_widget_destroy (priv->dock);
- priv->dock = NULL;
- }
+ g_clear_pointer (&priv->dock, gtk_widget_unparent);
if (priv->click_id != 0)
{
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 75e17e11aa..bf4d3ebeb9 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -156,6 +156,7 @@ struct _GtkTextPrivate
char *im_module;
+ GtkWidget *emoji_completion;
GtkTextHandle *text_handle;
GtkWidget *selection_bubble;
guint selection_bubble_timeout_id;
@@ -1786,8 +1787,11 @@ gtk_text_dispose (GObject *object)
priv->buffer = NULL;
}
+ g_clear_pointer (&priv->emoji_completion, gtk_widget_unparent);
+
keymap = gdk_display_get_keymap (gtk_widget_get_display (GTK_WIDGET (object)));
g_signal_handlers_disconnect_by_func (keymap, keymap_direction_changed, self);
+
G_OBJECT_CLASS (gtk_text_parent_class)->dispose (object);
}
@@ -6629,10 +6633,9 @@ set_enable_emoji_completion (GtkText *self,
priv->enable_emoji_completion = value;
if (priv->enable_emoji_completion)
- g_object_set_data (G_OBJECT (self), "emoji-completion-popup",
- gtk_emoji_completion_new (self));
+ priv->emoji_completion = gtk_emoji_completion_new (self);
else
- g_object_set_data (G_OBJECT (self), "emoji-completion-popup", NULL);
+ g_clear_pointer (&priv->emoji_completion, gtk_widget_unparent);
g_object_notify_by_pspec (G_OBJECT (self), text_props[PROP_ENABLE_EMOJI_COMPLETION]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]