don't draw if label->layout is NULL due to a pending resize

2001-01-09  Havoc Pennington  <hp@redhat.com>

	* gtk/gtklabel.c (gtk_label_expose): don't draw if label->layout
	is NULL due to a pending resize

	* gtk/gtktreeview.c (gtk_tree_view_check_dirty): don't set the
	column width to values less than 1

	* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_width): clamp
	width to be between min/max width, and still set the width
	even if autosize is turned on, so the tree view can use this
	function in order to autosize.
	(gtk_tree_view_column_init): set initial width to 1 not 0

	* gtk/gtktreeview.c (gtk_tree_view_size_request_buttons): use
	setter function to modify column width, so we get notification
	(gtk_tree_view_insert_iter_height): ditto
	(gtk_tree_view_calc_size): ditto
	(gtk_tree_view_check_dirty): ditto

	* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_class_init): Add
	properties to change all the interesting attributes of the tree
	view column.
	(gtk_tree_view_column_set_header_clickable): rename set_clickable
	(gtk_tree_view_column_get_clickable): add
	(gtk_tree_view_column_set_cell_renderer): don't unset the current
	attributes; assume a cell renderer with equivalent object
	properties has been swapped in. Do g_object_notify().
	(gtk_tree_view_column_set_visible): g_object_notify
	(gtk_tree_view_column_get_sizing): rename from get_col_type
	(gtk_tree_view_column_set_sizing): g_object_notify
	(gtk_tree_view_column_set_width): add g_object_notify
	(gtk_tree_view_column_set_min_width): ditto
	(gtk_tree_view_column_set_max_width): ditto
	(gtk_tree_view_column_set_title): ditto
	(gtk_tree_view_column_set_clickable): ditto
	(gtk_tree_view_column_set_widget): ditto
	(gtk_tree_view_column_set_justification): ditto
This commit is contained in:
Havoc Pennington 2001-01-09 23:24:20 +00:00 committed by Havoc Pennington
parent 637c61da76
commit 85267e9224
12 changed files with 679 additions and 54 deletions

View File

@ -1,3 +1,42 @@
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtklabel.c (gtk_label_expose): don't draw if label->layout
is NULL due to a pending resize
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): don't set the
column width to values less than 1
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_width): clamp
width to be between min/max width, and still set the width
even if autosize is turned on, so the tree view can use this
function in order to autosize.
(gtk_tree_view_column_init): set initial width to 1 not 0
* gtk/gtktreeview.c (gtk_tree_view_size_request_buttons): use
setter function to modify column width, so we get notification
(gtk_tree_view_insert_iter_height): ditto
(gtk_tree_view_calc_size): ditto
(gtk_tree_view_check_dirty): ditto
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_class_init): Add
properties to change all the interesting attributes of the tree
view column.
(gtk_tree_view_column_set_header_clickable): rename set_clickable
(gtk_tree_view_column_get_clickable): add
(gtk_tree_view_column_set_cell_renderer): don't unset the current
attributes; assume a cell renderer with equivalent object
properties has been swapped in. Do g_object_notify().
(gtk_tree_view_column_set_visible): g_object_notify
(gtk_tree_view_column_get_sizing): rename from get_col_type
(gtk_tree_view_column_set_sizing): g_object_notify
(gtk_tree_view_column_set_width): add g_object_notify
(gtk_tree_view_column_set_min_width): ditto
(gtk_tree_view_column_set_max_width): ditto
(gtk_tree_view_column_set_title): ditto
(gtk_tree_view_column_set_clickable): ditto
(gtk_tree_view_column_set_widget): ditto
(gtk_tree_view_column_set_justification): ditto
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): handle case where

View File

