[nautilus/wip/antoniof/gtk4-preparation-drop-outgoing-api: 4/18] files-view: Handle parent changes in GObject::notify




commit 3c4fc2e899b4a2e484ed0aa24e12d33d8adaa153
Author: Ernestas Kulik <ernestask gnome org>
Date:   Tue Jul 10 15:11:46 2018 +0300

    files-view: Handle parent changes in GObject::notify
    
    GtkWidget::parent-set is gone in GTK4.
    
    Rebased and ammended by António Fernandes <antoniof gnome org>

 src/nautilus-files-view.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index f013fa68c..41b4462a3 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -9434,25 +9434,22 @@ action_stop_enabled_changed (GActionGroup      *action_group,
 }
 
 static void
-nautilus_files_view_parent_set (GtkWidget *widget,
-                                GtkWidget *old_parent)
+on_parent_changed (GObject    *object,
+                   GParamSpec *pspec,
+                   gpointer    user_data)
 {
+    GtkWidget *widget;
     NautilusWindow *window;
     NautilusFilesView *view;
     NautilusFilesViewPrivate *priv;
     GtkWidget *parent;
 
-    view = NAUTILUS_FILES_VIEW (widget);
+    widget = GTK_WIDGET (object);
+    view = NAUTILUS_FILES_VIEW (object);
     priv = nautilus_files_view_get_instance_private (view);
 
     parent = gtk_widget_get_parent (widget);
     window = nautilus_files_view_get_window (view);
-    g_assert (parent == NULL || old_parent == NULL);
-
-    if (GTK_WIDGET_CLASS (nautilus_files_view_parent_class)->parent_set != NULL)
-    {
-        GTK_WIDGET_CLASS (nautilus_files_view_parent_class)->parent_set (widget, old_parent);
-    }
 
     if (priv->stop_signal_handler > 0)
     {
@@ -9468,8 +9465,6 @@ nautilus_files_view_parent_set (GtkWidget *widget,
 
     if (parent != NULL)
     {
-        g_assert (old_parent == NULL);
-
         if (priv->slot == nautilus_window_get_active_slot (window))
         {
             priv->active = TRUE;
@@ -9705,7 +9700,6 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
 
     widget_class->destroy = nautilus_files_view_destroy;
     widget_class->event = nautilus_files_view_event;
-    widget_class->parent_set = nautilus_files_view_parent_set;
     widget_class->grab_focus = nautilus_files_view_grab_focus;
 
 
@@ -9902,6 +9896,10 @@ nautilus_files_view_init (NautilusFilesView *view)
                       "notify::selection",
                       G_CALLBACK (nautilus_files_view_preview_update),
                       view);
+    g_signal_connect (view,
+                      "notify::parent",
+                      G_CALLBACK (on_parent_changed),
+                      NULL);
 
     g_object_unref (builder);
 


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