[gtk+/treeview-refactor-staging] Created _gtk_tree_view_column_request_width().
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/treeview-refactor-staging] Created _gtk_tree_view_column_request_width().
- Date: Wed, 1 Dec 2010 03:38:36 +0000 (UTC)
commit b375fcab87629c22bf00eb3bebfdd5ce1264bb9e
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Wed Dec 1 12:41:42 2010 +0900
Created _gtk_tree_view_column_request_width().
Removed gtk_tree_view_get_real_requested_width_from_column() from
gtktreeview.c in favor of this function in the treeviewcolumn domain
(since this function goes and checks treeviewcolumn internals, settings
and derives the real requested width, seems logical this should be done
by the treeviewcolumn instead).
gtk/gtktreeprivate.h | 1 +
gtk/gtktreeview.c | 55 ++--------------------------------------------
gtk/gtktreeviewcolumn.c | 39 +++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+), 52 deletions(-)
---
diff --git a/gtk/gtktreeprivate.h b/gtk/gtktreeprivate.h
index b033ec3..942a2a3 100644
--- a/gtk/gtktreeprivate.h
+++ b/gtk/gtktreeprivate.h
@@ -106,6 +106,7 @@ void _gtk_tree_view_column_unrealize_button (GtkTreeViewColumn *column);
void _gtk_tree_view_column_set_tree_view (GtkTreeViewColumn *column,
GtkTreeView *tree_view);
+gint _gtk_tree_view_column_request_width (GtkTreeViewColumn *tree_column);
void _gtk_tree_view_column_allocate (GtkTreeViewColumn *tree_column,
int x_offset,
int width,
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index e63d471..136eda8 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -2414,16 +2414,11 @@ gtk_tree_view_update_size (GtkTreeView *tree_view)
/* keep this in sync with size_allocate below */
for (list = tree_view->priv->columns, i = 0; list; list = list->next, i++)
{
- gint max_width, min_width;
- gint real_requested_width = 0;
-
column = list->data;
if (!gtk_tree_view_column_get_visible (column))
continue;
- real_requested_width = gtk_tree_view_get_real_requested_width_from_column (tree_view, column);
-
- tree_view->priv->width += real_requested_width;
+ tree_view->priv->width += _gtk_tree_view_column_request_width (column);
}
if (tree_view->priv->tree == NULL)
@@ -2553,48 +2548,6 @@ invalidate_last_column (GtkTreeView *tree_view)
}
}
-static gint
-gtk_tree_view_get_real_requested_width_from_column (GtkTreeView *tree_view,
- GtkTreeViewColumn *column)
-{
- gint max_width, min_width;
- gint real_requested_width;
-
- if (_gtk_tree_view_column_get_use_resized_width (column))
- {
- real_requested_width = _gtk_tree_view_column_get_resized_width (column);
- }
- else if (gtk_tree_view_column_get_sizing (column) == GTK_TREE_VIEW_COLUMN_FIXED)
- {
- real_requested_width = gtk_tree_view_column_get_fixed_width (column);
- }
- else if (GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_HEADERS_VISIBLE))
- {
- GtkWidget *button = gtk_tree_view_column_get_button (column);
- gint button_request;
-
- gtk_widget_get_preferred_width (button, &button_request, NULL);
-
- real_requested_width = MAX (_gtk_tree_view_column_get_requested_width (column), button_request);
- }
- else
- {
- real_requested_width = _gtk_tree_view_column_get_requested_width (column);
- if (real_requested_width < 0)
- real_requested_width = 0;
- }
-
- min_width = gtk_tree_view_column_get_min_width (column);
- if (min_width != -1)
- real_requested_width = MAX (real_requested_width, min_width);
-
- max_width = gtk_tree_view_column_get_max_width (column);
- if (max_width != -1)
- real_requested_width = MIN (real_requested_width, max_width);
-
- return real_requested_width;
-}
-
/* GtkWidget::size_allocate helper */
static void
gtk_tree_view_size_allocate_columns (GtkWidget *widget,
@@ -2638,7 +2591,7 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
if (!gtk_tree_view_column_get_visible (column))
continue;
- full_requested_width += gtk_tree_view_get_real_requested_width_from_column (tree_view, column);
+ full_requested_width += _gtk_tree_view_column_request_width (column);
if (gtk_tree_view_column_get_expand (column))
number_of_expand_columns++;
@@ -2685,8 +2638,6 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
list != (rtl ? first_column->prev : last_column->next);
list = (rtl ? list->prev : list->next))
{
- GtkWidget *button;
- GdkWindow *window;
gint internal_column_width = 0;
gint old_width, column_width;
@@ -2714,7 +2665,7 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
continue;
}
- column_width = gtk_tree_view_get_real_requested_width_from_column (tree_view, column);
+ column_width = _gtk_tree_view_column_request_width (column);
if (gtk_tree_view_column_get_expand (column))
{
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index cc3df59..0232955 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -1840,6 +1840,45 @@ gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column)
return tree_column->priv->width;
}
+gint
+_gtk_tree_view_column_request_width (GtkTreeViewColumn *tree_column)
+{
+ GtkTreeViewColumnPrivate *priv;
+ gint real_requested_width;
+
+ priv = tree_column->priv;
+
+ if (priv->use_resized_width)
+ {
+ real_requested_width = priv->resized_width;
+ }
+ else if (priv->column_type == GTK_TREE_VIEW_COLUMN_FIXED)
+ {
+ real_requested_width = priv->fixed_width;
+ }
+ else if (gtk_tree_view_get_headers_visible (GTK_TREE_VIEW (priv->tree_view)))
+ {
+ gint button_request;
+
+ gtk_widget_get_preferred_width (priv->button, &button_request, NULL);
+ real_requested_width = MAX (priv->requested_width, button_request);
+ }
+ else
+ {
+ real_requested_width = priv->requested_width;
+ if (real_requested_width < 0)
+ real_requested_width = 0;
+ }
+
+ if (priv->min_width != -1)
+ real_requested_width = MAX (real_requested_width, priv->min_width);
+
+ if (priv->max_width != -1)
+ real_requested_width = MIN (real_requested_width, priv->max_width);
+
+ return real_requested_width;
+}
+
void
_gtk_tree_view_column_allocate (GtkTreeViewColumn *tree_column,
int x_offset,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]