From 32a5729d18879676d7aa1388f0b44d0589257650 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 2 Nov 2016 07:16:08 +0100 Subject: [PATCH] gtk: Chain up in realize() ... instead of copy/paste from gtk_widget_real_realize. --- gtk/gtkbutton.c | 11 +++-------- gtk/gtkcolorswatch.c | 10 ++-------- gtk/gtkexpander.c | 10 +++------- gtk/gtkmenuitem.c | 9 ++------- gtk/gtknotebook.c | 9 ++------- gtk/gtkpaned.c | 9 ++------- gtk/gtkpathbar.c | 12 +++--------- gtk/gtkstack.c | 3 +-- gtk/gtktoolbar.c | 9 ++------- gtk/gtktoolitem.c | 10 ++-------- 10 files changed, 22 insertions(+), 70 deletions(-) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index b46eabe7b9..048b2c15e8 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -776,17 +776,12 @@ gtk_button_realize (GtkWidget *widget) GtkButton *button = GTK_BUTTON (widget); GtkButtonPrivate *priv = button->priv; GtkAllocation allocation; - GdkWindow *window; + + GTK_WIDGET_CLASS (gtk_button_parent_class)->realize (widget); gtk_widget_get_allocation (widget, &allocation); - gtk_widget_set_realized (widget, TRUE); - - window = gtk_widget_get_parent_window (widget); - gtk_widget_set_window (widget, window); - g_object_ref (window); - - priv->event_window = gdk_window_new_input (window, + priv->event_window = gdk_window_new_input (gtk_widget_get_window (widget), gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c index 971503ac02..565640a800 100644 --- a/gtk/gtkcolorswatch.c +++ b/gtk/gtkcolorswatch.c @@ -452,16 +452,10 @@ swatch_realize (GtkWidget *widget) { GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget); GtkAllocation allocation; - GdkWindow *window; - gtk_widget_get_allocation (widget, &allocation); - gtk_widget_set_realized (widget, TRUE); + GTK_WIDGET_CLASS (gtk_color_swatch_parent_class)->realize (widget); - window = gtk_widget_get_parent_window (widget); - gtk_widget_set_window (widget, window); - g_object_ref (window); - - swatch->priv->event_window = gdk_window_new_input (window, + swatch->priv->event_window = gdk_window_new_input (gtk_widget_get_window (widget), gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c index 865b654329..4540569da9 100644 --- a/gtk/gtkexpander.c +++ b/gtk/gtkexpander.c @@ -534,17 +534,14 @@ gtk_expander_realize (GtkWidget *widget) { GtkAllocation allocation; GtkExpanderPrivate *priv; - GdkWindow *window; priv = GTK_EXPANDER (widget)->priv; + GTK_WIDGET_CLASS (gtk_expander_parent_class)->realize (widget); + gtk_widget_get_allocation (widget, &allocation); - window = gtk_widget_get_parent_window (widget); - gtk_widget_set_window (widget, window); - g_object_ref (window); - - priv->event_window = gdk_window_new_input (gtk_widget_get_parent_window (widget), + priv->event_window = gdk_window_new_input (gtk_widget_get_window (widget), gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -554,7 +551,6 @@ gtk_expander_realize (GtkWidget *widget) gtk_widget_register_window (widget, priv->event_window); gtk_gesture_set_window (priv->multipress_gesture, priv->event_window); - gtk_widget_set_realized (widget, TRUE); } static void diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index 9330a441e1..f77ea0a1f8 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -1229,17 +1229,12 @@ gtk_menu_item_realize (GtkWidget *widget) GtkMenuItem *menu_item = GTK_MENU_ITEM (widget); GtkMenuItemPrivate *priv = menu_item->priv; GtkAllocation allocation; - GdkWindow *window; - gtk_widget_set_realized (widget, TRUE); - - window = gtk_widget_get_parent_window (widget); - gtk_widget_set_window (widget, window); - g_object_ref (window); + GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->realize (widget); gtk_widget_get_allocation (widget, &allocation); - priv->event_window = gdk_window_new_input (gtk_widget_get_parent_window (widget), + priv->event_window = gdk_window_new_input (gtk_widget_get_window (widget), gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index a15ffd8917..25b6c99f16 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -1818,18 +1818,13 @@ gtk_notebook_realize (GtkWidget *widget) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); GtkNotebookPrivate *priv = notebook->priv; - GdkWindow *window; GdkRectangle event_window_pos; - gtk_widget_set_realized (widget, TRUE); + GTK_WIDGET_CLASS (gtk_notebook_parent_class)->realize (widget); gtk_css_gadget_get_border_allocation (priv->header_gadget, &event_window_pos, NULL); - window = gtk_widget_get_parent_window (widget); - gtk_widget_set_window (widget, window); - g_object_ref (window); - - priv->event_window = gdk_window_new_input (gtk_widget_get_parent_window (widget), + priv->event_window = gdk_window_new_input (gtk_widget_get_window (widget), gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index 33bc901363..99ce300faa 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -1566,15 +1566,10 @@ gtk_paned_realize (GtkWidget *widget) { GtkPaned *paned = GTK_PANED (widget); GtkPanedPrivate *priv = paned->priv; - GdkWindow *window; - gtk_widget_set_realized (widget, TRUE); + GTK_WIDGET_CLASS (gtk_paned_parent_class)->realize (widget); - window = gtk_widget_get_parent_window (widget); - gtk_widget_set_window (widget, window); - g_object_ref (window); - - priv->handle = gdk_window_new_input (window, + priv->handle = gdk_window_new_input (gtk_widget_get_window (widget), gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c index 7ad0c831cc..76dddbcf7d 100644 --- a/gtk/gtkpathbar.c +++ b/gtk/gtkpathbar.c @@ -460,20 +460,14 @@ gtk_path_bar_unmap (GtkWidget *widget) static void gtk_path_bar_realize (GtkWidget *widget) { - GtkPathBar *path_bar; + GtkPathBar *path_bar = GTK_PATH_BAR (widget); GtkAllocation allocation; - GdkWindow *window; - gtk_widget_set_realized (widget, TRUE); - - path_bar = GTK_PATH_BAR (widget); - window = gtk_widget_get_parent_window (widget); - gtk_widget_set_window (widget, window); - g_object_ref (window); + GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->realize (widget); gtk_widget_get_allocation (widget, &allocation); - path_bar->priv->event_window = gdk_window_new_input (gtk_widget_get_parent_window (widget), + path_bar->priv->event_window = gdk_window_new_input (gtk_widget_get_window (widget), gtk_widget_get_events (widget) | GDK_SCROLL_MASK, &allocation); diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c index cf814b7dfb..b865104eef 100644 --- a/gtk/gtkstack.c +++ b/gtk/gtkstack.c @@ -332,8 +332,7 @@ gtk_stack_realize (GtkWidget *widget) GList *l; gint event_mask; - gtk_widget_set_realized (widget, TRUE); - gtk_widget_set_window (widget, g_object_ref (gtk_widget_get_parent_window (widget))); + GTK_WIDGET_CLASS (gtk_stack_parent_class)->realize (widget); gtk_css_gadget_get_content_allocation (priv->gadget, &allocation, NULL); diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index a708506e16..fd2f4f1d0c 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -773,17 +773,12 @@ gtk_toolbar_realize (GtkWidget *widget) GtkAllocation allocation; GtkToolbar *toolbar = GTK_TOOLBAR (widget); GtkToolbarPrivate *priv = toolbar->priv; - GdkWindow *window; - gtk_widget_set_realized (widget, TRUE); + GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->realize (widget); gtk_widget_get_allocation (widget, &allocation); - window = gtk_widget_get_parent_window (widget); - gtk_widget_set_window (widget, window); - g_object_ref (window); - - priv->event_window = gdk_window_new_input (gtk_widget_get_parent_window (widget), + priv->event_window = gdk_window_new_input (gtk_widget_get_window (widget), gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK diff --git a/gtk/gtktoolitem.c b/gtk/gtktoolitem.c index 54e54a1ea0..e7a8a8b8c9 100644 --- a/gtk/gtktoolitem.c +++ b/gtk/gtktoolitem.c @@ -336,15 +336,9 @@ create_drag_window (GtkToolItem *toolitem) static void gtk_tool_item_realize (GtkWidget *widget) { - GtkToolItem *toolitem; - GdkWindow *window; + GtkToolItem *toolitem = GTK_TOOL_ITEM (widget); - toolitem = GTK_TOOL_ITEM (widget); - gtk_widget_set_realized (widget, TRUE); - - window = gtk_widget_get_parent_window (widget); - gtk_widget_set_window (widget, window); - g_object_ref (window); + GTK_WIDGET_CLASS (gtk_tool_item_parent_class)->realize (widget); if (toolitem->priv->use_drag_window) create_drag_window(toolitem);