glom r1659 - in trunk: . glom/utility_widgets glom/utility_widgets/egg/toolpalette



Author: murrayc
Date: Tue Aug 19 13:49:11 2008
New Revision: 1659
URL: http://svn.gnome.org/viewvc/glom?rev=1659&view=rev

Log:
2008-08-19  Murray Cumming  <murrayc murrayc com>

* glom/utility_widgets/egg/toolpalette/eggtoolitemgroup.c:
* glom/utility_widgets/egg/toolpalette/eggtoolitemgroup.h:
* glom/utility_widgets/egg/toolpalette/eggtoolpalette.c:
* glom/utility_widgets/egg/toolpalette/eggtoolpalette.h:
* glom/utility_widgets/egg/toolpalette/eggtoolpaletteprivate.h:
* glom/utility_widgets/egg/toolpalette/testtoolpalette.c: Updated from libegg.
* glom/utility_widgets/sidebar.cc:
* glom/utility_widgets/sidebar.h: Fixed the whitespace.
set_drag_source(): Added the extra parameter for the call to 
egg_tool_palette_set_drag_source().

Modified:
   trunk/ChangeLog
   trunk/glom/utility_widgets/egg/toolpalette/eggtoolitemgroup.c
   trunk/glom/utility_widgets/egg/toolpalette/eggtoolitemgroup.h
   trunk/glom/utility_widgets/egg/toolpalette/eggtoolpalette.c
   trunk/glom/utility_widgets/egg/toolpalette/eggtoolpalette.h
   trunk/glom/utility_widgets/egg/toolpalette/eggtoolpaletteprivate.h
   trunk/glom/utility_widgets/egg/toolpalette/testtoolpalette.c
   trunk/glom/utility_widgets/sidebar.cc
   trunk/glom/utility_widgets/sidebar.h

Modified: trunk/glom/utility_widgets/egg/toolpalette/eggtoolitemgroup.c
==============================================================================
--- trunk/glom/utility_widgets/egg/toolpalette/eggtoolitemgroup.c	(original)
+++ trunk/glom/utility_widgets/egg/toolpalette/eggtoolitemgroup.c	Tue Aug 19 13:49:11 2008
@@ -38,6 +38,15 @@
 #define DEFAULT_COLLAPSED        FALSE
 #define DEFAULT_ELLIPSIZE        PANGO_ELLIPSIZE_NONE
 
+/**
+ * SECTION:EggToolItemGroup
+ * @short_description: A sub container used in a tool palette
+ * @include: eggtoolitemgroup.h
+ *
+ * An #EggToolItemGroup is used together with #EggToolPalette to add #GtkToolItem<!-- -->s to a palette like container
+ * with different categories and drag and drop support.
+ */
+
 enum
 {
   PROP_NONE,
@@ -71,8 +80,10 @@
   gint               header_spacing;
   PangoEllipsizeMode ellipsize;
 
-  guint              collapsed : 1;
+  gulong             focus_set_id;
+  GtkWidget         *toplevel;
 
+  guint              collapsed : 1;
 };
 
 struct _EggToolItemGroupChild
@@ -435,15 +446,35 @@
 }
 
 static void
+egg_tool_item_group_dispose (GObject *object)
+{
+  EggToolItemGroup *group = EGG_TOOL_ITEM_GROUP (object);
+
+  if (group->priv->toplevel)
+    {
+      /* disconnect focus tracking handler */
+      g_signal_handler_disconnect (group->priv->toplevel,
+                                   group->priv->focus_set_id);
+
+      group->priv->focus_set_id = 0;
+      group->priv->toplevel = NULL;
+    }
+
+  G_OBJECT_CLASS (egg_tool_item_group_parent_class)->dispose (object);
+}
+
+static void
 egg_tool_item_group_get_item_size (EggToolItemGroup *group,
-                                   GtkRequisition   *item_size)
+                                   GtkRequisition   *item_size,
+                                   gboolean          homogeneous_only,
+                                   gint             *requested_rows)
 {
   GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (group));
 
   if (EGG_IS_TOOL_PALETTE (parent))
-    _egg_tool_palette_get_item_size (EGG_TOOL_PALETTE (parent), item_size);
+    _egg_tool_palette_get_item_size (EGG_TOOL_PALETTE (parent), item_size, homogeneous_only, requested_rows);
   else
-    _egg_tool_item_group_item_size_request (group, item_size);
+    _egg_tool_item_group_item_size_request (group, item_size, homogeneous_only, requested_rows);
 }
 
 static void
@@ -454,6 +485,7 @@
   EggToolItemGroup *group = EGG_TOOL_ITEM_GROUP (widget);
   GtkOrientation orientation;
   GtkRequisition item_size;
+  gint requested_rows;
 
   if (group->priv->children && egg_tool_item_group_get_name (group))
     {
@@ -466,39 +498,56 @@
       gtk_widget_hide (group->priv->header);
     }
 
-  egg_tool_item_group_get_item_size (group, &item_size);
+  egg_tool_item_group_get_item_size (group, &item_size, FALSE, &requested_rows);
 
   orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group));
 
   if (GTK_ORIENTATION_VERTICAL == orientation)
     requisition->width = MAX (requisition->width, item_size.width);
   else
-    requisition->height = MAX (requisition->height, item_size.height);
+    requisition->height = MAX (requisition->height, item_size.height * requested_rows);
 
   requisition->width += border_width * 2;
   requisition->height += border_width * 2;
 }
 
 static gboolean
-egg_tool_item_group_is_item_visible (GtkToolItem    *item,
-                                     GtkOrientation  orientation)
+egg_tool_item_group_is_item_visible (EggToolItemGroup      *group,
+                                     EggToolItemGroupChild *child)
 {
+  GtkToolbarStyle style;
+  GtkOrientation orientation;
+
+  orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group));
+  style = gtk_tool_shell_get_style (GTK_TOOL_SHELL (group));
+
+  /* horizontal tool palettes with text style support only homogeneous items */
+  if (!child->homogeneous &&
+      GTK_ORIENTATION_HORIZONTAL == orientation &&
+      GTK_TOOLBAR_TEXT == style)
+    return FALSE;
+
   return
-    (GTK_WIDGET_VISIBLE (item)) &&
+    (GTK_WIDGET_VISIBLE (child->item)) &&
     (GTK_ORIENTATION_VERTICAL == orientation ?
-     gtk_tool_item_get_visible_vertical (item) :
-     gtk_tool_item_get_visible_horizontal (item));
+     gtk_tool_item_get_visible_vertical (child->item) :
+     gtk_tool_item_get_visible_horizontal (child->item));
+}
+
+static inline unsigned
+udiv (unsigned x,
+      unsigned y)
+{
+  return (x + y - 1) / y;
 }
 
 static void
-egg_tool_item_group_real_size_allocate (GtkWidget      *widget,
-                                        GtkAllocation  *allocation,
-                                        GtkRequisition *inquery)
+egg_tool_item_group_real_size_query (GtkWidget      *widget,
+                                     GtkAllocation  *allocation,
+                                     GtkRequisition *inquery)
 {
   const gint border_width = GTK_CONTAINER (widget)->border_width;
   EggToolItemGroup *group = EGG_TOOL_ITEM_GROUP (widget);
-  GtkRequisition child_requisition;
-  GtkAllocation child_allocation;
 
   GtkRequisition item_size;
   GtkAllocation item_area;
@@ -506,81 +555,261 @@
   GtkOrientation orientation;
   GtkToolbarStyle style;
 
-  guint n_visible_items;
+  gint min_rows;
 
-  GList *it;
+  orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group));
+  style = gtk_tool_shell_get_style (GTK_TOOL_SHELL (group));
 
-  guint header_width = 0;
+  /* figure out the size of homogeneous items */
+  egg_tool_item_group_get_item_size (group, &item_size, TRUE, &min_rows);
 
-  guint n_columns, n_rows;
+  if (GTK_ORIENTATION_VERTICAL == orientation)
+    item_size.width = MIN (item_size.width, allocation->width);
+  else
+    item_size.height = MIN (item_size.height, allocation->height);
 
-  GtkTextDirection direction = gtk_widget_get_direction (widget);
+  item_area.width = 0;
+  item_area.height = 0;
 
