forked from AuroraMiddleware/gtk
text handle: Stop using ::hierarchy-changed
Use notify::root instead.
This commit is contained in:
parent
9591d40742
commit
3ebf19b783
@ -61,6 +61,7 @@ struct _HandleWindow
|
||||
struct _GtkTextHandlePrivate
|
||||
{
|
||||
HandleWindow windows[2];
|
||||
GtkWidget *toplevel;
|
||||
GtkWidget *parent;
|
||||
GtkScrollable *parent_scrollable;
|
||||
GtkAdjustment *vadj;
|
||||
@ -217,7 +218,7 @@ _gtk_text_handle_ensure_widget (GtkTextHandle *handle,
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
|
||||
priv->windows[pos].widget = g_object_ref_sink (widget);
|
||||
window = gtk_widget_get_ancestor (priv->parent, GTK_TYPE_WINDOW);
|
||||
priv->toplevel = window = gtk_widget_get_ancestor (priv->parent, GTK_TYPE_WINDOW);
|
||||
_gtk_window_add_popover (GTK_WINDOW (window), widget, priv->parent, FALSE);
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
@ -468,7 +469,7 @@ gtk_text_handle_lookup_scrollable (GtkTextHandle *handle)
|
||||
|
||||
static void
|
||||
_gtk_text_handle_parent_hierarchy_changed (GtkWidget *widget,
|
||||
GtkWindow *previous_toplevel,
|
||||
GParamSpec *pspec,
|
||||
GtkTextHandle *handle)
|
||||
{
|
||||
GtkWidget *toplevel, *scrollable;
|
||||
@ -477,11 +478,11 @@ _gtk_text_handle_parent_hierarchy_changed (GtkWidget *widget,
|
||||
priv = handle->priv;
|
||||
toplevel = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
|
||||
|
||||
if (previous_toplevel && !toplevel)
|
||||
if (priv->toplevel && !toplevel)
|
||||
{
|
||||
if (priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_START].widget)
|
||||
{
|
||||
_gtk_window_remove_popover (GTK_WINDOW (previous_toplevel),
|
||||
_gtk_window_remove_popover (GTK_WINDOW (priv->toplevel),
|
||||
priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_START].widget);
|
||||
g_object_unref (priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_START].widget);
|
||||
priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_START].widget = NULL;
|
||||
@ -489,11 +490,13 @@ _gtk_text_handle_parent_hierarchy_changed (GtkWidget *widget,
|
||||
|
||||
if (priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_END].widget)
|
||||
{
|
||||
_gtk_window_remove_popover (GTK_WINDOW (previous_toplevel),
|
||||
_gtk_window_remove_popover (GTK_WINDOW (priv->toplevel),
|
||||
priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_END].widget);
|
||||
g_object_unref (priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_END].widget);
|
||||
priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_END].widget = NULL;
|
||||
}
|
||||
|
||||
priv->toplevel = NULL;
|
||||
}
|
||||
|
||||
scrollable = gtk_text_handle_lookup_scrollable (handle);
|
||||
@ -521,7 +524,7 @@ _gtk_text_handle_set_parent (GtkTextHandle *handle,
|
||||
if (parent)
|
||||
{
|
||||
priv->hierarchy_changed_id =
|
||||
g_signal_connect (parent, "hierarchy-changed",
|
||||
g_signal_connect (parent, "notify::root",
|
||||
G_CALLBACK (_gtk_text_handle_parent_hierarchy_changed),
|
||||
handle);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user