forked from AuroraMiddleware/gtk
columnview: Split gtk_column_view_allocate_columns
Split off a helper function that just distributes the widths, without actually allocating the columns. This will be used in measuring in the future.
This commit is contained in:
parent
11a18bd61a
commit
f6da324670
@ -236,19 +236,19 @@ gtk_column_view_measure (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
void
|
||||||
gtk_column_view_allocate_columns (GtkColumnView *self,
|
gtk_column_view_distribute_width (GtkColumnView *self,
|
||||||
int width)
|
int width,
|
||||||
|
GtkRequestedSize *sizes)
|
||||||
{
|
{
|
||||||
GtkScrollablePolicy scroll_policy;
|
GtkScrollablePolicy scroll_policy;
|
||||||
int col_min, col_nat, extra, col_size, x;
|
int col_min, col_nat, extra, col_size;
|
||||||
int n, n_expand, expand_size, n_extra;
|
int n, n_expand, expand_size, n_extra;
|
||||||
guint i;
|
guint i;
|
||||||
GtkRequestedSize *sizes;
|
|
||||||
|
|
||||||
n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
|
n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
|
||||||
n_expand = 0;
|
n_expand = 0;
|
||||||
sizes = g_newa (GtkRequestedSize, n);
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
GtkColumnViewColumn *column;
|
GtkColumnViewColumn *column;
|
||||||
@ -282,7 +282,6 @@ gtk_column_view_allocate_columns (GtkColumnView *self,
|
|||||||
else
|
else
|
||||||
expand_size = n_extra = 0;
|
expand_size = n_extra = 0;
|
||||||
|
|
||||||
x = 0;
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
GtkColumnViewColumn *column;
|
GtkColumnViewColumn *column;
|
||||||
@ -300,6 +299,37 @@ gtk_column_view_allocate_columns (GtkColumnView *self,
|
|||||||
n_extra--;
|
n_extra--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sizes[i].minimum_size = col_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
gtk_column_view_allocate_columns (GtkColumnView *self,
|
||||||
|
int width)
|
||||||
|
{
|
||||||
|
guint i, n;
|
||||||
|
int x;
|
||||||
|
GtkRequestedSize *sizes;
|
||||||
|
|
||||||
|
n = g_list_model_get_n_items (G_LIST_MODEL (self->columns));
|
||||||
|
|
||||||
|
sizes = g_newa (GtkRequestedSize, n);
|
||||||
|
|
||||||
|
gtk_column_view_distribute_width (self, width, sizes);
|
||||||
|
|
||||||
|
x = 0;
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
GtkColumnViewColumn *column;
|
||||||
|
int col_size;
|
||||||
|
|
||||||
|
column = g_list_model_get_item (G_LIST_MODEL (self->columns), i);
|
||||||
|
if (gtk_column_view_column_get_visible (column))
|
||||||
|
{
|
||||||
|
col_size = sizes[i].minimum_size;
|
||||||
|
|
||||||
gtk_column_view_column_allocate (column, x, col_size);
|
gtk_column_view_column_allocate (column, x, col_size);
|
||||||
if (self->in_column_reorder && i == self->drag_pos)
|
if (self->in_column_reorder && i == self->drag_pos)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "gtk/gtkcolumnview.h"
|
#include "gtk/gtkcolumnview.h"
|
||||||
#include "gtk/gtklistview.h"
|
#include "gtk/gtklistview.h"
|
||||||
|
#include "gtk/gtksizerequest.h"
|
||||||
|
|
||||||
#include "gtk/gtkcolumnviewsorterprivate.h"
|
#include "gtk/gtkcolumnviewsorterprivate.h"
|
||||||
#include "gtk/gtklistitemwidgetprivate.h"
|
#include "gtk/gtklistitemwidgetprivate.h"
|
||||||
@ -33,4 +34,8 @@ void gtk_column_view_measure_across (GtkColumnView
|
|||||||
int *minimum,
|
int *minimum,
|
||||||
int *natural);
|
int *natural);
|
||||||
|
|
||||||
|
void gtk_column_view_distribute_width (GtkColumnView *self,
|
||||||
|
int width,
|
||||||
|
GtkRequestedSize *sizes);
|
||||||
|
|
||||||
#endif /* __GTK_COLUMN_VIEW_PRIVATE_H__ */
|
#endif /* __GTK_COLUMN_VIEW_PRIVATE_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user