libegg r887 - in trunk: . doc libegg/toolpalette



Author: jap
Date: Sat Jun 21 15:54:37 2008
New Revision: 887
URL: http://svn.gnome.org/viewvc/libegg?rev=887&view=rev

Log:
2008-06-21  Jan Arne Petersen  <jpetersen openismus com>

	* doc/Makefile.am:
	* doc/libegg-docs.xml:
	* doc/libegg-sections.txt:
	* doc/libegg.types:
	* libegg/toolpalette/eggtoolitemgroup.[ch]:
	* libegg/toolpalette/eggtoolpalette.[ch]:
	* libegg/toolpalette/eggtoolpalette.h: Add API documentation.

	* libegg/toolpalette/eggtoolpalette.[ch]
	(egg_tool_palette_set_drag_source): Add additional target argument to
	select the drag source as items, groups or both.



Modified:
   trunk/ChangeLog
   trunk/doc/Makefile.am
   trunk/doc/libegg-docs.xml
   trunk/doc/libegg-sections.txt
   trunk/doc/libegg.types
   trunk/libegg/toolpalette/eggtoolitemgroup.c
   trunk/libegg/toolpalette/eggtoolitemgroup.h
   trunk/libegg/toolpalette/eggtoolpalette.c
   trunk/libegg/toolpalette/eggtoolpalette.h
   trunk/libegg/toolpalette/eggtoolpaletteprivate.h

Modified: trunk/doc/Makefile.am
==============================================================================
--- trunk/doc/Makefile.am	(original)
+++ trunk/doc/Makefile.am	Sat Jun 21 15:54:37 2008
@@ -54,6 +54,7 @@
   $(top_builddir)/libegg/druid/libegg-druid.la \
   $(top_builddir)/libegg/iconlist/libeggiconlist.la \
   $(top_builddir)/libegg/sidebar/libegg-sidebar.la \
+  $(top_builddir)/libegg/toolpalette/libeggtoolpalette.la \
   $(top_builddir)/libegg/util/libeggutil.la \
   $(EGG_LIBS) \
   `pkg-config --libs libxml-2.0`
@@ -89,6 +90,8 @@
 SCANOBJ_FILES = 		\
 	$(DOC_MODULE).args 	\
 	$(DOC_MODULE).hierarchy \
+	$(DOC_MODULE).interfaces \
+	$(DOC_MODULE).prerequisites \
 	$(DOC_MODULE).signals
 
 if ENABLE_GTK_DOC

Modified: trunk/doc/libegg-docs.xml
==============================================================================
--- trunk/doc/libegg-docs.xml	(original)
+++ trunk/doc/libegg-docs.xml	Sat Jun 21 15:54:37 2008
@@ -121,4 +121,10 @@
 
     <xi:include href="xml/eggintl.xml"/>
   </part>
+
+  <part id="toolpalette">
+    <title>Toolpalette</title>
+    <xi:include href="xml/EggToolPalette.xml"/>
+    <xi:include href="xml/EggToolItemGroup.xml"/>
+  </part>
 </book>

Modified: trunk/doc/libegg-sections.txt
==============================================================================
--- trunk/doc/libegg-sections.txt	(original)
+++ trunk/doc/libegg-sections.txt	Sat Jun 21 15:54:37 2008
@@ -558,3 +558,69 @@
 <SECTION>
 <FILE>eggmarshalers</FILE>
 </SECTION>