-  if (!inquery)
-    GTK_WIDGET_CLASS (egg_tool_item_group_parent_class)->size_allocate (widget, allocation);
+  /* figure out the required columns (n_columns) and rows (n_rows) to place all items */
+  if (!group->priv->collapsed || group->priv->animation_timeout)
+    {
+      guint n_columns;
+      gint n_rows;
+      GList *it;
 
-  orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group));
-  style = gtk_tool_shell_get_style (GTK_TOOL_SHELL (group));
+      if (GTK_ORIENTATION_VERTICAL == orientation)
+        {
+          gboolean new_row = FALSE;
+          gint row = -1;
+          guint col = 0;
 
-  /* figure out header size */
+          item_area.width = allocation->width - 2 * border_width;
+          n_columns = MAX (item_area.width / item_size.width, 1);
 
-  if (GTK_WIDGET_VISIBLE (group->priv->header))
-    gtk_widget_size_request (group->priv->header, &child_requisition);
-  else
-    child_requisition.width = child_requisition.height = 0;
+          /* calculate required rows for n_columns columns */
+          for (it = group->priv->children; it != NULL; it = it->next)
+            {
+              EggToolItemGroupChild *child = it->data;
 
-  /* figure out item size */
+              if (!egg_tool_item_group_is_item_visible (group, child))
+                continue;
 
-  egg_tool_item_group_get_item_size (group, &item_size);
+              if (new_row || child->new_row)
+                {
+                  new_row = FALSE;
+                  row++;
+                  col = 0;
+                }
 
-  if (GTK_ORIENTATION_VERTICAL == orientation)
-    item_size.width = MIN (item_size.width, allocation->width);
-  else
-    item_size.height = MIN (item_size.height, allocation->height);
+              if (child->expand)
+                new_row = TRUE;
 
-  n_visible_items = 0;
+              if (child->homogeneous)
+                {
+                  col++;
+                  if (col >= n_columns)
+                    new_row = TRUE;
+                }
+              else
+                {
+                  GtkRequisition req = {0, 0};
+                  guint width;
 
-  for (it = group->priv->children; it != NULL; it = it->next)
-    {
-      EggToolItemGroupChild *child = it->data;
+                  gtk_widget_size_request (GTK_WIDGET (child->item), &req);
 
-      if (egg_tool_item_group_is_item_visible (child->item, orientation))
-        n_visible_items += 1;
-    }
+                  width = udiv (req.width, item_size.width);
+                  col += width;
 
-  if (GTK_ORIENTATION_VERTICAL == orientation)
-    {
-      item_area.width = allocation->width - 2 * border_width;
-      n_columns = MAX (item_area.width / item_size.width, 1);
-      n_rows = (n_visible_items + n_columns - 1) / n_columns;
-    }
-  else if (inquery)
-    {
-      item_area.height = allocation->height - 2 * border_width;
-      n_rows = MAX (item_area.height / item_size.height, 1);
-      n_columns = (n_visible_items + n_rows - 1) / n_rows;
+                  if (col > n_columns)
+                    row++;
+
+                  col = width;
+
+                  if (col >= n_columns)
+                    new_row = TRUE;
+                }
+            }
+          n_rows = row + 2;
+        }
+      else
+        {
+          guint *row_min_width;
+          gint row = -1;
+          gboolean new_row = TRUE;
+          guint col = 0, min_col, max_col = 0, all_items = 0;
+          gint i;
+
+          item_area.height = allocation->height - 2 * border_width;
+          n_rows = MAX (item_area.height / item_size.height, min_rows);
+
+          row_min_width = g_new0 (guint, n_rows);
+
+          /* calculate minimal and maximal required cols and minimal required rows */
+          for (it = group->priv->children; it != NULL; it = it->next)
+            {
+              EggToolItemGroupChild *child = it->data;
+
+              if (!egg_tool_item_group_is_item_visible (group, child))
+                continue;
+
+              if (new_row || child->new_row)
+                {
+                  new_row = FALSE;
+                  row++;
+                  col = 0;
+                  row_min_width[row] = 1;
+                }
+
+              if (child->expand)
+                new_row = TRUE;
+
+              if (child->homogeneous)
+                {
+                  col++;
+                  all_items++;
+                }
+              else
+                {
+                  GtkRequisition req = {0, 0};
+                  guint width;
+
+                  gtk_widget_size_request (GTK_WIDGET (child->item), &req);
+
+                  width = udiv (req.width, item_size.width);
+
+                  col += width;
+                  all_items += width;
+
+                  row_min_width[row] = MAX (row_min_width[row], width);
+                }
+
+              max_col = MAX (max_col, col);
+            }
+
+          /* calculate minimal required cols */
+          min_col = udiv (all_items, n_rows);
+
+          for (i = 0; i <= row; i++)
+            {
+              min_col = MAX (min_col, row_min_width[i]);
+            }
+
+          /* simple linear search for minimal required columns for the given maximal number of rows (n_rows) */
+          for (n_columns = min_col; n_columns < max_col; n_columns ++)
+            {
+              new_row = TRUE;
+              row = -1;
+              /* calculate required rows for n_columns columns */
+              for (it = group->priv->children; it != NULL; it = it->next)
+                {
+                  EggToolItemGroupChild *child = it->data;
+
+                  if (!egg_tool_item_group_is_item_visible (group, child))
+                    continue;
+
+                  if (new_row || child->new_row)
+                    {
+                      new_row = FALSE;
+                      row++;
+                      col = 0;
+                    }
+
+                  if (child->expand)
+                    new_row = TRUE;
+
+                  if (child->homogeneous)
+                    {
+                      col++;
+                      if (col >= n_columns)
+                        new_row = TRUE;
+                    }
+                  else
+                    {
+                      GtkRequisition req = {0, 0};
+                      guint width;
+
+                      gtk_widget_size_request (GTK_WIDGET (child->item), &req);
+
+                      width = udiv (req.width, item_size.width);
+                      col += width;
+
+                      if (col > n_columns)
+                        row++;
+
+                      col = width;
+
+                      if (col >= n_columns)
+                        new_row = TRUE;
+                    }
+                }
+
+              if (row < n_rows)
+                break;
+            }
+        }
+
+      item_area.width = item_size.width * n_columns;
+      item_area.height = item_size.height * n_rows;
     }
-  else
+
+  inquery->width = 0;
+  inquery->height = 0;
+
+  /* figure out header widget size */
+  if (GTK_WIDGET_VISIBLE (group->priv->header))
     {
-      item_area.width = allocation->width - 2 * border_width;
+      GtkRequisition child_requisition;
 
-      if (child_requisition.width > 0)
-        item_area.width -= child_requisition.width;
+      gtk_widget_size_request (group->priv->header, &child_requisition);
 
-      n_columns = MAX (item_area.width / item_size.width, 1);
-      n_rows = (n_visible_items + n_columns - 1) / n_columns;
+      if (GTK_ORIENTATION_VERTICAL == orientation)
+        inquery->height += child_requisition.height;
+      else
+        inquery->width += child_requisition.width;
     }
 
-  item_area.width = item_size.width * n_columns;
-  item_area.height = item_size.height * n_rows;
+  /* report effective widget size */
+  inquery->width += item_area.width + 2 * border_width;
+  inquery->height += item_area.height + 2 * border_width;
+}
 
-  /* place the header widget */
+static void
+egg_tool_item_group_real_size_allocate (GtkWidget      *widget,
+                                        GtkAllocation  *allocation)
+{
+  const gint border_width = GTK_CONTAINER (widget)->border_width;
+  EggToolItemGroup *group = EGG_TOOL_ITEM_GROUP (widget);
+  GtkRequisition child_requisition;
+  GtkAllocation child_allocation;
+
+  GtkRequisition item_size;
+  GtkAllocation item_area;
+
+  GtkOrientation orientation;
+  GtkToolbarStyle style;
+
+  GList *it;
+
+  gint n_columns, n_rows = 1;
+  gint min_rows;
+
+  GtkTextDirection direction = gtk_widget_get_direction (widget);
+
+  orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group));
+  style = gtk_tool_shell_get_style (GTK_TOOL_SHELL (group));
+
+  /* chain up */
+  GTK_WIDGET_CLASS (egg_tool_item_group_parent_class)->size_allocate (widget, allocation);
 
   child_allocation.x = border_width;
   child_allocation.y = border_width;
 
