Author: nick
Date: 2007-10-20 10:32:12 +0000 (Sat, 20 Oct 2007)
New Revision: 26150

Modified:
   xfce4-panel/trunk/libxfce4panel/xfce-itembar.c
   xfce4-panel/trunk/libxfce4panel/xfce-itembar.h
   xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.c
   xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.h
   xfce4-panel/trunk/libxfce4panel/xfce-panel-window.c
   xfce4-panel/trunk/panel/panel-app.c
   xfce4-panel/trunk/panel/panel-dialogs.c
   xfce4-panel/trunk/panel/panel-properties.c
   xfce4-panel/trunk/panel/panel.c
Log:
* Some fixes of the wnck patch (which will be committed after this one).
* Rewrite itembar code so it can handle larger size requests then the
  screen size. This version is also a bit faster I think (less loops,
  less memory allocation).
* Use the new maximum itembar width in the panel code.


Modified: xfce4-panel/trunk/libxfce4panel/xfce-itembar.c
===================================================================
--- xfce4-panel/trunk/libxfce4panel/xfce-itembar.c      2007-10-20 09:22:49 UTC 
(rev 26149)
+++ xfce4-panel/trunk/libxfce4panel/xfce-itembar.c      2007-10-20 10:32:12 UTC 
(rev 26150)
@@ -63,7 +63,6 @@
 
 
 typedef struct _XfceItembarChild   XfceItembarChild;
-typedef struct _XfceItembarPrivate XfceItembarPrivate;
 
 struct _XfceItembarPrivate
 {
@@ -76,12 +75,14 @@
     gint            drop_index;
     guint           raised : 1;
     guint           expand_allowed : 1;
+    gint            maximum_size;
 };
 
 struct _XfceItembarChild
 {
-    GtkWidget *widget;
-    guint      expand : 1;
+    GtkWidget     *widget;
+    guint          expand : 1;
+    GtkAllocation  allocation;
 };
 
 
@@ -183,15 +184,15 @@
     gobject_class->set_property = xfce_itembar_set_property;
 
     widget_class = GTK_WIDGET_CLASS (klass);
-    widget_class->expose_event  = xfce_itembar_expose;
-    widget_class->size_request  = xfce_itembar_size_request;
-    widget_class->size_allocate = xfce_itembar_size_allocate;
-    widget_class->realize       = xfce_itembar_realize;
-    widget_class->unrealize     = xfce_itembar_unrealize;
-    widget_class->map           = xfce_itembar_map;
-    widget_class->unmap         = xfce_itembar_unmap;
-    widget_class->drag_leave    = xfce_itembar_drag_leave;
-    widget_class->drag_motion   = xfce_itembar_drag_motion;
+    widget_class->expose_event   = xfce_itembar_expose;
+    widget_class->size_request   = xfce_itembar_size_request;
+    widget_class->size_allocate  = xfce_itembar_size_allocate;
+    widget_class->realize        = xfce_itembar_realize;
+    widget_class->unrealize      = xfce_itembar_unrealize;
+    widget_class->map            = xfce_itembar_map;
+    widget_class->unmap          = xfce_itembar_unmap;
+    widget_class->drag_leave     = xfce_itembar_drag_leave;
+    widget_class->drag_motion    = xfce_itembar_drag_motion;
 
     container_class = GTK_CONTAINER_CLASS (klass);
     container_class->forall             = xfce_itembar_forall;
@@ -272,8 +273,12 @@
 static void
 xfce_itembar_init (XfceItembar *itembar)
 {
-    XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
+    XfceItembarPrivate *priv;
 
+    /* set the private pointer */
+    itembar->priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
+    priv = itembar->priv;
+
     GTK_WIDGET_SET_FLAGS (GTK_WIDGET (itembar), GTK_NO_WINDOW);
     gtk_widget_set_redraw_on_allocate (GTK_WIDGET (itembar), FALSE);
 
@@ -284,6 +289,7 @@
     priv->drop_index     = -1;
     priv->raised         = FALSE;
     priv->expand_allowed = FALSE;
+    priv->maximum_size   = -1;
 }
 
 
@@ -344,12 +350,12 @@
 xfce_itembar_expose (GtkWidget      *widget,
                      GdkEventExpose *event)
 {
-    XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR 
(widget));
+    XfceItembar *itembar = XFCE_ITEMBAR (widget);
 
     GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
 
-    if (priv->raised)
-        gdk_window_raise (priv->event_window);
+    if (itembar->priv->raised)
+        gdk_window_raise (itembar->priv->event_window);
 
     return TRUE;
 }
@@ -360,50 +366,41 @@
 xfce_itembar_size_request (GtkWidget      *widget,
                            GtkRequisition *requisition)
 {
-    XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR 
(widget));
+    XfceItembarPrivate *priv = XFCE_ITEMBAR (widget)->priv;
     XfceItembarChild   *child;
     GSList             *l;
     GtkRequisition      req;
-    gint                max, other_size;
 
+    /* start with the border width */
     requisition->width = requisition->height =
         2 * GTK_CONTAINER (widget)->border_width;
 
