Index: eggdropdowntoolbutton.c
===================================================================
RCS file: /cvs/gnome/libegg/libegg/dropdowntoolbutton/eggdropdowntoolbutton.c,v
retrieving revision 1.9
diff -u -p -r1.9 eggdropdowntoolbutton.c
--- eggdropdowntoolbutton.c	16 Sep 2004 11:16:25 -0000	1.9
+++ eggdropdowntoolbutton.c	16 Sep 2004 14:23:26 -0000
@@ -27,6 +27,7 @@
 #include <gtk/gtktogglebutton.h>
 #include <gtk/gtkarrow.h>
 #include <gtk/gtkhbox.h>
+#include <gtk/gtkvbox.h>
 #include <gtk/gtkmenu.h>
 #include <gtk/gtkmain.h>
 #include <gdk/gdkkeysyms.h>
@@ -37,7 +38,9 @@
 struct _EggDropdownToolButtonPrivate
 {
   GtkWidget *button;
+  GtkWidget *arrow;
   GtkWidget *arrow_button;
+  GtkWidget *box;
   GtkMenu   *menu;
 };
 
@@ -99,6 +103,72 @@ egg_dropdown_tool_button_set_tooltip (Gt
 }
 
 static void
+egg_dropdown_tool_button_construct_contents (EggDropdownToolButton *button)
+{
+  EggDropdownToolButtonPrivate *priv;
+  GtkWidget *box;
+  GtkOrientation orientation;
+
+  priv = EGG_DROPDOWN_TOOL_BUTTON_GET_PRIVATE (button);
+
+  orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button));
+
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    {
+      box = gtk_hbox_new (FALSE, 0);
+      gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_DOWN, GTK_SHADOW_NONE);
+    }
+  else
+    {
+      box = gtk_vbox_new (FALSE, 0);
+      gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
+    }
+
+  if (priv->button && priv->button->parent)
+    {
+      g_object_ref (priv->button);
+      gtk_container_remove (GTK_CONTAINER (priv->button->parent),
+                            priv->button);
+      gtk_container_add (GTK_CONTAINER (box), priv->button);
+      g_object_unref (priv->button);
+    }
+
+  if (priv->arrow_button && priv->arrow_button->parent)
+    {
+      g_object_ref (priv->arrow_button);
+      gtk_container_remove (GTK_CONTAINER (priv->arrow_button->parent),
+                            priv->arrow_button);
+      gtk_box_pack_end (GTK_BOX (box), priv->arrow_button,
+                        FALSE, FALSE, 0);
+      g_object_unref (priv->arrow_button);
+    }
+
+  if (priv->box)
+    {
+      /* Note: we are not destroying the button and the arrow_button
+       * here because they were removed from their container above
+       */
+      gtk_widget_destroy (priv->box);
+    }
+
+  priv->box = box;
+
+  gtk_container_add (GTK_CONTAINER (button), priv->box);
+  gtk_widget_show_all (priv->box);
+
+  gtk_widget_queue_resize (GTK_WIDGET (button));
+}
+
+static void
+egg_dropdown_tool_button_toolbar_reconfigured (GtkToolItem *toolitem)
+{
+  egg_dropdown_tool_button_construct_contents (EGG_DROPDOWN_TOOL_BUTTON (toolitem));
+
+  /* chain up */
+  GTK_TOOL_ITEM_CLASS (parent_class)->toolbar_reconfigured (toolitem);
+}
+
+static void
 egg_dropdown_tool_button_class_init (EggDropdownToolButtonClass *klass)
 {
   GObjectClass *object_class;
@@ -113,6 +183,7 @@ egg_dropdown_tool_button_class_init (Egg
 
   object_class->finalize = egg_dropdown_tool_button_finalize;
   toolitem_class->set_tooltip = egg_dropdown_tool_button_set_tooltip;
+  toolitem_class->toolbar_reconfigured = egg_dropdown_tool_button_toolbar_reconfigured;
 
   signals[MENU_ACTIVATED] =
     g_signal_new ("menu-activated",
@@ -174,7 +245,6 @@ menu_position_func (GtkMenu             
   GtkRequisition menu_req;
   GtkOrientation orientation;
   GtkTextDirection direction;
-  int max_x, max_y;
 
   priv = EGG_DROPDOWN_TOOL_BUTTON_GET_PRIVATE (button);
 
@@ -202,15 +272,6 @@ menu_position_func (GtkMenu             
       *y += priv->arrow_button->allocation.height - req.height;
     }
 
-  /* Make sure we are on the screen.  */
-  max_x = MAX (0, gdk_screen_width () - menu_req.width);
-  max_y = MAX (0, gdk_screen_height () - menu_req.height);
-
-  *x = CLAMP (*x, 0, max_x);
-  *y = CLAMP (*y, 0, max_y);
-
-/* FIXME: what is the push_in param? should it be set? afaics it
-   doesn't make any difference... */
   *push_in = TRUE;
 }
 
@@ -295,7 +356,7 @@ button_popup_menu_cb (GtkWidget         
 static void
 egg_dropdown_tool_button_init (EggDropdownToolButton *button)
 {
-  GtkWidget *hbox;
+  GtkWidget *box;
   GtkWidget *arrow;
   GtkWidget *arrow_button;
   GtkWidget *real_button;
@@ -304,27 +365,29 @@ egg_dropdown_tool_button_init (EggDropdo
 
   gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (button), FALSE);
 
-  hbox = gtk_hbox_new (FALSE, 0);
+  box = gtk_hbox_new (FALSE, 0);
 
   real_button = GTK_BIN (button)->child;
   g_object_ref (real_button);
   gtk_container_remove (GTK_CONTAINER (button), real_button);
-  gtk_container_add (GTK_CONTAINER (hbox), real_button);
+  gtk_container_add (GTK_CONTAINER (box), real_button);
   g_object_unref (real_button);
 
   arrow_button = gtk_toggle_button_new ();
-  arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
+  arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
   gtk_button_set_relief (GTK_BUTTON (arrow_button), GTK_RELIEF_NONE);
   gtk_container_add (GTK_CONTAINER (arrow_button), arrow);
 
-  gtk_box_pack_end (GTK_BOX (hbox), arrow_button,
+  gtk_box_pack_end (GTK_BOX (box), arrow_button,
                     FALSE, FALSE, 0);
-  gtk_widget_show_all (hbox);
+  gtk_widget_show_all (box);
 
-  gtk_container_add (GTK_CONTAINER (button), hbox);
+  gtk_container_add (GTK_CONTAINER (button), box);
 
   button->priv->button = real_button;
+  button->priv->arrow = arrow;
   button->priv->arrow_button = arrow_button;
+  button->priv->box = box;
 
   g_signal_connect (real_button, "state_changed",
                     G_CALLBACK (button_state_changed_cb), button);
Index: test.c
===================================================================
RCS file: /cvs/gnome/libegg/libegg/dropdowntoolbutton/test.c,v
retrieving revision 1.2
diff -u -p -r1.2 test.c
--- test.c	7 Sep 2004 18:37:13 -0000	1.2
+++ test.c	16 Sep 2004 14:23:26 -0000
@@ -46,6 +46,7 @@ main (int argc, char **argv)
 
 	toolbar = gtk_toolbar_new ();
 	gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
+//	gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar), GTK_ORIENTATION_VERTICAL);
 	gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
 
 	button = gtk_tool_button_new_from_stock (GTK_STOCK_NEW);