@ -1,3 +1,42 @@
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtklabel.c (gtk_label_expose): don't draw if label->layout
is NULL due to a pending resize
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): don't set the
column width to values less than 1
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_width): clamp
width to be between min/max width, and still set the width
even if autosize is turned on, so the tree view can use this
function in order to autosize.
(gtk_tree_view_column_init): set initial width to 1 not 0
* gtk/gtktreeview.c (gtk_tree_view_size_request_buttons): use
setter function to modify column width, so we get notification
(gtk_tree_view_insert_iter_height): ditto
(gtk_tree_view_calc_size): ditto
(gtk_tree_view_check_dirty): ditto
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_class_init): Add
properties to change all the interesting attributes of the tree
view column.
(gtk_tree_view_column_set_header_clickable): rename set_clickable
(gtk_tree_view_column_get_clickable): add
(gtk_tree_view_column_set_cell_renderer): don't unset the current
attributes; assume a cell renderer with equivalent object
properties has been swapped in. Do g_object_notify().
(gtk_tree_view_column_set_visible): g_object_notify
(gtk_tree_view_column_get_sizing): rename from get_col_type
(gtk_tree_view_column_set_sizing): g_object_notify
(gtk_tree_view_column_set_width): add g_object_notify
(gtk_tree_view_column_set_min_width): ditto
(gtk_tree_view_column_set_max_width): ditto
(gtk_tree_view_column_set_title): ditto
(gtk_tree_view_column_set_clickable): ditto
(gtk_tree_view_column_set_widget): ditto
(gtk_tree_view_column_set_justification): ditto
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): handle case where

View File

@ -1,3 +1,42 @@
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtklabel.c (gtk_label_expose): don't draw if label->layout
is NULL due to a pending resize
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): don't set the
column width to values less than 1
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_width): clamp
width to be between min/max width, and still set the width
even if autosize is turned on, so the tree view can use this
function in order to autosize.
(gtk_tree_view_column_init): set initial width to 1 not 0
* gtk/gtktreeview.c (gtk_tree_view_size_request_buttons): use
setter function to modify column width, so we get notification
(gtk_tree_view_insert_iter_height): ditto
(gtk_tree_view_calc_size): ditto
(gtk_tree_view_check_dirty): ditto
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_class_init): Add
properties to change all the interesting attributes of the tree
view column.
(gtk_tree_view_column_set_header_clickable): rename set_clickable
(gtk_tree_view_column_get_clickable): add
(gtk_tree_view_column_set_cell_renderer): don't unset the current
attributes; assume a cell renderer with equivalent object
properties has been swapped in. Do g_object_notify().
(gtk_tree_view_column_set_visible): g_object_notify
(gtk_tree_view_column_get_sizing): rename from get_col_type
(gtk_tree_view_column_set_sizing): g_object_notify
(gtk_tree_view_column_set_width): add g_object_notify
(gtk_tree_view_column_set_min_width): ditto
(gtk_tree_view_column_set_max_width): ditto
(gtk_tree_view_column_set_title): ditto
(gtk_tree_view_column_set_clickable): ditto
(gtk_tree_view_column_set_widget): ditto
(gtk_tree_view_column_set_justification): ditto
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): handle case where

View File

@ -1,3 +1,42 @@
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtklabel.c (gtk_label_expose): don't draw if label->layout
is NULL due to a pending resize
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): don't set the
column width to values less than 1
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_width): clamp
width to be between min/max width, and still set the width
even if autosize is turned on, so the tree view can use this
function in order to autosize.
(gtk_tree_view_column_init): set initial width to 1 not 0
* gtk/gtktreeview.c (gtk_tree_view_size_request_buttons): use
setter function to modify column width, so we get notification
(gtk_tree_view_insert_iter_height): ditto
(gtk_tree_view_calc_size): ditto
(gtk_tree_view_check_dirty): ditto
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_class_init): Add
properties to change all the interesting attributes of the tree
view column.
(gtk_tree_view_column_set_header_clickable): rename set_clickable
(gtk_tree_view_column_get_clickable): add
(gtk_tree_view_column_set_cell_renderer): don't unset the current
attributes; assume a cell renderer with equivalent object
properties has been swapped in. Do g_object_notify().
(gtk_tree_view_column_set_visible): g_object_notify
(gtk_tree_view_column_get_sizing): rename from get_col_type
(gtk_tree_view_column_set_sizing): g_object_notify
(gtk_tree_view_column_set_width): add g_object_notify
(gtk_tree_view_column_set_min_width): ditto
(gtk_tree_view_column_set_max_width): ditto
(gtk_tree_view_column_set_title): ditto
(gtk_tree_view_column_set_clickable): ditto
(gtk_tree_view_column_set_widget): ditto
(gtk_tree_view_column_set_justification): ditto
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): handle case where

View File

