[gtk/kill-display-changed: 1/2] gtk: Use root/unroot instead of display-changed



commit 965d0e04d1be1f172afe4c6b3d38f5ec547ffcb0
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 2 00:08:49 2019 +0000

    gtk: Use root/unroot instead of display-changed
    
    The display-changed signal is going away

 gtk/gtkbutton.c            | 15 -------
 gtk/gtkfilechooserbutton.c | 12 ++----
 gtk/gtkfilechooserwidget.c | 29 +++-----------
 gtk/gtkfontchooserwidget.c | 57 +++++++++------------------
 gtk/gtklabel.c             | 98 +++++++++++++++++++++-------------------------
 gtk/gtkmenushell.c         | 10 ++---
 gtk/gtkpathbar.c           | 25 ++++++------
 gtk/gtktext.c              | 10 ++---
 gtk/gtktoolbar.c           | 54 ++++++++++++-------------
 9 files changed, 123 insertions(+), 187 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 8414bec0e3..7f3154b955 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -129,8 +129,6 @@ static void gtk_button_get_property   (GObject            *object,
                                        guint               prop_id,
                                        GValue             *value,
                                        GParamSpec         *pspec);
-static void gtk_button_display_changed (GtkWidget         *widget,
-                                       GdkDisplay        *previous_display);
 static void gtk_button_unrealize (GtkWidget * widget);
 static void gtk_real_button_clicked (GtkButton * button);
 static void gtk_real_button_activate  (GtkButton          *button);
@@ -204,7 +202,6 @@ gtk_button_class_init (GtkButtonClass *klass)
   gobject_class->set_property = gtk_button_set_property;
   gobject_class->get_property = gtk_button_get_property;
 
-  widget_class->display_changed = gtk_button_display_changed;
   widget_class->unrealize = gtk_button_unrealize;
   widget_class->state_flags_changed = gtk_button_state_flags_changed;
   widget_class->grab_notify = gtk_button_grab_notify;
@@ -923,18 +920,6 @@ gtk_button_get_use_underline (GtkButton *button)
   return priv->use_underline;
 }
 
-static void
-gtk_button_display_changed (GtkWidget  *widget,
-                            GdkDisplay *previous_display)
-{
-  GtkButton *button = GTK_BUTTON (widget);
-  GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
-
-  /* If the button is being pressed while the display changes the
-    release might never occur, so we reset the state. */
-  priv->button_down = FALSE;
-}
-
 static void
 gtk_button_state_flags_changed (GtkWidget     *widget,
                                 GtkStateFlags  previous_state)
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index f7d4e3d49a..f6bc943746 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -256,12 +256,11 @@ static void     gtk_file_chooser_button_drag_data_received (GtkWidget        *wi
                                                            GtkSelectionData *data);
 static void     gtk_file_chooser_button_show               (GtkWidget        *widget);
 static void     gtk_file_chooser_button_hide               (GtkWidget        *widget);
+static void     gtk_file_chooser_button_root               (GtkWidget *widget);
 static void     gtk_file_chooser_button_map                (GtkWidget        *widget);
 static gboolean gtk_file_chooser_button_mnemonic_activate  (GtkWidget        *widget,
                                                            gboolean          group_cycling);
 static void     gtk_file_chooser_button_style_updated      (GtkWidget        *widget);
-static void     gtk_file_chooser_button_display_changed    (GtkWidget        *widget,
-                                                           GdkDisplay       *old_display);
 static void     gtk_file_chooser_button_state_flags_changed (GtkWidget       *widget,
                                                              GtkStateFlags    previous_state);
 
@@ -395,7 +394,7 @@ gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
   widget_class->hide = gtk_file_chooser_button_hide;
   widget_class->map = gtk_file_chooser_button_map;
   widget_class->style_updated = gtk_file_chooser_button_style_updated;
-  widget_class->display_changed = gtk_file_chooser_button_display_changed;
+  widget_class->root = gtk_file_chooser_button_root;
   widget_class->mnemonic_activate = gtk_file_chooser_button_mnemonic_activate;
   widget_class->state_flags_changed = gtk_file_chooser_button_state_flags_changed;
   widget_class->measure = gtk_file_chooser_button_measure;
@@ -1494,16 +1493,13 @@ gtk_file_chooser_button_style_updated (GtkWidget *widget)
 }
 
 static void