-    max = other_size = 0;
-
     for (l = priv->children; l != NULL; l = l->next)
     {
         child = l->data;
 
-        if (!GTK_WIDGET_VISIBLE (child->widget))
-            continue;
-
-        gtk_widget_size_request (child->widget, &req);
-
-        if (GTK_ORIENTATION_HORIZONTAL == priv->orientation)
+        /* skip invisible plugins */
+        if (GTK_WIDGET_VISIBLE (child->widget))
         {
-            max = MAX (max, req.height);
+            /* get the child size request */
+            gtk_widget_size_request (child->widget, &req);
 
-            other_size += req.width;
+            /* append the widget size request */
+            if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+                requisition->width += req.width;
+            else
+                requisition->height += req.height;
         }
-        else
-        {
-            max = MAX (max, req.width);
-
-            other_size += req.height;
-        }
     }
 
-    if (GTK_ORIENTATION_HORIZONTAL == priv->orientation)
+    if (G_LIKELY (priv->maximum_size != -1))
     {
-        requisition->height += max;
-        requisition->width  += other_size;
+        /* limit the maximum size */
+        if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+            requisition->width = MIN (requisition->width, priv->maximum_size);
+        else
+            requisition->height = MIN (requisition->height, 
priv->maximum_size);
     }
-    else
-    {
-        requisition->width  += max;
-        requisition->height += other_size;
-    }
 }
 
 
@@ -412,207 +409,170 @@
 xfce_itembar_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = XFCE_ITEMBAR (widget)->priv;
     XfceItembarChild   *child;
     GtkRequisition      req;
-    GtkTextDirection    direction;
-    GSList             *l;
-    gint                n_total, i;
-    gint                x, y, width, height, size;
-    gint                border_width, bar_height, total_size;
-    gint                n_expand, expand_width, max_expand, total_expand;
-    gboolean            horizontal;
-    struct ItemProps
-    {
-        GtkAllocation       allocation;
-        gboolean            expand;
-    }                  *props;
+    GSList             *li;
+    gint                x, y, width, height, border_width;
+    gint                itembar_length, itembar_size, itembar_expandable;
+    gint                itembar_expandreq, n_expand, size, expand_size;
+    gboolean            horizontal, rtl;
 
     /* itembar allocation */
     widget->allocation = *allocation;
 
-    priv         = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (widget));
-    horizontal   = (GTK_ORIENTATION_HORIZONTAL == priv->orientation);
+    /* wether the orientation is horizontal */
+    horizontal = (priv->orientation == GTK_ORIENTATION_HORIZONTAL);
 
+    /* get the border width */
     border_width = GTK_CONTAINER (widget)->border_width;
-    x            = allocation->x + border_width;
-    y            = allocation->y + border_width;
 
+    /* event window allocation */
+    x      = allocation->x + border_width;
+    y      = allocation->y + border_width;
+    width  = allocation->width - 2 * border_width;
+    height = allocation->height - 2 * border_width;
+
+    /* mova and resize the event window */
+    if (G_LIKELY (priv->event_window != NULL))
+        gdk_window_move_resize (priv->event_window, x, y, width, height);
+
+    /* get the length and fixed size of the itembar */
     if (horizontal)
     {
-        total_size = allocation->width - 2 * border_width;
-        bar_height = allocation->height - 2 * border_width;
-
-        if (priv->event_window != NULL)
-        {
-            gdk_window_move_resize (priv->event_window,
-                                    x, y, total_size, bar_height);
-        }
+        itembar_length = width;
+        itembar_size = height;
     }
     else
     {
-        total_size = allocation->height - 2 * border_width;
-        bar_height = allocation->width - 2 * border_width;
 
-        if (priv->event_window != NULL)
-        {
-            gdk_window_move_resize (priv->event_window,
-                                    x, y, bar_height, total_size);
-        }
+        itembar_length = height;
+        itembar_size = width;
     }
 
-    total_expand = total_size;
-    direction    = gtk_widget_get_direction (widget);
-    n_total      = g_slist_length (priv->children);
-    props        = g_new (struct ItemProps, n_total);
+    /* set expandable width equal to the length of the bar */
+    itembar_expandable = itembar_length;
+    itembar_expandreq = 0;
 