@ -1,3 +1,42 @@
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtklabel.c (gtk_label_expose): don't draw if label->layout
is NULL due to a pending resize
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): don't set the
column width to values less than 1
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_width): clamp
width to be between min/max width, and still set the width
even if autosize is turned on, so the tree view can use this
function in order to autosize.
(gtk_tree_view_column_init): set initial width to 1 not 0
* gtk/gtktreeview.c (gtk_tree_view_size_request_buttons): use
setter function to modify column width, so we get notification
(gtk_tree_view_insert_iter_height): ditto
(gtk_tree_view_calc_size): ditto
(gtk_tree_view_check_dirty): ditto
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_class_init): Add
properties to change all the interesting attributes of the tree
view column.
(gtk_tree_view_column_set_header_clickable): rename set_clickable
(gtk_tree_view_column_get_clickable): add
(gtk_tree_view_column_set_cell_renderer): don't unset the current
attributes; assume a cell renderer with equivalent object
properties has been swapped in. Do g_object_notify().
(gtk_tree_view_column_set_visible): g_object_notify
(gtk_tree_view_column_get_sizing): rename from get_col_type
(gtk_tree_view_column_set_sizing): g_object_notify
(gtk_tree_view_column_set_width): add g_object_notify
(gtk_tree_view_column_set_min_width): ditto
(gtk_tree_view_column_set_max_width): ditto
(gtk_tree_view_column_set_title): ditto
(gtk_tree_view_column_set_clickable): ditto
(gtk_tree_view_column_set_widget): ditto
(gtk_tree_view_column_set_justification): ditto
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): handle case where

View File

@ -1,3 +1,42 @@
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtklabel.c (gtk_label_expose): don't draw if label->layout
is NULL due to a pending resize
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): don't set the
column width to values less than 1
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_width): clamp
width to be between min/max width, and still set the width
even if autosize is turned on, so the tree view can use this
function in order to autosize.
(gtk_tree_view_column_init): set initial width to 1 not 0
* gtk/gtktreeview.c (gtk_tree_view_size_request_buttons): use
setter function to modify column width, so we get notification
(gtk_tree_view_insert_iter_height): ditto
(gtk_tree_view_calc_size): ditto
(gtk_tree_view_check_dirty): ditto
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_class_init): Add
properties to change all the interesting attributes of the tree
view column.
(gtk_tree_view_column_set_header_clickable): rename set_clickable
(gtk_tree_view_column_get_clickable): add
(gtk_tree_view_column_set_cell_renderer): don't unset the current
attributes; assume a cell renderer with equivalent object
properties has been swapped in. Do g_object_notify().
(gtk_tree_view_column_set_visible): g_object_notify
(gtk_tree_view_column_get_sizing): rename from get_col_type
(gtk_tree_view_column_set_sizing): g_object_notify
(gtk_tree_view_column_set_width): add g_object_notify
(gtk_tree_view_column_set_min_width): ditto
(gtk_tree_view_column_set_max_width): ditto
(gtk_tree_view_column_set_title): ditto
(gtk_tree_view_column_set_clickable): ditto
(gtk_tree_view_column_set_widget): ditto
(gtk_tree_view_column_set_justification): ditto
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): handle case where

View File

@ -1,3 +1,42 @@
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtklabel.c (gtk_label_expose): don't draw if label->layout
is NULL due to a pending resize
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): don't set the
column width to values less than 1
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_width): clamp
width to be between min/max width, and still set the width
even if autosize is turned on, so the tree view can use this
function in order to autosize.
(gtk_tree_view_column_init): set initial width to 1 not 0
* gtk/gtktreeview.c (gtk_tree_view_size_request_buttons): use
setter function to modify column width, so we get notification
(gtk_tree_view_insert_iter_height): ditto
(gtk_tree_view_calc_size): ditto
(gtk_tree_view_check_dirty): ditto
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_class_init): Add
properties to change all the interesting attributes of the tree
view column.
(gtk_tree_view_column_set_header_clickable): rename set_clickable
(gtk_tree_view_column_get_clickable): add
(gtk_tree_view_column_set_cell_renderer): don't unset the current
attributes; assume a cell renderer with equivalent object
properties has been swapped in. Do g_object_notify().
(gtk_tree_view_column_set_visible): g_object_notify
(gtk_tree_view_column_get_sizing): rename from get_col_type
(gtk_tree_view_column_set_sizing): g_object_notify
(gtk_tree_view_column_set_width): add g_object_notify
(gtk_tree_view_column_set_min_width): ditto
(gtk_tree_view_column_set_max_width): ditto
(gtk_tree_view_column_set_title): ditto
(gtk_tree_view_column_set_clickable): ditto
(gtk_tree_view_column_set_widget): ditto
(gtk_tree_view_column_set_justification): ditto
2001-01-09 Havoc Pennington <hp@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_check_dirty): handle case where