+  /* place the header widget */
   if (GTK_WIDGET_VISIBLE (group->priv->header))
     {
+      gtk_widget_size_request (group->priv->header, &child_requisition);
+
       if (GTK_ORIENTATION_VERTICAL == orientation)
         {
           child_allocation.width = allocation->width;
@@ -589,15 +818,13 @@
       else
         {
           child_allocation.width = child_requisition.width;
-	  header_width = child_allocation.width;
           child_allocation.height = allocation->height;
 
-	  if (GTK_TEXT_DIR_RTL == direction)
-            child_allocation.x = allocation->width - border_width - header_width;
+          if (GTK_TEXT_DIR_RTL == direction)
+            child_allocation.x = allocation->width - border_width - child_allocation.width;
         }
 
-      if (!inquery)
-        gtk_widget_size_allocate (group->priv->header, &child_allocation);
+      gtk_widget_size_allocate (group->priv->header, &child_allocation);
 
       if (GTK_ORIENTATION_VERTICAL == orientation)
         child_allocation.y += child_allocation.height;
@@ -606,55 +833,67 @@
       else
         child_allocation.x = border_width;
     }
+  else
+    child_requisition.width = child_requisition.height = 0;
 
-  item_area.x = child_allocation.x;
-  item_area.y = child_allocation.y;
+  /* figure out the size of homogeneous items */
+  egg_tool_item_group_get_item_size (group, &item_size, TRUE, &min_rows);
 
-  if (!inquery)
+  /* figure out the available columns and size of item_area */
+  if (GTK_ORIENTATION_VERTICAL == orientation)
     {
-      if (GTK_ORIENTATION_VERTICAL == orientation)
-        {
-          item_area.width = allocation->width - 2 * border_width - header_width;
-          item_size.width = item_area.width / n_columns;
-        }
-      else
-        {
-          item_area.height = allocation->height - 2 * border_width;
-          item_size.height = item_area.height / n_rows;
-        }
+      item_size.width = MIN (item_size.width, allocation->width);
+
+      item_area.width = allocation->width - 2 * border_width;
+      item_area.height = allocation->height - 2 * border_width - child_requisition.height;
+
+      n_columns = MAX (item_area.width / item_size.width, 1);
+
+      item_size.width = item_area.width / n_columns;
+    }
+  else
+    {
+      item_size.height = MIN (item_size.height, allocation->height);
+
+      item_area.width = allocation->width - 2 * border_width - child_requisition.width;
+      item_area.height = allocation->height - 2 * border_width;
+
+      n_columns = MAX (item_area.width / item_size.width, 1);
+      n_rows = MAX (item_area.height / item_size.height, min_rows);
+
+      item_size.height = item_area.height / n_rows;
     }
 
-  /* otherwise, when expanded or in transition, place the tool items */
+  item_area.x = child_allocation.x;
+  item_area.y = child_allocation.y;
+
+  /* when expanded or in transition, place the tool items in a grid like layout */
   if (!group->priv->collapsed || group->priv->animation_timeout)
     {
-      guint col = 0, row = 0;
+      gint col = 0, row = 0;
 
       for (it = group->priv->children; it != NULL; it = it->next)
         {
           EggToolItemGroupChild *child = it->data;
+          gint col_child;
 
-          if (!egg_tool_item_group_is_item_visible (child->item, orientation))
+          if (!egg_tool_item_group_is_item_visible (group, child))
             {
-              if (!inquery)
-                gtk_widget_set_child_visible (GTK_WIDGET (child->item), FALSE);
+              gtk_widget_set_child_visible (GTK_WIDGET (child->item), FALSE);
 
               continue;
             }
 
+          /* for non homogeneous widgets request the required size */
           child_requisition.width = 0;
-	  if (!child->homogeneous)
-            {
-              if (GTK_ORIENTATION_HORIZONTAL == orientation && GTK_TOOLBAR_TEXT == style)
-                {
-                  /* in horizontal text mode non homogneneous items are not supported */
-                  gtk_widget_set_child_visible (GTK_WIDGET (child->item), FALSE);
-                  continue;
-                }
 
+          if (!child->homogeneous)
+            {
               gtk_widget_size_request (GTK_WIDGET (child->item), &child_requisition);
               child_requisition.width = MIN (child_requisition.width, item_area.width);
             }
 
+          /* select next row if at end of row */
           if (col > 0 && (child->new_row || (col * item_size.width) + MAX (child_requisition.width, item_size.width) > item_area.width))
             {
               row++;
@@ -662,29 +901,34 @@
               child_allocation.y += child_allocation.height;
             }
 
+          col_child = col;
+
+          /* calculate the position and size of the item */
           if (!child->homogeneous)
             {
-              guint col_width;
-              guint width;
+              gint col_width;
+              gint width;
 
-              if (child->expand)
-                col_width = n_columns - col;
+              if (!child->expand)
+                col_width = udiv (child_requisition.width, item_size.width);
               else
-                col_width = (guint) ceil (1.0 * child_requisition.width / item_size.width);
+                col_width = n_columns - col;
 
               width = col_width * item_size.width;
 
+              if (GTK_TEXT_DIR_RTL == direction)
+                col_child = (n_columns - col - col_width);
+
               if (child->fill)
                 {
-                  child_allocation.x = item_area.x + 
-			  (((GTK_TEXT_DIR_RTL == direction) ? (n_columns - col - col_width) : col) * item_size.width);
+                  child_allocation.x = item_area.x + col_child * item_size.width;
                   child_allocation.width = width;
                 }
               else
                 {
-                  child_allocation.x = item_area.x + 
-			  (((GTK_TEXT_DIR_RTL == direction) ? (n_columns - col - col_width) : col) * item_size.width) + 
-			  (width - child_requisition.width) / 2;
+                  child_allocation.x =
+                    (item_area.x + col_child * item_size.width +
+                    (width - child_requisition.width) / 2);
                   child_allocation.width = child_requisition.width;
                 }
 
@@ -692,8 +936,10 @@
             }
           else
             {
-              child_allocation.x = item_area.x + 
-		      (((GTK_TEXT_DIR_RTL == direction) ? (n_columns - col - 1) : col) * item_size.width);
+              if (GTK_TEXT_DIR_RTL == direction)
+                col_child = (n_columns - col - 1);
+
+              child_allocation.x = item_area.x + col_child * item_size.width;
               child_allocation.width = item_size.width;
 
               col++;
@@ -701,11 +947,8 @@
 
           child_allocation.height = item_size.height;
 
-          if (!inquery)
-            {
-              gtk_widget_size_allocate (GTK_WIDGET (child->item), &child_allocation);
-              gtk_widget_set_child_visible (GTK_WIDGET (child->item), TRUE);
-            }
+          gtk_widget_size_allocate (GTK_WIDGET (child->item), &child_allocation);
+          gtk_widget_set_child_visible (GTK_WIDGET (child->item), TRUE);
         }
 
       child_allocation.y += item_size.height;
@@ -713,7 +956,7 @@
 
   /* or just hide all items, when collapsed */
 
-  else if (!inquery)
+  else
     {
       for (it = group->priv->children; it != NULL; it = it->next)
         {
@@ -722,29 +965,129 @@
           gtk_widget_set_child_visible (GTK_WIDGET (child->item), FALSE);
         }
     }
-
-  /* report effective widget size */
-
-  if (inquery)
-    {
-      inquery->width = item_area.width + header_width + 2 * border_width;
-      inquery->height = child_allocation.y + border_width;
-    }
 }
 
 static void
 egg_tool_item_group_size_allocate (GtkWidget     *widget,
                                    GtkAllocation *allocation)
 {
-  egg_tool_item_group_real_size_allocate (widget, allocation, NULL);
+  egg_tool_item_group_real_size_allocate (widget, allocation);
 
   if (GTK_WIDGET_MAPPED (widget))
     gdk_window_invalidate_rect (widget->window, NULL, FALSE);
 }
 
 static void
+egg_tool_item_group_set_focus_cb (GtkWidget *window G_GNUC_UNUSED,
+                                  GtkWidget *widget,
+                                  gpointer   user_data)
+{
+  GtkAdjustment *adjustment;
+  GtkWidget *p;
+
+  /* Find this group's parent widget in the focused widget's anchestry. */
+  for (p = widget; p; p = gtk_widget_get_parent (p))
+    if (p == user_data)
+      {
+        p = gtk_widget_get_parent (p);
+        break;
+      }
+
+  if (EGG_IS_TOOL_PALETTE (p))
+    {
+      /* Check that the focused widgets is fully visible within
+       * the group's parent widget and make it visible otherwise. */
+
+      adjustment = egg_tool_palette_get_hadjustment (EGG_TOOL_PALETTE (p));
+      adjustment = egg_tool_palette_get_vadjustment (EGG_TOOL_PALETTE (p));
+
+      if (adjustment)
+        {
+          int y;
+
+          /* Handle vertical adjustment. */
+          if (gtk_widget_translate_coordinates
+                (widget, p, 0, 0, NULL, &y) && y < 0)
+            {
+              y += adjustment->value;
+              gtk_adjustment_clamp_page (adjustment, y, y + widget->allocation.height);
+            }
+          else if (gtk_widget_translate_coordinates
+                      (widget, p, 0, widget->allocation.height, NULL, &y) &&
+                   y > p->allocation.height)
+            {
+              y += adjustment->value;
+              gtk_adjustment_clamp_page (adjustment, y - widget->allocation.height, y);
+            }
+        }
+
+      adjustment = egg_tool_palette_get_hadjustment (EGG_TOOL_PALETTE (p));
+
+      if (adjustment)
+        {
+          int x;
+
+          /* Handle horizontal adjustment. */
+          if (gtk_widget_translate_coordinates
+                (widget, p, 0, 0, &x, NULL) && x < 0)
+            {
+              x += adjustment->value;
+              gtk_adjustment_clamp_page (adjustment, x, x + widget->allocation.width);
+            }
+          else if (gtk_widget_translate_coordinates
+                      (widget, p, widget->allocation.width, 0, &x, NULL) &&
+                   x > p->allocation.width)
+            {
+              x += adjustment->value;
+              gtk_adjustment_clamp_page (adjustment, x - widget->allocation.width, x);
+            }
+
+          return;
+        }
+    }
+}
+
+static void
+egg_tool_item_group_set_toplevel_window (EggToolItemGroup *group,
+                                         GtkWidget        *toplevel)
+{
+  if (toplevel != group->priv->toplevel)
+    {
+      if (group->priv->toplevel)
+        {
+          /* Disconnect focus tracking handler. */
+          g_signal_handler_disconnect (group->priv->toplevel,
+                                       group->priv->focus_set_id);
+
+          group->priv->focus_set_id = 0;
+          group->priv->toplevel = NULL;
+        }
+
+      if (toplevel)
+        {
+          /* Install focus tracking handler. We connect to the window's
+           * set-focus signal instead of connecting to the focus signal of
+           * each child to:
+           *
+           * 1) Reduce the number of signal handlers used.
+           * 2) Avoid special handling for group headers.
+           * 3) Catch focus grabs not only for direct children,
+           *    but also for nested widgets.
+           */
+          group->priv->focus_set_id =
+            g_signal_connect (toplevel, "set-focus",
+                              G_CALLBACK (egg_tool_item_group_set_focus_cb),
+                              group);
+
+          group->priv->toplevel = toplevel;
+        }
+    }
+}
+
+static void
 egg_tool_item_group_realize (GtkWidget *widget)
 {
+  GtkWidget *toplevel_window;
   const gint border_width = GTK_CONTAINER (widget)->border_width;
   gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
   GdkWindowAttr attributes;
@@ -780,6 +1123,17 @@
                         widget->window);
 
   gtk_widget_queue_resize_no_redraw (widget);
+
+  toplevel_window = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
+  egg_tool_item_group_set_toplevel_window (EGG_TOOL_ITEM_GROUP (widget),
+                                           toplevel_window);
+}
+
+static void
+egg_tool_item_group_unrealize (GtkWidget *widget)
+{
+  egg_tool_item_group_set_toplevel_window (EGG_TOOL_ITEM_GROUP (widget), NULL);
+  GTK_WIDGET_CLASS (egg_tool_item_group_parent_class)->unrealize (widget);
 }
 
 static void
@@ -1090,10 +1444,12 @@
   oclass->set_property       = egg_tool_item_group_set_property;
   oclass->get_property       = egg_tool_item_group_get_property;
   oclass->finalize           = egg_tool_item_group_finalize;
+  oclass->dispose            = egg_tool_item_group_dispose;
 
   wclass->size_request       = egg_tool_item_group_size_request;
   wclass->size_allocate      = egg_tool_item_group_size_allocate;
   wclass->realize            = egg_tool_item_group_realize;
+  wclass->unrealize          = egg_tool_item_group_unrealize;
   wclass->style_set          = egg_tool_item_group_style_set;
 
   cclass->add                = egg_tool_item_group_add;
@@ -1192,12 +1548,28 @@
   g_type_class_add_private (cls, sizeof (EggToolItemGroupPrivate));
 }
 
+/**
+ * egg_tool_item_group_new:
+ * @name: the name of the new group.
+ *
+ * Creates a new tool item group with name @name.
+ *
+ * Returns: a new #EggToolItemGroup.
+ */
 GtkWidget*
 egg_tool_item_group_new (const gchar *name)
 {
   return g_object_new (EGG_TYPE_TOOL_ITEM_GROUP, "name", name, NULL);
 }
 
+/**
+ * egg_tool_item_group_set_name:
+ * @group: an #EggToolItemGroup.
+ * @name: the new name of of the group.
+ *
+ * Sets the name of the tool item group. The name is displayed in the header
+ * of the group.
+ */
 void
 egg_tool_item_group_set_name (EggToolItemGroup *group,
                               const gchar      *name)
@@ -1236,19 +1608,37 @@
   EggToolItemGroup *group = EGG_TOOL_ITEM_GROUP (data);
   gint64 timestamp = egg_tool_item_group_get_animation_timestamp (group);
 
-  /* enque this early to reduce number of expose events */
+  /* Enque this early to reduce number of expose events. */
   gtk_widget_queue_resize_no_redraw (GTK_WIDGET (group));
 
+  /* Figure out current style of the expander arrow. */
+  if (group->priv->collapsed)
+    {
+      if (group->priv->expander_style == GTK_EXPANDER_EXPANDED)
+        group->priv->expander_style = GTK_EXPANDER_SEMI_COLLAPSED;
+      else
+        group->priv->expander_style = GTK_EXPANDER_COLLAPSED;
+    }
+  else
+    {
+      if (group->priv->expander_style == GTK_EXPANDER_COLLAPSED)
+        group->priv->expander_style = GTK_EXPANDER_SEMI_EXPANDED;
+      else
+        group->priv->expander_style = GTK_EXPANDER_EXPANDED;
+    }
+
   if (GTK_WIDGET_REALIZED (group->priv->header))
     {
       GtkWidget *alignment = egg_tool_item_group_get_alignment (group);
       GdkRectangle area;
 
+      /* Find the header button's arrow area... */
       area.x = alignment->allocation.x;
       area.y = alignment->allocation.y + (alignment->allocation.height - group->priv->expander_size) / 2;
       area.height = group->priv->expander_size;
       area.width = group->priv->expander_size;
 
+      /* ... and invalidated it to get it animated. */
       gdk_window_invalidate_rect (group->priv->header->window, &area, TRUE);
     }
 
@@ -1256,10 +1646,11 @@
     {
       GtkWidget *widget = GTK_WIDGET (group);
       GtkWidget *parent = gtk_widget_get_parent (widget);
+      int x, y, width, height;
 
-      gint width = widget->allocation.width;
-      gint height = widget->allocation.height;
-      gint x, y;
+      /* Find the tool item area button's arrow area... */
+      width = widget->allocation.width;
+      height = widget->allocation.height;
 
       gtk_widget_translate_coordinates (widget, parent, 0, 0, &x, &y);
 
@@ -1269,24 +1660,11 @@
           y += group->priv->header->allocation.height;
         }
 
+      /* ... and invalidated it to get it animated. */
       gtk_widget_queue_draw_area (parent, x, y, width, height);
     }
 
