In the tab task switcher popup, dim the window icon and put its name

2005-01-18  Vincent Noel  <vnoel@cox.net>

	* src/screen.c: (meta_screen_ensure_tab_popup),
	(meta_screen_ensure_workspace_popup):
	* src/tabpopup.c: (dimm_icon), (meta_ui_tab_popup_new),
	(free_entry):
	* src/tabpopup.h: In the tab task switcher popup, dim the window
	icon and put its name between brackets when the window is
	minimized. Fixes #136666.
This commit is contained in:
Vincent Noel 2005-01-18 16:48:53 +00:00 committed by Vincent Noel
parent 48a6dd603a
commit 47221dcce2
4 changed files with 90 additions and 13 deletions

View File

@ -1,3 +1,13 @@
2005-01-18 Vincent Noel <vnoel@cox.net>
* src/screen.c: (meta_screen_ensure_tab_popup),
(meta_screen_ensure_workspace_popup):
* src/tabpopup.c: (dimm_icon), (meta_ui_tab_popup_new),
(free_entry):
* src/tabpopup.h: In the tab task switcher popup, dim the window
icon and put its name between brackets when the window is
minimized. Fixes #136666.
2005-01-11 Elijah Newren <newren@gmail.com> 2005-01-11 Elijah Newren <newren@gmail.com>
Correct highlighting of windows in workspace switcher popup. Correct highlighting of windows in workspace switcher popup.

View File

@ -1163,6 +1163,7 @@ meta_screen_ensure_tab_popup (MetaScreen *screen,
entries[i].title = window->title; entries[i].title = window->title;
entries[i].icon = window->icon; entries[i].icon = window->icon;
entries[i].blank = FALSE; entries[i].blank = FALSE;
entries[i].minimized = window->minimized;
if (!window->minimized || !meta_window_get_icon_geometry (window, &r)) if (!window->minimized || !meta_window_get_icon_geometry (window, &r))
meta_window_get_outer_rect (window, &r); meta_window_get_outer_rect (window, &r);
@ -1255,6 +1256,7 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen)
entries[i].title = meta_workspace_get_name (workspace); entries[i].title = meta_workspace_get_name (workspace);
entries[i].icon = NULL; entries[i].icon = NULL;
entries[i].blank = FALSE; entries[i].blank = FALSE;
entries[i].minimized = FALSE;
g_assert (entries[i].title != NULL); g_assert (entries[i].title != NULL);
} }
@ -1264,6 +1266,7 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen)
entries[i].title = NULL; entries[i].title = NULL;
entries[i].icon = NULL; entries[i].icon = NULL;
entries[i].blank = TRUE; entries[i].blank = TRUE;
entries[i].minimized = FALSE;
} }
++i; ++i;

View File

