2 new signals; is_expander/is_expanded.

Sat Aug 18 04:34:31 2001  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): 2 new
	signals; is_expander/is_expanded.

	* gtk/gtlcellrendererpixbuf.c: Allow other expanded and closed
	pixbufs.

	* gtk/gtktreeview.c: set above properties.
This commit is contained in:
Jonathan Blandford 2001-08-19 04:19:56 +00:00 committed by Jonathan Blandford
parent 9e58bc3117
commit 6ffd507dea
14 changed files with 209 additions and 22 deletions

View File

@ -1,3 +1,13 @@
Sat Aug 18 04:34:31 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): 2 new
signals; is_expander/is_expanded.
* gtk/gtlcellrendererpixbuf.c: Allow other expanded and closed
pixbufs.
* gtk/gtktreeview.c: set above properties.
Sat Aug 18 23:01:33 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Really remove set_default_style().

View File

@ -1,3 +1,13 @@
Sat Aug 18 04:34:31 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): 2 new
signals; is_expander/is_expanded.
* gtk/gtlcellrendererpixbuf.c: Allow other expanded and closed
pixbufs.
* gtk/gtktreeview.c: set above properties.
Sat Aug 18 23:01:33 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Really remove set_default_style().

View File

@ -1,3 +1,13 @@
Sat Aug 18 04:34:31 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): 2 new
signals; is_expander/is_expanded.
* gtk/gtlcellrendererpixbuf.c: Allow other expanded and closed
pixbufs.
* gtk/gtktreeview.c: set above properties.
Sat Aug 18 23:01:33 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Really remove set_default_style().

View File

@ -1,3 +1,13 @@
Sat Aug 18 04:34:31 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): 2 new
signals; is_expander/is_expanded.
* gtk/gtlcellrendererpixbuf.c: Allow other expanded and closed
pixbufs.
* gtk/gtktreeview.c: set above properties.
Sat Aug 18 23:01:33 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Really remove set_default_style().

View File

@ -1,3 +1,13 @@
Sat Aug 18 04:34:31 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): 2 new
signals; is_expander/is_expanded.
* gtk/gtlcellrendererpixbuf.c: Allow other expanded and closed
pixbufs.
* gtk/gtktreeview.c: set above properties.
Sat Aug 18 23:01:33 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Really remove set_default_style().

View File

@ -1,3 +1,13 @@
Sat Aug 18 04:34:31 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): 2 new
signals; is_expander/is_expanded.
* gtk/gtlcellrendererpixbuf.c: Allow other expanded and closed
pixbufs.
* gtk/gtktreeview.c: set above properties.
Sat Aug 18 23:01:33 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Really remove set_default_style().

View File

@ -1,3 +1,13 @@
Sat Aug 18 04:34:31 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): 2 new
signals; is_expander/is_expanded.
* gtk/gtlcellrendererpixbuf.c: Allow other expanded and closed
pixbufs.
* gtk/gtktreeview.c: set above properties.
Sat Aug 18 23:01:33 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Really remove set_default_style().

View File

