[gtk/matthiasc/for-master: 7/7] columnview: Make right-aligned content work




commit 81ee273e98c85140ac28c4916dc1311d8792bb17
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 19 08:42:33 2020 -0400

    columnview: Make right-aligned content work
    
    Make right-aligned content work in resized columns.
    There is currently no way to make a title right-aligned,
    but we can still make it work correctly. This is a follow
    up to 7eb0ae39c5549bfaa4e.
    
    Fixes: #3276

 gtk/gtkcolumnviewcell.c  | 8 ++++----
 gtk/gtkcolumnviewtitle.c | 7 ++++---
 2 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkcolumnviewcell.c b/gtk/gtkcolumnviewcell.c
index f7db70e04f..1ada1b4292 100644
--- a/gtk/gtkcolumnviewcell.c
+++ b/gtk/gtkcolumnviewcell.c
@@ -124,15 +124,15 @@ gtk_column_view_cell_size_allocate (GtkWidget *widget,
                                     int        height,
                                     int        baseline)
 {
-  GtkColumnViewCell *self = GTK_COLUMN_VIEW_CELL (widget);
   GtkWidget *child = gtk_widget_get_first_child (widget);
 
   if (child)
     {
-      if (gtk_column_view_column_get_fixed_width (self->column) > -1)
-        gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, NULL, &width, NULL, NULL);
+      int min;
+
+      gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, &min, NULL, NULL, NULL);
 
-      gtk_widget_allocate (child, width, height, baseline, NULL);
+      gtk_widget_allocate (child, MAX (min, width), height, baseline, NULL);
     }
 }
 
diff --git a/gtk/gtkcolumnviewtitle.c b/gtk/gtkcolumnviewtitle.c
index f2cb4fca83..c76c8a9a8b 100644
--- a/gtk/gtkcolumnviewtitle.c
+++ b/gtk/gtkcolumnviewtitle.c
@@ -136,10 +136,11 @@ gtk_column_view_title_size_allocate (GtkWidget *widget,
 
   if (child)
     {
-      if (gtk_column_view_column_get_fixed_width (self->column) > -1)
-        gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, NULL, &width, NULL, NULL);
+      int min;
 
-      gtk_widget_allocate (child, width, height, baseline, NULL);
+      gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, &min, NULL, NULL, NULL);
+
+      gtk_widget_allocate (child, MAX (min, width), height, baseline, NULL);
     }
 
   if (self->popup_menu)


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