-gtk_file_chooser_button_display_changed (GtkWidget  *widget,
-                                        GdkDisplay *old_display)
+gtk_file_chooser_button_root (GtkWidget *widget)
 {
-  if (GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->display_changed)
-    GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->display_changed (widget, old_display);
+  GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->root (widget);
 
   change_icon_theme (GTK_FILE_CHOOSER_BUTTON (widget));
 }
 
-
 /* ******************* *
  *  Utility Functions  *
  * ******************* */
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index ad0ebf8991..915c615b78 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -461,8 +461,6 @@ static void     gtk_file_chooser_widget_unmap          (GtkWidget             *w
 static void     gtk_file_chooser_widget_root           (GtkWidget             *widget);
 static void     gtk_file_chooser_widget_unroot         (GtkWidget             *widget);
 static void     gtk_file_chooser_widget_style_updated   (GtkWidget             *widget);
-static void     gtk_file_chooser_widget_display_changed (GtkWidget            *widget,
-                                                         GdkDisplay           *previous_display);
 
 static gboolean       gtk_file_chooser_widget_set_current_folder           (GtkFileChooser    *chooser,
                                                                             GFile             *folder,
@@ -536,6 +534,7 @@ static void search_shortcut_handler (GtkFileChooserWidget *impl);
 static void recent_shortcut_handler (GtkFileChooserWidget *impl);
 static void places_shortcut_handler (GtkFileChooserWidget *impl);
 static void update_appearance       (GtkFileChooserWidget *impl);
+static void check_icon_theme (GtkFileChooserWidget *impl);
 
 static void operation_mode_set (GtkFileChooserWidget *impl, OperationMode mode);
 static void location_mode_set  (GtkFileChooserWidget *impl, LocationMode new_mode);
@@ -3538,6 +3537,10 @@ gtk_file_chooser_widget_unroot (GtkWidget *widget)
       priv->toplevel_current_focus_widget = NULL;
     }
 
+  remove_settings_signal (impl, gtk_widget_get_display (widget));
+  check_icon_theme (impl);
+  emit_default_size_changed (impl);
+
   GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->unroot (widget);
 }
 
@@ -3622,27 +3625,6 @@ gtk_file_chooser_widget_style_updated (GtkWidget *widget)
   profile_end ("end", NULL);
 }
 
