[gtk/kill-hierarchy-changed: 10/14] menu bar: Stop using ::hierarchy-changed



commit 3ccbcf9f55dc374d4a676cbceb9fd58da6b60236
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 23 01:06:57 2019 -0500

    menu bar: Stop using ::hierarchy-changed
    
    Use the root and unroot vfuncs instead.

 gtk/gtkmenubar.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index ce5e1388b9..0a5cbca1d1 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -91,8 +91,8 @@ static void gtk_menu_bar_size_allocate     (GtkWidget *widget,
                                             int        width,
                                             int        height,
                                             int        baseline);
-static void gtk_menu_bar_hierarchy_changed (GtkWidget       *widget,
-                                           GtkWidget       *old_toplevel);
+static void gtk_menu_bar_root              (GtkWidget *widget);
+static void gtk_menu_bar_unroot            (GtkWidget *widget);
 static gint gtk_menu_bar_get_popup_delay   (GtkMenuShell    *menu_shell);
 static void gtk_menu_bar_move_current      (GtkMenuShell     *menu_shell,
                                             GtkMenuDirectionType direction);
@@ -117,7 +117,8 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
 
   widget_class->measure = gtk_menu_bar_measure;
   widget_class->size_allocate = gtk_menu_bar_size_allocate;
-  widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
+  widget_class->root = gtk_menu_bar_root;
+  widget_class->unroot = gtk_menu_bar_unroot;
 
   menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
   menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
@@ -536,21 +537,27 @@ remove_from_window (GtkWindow  *window,
 }
 
 static void
-gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
-                               GtkWidget *old_toplevel)
+gtk_menu_bar_root (GtkWidget *widget)
 {
+  GtkMenuBar *menubar = GTK_MENU_BAR (widget);
   GtkWidget *toplevel;  
-  GtkMenuBar *menubar;
 
-  menubar = GTK_MENU_BAR (widget);
+  GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->root (widget);
 
   toplevel = gtk_widget_get_toplevel (widget);
+  add_to_window (GTK_WINDOW (toplevel), menubar);
+}
 
-  if (old_toplevel)
-    remove_from_window (GTK_WINDOW (old_toplevel), menubar);
-  
-  if (gtk_widget_is_toplevel (toplevel))
-    add_to_window (GTK_WINDOW (toplevel), menubar);
+static void
+gtk_menu_bar_unroot (GtkWidget *widget)
+{
+  GtkMenuBar *menubar = GTK_MENU_BAR (widget);
+  GtkWidget *toplevel;
+
+  toplevel = gtk_widget_get_toplevel (widget);
+  remove_from_window (GTK_WINDOW (toplevel), menubar);
+
+  GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->unroot (widget);
 }
 
 /**


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