summaryrefslogtreecommitdiff
path: root/libwnck
diff options
context:
space:
mode:
authorVincent Untz <vuntz@gnome.org>2007-06-26 13:58:14 +0000
committerVincent Untz <vuntz@src.gnome.org>2007-06-26 13:58:14 +0000
commit43e1aa971edb54dbb3e7959eaf6a22a1bc8eae2c (patch)
treefdece103c5b868cfc1bae1ba7f363b9bedf7dd11 /libwnck
parentb9ffaefa880599d910d14a1304a2c60e18594c1e (diff)
downloadlibwnck-43e1aa971edb54dbb3e7959eaf6a22a1bc8eae2c.tar.gz
Fix bug #308552.
2007-06-26 Vincent Untz <vuntz@gnome.org> Fix bug #308552. * libwnck/tasklist.c: (wnck_tasklist_size_request): some clean up, and add a comment about wnck_task_size_allocated() (wnck_task_size_allocated): new, hide widget the image or label in the task button if the width is really small (wnck_task_create_widgets): connect to the size-allocate signal of the buttons svn path=/trunk/; revision=1379
Diffstat (limited to 'libwnck')
-rw-r--r--libwnck/tasklist.c96
1 files changed, 53 insertions, 43 deletions
diff --git a/libwnck/tasklist.c b/libwnck/tasklist.c
index 2befd4e..1f75a82 100644
--- a/libwnck/tasklist.c
+++ b/libwnck/tasklist.c
@@ -1278,55 +1278,36 @@ wnck_tasklist_size_request (GtkWidget *widget,
WnckTask *class_group_task;
int lowest_range;
int grouping_limit;
-
+
tasklist = WNCK_TASKLIST (widget);
/* Calculate max needed height and width of the buttons */
- l = tasklist->priv->windows;
- while (l != NULL)
- {
- WnckTask *task = WNCK_TASK (l->data);
-
- gtk_widget_size_request (task->button, &child_req);
-
- max_height = MAX (child_req.height,
- max_height);
- max_width = MAX (child_req.width,
- max_width);
-
- l = l->next;
+#define GET_MAX_WIDTH_HEIGHT_FROM_BUTTONS(list) \
+ l = list; \
+ while (l != NULL) \
+ { \
+ WnckTask *task = WNCK_TASK (l->data); \
+ \
+ gtk_widget_size_request (task->button, &child_req); \
+ \
+ max_height = MAX (child_req.height, \
+ max_height); \
+ max_width = MAX (child_req.width, \
+ max_width); \
+ \
+ l = l->next; \
}
- l = tasklist->priv->class_groups;
- while (l != NULL)
- {
- WnckTask *task = WNCK_TASK (l->data);
-
- gtk_widget_size_request (task->button, &child_req);
-
- max_height = MAX (child_req.height,
- max_height);
- max_width = MAX (child_req.width,
- max_width);
-
- l = l->next;
- }
-
- l = tasklist->priv->startup_sequences;
- while (l != NULL)
- {
- WnckTask *task = WNCK_TASK (l->data);
-
- gtk_widget_size_request (task->button, &child_req);
-
- max_height = MAX (child_req.height,
- max_height);
- max_width = MAX (child_req.width,
- max_width);
-
- l = l->next;
- }
+ GET_MAX_WIDTH_HEIGHT_FROM_BUTTONS (tasklist->priv->windows)
+ GET_MAX_WIDTH_HEIGHT_FROM_BUTTONS (tasklist->priv->class_groups)
+ GET_MAX_WIDTH_HEIGHT_FROM_BUTTONS (tasklist->priv->startup_sequences)
+ /* Note that the fact that we nearly don't care about the width/height
+ * requested by the buttons makes it possible to hide/show the label/image
+ * in wnck_task_size_allocated(). If we really cared about those, this
+ * wouldn't work since our call to gtk_widget_size_request() does not take
+ * into account the hidden widgets.
+ */
tasklist->priv->max_button_width = wnck_tasklist_get_button_size (widget);
tasklist->priv->max_button_height = max_height;
@@ -1458,6 +1439,31 @@ wnck_tasklist_get_size_hint_list (WnckTasklist *tasklist,
}
static void
+wnck_task_size_allocated (GtkWidget *widget,
+ GtkAllocation *allocation,
+ gpointer data)
+{
+ WnckTask *task = WNCK_TASK (data);
+ int min_image_width;
+
+ min_image_width = MINI_ICON_SIZE +
+ 2 * widget->style->xthickness +
+ 2 * TASKLIST_BUTTON_PADDING;
+
+ if ((allocation->width < min_image_width + 2 * TASKLIST_BUTTON_PADDING) &&
+ (allocation->width >= min_image_width)) {
+ gtk_widget_show (task->image);
+ gtk_widget_hide (task->label);
+ } else if (allocation->width < min_image_width) {
+ gtk_widget_hide (task->image);
+ gtk_widget_show (task->label);
+ } else {
+ gtk_widget_show (task->image);
+ gtk_widget_show (task->label);
+ }
+}
+
+static void
wnck_tasklist_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
@@ -3719,6 +3725,10 @@ wnck_task_create_widgets (WnckTask *task, GtkReliefStyle relief)
G_OBJECT (task),
0);
+ g_signal_connect_object (G_OBJECT (task->button), "size_allocate",
+ G_CALLBACK (wnck_task_size_allocated),
+ G_OBJECT (task),
+ 0);
g_signal_connect_object (G_OBJECT (task->button), "button_press_event",
G_CALLBACK (wnck_task_button_press_event),