-static void
-gtk_file_chooser_widget_display_changed (GtkWidget  *widget,
-                                         GdkDisplay *previous_display)
-{
-  GtkFileChooserWidget *impl;
-
-  profile_start ("start", NULL);
-
-  impl = GTK_FILE_CHOOSER_WIDGET (widget);
-
-  if (GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->display_changed)
-    GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->display_changed (widget, previous_display);
-
-  remove_settings_signal (impl, previous_display);
-  check_icon_theme (impl);
-
-  emit_default_size_changed (impl);
-
-  profile_end ("end", NULL);
-}
-
 static void
 set_sort_column (GtkFileChooserWidget *impl)
 {
@@ -7919,7 +7901,6 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
   widget_class->root = gtk_file_chooser_widget_root;
   widget_class->unroot = gtk_file_chooser_widget_unroot;
   widget_class->style_updated = gtk_file_chooser_widget_style_updated;
-  widget_class->display_changed = gtk_file_chooser_widget_display_changed;
 
   /*
    * Signals
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index b5cc584c77..a7f1ff6e0a 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -169,9 +169,6 @@ static void gtk_font_chooser_widget_get_property         (GObject         *objec
                                                           GParamSpec      *pspec);
 static void gtk_font_chooser_widget_finalize             (GObject         *object);
 
-static void gtk_font_chooser_widget_display_changed      (GtkWidget       *widget,
-                                                          GdkDisplay      *previous_display);
-
 static gboolean gtk_font_chooser_widget_find_font        (GtkFontChooserWidget *fontchooser,
                                                           const PangoFontDescription *font_desc,
                                                           GtkTreeIter          *iter);
@@ -670,21 +667,40 @@ gtk_font_chooser_widget_unmap (GtkWidget *widget)
   GTK_WIDGET_CLASS (gtk_font_chooser_widget_parent_class)->unmap (widget);
 }
 
+static void
+fontconfig_changed (GtkFontChooserWidget *fontchooser)
+{
+  gtk_font_chooser_widget_load_fonts (fontchooser, TRUE);
+}
+
 static void
 gtk_font_chooser_widget_root (GtkWidget *widget)
 {
+  GtkSettings *settings;
+
   GTK_WIDGET_CLASS (gtk_font_chooser_widget_parent_class)->root (widget);
 
   g_signal_connect_swapped (gtk_widget_get_root (widget), "notify::focus-widget",
                             G_CALLBACK (update_key_capture), widget);
+
+  settings = gtk_widget_get_settings (widget);
+  g_signal_connect_object (settings, "notify::gtk-fontconfig-timestamp",
+                           G_CALLBACK (fontconfig_changed), widget, G_CONNECT_SWAPPED);
+
+  gtk_font_chooser_widget_load_fonts (GTK_FONT_CHOOSER_WIDGET (widget), FALSE);
  }
 
 static void
 gtk_font_chooser_widget_unroot (GtkWidget *widget)
 {
+  GtkSettings *settings;
+
   g_signal_handlers_disconnect_by_func (gtk_widget_get_root (widget),
                                         update_key_capture, widget);
 
+  settings = gtk_widget_get_settings (widget);
+  g_signal_handlers_disconnect_by_func (settings, fontconfig_changed, widget);
+
   GTK_WIDGET_CLASS (gtk_font_chooser_widget_parent_class)->unroot (widget);
 }
 
@@ -743,7 +759,6 @@ gtk_font_chooser_widget_class_init (GtkFontChooserWidgetClass *klass)
   g_type_ensure (GTK_TYPE_DELAYED_FONT_DESCRIPTION);
   g_type_ensure (G_TYPE_THEMED_ICON);
 
-  widget_class->display_changed = gtk_font_chooser_widget_display_changed;
   widget_class->measure = gtk_font_chooser_widget_measure;
   widget_class->size_allocate = gtk_font_chooser_widget_size_allocate;
   widget_class->root = gtk_font_chooser_widget_root;
@@ -1308,40 +1323,6 @@ gtk_font_chooser_widget_find_font (GtkFontChooserWidget        *fontchooser,
   return valid;
 }
 
-static void
-fontconfig_changed (GtkFontChooserWidget *fontchooser)
-{
-  gtk_font_chooser_widget_load_fonts (fontchooser, TRUE);
-}
-
-static void
-gtk_font_chooser_widget_display_changed (GtkWidget  *widget,
-                                         GdkDisplay *previous_display)
-{
-  GtkFontChooserWidget *fontchooser = GTK_FONT_CHOOSER_WIDGET (widget);
-  GtkSettings *settings;
-
-  if (GTK_WIDGET_CLASS (gtk_font_chooser_widget_parent_class)->display_changed)
-    GTK_WIDGET_CLASS (gtk_font_chooser_widget_parent_class)->display_changed (widget, previous_display);
-
-  if (previous_display)
-    {
-      settings = gtk_settings_get_for_display (previous_display);
-      g_signal_handlers_disconnect_by_func (settings, fontconfig_changed, widget);
-    }
-  settings = gtk_widget_get_settings (widget);
-  g_signal_connect_object (settings, "notify::gtk-fontconfig-timestamp",
-                           G_CALLBACK (fontconfig_changed), widget, G_CONNECT_SWAPPED);
-
-  if (previous_display == NULL)
-    previous_display = gdk_display_get_default ();
-
-  if (previous_display == gtk_widget_get_display (widget))
-    return;
-
-  gtk_font_chooser_widget_load_fonts (fontchooser, FALSE);
-}
-
 static PangoFontFamily *
 gtk_font_chooser_widget_get_family (GtkFontChooser *chooser)
 {
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 5d18a7567f..e883b961f3 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -456,8 +456,6 @@ static void gtk_label_set_markup_internal        (GtkLabel      *label,
 static void gtk_label_recalculate                (GtkLabel      *label);
 static void gtk_label_root                       (GtkWidget     *widget);
 static void gtk_label_unroot                     (GtkWidget     *widget);
-static void gtk_label_display_changed            (GtkWidget     *widget,
-                                                 GdkDisplay    *old_display);
 static gboolean gtk_label_popup_menu             (GtkWidget     *widget);
 
 static void gtk_label_set_selectable_hint (GtkLabel *label);
@@ -609,7 +607,6 @@ gtk_label_class_init (GtkLabelClass *class)
   widget_class->unmap = gtk_label_unmap;
   widget_class->root = gtk_label_root;
   widget_class->unroot = gtk_label_unroot;
-  widget_class->display_changed = gtk_label_display_changed;
   widget_class->mnemonic_activate = gtk_label_mnemonic_activate;
   widget_class->drag_data_get = gtk_label_drag_data_get;
   widget_class->grab_focus = gtk_label_grab_focus;
@@ -1803,28 +1800,6 @@ gtk_label_setup_mnemonic (GtkLabel  *label,
   g_object_set_qdata (G_OBJECT (label), quark_mnemonic_menu, mnemonic_menu);
 }
 
-static void
-gtk_label_root (GtkWidget *widget)
-{
-  GtkLabel *label = GTK_LABEL (widget);
-  GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
-
-  GTK_WIDGET_CLASS (gtk_label_parent_class)->root (widget);
-
-  gtk_label_setup_mnemonic (label, gtk_widget_get_toplevel (widget), priv->mnemonic_keyval);
-}
-
-static void
-gtk_label_unroot (GtkWidget *widget)
-{
-  GtkLabel *label = GTK_LABEL (widget);
-  GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
-
-  gtk_label_setup_mnemonic (label, NULL, priv->mnemonic_keyval);
-
-  GTK_WIDGET_CLASS (gtk_label_parent_class)->unroot (widget);
-}
-
 static void
 label_shortcut_setting_apply (GtkLabel *label)
 {
@@ -1861,6 +1836,50 @@ label_shortcut_setting_changed (GtkSettings *settings)
   g_list_free (list);
 }
 
+static void
+gtk_label_root (GtkWidget *widget)
+{
+  GtkLabel *label = GTK_LABEL (widget);
+  GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
+  GtkSettings *settings;
+  gboolean shortcuts_connected;
+
+  GTK_WIDGET_CLASS (gtk_label_parent_class)->root (widget);
+
+  gtk_label_setup_mnemonic (label, gtk_widget_get_toplevel (widget), priv->mnemonic_keyval);
+
+  /* The PangoContext is replaced when the display changes, so clear the layouts */
+  gtk_label_clear_layout (GTK_LABEL (widget));
+
+  settings = gtk_widget_get_settings (widget);
+
+  shortcuts_connected =
+    GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (settings), quark_shortcuts_connected));
+
+  if (! shortcuts_connected)
+    {
+      g_signal_connect (settings, "notify::gtk-enable-accels",
+                        G_CALLBACK (label_shortcut_setting_changed),
+                        NULL);
+
+      g_object_set_qdata (G_OBJECT (settings), quark_shortcuts_connected,
+                         GINT_TO_POINTER (TRUE));
+    }
+
+  label_shortcut_setting_apply (GTK_LABEL (widget));
+}
+
+static void
+gtk_label_unroot (GtkWidget *widget)
+{
+  GtkLabel *label = GTK_LABEL (widget);
+  GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
+
+  gtk_label_setup_mnemonic (label, NULL, priv->mnemonic_keyval);
+
+  GTK_WIDGET_CLASS (gtk_label_parent_class)->unroot (widget);
+}
+
 static void
 mnemonics_visible_apply (GtkWidget *widget,
                          gboolean   mnemonics_visible)
