diff --git a/toolkit/themes/gnomestripe/global/listbox.css b/toolkit/themes/gnomestripe/global/listbox.css index 1732aab2b2e..fc212fa1ec6 100644 --- a/toolkit/themes/gnomestripe/global/listbox.css +++ b/toolkit/themes/gnomestripe/global/listbox.css @@ -127,15 +127,7 @@ listheader[sortable="true"]:hover:active { /* ..... sort direction icon ..... */ .listheader-sortdirection { - list-style-image: none; -} - -.listheader-sortdirection[sortDirection="ascending"] { - list-style-image: url("chrome://global/skin/tree/sort-asc.gif"); -} - -.listheader-sortdirection[sortDirection="descending"] { - list-style-image: url("chrome://global/skin/tree/sort-dsc.gif"); + -moz-appearance: treeheadersortarrow; } /* ::::: listcell ::::: */ diff --git a/toolkit/themes/gnomestripe/global/tree.css b/toolkit/themes/gnomestripe/global/tree.css index b4af39a34f2..d175d66fcdd 100644 --- a/toolkit/themes/gnomestripe/global/tree.css +++ b/toolkit/themes/gnomestripe/global/tree.css @@ -311,15 +311,7 @@ treechildren::-moz-tree-column(insertafter) { /* ::::: sort direction indicator ::::: */ .treecol-sortdirection { - list-style-image: none; -} - -treecol:not([hideheader="true"]) > .treecol-sortdirection[sortDirection="ascending"] { - list-style-image: url("chrome://global/skin/tree/sort-asc.gif"); -} - -treecol:not([hideheader="true"]) > .treecol-sortdirection[sortDirection="descending"] { - list-style-image: url("chrome://global/skin/tree/sort-dsc.gif"); + -moz-appearance: treeheadersortarrow; } /* ::::: column picker ::::: */ diff --git a/widget/src/gtk2/gtk2drawing.c b/widget/src/gtk2/gtk2drawing.c index 19824d014d3..654773dd840 100644 --- a/widget/src/gtk2/gtk2drawing.c +++ b/widget/src/gtk2/gtk2drawing.c @@ -80,6 +80,7 @@ static GtkWidget* gMenuItemWidget; static GtkWidget* gCheckMenuItemWidget; static GtkWidget* gTreeViewWidget; static GtkWidget* gTreeHeaderCellWidget; +static GtkWidget* gTreeHeaderSortArrowWidget; static GtkShadowType gMenuBarShadowType; static GtkShadowType gToolbarShadowType; @@ -379,6 +380,8 @@ ensure_tree_header_cell_widget() gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget), treeViewColumn); gTreeHeaderCellWidget = treeViewColumn->button; + gtk_tree_view_column_set_sort_indicator(treeViewColumn, TRUE); + gTreeHeaderSortArrowWidget = treeViewColumn->arrow; } return MOZ_GTK_SUCCESS; } @@ -1028,7 +1031,7 @@ moz_gtk_treeview_paint(GdkDrawable* drawable, GdkRectangle* rect, /* only handle disabled and normal states, otherwise the whole background * area will be painted differently with other states */ state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL; - + style = gTreeViewWidget->style; TSOffsetStyleGCs(style, rect->x, rect->y); @@ -1049,6 +1052,36 @@ moz_gtk_tree_header_cell_paint(GdkDrawable* drawable, GdkRectangle* rect, return MOZ_GTK_SUCCESS; } +static gint +moz_gtk_tree_header_sort_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect, + GdkRectangle* cliprect, GtkWidgetState* state, + GtkArrowType flags) +{ + GdkRectangle arrow_rect; + GtkStateType state_type = ConvertGtkState(state); + GtkShadowType shadow_type = GTK_SHADOW_IN; + GtkArrowType arrow_type = flags; + GtkStyle* style; + + ensure_tree_header_cell_widget(); + + /* hard code these values */ + arrow_rect.width = 11; + arrow_rect.height = 11; + arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2; + arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2; + + style = gTreeHeaderSortArrowWidget->style; + TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y); + + gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect, + gTreeHeaderSortArrowWidget, "arrow", arrow_type, TRUE, + arrow_rect.x, arrow_rect.y, + arrow_rect.width, arrow_rect.height); + + return MOZ_GTK_SUCCESS; +} + static gint moz_gtk_option_menu_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state) @@ -1149,7 +1182,7 @@ moz_gtk_dropdown_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect, real_arrow_rect.y = floor (arrow_rect.y + ((arrow_rect.height - real_arrow_rect.height) / 2) + 0.5); gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect, - gHorizScrollbarWidget, "arrow", GTK_ARROW_DOWN, TRUE, + gDropdownButtonWidget, "arrow", GTK_ARROW_DOWN, TRUE, real_arrow_rect.x, real_arrow_rect.y, real_arrow_rect.width, real_arrow_rect.height); @@ -1650,6 +1683,10 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, *bottom += gTreeHeaderCellWidget->style->ythickness; return MOZ_GTK_SUCCESS; } + case MOZ_GTK_TREE_HEADER_SORTARROW: + ensure_tree_header_cell_widget(); + w = gTreeHeaderSortArrowWidget; + break; case MOZ_GTK_DROPDOWN_ARROW: ensure_arrow_widget(); w = gDropdownButtonWidget; @@ -1912,6 +1949,9 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable, case MOZ_GTK_TREE_HEADER_CELL: return moz_gtk_tree_header_cell_paint(drawable, rect, cliprect, state); break; + case MOZ_GTK_TREE_HEADER_SORTARROW: + return moz_gtk_tree_header_sort_arrow_paint(drawable, rect, cliprect, state, (GtkArrowType) flags); + break; case MOZ_GTK_ENTRY: return moz_gtk_entry_paint(drawable, rect, cliprect, state); break; @@ -2021,6 +2061,7 @@ moz_gtk_shutdown() gCheckMenuItemWidget = NULL; gTreeViewWidget = NULL; gTreeHeaderCellWidget = NULL; + gTreeHeaderSortArrowWidget = NULL; is_initialized = FALSE; diff --git a/widget/src/gtk2/gtkdrawing.h b/widget/src/gtk2/gtkdrawing.h index 1febd7a075a..25365b109c4 100644 --- a/widget/src/gtk2/gtkdrawing.h +++ b/widget/src/gtk2/gtkdrawing.h @@ -157,6 +157,8 @@ typedef enum { MOZ_GTK_TREEVIEW, /* Paints treeheader cells */ MOZ_GTK_TREE_HEADER_CELL, + /* Paints sort arrows in treeheader cells */ + MOZ_GTK_TREE_HEADER_SORTARROW, /* Paints the background of the menu bar. */ MOZ_GTK_MENUBAR, /* Paints the background of menus, context menus. */ diff --git a/widget/src/gtk2/nsNativeThemeGTK.cpp b/widget/src/gtk2/nsNativeThemeGTK.cpp index 44a9a2c12cb..830f582f830 100644 --- a/widget/src/gtk2/nsNativeThemeGTK.cpp +++ b/widget/src/gtk2/nsNativeThemeGTK.cpp @@ -61,6 +61,7 @@ #include #include +#include #include "gfxContext.h" #include "gfxPlatformGtk.h" @@ -377,6 +378,31 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame, case NS_THEME_TREEVIEW_HEADER_CELL: aGtkWidgetType = MOZ_GTK_TREE_HEADER_CELL; break; + case NS_THEME_TREEVIEW_HEADER_SORTARROW: + if (aWidgetFlags) { + switch (GetTreeSortDirection(aFrame)) { + case eTreeSortDirection_Ascending: + *aWidgetFlags = GTK_ARROW_DOWN; + break; + case eTreeSortDirection_Descending: + *aWidgetFlags = GTK_ARROW_UP; + break; + case eTreeSortDirection_Natural: + default: + /* GTK_ARROW_NONE is implemented since GTK 2.10 + * This prevents the treecolums from getting smaller + * and wider when switching sort direction off and on + * */ +#if GTK_CHECK_VERSION(2,10,0) + *aWidgetFlags = GTK_ARROW_NONE; +#else + return PR_FALSE; // Don't draw when we shouldn't +#endif // GTK_CHECK_VERSION(2,10,0) + break; + } + } + aGtkWidgetType = MOZ_GTK_TREE_HEADER_SORTARROW; + break; case NS_THEME_DROPDOWN: aGtkWidgetType = MOZ_GTK_DROPDOWN; break; @@ -851,6 +877,7 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsIRenderingContext* aContext, aResult->height = border.top + border.bottom; } break; + case NS_THEME_TREEVIEW_HEADER_SORTARROW: case NS_THEME_SPINNER_UP_BUTTON: case NS_THEME_SPINNER_DOWN_BUTTON: // hard code these sizes @@ -862,7 +889,6 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsIRenderingContext* aContext, aResult->width = aResult->height = 15; break; } - return NS_OK; } @@ -883,6 +909,7 @@ nsNativeThemeGTK::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, aWidgetType == NS_THEME_MENUBAR || aWidgetType == NS_THEME_MENUPOPUP || aWidgetType == NS_THEME_TOOLTIP || + aWidgetType == NS_THEME_TREEVIEW_HEADER_SORTARROW || aWidgetType == NS_THEME_WINDOW || aWidgetType == NS_THEME_DIALOG) { *aShouldRepaint = PR_FALSE; @@ -959,7 +986,7 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext, // case NS_THEME_TREEVIEW_LINE: // case NS_THEME_TREEVIEW_HEADER: case NS_THEME_TREEVIEW_HEADER_CELL: - // case NS_THEME_TREEVIEW_HEADER_SORTARROW: + case NS_THEME_TREEVIEW_HEADER_SORTARROW: // case NS_THEME_TREEVIEW_TWISTY_OPEN: case NS_THEME_PROGRESSBAR: case NS_THEME_PROGRESSBAR_CHUNK: