Commit 710fb020 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford
Browse files

Remove almost all instances of GtkCellRenderer in code (all but dnd icon

Fri May 25 19:04:17 2001  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtktreeview.c (gtk_tree_view_calc_size): Remove almost all
	instances of GtkCellRenderer in code (all but dnd icon code).
	Virtualized in GtkTreeViewColumn.  Now I need to move focus in
	there, and I can do multiple Cells per column.

	* gtk/gtktreeviewcolumn.c: Proxy all cell calls correctly

	* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): fix bug
	when model was unreffed prior to removing the row reference.
parent e0547220
Fri May 25 19:04:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_calc_size): Remove almost all
instances of GtkCellRenderer in code (all but dnd icon code).
Virtualized in GtkTreeViewColumn. Now I need to move focus in
there, and I can do multiple Cells per column.
* gtk/gtktreeviewcolumn.c: Proxy all cell calls correctly
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): fix bug
when model was unreffed prior to removing the row reference.
2001-05-25 Havoc Pennington <hp@redhat.com>
* gtk/gtkiconfactory.c: fix so that default icons are created if
......
Fri May 25 19:04:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_calc_size): Remove almost all
instances of GtkCellRenderer in code (all but dnd icon code).
Virtualized in GtkTreeViewColumn. Now I need to move focus in
there, and I can do multiple Cells per column.
* gtk/gtktreeviewcolumn.c: Proxy all cell calls correctly
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): fix bug
when model was unreffed prior to removing the row reference.
2001-05-25 Havoc Pennington <hp@redhat.com>
* gtk/gtkiconfactory.c: fix so that default icons are created if
......
Fri May 25 19:04:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_calc_size): Remove almost all
instances of GtkCellRenderer in code (all but dnd icon code).
Virtualized in GtkTreeViewColumn. Now I need to move focus in
there, and I can do multiple Cells per column.
* gtk/gtktreeviewcolumn.c: Proxy all cell calls correctly
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): fix bug
when model was unreffed prior to removing the row reference.
2001-05-25 Havoc Pennington <hp@redhat.com>
* gtk/gtkiconfactory.c: fix so that default icons are created if
......
Fri May 25 19:04:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_calc_size): Remove almost all
instances of GtkCellRenderer in code (all but dnd icon code).
Virtualized in GtkTreeViewColumn. Now I need to move focus in
there, and I can do multiple Cells per column.
* gtk/gtktreeviewcolumn.c: Proxy all cell calls correctly
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): fix bug
when model was unreffed prior to removing the row reference.
2001-05-25 Havoc Pennington <hp@redhat.com>
* gtk/gtkiconfactory.c: fix so that default icons are created if
......
Fri May 25 19:04:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_calc_size): Remove almost all
instances of GtkCellRenderer in code (all but dnd icon code).
Virtualized in GtkTreeViewColumn. Now I need to move focus in
there, and I can do multiple Cells per column.
* gtk/gtktreeviewcolumn.c: Proxy all cell calls correctly
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): fix bug
when model was unreffed prior to removing the row reference.
2001-05-25 Havoc Pennington <hp@redhat.com>
* gtk/gtkiconfactory.c: fix so that default icons are created if
......
Fri May 25 19:04:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_calc_size): Remove almost all
instances of GtkCellRenderer in code (all but dnd icon code).
Virtualized in GtkTreeViewColumn. Now I need to move focus in
there, and I can do multiple Cells per column.
* gtk/gtktreeviewcolumn.c: Proxy all cell calls correctly
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): fix bug
when model was unreffed prior to removing the row reference.
2001-05-25 Havoc Pennington <hp@redhat.com>
* gtk/gtkiconfactory.c: fix so that default icons are created if
......
Fri May 25 19:04:17 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_calc_size): Remove almost all
instances of GtkCellRenderer in code (all but dnd icon code).
Virtualized in GtkTreeViewColumn. Now I need to move focus in
there, and I can do multiple Cells per column.
* gtk/gtktreeviewcolumn.c: Proxy all cell calls correctly
* gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): fix bug
when model was unreffed prior to removing the row reference.
2001-05-25 Havoc Pennington <hp@redhat.com>
* gtk/gtkiconfactory.c: fix so that default icons are created if
......
......@@ -387,5 +387,5 @@ gtk_cell_renderer_toggle_set_active (GtkCellRendererToggle *toggle,
{
g_return_if_fail (GTK_IS_CELL_RENDERER_TOGGLE (toggle));
g_object_set (G_OBJECT (toggle), "active", !! setting, NULL);
g_object_set (G_OBJECT (toggle), "active", setting?TRUE:FALSE, NULL);
}
......@@ -1407,6 +1407,8 @@ gtk_tree_row_reference_new_proxy (GObject *proxy,
reference = g_new (GtkTreeRowReference, 1);
g_object_ref (proxy);
g_object_ref (model);
reference->proxy = proxy;
reference->model = model;
reference->path = gtk_tree_path_copy (path);
......@@ -1452,26 +1454,25 @@ gtk_tree_row_reference_free (GtkTreeRowReference *reference)
g_return_if_fail (reference != NULL);
if (reference->proxy)
refs = g_object_get_data (G_OBJECT (reference->proxy), ROW_REF_DATA_STRING);
if (refs == NULL)
{
g_warning (G_STRLOC": bad row reference, proxy has no outstanding row references");
return;
}
refs->list = g_slist_remove (refs->list, reference);
if (refs->list == NULL)
{
refs = g_object_get_data (G_OBJECT (reference->proxy), ROW_REF_DATA_STRING);
if (refs == NULL)
{
g_warning (G_STRLOC": bad row reference, proxy has no outstanding row references");
return;
}
refs->list = g_slist_remove (refs->list, reference);
if (refs->list == NULL)
{
disconnect_ref_callbacks (reference->model);
g_object_set_data (G_OBJECT (reference->proxy),
ROW_REF_DATA_STRING,
NULL);
}
disconnect_ref_callbacks (reference->model);
g_object_set_data (G_OBJECT (reference->proxy),
ROW_REF_DATA_STRING,
NULL);
}
g_object_unref (reference->proxy);
g_object_unref (reference->model);
if (reference->path)
gtk_tree_path_free (reference->path);
......
......@@ -992,7 +992,10 @@ gtk_tree_view_size_request_buttons (GtkTreeView *tree_view)
for (list = tree_view->priv->columns; list; list = list->next)
{
GtkRequisition requisition;
GtkTreeViewColumn *column;
GtkTreeViewColumn *column = list->data;
if (column->button == NULL)
continue;
column = list->data;
......@@ -1215,10 +1218,7 @@ gtk_tree_view_button_press (GtkWidget *widget,
for (i = 0, list = tree_view->priv->columns; i < tree_view->priv->n_columns; i++, list = list->next)
{
GtkCellRenderer *cell;
GtkTreeIter iter;
gboolean visible;
gboolean can_activate;
column = list->data;
......@@ -1238,8 +1238,6 @@ gtk_tree_view_button_press (GtkWidget *widget,
cell_area = background_area;
}
cell = column->cell;
if ((background_area.x > (gint) event->x) ||
(background_area.y > (gint) event->y) ||
(background_area.x + background_area.width <= (gint) event->x) ||
......@@ -1252,22 +1250,17 @@ gtk_tree_view_button_press (GtkWidget *widget,
gtk_tree_model_get_iter (tree_view->priv->model,
&iter,
path);
gtk_tree_view_column_set_cell_data (column,
tree_view->priv->model,
&iter);
gtk_tree_view_column_cell_set_cell_data (column,
tree_view->priv->model,
&iter);
path_string = gtk_tree_path_to_string (path);
g_object_get (G_OBJECT (cell),
"visible", &visible,
"can_activate", &can_activate,
NULL);
if (visible &&
can_activate &&
gtk_cell_renderer_event (cell, (GdkEvent *)event,
widget, path_string,
&background_area,
&cell_area, 0))
if (gtk_tree_view_column_cell_event (column,
(GdkEvent *)event,
path_string,
&background_area,
&cell_area, 0))
{
g_free (path_string);
gtk_tree_path_free (path);
......@@ -2124,7 +2117,7 @@ gtk_tree_view_draw_focus (GtkWidget *widget)
cell_area.height = CELL_HEIGHT (node, vertical_separator);
gtk_tree_model_get_iter (tree_view->priv->model, &iter, cursor_path);
gtk_tree_view_column_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_cell_renderer_get_size (tree_view->priv->focus_column->cell, GTK_WIDGET (tree_view), &cell_area, &x_offset, &y_offset, &width, &height);
width += 2;
......@@ -2161,7 +2154,6 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
GtkRBNode *drag_highlight = NULL;
GtkRBTree *drag_highlight_tree = NULL;
GtkTreeIter iter;
GtkCellRenderer *cell;
gint new_y;
gint y_offset, x_offset, cell_offset;
gint i, max_height;
......@@ -2244,11 +2236,6 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
do
{
/* Need to think about this more.
if (tree_view->priv->show_expanders)
max_height = MAX (TREE_VIEW_EXPANDER_MIN_HEIGHT, GTK_RBNODE_GET_HEIGHT (node));
else
*/
gboolean parity;
max_height = BACKGROUND_HEIGHT (node);
......@@ -2264,11 +2251,11 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_PRELIT))
flags |= GTK_CELL_RENDERER_PRELIT;
parity = _gtk_rbtree_node_find_parity (tree, node);
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
flags |= GTK_CELL_RENDERER_SELECTED;
parity = _gtk_rbtree_node_find_parity (tree, node);
for (i = 0, list = tree_view->priv->columns; i < tree_view->priv->n_columns; i++, list = list->next)
{
GtkTreeViewColumn *column = list->data;
......@@ -2289,10 +2276,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
else
flags &= ~GTK_CELL_RENDERER_SORTED;
cell = column->cell;
gtk_tree_view_column_set_cell_data (column,
tree_view->priv->model,
&iter);
gtk_tree_view_column_cell_set_cell_data (column,
tree_view->priv->model,
&iter);
background_area.x = cell_offset;
background_area.width = column->displayed_width;
......@@ -2363,8 +2349,6 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
if (i == tree_view->priv->expander_column &&
TREE_VIEW_DRAW_EXPANDERS(tree_view))
{
gboolean visible;
cell_area.x += depth*tree_view->priv->tab_offset;
cell_area.width -= depth*tree_view->priv->tab_offset;
......@@ -2374,16 +2358,12 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
*/
highlight_x = cell_area.x;
g_object_get (G_OBJECT (cell), "visible", &visible, NULL);
if (visible)
gtk_cell_renderer_render (cell,
event->window,
widget,
&background_area,
&cell_area,
&event->area,
flags);
gtk_tree_view_column_cell_render (column,
event->window,
&background_area,
&cell_area,
&event->area,
flags);
if ((node->flags & GTK_RBNODE_IS_PARENT) == GTK_RBNODE_IS_PARENT)
{
gint x, y;
......@@ -2396,17 +2376,12 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
}
else
{
gboolean visible;
g_object_get (G_OBJECT (cell), "visible", &visible, NULL);
if (visible)
gtk_cell_renderer_render (cell,
event->window,
widget,
&background_area,
&cell_area,
&event->area,
flags);
gtk_tree_view_column_cell_render (column,
event->window,
&background_area,
&cell_area,
&event->area,
flags);
}
cell_offset += column->displayed_width;
}
......@@ -2479,7 +2454,6 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
has_child = gtk_tree_model_iter_children (tree_view->priv->model,
&iter,
&parent);
cell = gtk_tree_view_get_column (tree_view, 0)->cell;
depth++;
/* Sanity Check! */
......@@ -2494,7 +2468,6 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
if (node != NULL)
{
gboolean has_next = gtk_tree_model_iter_next (tree_view->priv->model, &iter);
cell = gtk_tree_view_get_column (tree_view, 0)->cell;
done = TRUE;
/* Sanity Check! */
......@@ -4116,6 +4089,7 @@ gtk_tree_view_range_changed (GtkTreeModel *model,
gboolean free_path = FALSE;
gint vertical_separator;
g_return_if_fail (path != NULL || iter != NULL);
gtk_widget_style_get (GTK_WIDGET (data), "vertical_separator", &vertical_separator, NULL);
......@@ -4152,9 +4126,7 @@ gtk_tree_view_range_changed (GtkTreeModel *model,
if (dirty_marked)
gtk_widget_queue_resize (GTK_WIDGET (data));
else
{
gtk_tree_view_queue_draw_node (tree_view, tree, node, NULL);
}
gtk_tree_view_queue_draw_node (tree_view, tree, node, NULL);
done:
if (free_path)
......@@ -4663,7 +4635,6 @@ gtk_tree_view_insert_iter_height (GtkTreeView *tree_view,
gint depth)
{
GtkTreeViewColumn *column;
GtkCellRenderer *cell;
GList *list;
gint max_height = 0;
gint i;
......@@ -4687,10 +4658,9 @@ gtk_tree_view_insert_iter_height (GtkTreeView *tree_view,
continue;
}
cell = column->cell;
gtk_tree_view_column_set_cell_data (column, tree_view->priv->model, iter);
gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, iter);
gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, &height);
gtk_tree_view_column_cell_get_size (column, NULL, NULL, NULL, &width, &height);
max_height = MAX (max_height, vertical_separator + height);
if (i == tree_view->priv->expander_column &&
......@@ -4758,7 +4728,6 @@ gtk_tree_view_calc_size (GtkTreeView *tree_view,
{
GtkRBNode *temp;
GtkTreeIter child;
GtkCellRenderer *cell;
GList *list;
GtkTreeViewColumn *column;
gint max_height;
......@@ -4785,9 +4754,8 @@ gtk_tree_view_calc_size (GtkTreeView *tree_view,
if (!column->visible)
continue;
gtk_tree_view_column_set_cell_data (column, tree_view->priv->model, iter);
cell = column->cell;
gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, &height);
gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, iter);
gtk_tree_view_column_cell_get_size (column, NULL, NULL, NULL, &width, &height);
max_height = MAX (max_height, vertical_separator + height);
/* FIXME: I'm getting the width of all nodes here. )-: */
......@@ -4822,7 +4790,6 @@ gtk_tree_view_discover_dirty_iter (GtkTreeView *tree_view,
gint depth,
gint *height)
{
GtkCellRenderer *cell;
GtkTreeViewColumn *column;
GList *list;
gint i;
......@@ -4841,17 +4808,20 @@ gtk_tree_view_discover_dirty_iter (GtkTreeView *tree_view,
if (!column->visible)
continue;
cell = column->cell;
gtk_tree_view_column_set_cell_data (column, tree_view->priv->model, iter);
gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, iter);
if (height)
{
gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, &tmpheight);
gtk_tree_view_column_cell_get_size (column,
NULL, NULL, NULL,
&width, &tmpheight);
*height = MAX (*height, tmpheight);
}
else
{
gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, NULL);
gtk_tree_view_column_cell_get_size (column,
NULL, NULL, NULL,
&width, NULL);
}
if (i == tree_view->priv->expander_column &&
TREE_VIEW_DRAW_EXPANDERS (tree_view))
......@@ -5140,7 +5110,7 @@ gtk_tree_view_set_column_drag_info (GtkTreeView *tree_view,
GtkTreeViewColumn *column)
{
GtkTreeViewColumn *left_column;
GtkTreeViewColumn *cur_column;
GtkTreeViewColumn *cur_column = NULL;
GtkTreeViewColumnReorder *reorder;
GList *tmp_list;
......@@ -7548,9 +7518,9 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
continue;
cell = column->cell;
gtk_tree_view_column_set_cell_data (column,
tree_view->priv->model,
&iter);
gtk_tree_view_column_cell_set_cell_data (column,
tree_view->priv->model,
&iter);
background_area.x = cell_offset;
background_area.width = column->displayed_width;
......
......@@ -376,6 +376,11 @@ gtk_tree_view_column_set_property (GObject *object,
g_value_get_float (value));
break;
case PROP_REORDERABLE:
gtk_tree_view_column_set_reorderable (tree_column,
g_value_get_boolean (value));
break;
case PROP_SORT_INDICATOR:
gtk_tree_view_column_set_sort_indicator (tree_column,
g_value_get_boolean (value));
......@@ -454,6 +459,11 @@ gtk_tree_view_column_get_property (GObject *object,
gtk_tree_view_column_get_alignment (tree_column));
break;
case PROP_REORDERABLE:
g_value_set_boolean (value,
gtk_tree_view_column_get_reorderable (tree_column));
break;
case PROP_SORT_INDICATOR:
g_value_set_boolean (value,
gtk_tree_view_column_get_sort_indicator (tree_column));
......@@ -494,6 +504,8 @@ gtk_tree_view_column_create_button (GtkTreeViewColumn *tree_column)
/* make sure we own a reference to it as well. */
gtk_widget_set_parent (tree_column->button, GTK_WIDGET (tree_view));
if (tree_view->priv->header_window)
gtk_widget_set_parent_window (tree_column->button, tree_view->priv->header_window);
gtk_signal_connect (GTK_OBJECT (tree_column->button), "realize",
(GtkSignalFunc) gtk_tree_view_column_button_realize,
......@@ -643,7 +655,7 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
{
if (tree_column->visible)
{
gtk_widget_show (tree_column->button);
gtk_widget_show_now (tree_column->button);
if (tree_column->window)
{
if (tree_column->column_type == GTK_TREE_VIEW_COLUMN_RESIZEABLE)
......@@ -666,9 +678,15 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
}
if (tree_column->reorderable || tree_column->clickable)
GTK_WIDGET_SET_FLAGS (tree_column->button, GTK_CAN_FOCUS);
{
GTK_WIDGET_SET_FLAGS (tree_column->button, GTK_CAN_FOCUS);
}
else
GTK_WIDGET_UNSET_FLAGS (tree_column->button, GTK_CAN_FOCUS);
{
GTK_WIDGET_UNSET_FLAGS (tree_column->button, GTK_CAN_FOCUS);
if (GTK_WIDGET_HAS_FOCUS (tree_column->button))
gtk_window_set_focus (GTK_WINDOW (gtk_widget_get_toplevel (tree_column->tree_view)), NULL);
}
tree_column->dirty = TRUE;
gtk_widget_queue_resize (tree_column->tree_view);
......@@ -1253,55 +1271,6 @@ gtk_tree_view_column_clear_attributes (GtkTreeViewColumn *tree_column)
}
}
/**
* gtk_tree_view_column_set_cell_data:
* @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.
*
* 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
* column on the @tree_node, and use that value to set the attribute on the cell
* renderer.
**/
void
gtk_tree_view_column_set_cell_data (GtkTreeViewColumn *tree_column,
GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GSList *list;
GValue value = { 0, };
GObject *cell;
g_return_if_fail (tree_column != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
g_return_if_fail (tree_column->cell != NULL);
if (tree_model == NULL)
return;
cell = (GObject *) tree_column->cell;
list = tree_column->attributes;
g_object_freeze_notify (cell);
while (list && list->next)
{
gtk_tree_model_get_value (tree_model, iter,
GPOINTER_TO_INT (list->next->data),
&value);
g_object_set_property (cell, (gchar *) list->data, &value);
g_value_unset (&value);
list = list->next->next;
}
if (tree_column->func)
(* tree_column->func) (tree_column, tree_column->cell, tree_model, iter, tree_column->func_data);
g_object_thaw_notify (cell);
}
/* Options for manipulating the columns */
/**
......@@ -1916,3 +1885,162 @@ gtk_tree_view_column_get_sort_order (GtkTreeViewColumn *tree_column)
/**
* gtk_tree_view_column_cell_set_cell_data:
* @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.
*
* 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
* column on the @tree_node, and use that value to set the attribute on the cell
* renderer. This is used primarily by the GtkTreeView.
**/
void
gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GSList *list;
GValue value = { 0, };
GObject *cell;
g_return_if_fail (tree_column != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
g_return_if_fail (tree_column->cell != NULL);
if (tree_model == NULL)
return;
cell = (GObject *) tree_column->cell;
list = tree_column->attributes;
g_object_freeze_notify (cell);
while (list && list->next)
{
gtk_tree_model_get_value (tree_model, iter,
GPOINTER_TO_INT (list->next->data),
&value);
g_object_set_property (cell, (gchar *) list->data, &value);