[maemo-commits] [maemo-commits] r16205 - in projects/haf/trunk/gtk+: . gtk

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Sep 24 14:05:29 EEST 2008
Author: mitch
Date: 2008-09-24 14:05:27 +0300 (Wed, 24 Sep 2008)
New Revision: 16205

Modified:
   projects/haf/trunk/gtk+/ChangeLog
   projects/haf/trunk/gtk+/gtk/gtkcombobox.c
   projects/haf/trunk/gtk+/gtk/gtkentry.c
Log:
2008-09-24  Michael Natterer  <mitch at imendio.com>

	Fixes NB#87440: Combobox popup not moving with the combobox

	Merged code from upstream that repositions the popups when
	the widgets change size. Patch by Christian Dywan:

	* gtk/gtkentry.c: remove #ifdef MAEMO_CHANGES since the same
	code is in upstream.

	* gtk/gtkcombobox.c: move the popup around here too when the
	combobox changes its allocation.



Modified: projects/haf/trunk/gtk+/ChangeLog
===================================================================
--- projects/haf/trunk/gtk+/ChangeLog	2008-09-24 10:10:20 UTC (rev 16204)
+++ projects/haf/trunk/gtk+/ChangeLog	2008-09-24 11:05:27 UTC (rev 16205)
@@ -1,3 +1,16 @@
+2008-09-24  Michael Natterer  <mitch at imendio.com>
+
+	Fixes NB#87440: Combobox popup not moving with the combobox
+
+	Merged code from upstream that repositions the popups when
+	the widgets change size. Patch by Christian Dywan:
+
+	* gtk/gtkentry.c: remove #ifdef MAEMO_CHANGES since the same
+	code is in upstream.
+
+	* gtk/gtkcombobox.c: move the popup around here too when the
+	combobox changes its allocation.
+
 2008-09-24  Claudio Saavedra  <csaavedra at igalia.com>
 
 	Released 2:2.12.9-1maemo2

Modified: projects/haf/trunk/gtk+/gtk/gtkcombobox.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkcombobox.c	2008-09-24 10:10:20 UTC (rev 16204)
+++ projects/haf/trunk/gtk+/gtk/gtkcombobox.c	2008-09-24 11:05:27 UTC (rev 16205)
@@ -1622,24 +1622,26 @@
 			     gint     *push_in,
 			     gpointer  user_data)
 {
-  GtkComboBox *combo_box;
+  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
+  GtkComboBoxPrivate *priv = combo_box->priv;
   GtkWidget *menu_item;
 
-  combo_box = GTK_COMBO_BOX (user_data);
-
-  if (combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL)	
+  if (priv->wrap_width > 0 || priv->cell_view == NULL)	
     gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
   else
     {
       /* FIXME handle nested menus better */
-      menu_item = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
+      menu_item = gtk_menu_get_active (GTK_MENU (priv->popup_widget));
       if (menu_item)
-	gtk_menu_shell_select_item (GTK_MENU_SHELL (combo_box->priv->popup_widget), 
+	gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->popup_widget), 
 				    menu_item);
 
       gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
     }
 
+  if (!GTK_WIDGET_VISIBLE (GTK_MENU (priv->popup_widget)->toplevel))
+    gtk_window_set_type_hint (GTK_WINDOW (GTK_MENU (priv->popup_widget)->toplevel),
+                              GDK_WINDOW_TYPE_HINT_COMBO);
 }
 
 static void
@@ -2228,6 +2230,7 @@
                              GtkAllocation *allocation)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
+  GtkComboBoxPrivate *priv = combo_box->priv;
   gint shadow_width, shadow_height;
   gint focus_width, focus_pad;
   GtkAllocation child;
@@ -2319,6 +2322,23 @@
               child.width -= child.x;
             }
 
+          if (GTK_WIDGET_VISIBLE (priv->popup_widget))
+            {
+              gint width;
+              GtkRequisition requisition;
+
+              /* Warning here, without the check in the position func */
+              gtk_menu_reposition (GTK_MENU (priv->popup_widget));
+              if (priv->wrap_width == 0)
+                {
+                  width = GTK_WIDGET (combo_box)->allocation.width;
+                  gtk_widget_set_size_request (priv->popup_widget, -1, -1);
+                  gtk_widget_size_request (priv->popup_widget, &requisition);
+                  gtk_widget_set_size_request (priv->popup_widget,
+                    MAX (width, requisition.width), -1);
+               }
+            }
+
 	  child.width = MAX (1, child.width);
 	  child.height = MAX (1, child.height);
           gtk_widget_size_allocate (GTK_BIN (widget)->child, &child);
@@ -2377,6 +2397,15 @@
 				   GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness);
 	    }
         }
+
+      if (GTK_WIDGET_VISIBLE (priv->popup_window))
+        {
+          gint x, y, width, height;
+          gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
+          gtk_window_move (GTK_WINDOW (priv->popup_window), x, y);
+          gtk_widget_set_size_request (priv->popup_window, width, height);
+        }
+
       
       child.x += shadow_width;
       child.y += shadow_height;

Modified: projects/haf/trunk/gtk+/gtk/gtkentry.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkentry.c	2008-09-24 10:10:20 UTC (rev 16204)
+++ projects/haf/trunk/gtk+/gtk/gtkentry.c	2008-09-24 11:05:27 UTC (rev 16205)
@@ -1613,9 +1613,7 @@
        * be affected by the usize of the entry, if set
        */
       gint x, y, width, height;
-#if defined(MAEMO_CHANGES)
       GtkEntryCompletion *completion;
-#endif
 
       get_widget_window_size (entry, &x, &y, &width, &height);
       
@@ -1629,11 +1627,9 @@
 
       gtk_entry_recompute (entry);
 
-#if defined(MAEMO_CHANGES)
       completion = gtk_entry_get_completion (entry);
       if (completion && GTK_WIDGET_MAPPED (completion->priv->popup_window))
         _gtk_entry_completion_resize_popup (completion);
-#endif
     }
 }
 


More information about the maemo-commits mailing list