-  if (group->priv->collapsed)
-    {
-      if (group->priv->expander_style == GTK_EXPANDER_EXPANDED)
-        group->priv->expander_style = GTK_EXPANDER_SEMI_COLLAPSED;
-      else
-        group->priv->expander_style = GTK_EXPANDER_COLLAPSED;
-    }
-  else
-    {
-      if (group->priv->expander_style == GTK_EXPANDER_COLLAPSED)
-        group->priv->expander_style = GTK_EXPANDER_SEMI_EXPANDED;
-      else
-        group->priv->expander_style = GTK_EXPANDER_EXPANDED;
-    }
-
+  /* Finish animation when done. */
   if (timestamp >= ANIMATION_DURATION)
     group->priv->animation_timeout = NULL;
 
@@ -1301,6 +1679,13 @@
   return (group->priv->animation_timeout != NULL);
 }
 
+/**
+ * egg_tool_item_group_set_collapsed:
+ * @group: an #EggToolItemGroup.
+ * @collapsed: whether the @group should be collapsed or expanded.
+ *
+ * Sets whether the @group should be collapsed or expanded.
+ */
 void
 egg_tool_item_group_set_collapsed (EggToolItemGroup *group,
                                    gboolean          collapsed)
@@ -1322,8 +1707,10 @@
       group->priv->animation_timeout = g_timeout_source_new (ANIMATION_TIMEOUT);
 
       parent = gtk_widget_get_parent (GTK_WIDGET (group));
+
       if (EGG_IS_TOOL_PALETTE (parent) && !collapsed)
-        _egg_tool_palette_set_expanding_child (EGG_TOOL_PALETTE (parent), GTK_WIDGET (group));
+        _egg_tool_palette_set_expanding_child (EGG_TOOL_PALETTE (parent),
+                                               GTK_WIDGET (group));
 
       g_source_set_callback (group->priv->animation_timeout,
                              egg_tool_item_group_animation_cb,
@@ -1334,6 +1721,13 @@
     }
 }
 
+/**
+ * egg_tool_item_group_set_ellipsize:
+ * @group: an #EggToolItemGroup.
+ * @ellipsize: the #PangoEllipsizeMode labels in @group should use.
+ *
+ * Sets the ellipsization mode which should be used by labels in @group.
+ */
 void
 egg_tool_item_group_set_ellipsize (EggToolItemGroup   *group,
                                    PangoEllipsizeMode  ellipsize)
@@ -1351,6 +1745,14 @@
     }
 }
 
+/**
+ * egg_tool_item_group_get_name:
+ * @group: an #EggToolItemGroup.
+ *
+ * Gets the name of @group.
+ *
+ * Returns: the name of @group. The name is an internal string of @group and must not be modified.
+ */
 G_CONST_RETURN gchar*
 egg_tool_item_group_get_name (EggToolItemGroup *group)
 {
@@ -1362,6 +1764,14 @@
   return gtk_label_get_text (GTK_LABEL (label));
 }
 
+/**
+ * egg_tool_item_group_get_collapsed:
+ * @group: an EggToolItemGroup.
+ *
+ * Gets whether @group is collapsed or expanded.
+ *
+ * Returns: %TRUE if @group is collapsed, %FALSE if it is expanded.
+ */
 gboolean
 egg_tool_item_group_get_collapsed (EggToolItemGroup *group)
 {
@@ -1369,6 +1779,14 @@
   return group->priv->collapsed;
 }
 
+/**
+ * egg_tool_item_group_get_ellipsize:
+ * @group: an #EggToolItemGroup.
+ *
+ * Gets the ellipsization mode of @group.
+ *
+ * Returns: the #PangoEllipsizeMode of @group.
+ */
 PangoEllipsizeMode
 egg_tool_item_group_get_ellipsize (EggToolItemGroup *group)
 {
@@ -1376,12 +1794,20 @@
   return group->priv->ellipsize;
 }
 
+/**
+ * egg_tool_item_group_insert:
+ * @group: an #EggToolItemGroup.
+ * @item: the #GtkToolItem to insert into @group.
+ * @position: the position of @item in @group, starting with 0. The position -1 means end of list.
+ *
+ * Inserts @item at @position in the list of children of @group.
+ */
 void
 egg_tool_item_group_insert (EggToolItemGroup *group,
                             GtkToolItem      *item,
                             gint              position)
 {
-  GtkWidget *parent;
+  GtkWidget *parent, *child_widget;
   EggToolItemGroupChild *child;
 
   g_return_if_fail (EGG_IS_TOOL_ITEM_GROUP (group));
@@ -1402,9 +1828,22 @@
   if (EGG_IS_TOOL_PALETTE (parent))
     _egg_tool_palette_child_set_drag_source (GTK_WIDGET (item), parent);
 
+  child_widget = gtk_bin_get_child (GTK_BIN (item));
+
+  if (GTK_IS_BUTTON (child_widget))
+    gtk_button_set_focus_on_click (GTK_BUTTON (child_widget), TRUE);
+
   gtk_widget_set_parent (GTK_WIDGET (item), GTK_WIDGET (group));
 }
 
+/**
+ * egg_tool_item_group_set_item_position:
+ * @group: an #EggToolItemGroup.
+ * @item: the #GtkToolItem to move to a new position, should be a child of @group.
+ * @position: the new position of @item in @group, starting with 0. The position -1 means end of list.
+ *
+ * Sets the position of @item in the list of children of @group.
+ */
 void
 egg_tool_item_group_set_item_position (EggToolItemGroup *group,
                                        GtkToolItem      *item,
@@ -1434,6 +1873,15 @@
     gtk_widget_queue_resize (GTK_WIDGET (group));
 }
 
+/**
+ * egg_tool_item_group_get_item_position:
+ * @group: an #EggToolItemGroup.
+ * @item: a #GtkToolItem.
+ *
+ * Gets the position of @item in @group as index.
+ *
+ * Returns: the index of @item in @group or -1 if @item is no child of @group.
+ */
 gint
 egg_tool_item_group_get_item_position (EggToolItemGroup *group,
                                        GtkToolItem      *item)
@@ -1449,6 +1897,14 @@
   return -1;
 }
 