@@ -1913,35 +1932,6 @@ label_mnemonics_visible_changed (GtkWindow  *window,
                         GINT_TO_POINTER (mnemonics_visible));
 }
 
-static void
-gtk_label_display_changed (GtkWidget  *widget,
-                          GdkDisplay *old_display)
-{
-  GtkSettings *settings;
-  gboolean shortcuts_connected;
-
-  /* The PangoContext is replaced when the display changes, so clear the layouts */
-  gtk_label_clear_layout (GTK_LABEL (widget));
-
-  settings = gtk_widget_get_settings (widget);
-
-  shortcuts_connected =
-    GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (settings), quark_shortcuts_connected));
-
-  if (! shortcuts_connected)
-    {
-      g_signal_connect (settings, "notify::gtk-enable-accels",
-                        G_CALLBACK (label_shortcut_setting_changed),
-                        NULL);
-
-      g_object_set_qdata (G_OBJECT (settings), quark_shortcuts_connected,
-                         GINT_TO_POINTER (TRUE));
-    }
-
-  label_shortcut_setting_apply (GTK_LABEL (widget));
-}
-
-
 static void
 label_mnemonic_widget_weak_notify (gpointer      data,
                                   GObject      *where_the_object_was)
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index de698d8463..c3150aa1b2 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -118,8 +118,7 @@ static gboolean gtk_menu_shell_key_press     (GtkEventControllerKey *key,
                                               guint                  keycode,
                                               GdkModifierType        modifiers,
                                               GtkWidget             *widget);
-static void gtk_menu_shell_display_changed   (GtkWidget         *widget,
-                                              GdkDisplay        *previous_display);
+static void gtk_menu_shell_root              (GtkWidget         *widget);
 static void multi_press_pressed  (GtkGestureMultiPress *gesture,
                                   gint                  n_press,
                                   gdouble               x,
@@ -188,7 +187,7 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass)
   object_class->finalize = gtk_menu_shell_finalize;
   object_class->dispose = gtk_menu_shell_dispose;
 
-  widget_class->display_changed = gtk_menu_shell_display_changed;
+  widget_class->root = gtk_menu_shell_root;
 
   container_class->add = gtk_menu_shell_add;
   container_class->remove = gtk_menu_shell_remove;
@@ -945,9 +944,10 @@ gtk_menu_shell_key_press (GtkEventControllerKey *key,
 }
 
 static void
-gtk_menu_shell_display_changed (GtkWidget  *widget,
-                                GdkDisplay *previous_display)
+gtk_menu_shell_root (GtkWidget  *widget)
 {
+  GTK_WIDGET_CLASS (gtk_menu_shell_parent_class)->root (widget);
+
   gtk_menu_shell_reset_key_hash (GTK_MENU_SHELL (widget));
 }
 
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index a9ff9a58a4..1200e01596 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -151,8 +151,8 @@ static gboolean gtk_path_bar_slider_down_defocus  (GtkWidget        *widget,
                                                   GdkEventButton   *event,
                                                   GtkPathBar       *path_bar);
 static void gtk_path_bar_style_updated            (GtkWidget        *widget);
-static void gtk_path_bar_display_changed          (GtkWidget        *widget,
-                                                  GdkDisplay       *previous_display);
+static void gtk_path_bar_root                     (GtkWidget        *widget);
+static void gtk_path_bar_unroot                   (GtkWidget        *widget);
 static void gtk_path_bar_check_icon_theme         (GtkPathBar       *path_bar);
 static void gtk_path_bar_update_button_appearance (GtkPathBar       *path_bar,
                                                   ButtonData       *button_data,
@@ -273,7 +273,8 @@ gtk_path_bar_class_init (GtkPathBarClass *path_bar_class)
   widget_class->measure = gtk_path_bar_measure;
   widget_class->size_allocate = gtk_path_bar_size_allocate;
   widget_class->style_updated = gtk_path_bar_style_updated;
-  widget_class->display_changed = gtk_path_bar_display_changed;
+  widget_class->root = gtk_path_bar_root;
+  widget_class->unroot = gtk_path_bar_unroot;
 
   container_class->add = gtk_path_bar_add;
   container_class->forall = gtk_path_bar_forall;
@@ -729,19 +730,21 @@ gtk_path_bar_style_updated (GtkWidget *widget)
 }
 
 static void
-gtk_path_bar_display_changed (GtkWidget  *widget,
-                             GdkDisplay *previous_display)
+gtk_path_bar_root (GtkWidget *widget)
 {
-  if (GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->display_changed)
-    GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->display_changed (widget, previous_display);
-
-  /* We might nave a new settings, so we remove the old one */
-  if (previous_display)
-    remove_settings_signal (GTK_PATH_BAR (widget), previous_display);
+  GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->root (widget);
 
   gtk_path_bar_check_icon_theme (GTK_PATH_BAR (widget));
 }
 
+static void
+gtk_path_bar_unroot (GtkWidget *widget)
+{
+  remove_settings_signal (GTK_PATH_BAR (widget), gtk_widget_get_display (widget));
+
+  GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->unroot (widget);
+}
+
 static gboolean
 gtk_path_bar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
                                        gdouble                   dx,
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index b5d37bbd77..f026ead3ae 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -324,8 +324,7 @@ static void   gtk_text_direction_changed    (GtkWidget        *widget,
                                              GtkTextDirection  previous_dir);
 static void   gtk_text_state_flags_changed  (GtkWidget        *widget,
                                              GtkStateFlags     previous_state);
