diff --git a/libxfce4panel/xfce-itembar.c b/libxfce4panel/xfce-itembar.c
index 4d8d8c8b..a31a3b57 100644
--- a/libxfce4panel/xfce-itembar.c
+++ b/libxfce4panel/xfce-itembar.c
@@ -63,7 +63,6 @@ enum
typedef struct _XfceItembarChild XfceItembarChild;
-typedef struct _XfceItembarPrivate XfceItembarPrivate;
struct _XfceItembarPrivate
{
@@ -76,12 +75,14 @@ struct _XfceItembarPrivate
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 @@ xfce_itembar_class_init (XfceItembarClass *klass)
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,7 +273,11 @@ xfce_itembar_class_init (XfceItembarClass *klass)
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 @@ xfce_itembar_init (XfceItembar *itembar)
priv->drop_index = -1;
priv->raised = FALSE;
priv->expand_allowed = FALSE;
+ priv->maximum_size = -1;
}
@@ -344,12 +350,12 @@ static gint
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,49 +366,40 @@ static void
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;
- }
- else
- {
- max = MAX (max, req.width);
-
- other_size += req.height;
+ /* append the widget size request */
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ requisition->width += req.width;
+ else
+ requisition->height += req.height;
}
}
- if (GTK_ORIENTATION_HORIZONTAL == priv->orientation)
- {
- requisition->height += max;
- requisition->width += other_size;
- }
- else
+ if (G_LIKELY (priv->maximum_size != -1))
{
- requisition->width += max;
- requisition->height += 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);
}
}
@@ -412,207 +409,170 @@ static void
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 @@ xfce_itembar_realize (GtkWidget *widget)
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 @@ xfce_itembar_realize (GtkWidget *widget)
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,9 +621,7 @@ xfce_itembar_realize (GtkWidget *widget)
static void
xfce_itembar_unrealize (GtkWidget *widget)
{
- XfceItembarPrivate *priv;
-
- priv = XFCE_ITEMBAR_GET_PRIVATE (widget);
+ XfceItembarPrivate *priv = XFCE_ITEMBAR (widget)->priv;
if (priv->event_window != NULL)
{
@@ -681,9 +639,7 @@ xfce_itembar_unrealize (GtkWidget *widget)
static void
xfce_itembar_map (GtkWidget *widget)
{
- XfceItembarPrivate *priv;
-
- priv = XFCE_ITEMBAR_GET_PRIVATE (widget);
+ XfceItembarPrivate *priv = XFCE_ITEMBAR (widget)->priv;
gdk_window_show (priv->event_window);
@@ -698,9 +654,7 @@ xfce_itembar_map (GtkWidget *widget)
static void
xfce_itembar_unmap (GtkWidget *widget)
{
- XfceItembarPrivate *priv;
-
- priv = XFCE_ITEMBAR_GET_PRIVATE (widget);
+ XfceItembarPrivate *priv = XFCE_ITEMBAR (widget)->priv;
if (priv->event_window != NULL)
gdk_window_hide (priv->event_window);
@@ -715,8 +669,7 @@ xfce_itembar_drag_leave (GtkWidget *widget,
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 @@ xfce_itembar_drag_motion (GtkWidget *widget,
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 @@ xfce_itembar_drag_motion (GtkWidget *widget,
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,9 +768,7 @@ xfce_itembar_forall (GtkContainer *container,
{
GSList *l;
XfceItembarChild *child;
- XfceItembarPrivate *priv;
-
- priv = XFCE_ITEMBAR_GET_PRIVATE (XFCE_ITEMBAR (container));
+ XfceItembarPrivate *priv = XFCE_ITEMBAR (container)->priv;
for (l = priv->children; l != NULL; l = l->next)
{
@@ -851,16 +802,13 @@ static void
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 @@ _find_drop_index (XfceItembar *itembar,
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)
@@ -1036,6 +984,27 @@ xfce_itembar_new (GtkOrientation orientation)
+/**
+ * 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
@@ -1049,12 +1018,10 @@ void
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 @@ xfce_itembar_set_allow_expand (XfceItembar *itembar,
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 @@ void
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 @@ xfce_itembar_insert (XfceItembar *itembar,
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 @@ xfce_itembar_reorder_child (XfceItembar *itembar,
GtkWidget *item,
gint position)
{
- XfceItembarPrivate *priv;
+ XfceItembarPrivate *priv = itembar->priv;
XfceItembarChild *child;
GSList *l;
@@ -1204,8 +1165,6 @@ xfce_itembar_reorder_child (XfceItembar *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;
@@ -1243,7 +1202,7 @@ gboolean
xfce_itembar_get_child_expand (XfceItembar *itembar,
GtkWidget *item)
{
- XfceItembarPrivate *priv;
+ XfceItembarPrivate *priv = itembar->priv;
XfceItembarChild *child;
GSList *l;
@@ -1251,8 +1210,6 @@ xfce_itembar_get_child_expand (XfceItembar *itembar,
_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 @@ xfce_itembar_set_child_expand (XfceItembar *itembar,
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 @@ xfce_itembar_set_child_expand (XfceItembar *itembar,
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 @@ gint
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 @@ xfce_itembar_get_item_index (XfceItembar *itembar,
_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 @@ GtkWidget *
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 @@ xfce_itembar_get_nth_item (XfceItembar *itembar,
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 @@ xfce_itembar_raise_event_window (XfceItembar *itembar)
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 @@ xfce_itembar_lower_event_window (XfceItembar *itembar)
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 @@ xfce_itembar_get_item_at_point (XfceItembar *itembar,
gint x,
gint y)
{
- XfceItembarPrivate *priv;
+ XfceItembarPrivate *priv = itembar->priv;
XfceItembarChild *child;
GSList *l;
GtkWidget *w;
@@ -1499,8 +1442,6 @@ xfce_itembar_get_item_at_point (XfceItembar *itembar,
_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;
diff --git a/libxfce4panel/xfce-itembar.h b/libxfce4panel/xfce-itembar.h
index feebf47d..b7f6851c 100644
--- a/libxfce4panel/xfce-itembar.h
+++ b/libxfce4panel/xfce-itembar.h
@@ -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 @@ typedef struct _XfceItembarClass XfceItembarClass;
struct _XfceItembar
{
GtkContainer __parent__;
+
+ /* private */
+ XfceItembarPrivate *priv;
};
struct _XfceItembarClass
@@ -61,6 +65,9 @@ GType xfce_itembar_get_type (void) G_GNUC_CONST;
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);
diff --git a/libxfce4panel/xfce-panel-plugin-iface.c b/libxfce4panel/xfce-panel-plugin-iface.c
index 3b0c0fe8..372fc232 100644
--- a/libxfce4panel/xfce-panel-plugin-iface.c
+++ b/libxfce4panel/xfce-panel-plugin-iface.c
@@ -1258,10 +1258,10 @@ _xfce_panel_plugin_set_sensitive (XfcePanelPlugin *plugin,
/**
* 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 @@ xfce_panel_plugin_arrow_type (XfcePanelPlugin *plugin)
* 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 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
* @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.
*
*
@@ -1434,7 +1434,7 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
* }
*
*
- * 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 @@ xfce_panel_plugin_position_menu (GtkMenu *menu,
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 */
diff --git a/libxfce4panel/xfce-panel-plugin-iface.h b/libxfce4panel/xfce-panel-plugin-iface.h
index 815078f5..ff83e360 100644
--- a/libxfce4panel/xfce-panel-plugin-iface.h
+++ b/libxfce4panel/xfce-panel-plugin-iface.h
@@ -112,7 +112,7 @@ void xfce_panel_plugin_register_menu (XfcePanelPlugin *p
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,
diff --git a/libxfce4panel/xfce-panel-window.c b/libxfce4panel/xfce-panel-window.c
index b246d7ce..7d0687b1 100644
--- a/libxfce4panel/xfce-panel-window.c
+++ b/libxfce4panel/xfce-panel-window.c
@@ -309,6 +309,7 @@ xfce_panel_window_init (XfcePanelWindow *panel_window)
"decorated", FALSE,
"resizable", FALSE,
"type-hint", GDK_WINDOW_TYPE_HINT_DOCK,
+ "title", PACKAGE_NAME " " PACKAGE_VERSION,
NULL);
gtk_window_stick (GTK_WINDOW (panel_window));
diff --git a/panel/panel-app.c b/panel/panel-app.c
index 5eab0634..05318ba0 100644
--- a/panel/panel-app.c
+++ b/panel/panel-app.c
@@ -47,7 +47,9 @@
#endif
#include
+#include
#include
+#include
#include
#include
#include
diff --git a/panel/panel-dialogs.c b/panel/panel-dialogs.c
index bb90f4ed..47ab489f 100644
--- a/panel/panel-dialogs.c
+++ b/panel/panel-dialogs.c
@@ -28,6 +28,7 @@
#include
#include
+#include
#include
#include
diff --git a/panel/panel-properties.c b/panel/panel-properties.c
index 6dc57018..19565a26 100644
--- a/panel/panel-properties.c
+++ b/panel/panel-properties.c
@@ -292,7 +292,7 @@ _set_struts (Panel *panel,
/* 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 @@ _set_struts (Panel *panel,
/* 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 @@ _set_struts (Panel *panel,
/* 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 @@ panel_set_hidden (Panel *panel,
}
gtk_widget_hide (priv->itembar);
- gtk_widget_set_size_request (GTK_WIDGET (panel), w, h);
}
else
{
@@ -729,8 +728,9 @@ panel_set_hidden (Panel *panel,
}
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 @@ panel_init_position (Panel *panel)
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 @@ panel_init_position (Panel *panel)
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 @@ panel_set_full_width (Panel *panel,
{
PanelPrivate *priv;
XfceMonitor *xmon;
- gint w, h;
+ gint w = -1, h = -1, max = -1;
priv = panel->priv;
@@ -1196,46 +1202,52 @@ panel_set_full_width (Panel *panel,
{
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_screen_position (Panel *panel,
{
panel_set_full_width (panel, full_width);
}
-
+
/* update itembar size request */
panel_set_size (panel, priv->size);
diff --git a/panel/panel.c b/panel/panel.c
index dd6bc9f1..a4285605 100644
--- a/panel/panel.c
+++ b/panel/panel.c
@@ -249,8 +249,6 @@ panel_init (Panel * panel)
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);