+/**
+ * egg_tool_item_group_get_n_items:
+ * @group: an #EggToolItemGroup.
+ *
+ * Gets the number of tool items in group.
+ *
+ * Returns: the number of tool items in group.
+ */
 guint
 egg_tool_item_group_get_n_items (EggToolItemGroup *group)
 {
@@ -1457,6 +1913,15 @@
   return g_list_length (group->priv->children);
 }
 
+/**
+ * egg_tool_item_group_get_nth_item:
+ * @group: an #EggToolItemGroup.
+ * @index: the index.
+ *
+ * Gets the tool item at index in group.
+ *
+ * Returns: the #GtkToolItem at index.
+ */
 GtkToolItem*
 egg_tool_item_group_get_nth_item (EggToolItemGroup *group,
                                   guint             index)
@@ -1470,6 +1935,16 @@
   return child != NULL ? child->item : NULL;
 }
 
+/** 
+ * egg_tool_item_group_get_drop_item:
+ * @group: an #EggToolItemGroup.
+ * @x: the x position.
+ * @y: the y position.
+ *
+ * Gets the tool item at position (x, y).
+ *
+ * Returns: the #GtkToolItem at position (x, y).
+ */
 GtkToolItem*
 egg_tool_item_group_get_drop_item (EggToolItemGroup *group,
                                    gint              x,
@@ -1493,7 +1968,7 @@
       GtkToolItem *item = child->item;
       gint x0, y0;
 
-      if (!item || !egg_tool_item_group_is_item_visible (item, orientation))
+      if (!item || !egg_tool_item_group_is_item_visible (group, child))
         continue;
 
       allocation = &GTK_WIDGET (item)->allocation;
@@ -1511,26 +1986,50 @@
 
 void
 _egg_tool_item_group_item_size_request (EggToolItemGroup *group,
-                                        GtkRequisition   *item_size)
+                                        GtkRequisition   *item_size,
+                                        gboolean          homogeneous_only,
+                                        gint             *requested_rows)
 {
   GtkRequisition child_requisition;
   GList *it;
+  gint rows = 0;
+  gboolean new_row = TRUE;
+  GtkOrientation orientation;
+  GtkToolbarStyle style;
 
   g_return_if_fail (EGG_IS_TOOL_ITEM_GROUP (group));
   g_return_if_fail (NULL != item_size);
 
+  orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group));
+  style = gtk_tool_shell_get_style (GTK_TOOL_SHELL (group));
+
   item_size->width = item_size->height = 0;
 
   for (it = group->priv->children; it != NULL; it = it->next)
     {
       EggToolItemGroupChild *child = it->data;
 
+      if (!egg_tool_item_group_is_item_visible (group, child))
+        continue;
+
+      if (child->new_row || new_row)
+        {
+          rows++;
+          new_row = FALSE;
+        }
+
+      if (!child->homogeneous && child->expand)
+          new_row = TRUE;
+
       gtk_widget_size_request (GTK_WIDGET (child->item), &child_requisition);
 
-      if (child->homogeneous)
+      if (!homogeneous_only || child->homogeneous)
         item_size->width = MAX (item_size->width, child_requisition.width);
       item_size->height = MAX (item_size->height, child_requisition.height);
     }
+
+  if (requested_rows)
+    *requested_rows = rows;
 }
 
 void
@@ -1613,8 +2112,8 @@
       else
         allocation.height = limit;
 
-      egg_tool_item_group_real_size_allocate (GTK_WIDGET (group),
-                                              &allocation, &inquery);
+      egg_tool_item_group_real_size_query (GTK_WIDGET (group),
+                                           &allocation, &inquery);
 
       if (vertical)
         inquery.height -= requisition.height;

Modified: trunk/glom/utility_widgets/egg/toolpalette/eggtoolitemgroup.h
==============================================================================
--- trunk/glom/utility_widgets/egg/toolpalette/eggtoolitemgroup.h	(original)
+++ trunk/glom/utility_widgets/egg/toolpalette/eggtoolitemgroup.h	Tue Aug 19 13:49:11 2008
@@ -38,6 +38,11 @@
 typedef struct _EggToolItemGroupClass   EggToolItemGroupClass;
 typedef struct _EggToolItemGroupPrivate EggToolItemGroupPrivate;
 
+/**
+ * EggToolItemGroup:
+ *
+ * This should not be accessed directly. Use the accessor functions below.
+ */
 struct _EggToolItemGroup
 {
   GtkContainer parent_instance;

Modified: trunk/glom/utility_widgets/egg/toolpalette/eggtoolpalette.c
==============================================================================
--- trunk/glom/utility_widgets/egg/toolpalette/eggtoolpalette.c	(original)
+++ trunk/glom/utility_widgets/egg/toolpalette/eggtoolpalette.c	Tue Aug 19 13:49:11 2008
@@ -36,6 +36,72 @@
 
 #define P_(msgid) (msgid)
 
+/**
+ * SECTION:EggToolPalette
+ * @short_description: A tool palette with categories
+ * @include: eggtoolpalette.h
+ *
+ * An #EggToolPalette allows it to add #GtkToolItem<!-- -->s to a palette like container
+ * with different categories and drag and drop support.
+ *
+ * An #EggToolPalette is created with a call to egg_tool_palette_new().
+ *
+ * #GtkToolItem<!-- -->s cannot be added directly to an #EggToolPalette, instead they
+ * are added to an #EggToolItemGroup which can than be added to an #EggToolPalette. To add
+ * an #EggToolItemGroup to an #EggToolPalette use gtk_container_add().
+ *
+ * |[
+ * GtkWidget *palette, *group;
+ * GtkToolItem *item;
+ *
+ * palette = egg_tool_palette_new ();
+ * group = egg_tool_item_group_new (_("Test Category"));
+ * gtk_container_add (GTK_CONTAINER (palette), group);
+ *
+ * item = gtk_tool_button_new_from_stock (GTK_STOCK_OK);
+ * egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (group), item, -1);
+ * ]|
+ *
+ * The easiest way to use drag and drop with EggToolPalette is to call egg_tool_palette_add_drag_dest()
+ * with the desired drag source @palette and the desired drag target @widget. Than egg_tool_palette_get_drag_item()
+ * can be used to get the dragged item in the #GtkWidget::drag-data-received signal handler of the drag target.
+ *
+ * |[
+ * static void
+ * passive_canvas_drag_data_received (GtkWidget        *widget,
+ *                                    GdkDragContext   *context,
+ *                                    gint              x,
+ *                                    gint              y,
+ *                                    GtkSelectionData *selection,
+ *                                    guint             info,
+ *                                    guint             time,
+ *                                    gpointer          data)
+ * {
+ *   GtkWidget *palette;
+ *   GtkWidget *item;
+ *
+ *   /<!-- -->* Get the dragged item *<!-- -->/
+ *   palette = gtk_widget_get_ancestor (gtk_drag_get_source_widget (context), EGG_TYPE_TOOL_PALETTE);
+ *   if (palette != NULL)
+ *     item = egg_tool_palette_get_drag_item (EGG_TOOL_PALETTE (palette), selection);
+ *
+ *   /<!-- -->* Do something with item *<!-- -->/
+ * }
+ *
+ * GtkWidget *target, palette;
+ *
+ * palette = egg_tool_palette_new ();
+ * target = gtk_drawing_area_new ();
+ *
+ * g_signal_connect (G_OBJECT (target), "drag-data-received",
+ *                   G_CALLBACK (passive_canvas_drag_data_received), NULL);   
+ * egg_tool_palette_add_drag_dest (EGG_TOOL_PALETTE (palette), target,
+ *                                 GTK_DEST_DEFAULT_ALL,
+ *                                 EGG_TOOL_PALETTE_DRAG_ITEMS,
+ *                                 GDK_ACTION_COPY);
+ * ]|
+ */
+
 typedef struct _EggToolItemGroupInfo   EggToolItemGroupInfo;
 typedef struct _EggToolPaletteDragData EggToolPaletteDragData;
 
@@ -72,7 +138,6 @@
   GtkAdjustment        *hadjustment;
   GtkAdjustment        *vadjustment;
 
-  GtkRequisition        item_size;
   GtkIconSize           icon_size;
   GtkOrientation        orientation;
   GtkToolbarStyle       style;
@@ -84,7 +149,7 @@
 #endif
 
   guint                 sparse_groups : 1;
-  guint                 drag_source : 1;
+  guint                 drag_source : 2;
 };
 
 struct _EggToolPaletteDragData
@@ -275,9 +340,6 @@
   requisition->width = 0;
   requisition->height = 0;
 
-  palette->priv->item_size.width = 0;
-  palette->priv->item_size.height = 0;
-
   for (i = 0; i < palette->priv->groups_length; ++i)
     {
       EggToolItemGroupInfo *group = &palette->priv->groups[i];
@@ -297,13 +359,6 @@
           requisition->width += child_requisition.width;
           requisition->height = MAX (requisition->height, child_requisition.height);
         }
-
-      _egg_tool_item_group_item_size_request (group->widget, &child_requisition);
-
-      palette->priv->item_size.width = MAX (palette->priv->item_size.width,
-                                            child_requisition.width);
-      palette->priv->item_size.height = MAX (palette->priv->item_size.height,
-                                             child_requisition.height);
     }
 
   requisition->width += border_width * 2;
@@ -364,6 +419,8 @@
   else
     remaining_space = allocation->width;
 
