diff options
Diffstat (limited to 'libwnck/tasklist.c')
-rw-r--r-- | libwnck/tasklist.c | 67 |
1 files changed, 49 insertions, 18 deletions
diff --git a/libwnck/tasklist.c b/libwnck/tasklist.c index 8791b10..4166d76 100644 --- a/libwnck/tasklist.c +++ b/libwnck/tasklist.c @@ -32,6 +32,7 @@ #include "class-group.h" #include "window-action-menu.h" #include "wnck-image-menu-item-private.h" +#include "wnck-handle-private.h" #include "workspace.h" #include "xutils.h" #include "private.h" @@ -92,7 +93,6 @@ typedef struct _WnckTaskClass WnckTaskClass; #define DEFAULT_GROUPING_LIMIT 80 -#define MINI_ICON_SIZE _wnck_get_default_mini_icon_size () #define TASKLIST_BUTTON_PADDING 4 #define TASKLIST_TEXT_MAX_WIDTH 25 /* maximum width in characters */ @@ -108,6 +108,8 @@ struct _WnckButton { GtkToggleButton parent; + WnckHandle *handle; + GtkWidget *image; gboolean show_image; @@ -480,7 +482,7 @@ wnck_button_size_allocate (GtkWidget *widget, min_width = get_css_width (widget); min_width += get_css_width (gtk_bin_get_child (GTK_BIN (widget))); - min_image_width = MINI_ICON_SIZE + + min_image_width = _wnck_handle_get_default_mini_icon_size (self->handle) + min_width + 2 * TASKLIST_BUTTON_PADDING; @@ -611,6 +613,13 @@ wnck_button_new (void) } static void +wnck_button_set_handle (WnckButton *self, + WnckHandle *handle) +{ + self->handle = handle; +} + +static void wnck_button_set_image_from_pixbuf (WnckButton *self, GdkPixbuf *pixbuf) { @@ -1765,12 +1774,14 @@ get_n_buttons (WnckTasklist *self) } static void -get_minimum_button_size (int *minimum_width, - int *minimum_height) +get_minimum_button_size (WnckHandle *handle, + int *minimum_width, + int *minimum_height) { GtkWidget *button; button = wnck_button_new (); + wnck_button_set_handle (WNCK_BUTTON (button), handle); gtk_widget_show (button); if (minimum_width != NULL) @@ -1805,9 +1816,12 @@ get_preferred_size (WnckTasklist *self, if (orientation == GTK_ORIENTATION_HORIZONTAL) { + WnckHandle *handle; int min_button_width; - get_minimum_button_size (&min_button_width, NULL); + handle = wnck_screen_get_handle (self->priv->screen); + + get_minimum_button_size (handle, &min_button_width, NULL); if (self->priv->orientation == GTK_ORIENTATION_HORIZONTAL) { @@ -3610,9 +3624,12 @@ wnck_dimm_icon (GdkPixbuf *pixbuf) } static GdkPixbuf * -wnck_task_scale_icon (GdkPixbuf *orig, gboolean minimized) +wnck_task_scale_icon (WnckHandle *handle, + GdkPixbuf *orig, + gboolean minimized) { int w, h; + gsize mini_icon_size; GdkPixbuf *pixbuf; if (!orig) @@ -3621,7 +3638,9 @@ wnck_task_scale_icon (GdkPixbuf *orig, gboolean minimized) w = gdk_pixbuf_get_width (orig); h = gdk_pixbuf_get_height (orig); - if (h != (int) MINI_ICON_SIZE || + mini_icon_size = _wnck_handle_get_default_mini_icon_size (handle); + + if (h != (int) mini_icon_size || !gdk_pixbuf_get_has_alpha (orig)) { double scale; @@ -3629,10 +3648,10 @@ wnck_task_scale_icon (GdkPixbuf *orig, gboolean minimized) pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, - MINI_ICON_SIZE * w / (double) h, - MINI_ICON_SIZE); + mini_icon_size * w / (double) h, + mini_icon_size); - scale = MINI_ICON_SIZE / (double) gdk_pixbuf_get_height (orig); + scale = mini_icon_size / (double) gdk_pixbuf_get_height (orig); gdk_pixbuf_scale (orig, pixbuf, @@ -3664,23 +3683,27 @@ wnck_task_scale_icon (GdkPixbuf *orig, gboolean minimized) static GdkPixbuf * wnck_task_get_icon (WnckTask *task) { + WnckHandle *handle; WnckWindowState state; GdkPixbuf *pixbuf; + handle = wnck_screen_get_handle (task->tasklist->priv->screen); pixbuf = NULL; switch (task->type) { case WNCK_TASK_CLASS_GROUP: - pixbuf = wnck_task_scale_icon (wnck_class_group_get_mini_icon (task->class_group), - FALSE); + pixbuf = wnck_task_scale_icon (handle, + wnck_class_group_get_mini_icon (task->class_group), + FALSE); break; case WNCK_TASK_WINDOW: state = wnck_window_get_state (task->window); - pixbuf = wnck_task_scale_icon (wnck_window_get_mini_icon (task->window), - state & WNCK_WINDOW_STATE_MINIMIZED); + pixbuf = wnck_task_scale_icon (handle, + wnck_window_get_mini_icon (task->window), + state & WNCK_WINDOW_STATE_MINIMIZED); break; case WNCK_TASK_STARTUP_SEQUENCE: @@ -3692,16 +3715,19 @@ wnck_task_get_icon (WnckTask *task) icon = sn_startup_sequence_get_icon_name (task->startup_sequence); if (icon != NULL) { + gsize mini_icon_size; GdkPixbuf *loaded; + mini_icon_size = _wnck_handle_get_default_mini_icon_size (handle); + loaded = (* task->tasklist->priv->icon_loader) (icon, - MINI_ICON_SIZE, + mini_icon_size, 0, task->tasklist->priv->icon_loader_data); if (loaded != NULL) { - pixbuf = wnck_task_scale_icon (loaded, FALSE); + pixbuf = wnck_task_scale_icon (handle, loaded, FALSE); g_object_unref (G_OBJECT (loaded)); } } @@ -3709,8 +3735,11 @@ wnck_task_get_icon (WnckTask *task) if (pixbuf == NULL) { - _wnck_get_fallback_icons (NULL, 0, - &pixbuf, MINI_ICON_SIZE); + gsize mini_icon_size; + + mini_icon_size = _wnck_handle_get_default_mini_icon_size (handle); + + _wnck_get_fallback_icons (NULL, 0, &pixbuf, mini_icon_size); } #endif break; @@ -4251,6 +4280,8 @@ wnck_task_create_widgets (WnckTask *task, GtkReliefStyle relief) }; task->button = wnck_button_new (); + wnck_button_set_handle (WNCK_BUTTON (task->button), + wnck_screen_get_handle (task->tasklist->priv->screen)); gtk_button_set_relief (GTK_BUTTON (task->button), relief); |