[gtk+] Fix fallback menubar size allocation



commit 9e18a521569341486156c75db488e35e16904616
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Nov 16 14:49:21 2013 -0500

    Fix fallback menubar size allocation
    
    When the menubar inserted by GtkApplicationWindow is the widest
    widget in a csd window, its allocation gets cut short. Fix this
    by taking the decoration size into account while calculating
    the size request (it is implicitly taken into account in the
    size allocation phase by _gtk_window_set_allocation).

 gtk/gtkapplicationwindow.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c
index 9c3d1ba..079f4bb 100644
--- a/gtk/gtkapplicationwindow.c
+++ b/gtk/gtkapplicationwindow.c
@@ -547,8 +547,17 @@ gtk_application_window_real_get_preferred_width (GtkWidget *widget,
   if (window->priv->menubar != NULL)
     {
       gint menubar_min_width, menubar_nat_width;
+      gint border_width;
+      GtkBorder border = { 0 };
 
       gtk_widget_get_preferred_width (window->priv->menubar, &menubar_min_width, &menubar_nat_width);
+
+      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+      _gtk_window_get_decoration_size (GTK_WINDOW (widget), &border);
+
+      menubar_min_width += 2 * border_width + border.left + border.right;
+      menubar_nat_width += 2 * border_width + border.left + border.right;
+
       *minimum_width = MAX (*minimum_width, menubar_min_width);
       *natural_width = MAX (*natural_width, menubar_nat_width);
     }
@@ -574,8 +583,17 @@ gtk_application_window_real_get_preferred_width_for_height (GtkWidget *widget,
   if (window->priv->menubar != NULL)
     {
       gint menubar_min_width, menubar_nat_width;
+      gint border_width;
+      GtkBorder border = { 0 };
 
       gtk_widget_get_preferred_width_for_height (window->priv->menubar, menubar_height, &menubar_min_width, 
&menubar_nat_width);
+
+      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+      _gtk_window_get_decoration_size (GTK_WINDOW (widget), &border);
+
+      menubar_min_width += 2 * border_width + border.left + border.right;
+      menubar_nat_width += 2 * border_width + border.left + border.right;
+
       *minimum_width = MAX (*minimum_width, menubar_min_width);
       *natural_width = MAX (*natural_width, menubar_nat_width);
     }


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