@ -42,6 +42,8 @@ enum {
PROP_YPAD,
PROP_WIDTH,
PROP_HEIGHT,
PROP_IS_EXPANDER,
PROP_IS_EXPANDED,
};
@ -182,6 +184,25 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
-1,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_IS_EXPANDER,
g_param_spec_boolean ("is_expander",
_("Is Expander"),
_("Row has children."),
FALSE,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_IS_EXPANDED,
g_param_spec_boolean ("is_expanded",
_("Is Expanded"),
_("Row is an expander row, and is expanded"),
FALSE,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
}
static void
@ -218,6 +239,12 @@ gtk_cell_renderer_get_property (GObject *object,
case PROP_HEIGHT:
g_value_set_int (value, cell->height);
break;
case PROP_IS_EXPANDER:
g_value_set_int (value, cell->is_expander);
break;
case PROP_IS_EXPANDED:
g_value_set_int (value, cell->is_expanded);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@ -267,6 +294,14 @@ gtk_cell_renderer_set_property (GObject *object,
cell->height = g_value_get_int (value);
g_object_notify (object, "height");
break;
case PROP_IS_EXPANDER:
cell->is_expander = g_value_get_boolean (value);
g_object_notify (object, "is_expander");
break;
case PROP_IS_EXPANDED:
cell->is_expanded = g_value_get_boolean (value);
g_object_notify (object, "is_expanded");
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;

View File

@ -62,6 +62,8 @@ struct _GtkCellRenderer
guint can_activate : 1;
guint visible : 1;
guint is_expander : 1;
guint is_expanded : 1;
};
struct _GtkCellRendererClass

View File

@ -49,7 +49,9 @@ static void gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cel
enum {
PROP_ZERO,
PROP_PIXBUF
PROP_PIXBUF,
PROP_PIXBUF_EXPANDER_OPEN,
PROP_PIXBUF_EXPANDER_CLOSED
};
@ -120,6 +122,14 @@ gtk_cell_renderer_pixbuf_get_property (GObject *object,
g_value_set_object (value,
cellpixbuf->pixbuf ? G_OBJECT (cellpixbuf->pixbuf) : NULL);
break;
case PROP_PIXBUF_EXPANDER_OPEN:
g_value_set_object (value,
cellpixbuf->pixbuf_expander_open ? G_OBJECT (cellpixbuf->pixbuf_expander_open) : NULL);
break;
case PROP_PIXBUF_EXPANDER_CLOSED:
g_value_set_object (value,
cellpixbuf->pixbuf_expander_closed ? G_OBJECT (cellpixbuf->pixbuf_expander_closed) : NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@ -147,6 +157,24 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
cellpixbuf->pixbuf = pixbuf;
g_object_notify (object, "pixbuf");
break;
case PROP_PIXBUF_EXPANDER_OPEN:
pixbuf = (GdkPixbuf*) g_value_get_object (value);
if (pixbuf)
g_object_ref (G_OBJECT (pixbuf));
if (cellpixbuf->pixbuf_expander_open)
g_object_unref (G_OBJECT (cellpixbuf->pixbuf_expander_open));
cellpixbuf->pixbuf_expander_open = pixbuf;
g_object_notify (object, "pixbuf_expander_open");
break;
case PROP_PIXBUF_EXPANDER_CLOSED:
pixbuf = (GdkPixbuf*) g_value_get_object (value);
if (pixbuf)
g_object_ref (G_OBJECT (pixbuf));
if (cellpixbuf->pixbuf_expander_closed)
g_object_unref (G_OBJECT (cellpixbuf->pixbuf_expander_closed));
cellpixbuf->pixbuf_expander_closed = pixbuf;
g_object_notify (object, "pixbuf_expander_closed");
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@ -182,22 +210,34 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
gint *height)
{
GtkCellRendererPixbuf *cellpixbuf = (GtkCellRendererPixbuf *) cell;
GdkPixbuf *pixbuf;
gint pixbuf_width = 0;
gint pixbuf_height = 0;
gint calc_width;
gint calc_height;
pixbuf = cellpixbuf->pixbuf;
calc_width = (gint) GTK_CELL_RENDERER (cellpixbuf)->xpad * 2 +
(cellpixbuf->pixbuf ? gdk_pixbuf_get_width (cellpixbuf->pixbuf) : 0);
if (cellpixbuf->pixbuf)
{
pixbuf_width = gdk_pixbuf_get_width (cellpixbuf->pixbuf);
pixbuf_height = gdk_pixbuf_get_height (cellpixbuf->pixbuf);
}
if (cellpixbuf->pixbuf_expander_open)
{
pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_open));
pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellpixbuf->pixbuf_expander_open));
}
if (cellpixbuf->pixbuf_expander_closed)
{
pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_closed));
pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellpixbuf->pixbuf_expander_closed));
}
calc_height = (gint) GTK_CELL_RENDERER (cellpixbuf)->ypad * 2 +
(cellpixbuf->pixbuf ? gdk_pixbuf_get_height (cellpixbuf->pixbuf) : 0);
calc_width = (gint) GTK_CELL_RENDERER (cellpixbuf)->xpad * 2 + pixbuf_width;
calc_height = (gint) GTK_CELL_RENDERER (cellpixbuf)->ypad * 2 + pixbuf_height;
if (x_offset) *x_offset = 0;
if (y_offset) *y_offset = 0;
if (cell_area && pixbuf)
if (cell_area && pixbuf_width > 0 && pixbuf_height > 0)
{
if (x_offset)
{
@ -236,6 +276,15 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
GdkRectangle draw_rect;
pixbuf = cellpixbuf->pixbuf;
if (cell->is_expander)
{
if (cell->is_expanded &&
cellpixbuf->pixbuf_expander_open != NULL)
pixbuf = cellpixbuf->pixbuf_expander_open;
else if (! cell->is_expanded &&
cellpixbuf->pixbuf_expander_closed != NULL)
pixbuf = cellpixbuf->pixbuf_expander_closed;
}
if (!pixbuf)
return;

View File

@ -42,6 +42,8 @@ struct _GtkCellRendererPixbuf
GtkCellRenderer parent;
GdkPixbuf *pixbuf;
GdkPixbuf *pixbuf_expander_open;
GdkPixbuf *pixbuf_expander_closed;
};
struct _GtkCellRendererPixbufClass

View File

@ -316,7 +316,8 @@ static void gtk_tree_view_calc_size (GtkTreeView
static gboolean gtk_tree_view_discover_dirty_iter (GtkTreeView *tree_view,
GtkTreeIter *iter,
gint depth,
gint *height);
gint *height,
GtkRBNode *node);
static void gtk_tree_view_discover_dirty (GtkTreeView *tree_view,
GtkRBTree *tree,
GtkTreeIter *iter,
@ -1614,7 +1615,9 @@ gtk_tree_view_button_press (GtkWidget *widget,
gtk_tree_model_get_iter (tree_view->priv->model, &iter, path);
gtk_tree_view_column_cell_set_cell_data (column,
tree_view->priv->model,
&iter);
&iter,
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_PARENT),
node->children?TRUE:FALSE);
path_string = gtk_tree_path_to_string (path);
@ -2424,7 +2427,11 @@ gtk_tree_view_draw_focus (GtkWidget *widget)
GtkTreeIter iter;
gtk_tree_model_get_iter (tree_view->priv->model, &iter, cursor_path);
gtk_tree_view_column_cell_set_cell_data (tree_view->priv->focus_column, tree_view->priv->model, &iter);
gtk_tree_view_column_cell_set_cell_data (tree_view->priv->focus_column,
tree_view->priv->model,
&iter,
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_PARENT),
node->children?TRUE:FALSE);
if (gtk_tree_view_column_cell_can_focus (tree_view->priv->focus_column))
{
@ -2599,7 +2606,10 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
gtk_tree_view_column_cell_set_cell_data (column,
tree_view->priv->model,
&iter);
&iter,
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_PARENT),
node->children?TRUE:FALSE);
background_area.x = cell_offset;
background_area.width = column->displayed_width;
@ -4333,7 +4343,8 @@ gtk_tree_view_range_changed (GtkTreeModel *model,
dirty_marked = gtk_tree_view_discover_dirty_iter (tree_view,
iter,
gtk_tree_path_get_depth (path),
&height);
&height,
node);
if (GTK_RBNODE_GET_HEIGHT (node) != height + vertical_separator)
{
@ -4817,7 +4828,9 @@ gtk_tree_view_insert_iter_height (GtkTreeView *tree_view,
if (column->column_type == GTK_TREE_VIEW_COLUMN_FIXED)
continue;
gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, iter);
gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, iter,
gtk_tree_model_iter_has_child (tree_view->priv->model, iter),
FALSE);
gtk_tree_view_column_cell_get_size (column, NULL, NULL, NULL, &width, &height);
max_height = MAX (max_height, vertical_separator + height);
@ -4910,7 +4923,9 @@ gtk_tree_view_calc_size (GtkTreeView *tree_view,
if (!column->visible)
continue;
gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, iter);
gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, iter,
GTK_RBNODE_FLAG_SET (temp, GTK_RBNODE_IS_PARENT),
temp->children?TRUE:FALSE);
gtk_tree_view_column_cell_get_size (column, NULL, NULL, NULL, &width, &height);
max_height = MAX (max_height, vertical_separator + height);
@ -4944,7 +4959,8 @@ static gboolean
gtk_tree_view_discover_dirty_iter (GtkTreeView *tree_view,
GtkTreeIter *iter,
gint depth,
gint *height)
gint *height,
GtkRBNode *node)
{
GtkTreeViewColumn *column;
GList *list;
@ -4962,8 +4978,11 @@ gtk_tree_view_discover_dirty_iter (GtkTreeView *tree_view,
continue;
if (!column->visible)
continue;
gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, iter,
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_PARENT),
node->children?TRUE:FALSE);
gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, iter);
if (height)
{
@ -5037,7 +5056,8 @@ gtk_tree_view_discover_dirty (GtkTreeView *tree_view,
gtk_tree_view_discover_dirty_iter (tree_view,
iter,
depth,
FALSE);
FALSE,
temp);
if (gtk_tree_model_iter_children (tree_view->priv->model, &child, iter) &&
temp->children != NULL)
gtk_tree_view_discover_dirty (tree_view, temp->children, &child, depth + 1);
@ -8402,7 +8422,9 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
if (!column->visible)
continue;
gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, &iter);
gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, &iter,
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_PARENT),
node->children?TRUE:FALSE);
background_area.x = cell_offset;
background_area.width = column->displayed_width;