+  /* figure out the required size of all groups to be able to distribute the
+   * remaining space on allocation */
   for (i = 0; i < palette->priv->groups_length; ++i)
     {
       EggToolItemGroupInfo *group = &palette->priv->groups[i];
@@ -390,22 +447,29 @@
       remaining_space -= size;
       group_sizes[i] = size;
 
+      /* if the widget is currently expanding an offset which allows to display as much of the
+       * widget as possible is calculated */
       if (widget == palette->priv->expanding_child)
         {
-          gint j, real_size;
-          gint limit = GTK_ORIENTATION_VERTICAL == palette->priv->orientation ? child_allocation.width : child_allocation.height;
+          gint limit =
+            GTK_ORIENTATION_VERTICAL == palette->priv->orientation ?
+            child_allocation.width : child_allocation.height;
+
+          gint real_size;
+          guint j;
 
           min_offset = 0;
+
           for (j = 0; j < i; ++j)
-            {
-              min_offset += group_sizes[j];
-            }
+            min_offset += group_sizes[j];
+
           max_offset = min_offset + group_sizes[i];
 
-          real_size = _egg_tool_item_group_get_size_for_limit (EGG_TOOL_ITEM_GROUP (widget),
-                                                               limit,
-                                                               GTK_ORIENTATION_VERTICAL == palette->priv->orientation,
-                                                               FALSE);
+          real_size = _egg_tool_item_group_get_size_for_limit
+            (EGG_TOOL_ITEM_GROUP (widget), limit,
+             GTK_ORIENTATION_VERTICAL == palette->priv->orientation,
+             FALSE);
+
           if (size == real_size)
             palette->priv->expanding_child = NULL;
         }
@@ -419,9 +483,11 @@
 
   if (max_offset != -1)
     {
-      gint limit = GTK_ORIENTATION_VERTICAL == palette->priv->orientation ? allocation->height : allocation->width;
+      gint limit =
+        GTK_ORIENTATION_VERTICAL == palette->priv->orientation ?
+        allocation->height : allocation->width;
 
-      offset = MIN(MAX (offset, max_offset - limit), min_offset);
+      offset = MIN (MAX (offset, max_offset - limit), min_offset);
     }
 
   if (remaining_space > 0)
@@ -435,6 +501,7 @@
   else
     x -= offset;
 
+  /* allocate all groups at the calculated positions */
   for (i = 0; i < palette->priv->groups_length; ++i)
     {
       EggToolItemGroupInfo *group = &palette->priv->groups[i];
@@ -493,6 +560,7 @@
       page_start = x;
     }
 
+  /* update the scrollbar to match the displayed adjustment */
   if (adjustment)
     {
       gdouble value;
@@ -500,18 +568,9 @@
       adjustment->page_increment = page_size * 0.9;
       adjustment->step_increment = page_size * 0.1;
       adjustment->page_size = page_size;
-      if (GTK_ORIENTATION_HORIZONTAL == palette->priv->orientation &&
-          GTK_TEXT_DIR_RTL == direction)
-        {
-          adjustment->lower = page_size - MAX (0, page_start);
-          adjustment->upper = page_size;
 
-          offset = -offset;
-
-          value = MAX(offset, adjustment->lower);
-          gtk_adjustment_clamp_page (adjustment, offset, value + page_size);
-        }
-      else
+      if (GTK_ORIENTATION_VERTICAL == palette->priv->orientation ||
+          GTK_TEXT_DIR_LTR == direction)
         {
           adjustment->lower = 0;
           adjustment->upper = MAX (0, page_start);
@@ -519,6 +578,16 @@
           value = MIN (offset, adjustment->upper - adjustment->page_size);
           gtk_adjustment_clamp_page (adjustment, value, offset + page_size);
         }
+      else
+        {
+          adjustment->lower = page_size - MAX (0, page_start);
+          adjustment->upper = page_size;
+
+          offset = -offset;
+
+          value = MAX (offset, adjustment->lower);
+          gtk_adjustment_clamp_page (adjustment, offset, value + page_size);
+        }
 
       gtk_adjustment_changed (adjustment);
     }
@@ -863,12 +932,26 @@
   dnd_target_atom_group = gdk_atom_intern_static_string (dnd_targets[1].target);
 }
 
+/**
+ * egg_tool_palette_new:
+ *
+ * Creates a new tool palette.
+ *
+ * Returns: a new #EggToolPalette.
+ */
 GtkWidget*
 egg_tool_palette_new (void)
 {
   return g_object_new (EGG_TYPE_TOOL_PALETTE, NULL);
 }
 
+/**
+ * egg_tool_palette_set_icon_size:
+ * @palette: an #EggToolPalette.
+ * @icon_size: the #GtkIconSize that icons in the tool palette shall have.
+ *
+ * Sets the size of icons in the tool palette.
+ */
 void
 egg_tool_palette_set_icon_size (EggToolPalette *palette,
                                 GtkIconSize     icon_size)
@@ -879,6 +962,13 @@
     g_object_set (palette, "icon-size", icon_size, NULL);
 }
 
+/**
+ * egg_tool_palette_set_orientation:
+ * @palette: an #EggToolPalette.
+ * @orientation: the #GtkOrientation that the tool palette shall have.
+ *
+ * Sets the orientation (horizontal or vertical) of the tool palette.
+ */
 void
 egg_tool_palette_set_orientation (EggToolPalette *palette,
                                   GtkOrientation  orientation)
@@ -889,6 +979,13 @@
     g_object_set (palette, "orientation", orientation, NULL);
 }
 
+/**
+ * egg_tool_palette_set_style:
+ * @palette: an #EggToolPalette.
+ * @style: the #GtkToolbarStyle that items in the tool palette shall have.
+ *
+ * Sets the style (text, icons or both) of items in the tool palette.
+ */
 void
 egg_tool_palette_set_style (EggToolPalette  *palette,
                             GtkToolbarStyle  style)
@@ -899,6 +996,14 @@
     g_object_set (palette, "style", style, NULL);
 }
 
+/**
+ * egg_tool_palette_get_icon_size:
+ * @palette: an #EggToolPalette.
+ *
+ * Gets the size of icons in the tool palette. See egg_tool_palette_set_icon_size().
+ * 
+ * Returns: the #GtkIconSize of icons in the tool palette.
+ */
 GtkIconSize
 egg_tool_palette_get_icon_size (EggToolPalette *palette)
 {
@@ -906,6 +1011,14 @@
   return palette->priv->icon_size;
 }
 
+/**
+ * egg_tool_palette_get_orientation:
+ * @palette: an #EggToolPalette.
+ *
+ * Gets the orientation (horizontal or vertical) of the tool palette. See egg_tool_palette_set_orientation().
+ *
+ * Returns the #GtkOrientation of the tool palette.
+ */
 GtkOrientation
 egg_tool_palette_get_orientation (EggToolPalette *palette)
 {
@@ -913,6 +1026,14 @@
   return palette->priv->orientation;
 }
 
+/**
+ * egg_tool_palette_get_style:
+ * @palette: an #EggToolPalette.
+ *
+ * Gets the style (icons, text or both) of items in the tool palette.
+ *
+ * Returns: the #GtkToolbarStyle of items in the tool palette.
+ */
 GtkToolbarStyle
 egg_tool_palette_get_style (EggToolPalette *palette)
 {
@@ -920,6 +1041,16 @@
   return palette->priv->style;
 }
 
+/**
+ * egg_tool_palette_set_group_position:
+ * @palette: an #EggToolPalette.
+ * @group: an #EggToolItemGroup which is a child of palette.
+ * @position: a new index for group.
+ *
+ * Sets the position of the group as an index of the tool palette.
+ * If position is 0 the group will become the first child, if position is
+ * -1 it will become the last child.
+ */
 void
 egg_tool_palette_set_group_position (EggToolPalette *palette,
                                      GtkWidget      *group,
@@ -989,6 +1120,15 @@
     }
 }
 
+/**
+ * egg_tool_palette_set_exclusive:
+ * @palette: an #EggToolPalette.
+ * @group: an #EggToolItemGroup which is a child of palette.
+ * @exclusive: whether the group should be exclusive or not.
+ *
+ * Sets whether the group should be exclusive or not. If an exclusive group is expanded
+ * all other groups are collapsed.
+ */
 void
 egg_tool_palette_set_exclusive (EggToolPalette *palette,
                                 GtkWidget      *group,
@@ -1030,10 +1170,18 @@
   gtk_widget_child_notify (group, "exclusive");
 }
 
+/**
+ * egg_tool_palette_set_expand:
+ * @palette: an #EggToolPalette.
+ * @group: an #EggToolItemGroup which is a child of palette.
+ * @expand: whether the group should be given extra space.
+ *
+ * Sets whether the group should be given extra space.
+ */
 void
 egg_tool_palette_set_expand (EggToolPalette *palette,
                              GtkWidget      *group,
-                             gboolean        expand G_GNUC_UNUSED)
+                             gboolean        expand)
 {
   EggToolItemGroupInfo *group_info;
   gint position;
@@ -1054,6 +1202,15 @@
     }
 }
 
+/**
+ * egg_tool_palette_get_group_position:
+ * @palette: an #EggToolPalette.
+ * @group: an #EggToolItemGroup.
+ *
+ * Gets the position of @group in @palette as index. see egg_tool_palette_set_group_position().
+ *
+ * Returns: the index of group or -1 if @group is not a child of @palette.
+ */
 gint
 egg_tool_palette_get_group_position (EggToolPalette *palette,
                                      GtkWidget      *group)
@@ -1070,9 +1227,18 @@
   return -1;
 }
 
+/**
+ * egg_tool_palette_get_exclusive:
+ * @palette: an #EggToolPalette.
+ * @group: an #EggToolItemGroup which is a child of palette.
+ *
+ * Gets whether group is exclusive or not. See egg_tool_palette_set_exclusive().
+ *
+ * Returns: %TRUE if group is exclusive.
+ */
 gboolean
-egg_tool_palette_get_exclusive (EggToolPalette *palette G_GNUC_UNUSED,
-                                GtkWidget      *group G_GNUC_UNUSED)
+egg_tool_palette_get_exclusive (EggToolPalette *palette,
+                                GtkWidget      *group)
 {
   gint position;
 
@@ -1085,6 +1251,15 @@
   return palette->priv->groups[position].exclusive;
 }
 