-    n_expand = expand_width = max_expand = 0;
-
-    /* - get size request for all items
-     * - get number of expanding items
-     * - determine space available for expanding items
-     * - determine largest width of expanding items
-     */
-    for (l = priv->children, i = 0; l != NULL; l = l->next, i++)
+    /* walk the childeren to get the requested width, the size we share between
+     * the expandable items and the number of expand items */
+    for (li = priv->children, n_expand = 0; li != NULL; li = li->next)
     {
-        child = l->data;
+        child = li->data;
 
         if (!GTK_WIDGET_VISIBLE (child->widget))
         {
-            props[i].allocation.width = 0;
+            child->allocation.width = 0;
+            child->allocation.height = 0;
+
             continue;
         }
 
+        /* get child size request */
         gtk_widget_size_request (child->widget, &req);
 
         if (horizontal)
         {
             width  = req.width;
-            height = bar_height;
+            height = itembar_size;
 
-            if (child->expand && priv->expand_allowed)
-            {
-                n_expand++;
-                max_expand = MAX (max_expand, width);
-            }
+            if (child->expand)
+                itembar_expandreq += width;
             else
-            {
-                total_expand -= width;
-            }
+                itembar_expandable -= width;
         }
         else
         {
             height = req.height;
-            width  = bar_height;
+            width  = itembar_size;
 
-            if (child->expand && priv->expand_allowed)
-            {
-                n_expand++;
-                max_expand = MAX (max_expand, height);
-            }
+            if (child->expand)
+                itembar_expandreq += height;
             else
-            {
-                total_expand -= height;
-            }
+                itembar_expandable -= height;
         }
 
-        props[i].allocation.width  = width;
-        props[i].allocation.height = height;
-        props[i].expand = (child->expand && priv->expand_allowed);
+        /* increase counter if child can expand */
+        if (child->expand)
+            n_expand++;
+
+        /* set the allocation sizes */
+        child->allocation.width  = width;
+        child->allocation.height = height;
     }
 
-    /* check if expanding items fit */
-    while (n_expand > 0)
+    /* resize the expanding items if the request and available space don't 
match */
+    if (n_expand > 0 && itembar_expandreq != itembar_expandable)
     {
-        /* space available for 1 expanding item */
-        expand_width = MAX (total_expand / n_expand, 0);
-
-        /* if it fits, we're done */
-        if (expand_width >= max_expand)
+        for (li = priv->children; li != NULL && n_expand > 0; li = li->next)
         {
-            break;
-        }
+            child = li->data;
 
-        max_expand = 0;
-
-        /* - remove bigger items from expand list
-         * - recalculate n_expand, total_expand and max_expand
-         */
-        for (i = 0; i < n_total; ++i)
-        {
-            if (!props[i].expand)
+            /* skip non expand items */
+            if (!child->expand)
                 continue;
 
+            /* get the size that matters */
+            size = horizontal ? child->allocation.width : 
child->allocation.height;
+
+            /* calculate the relative expanding size */
+            expand_size = MAX (itembar_expandable * size / itembar_expandreq, 
0);
+
+            /* limit to the expandable size */
             if (horizontal)
-                size = props[i].allocation.width;
+                child->allocation.width = expand_size;
             else
-                size = props[i].allocation.height;
+                child->allocation.height = expand_size;
 
-            if (size > expand_width)
-            {
-                props[i].expand = FALSE;
-                total_expand -= size;
-                n_expand--;
-            }
-            else
-            {
-                max_expand = MAX (size, max_expand);
-            }
+            /* remove the allocated size from the available size */
+            itembar_expandable -= expand_size;
+
+            /* remove the origionally requested size from the total expand 
request */
+            itembar_expandreq -= size;
+
+            /* decrease counter */
+            n_expand--;
         }
     }
 
+    /* init coordinates and the widgets direction */
     x = y = border_width;
+    rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
 
-    /* allocate items */
-    for (l = priv->children, i = 0; l != NULL; l = l->next, i++)
+    /* allocate the childeren */
+    for (li = priv->children; li != NULL; li = li->next)
     {
-        child = l->data;
+        child = li->data;
 
-        if (props[i].allocation.width == 0)
+        /* skip invisible plugins */
+        if (G_UNLIKELY (child->allocation.width == 0))
             continue;
 
-        props[i].allocation.x = x + allocation->x;
-        props[i].allocation.y = y + allocation->y;
+        child->allocation.x = x + allocation->x;
+        child->allocation.y = y + allocation->y;
 
         if (horizontal)
         {
-            /* to cope with rounding errors, the last expanded child
-             * gets all of the remaining expanded space */
-            if (props[i].expand)
+            if (rtl)
             {
-                if (n_expand == 1)
-                    expand_width = total_expand;
-
-                props[i].allocation.width = expand_width;
-                n_expand--;
-                total_expand -= expand_width;
+                /* invert the direction of the packed widgets */
+                child->allocation.x = allocation->x + itembar_length
+                                      - x - child->allocation.width;
             }
 
-            if (direction == GTK_TEXT_DIR_RTL)
-            {
-                props[i].allocation.x = allocation->x + total_size - x
-                                        - props[i].allocation.width;
-            }
-
-            x += props[i].allocation.width;
+            x += child->allocation.width;
         }
         else
         {
-            if (props[i].expand)
-                props[i].allocation.height = expand_width;
-
-            y += props[i].allocation.height;
+            y += child->allocation.height;
         }
 
-      gtk_widget_size_allocate (child->widget, &(props[i].allocation));
+        /* send the allocation */
+        gtk_widget_size_allocate (child->widget, &child->allocation);
     }
 
-    g_free (props);
-
     if (priv->raised && priv->event_window != NULL)
-    {
         gdk_window_raise (priv->event_window);
-    }
 }
 
 
@@ -623,7 +583,7 @@
     GdkWindowAttr       attributes;
     gint                attributes_mask;
     gint                border_width;
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = XFCE_ITEMBAR (widget)->priv;
 
     GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
 
@@ -635,16 +595,16 @@
     attributes.height = widget->allocation.height - 2 * border_width;
     attributes.window_type = GDK_WINDOW_CHILD;
     attributes.event_mask = gtk_widget_get_events (widget)
-        | GDK_POINTER_MOTION_MASK
-        | GDK_BUTTON_MOTION_MASK
-        | GDK_BUTTON_PRESS_MASK
-        | GDK_BUTTON_RELEASE_MASK
-    | GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK;
+                            | GDK_POINTER_MOTION_MASK
+                            | GDK_BUTTON_MOTION_MASK
+                            | GDK_BUTTON_PRESS_MASK
+                            | GDK_BUTTON_RELEASE_MASK
+                            | GDK_EXPOSURE_MASK
+                            | GDK_ENTER_NOTIFY_MASK
+                            | GDK_LEAVE_NOTIFY_MASK;
     attributes.wclass = GDK_INPUT_ONLY;
     attributes_mask = GDK_WA_X | GDK_WA_Y;
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (widget);
-
     widget->window = gtk_widget_get_parent_window (widget);
     g_object_ref (G_OBJECT (widget->window));
 