+
+<SECTION>
+<FILE>EggToolPalette</FILE>
+<TITLE>EggToolPalette</TITLE>
+EggToolPalette
+egg_tool_palette_new
+egg_tool_palette_get_exclusive
+egg_tool_palette_set_exclusive
+egg_tool_palette_get_expand
+egg_tool_palette_set_expand
+egg_tool_palette_get_group_position
+egg_tool_palette_set_group_position
+egg_tool_palette_get_icon_size
+egg_tool_palette_set_icon_size
+egg_tool_palette_get_orientation
+egg_tool_palette_set_orientation
+egg_tool_palette_get_style
+egg_tool_palette_set_style
+egg_tool_palette_add_drag_dest
+egg_tool_palette_get_drag_item
+egg_tool_palette_get_drag_target_group
+egg_tool_palette_get_drag_target_item
+egg_tool_palette_get_drop_group
+egg_tool_palette_get_drop_item
+egg_tool_palette_set_drag_source
+<SUBSECTION Standard>
+EggToolPaletteClass
+EGG_TOOL_PALETTE
+EGG_IS_TOOL_PALETTE
+EGG_TYPE_TOOL_PALETTE
+EGG_TOOL_PALETTE_CLASS
+EGG_IS_TOOL_PALETTE_CLASS
+EGG_TOOL_PALETTE_GET_CLASS
+<SUBSECTION Private>
+egg_tool_palette_get_type
+EggToolPalettePrivate
+</SECTION>
+
+<SECTION>
+<FILE>EggToolItemGroup</FILE>
+<TITLE>EggToolItemGroup</TITLE>
+EggToolItemGroup
+egg_tool_item_group_get_collapsed
+egg_tool_item_group_get_drop_item
+egg_tool_item_group_get_ellipsize
+egg_tool_item_group_get_item_position
+egg_tool_item_group_get_n_items
+egg_tool_item_group_get_name
+egg_tool_item_group_get_nth_item
+egg_tool_item_group_insert
+egg_tool_item_group_new
+egg_tool_item_group_set_collapsed
+egg_tool_item_group_set_ellipsize
+egg_tool_item_group_set_item_position
+egg_tool_item_group_set_name
+<SUBSECTION Standard>
+EggToolItemGroupClass
+EGG_TOOL_ITEM_GROUP
+EGG_IS_TOOL_ITEM_GROUP
+EGG_TYPE_TOOL_ITEM_GROUP
+EGG_TOOL_ITEM_GROUP_CLASS
+EGG_IS_TOOL_ITEM_GROUP_CLASS
+EGG_TOOL_ITEM_GROUP_GET_CLASS
+<SUBSECTION Private>
+egg_tool_item_group_get_type
+</SECTION>

Modified: trunk/doc/libegg.types
==============================================================================
--- trunk/doc/libegg.types	(original)
+++ trunk/doc/libegg.types	Sat Jun 21 15:54:37 2008
@@ -18,6 +18,9 @@
 #include <libegg/sidebar/eggsidebar.h>
 #include <libegg/sidebar/eggsidebarbutton.h>
 
+#include <libegg/toolpalette/eggtoolpalette.h>
+#include <libegg/toolpalette/eggtoolitemgroup.h>
+
 egg_cell_renderer_keys_get_type
 egg_cell_renderer_popup_get_type
 egg_cell_renderer_text_get_type
@@ -31,3 +34,5 @@
 egg_icon_list_get_type
 egg_sidebar_get_type
 egg_sidebar_button_get_type
+egg_tool_palette_get_type
+egg_tool_item_group_get_type

Modified: trunk/libegg/toolpalette/eggtoolitemgroup.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolitemgroup.c	(original)
+++ trunk/libegg/toolpalette/eggtoolitemgroup.c	Sat Jun 21 15:54:37 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,
@@ -438,7 +447,7 @@
 egg_tool_item_group_get_item_size (EggToolItemGroup *group,
                                    GtkRequisition   *item_size,
                                    gboolean          homogeneous_only,
-                                   guint            *requested_rows)
+                                   gint             *requested_rows)
 {
   GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (group));
 
@@ -456,7 +465,7 @@
   EggToolItemGroup *group = EGG_TOOL_ITEM_GROUP (widget);
   GtkOrientation orientation;
   GtkRequisition item_size;
