--- tasklist-widget-ORIG.c 2014-02-16 03:38:19.000000000 +0100
+++ tasklist-widget.c 2014-04-26 13:08:32.505528412 +0200
@@ -55,7 +55,7 @@
#define WIREFRAME_SIZE (5) /* same as xfwm4 */
#define DRAG_ACTIVATE_TIMEOUT (500)
-
+#define ICON_SWITCH_SIZE (31) /* size for switching from mini-icon to normal icon */
/* locking helpers for tasklist->locked */
#define xfce_taskbar_lock(tasklist) G_STMT_START { XFCE_TASKLIST (tasklist)->locked++; } G_STMT_END
@@ -1102,7 +1102,18 @@
}
else /* buttons without labels */
{
- w = h;
+ if (tasklist->grouping == XFCE_TASKLIST_GROUPING_ALWAYS)
+ {
+ /* reserve some space for the number of windows in a group: */
+ w = h + tasklist->size / tasklist->nrows / 4;
+ /* some little adjustments necessary for small panel sizes: */
+ if (xfce_tasklist_deskbar (tasklist))
+ w = MAX (w + 4, 36);
+ else
+ w = MAX (w, 30);
+ }
+ else
+ w = h;
}
area_width -= w;
@@ -2070,8 +2081,10 @@
gtk_button_set_relief (GTK_BUTTON (child->button),
tasklist->button_relief);
- child->box = xfce_hvbox_new (!xfce_tasklist_vertical (tasklist) ?
- GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, FALSE, 6);
+ child->box = xfce_hvbox_new ((xfce_tasklist_horizontal (tasklist) ||
+ (xfce_tasklist_deskbar (tasklist) && tasklist->show_labels)) ?
+ GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, FALSE,
+ (!(tasklist->show_labels) && tasklist->grouping == XFCE_TASKLIST_GROUPING_ALWAYS) ? 0 : 6);
gtk_container_add (GTK_CONTAINER (child->button), child->box);
gtk_widget_show (child->box);
@@ -2088,7 +2101,10 @@
if (!xfce_tasklist_vertical (tasklist))
{
/* gtk_box_reorder_child (GTK_BOX (child->box), child->icon, 0); */
- gtk_misc_set_alignment (GTK_MISC (child->label), 0.0, 0.5);
+ if (!tasklist->show_labels)
+ gtk_misc_set_alignment (GTK_MISC (child->label), xfce_tasklist_deskbar (tasklist)? 0.5 : 0.0, 0.95);
+ else
+ gtk_misc_set_alignment (GTK_MISC (child->label), 0.0, 0.5);
gtk_label_set_ellipsize (GTK_LABEL (child->label), tasklist->ellipsize_mode);
}
else
@@ -2432,7 +2448,7 @@
return;
/* get the window icon */
- if (tasklist->show_labels)
+ if (tasklist->show_labels || tasklist->size / tasklist->nrows < ICON_SWITCH_SIZE)
pixbuf = wnck_window_get_mini_icon (window);
else
pixbuf = wnck_window_get_icon (window);
@@ -3446,13 +3462,28 @@
}
/* create the button label */
- name = wnck_class_group_get_name (group_child->class_group);
- if (!exo_str_is_empty (name))
- label = g_strdup_printf ("%s (%d)", name, n_windows);
+ if (group_child->tasklist->show_labels == FALSE)
+ {
+ /* prepare the label with the number of windows in a group */
+ if (group_child->tasklist->size / group_child->tasklist->nrows < 21)
+ label = g_strdup_printf ("..");
+ else
+ label = g_strdup_printf ("%d", n_windows);
+ gtk_label_set_markup (GTK_LABEL (group_child->label), label);
+ }
else
- label = g_strdup_printf ("(%d)", n_windows);
- gtk_label_set_text (GTK_LABEL (group_child->label), label);
+ {
+ name = wnck_class_group_get_name (group_child->class_group);
+ if (!exo_str_is_empty (name))
+ label = g_strdup_printf ("%s (%d)", name, n_windows);
+ else
+ label = g_strdup_printf ("(%d)", n_windows);
+ gtk_label_set_text (GTK_LABEL (group_child->label), label);
+ }
g_free (label);
+
+ /* show the label for the group */
+ gtk_widget_show (group_child->label);
/* don't sort if there is no need to update the sorting (ie. only number
* of windows is changed or button is not inserted in the tasklist yet */
@@ -3466,23 +3497,53 @@
xfce_tasklist_group_button_icon_changed (WnckClassGroup *class_group,
XfceTasklistChild *group_child)
{
- GdkPixbuf *pixbuf;
-
+ GdkPixbuf *pixbuf;
+ XfceTasklist *tasklist;
+ gboolean icon_expand = FALSE, icon_fill = FALSE,
+ label_expand = FALSE, label_fill = FALSE;
+ int spacing = 0;
+
panel_return_if_fail (XFCE_IS_TASKLIST (group_child->tasklist));
panel_return_if_fail (WNCK_IS_CLASS_GROUP (class_group));
panel_return_if_fail (group_child->class_group == class_group);
panel_return_if_fail (XFCE_IS_PANEL_IMAGE (group_child->icon));
+ tasklist = group_child->tasklist;
+
/* 0 means icons are disabled, although the grouping button does
* not use lucient icons */
- if (group_child->tasklist->minimized_icon_lucency == 0)
+ if (tasklist->minimized_icon_lucency == 0)
return;
/* get the class group icon */
- if (group_child->tasklist->show_labels)
- pixbuf = wnck_class_group_get_mini_icon (class_group);
+ if (tasklist->show_labels || tasklist->size / tasklist->nrows < ICON_SWITCH_SIZE)
+ {
+ pixbuf = wnck_class_group_get_mini_icon (class_group);
+ if (tasklist->grouping != XFCE_TASKLIST_GROUPING_ALWAYS)
+ icon_expand = icon_fill = TRUE;
+ if (!tasklist->show_labels)
+ gtk_widget_set_size_request(group_child->label, 6, 13);
+ if (xfce_tasklist_horizontal (tasklist))
+ spacing = 1;
+ if (tasklist->show_labels || tasklist->size / tasklist->nrows >= ICON_SWITCH_SIZE)
+ label_expand = label_fill = TRUE;
+ }
else
- pixbuf = wnck_class_group_get_icon (class_group);
+ {
+ pixbuf = wnck_class_group_get_icon (class_group);
+ icon_expand = icon_fill = TRUE;
+ gtk_widget_set_size_request(group_child->label, 10, 13);
+ spacing = 0;
+ }
+
+ gtk_box_set_child_packing (GTK_BOX (group_child->box),
+ group_child->icon,
+ icon_expand, icon_fill, 0,
+ GTK_PACK_START);
+ gtk_box_set_child_packing (GTK_BOX (group_child->box),
+ group_child->label,
+ label_expand, label_fill, spacing,
+ GTK_PACK_START);
if (G_LIKELY (pixbuf != NULL))
xfce_panel_image_set_from_pixbuf (XFCE_PANEL_IMAGE (group_child->icon), pixbuf);
@@ -3800,7 +3861,7 @@
child = li->data;
/* show or hide the label */
- if (show_labels)
+ if (show_labels || child->type == CHILD_TYPE_GROUP)
{
gtk_widget_show (child->label);
gtk_box_set_child_packing (GTK_BOX (child->box),
@@ -3819,7 +3880,19 @@
/* update the icon (we use another size for
* icon box mode) */
- xfce_tasklist_button_icon_changed (child->window, child);
+ if (child->type == CHILD_TYPE_GROUP)
+ {
+ xfce_tasklist_group_button_icon_changed (child->class_group, child);
+ xfce_tasklist_group_button_name_changed (NULL, child);
+ }
+ else
+ xfce_tasklist_button_icon_changed (child->window, child);
+ }
+
+ if (tasklist->screen != NULL)
+ {
+ xfce_tasklist_disconnect_screen (tasklist);
+ xfce_tasklist_connect_screen (tasklist);
}
}
}
@@ -3882,6 +3955,16 @@
xfce_tasklist_disconnect_screen (tasklist);
xfce_tasklist_connect_screen (tasklist);
}
+
+ /* update the group icons */
+ GList *li;
+ XfceTasklistChild *child;
+ for (li = tasklist->windows; li != NULL; li = li->next)
+ {
+ child = li->data;
+ if (child->type == CHILD_TYPE_GROUP)
+ xfce_tasklist_group_button_icon_changed (child->class_group, child);
+ }
}
}
@@ -3889,12 +3972,13 @@
static void
xfce_tasklist_update_orientation (XfceTasklist *tasklist)
{
- gboolean horizontal;
+ gboolean horizontal, deskbar;
GList *li;
XfceTasklistChild *child;
- horizontal = !xfce_tasklist_vertical (tasklist);
-
+ horizontal = xfce_tasklist_horizontal (tasklist);
+ deskbar = xfce_tasklist_deskbar (tasklist);
+
/* update the tasklist */
for (li = tasklist->windows; li != NULL; li = li->next)
{
@@ -3902,13 +3986,17 @@
/* update task box */
xfce_hvbox_set_orientation (XFCE_HVBOX (child->box),
- horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
+ (horizontal || (deskbar && tasklist->show_labels))?
+ GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
/* update the label */
- if (horizontal)
+ if (horizontal || deskbar)
{
/* gtk_box_reorder_child (GTK_BOX (child->box), child->icon, 0); */
- gtk_misc_set_alignment (GTK_MISC (child->label), 0.0, 0.5);
+ if (tasklist->show_labels)
+ gtk_misc_set_alignment (GTK_MISC (child->label), 0.0, 0.5);
+ else
+ gtk_misc_set_alignment (GTK_MISC (child->label), deskbar ? 0.5 : 0.0, 0.95);
gtk_label_set_angle (GTK_LABEL (child->label), 0);
gtk_label_set_ellipsize (GTK_LABEL (child->label),
child->tasklist->ellipsize_mode);
@@ -3969,6 +4057,21 @@
tasklist->size = size;
gtk_widget_queue_resize (GTK_WIDGET (tasklist));
}
+
+ /* update icons and labels */
+ GList *li;
+ XfceTasklistChild *child;
+ for (li = tasklist->windows; li != NULL; li = li->next)
+ {
+ child = li->data;
+ if (child->type == CHILD_TYPE_GROUP)
+ {
+ xfce_tasklist_group_button_icon_changed (child->class_group, child);
+ xfce_tasklist_group_button_name_changed (NULL, child);
+ }
+ else
+ xfce_tasklist_button_icon_changed (child->window, child);
+ }
}