-static void   gtk_text_display_changed      (GtkWidget        *widget,
-                                             GdkDisplay       *old_display);
+static void   gtk_text_root                 (GtkWidget        *widget);
 
 static gboolean gtk_text_drag_drop          (GtkWidget        *widget,
                                              GdkDrop          *drop,
@@ -679,7 +678,7 @@ gtk_text_class_init (GtkTextClass *class)
   widget_class->drag_end = gtk_text_drag_end;
   widget_class->direction_changed = gtk_text_direction_changed;
   widget_class->state_flags_changed = gtk_text_state_flags_changed;
-  widget_class->display_changed = gtk_text_display_changed;
+  widget_class->root = gtk_text_root;
   widget_class->mnemonic_activate = gtk_text_mnemonic_activate;
   widget_class->popup_menu = gtk_text_popup_menu;
   widget_class->drag_drop = gtk_text_drag_drop;
@@ -3029,9 +3028,10 @@ gtk_text_state_flags_changed (GtkWidget     *widget,
 }
 
 static void
-gtk_text_display_changed (GtkWidget  *widget,
-                          GdkDisplay *old_display)
+gtk_text_root (GtkWidget *widget)
 {
+  GTK_WIDGET_CLASS (gtk_text_parent_class)->root (widget);
+
   gtk_text_recompute (GTK_TEXT (widget));
 }
 
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index e160874573..b1e59b06d2 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -186,8 +186,8 @@ static gboolean   gtk_toolbar_focus                (GtkWidget           *widget,
                                                    GtkDirectionType     dir);
 static void       gtk_toolbar_move_focus           (GtkWidget           *widget,
                                                    GtkDirectionType     dir);
-static void       gtk_toolbar_display_changed      (GtkWidget           *widget,
-                                                   GdkDisplay          *previous_display);
+static void       gtk_toolbar_root                 (GtkWidget           *widget);
+static void       gtk_toolbar_unroot               (GtkWidget           *widget);
 static void       gtk_toolbar_finalize             (GObject             *object);
 static void       gtk_toolbar_dispose              (GObject             *object);
 static void       gtk_toolbar_add                  (GtkContainer        *container,
@@ -362,7 +362,8 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
                                    GTK_TYPE_TOOLBAR,
                                    G_CALLBACK (gtk_toolbar_move_focus));
 
-  widget_class->display_changed = gtk_toolbar_display_changed;
+  widget_class->root = gtk_toolbar_root;
+  widget_class->unroot = gtk_toolbar_unroot;
   widget_class->popup_menu = gtk_toolbar_popup_menu;
 
   container_class->add    = gtk_toolbar_add;
@@ -1645,41 +1646,40 @@ settings_change_notify (GtkSettings      *settings,
 }
 
 static void
-gtk_toolbar_display_changed (GtkWidget *widget,
-                            GdkDisplay *previous_display)
+gtk_toolbar_root (GtkWidget *widget)
 {
   GtkToolbar *toolbar = GTK_TOOLBAR (widget);
   GtkToolbarPrivate *priv = toolbar->priv;
-  GtkSettings *old_settings = toolbar_get_settings (toolbar);
   GtkSettings *settings;
-  
+
+  GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->root (widget);
+
   settings = gtk_widget_get_settings (GTK_WIDGET (toolbar));
-  
-  if (settings == old_settings)
-    return;
-  
-  if (old_settings)
-    {
-      g_signal_handler_disconnect (old_settings, priv->settings_connection);
-      priv->settings_connection = 0;
-      g_object_unref (old_settings);
-    }
 
-  if (settings)
-    {
-      priv->settings_connection =
-       g_signal_connect (settings, "notify",
-                          G_CALLBACK (settings_change_notify),
-                          toolbar);
+  priv->settings_connection =
+    g_signal_connect (settings, "notify",
+                      G_CALLBACK (settings_change_notify),
+                      toolbar);
 
-      priv->settings = g_object_ref (settings);
-    }
-  else
-    priv->settings = NULL;
+  priv->settings = g_object_ref (settings);
 
   animation_change_notify (toolbar);
 }
 
+static void
+gtk_toolbar_unroot (GtkWidget *widget)
+{
+  GtkToolbar *toolbar = GTK_TOOLBAR (widget);
+  GtkToolbarPrivate *priv = toolbar->priv;
+
+  if (priv->settings_connection)
+    g_signal_handler_disconnect (priv->settings, priv->settings_connection);
+  priv->settings_connection = 0;
+  g_clear_object (&priv->settings);
+
+  GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unroot (widget);
+}
+
 static int
 find_drop_index (GtkToolbar *toolbar,
                 gint        x,


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