View File

@ -2019,6 +2019,8 @@ gtk_tree_view_column_get_sort_order (GtkTreeViewColumn *tree_column)
* @tree_column: A #GtkTreeViewColumn.
* @tree_model: The #GtkTreeModel to to get the cell renderers attributes from.
* @iter: The #GtkTreeIter to to get the cell renderer's attributes from.
* @is_expander: TRUE, if the row has children
* @is_expanded: TRUE, if the row has visible children
*
* Sets the cell renderer based on the @tree_model and @tree_node. That is, for
* every attribute mapping in @tree_column, it will get a value from the set
@ -2028,7 +2030,9 @@ gtk_tree_view_column_get_sort_order (GtkTreeViewColumn *tree_column)
void
gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
GtkTreeModel *tree_model,
GtkTreeIter *iter)
GtkTreeIter *iter,
gboolean is_expander,
gboolean is_expanded)
{
GSList *list;
GValue value = { 0, };
@ -2048,6 +2052,7 @@ gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
list = info->attributes;
g_object_freeze_notify (cell);
g_object_set (cell, "is_expander", is_expander, "is_expanded", is_expanded, NULL);
while (list && list->next)
{

View File

@ -196,7 +196,9 @@ GtkTreeSortOrder gtk_tree_view_column_get_sort_order (GtkTreeViewCol
*/
void gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
GtkTreeModel *tree_model,
GtkTreeIter *iter);
GtkTreeIter *iter,
gboolean is_expander,
gboolean is_expanded);
void gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
GdkRectangle *cell_area,
gint *x_offset,