+/**
+ * egg_tool_palette_get_expand:
+ * @palette: an #EggToolPalette.
+ * @group: an #EggToolItemGroup which is a child of palette.
+ *
+ * Gets whether group should be given extra space. See egg_tool_palette_set_expand().
+ *
+ * Returns: %TRUE if group should be given extra space, %FALSE otherwise.
+ */
 gboolean
 egg_tool_palette_get_expand (EggToolPalette *palette,
                              GtkWidget      *group)
@@ -1100,6 +1275,16 @@
   return palette->priv->groups[position].expand;
 }
 
+/**
+ * egg_tool_palette_get_drop_item:
+ * @palette: an #EggToolPalette.
+ * @x: the x position.
+ * @y: the y position.
+ *
+ * Gets the item at position (x, y). See egg_tool_palette_get_drop_group().
+ *
+ * Returns: the #GtkToolItem at position or %NULL if there is no such item.
+ */
 GtkToolItem*
 egg_tool_palette_get_drop_item (EggToolPalette *palette,
                                 gint            x,
@@ -1115,6 +1300,16 @@
   return NULL;
 }
 
+/**
+ * egg_tool_palette_get_drop_group:
+ * @palette: an #EggToolPalette.
+ * @x: the x position.
+ * @y: the y position.
+ *
+ * Gets the group at position (x, y).
+ *
+ * Returns: the #EggToolItemGroup at position or %NULL if there is no such group.
+ */
 GtkWidget*
 egg_tool_palette_get_drop_group (EggToolPalette *palette,
                                  gint            x,
@@ -1152,6 +1347,16 @@
   return NULL;
 }
 
+/**
+ * egg_tool_palette_get_drag_item:
+ * @palette: an #EggToolPalette.
+ * @selection: a #GtkSelectionData.
+ *
+ * Get the dragged item from the selection. This could be a #GtkToolItem or 
+ * an #EggToolItemGroup.
+ *
+ * Returns: the dragged item in selection.
+ */
 GtkWidget*
 egg_tool_palette_get_drag_item (EggToolPalette         *palette,
                                 const GtkSelectionData *selection)
@@ -1179,17 +1384,30 @@
   return data->item;
 }
 
+/**
+ * egg_tool_palette_set_drag_source:
+ * @palette: an #EggToolPalette.
+ * @targets: the #EggToolPaletteDragTargets which the widget should support.
+ *
+ * Sets the tool palette as a drag source. Enables all groups and items in
+ * the tool palette as drag sources on button 1 and button 3 press with copy
+ * and move actions.
+ *
+ * See gtk_drag_source_set().
+ *
+ */
 void
-egg_tool_palette_set_drag_source (EggToolPalette *palette)
+egg_tool_palette_set_drag_source (EggToolPalette            *palette,
+                                  EggToolPaletteDragTargets  targets)
 {
   guint i;
 
   g_return_if_fail (EGG_IS_TOOL_PALETTE (palette));
 
-  if (palette->priv->drag_source)
+  if ((palette->priv->drag_source & targets) == targets)
     return;
 
-  palette->priv->drag_source = TRUE;
+  palette->priv->drag_source |= targets;
 
   for (i = 0; i < palette->priv->groups_length; ++i)
     {
@@ -1200,6 +1418,23 @@
     }
 }
 
+/**
+ * egg_tool_palette_add_drag_dest:
+ * @palette: an #EggToolPalette.
+ * @widget: a #GtkWidget which should be a drag destination for palette.
+ * @flags: the flags that specify what actions GTK+ should take for drops on that widget.
+ * @targets: the #EggToolPaletteDragTargets which the widget should support.
+ * @actions: the #GdkDragAction<!-- -->s which the widget should suppport.
+ *
+ * Sets the tool palette as drag source (see egg_tool_palette_set_drag_source) and
+ * sets widget as a drag destination for drags from palette. With flags the actions
+ * (like highlighting and target checking) which should be performed by GTK+ for
+ * drops on widget can be specified. With targets the supported drag targets 
+ * (groups and/or items) can be specified. With actions the supported drag actions
+ * (copy and move) can be specified.
+ *
+ * See gtk_drag_dest_set().
+ */
 void
 egg_tool_palette_add_drag_dest (EggToolPalette            *palette,
                                 GtkWidget                 *widget,
@@ -1213,7 +1448,8 @@
   g_return_if_fail (EGG_IS_TOOL_PALETTE (palette));
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  egg_tool_palette_set_drag_source (palette);
+  egg_tool_palette_set_drag_source (palette,
+                                    targets);
 
   if (targets & EGG_TOOL_PALETTE_DRAG_ITEMS)
     entries[n_entries++] = dnd_targets[0];
@@ -1225,27 +1461,41 @@
 
 void
 _egg_tool_palette_get_item_size (EggToolPalette *palette,
-                                 GtkRequisition *item_size)
+                                 GtkRequisition *item_size,
+                                 gboolean        homogeneous_only,
+                                 gint           *requested_rows)
 {
+  GtkRequisition max_requisition;
+  gint max_rows;
+  guint i;
+
   g_return_if_fail (EGG_IS_TOOL_PALETTE (palette));
   g_return_if_fail (NULL != item_size);
 
-  *item_size = palette->priv->item_size;
-}
+  max_requisition.width = 0;
+  max_requisition.height = 0;
+  max_rows = 0;
 
-static GtkWidget*
-egg_tool_palette_find_anchestor (GtkWidget *widget,
-                                 GType      type)
-{
-  while (widget)
+  /* iterate over all groups and calculate the max item_size and max row request */
+  for (i = 0; i < palette->priv->groups_length; ++i)
     {
-      if (G_TYPE_CHECK_INSTANCE_TYPE (widget, type))
-        return widget;
+      GtkRequisition requisition;
+      gint rows;
+      EggToolItemGroupInfo *group = &palette->priv->groups[i];
+
+      if (!group->widget)
+        continue;
+
+      _egg_tool_item_group_item_size_request (group->widget, &requisition, homogeneous_only, &rows);
 
-      widget = gtk_widget_get_parent (widget);
+      max_requisition.width = MAX (max_requisition.width, requisition.width);
+      max_requisition.height = MAX (max_requisition.height, requisition.height);
+      max_rows = MAX (max_rows, rows);
     }
 
-  return NULL;
+  *item_size = max_requisition;
+  if (requested_rows)
+    *requested_rows = max_rows;
 }
 
 static void
@@ -1259,7 +1509,7 @@
   EggToolPaletteDragData drag_data = { EGG_TOOL_PALETTE (data), NULL };
 
   if (selection->target == dnd_target_atom_item)
-    drag_data.item = egg_tool_palette_find_anchestor (widget, GTK_TYPE_TOOL_ITEM);
+    drag_data.item = gtk_widget_get_ancestor (widget, GTK_TYPE_TOOL_ITEM);
 
   if (drag_data.item)
     gtk_selection_data_set (selection, selection->target, 8,
@@ -1277,7 +1527,7 @@
   EggToolPaletteDragData drag_data = { EGG_TOOL_PALETTE (data), NULL };
 
   if (selection->target == dnd_target_atom_group)
-    drag_data.item = egg_tool_palette_find_anchestor (widget, EGG_TYPE_TOOL_ITEM_GROUP);
+    drag_data.item = gtk_widget_get_ancestor (widget, EGG_TYPE_TOOL_ITEM_GROUP);
 
   if (drag_data.item)
     gtk_selection_data_set (selection, selection->target, 8,
@@ -1296,12 +1546,14 @@
   if (!palette->priv->drag_source)
     return;
 
-  if (GTK_IS_TOOL_ITEM (child))
+  if (GTK_IS_TOOL_ITEM (child) &&
+      (palette->priv->drag_source & EGG_TOOL_PALETTE_DRAG_ITEMS))
     {
       /* Connect to child instead of the item itself,
        * to work arround bug 510377.
        */
-      child = gtk_bin_get_child (GTK_BIN (child));
+      if (GTK_IS_TOOL_BUTTON (child))
+        child = gtk_bin_get_child (GTK_BIN (child));
 
       if (!child)
         return;
@@ -1313,7 +1565,8 @@
                         G_CALLBACK (egg_tool_palette_item_drag_data_get),
                         palette);
     }
-  else if (GTK_IS_BUTTON (child))
+  else if (GTK_IS_BUTTON (child) && 
+           (palette->priv->drag_source & EGG_TOOL_PALETTE_DRAG_GROUPS))
     {
       gtk_drag_source_set (child, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
                            &dnd_targets[1], 1, GDK_ACTION_COPY | GDK_ACTION_MOVE);
@@ -1324,12 +1577,26 @@
     }
 }
 
+/**
+ * egg_tool_palette_get_drag_target_item:
+ *
+ * Get the target entry for a dragged #GtkToolItem.
+ *
+ * Returns: the #GtkTargetEntry for a dragged item.
+ */
 G_CONST_RETURN GtkTargetEntry*
 egg_tool_palette_get_drag_target_item (void)
 {
   return &dnd_targets[0];
 }
 
+/**
+ * egg_tool_palette_get_drag_target_group:
+ *
+ * Get the target entry for a dragged #EggToolItemGroup.
+ *
+ * Returns: the #GtkTargetEntry for a dragged group.
+ */
 G_CONST_RETURN GtkTargetEntry*
 egg_tool_palette_get_drag_target_group (void)
 {
@@ -1337,15 +1604,29 @@
 }
 
 void
-_egg_tool_palette_set_expanding_child (EggToolPalette   *palette,
-                                       GtkWidget        *widget)
+_egg_tool_palette_set_expanding_child (EggToolPalette *palette,
+                                       GtkWidget      *widget)
 {
   g_return_if_fail (EGG_IS_TOOL_PALETTE (palette));
-
   palette->priv->expanding_child = widget;
 }
 
