Debian #524117
GNOME #513347 and #86382
Index: libwnck-2.30.3/libwnck/tasklist.c
===================================================================
--- libwnck-2.30.3.orig/libwnck/tasklist.c 2010-08-16 19:49:35.885871012 +0200
+++ libwnck-2.30.3/libwnck/tasklist.c 2010-08-17 00:06:53.550368075 +0200
@@ -234,6 +234,8 @@ struct _WnckTasklistPrivate
GdkPixmap *background;
guint drag_start_time;
+
+ GtkOrientation orientation;
};
static GType wnck_task_get_type (void);
@@ -316,6 +318,7 @@ static int wnck_tasklist_layout
int max_width,
int max_height,
int n_buttons,
+ GtkOrientation orientation,
int *n_cols_out,
int *n_rows_out);
@@ -976,6 +979,20 @@ wnck_tasklist_set_button_relief (WnckTas
}
/**
+ * wnck_tasklist_set_orientation:
+ * @tasklist: a #WnckTasklist.
+ * @orient: a GtkOrientation.
+ *
+ * Set the orientation of the @taskluist. The main use of this function is
+ * proper integration of #WnckTasklist in vertical panels.
+ */
+
+void wnck_tasklist_set_orientation(WnckTasklist *tasklist, GtkOrientation orient)
+{
+ tasklist->priv->orientation = orient;
+}
+
+/**
* wnck_tasklist_set_switch_workspace_on_unminimize:
* @tasklist: a #WnckTasklist.
* @switch_workspace_on_unminimize: whether to activate the #WnckWorkspace a
@@ -1147,29 +1164,38 @@ wnck_tasklist_layout (GtkAllocation *all
int max_width,
int max_height,
int n_buttons,
+ GtkOrientation orientation,
int *n_cols_out,
int *n_rows_out)
{
int n_cols, n_rows;
- /* How many rows fit in the allocation */
- n_rows = allocation->height / max_height;
-
- /* Don't have more rows than buttons */
- n_rows = MIN (n_rows, n_buttons);
-
- /* At least one row */
- n_rows = MAX (n_rows, 1);
-
- /* We want to use as many rows as possible to limit the width */
- n_cols = (n_buttons + n_rows - 1) / n_rows;
-
- /* At least one column */
- n_cols = MAX (n_cols, 1);
+ if (orientation == GTK_ORIENTATION_HORIZONTAL) {
+ /* How many rows fit in the allocation */
+ n_rows = allocation->height / max_height;
+
+ /* Don't have more rows than buttons */
+ n_rows = MIN (n_rows, n_buttons);
+
+ /* At least one row */
+ n_rows = MAX (n_rows, 1);
+
+ /* We want to use as many rows as possible to limit the width */
+ n_cols = (n_buttons + n_rows - 1) / n_rows;
+
+ /* At least one column */
+ n_cols = MAX (n_cols, 1);
+
+ } else {
+ n_cols = allocation->width / max_width;
+ n_cols = MIN(n_cols, n_buttons);
+ n_cols = MAX(n_cols, 1);
+ n_rows = (n_buttons + n_cols - 1) / n_cols;
+ n_rows = MAX(n_rows, 1);
+ }
*n_cols_out = n_cols;
*n_rows_out = n_rows;
-
return allocation->width / n_cols;
}
@@ -1367,19 +1393,31 @@ wnck_tasklist_size_request (GtkWidget
tasklist->priv->max_button_width,
tasklist->priv->max_button_height,
n_windows + n_startup_sequences,
+ tasklist->priv->orientation,
&n_cols, &n_rows);
last_n_cols = G_MAXINT;
lowest_range = G_MAXINT;
if (tasklist->priv->grouping != WNCK_TASKLIST_ALWAYS_GROUP)
{
- val = n_cols * tasklist->priv->max_button_width;
- g_array_insert_val (array, array->len, val);
- val = n_cols * grouping_limit;
- g_array_insert_val (array, array->len, val);
-
- last_n_cols = n_cols;
- lowest_range = val;
+ if (tasklist->priv->orientation == GTK_ORIENTATION_HORIZONTAL) {
+ val = n_cols * tasklist->priv->max_button_width;
+ g_array_insert_val (array, array->len, val);
+ val = n_cols * grouping_limit;
+ g_array_insert_val (array, array->len, val);
+
+ last_n_cols = n_cols;
+ lowest_range = val;
+ } else {
+ val = n_rows * tasklist->priv->max_button_height;
+ g_array_insert_val (array, array->len, val);
+ val = n_rows * grouping_limit;
+ g_array_insert_val (array, array->len, val);
+
+ last_n_cols = n_rows;
+ lowest_range = val;
+
+ }
}
while (ungrouped_class_groups != NULL &&
@@ -1399,29 +1437,56 @@ wnck_tasklist_size_request (GtkWidget
tasklist->priv->max_button_width,
tasklist->priv->max_button_height,
n_startup_sequences + n_windows - n_grouped_buttons,
+ tasklist->priv->orientation,
&n_cols, &n_rows);
- if (n_cols != last_n_cols &&
- (tasklist->priv->grouping == WNCK_TASKLIST_AUTO_GROUP ||
- ungrouped_class_groups == NULL))
- {
- val = n_cols * tasklist->priv->max_button_width;
- if (val >= lowest_range)
- { /* Overlaps old range */
- g_assert (array->len > 0);
- lowest_range = n_cols * grouping_limit;
- g_array_index(array, int, array->len-1) = lowest_range;
- }
- else
- {
- /* Full new range */
- g_array_insert_val (array, array->len, val);
- val = n_cols * grouping_limit;
- g_array_insert_val (array, array->len, val);
- lowest_range = val;
- }
-
- last_n_cols = n_cols;
- }
+ if (tasklist->priv->orientation == GTK_ORIENTATION_HORIZONTAL) {
+ if (n_cols != last_n_cols &&
+ (tasklist->priv->grouping == WNCK_TASKLIST_AUTO_GROUP ||
+ ungrouped_class_groups == NULL))
+ {
+ val = n_cols * tasklist->priv->max_button_width;
+ if (val >= lowest_range)
+ { /* Overlaps old range */
+ g_assert (array->len > 0);
+ lowest_range = n_cols * grouping_limit;
+ g_array_index(array, int, array->len-1) = lowest_range;
+ }
+ else
+ {
+ /* Full new range */
+ g_array_insert_val (array, array->len, val);
+ val = n_cols * grouping_limit;
+ g_array_insert_val (array, array->len, val);
+ lowest_range = val;
+ }
+
+ last_n_cols = n_cols;
+ }
+ } else {
+ if (n_rows != last_n_cols &&
+ (tasklist->priv->grouping == WNCK_TASKLIST_AUTO_GROUP ||
+ ungrouped_class_groups == NULL))
+ {
+ val = n_rows * tasklist->priv->max_button_height;;
+ if (val >= lowest_range)
+ { /* Overlaps old range */
+ g_assert (array->len > 0);
+ lowest_range = n_rows * grouping_limit;
+ g_array_index(array, int, array->len-1) = lowest_range;
+ }
+ else
+ {
+ /* Full new range */
+ g_array_insert_val (array, array->len, val);
+ val = n_rows * grouping_limit;
+ g_array_insert_val (array, array->len, val);
+ lowest_range = val;
+ }
+
+ last_n_cols = n_rows;
+ }
+ }
+
}
g_list_free (ungrouped_class_groups);
@@ -1443,8 +1508,13 @@ wnck_tasklist_size_request (GtkWidget
tasklist->priv->size_hints = (int *)g_array_free (array, FALSE);
- requisition->width = tasklist->priv->size_hints[0];
- requisition->height = fake_allocation.height;
+ if (tasklist->priv->orientation == GTK_ORIENTATION_VERTICAL) {
+ requisition->width = n_cols * tasklist->priv->max_button_width;
+ requisition->height = n_rows * tasklist->priv->max_button_height;
+ } else {
+ requisition->width = tasklist->priv->size_hints[0];
+ requisition->height = fake_allocation.height;
+ }
}
/**
@@ -1540,6 +1610,7 @@ wnck_tasklist_size_allocate (GtkWidget
tasklist->priv->max_button_width,
tasklist->priv->max_button_height,
n_startup_sequences + n_windows,
+ tasklist->priv->orientation,
&n_cols, &n_rows);
while (ungrouped_class_groups != NULL &&
((tasklist->priv->grouping == WNCK_TASKLIST_ALWAYS_GROUP) ||
@@ -1589,6 +1660,7 @@ wnck_tasklist_size_allocate (GtkWidget
tasklist->priv->max_button_width,
tasklist->priv->max_button_height,
n_startup_sequences + n_windows - n_grouped_buttons,
+ tasklist->priv->orientation,
&n_cols, &n_rows);
}
@@ -2143,6 +2215,7 @@ wnck_tasklist_new (WnckScreen *screen)
WnckTasklist *tasklist;
tasklist = g_object_new (WNCK_TYPE_TASKLIST, NULL);
+ tasklist->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
return GTK_WIDGET (tasklist);
}
@@ -4275,7 +4348,6 @@ wnck_task_new_from_window (WnckTasklist
WnckTask *task;
task = g_object_new (WNCK_TYPE_TASK, NULL);
-
task->type = WNCK_TASK_WINDOW;
task->window = g_object_ref (window);
task->class_group = g_object_ref (wnck_window_get_class_group (window));
Index: libwnck-2.30.3/libwnck/tasklist.h
===================================================================
--- libwnck-2.30.3.orig/libwnck/tasklist.h 2010-08-16 19:49:35.841870516 +0200
+++ libwnck-2.30.3/libwnck/tasklist.h 2010-08-17 00:07:59.713865796 +0200
@@ -99,6 +99,11 @@ void wnck_tasklist_set_include_all_works
gboolean include_all_workspaces);
void wnck_tasklist_set_button_relief (WnckTasklist *tasklist,
GtkReliefStyle relief);
+#ifdef WNCK_I_KNOW_THIS_IS_NOT_UPSTREAM
+void wnck_tasklist_set_orientation(WnckTasklist *tasklist,
+ GtkOrientation orient);
+#endif
+
#ifndef WNCK_DISABLE_DEPRECATED
void wnck_tasklist_set_minimum_width (WnckTasklist *tasklist, gint size);
gint wnck_tasklist_get_minimum_width (WnckTasklist *tasklist);