@@ -661,10 +621,8 @@
 static void
 xfce_itembar_unrealize (GtkWidget *widget)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = XFCE_ITEMBAR (widget)->priv;
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (widget);
-
     if (priv->event_window != NULL)
     {
         gdk_window_set_user_data (priv->event_window, NULL);
@@ -681,10 +639,8 @@
 static void
 xfce_itembar_map (GtkWidget *widget)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = XFCE_ITEMBAR (widget)->priv;
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (widget);
-
     gdk_window_show (priv->event_window);
 
     (*GTK_WIDGET_CLASS (parent_class)->map) (widget);
@@ -698,10 +654,8 @@
 static void
 xfce_itembar_unmap (GtkWidget *widget)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = XFCE_ITEMBAR (widget)->priv;
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (widget);
-
     if (priv->event_window != NULL)
         gdk_window_hide (priv->event_window);
 
@@ -715,8 +669,7 @@
                          GdkDragContext *context,
                          guint           time_)
 {
-    XfceItembar        *toolbar = XFCE_ITEMBAR (widget);
-    XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (toolbar);
+    XfceItembarPrivate *priv = XFCE_ITEMBAR (widget)->priv;
 
     if (priv->drag_highlight)
     {
@@ -738,7 +691,7 @@
                           guint           time_)
 {
     XfceItembar        *itembar = XFCE_ITEMBAR (widget);
-    XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
+    XfceItembarPrivate *priv = itembar->priv;
     XfceItembarChild   *child;
     gint                new_index, new_pos, border_width;
     GdkWindowAttr       attributes;
@@ -767,7 +720,7 @@
 
     if (priv->drop_index < 0 || priv->drop_index != new_index)
     {
-        border_width = GTK_CONTAINER (itembar)->border_width;
+        border_width = GTK_CONTAINER (widget)->border_width;
 
         child = g_slist_nth_data (priv->children, new_index);
 
@@ -815,10 +768,8 @@
 {
     GSList             *l;
     XfceItembarChild   *child;
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = XFCE_ITEMBAR (container)->priv;
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (container));
-
     for (l = priv->children; l != NULL; l = l->next)
     {
         child = l->data;
@@ -851,16 +802,13 @@
 xfce_itembar_remove (GtkContainer *container,
                      GtkWidget    *child)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = XFCE_ITEMBAR (container)->priv;
     XfceItembarChild   *ic;
     gboolean            was_visible;
     GSList             *l;
 
-    _panel_return_if_fail (XFCE_IS_ITEMBAR (container));
     _panel_return_if_fail (child != NULL && child->parent == GTK_WIDGET 
(container));
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (container));
-
     for (l = priv->children; l != NULL; l = l->next)
     {
         ic = l->data;
@@ -947,7 +895,7 @@
     GtkTextDirection    direction;
     gint                distance, cursor, pos, i, index;
     XfceItembarChild   *child;
-    XfceItembarPrivate *priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
+    XfceItembarPrivate *priv = itembar->priv;
     gint                best_distance = G_MAXINT;
 
     if (!priv->children)
@@ -1037,6 +985,27 @@
 
 
 /**
+ * xfce_itembar_set_maximum_size:
+ * @size: maximum size request
+ *
+ * Control the maximum allocatable size of the itembar. This
+ * function was introduced to handle larger request then the screen
+ * on floating/normal width panels.
+ **/
+void
+xfce_itembar_set_maximum_size (XfceItembar *itembar,
+                               gint         size)
+{
+    XfceItembarPrivate *priv = itembar->priv;
+
+    _panel_return_if_fail (XFCE_IS_ITEMBAR (itembar));
+
+    priv->maximum_size = size;
+}
+
+
+
+/**
  * xfce_itembar_set_allow_expand:
  * @itembar: a #XfceItembar
  * @allow   : %TRUE when the expansion is allowed.
@@ -1049,12 +1018,10 @@
 xfce_itembar_set_allow_expand (XfceItembar *itembar,
                                gboolean     allow)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
 
     _panel_return_if_fail (XFCE_IS_ITEMBAR (itembar));
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
-
     priv->expand_allowed = allow;
     gtk_widget_queue_resize (GTK_WIDGET(itembar));
 }
@@ -1072,12 +1039,10 @@
 GtkOrientation
 xfce_itembar_get_orientation (XfceItembar *itembar)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
 
     _panel_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), DEFAULT_ORIENTATION);
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
-
     return priv->orientation;
 }
 
@@ -1094,12 +1059,10 @@
 xfce_itembar_set_orientation (XfceItembar    *itembar,
                               GtkOrientation  orientation)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
 
     _panel_return_if_fail (XFCE_IS_ITEMBAR (itembar));
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
-
     if (orientation == priv->orientation)
         return;
 
@@ -1128,14 +1091,12 @@
                      GtkWidget   *item,
                      gint         position)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
     XfceItembarChild   *child;
 
     _panel_return_if_fail (XFCE_IS_ITEMBAR (itembar));
     _panel_return_if_fail (item != NULL && GTK_WIDGET (item)->parent == NULL);
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
-
     child = panel_slice_new0 (XfceItembarChild);
 
     child->widget = item;
@@ -1196,7 +1157,7 @@
                             GtkWidget   *item,
                             gint         position)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
     XfceItembarChild   *child;
     GSList             *l;
 
@@ -1204,8 +1165,6 @@
     _panel_return_if_fail (item != NULL
                       && GTK_WIDGET (item)->parent == GTK_WIDGET (itembar));
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (itembar));
-
     for (l = priv->children; l != NULL; l = l->next)
     {
         child = l->data;
@@ -1243,7 +1202,7 @@
 xfce_itembar_get_child_expand (XfceItembar *itembar,
                                GtkWidget   *item)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
     XfceItembarChild   *child;
     GSList             *l;
 
@@ -1251,8 +1210,6 @@
     _panel_return_val_if_fail (item != NULL && GTK_WIDGET (item)->parent == 
GTK_WIDGET (itembar),
                                FALSE);
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (itembar));
-
     for (l = priv->children; l != NULL; l = l->next)
     {
         child = l->data;
@@ -1279,15 +1236,13 @@
                                GtkWidget   *item,
                                gboolean     expand)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
     XfceItembarChild   *child;
     GSList             *l;
 
     _panel_return_if_fail (XFCE_IS_ITEMBAR (itembar));
     _panel_return_if_fail (item != NULL && GTK_WIDGET (item)->parent == 
GTK_WIDGET (itembar));
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (itembar));
-
     for (l = priv->children; l != NULL; l = l->next)
     {
         child = l->data;
@@ -1315,12 +1270,10 @@
 gint
 xfce_itembar_get_n_items (XfceItembar *itembar)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
 
     _panel_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), 0);
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (itembar));
-
     return g_slist_length (priv->children);
 }
 
@@ -1339,7 +1292,7 @@
 xfce_itembar_get_item_index (XfceItembar *itembar,
                              GtkWidget   *item)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
     XfceItembarChild   *child;
     GSList             *l;
     gint                n;
@@ -1347,8 +1300,6 @@
     _panel_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), -1);
     _panel_return_val_if_fail (item != NULL && GTK_WIDGET (item)->parent == 
GTK_WIDGET (itembar), -1);
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (itembar));
-
     for (n = 0, l = priv->children; l != NULL; l = l->next, ++n)
     {
         child = l->data;
@@ -1379,14 +1330,12 @@
 xfce_itembar_get_nth_item (XfceItembar *itembar,
                            gint         n)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
     XfceItembarChild   *child;
     gint                n_items;
 
     _panel_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), NULL);
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
-
     n_items = g_slist_length (priv->children);
 
     if (n < 0 || n >= n_items)
@@ -1412,12 +1361,10 @@
 void
 xfce_itembar_raise_event_window (XfceItembar *itembar)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
 
     _panel_return_if_fail (XFCE_IS_ITEMBAR (itembar));
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
-
     priv->raised = TRUE;
 
     if (priv->event_window)
@@ -1439,12 +1386,10 @@
 void
 xfce_itembar_lower_event_window (XfceItembar *itembar)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
 
     _panel_return_if_fail (XFCE_IS_ITEMBAR (itembar));
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
-
     priv->raised = FALSE;
 
     if (priv->event_window)
@@ -1464,12 +1409,10 @@
 gboolean
 xfce_itembar_event_window_is_raised (XfceItembar *itembar)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
 
     _panel_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), FALSE);
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
-
     return priv->raised;
 }
 
@@ -1491,7 +1434,7 @@
                                 gint         x,
                                 gint         y)
 {
-    XfceItembarPrivate *priv;
+    XfceItembarPrivate *priv = itembar->priv;
     XfceItembarChild   *child;
     GSList             *l;
     GtkWidget          *w;
@@ -1499,8 +1442,6 @@
 
     _panel_return_val_if_fail (XFCE_IS_ITEMBAR (itembar), NULL);
 
-    priv = XFCE_ITEMBAR_GET_PRIVATE (itembar);
-
     x += GTK_WIDGET (itembar)->allocation.x;
     y += GTK_WIDGET (itembar)->allocation.y;
 

Modified: xfce4-panel/trunk/libxfce4panel/xfce-itembar.h
===================================================================
--- xfce4-panel/trunk/libxfce4panel/xfce-itembar.h      2007-10-20 09:22:49 UTC 
(rev 26149)
+++ xfce4-panel/trunk/libxfce4panel/xfce-itembar.h      2007-10-20 10:32:12 UTC 
(rev 26150)
@@ -26,8 +26,9 @@
 
 G_BEGIN_DECLS
 
-typedef struct _XfceItembar      XfceItembar;
-typedef struct _XfceItembarClass XfceItembarClass;
+typedef struct _XfceItembar        XfceItembar;
+typedef struct _XfceItembarClass   XfceItembarClass;
+typedef struct _XfceItembarPrivate XfceItembarPrivate;
 
 #define XFCE_TYPE_ITEMBAR            (xfce_itembar_get_type ())
 #define XFCE_ITEMBAR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
XFCE_TYPE_ITEMBAR, XfceItembar))
@@ -39,6 +40,9 @@
 struct _XfceItembar
 {
     GtkContainer __parent__;
+
+    /* private */
+    XfceItembarPrivate *priv;
 };
 
 struct _XfceItembarClass
@@ -61,6 +65,9 @@
 
 GtkWidget      *xfce_itembar_new                    (GtkOrientation        
orientation) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
+void            xfce_itembar_set_maximum_size       (XfceItembar          
*itembar,
+                                                     gint                  
size);
+
 void            xfce_itembar_set_allow_expand       (XfceItembar          
*itembar,
                                                      gboolean              
allow);
 

Modified: xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.c
===================================================================
--- xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.c   2007-10-20 
09:22:49 UTC (rev 26149)
+++ xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.c   2007-10-20 
10:32:12 UTC (rev 26150)
@@ -1258,10 +1258,10 @@
 /**
  * xfce_panel_plugin_arrow_type:
  * @plugin        : an #XfcePanelPlugin
- * 
+ *
  * Determine the #GtkArrowType for a widget that opens a menu and uses
  *  xfce_panel_plugin_position_menu() to position the menu.
- * 
+ *
  * Returns: The #GtkArrowType to use.
  **/
 GtkArrowType
@@ -1332,7 +1332,7 @@
  * If @attach_widget is NULL, the menu widget is instead positioned
  * relative to @panel_plugin.
  *
- * This function is intended for custom menu widgets. 
+ * This function is intended for custom menu widgets.
  * For a regular #GtkMenu you should use xfce_panel_plugin_position_menu()
  * instead (as callback argument to gtk_menu_popup()).
  *
@@ -1410,16 +1410,16 @@
  * @x            : return location for the x coordinate
  * @y            : return location for the y coordinate
  * @push_in      : keep inside the screen (see #GtkMenuPositionFunc)
- * @panel_plugin : a pointer to an #XfcePanelPlugin 
+ * @panel_plugin : a pointer to an #XfcePanelPlugin
  *
- * Function to be used as #GtkMenuPositionFunc in a call to gtk_menu_popup(). 
+ * Function to be used as #GtkMenuPositionFunc in a call to gtk_menu_popup().
  * As data argument it needs an #XfcePanelPlugin.
  *
  * The menu is normally positioned relative to @panel_plugin. If you want the
- * menu to be positioned relative to another widget, you can use 
+ * menu to be positioned relative to another widget, you can use
  * gtk_menu_attach_to_widget() to explicitly set a 'parent' widget.
  *
- * As a convenience, xfce_panel_plugin_position_menu() calls 
+ * As a convenience, xfce_panel_plugin_position_menu() calls
  * xfce_panel_plugin_register_menu() for the menu.
  *
  * <example>
@@ -1434,7 +1434,7 @@
  * }
  * </example>
  *
- * For a custom widget that will be used as a popup menu, use 
+ * For a custom widget that will be used as a popup menu, use
  * xfce_panel_plugin_position_widget() instead.
  *
  * See also: gtk_menu_popup().
@@ -1451,9 +1451,9 @@
 
     attach_widget = gtk_menu_get_attach_widget (menu);
 
-    xfce_panel_plugin_position_widget (plugin, 
-                                       GTK_WIDGET (menu), 
-                                       attach_widget, 
+    xfce_panel_plugin_position_widget (plugin,
+                                       GTK_WIDGET (menu),
+                                       attach_widget,
                                        x, y);
 
     /* keep inside screen */

Modified: xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.h
===================================================================
--- xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.h   2007-10-20 
09:22:49 UTC (rev 26149)
+++ xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.h   2007-10-20 
10:32:12 UTC (rev 26150)
@@ -112,7 +112,7 @@
 GtkArrowType         xfce_panel_plugin_arrow_type           (XfcePanelPlugin  
*plugin);
 void                 xfce_panel_plugin_position_widget      (XfcePanelPlugin  
*plugin,
                                                              GtkWidget        
*menu_widget,
-                                                            GtkWidget        
*attach_widget,
+                                                             GtkWidget        
*attach_widget,
                                                              gint             
*x,
                                                              gint             
*y);
 void                 xfce_panel_plugin_position_menu        (GtkMenu          
*menu,

Modified: xfce4-panel/trunk/libxfce4panel/xfce-panel-window.c
===================================================================
--- xfce4-panel/trunk/libxfce4panel/xfce-panel-window.c 2007-10-20 09:22:49 UTC 
(rev 26149)
+++ xfce4-panel/trunk/libxfce4panel/xfce-panel-window.c 2007-10-20 10:32:12 UTC 
(rev 26150)
@@ -309,6 +309,7 @@
                   "decorated", FALSE,
                   "resizable", FALSE,
                   "type-hint", GDK_WINDOW_TYPE_HINT_DOCK,
+                  "title", PACKAGE_NAME " " PACKAGE_VERSION,
                   NULL);
 
     gtk_window_stick (GTK_WINDOW (panel_window));

Modified: xfce4-panel/trunk/panel/panel-app.c
===================================================================
--- xfce4-panel/trunk/panel/panel-app.c 2007-10-20 09:22:49 UTC (rev 26149)
+++ xfce4-panel/trunk/panel/panel-app.c 2007-10-20 10:32:12 UTC (rev 26150)
@@ -47,7 +47,9 @@
 #endif
 
 #include <X11/Xlib.h>
+#include <X11/Xatom.h>
 #include <gtk/gtk.h>
+#include <gdk/gdkx.h>
 #include <libxfcegui4/libxfcegui4.h>
 #include <libxfce4panel/xfce-panel-macros.h>
 #include <libxfce4panel/xfce-panel-convenience.h>

Modified: xfce4-panel/trunk/panel/panel-dialogs.c
===================================================================
--- xfce4-panel/trunk/panel/panel-dialogs.c     2007-10-20 09:22:49 UTC (rev 
26149)
+++ xfce4-panel/trunk/panel/panel-dialogs.c     2007-10-20 10:32:12 UTC (rev 
26150)
@@ -28,6 +28,7 @@
 
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtk.h>
+#include <gdk/gdkx.h>
 #include <libxfcegui4/libxfcegui4.h>
 
 #include <libxfce4panel/xfce-itembar.h>

Modified: xfce4-panel/trunk/panel/panel-properties.c
===================================================================
--- xfce4-panel/trunk/panel/panel-properties.c  2007-10-20 09:22:49 UTC (rev 
26149)
+++ xfce4-panel/trunk/panel/panel-properties.c  2007-10-20 10:32:12 UTC (rev 
26150)
@@ -292,7 +292,7 @@
             /* no struts possible on Xinerama screens when this monitor
              * has neighbors on the left (see fd.o spec).
              */
-            if (!xmon->has_neighbor_left 
+            if (!xmon->has_neighbor_left
                 && _validate_strut (xmon->geometry.width, w))
             {
                 data[0] = xmon->geometry.x + w; /* left           */
@@ -305,7 +305,7 @@
             /* no struts possible on Xinerama screens when this monitor
              * has neighbors on the right (see fd.o spec).
              */
-            if (!xmon->has_neighbor_right 
+            if (!xmon->has_neighbor_right
                 && _validate_strut (xmon->geometry.width, w))
             {
                 data[1] =  gdk_screen_get_width (xmon->screen)
@@ -320,7 +320,7 @@
             /* no struts possible on Xinerama screens when this monitor
              * has neighbors on the top (see fd.o spec).
              */
-            if (!xmon->has_neighbor_above 
+            if (!xmon->has_neighbor_above
                 && _validate_strut (xmon->geometry.height, h))
             {
                 data[2] = xmon->geometry.y
@@ -695,7 +695,6 @@
         }
 
         gtk_widget_hide (priv->itembar);
-        gtk_widget_set_size_request (GTK_WIDGET (panel), w, h);
     }
     else
     {
@@ -729,8 +728,9 @@
         }
 
         gtk_widget_show (priv->itembar);
-        gtk_widget_set_size_request (GTK_WIDGET (panel), w, h);
     }
+
+    gtk_widget_set_size_request (GTK_WIDGET (panel), w, h);
 }
 
 static gboolean
@@ -958,7 +958,7 @@
     PanelPrivate   *priv;
     GtkOrientation  orientation;
     XfceMonitor    *xmon;
-    gint            x, y, w, h;
+    gint            x, y, w, h, max;
     GtkRequisition  req;
     GdkRectangle    rect;
 
@@ -975,29 +975,35 @@
 
     gtk_window_set_screen (GTK_WINDOW (panel), xmon->screen);
 
+    w = h = -1;
+
     if (priv->full_width > XFCE_PANEL_NORMAL_WIDTH)
-    {
         xfce_itembar_set_allow_expand (XFCE_ITEMBAR (priv->itembar), TRUE);
-        if (xfce_screen_position_is_horizontal (priv->screen_position))
-        {
-            if (priv->full_width == XFCE_PANEL_FULL_WIDTH)
-                w = xmon->geometry.width;
-            else
-                w = gdk_screen_get_width (xmon->screen);
 
-            gtk_widget_set_size_request (GTK_WIDGET (panel), w, -1);
-        }
+    if (xfce_screen_position_is_horizontal (priv->screen_position))
+    {
+        if (priv->full_width < XFCE_PANEL_SPAN_MONITORS)
+            w = xmon->geometry.width;
         else
-        {
-            if (priv->full_width == XFCE_PANEL_FULL_WIDTH)
-                h = xmon->geometry.height;
-            else
-                h = gdk_screen_get_height (xmon->screen);
+            w = gdk_screen_get_width (xmon->screen);
 
-            gtk_widget_set_size_request (GTK_WIDGET (panel), -1, h);
-        }
+        max = w;
     }
+    else
+    {
+        if (priv->full_width < XFCE_PANEL_SPAN_MONITORS)
+            h = xmon->geometry.height;
+        else
+            h = gdk_screen_get_height (xmon->screen);
 
+        max = h;
+    }
+
+    xfce_itembar_set_maximum_size (XFCE_ITEMBAR (priv->itembar), max);
+
+    if (priv->full_width > XFCE_PANEL_NORMAL_WIDTH)
+        gtk_widget_set_size_request (GTK_WIDGET (panel), w, -1);
+
     if (!xfce_screen_position_is_floating (priv->screen_position))
     {
         xfce_panel_window_set_movable (XFCE_PANEL_WINDOW (panel), FALSE);
@@ -1184,7 +1190,7 @@
 {
     PanelPrivate *priv;
     XfceMonitor  *xmon;
-    gint          w, h;
+    gint          w = -1, h = -1, max = -1;
 
     priv = panel->priv;
 
@@ -1196,46 +1202,52 @@
         {
             xmon = panel_app_get_monitor (priv->monitor);
 
-            w = h = 0;
-
             switch (priv->full_width)
             {
                 case XFCE_PANEL_NORMAL_WIDTH:
-                    w = h = -1;
                     xfce_itembar_set_allow_expand (XFCE_ITEMBAR 
(priv->itembar),
                                                    FALSE);
+
+                    if (xfce_screen_position_is_horizontal 
(priv->screen_position))
+                        max = xmon->geometry.width;
+                    else
+                        max = xmon->geometry.height;
                     break;
 
                 case XFCE_PANEL_FULL_WIDTH:
                 case XFCE_PANEL_SPAN_MONITORS:
-                    xfce_itembar_set_allow_expand (XFCE_ITEMBAR 
(priv->itembar), 
+                    xfce_itembar_set_allow_expand (XFCE_ITEMBAR 
(priv->itembar),
                                                    TRUE);
                     if (xfce_screen_position_is_horizontal (
                                 priv->screen_position))
                     {
-                        h = -1;
                         if (priv->full_width == XFCE_PANEL_FULL_WIDTH)
                             w = xmon->geometry.width;
                         else
                             w = gdk_screen_get_width (xmon->screen);
+
+                        max = w;
                     }
                     else
                     {
-                        w = -1;
                         if (priv->full_width == XFCE_PANEL_FULL_WIDTH)
                             h = xmon->geometry.height;
                         else
                             h = gdk_screen_get_height (xmon->screen);
+
+                        max = h;
                     }
                     break;
             }
 
+            xfce_itembar_set_maximum_size (XFCE_ITEMBAR (priv->itembar), max);
+
             gtk_widget_set_size_request (GTK_WIDGET (panel), w, h);
 
             panel_set_position (panel, priv->screen_position,
                                 priv->xoffset, priv->yoffset);
 
-            gtk_widget_queue_draw (GTK_WIDGET (panel));
+            gtk_widget_queue_resize (GTK_WIDGET (panel));
         }
     }
 }
@@ -1460,7 +1472,7 @@
         {
             panel_set_full_width (panel, full_width);
         }
-        
+
         /* update itembar size request */
         panel_set_size (panel, priv->size);
 

Modified: xfce4-panel/trunk/panel/panel.c
===================================================================
--- xfce4-panel/trunk/panel/panel.c     2007-10-20 09:22:49 UTC (rev 26149)
+++ xfce4-panel/trunk/panel/panel.c     2007-10-20 10:32:12 UTC (rev 26150)
@@ -249,8 +249,6 @@
     priv->transparency    = DEFAULT_TRANSPARENCY;
     priv->activetrans     = DEFAULT_ACTIVE_TRANS;
 
-    gtk_window_set_title (GTK_WINDOW (panel), "Xfce Panel");
-
     priv->itembar = xfce_itembar_new (GTK_ORIENTATION_HORIZONTAL);
     gtk_widget_show (priv->itembar);
     gtk_container_add (GTK_CONTAINER (panel), priv->itembar);

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to