+GtkAdjustment*
+egg_tool_palette_get_hadjustment (EggToolPalette *palette)
+{
+  g_return_val_if_fail (EGG_IS_TOOL_PALETTE (palette), NULL);
+  return palette->priv->hadjustment;
+}
+
+GtkAdjustment*
+egg_tool_palette_get_vadjustment (EggToolPalette *palette)
+{
+  g_return_val_if_fail (EGG_IS_TOOL_PALETTE (palette), NULL);
+  return palette->priv->vadjustment;
+}
+
 #ifdef HAVE_EXTENDED_TOOL_SHELL_SUPPORT_BUG_535090
+
 GtkSizeGroup *
 _egg_tool_palette_get_size_group (EggToolPalette *palette)
 {
@@ -1353,4 +1634,5 @@
 
   return palette->priv->text_size_group;
 }
+
 #endif

Modified: trunk/glom/utility_widgets/egg/toolpalette/eggtoolpalette.h
==============================================================================
--- trunk/glom/utility_widgets/egg/toolpalette/eggtoolpalette.h	(original)
+++ trunk/glom/utility_widgets/egg/toolpalette/eggtoolpalette.h	Tue Aug 19 13:49:11 2008
@@ -39,6 +39,13 @@
 typedef struct _EggToolPaletteClass      EggToolPaletteClass;
 typedef struct _EggToolPalettePrivate    EggToolPalettePrivate;
 
+/**
+ * EggToolPaletteDragTargets:
+ * @EGG_TOOL_PALETTE_DRAG_ITEMS: Support drag of items.
+ * @EGG_TOOL_PALETTE_DRAG_GROUPS: Support drag of groups.
+ *
+ * Flags used to specify the supported drag targets. 
+ */
 typedef enum /*< flags >*/
 {
   EGG_TOOL_PALETTE_DRAG_ITEMS = (1 << 0),
@@ -46,6 +53,11 @@
 }
 EggToolPaletteDragTargets;
 
+/**
+ * EggToolPalette:
+ *
+ * This should not be accessed directly. Use the accessor functions below.
+ */
 struct _EggToolPalette
 {
   GtkContainer parent_instance;
@@ -101,13 +113,17 @@
 GtkWidget*                     egg_tool_palette_get_drag_item         (EggToolPalette            *palette,
                                                                        const GtkSelectionData    *selection);
 
-void                           egg_tool_palette_set_drag_source       (EggToolPalette            *palette);
+void                           egg_tool_palette_set_drag_source       (EggToolPalette            *palette,
+                                                                       EggToolPaletteDragTargets  targets);
 void                           egg_tool_palette_add_drag_dest         (EggToolPalette            *palette,
                                                                        GtkWidget                 *widget,
                                                                        GtkDestDefaults            flags,
                                                                        EggToolPaletteDragTargets  targets,
                                                                        GdkDragAction              actions);
 
+GtkAdjustment*                 egg_tool_palette_get_hadjustment       (EggToolPalette            *palette);
+GtkAdjustment*                 egg_tool_palette_get_vadjustment       (EggToolPalette            *palette);
+
 G_CONST_RETURN GtkTargetEntry* egg_tool_palette_get_drag_target_item  (void) G_GNUC_CONST;
 G_CONST_RETURN GtkTargetEntry* egg_tool_palette_get_drag_target_group (void) G_GNUC_CONST;
 

Modified: trunk/glom/utility_widgets/egg/toolpalette/eggtoolpaletteprivate.h
==============================================================================
--- trunk/glom/utility_widgets/egg/toolpalette/eggtoolpaletteprivate.h	(original)
+++ trunk/glom/utility_widgets/egg/toolpalette/eggtoolpaletteprivate.h	Tue Aug 19 13:49:11 2008
@@ -27,7 +27,9 @@
 #include <gtk/gtk.h>
 
 void _egg_tool_palette_get_item_size           (EggToolPalette   *palette,
-                                                GtkRequisition   *item_size);
+                                                GtkRequisition   *item_size,
+                                                gboolean          homogeneous_only,
+                                                gint             *requested_rows);
 void _egg_tool_palette_child_set_drag_source   (GtkWidget        *widget,
                                                 gpointer          data);
 void _egg_tool_palette_set_expanding_child     (EggToolPalette   *palette,
@@ -35,7 +37,9 @@
 
 void _egg_tool_item_group_palette_reconfigured (EggToolItemGroup *group);
 void _egg_tool_item_group_item_size_request    (EggToolItemGroup *group,
-                                                GtkRequisition   *item_size);
+                                                GtkRequisition   *item_size,
+                                                gboolean          homogeneous_only,
+                                                gint             *requested_rows);
 gint _egg_tool_item_group_get_height_for_width (EggToolItemGroup *group,
                                                 gint              width);
 gint _egg_tool_item_group_get_width_for_height (EggToolItemGroup *group,

Modified: trunk/glom/utility_widgets/egg/toolpalette/testtoolpalette.c
==============================================================================
--- trunk/glom/utility_widgets/egg/toolpalette/testtoolpalette.c	(original)
+++ trunk/glom/utility_widgets/egg/toolpalette/testtoolpalette.c	Tue Aug 19 13:49:11 2008
@@ -117,7 +117,7 @@
   if (EGG_TOOL_ITEM_GROUP (drag_group) != drop_group)
     {
       gboolean homogeneous, expand, fill, new_row;
-      
+
       g_object_ref (drag_item);
       gtk_container_child_get (GTK_CONTAINER (drag_group), GTK_WIDGET (drag_item),
                                "homogeneous", &homogeneous,
@@ -433,6 +433,30 @@
 }
 
 static void
+load_toggle_items (EggToolPalette *palette)
+{
+  GSList *toggle_group = NULL;
+  GtkToolItem *item;
+  GtkWidget *group;
+  char *label;
+  int i;
+
+  group = egg_tool_item_group_new (_("Radio Item"));
+  gtk_container_add (GTK_CONTAINER (palette), group);
+
+  for (i = 1; i <= 10; ++i)
+    {
+      label = g_strdup_printf ("#%d", i);
+      item = gtk_radio_tool_button_new (toggle_group);
+      gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), label);
+      g_free (label);
+
+      egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (group), item, -1);
+      toggle_group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (item));
+    }
+}
+
+static void
 load_special_items (EggToolPalette *palette)
 {
   GtkToolItem *item;
@@ -720,6 +744,7 @@
   /* ===== palette ===== */
 
   load_stock_items (EGG_TOOL_PALETTE (palette));
+  load_toggle_items (EGG_TOOL_PALETTE (palette));
   load_special_items (EGG_TOOL_PALETTE (palette));
 
   g_signal_connect (palette, "notify::orientation",

Modified: trunk/glom/utility_widgets/sidebar.cc
==============================================================================
--- trunk/glom/utility_widgets/sidebar.cc	(original)
+++ trunk/glom/utility_widgets/sidebar.cc	Tue Aug 19 13:49:11 2008
@@ -25,48 +25,48 @@
 {
 
 SideBar::SideBar()
+: m_width(0), m_height(0)
 { 
-  set_handle_position (Gtk::POS_TOP);
-  set_snap_edge (Gtk::POS_TOP);
+  set_handle_position(Gtk::POS_TOP);
+  set_snap_edge(Gtk::POS_TOP);
   
-	palette = EGG_TOOL_PALETTE(egg_tool_palette_new ());
-	Gtk::Container* container = Glib::wrap(GTK_CONTAINER(palette));
-	
-	add(*container);
+  palette = EGG_TOOL_PALETTE(egg_tool_palette_new());
+  Gtk::Container* container = Glib::wrap(GTK_CONTAINER(palette));
+  
+  add(*container);
   show_all_children();
 }
 
 SideBar::~SideBar()
 {
-  
 }
 
 void SideBar::add_group(EggToolItemGroup* group)
 {
-	gtk_container_add(GTK_CONTAINER(palette), GTK_WIDGET(group));
+  gtk_container_add(GTK_CONTAINER(palette), GTK_WIDGET(group));
 }
 
 void SideBar::remove_group(EggToolItemGroup* group)
 {
-	gtk_container_remove(GTK_CONTAINER(palette), GTK_WIDGET(group));
+  gtk_container_remove(GTK_CONTAINER(palette), GTK_WIDGET(group));
 }
 
 void SideBar::set_drag_source()
 {
   // It's important to call this AFTER all groups have been added
-  egg_tool_palette_set_drag_source (palette);
+  egg_tool_palette_set_drag_source(palette, EGG_TOOL_PALETTE_DRAG_ITEMS);
 }
 
 void SideBar::on_child_detached(Gtk::Widget* child)
 {
-  get_size_request (m_width, m_height);
-  child->set_size_request (m_width, m_height);
-  set_size_request (0, 0);
+  get_size_request(m_width, m_height);
+  child->set_size_request(m_width, m_height);
+  set_size_request(0, 0);
 }
 
 void SideBar::on_child_attached(Gtk::Widget* child)
 {
-  set_size_request (m_width, m_height);
+  set_size_request(m_width, m_height);
 }
 
 } // namespace Glom

Modified: trunk/glom/utility_widgets/sidebar.h
==============================================================================
--- trunk/glom/utility_widgets/sidebar.h	(original)
+++ trunk/glom/utility_widgets/sidebar.h	Tue Aug 19 13:49:11 2008
@@ -37,8 +37,8 @@
   SideBar();
   ~SideBar();
     
-  void add_group (EggToolItemGroup* group);
-	void remove_group (EggToolItemGroup* group);
+  void add_group(EggToolItemGroup* group);
+  void remove_group(EggToolItemGroup* group);
   
   void set_drag_source();
 



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