Bug 423236 - "Tree view headers should correctly tell the GTK engine if its sorted or not" [p=ventnor.bugzilla@yahoo.com.au (Michael Ventnor) r+sr=roc a1.9=beltzner]
authorreed@reedloden.com
Tue, 18 Mar 2008 12:35:23 -0700
changeset 13247 1d13811d430444fade02eec6550c4612df3673fd
parent 13246 f3902f3ff3c80953585ba21f5cbc45997e0fca29
child 13248 4f7b412c62150a21b57b93a35a72fb779b43ab6c
push idunknown
push userunknown
push dateunknown
bugs423236
milestone1.9b5pre
Bug 423236 - "Tree view headers should correctly tell the GTK engine if its sorted or not" [p=ventnor.bugzilla@yahoo.com.au (Michael Ventnor) r+sr=roc a1.9=beltzner]
widget/src/gtk2/gtk2drawing.c
widget/src/gtk2/nsNativeThemeGTK.cpp
--- a/widget/src/gtk2/gtk2drawing.c
+++ b/widget/src/gtk2/gtk2drawing.c
@@ -84,16 +84,17 @@ static GtkWidget* gTabWidget;
 static GtkWidget* gTooltipWidget;
 static GtkWidget* gMenuBarWidget;
 static GtkWidget* gMenuBarItemWidget;
 static GtkWidget* gMenuPopupWidget;
 static GtkWidget* gMenuItemWidget;
 static GtkWidget* gImageMenuItemWidget;
 static GtkWidget* gCheckMenuItemWidget;
 static GtkWidget* gTreeViewWidget;
+static GtkWidget* gMiddleTreeViewColumn;
 static GtkWidget* gTreeHeaderCellWidget;
 static GtkWidget* gTreeHeaderSortArrowWidget;
 static GtkWidget* gExpanderWidget;
 static GtkWidget* gToolbarSeparatorWidget;
 static GtkWidget* gMenuSeparatorWidget;
 static GtkWidget* gHPanedWidget;
 static GtkWidget* gVPanedWidget;
 static GtkWidget* gScrolledWindowWidget;
@@ -658,38 +659,37 @@ ensure_tree_header_cell_widget()
          * thus ensuring it is neither the first or last button
          * in the header.
          * GTK doesn't give us a way to do this explicitly,
          * so we must paint with a button that is between two
          * others.
          */
 
         GtkTreeViewColumn* firstTreeViewColumn;
-        GtkTreeViewColumn* middleTreeViewColumn;
         GtkTreeViewColumn* lastTreeViewColumn;
 
         ensure_tree_view_widget();
 
         /* Create and append our three columns */
         firstTreeViewColumn = gtk_tree_view_column_new();
         gtk_tree_view_column_set_title(firstTreeViewColumn, "M");
         gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget), firstTreeViewColumn);
 
-        middleTreeViewColumn = gtk_tree_view_column_new();
-        gtk_tree_view_column_set_title(middleTreeViewColumn, "M");
-        gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget), middleTreeViewColumn);
+        gMiddleTreeViewColumn = gtk_tree_view_column_new();
+        gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(gMiddleTreeViewColumn), "M");
+        gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget),
+                                    GTK_TREE_VIEW_COLUMN(gMiddleTreeViewColumn));
 
         lastTreeViewColumn = gtk_tree_view_column_new();
         gtk_tree_view_column_set_title(lastTreeViewColumn, "M");
         gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget), lastTreeViewColumn);
 
         /* Use the middle column's header for our button */
-        gTreeHeaderCellWidget = middleTreeViewColumn->button;
-        gtk_tree_view_column_set_sort_indicator(middleTreeViewColumn, TRUE);
-        gTreeHeaderSortArrowWidget = middleTreeViewColumn->arrow;
+        gTreeHeaderCellWidget = GTK_TREE_VIEW_COLUMN(gMiddleTreeViewColumn)->button;
+        gTreeHeaderSortArrowWidget = GTK_TREE_VIEW_COLUMN(gMiddleTreeViewColumn)->arrow;
     }
     return MOZ_GTK_SUCCESS;
 }
 
 static gint
 ensure_expander_widget()
 {
     if (!gExpanderWidget) {
@@ -1553,18 +1553,21 @@ moz_gtk_treeview_paint(GdkDrawable* draw
                      rect->x, rect->y, rect->width, rect->height); 
 
     return MOZ_GTK_SUCCESS;
 }
 
 static gint
 moz_gtk_tree_header_cell_paint(GdkDrawable* drawable, GdkRectangle* rect,
                                GdkRectangle* cliprect, GtkWidgetState* state,
-                               GtkTextDirection direction)
+                               gboolean isSorted, GtkTextDirection direction)
 {
+    gtk_tree_view_column_set_sort_indicator(GTK_TREE_VIEW_COLUMN(gMiddleTreeViewColumn),
+                                            isSorted);
+
     moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
                          gTreeHeaderCellWidget, direction);
     return MOZ_GTK_SUCCESS;
 }
 
 static gint
 moz_gtk_tree_header_sort_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
                                      GdkRectangle* cliprect,
@@ -2995,17 +2998,17 @@ moz_gtk_widget_paint(GtkThemeWidgetType 
                                      direction);
         break;
     case MOZ_GTK_TREEVIEW:
         return moz_gtk_treeview_paint(drawable, rect, cliprect, state,
                                       direction);
         break;
     case MOZ_GTK_TREE_HEADER_CELL:
         return moz_gtk_tree_header_cell_paint(drawable, rect, cliprect, state,
-                                              direction);
+                                              flags, direction);
         break;
     case MOZ_GTK_TREE_HEADER_SORTARROW:
         return moz_gtk_tree_header_sort_arrow_paint(drawable, rect, cliprect,
                                                     state,
                                                     (GtkArrowType) flags,
                                                     direction);
         break;
     case MOZ_GTK_TREEVIEW_EXPANDER:
@@ -3171,16 +3174,17 @@ moz_gtk_shutdown()
     gTooltipWidget = NULL;
     gMenuBarWidget = NULL;
     gMenuBarItemWidget = NULL;
     gMenuPopupWidget = NULL;
     gMenuItemWidget = NULL;
     gImageMenuItemWidget = NULL;
     gCheckMenuItemWidget = NULL;
     gTreeViewWidget = NULL;
+    gMiddleTreeViewColumn = NULL;
     gTreeHeaderCellWidget = NULL;
     gTreeHeaderSortArrowWidget = NULL;
     gExpanderWidget = NULL;
     gToolbarSeparatorWidget = NULL;
     gMenuSeparatorWidget = NULL;
     gHPanedWidget = NULL;
     gVPanedWidget = NULL;
     gScrolledWindowWidget = NULL;
--- a/widget/src/gtk2/nsNativeThemeGTK.cpp
+++ b/widget/src/gtk2/nsNativeThemeGTK.cpp
@@ -439,16 +439,23 @@ nsNativeThemeGTK::GetGtkWidgetAndState(P
   case NS_THEME_TEXTFIELD_MULTILINE:
     aGtkWidgetType = MOZ_GTK_ENTRY;
     break;
   case NS_THEME_LISTBOX:
   case NS_THEME_TREEVIEW:
     aGtkWidgetType = MOZ_GTK_TREEVIEW;
     break;
   case NS_THEME_TREEVIEW_HEADER_CELL:
+    if (aWidgetFlags) {
+      // In this case, the flag denotes whether the header is the sorted one or not
+      if (GetTreeSortDirection(aFrame) == eTreeSortDirection_Natural)
+        *aWidgetFlags = PR_FALSE;
+      else
+        *aWidgetFlags = PR_TRUE;
+    }
     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;