View File

@ -711,9 +711,13 @@ gtk_label_expose (GtkWidget *widget,
g_return_val_if_fail (event != NULL, FALSE);
label = GTK_LABEL (widget);
/* if label->layout is NULL it means we got a set_text since
* our last size request, so a resize should be queued,
* which means a full expose is in the queue anyway.
*/
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget) &&
label->label && (*label->label != '\0'))
label->layout && label->label && (*label->label != '\0'))
{
misc = GTK_MISC (widget);

View File

@ -520,7 +520,8 @@ gtk_tree_view_size_request_buttons (GtkTreeView *tree_view)
gtk_widget_size_request (column->button, &requisition);
column->width = MAX (column->width, requisition.width);
gtk_tree_view_column_set_width (column,
MAX (column->width, requisition.width));
tree_view->priv->header_height = MAX (tree_view->priv->header_height, requisition.height);
}
}
@ -2215,9 +2216,11 @@ gtk_tree_view_insert_iter_height (GtkTreeView *tree_view,
max_height = MAX (max_height, TREE_VIEW_VERTICAL_SEPARATOR + height);
if (first == TRUE && TREE_VIEW_DRAW_EXPANDERS (tree_view))
column->width = MAX (column->width, depth * tree_view->priv->tab_offset + width);
gtk_tree_view_column_set_width (column,
MAX (column->width, depth * tree_view->priv->tab_offset + width));
else
column->width = MAX (column->width, width);
gtk_tree_view_column_set_width (column,
MAX (column->width, width));
first = FALSE;
}
@ -2311,9 +2314,10 @@ gtk_tree_view_calc_size (GtkTreeView *tree_view,
continue;
if (i == 0 && TREE_VIEW_DRAW_EXPANDERS (tree_view))
column->width = MAX (column->width, depth * tree_view->priv->tab_offset + width);
gtk_tree_view_column_set_width (column,
MAX (column->width, depth * tree_view->priv->tab_offset + width));
else
column->width = MAX (column->width, width);
gtk_tree_view_column_set_width (column, MAX (column->width, width));
}
_gtk_rbtree_node_set_height (tree, temp, max_height);
if (temp->children != NULL &&
@ -2445,7 +2449,7 @@ gtk_tree_view_check_dirty (GtkTreeView *tree_view)
dirty = TRUE;
if (column->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE)
{
column->width = column->button->requisition.width;
gtk_tree_view_column_set_width (column, MAX (column->button->requisition.width, 1));
}
}
}
@ -3279,9 +3283,6 @@ gtk_tree_view_columns_autosize (GtkTreeView *tree_view)
gtk_widget_queue_resize (GTK_WIDGET (tree_view));
}
/* FIXME let's rename this to be "interactive" or something,
* "active" is confusing since it also is a widget state
*/
/**
* gtk_tree_view_set_headers_clickable:
* @tree_view: A #GtkTreeView.
@ -3300,7 +3301,7 @@ gtk_tree_view_set_headers_clickable (GtkTreeView *tree_view,
g_return_if_fail (tree_view->priv->model != NULL);
for (list = tree_view->priv->columns; list; list = list->next)
gtk_tree_view_column_set_header_clickable (GTK_TREE_VIEW_COLUMN (list->data), setting);
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (list->data), setting);
}
/**

View File

@ -23,8 +23,26 @@
#include "gtkbutton.h"
#include "gtkalignment.h"
#include "gtklabel.h"
#include "gtkintl.h"
enum {
enum
{
PROP_0,
PROP_CELL_RENDERER,
PROP_VISIBLE,
PROP_SIZING,
PROP_WIDTH,
PROP_MIN_WIDTH,
PROP_MAX_WIDTH,
PROP_TITLE,
PROP_CLICKABLE,
PROP_WIDGET,
PROP_JUSTIFICATION
};
enum
{
CLICKED,
LAST_SIGNAL
};
@ -35,6 +53,17 @@ static void gtk_tree_view_column_class_init (GtkTreeViewColumnClass *klass)
static void gtk_tree_view_column_set_attributesv (GtkTreeViewColumn *tree_column,
va_list args);
static void gtk_real_tree_column_clicked (GtkTreeViewColumn *tree_column);
static void gtk_tree_view_column_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec,
const gchar *trailer);
static void gtk_tree_view_column_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec,
const gchar *trailer);
static GtkObjectClass *parent_class = NULL;
@ -70,21 +99,114 @@ gtk_tree_view_column_get_type (void)
static void
gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
{
GtkObjectClass *object_class;
GObjectClass *object_class;
object_class = (GtkObjectClass*) class;
object_class = (GObjectClass*) class;
parent_class = g_type_class_peek_parent (class);
class->clicked = gtk_real_tree_column_clicked;
object_class->set_property = gtk_tree_view_column_set_property;
object_class->get_property = gtk_tree_view_column_get_property;
tree_column_signals[CLICKED] =
gtk_signal_new ("clicked",
GTK_RUN_FIRST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTreeViewColumnClass, clicked),
gtk_marshal_VOID__VOID,
GTK_TYPE_NONE, 0);
g_signal_newc ("clicked",
GTK_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkTreeViewColumnClass, clicked),
NULL,
gtk_marshal_VOID__VOID,
GTK_TYPE_NONE, 0);
g_object_class_install_property (object_class,
PROP_CELL_RENDERER,
g_param_spec_object ("cell_renderer",
_("Cell renderer"),
_("Cell renderer object to use for rendering the cell"),
GTK_TYPE_CELL_RENDERER,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_VISIBLE,
g_param_spec_boolean ("visible",
_("Visible"),
_("Whether to display the colomn"),
TRUE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_SIZING,
g_param_spec_enum ("sizing",
_("Sizing"),
_("Resize mode of the column"),
GTK_TYPE_TREE_VIEW_COLUMN_SIZING,
GTK_TREE_VIEW_COLUMN_AUTOSIZE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_WIDTH,
g_param_spec_int ("width",
_("Width"),
_("Current width of the column"),
1,
G_MAXINT,
1, /* not useful */
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_MIN_WIDTH,
g_param_spec_int ("min_width",
_("Minimum Width"),
_("Minimum allowed width of the column"),
-1,
G_MAXINT,
1,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_MAX_WIDTH,
g_param_spec_int ("max_width",
_("Maximum Width"),
_("Maximum allowed width of the column"),
-1,
G_MAXINT,
G_MAXINT,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_TITLE,
g_param_spec_string ("title",
_("Title"),
_("Title to appear in column header"),
"",
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_CLICKABLE,
g_param_spec_boolean ("clickable",
_("Clickable"),
_("Whether the header can be clicked"),
TRUE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_WIDGET,
g_param_spec_object ("widget",
_("Widget"),
_("Widget to put in column header button instead of column title"),
GTK_TYPE_WIDGET,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_JUSTIFICATION,
g_param_spec_enum ("justification",
_("Justification"),
_("Justification of the column"),
GTK_TYPE_JUSTIFICATION,
GTK_JUSTIFY_LEFT,
G_PARAM_READABLE | G_PARAM_WRITABLE));
}
static void
@ -92,7 +214,7 @@ gtk_tree_view_column_init (GtkTreeViewColumn *tree_column)
{
tree_column->button = NULL;
tree_column->justification = GTK_JUSTIFY_LEFT;
tree_column->width = 0;
tree_column->width = 1;
tree_column->min_width = -1;
tree_column->max_width = -1;
tree_column->cell = NULL;
@ -103,6 +225,136 @@ gtk_tree_view_column_init (GtkTreeViewColumn *tree_column)
tree_column->dirty = TRUE;
}
static void
gtk_tree_view_column_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec,
const gchar *trailer)
{
GtkTreeViewColumn *tree_column;
tree_column = GTK_TREE_VIEW_COLUMN (object);
switch (prop_id)
{
case PROP_CELL_RENDERER:
gtk_tree_view_column_set_cell_renderer (tree_column,
(GtkCellRenderer*)
g_value_get_object (value));
break;
case PROP_VISIBLE:
gtk_tree_view_column_set_visible (tree_column,
g_value_get_boolean (value));
break;
case PROP_SIZING:
gtk_tree_view_column_set_sizing (tree_column,
g_value_get_enum (value));
break;
case PROP_WIDTH:
gtk_tree_view_column_set_width (tree_column,
g_value_get_int (value));
break;
case PROP_MIN_WIDTH:
gtk_tree_view_column_set_min_width (tree_column,
g_value_get_int (value));
break;
case PROP_MAX_WIDTH:
gtk_tree_view_column_set_max_width (tree_column,
g_value_get_int (value));
break;
case PROP_TITLE:
gtk_tree_view_column_set_title (tree_column,
g_value_get_string (value));
break;
case PROP_CLICKABLE:
gtk_tree_view_column_set_clickable (tree_column,
g_value_get_boolean (value));
break;
case PROP_WIDGET:
gtk_tree_view_column_set_widget (tree_column,
(GtkWidget*) g_value_get_object (value));
break;
case PROP_JUSTIFICATION:
gtk_tree_view_column_set_justification (tree_column,
g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_tree_view_column_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec,
const gchar *trailer)
{
GtkTreeViewColumn *tree_column;
tree_column = GTK_TREE_VIEW_COLUMN (object);
switch (prop_id)
{
case PROP_CELL_RENDERER:
g_value_set_object (value, (GObject*) tree_column->cell);
break;
case PROP_VISIBLE:
g_value_set_boolean (value, tree_column->visible);
break;
case PROP_SIZING:
g_value_set_enum (value, tree_column->column_type);
break;
case PROP_WIDTH:
g_value_set_int (value, tree_column->width);
break;
case PROP_MIN_WIDTH:
g_value_set_int (value, tree_column->min_width);
break;
case PROP_MAX_WIDTH:
g_value_set_int (value, tree_column->max_width);
break;
case PROP_TITLE:
g_value_set_string (value, tree_column->title);
break;
case PROP_CLICKABLE:
g_value_set_boolean (value, tree_column->button_active);
break;
case PROP_WIDGET:
g_warning ("FIXME");
break;
case PROP_JUSTIFICATION:
g_value_set_enum (value, tree_column->justification);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/* used to make the buttons 'unclickable' */
static gint
@ -191,9 +443,9 @@ gtk_tree_view_column_new_with_attributes (gchar *title,
* @tree_column: A #GtkTreeViewColumn.
* @cell: The #GtkCellRenderer, or NULL.
*
* Sets the cell renderer of the @tree_column, and unsets the current
* attributes. If there is a cell renderer already set, then it is removed. If
* @cell is NULL, then the cell renderer is unset.
* Sets the cell renderer of the @tree_column. If there is a cell
* renderer already set, then it is removed. If @cell is NULL, then
* the cell renderer is unset.
**/
void
gtk_tree_view_column_set_cell_renderer (GtkTreeViewColumn *tree_column,
@ -212,7 +464,7 @@ gtk_tree_view_column_set_cell_renderer (GtkTreeViewColumn *tree_column,
tree_column->cell = cell;
gtk_tree_view_column_set_attributes (tree_column, NULL);
g_object_notify (G_OBJECT (tree_column), "cell_renderer");
}
/**
@ -383,6 +635,8 @@ gtk_tree_view_column_set_visible (GtkTreeViewColumn *tree_column,
if (GTK_WIDGET_REALIZED (tree_column->tree_view))
_gtk_tree_view_set_size (GTK_TREE_VIEW (tree_column->tree_view), -1, -1);
g_object_notify (G_OBJECT (tree_column), "visible");
}
/**
@ -412,7 +666,7 @@ gtk_tree_view_column_get_visible (GtkTreeViewColumn *tree_column)
**/
void
gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column,
GtkTreeViewColumnSizing type)
GtkTreeViewColumnSizing type)
{
g_return_if_fail (tree_column != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
@ -439,10 +693,12 @@ gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column,
}
gtk_widget_queue_resize (tree_column->tree_view);
g_object_notify (G_OBJECT (tree_column), "sizing");
}
/**
* gtk_tree_view_column_get_col_type:
* gtk_tree_view_column_get_sizing:
* @tree_column: A #GtkTreeViewColumn.
*
* Returns the current type of @tree_column.
@ -450,7 +706,7 @@ gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column,
* Return value: The type of @tree_column.
**/
gint
gtk_tree_view_column_get_col_type (GtkTreeViewColumn *tree_column)
gtk_tree_view_column_get_sizing (GtkTreeViewColumn *tree_column)
{
g_return_val_if_fail (tree_column != NULL, 0);
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), 0);
@ -482,7 +738,8 @@ gtk_tree_view_column_get_size (GtkTreeViewColumn *tree_column)
*
* Sets the size of the column in pixels, unless the the column type is
* #GTK_TREE_VIEW_COLUMN_AUTOSIZE. In this case, the value is discarded as the
* size of the column is based on the calculated width of the column.
* size of the column is based on the calculated width of the column. The
* width is clamped to the min/max width for the column.
**/
void
gtk_tree_view_column_set_width (GtkTreeViewColumn *tree_column,
@ -491,15 +748,23 @@ gtk_tree_view_column_set_width (GtkTreeViewColumn *tree_column,
g_return_if_fail (tree_column != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
g_return_if_fail (size > 0);
if (tree_column->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE ||
tree_column->width == size)
if (tree_column->min_width != -1 &&
size < tree_column->min_width)
size = tree_column->min_width;
else if (tree_column->max_width != -1 &&
size > tree_column->max_width)
size = tree_column->max_width;
if (tree_column->width == size)
return;
tree_column->width = size;
if (GTK_WIDGET_REALIZED (tree_column->tree_view))
gtk_widget_queue_resize (tree_column->tree_view);
g_object_notify (G_OBJECT (tree_column), "width");
}
/**
@ -542,6 +807,8 @@ gtk_tree_view_column_set_min_width (GtkTreeViewColumn *tree_column,
tree_column->max_width = real_min_width;
tree_column->min_width = min_width;
g_object_notify (G_OBJECT (tree_column), "min_width");
}
/**
@ -595,6 +862,8 @@ gtk_tree_view_column_set_max_width (GtkTreeViewColumn *tree_column,
if (real_min_width > max_width)
tree_column->min_width = max_width;
g_object_notify (G_OBJECT (tree_column), "max_width");
}
/**
@ -664,6 +933,8 @@ gtk_tree_view_column_set_title (GtkTreeViewColumn *tree_column,
}
}
}
g_object_notify (G_OBJECT (tree_column), "title");
}
/**
@ -684,7 +955,7 @@ gtk_tree_view_column_get_title (GtkTreeViewColumn *tree_column)
}
/**
* gtk_tree_view_column_set_header_clickable:
* gtk_tree_view_column_set_clickable:
* @tree_column: A #GtkTreeViewColumn.
* @active: TRUE if the header is active.
*
@ -692,8 +963,8 @@ gtk_tree_view_column_get_title (GtkTreeViewColumn *tree_column)
* then it can take keyboard focus, and can be clicked.
**/
void
gtk_tree_view_column_set_header_clickable (GtkTreeViewColumn *tree_column,
gboolean active)
gtk_tree_view_column_set_clickable (GtkTreeViewColumn *tree_column,
gboolean active)
{
g_return_if_fail (tree_column != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
@ -728,6 +999,24 @@ gtk_tree_view_column_set_header_clickable (GtkTreeViewColumn *tree_column,
if (GTK_WIDGET_VISIBLE (tree_column->tree_view))
gtk_widget_queue_draw (tree_column->button);
}
g_object_notify (G_OBJECT (tree_column), "clickable");
}
/**
* gtk_tree_view_column_get_clickable:
* @tree_column: a #GtkTreeViewColumn
*
* Returns %TRUE if the user can click on the header for the column.
*
* Return value: whether the user can click the column header
**/
gboolean
gtk_tree_view_column_get_clickable (GtkTreeViewColumn *tree_column)
{
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), FALSE);
return tree_column->button_active;
}
/**
@ -781,6 +1070,8 @@ gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column,
if (GTK_WIDGET_VISIBLE (clist) && new_button)
size_allocate_title_buttons (clist);
#endif
g_object_notify (G_OBJECT (tree_column), "widget");
}
/**
@ -855,4 +1146,6 @@ gtk_tree_view_column_set_justification (GtkTreeViewColumn *tree_column,
break;
}
}
g_object_notify (G_OBJECT (tree_column), "justification");
}

View File

@ -101,11 +101,11 @@ void gtk_tree_view_column_set_cell_data (GtkTreeViewColumn
void gtk_tree_view_column_set_visible (GtkTreeViewColumn *tree_column,
gboolean visible);
gboolean gtk_tree_view_column_get_visible (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column,
GtkTreeViewColumnSizing type);
gint gtk_tree_view_column_get_col_type (GtkTreeViewColumn *tree_column);
gint gtk_tree_view_column_get_size (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_width (GtkTreeViewColumn *tree_column,
void gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column,
GtkTreeViewColumnSizing type);
gint gtk_tree_view_column_get_sizing (GtkTreeViewColumn *tree_column);
gint gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_width (GtkTreeViewColumn *tree_column,
gint size);
void gtk_tree_view_column_set_min_width (GtkTreeViewColumn *tree_column,
gint min_width);
@ -122,8 +122,9 @@ void gtk_tree_view_column_clicked (GtkTreeViewColumn
void gtk_tree_view_column_set_title (GtkTreeViewColumn *tree_column,
gchar *title);
gchar *gtk_tree_view_column_get_title (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_header_clickable (GtkTreeViewColumn *tree_column,
gboolean active);
void gtk_tree_view_column_set_clickable (GtkTreeViewColumn *tree_column,
gboolean active);
gboolean gtk_tree_view_column_get_clickable (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column,
GtkWidget *widget);
GtkWidget *gtk_tree_view_column_get_widget (GtkTreeViewColumn *tree_column);

View File

@ -139,6 +139,28 @@ get_model_types (void)
return column_types;
}
static void
col_clicked_cb (GtkTreeViewColumn *col, gpointer data)
{
GtkWindow *win;
win = GTK_WINDOW (create_prop_editor (G_OBJECT (col)));
gtk_window_set_title (win, gtk_tree_view_column_get_title (col));
}
static void
setup_column (GtkTreeViewColumn *col)
{
g_signal_connect_data (G_OBJECT (col),
"clicked",
(GCallback) col_clicked_cb,
NULL,
NULL,
FALSE,
FALSE);
}
static void
set_columns_type (GtkTreeView *tree_view, ColumnsType type)
{
@ -165,6 +187,7 @@ set_columns_type (GtkTreeView *tree_view, ColumnsType type)
rend,
"text", 1,
NULL);
setup_column (col);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);
@ -178,6 +201,8 @@ set_columns_type (GtkTreeView *tree_view, ColumnsType type)
"text", 0,
"pixbuf", 2,
NULL);
setup_column (col);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);
@ -193,6 +218,8 @@ set_columns_type (GtkTreeView *tree_view, ColumnsType type)
rend,
"text", 0,
NULL);
setup_column (col);
gtk_tree_view_insert_column (GTK_TREE_VIEW (tree_view), col, 0);
@ -941,18 +968,44 @@ get_param_specs (GObject *object,
*n_specs = G_OBJECT_GET_CLASS (object)->n_property_specs;
}
typedef struct
{
gpointer instance;
guint id;
} DisconnectData;
static void
disconnect_func (gpointer data)
{
DisconnectData *dd = data;
g_signal_handler_disconnect (dd->instance, dd->id);
g_free (dd);
}
static void
g_object_connect_property (GObject *object,
const gchar *prop_name,
GtkSignalFunc func,
gpointer data)
gpointer data,
GObject *alive_object)
{
gchar *with_detail = g_strconcat ("notify::", prop_name, NULL);
g_signal_connect_data (object, with_detail,
func, data,
NULL, FALSE, FALSE);
DisconnectData *dd;
dd = g_new (DisconnectData, 1);
dd->id = g_signal_connect_data (object, with_detail,
func, data,
NULL, FALSE, FALSE);
dd->instance = object;
g_object_set_data_full (G_OBJECT (alive_object),
"alive-object",
dd,
disconnect_func);
g_free (with_detail);
}
@ -1188,7 +1241,7 @@ create_prop_editor (GObject *object)
g_object_connect_property (object, spec->name,
GTK_SIGNAL_FUNC (int_changed),
adj);
adj, G_OBJECT (adj));
if (can_modify)
connect_controller (G_OBJECT (adj), "value_changed",
@ -1208,7 +1261,7 @@ create_prop_editor (GObject *object)
g_object_connect_property (object, spec->name,
GTK_SIGNAL_FUNC (string_changed),
prop_edit);
prop_edit, G_OBJECT (prop_edit));
if (can_modify)
connect_controller (G_OBJECT (prop_edit), "changed",
@ -1228,7 +1281,7 @@ create_prop_editor (GObject *object)
g_object_connect_property (object, spec->name,
GTK_SIGNAL_FUNC (bool_changed),
prop_edit);
prop_edit, G_OBJECT (prop_edit));
if (can_modify)
connect_controller (G_OBJECT (prop_edit), "toggled",
@ -1275,7 +1328,7 @@ create_prop_editor (GObject *object)
g_object_connect_property (object, spec->name,
GTK_SIGNAL_FUNC (enum_changed),
prop_edit);
prop_edit, G_OBJECT (prop_edit));
if (can_modify)
connect_controller (G_OBJECT (prop_edit), "changed",