@ -40,7 +40,7 @@ struct _TabEntry
{ {
MetaTabEntryKey key; MetaTabEntryKey key;
char *title; char *title;
GdkPixbuf *icon; GdkPixbuf *icon, *dimmed_icon;
GtkWidget *widget; GtkWidget *widget;
GdkRectangle rect; GdkRectangle rect;
GdkRectangle inner_rect; GdkRectangle inner_rect;
@ -115,6 +115,44 @@ utf8_strndup (const char *src,
return g_strndup (src, s - src); return g_strndup (src, s - src);
} }
static GdkPixbuf*
dimm_icon (GdkPixbuf *pixbuf)
{
int x, y, pixel_stride, row_stride;
guchar *row, *pixels;
int w, h;
GdkPixbuf *dimmed_pixbuf;
if (gdk_pixbuf_get_has_alpha (dimmed_pixbuf))
{
dimmed_pixbuf = gdk_pixbuf_copy (pixbuf);
}
else
{
dimmed_pixbuf = gdk_pixbuf_add_alpha (pixbuf, FALSE, 0, 0, 0);
}
w = gdk_pixbuf_get_width (dimmed_pixbuf);
h = gdk_pixbuf_get_height (dimmed_pixbuf);
pixel_stride = 4;
row = gdk_pixbuf_get_pixels (dimmed_pixbuf);
row_stride = gdk_pixbuf_get_rowstride (dimmed_pixbuf);
for (y = 0; y < h; y++)
{
pixels = row;
for (x = 0; x < w; x++)
{
pixels[3] /= 2;
pixels += pixel_stride;
}
row += row_stride;
}
return dimmed_pixbuf;
}
MetaTabPopup* MetaTabPopup*
meta_ui_tab_popup_new (const MetaTabEntry *entries, meta_ui_tab_popup_new (const MetaTabEntry *entries,
int screen_number, int screen_number,
@ -172,7 +210,7 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
* avg char width of our font would be a better number. * avg char width of our font would be a better number.
*/ */
max_chars_per_title = gdk_screen_get_width (screen) / 15; max_chars_per_title = gdk_screen_get_width (screen) / 15;
tab_entries = NULL; tab_entries = NULL;
for (i = 0; i < entry_count; ++i) for (i = 0; i < entry_count; ++i)
{ {
@ -180,15 +218,31 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
te = g_new (TabEntry, 1); te = g_new (TabEntry, 1);
te->key = entries[i].key; te->key = entries[i].key;
te->title = te->title = NULL;
entries[i].title if (entries[i].title)
? utf8_strndup (entries[i].title, max_chars_per_title) {
: NULL; if (entries[i].minimized)
{
gchar *tmp;
tmp = g_strdup_printf ("[%s]", entries[i].title);
te->title = utf8_strndup (tmp, max_chars_per_title);
g_free (tmp);
}
else
{
te->title = utf8_strndup (entries[i].title, max_chars_per_title);
}
}
te->widget = NULL; te->widget = NULL;
te->icon = entries[i].icon; te->icon = entries[i].icon;
te->blank = entries[i].blank; te->blank = entries[i].blank;
te->dimmed_icon = NULL;
if (te->icon) if (te->icon)
g_object_ref (G_OBJECT (te->icon)); {
g_object_ref (G_OBJECT (te->icon));
if (entries[i].minimized)
te->dimmed_icon = dimm_icon (entries[i].icon);
}
if (outline) if (outline)
{ {
@ -225,12 +279,12 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
vbox); vbox);
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (align), gtk_container_add (GTK_CONTAINER (align),
table); table);
popup->label = gtk_label_new (""); popup->label = gtk_label_new ("");
obj = gtk_widget_get_accessible (popup->label); obj = gtk_widget_get_accessible (popup->label);
atk_object_set_role (obj, ATK_ROLE_STATUSBAR); atk_object_set_role (obj, ATK_ROLE_STATUSBAR);
@ -243,7 +297,7 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
top = 0; top = 0;
bottom = 1; bottom = 1;
tmp = popup->entries; tmp = popup->entries;
while (tmp && top < height) while (tmp && top < height)
{ {
left = 0; left = 0;
@ -253,7 +307,7 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
{ {
GtkWidget *image; GtkWidget *image;
GtkRequisition req; GtkRequisition req;
TabEntry *te; TabEntry *te;
te = tmp->data; te = tmp->data;
@ -265,7 +319,14 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
} }
else if (outline) else if (outline)
{ {
image = selectable_image_new (te->icon); if (te->dimmed_icon)
{
image = selectable_image_new (te->dimmed_icon);
}
else
{
image = selectable_image_new (te->icon);
}
gtk_misc_set_padding (GTK_MISC (image), gtk_misc_set_padding (GTK_MISC (image),
INSIDE_SELECT_RECT + OUTSIDE_SELECT_RECT + 1, INSIDE_SELECT_RECT + OUTSIDE_SELECT_RECT + 1,
@ -276,7 +337,7 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
{ {
image = selectable_workspace_new ((MetaWorkspace *) te->key); image = selectable_workspace_new ((MetaWorkspace *) te->key);
} }
te->widget = image; te->widget = image;
gtk_table_attach (GTK_TABLE (table), gtk_table_attach (GTK_TABLE (table),
@ -323,6 +384,8 @@ free_entry (gpointer data, gpointer user_data)
g_free (te->title); g_free (te->title);
if (te->icon) if (te->icon)
g_object_unref (G_OBJECT (te->icon)); g_object_unref (G_OBJECT (te->icon));
if (te->dimmed_icon)
g_object_unref (G_OBJECT (te->dimmed_icon));
g_free (te); g_free (te);
} }

View File

@ -40,6 +40,7 @@ struct _MetaTabEntry
int x, y, width, height; int x, y, width, height;
int inner_x, inner_y, inner_width, inner_height; int inner_x, inner_y, inner_width, inner_height;
guint blank : 1; guint blank : 1;
guint minimized : 1;
}; };
MetaTabPopup* meta_ui_tab_popup_new (const MetaTabEntry *entries, MetaTabPopup* meta_ui_tab_popup_new (const MetaTabEntry *entries,