Updating branch refs/heads/andrzejr/deskbar-github to d31a2d90bb5bd1d2234d142957d41cd8db105b8b (commit) from 4cfca15e1faa64880dc17490d6891a9edb3342f9 (commit)
commit d31a2d90bb5bd1d2234d142957d41cd8db105b8b Author: Andrzej <ndrwr...@gmail.com> Date: Fri Nov 11 05:04:51 2011 +0900 Added multi-row layout of "small" plug-ins to the panel. Early implementation, not fully tested. D&D is not aware of different plug-in sizes. panel/panel-itembar.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 81 insertions(+), 3 deletions(-) diff --git a/panel/panel-itembar.c b/panel/panel-itembar.c index 8b65182..29f5efe 100644 --- a/panel/panel-itembar.c +++ b/panel/panel-itembar.c @@ -308,6 +308,38 @@ panel_itembar_finalize (GObject *object) } +static void +panel_itembar_column_wrap (PanelItembar *itembar, + gint *column_row, + gint *x, + gint *y) +{ + *column_row = 0; + if (itembar->horizontal) { + *y = 0; + *x += itembar->size / itembar->nrows; + } else { + *x = 0; + *y += itembar->size / itembar->nrows; + } +} + + +static void +panel_itembar_column_next (PanelItembar *itembar, + gint *column_row, + gint *x, + gint *y) +{ + (*column_row)++; + if (*column_row < itembar->nrows) { + if (itembar->horizontal) + *y += itembar->size / itembar->nrows; + else + *x += itembar->size / itembar->nrows; + } else panel_itembar_column_wrap(itembar, column_row, x, y); +} + static void panel_itembar_size_request (GtkWidget *widget, @@ -319,6 +351,7 @@ panel_itembar_size_request (GtkWidget *widget, GtkRequisition child_requisition; gint border_width; gint row_length = 0; + gint column_row = 0; /* intialize the requisition, we always set the panel height */ if (itembar->horizontal) @@ -344,8 +377,21 @@ panel_itembar_size_request (GtkWidget *widget, gtk_widget_size_request (child->widget, &child_requisition); - if (G_LIKELY (!child->wrap)) + if (child->small) { + if (column_row == 0) + { + column_row ++; + row_length += (itembar->size / itembar->nrows); + } + else if (column_row < itembar->nrows) + column_row ++; + else + column_row = 0; + } + else if (G_LIKELY (!child->wrap)) + { + column_row = 0; if (itembar->horizontal) row_length += child_requisition.width; else @@ -353,6 +399,7 @@ panel_itembar_size_request (GtkWidget *widget, } else { + column_row = 0; /* add to size for new wrap element */ if (itembar->horizontal) { @@ -408,6 +455,7 @@ panel_itembar_size_allocate (GtkWidget *widget, gboolean expand_children_fit; gint new_length; gint child_length; + gint column_row; widget->allocation = *allocation; @@ -425,6 +473,7 @@ panel_itembar_size_allocate (GtkWidget *widget, expand_length_req = 0; shrink_length_avail = 0; shrink_length_req = 0; + column_row = 0; /* get information about the expandable lengths */ for (lp = li; lp != NULL; lp = g_slist_next (lp)) @@ -442,12 +491,26 @@ panel_itembar_size_allocate (GtkWidget *widget, gtk_widget_get_child_requisition (child->widget, &child_req); length = itembar->horizontal ? child_req.width : child_req.height; - if (G_UNLIKELY (child->expand)) + if (child->small) { + if (column_row == 0) + { + column_row ++; + expand_length_avail -= (itembar->size / itembar->nrows); + } + else if (column_row < itembar->nrows) + column_row ++; + else + column_row = 0; + } + else if (G_UNLIKELY (child->expand)) + { + column_row = 0; expand_length_req += length; } else { + column_row = 0; expand_length_avail -= length; if (child->shrink) @@ -484,6 +547,7 @@ panel_itembar_size_allocate (GtkWidget *widget, } /* allocate the children on this row */ + column_row = 0; for (; li != NULL; li = g_slist_next (li)) { child = li->data; @@ -493,12 +557,12 @@ panel_itembar_size_allocate (GtkWidget *widget, { itembar->highlight_x = x; itembar->highlight_y = y; - expand_length_avail -= itembar->size; if (itembar->horizontal) x += itembar->size; else y += itembar->size; + expand_length_avail -= itembar->size; continue; } @@ -506,6 +570,17 @@ panel_itembar_size_allocate (GtkWidget *widget, if (!GTK_WIDGET_VISIBLE (child->widget)) continue; + if (child->small) { + child_alloc.x = x; + child_alloc.y = y; + child_alloc.height = itembar->size / itembar->nrows; + child_alloc.width = itembar->size / itembar->nrows; + panel_itembar_column_next(itembar, &column_row, &x, &y); + gtk_widget_size_allocate (child->widget, &child_alloc); + continue; + } else + if (column_row > 0) panel_itembar_column_wrap(itembar, &column_row, &x, &y); + gtk_widget_get_child_requisition (child->widget, &child_req); child_alloc.x = x; @@ -540,6 +615,9 @@ panel_itembar_size_allocate (GtkWidget *widget, break; } + /* if (child->small) */ + /* child_length = itembar->size / itembar->nrows; */ + /* else */ child_length = itembar->horizontal ? child_req.width : child_req.height; if (G_UNLIKELY (!expand_children_fit && child->expand)) _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits