[rhythmbox] entry-view: Take into account the header button for columns width



commit 1ac3ec3ebb4ddb6dd195248269fdaea3ce0966f8
Author: Jonh Wendell <jonh wendell intel com>
Date:   Tue Nov 19 15:11:53 2013 -0200

    entry-view: Take into account the header button for columns width
    
    Currently the width of a column is calculated by measuring
    its contents. However in some cases, like the 'Track' column,
    their content is smaller than the header.
    
    So, let's take into account the header button width as well.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712699

 lib/rb-util.c           |    8 ++++++++
 widgets/rb-entry-view.c |   28 ++++++++++++++--------------
 2 files changed, 22 insertions(+), 14 deletions(-)
---
diff --git a/lib/rb-util.c b/lib/rb-util.c
index 7a65694..40cd070 100644
--- a/lib/rb-util.c
+++ b/lib/rb-util.c
@@ -1222,6 +1222,14 @@ rb_set_tree_view_column_fixed_width (GtkWidget  *treeview,
        int max_width = 0;
        int i = 0;
 
+       /* Take into account the header button width */
+       GtkWidget *widget = gtk_tree_view_column_get_button (column);
+       if (widget != NULL) {
+               GtkRequisition natural_size;
+               gtk_widget_get_preferred_size (widget, NULL, &natural_size);
+               max_width = natural_size.width;
+       }
+
        while (strings[i] != NULL) {
                GtkRequisition natural_size;
                g_object_set (renderer, "text", strings[i], NULL);
diff --git a/widgets/rb-entry-view.c b/widgets/rb-entry-view.c
index aa8e82e..7c00a63 100644
--- a/widgets/rb-entry-view.c
+++ b/widgets/rb-entry-view.c
@@ -1650,20 +1650,6 @@ rb_entry_view_append_column (RBEntryView *view,
                g_free (cell_data);
        }
 
-       /*
-        * Columns must either be expanding (ellipsized) or have a
-        * fixed minimum width specified.  Otherwise, gtk+ gives them a
-        * width of 0.
-        */
-       if (ellipsize) {
-               g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
-               gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
-       } else if (column_width != -1) {
-               gtk_tree_view_column_set_fixed_width (column, column_width);
-       } else {
-               rb_entry_view_set_fixed_column_width (view, column, renderer, strings);
-       }
-
        if (resizable)
                gtk_tree_view_column_set_resizable (column, TRUE);
 
@@ -1678,6 +1664,20 @@ rb_entry_view_append_column (RBEntryView *view,
        g_hash_table_insert (view->priv->propid_column_map, GINT_TO_POINTER (propid), column);
 
        rb_entry_view_append_column_custom (view, column, title, key, sort_func, GINT_TO_POINTER 
(sort_propid), NULL);
+
+       /*
+        * Columns must either be expanding (ellipsized) or have a
+        * fixed minimum width specified.  Otherwise, gtk+ gives them a
+        * width of 0.
+        */
+       if (ellipsize) {
+               g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+               gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
+       } else if (column_width != -1) {
+               gtk_tree_view_column_set_fixed_width (column, column_width);
+       } else {
+               rb_entry_view_set_fixed_column_width (view, column, renderer, strings);
+       }
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]