-  guint requested_rows;
+  gint requested_rows;
 
   if (group->priv->children && egg_tool_item_group_get_name (group))
     {
@@ -519,7 +528,7 @@
   GtkOrientation orientation;
   GtkToolbarStyle style;
 
-  guint min_rows;
+  gint min_rows;
 
   orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group));
   style = gtk_tool_shell_get_style (GTK_TOOL_SHELL (group));
@@ -538,7 +547,8 @@
   /* 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, n_rows;
+      guint n_columns;
+      gint n_rows;
       GList *it;
 
       if (GTK_ORIENTATION_VERTICAL == orientation)
@@ -576,7 +586,7 @@
                 }
               else
                 {
-                  GtkRequisition req = {0};
+                  GtkRequisition req = {0, 0};
                   guint width;
 
                   gtk_widget_size_request (GTK_WIDGET (child->item), &req);
@@ -598,7 +608,7 @@
           gint row = -1;
           gboolean new_row = TRUE;
           guint col = 0, min_col, max_col = 0, all_items = 0;
-          guint i;
+          gint i;
 
           item_area.height = allocation->height - 2 * border_width;
           n_rows = MAX (item_area.height / item_size.height, min_rows);
@@ -631,7 +641,7 @@
                 }
               else
                 {
-                  GtkRequisition req = {0};
+                  GtkRequisition req = {0, 0};
                   guint width;
 
                   gtk_widget_size_request (GTK_WIDGET (child->item), &req);
@@ -653,7 +663,7 @@
               min_col = MAX (min_col, row_min_width[i]);
             }
 
-          /* simple linear search for minimal required columns if maximal row count is n_rows */
+          /* 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;
@@ -684,7 +694,7 @@
                     }
                   else
                     {
-                      GtkRequisition req = {0};
+                      GtkRequisition req = {0, 0};
                       guint width;
 
                       gtk_widget_size_request (GTK_WIDGET (child->item), &req);
@@ -746,7 +756,8 @@
 
   GList *it;
 
-  guint n_columns, n_rows = 1, min_rows;
+  gint n_columns, n_rows = 1;
+  gint min_rows;
 
   GtkTextDirection direction = gtk_widget_get_direction (widget);
 
@@ -824,7 +835,7 @@
   /* 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)
         {
@@ -856,13 +867,13 @@
           /* 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;
               else
-                col_width = (guint) ceil (1.0 * child_requisition.width / item_size.width);
+                col_width = (gint) ceil (1.0 * child_requisition.width / item_size.width);
 
               width = col_width * item_size.width;
 
@@ -1373,12 +1384,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)
@@ -1482,6 +1509,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)
@@ -1515,6 +1549,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)
@@ -1532,6 +1573,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)
 {
@@ -1543,6 +1592,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)
 {
@@ -1550,6 +1607,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)
 {
@@ -1557,6 +1622,14 @@
   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,
@@ -1586,6 +1659,14 @@
   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,
@@ -1615,6 +1696,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)
@@ -1630,6 +1720,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)
 {
@@ -1638,6 +1736,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)
@@ -1651,6 +1758,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,
@@ -1694,11 +1811,11 @@
 _egg_tool_item_group_item_size_request (EggToolItemGroup *group,
                                         GtkRequisition   *item_size,
                                         gboolean          homogeneous_only,
-                                        guint            *requested_rows)
+                                        gint             *requested_rows)
 {
   GtkRequisition child_requisition;
   GList *it;
-  guint rows = 0;
+  gint rows = 0;
   gboolean new_row = TRUE;
   GtkOrientation orientation;
   GtkToolbarStyle style;

Modified: trunk/libegg/toolpalette/eggtoolitemgroup.h
==============================================================================
--- trunk/libegg/toolpalette/eggtoolitemgroup.h	(original)
+++ trunk/libegg/toolpalette/eggtoolitemgroup.h	Sat Jun 21 15:54:37 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/libegg/toolpalette/eggtoolpalette.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolpalette.c	(original)
+++ trunk/libegg/toolpalette/eggtoolpalette.c	Sat Jun 21 15:54:37 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;
 
@@ -83,7 +149,7 @@
 #endif
 
   guint                 sparse_groups : 1;
-  guint                 drag_source : 1;
+  guint                 drag_source : 2;
 };
 
 struct _EggToolPaletteDragData
@@ -353,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];
@@ -379,9 +447,12 @@
       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;
+          guint j;
+          gint real_size;
           gint limit = GTK_ORIENTATION_VERTICAL == palette->priv->orientation ? child_allocation.width : child_allocation.height;
 
           min_offset = 0;
@@ -424,6 +495,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];
@@ -482,6 +554,7 @@
       page_start = x;
     }
 
+  /* update the scrollbar to match the displayed adjustment */
   if (adjustment)
     {
       gdouble value;
@@ -852,12 +925,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)
@@ -868,6 +955,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)
@@ -878,6 +972,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)
@@ -888,6 +989,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)
 {
@@ -895,6 +1004,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)
 {
@@ -902,6 +1019,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)
 {
@@ -909,6 +1034,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,
@@ -978,6 +1113,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,
@@ -1019,10 +1163,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;
@@ -1043,6 +1195,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)
@@ -1059,9 +1220,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;
 
@@ -1074,6 +1244,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)
@@ -1089,6 +1268,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,
@@ -1104,6 +1293,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,
@@ -1141,6 +1340,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)
@@ -1168,17 +1377,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)
     {
@@ -1189,6 +1411,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,
@@ -1202,7 +1441,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];
@@ -1216,10 +1456,11 @@
 _egg_tool_palette_get_item_size (EggToolPalette *palette,
                                  GtkRequisition *item_size,
                                  gboolean        homogeneous_only,
-                                 guint          *requested_rows)
+                                 gint           *requested_rows)
 {
   GtkRequisition max_requisition;
-  guint max_rows, i;
+  gint max_rows;
+  guint i;
 
   g_return_if_fail (EGG_IS_TOOL_PALETTE (palette));
   g_return_if_fail (NULL != item_size);
@@ -1232,7 +1473,7 @@
   for (i = 0; i < palette->priv->groups_length; ++i)
     {
       GtkRequisition requisition;
-      guint rows;
+      gint rows;
       EggToolItemGroupInfo *group = &palette->priv->groups[i];
 
       if (!group->widget)
@@ -1298,12 +1539,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;
@@ -1315,7 +1558,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);
@@ -1326,12 +1570,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)
 {

Modified: trunk/libegg/toolpalette/eggtoolpalette.h
==============================================================================
--- trunk/libegg/toolpalette/eggtoolpalette.h	(original)
+++ trunk/libegg/toolpalette/eggtoolpalette.h	Sat Jun 21 15:54:37 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,7 +113,8 @@
 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,

Modified: trunk/libegg/toolpalette/eggtoolpaletteprivate.h
==============================================================================
--- trunk/libegg/toolpalette/eggtoolpaletteprivate.h	(original)
+++ trunk/libegg/toolpalette/eggtoolpaletteprivate.h	Sat Jun 21 15:54:37 2008
@@ -29,7 +29,7 @@
 void _egg_tool_palette_get_item_size           (EggToolPalette   *palette,
                                                 GtkRequisition   *item_size,
                                                 gboolean          homogeneous_only,
-                                                guint            *requested_rows);
+                                                gint             *requested_rows);
 void _egg_tool_palette_child_set_drag_source   (GtkWidget        *widget,
                                                 gpointer          data);
 void _egg_tool_palette_set_expanding_child     (EggToolPalette   *palette,
@@ -39,7 +39,7 @@
 void _egg_tool_item_group_item_size_request    (EggToolItemGroup *group,
                                                 GtkRequisition   *item_size,
                                                 gboolean          homogeneous_only,
-                                                guint            *requested_rows);
+                                                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,



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