mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
You can now set all sorts of properties in any order you wan, whether or
Tue May 15 20:13:24 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtktreeviewcolumn.c: You can now set all sorts of properties in any order you wan, whether or not the column is added to the tree, or the tree is realized. Yay! * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_setup_sort_column_id_callback): handle sorting columns a lot saner * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_reorderable): new function to actually set wether or not a column is reorderable. * gtk/gtktreeview.c (gtk_tree_view_unrealize): Only destroy things if we have 'em. * gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_set_tree_view): Fix nasty bug where we were showing the button just before realizing it. As a result, the parent window was tree_view->window instead of tree_view->priv->header_window. * gtk/gtktreeview.c (gtk_tree_view_set_reorderable): new property to let you easily reorder a list or tree.
This commit is contained in:
parent
8b33cffe23
commit
2970a2feee
25
ChangeLog
25
ChangeLog
@ -1,3 +1,28 @@
|
||||
Tue May 15 20:13:24 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c: You can now set all sorts of properties
|
||||
in any order you wan, whether or not the column is added to the
|
||||
tree, or the tree is realized. Yay!
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_setup_sort_column_id_callback): handle
|
||||
sorting columns a lot saner
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_reorderable):
|
||||
new function to actually set wether or not a column is
|
||||
reorderable.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_unrealize): Only destroy things
|
||||
if we have 'em.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_set_tree_view):
|
||||
Fix nasty bug where we were showing the button just before
|
||||
realizing it. As a result, the parent window was
|
||||
tree_view->window instead of tree_view->priv->header_window.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_set_reorderable): new property
|
||||
to let you easily reorder a list or tree.
|
||||
|
||||
2001-05-15 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkpacker.c: Apply patch from John Margaglione that converts
|
||||
|
@ -1,3 +1,28 @@
|
||||
Tue May 15 20:13:24 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c: You can now set all sorts of properties
|
||||
in any order you wan, whether or not the column is added to the
|
||||
tree, or the tree is realized. Yay!
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_setup_sort_column_id_callback): handle
|
||||
sorting columns a lot saner
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_reorderable):
|
||||
new function to actually set wether or not a column is
|
||||
reorderable.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_unrealize): Only destroy things
|
||||
if we have 'em.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_set_tree_view):
|
||||
Fix nasty bug where we were showing the button just before
|
||||
realizing it. As a result, the parent window was
|
||||
tree_view->window instead of tree_view->priv->header_window.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_set_reorderable): new property
|
||||
to let you easily reorder a list or tree.
|
||||
|
||||
2001-05-15 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkpacker.c: Apply patch from John Margaglione that converts
|
||||
|
@ -1,3 +1,28 @@
|
||||
Tue May 15 20:13:24 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c: You can now set all sorts of properties
|
||||
in any order you wan, whether or not the column is added to the
|
||||
tree, or the tree is realized. Yay!
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_setup_sort_column_id_callback): handle
|
||||
sorting columns a lot saner
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_reorderable):
|
||||
new function to actually set wether or not a column is
|
||||
reorderable.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_unrealize): Only destroy things
|
||||
if we have 'em.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_set_tree_view):
|
||||
Fix nasty bug where we were showing the button just before
|
||||
realizing it. As a result, the parent window was
|
||||
tree_view->window instead of tree_view->priv->header_window.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_set_reorderable): new property
|
||||
to let you easily reorder a list or tree.
|
||||
|
||||
2001-05-15 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkpacker.c: Apply patch from John Margaglione that converts
|
||||
|
@ -1,3 +1,28 @@
|
||||
Tue May 15 20:13:24 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c: You can now set all sorts of properties
|
||||
in any order you wan, whether or not the column is added to the
|
||||
tree, or the tree is realized. Yay!
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_setup_sort_column_id_callback): handle
|
||||
sorting columns a lot saner
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_reorderable):
|
||||
new function to actually set wether or not a column is
|
||||
reorderable.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_unrealize): Only destroy things
|
||||
if we have 'em.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_set_tree_view):
|
||||
Fix nasty bug where we were showing the button just before
|
||||
realizing it. As a result, the parent window was
|
||||
tree_view->window instead of tree_view->priv->header_window.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_set_reorderable): new property
|
||||
to let you easily reorder a list or tree.
|
||||
|
||||
2001-05-15 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkpacker.c: Apply patch from John Margaglione that converts
|
||||
|
@ -1,3 +1,28 @@
|
||||
Tue May 15 20:13:24 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c: You can now set all sorts of properties
|
||||
in any order you wan, whether or not the column is added to the
|
||||
tree, or the tree is realized. Yay!
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_setup_sort_column_id_callback): handle
|
||||
sorting columns a lot saner
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_reorderable):
|
||||
new function to actually set wether or not a column is
|
||||
reorderable.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_unrealize): Only destroy things
|
||||
if we have 'em.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_set_tree_view):
|
||||
Fix nasty bug where we were showing the button just before
|
||||
realizing it. As a result, the parent window was
|
||||
tree_view->window instead of tree_view->priv->header_window.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_set_reorderable): new property
|
||||
to let you easily reorder a list or tree.
|
||||
|
||||
2001-05-15 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkpacker.c: Apply patch from John Margaglione that converts
|
||||
|
@ -1,3 +1,28 @@
|
||||
Tue May 15 20:13:24 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c: You can now set all sorts of properties
|
||||
in any order you wan, whether or not the column is added to the
|
||||
tree, or the tree is realized. Yay!
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_setup_sort_column_id_callback): handle
|
||||
sorting columns a lot saner
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_reorderable):
|
||||
new function to actually set wether or not a column is
|
||||
reorderable.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_unrealize): Only destroy things
|
||||
if we have 'em.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_set_tree_view):
|
||||
Fix nasty bug where we were showing the button just before
|
||||
realizing it. As a result, the parent window was
|
||||
tree_view->window instead of tree_view->priv->header_window.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_set_reorderable): new property
|
||||
to let you easily reorder a list or tree.
|
||||
|
||||
2001-05-15 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkpacker.c: Apply patch from John Margaglione that converts
|
||||
|
@ -1,3 +1,28 @@
|
||||
Tue May 15 20:13:24 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c: You can now set all sorts of properties
|
||||
in any order you wan, whether or not the column is added to the
|
||||
tree, or the tree is realized. Yay!
|
||||
|
||||
* gtk/gtktreeviewcolumn.c
|
||||
(gtk_tree_view_column_setup_sort_column_id_callback): handle
|
||||
sorting columns a lot saner
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_reorderable):
|
||||
new function to actually set wether or not a column is
|
||||
reorderable.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_unrealize): Only destroy things
|
||||
if we have 'em.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_set_tree_view):
|
||||
Fix nasty bug where we were showing the button just before
|
||||
realizing it. As a result, the parent window was
|
||||
tree_view->window instead of tree_view->priv->header_window.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_set_reorderable): new property
|
||||
to let you easily reorder a list or tree.
|
||||
|
||||
2001-05-15 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gtk/gtkpacker.c: Apply patch from John Margaglione that converts
|
||||
|
@ -153,6 +153,7 @@ struct _GtkTreeViewPrivate
|
||||
gfloat scroll_to_row_align;
|
||||
gfloat scroll_to_col_align;
|
||||
|
||||
guint reorderable : 1;
|
||||
guint header_has_focus : 1;
|
||||
guint drag_column_window_state : 3;
|
||||
/* hint to display rows in alternating colors */
|
||||
@ -246,12 +247,13 @@ GtkTreePath *_gtk_tree_view_find_path (GtkTreeView *tree_v
|
||||
void _gtk_tree_view_update_size (GtkTreeView *tree_view);
|
||||
|
||||
|
||||
void _gtk_tree_view_column_create_button (GtkTreeViewColumn *column);
|
||||
void _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column);
|
||||
void _gtk_tree_view_column_unrealize_button (GtkTreeViewColumn *column);
|
||||
void _gtk_tree_view_column_set_tree_view (GtkTreeViewColumn *column,
|
||||
GtkTreeView *tree_view);
|
||||
void _gtk_tree_view_column_unset_tree_view (GtkTreeViewColumn *column);
|
||||
void _gtk_tree_view_column_set_width (GtkTreeViewColumn *column,
|
||||
gint width);
|
||||
void _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
|
||||
GtkTreeViewColumn *column);
|
||||
|
||||
|
@ -107,6 +107,7 @@ enum {
|
||||
PROP_HEADERS_VISIBLE,
|
||||
PROP_HEADERS_CLICKABLE,
|
||||
PROP_EXPANDER_COLUMN,
|
||||
PROP_REORDERABLE,
|
||||
PROP_RULES_HINT
|
||||
};
|
||||
|
||||
@ -424,6 +425,14 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
|
||||
0,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (o_class,
|
||||
PROP_REORDERABLE,
|
||||
g_param_spec_boolean ("reorderable",
|
||||
_("Reorderable"),
|
||||
_("View is reorderable"),
|
||||
FALSE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (o_class,
|
||||
PROP_RULES_HINT,
|
||||
g_param_spec_boolean ("rules_hint",
|
||||
@ -542,7 +551,7 @@ gtk_tree_view_init (GtkTreeView *tree_view)
|
||||
tree_view->priv->pressed_button = -1;
|
||||
tree_view->priv->press_start_x = -1;
|
||||
tree_view->priv->press_start_y = -1;
|
||||
|
||||
tree_view->priv->reorderable = FALSE;
|
||||
gtk_tree_view_set_adjustments (tree_view, NULL, NULL);
|
||||
_gtk_tree_view_update_size (tree_view);
|
||||
}
|
||||
@ -582,6 +591,9 @@ gtk_tree_view_set_property (GObject *object,
|
||||
case PROP_EXPANDER_COLUMN:
|
||||
gtk_tree_view_set_expander_column (tree_view, g_value_get_uint (value));
|
||||
break;
|
||||
case PROP_REORDERABLE:
|
||||
gtk_tree_view_set_reorderable (tree_view, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_RULES_HINT:
|
||||
gtk_tree_view_set_rules_hint (tree_view, g_value_get_boolean (value));
|
||||
break;
|
||||
@ -617,6 +629,9 @@ gtk_tree_view_get_property (GObject *object,
|
||||
case PROP_EXPANDER_COLUMN:
|
||||
g_value_set_uint (value, tree_view->priv->expander_column);
|
||||
break;
|
||||
case PROP_REORDERABLE:
|
||||
g_value_set_boolean (value, tree_view->priv->reorderable);
|
||||
break;
|
||||
case PROP_RULES_HINT:
|
||||
g_value_set_boolean (value, tree_view->priv->has_rules);
|
||||
break;
|
||||
@ -717,7 +732,7 @@ gtk_tree_view_destroy (GtkObject *object)
|
||||
/* GtkWidget Methods
|
||||
*/
|
||||
|
||||
/* GtkWidget:;map helper */
|
||||
/* GtkWidget::map helper */
|
||||
static void
|
||||
gtk_tree_view_map_buttons (GtkTreeView *tree_view)
|
||||
{
|
||||
@ -947,11 +962,19 @@ gtk_tree_view_unrealize (GtkWidget *widget)
|
||||
tree_view->priv->drag_highlight_window = NULL;
|
||||
}
|
||||
|
||||
gdk_cursor_destroy (tree_view->priv->cursor_drag);
|
||||
gdk_gc_destroy (tree_view->priv->xor_gc);
|
||||
if (tree_view->priv->cursor_drag)
|
||||
{
|
||||
gdk_cursor_destroy (tree_view->priv->cursor_drag);
|
||||
tree_view->priv->cursor_drag = NULL;
|
||||
}
|
||||
|
||||
if (tree_view->priv->xor_gc)
|
||||
{
|
||||
gdk_gc_destroy (tree_view->priv->xor_gc);
|
||||
tree_view->priv->xor_gc = NULL;
|
||||
}
|
||||
|
||||
/* GtkWidget::unrealize destroys children and widget->window */
|
||||
|
||||
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
|
||||
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
|
||||
}
|
||||
@ -975,7 +998,7 @@ gtk_tree_view_size_request_buttons (GtkTreeView *tree_view)
|
||||
|
||||
gtk_widget_size_request (column->button, &requisition);
|
||||
|
||||
gtk_tree_view_column_set_width (column, 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);
|
||||
}
|
||||
}
|
||||
@ -1391,7 +1414,7 @@ gtk_tree_view_button_release_column_resize (GtkWidget *widget,
|
||||
gdk_pointer_ungrab (event->time);
|
||||
|
||||
width = gtk_tree_view_new_column_width (GTK_TREE_VIEW (widget), i, &x);
|
||||
gtk_tree_view_column_set_width (gtk_tree_view_get_column (GTK_TREE_VIEW (widget), i), width);
|
||||
_gtk_tree_view_column_set_width (gtk_tree_view_get_column (GTK_TREE_VIEW (widget), i), width);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1862,7 +1885,7 @@ gtk_tree_view_motion_resize_column (GtkWidget *widget,
|
||||
new_width = gtk_tree_view_new_column_width (GTK_TREE_VIEW (widget),
|
||||
GTK_TREE_VIEW (widget)->priv->drag_pos, &x);
|
||||
if (x != GTK_TREE_VIEW (widget)->priv->x_drag)
|
||||
gtk_tree_view_column_set_width (gtk_tree_view_get_column (GTK_TREE_VIEW (widget), GTK_TREE_VIEW (widget)->priv->drag_pos), new_width);
|
||||
_gtk_tree_view_column_set_width (gtk_tree_view_get_column (GTK_TREE_VIEW (widget), GTK_TREE_VIEW (widget)->priv->drag_pos), new_width);
|
||||
|
||||
/* FIXME: Do we need to scroll */
|
||||
_gtk_tree_view_update_size (GTK_TREE_VIEW (widget));
|
||||
@ -4672,10 +4695,10 @@ gtk_tree_view_insert_iter_height (GtkTreeView *tree_view,
|
||||
|
||||
if (i == tree_view->priv->expander_column &&
|
||||
TREE_VIEW_DRAW_EXPANDERS (tree_view))
|
||||
gtk_tree_view_column_set_width (column,
|
||||
_gtk_tree_view_column_set_width (column,
|
||||
MAX (column->width, depth * tree_view->priv->tab_offset + width));
|
||||
else
|
||||
gtk_tree_view_column_set_width (column,
|
||||
_gtk_tree_view_column_set_width (column,
|
||||
MAX (column->width, width));
|
||||
|
||||
++i;
|
||||
@ -4777,10 +4800,10 @@ gtk_tree_view_calc_size (GtkTreeView *tree_view,
|
||||
}
|
||||
if (i == tree_view->priv->expander_column &&
|
||||
TREE_VIEW_DRAW_EXPANDERS (tree_view))
|
||||
gtk_tree_view_column_set_width (column,
|
||||
_gtk_tree_view_column_set_width (column,
|
||||
MAX (column->width, depth * tree_view->priv->tab_offset + width));
|
||||
else
|
||||
gtk_tree_view_column_set_width (column, MAX (column->width, width));
|
||||
_gtk_tree_view_column_set_width (column, MAX (column->width, width));
|
||||
}
|
||||
|
||||
_gtk_rbtree_node_set_height (tree, temp, max_height);
|
||||
@ -4924,7 +4947,7 @@ gtk_tree_view_check_dirty (GtkTreeView *tree_view)
|
||||
if (column->button)
|
||||
w = MAX (w, column->button->requisition.width);
|
||||
|
||||
gtk_tree_view_column_set_width (column, w);
|
||||
_gtk_tree_view_column_set_width (column, w);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5141,12 +5164,14 @@ gtk_tree_view_set_column_drag_info (GtkTreeView *tree_view,
|
||||
if (cur_column->visible == FALSE)
|
||||
continue;
|
||||
|
||||
if (tree_view->priv->column_drop_func &&
|
||||
(* tree_view->priv->column_drop_func) (tree_view, column, left_column, cur_column, tree_view->priv->column_drop_func_data))
|
||||
/* If it's not the column moving and func tells us to skip over the column, we continue. */
|
||||
if (left_column != column && cur_column != column &&
|
||||
tree_view->priv->column_drop_func &&
|
||||
! (* tree_view->priv->column_drop_func) (tree_view, column, left_column, cur_column, tree_view->priv->column_drop_func_data))
|
||||
{
|
||||
left_column = cur_column;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
reorder = g_new (GtkTreeViewColumnReorder, 1);
|
||||
reorder->left_column = left_column;
|
||||
left_column = reorder->right_column = cur_column;
|
||||
@ -5155,12 +5180,35 @@ gtk_tree_view_set_column_drag_info (GtkTreeView *tree_view,
|
||||
}
|
||||
|
||||
/* Add the last one */
|
||||
reorder = g_new (GtkTreeViewColumnReorder, 1);
|
||||
reorder->left_column = left_column;
|
||||
reorder->right_column = NULL;
|
||||
tree_view->priv->column_drag_info = g_list_append (tree_view->priv->column_drag_info, reorder);
|
||||
if (tree_view->priv->column_drop_func == NULL ||
|
||||
((left_column != column) &&
|
||||
(* tree_view->priv->column_drop_func) (tree_view, column, left_column, cur_column, tree_view->priv->column_drop_func_data)))
|
||||
{
|
||||
reorder = g_new (GtkTreeViewColumnReorder, 1);
|
||||
reorder->left_column = left_column;
|
||||
reorder->right_column = NULL;
|
||||
tree_view->priv->column_drag_info = g_list_append (tree_view->priv->column_drag_info, reorder);
|
||||
}
|
||||
|
||||
/* Now we want to fill in the ranges for the columns, now that we've isolated them */
|
||||
/* We quickly check to see if it even makes sense to reorder columns. */
|
||||
/* If there is nothing that can be moved, then we return */
|
||||
|
||||
if (tree_view->priv->column_drag_info == NULL)
|
||||
return;
|
||||
|
||||
/* We know there are always 2 slots possbile, as you can always return column. */
|
||||
/* If that's all there is, return */
|
||||
if (tree_view->priv->column_drag_info->next->next == NULL &&
|
||||
((GtkTreeViewColumnReorder *)tree_view->priv->column_drag_info->data)->right_column == column &&
|
||||
((GtkTreeViewColumnReorder *)tree_view->priv->column_drag_info->next->data)->left_column == column)
|
||||
{
|
||||
for (tmp_list = tree_view->priv->column_drag_info; tmp_list; tmp_list = tmp_list->next)
|
||||
g_free (tmp_list->data);
|
||||
g_list_free (tree_view->priv->column_drag_info);
|
||||
tree_view->priv->column_drag_info = NULL;
|
||||
return;
|
||||
}
|
||||
/* We fill in the ranges for the columns, now that we've isolated them */
|
||||
left = - TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER (tree_view);
|
||||
|
||||
for (tmp_list = tree_view->priv->column_drag_info; tmp_list; tmp_list = tmp_list->next)
|
||||
@ -5991,14 +6039,13 @@ gtk_tree_view_remove_column (GtkTreeView *tree_view,
|
||||
|
||||
tree_view->priv->columns = g_list_remove (tree_view->priv->columns, column);
|
||||
|
||||
g_object_unref (G_OBJECT (column));
|
||||
|
||||
tree_view->priv->n_columns--;
|
||||
|
||||
if (GTK_WIDGET_REALIZED (tree_view))
|
||||
{
|
||||
GList *list;
|
||||
|
||||
_gtk_tree_view_column_unrealize_button (column);
|
||||
for (list = tree_view->priv->columns; list; list = list->next)
|
||||
{
|
||||
column = GTK_TREE_VIEW_COLUMN (list->data);
|
||||
@ -6013,7 +6060,9 @@ gtk_tree_view_remove_column (GtkTreeView *tree_view,
|
||||
gtk_widget_queue_resize (GTK_WIDGET (tree_view));
|
||||
}
|
||||
|
||||
g_object_unref (G_OBJECT (column));
|
||||
g_signal_emit (G_OBJECT (tree_view), tree_view_signals[COLUMNS_CHANGED], 0);
|
||||
|
||||
return tree_view->priv->n_columns;
|
||||
}
|
||||
|
||||
@ -6048,16 +6097,16 @@ gtk_tree_view_insert_column (GtkTreeView *tree_view,
|
||||
|
||||
tree_view->priv->columns = g_list_insert (tree_view->priv->columns,
|
||||
column, position);
|
||||
_gtk_tree_view_column_set_tree_view (column, tree_view);
|
||||
_gtk_tree_view_column_create_button (column);
|
||||
|
||||
tree_view->priv->n_columns++;
|
||||
|
||||
_gtk_tree_view_column_set_tree_view (column, tree_view);
|
||||
|
||||
if (GTK_WIDGET_REALIZED (tree_view))
|
||||
{
|
||||
GList *list;
|
||||
|
||||
_gtk_tree_view_column_realize_button (column);
|
||||
|
||||
for (list = tree_view->priv->columns; list; list = list->next)
|
||||
{
|
||||
column = GTK_TREE_VIEW_COLUMN (list->data);
|
||||
@ -6718,6 +6767,50 @@ gtk_tree_view_map_expanded_rows (GtkTreeView *tree_view,
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
static GtkTargetEntry row_targets[] = {
|
||||
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 }
|
||||
};
|
||||
|
||||
/**
|
||||
* gtk_tree_view_set_reorderable:
|
||||
* @tree_view: A #GtkTreeView.
|
||||
* @reorderable: TRUE, if the tree can be reordered.
|
||||
*
|
||||
* This function is a convenience function to allow you to reorder models that
|
||||
* support the #GtkDragSourceIface and the #GtkDragDestIface. Both
|
||||
* #GtkTreeStore and #GtkListStore support these. If @reorderable is TRUE, then
|
||||
* the user can reorder the model by dragging and dropping columns. The
|
||||
* developer will can listen to these changes by connecting to the model's
|
||||
* signals.
|
||||
*
|
||||
* This function does not give you any degree of control over the order -- any
|
||||
* reorderering is allowed. If more control is needed, you should probably
|
||||
* handle drag and drop manually.
|
||||
**/
|
||||
void
|
||||
gtk_tree_view_set_reorderable (GtkTreeView *tree_view,
|
||||
gboolean reorderable)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
|
||||
|
||||
if (tree_view->priv->reorderable == (reorderable?TRUE:FALSE))
|
||||
return;
|
||||
|
||||
gtk_tree_view_set_rows_drag_source (tree_view,
|
||||
GDK_BUTTON1_MASK,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
GDK_ACTION_MOVE,
|
||||
NULL, NULL);
|
||||
gtk_tree_view_set_rows_drag_dest (tree_view,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
GDK_ACTION_MOVE,
|
||||
NULL, NULL);
|
||||
|
||||
g_object_notify (G_OBJECT (tree_view), "reorderable");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_tree_view_get_path_at_pos:
|
||||
@ -7258,14 +7351,17 @@ gtk_tree_view_get_dest_row_at_pos (GtkTreeView *tree_view,
|
||||
*/
|
||||
|
||||
g_return_val_if_fail (tree_view != NULL, FALSE);
|
||||
g_return_val_if_fail (tree_view->priv->tree != NULL, FALSE);
|
||||
g_return_val_if_fail (drag_x >= 0, FALSE);
|
||||
g_return_val_if_fail (drag_y >= 0, FALSE);
|
||||
g_return_val_if_fail (tree_view->priv->bin_window != NULL, FALSE);
|
||||
|
||||
|
||||
if (path)
|
||||
*path = NULL;
|
||||
|
||||
if (tree_view->priv->tree == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* remember that drag_x and drag_y are in widget coords, convert to tree window */
|
||||
|
||||
gtk_tree_view_widget_to_tree_coords (tree_view, drag_x, drag_y,
|
||||
|
@ -173,6 +173,9 @@ gboolean gtk_tree_view_collapse_row (GtkTreeView
|
||||
void gtk_tree_view_map_expanded_rows (GtkTreeView *tree_view,
|
||||
GtkTreeViewMappingFunc func,
|
||||
gpointer data);
|
||||
void gtk_tree_view_set_reorderable (GtkTreeView *tree_view,
|
||||
gboolean reorderable);
|
||||
|
||||
|
||||
/* Layout information */
|
||||
gboolean gtk_tree_view_get_path_at_pos (GtkTreeView *tree_view,
|
||||
@ -221,6 +224,7 @@ void gtk_tree_view_set_rows_drag_dest (GtkTreeView
|
||||
void gtk_tree_view_unset_rows_drag_source (GtkTreeView *tree_view);
|
||||
void gtk_tree_view_unset_rows_drag_dest (GtkTreeView *tree_view);
|
||||
|
||||
|
||||
/* These are useful to implement your own custom stuff. */
|
||||
void gtk_tree_view_set_drag_dest_row (GtkTreeView *tree_view,
|
||||
GtkTreePath *path,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -63,9 +63,11 @@ struct _GtkTreeViewColumn
|
||||
GtkWidget *alignment;
|
||||
GdkWindow *window;
|
||||
gfloat xalign;
|
||||
guint model_changed_signal;
|
||||
guint property_changed_signal;
|
||||
guint clickable_signal;
|
||||
|
||||
gint width;
|
||||
gint requested_width;
|
||||
gint min_width;
|
||||
gint max_width;
|
||||
gint displayed_width;
|
||||
@ -88,12 +90,12 @@ struct _GtkTreeViewColumn
|
||||
gint sort_column_id;
|
||||
GtkTreeSortOrder sort_order;
|
||||
|
||||
guint visible : 1;
|
||||
guint button_active : 1;
|
||||
guint dirty : 1;
|
||||
guint visible : 1;
|
||||
guint clickable : 1;
|
||||
guint dirty : 1;
|
||||
guint show_sort_indicator : 1;
|
||||
guint maybe_reordered : 1;
|
||||
guint reorderable : 1;
|
||||
guint reorderable : 1;
|
||||
};
|
||||
|
||||
struct _GtkTreeViewColumnClass
|
||||
@ -150,7 +152,7 @@ void gtk_tree_view_column_set_title (GtkTreeViewColumn
|
||||
const gchar *title);
|
||||
G_CONST_RETURN gchar *gtk_tree_view_column_get_title (GtkTreeViewColumn *tree_column);
|
||||
void gtk_tree_view_column_set_clickable (GtkTreeViewColumn *tree_column,
|
||||
gboolean active);
|
||||
gboolean clickable);
|
||||
gboolean gtk_tree_view_column_get_clickable (GtkTreeViewColumn *tree_column);
|
||||
void gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column,
|
||||
GtkWidget *widget);
|
||||
@ -158,7 +160,9 @@ GtkWidget *gtk_tree_view_column_get_widget (GtkTreeViewColumn
|
||||
void gtk_tree_view_column_set_alignment (GtkTreeViewColumn *tree_column,
|
||||
gfloat xalign);
|
||||
gfloat gtk_tree_view_column_get_alignment (GtkTreeViewColumn *tree_column);
|
||||
|
||||
void gtk_tree_view_column_set_reorderable (GtkTreeViewColumn *tree_column,
|
||||
gboolean reorderable);
|
||||
gboolean gtk_tree_view_column_get_reorderable (GtkTreeViewColumn *tree_column);
|
||||
|
||||
/* You probably only want to use gtk_tree_view_column_set_sort_column_id. The
|
||||
* other sorting functions exist primarily to let others do their own custom sorting.
|
||||
|
@ -13,19 +13,26 @@ GtkWidget *sample_tree_view_bottom;
|
||||
static void
|
||||
add_clicked (GtkWidget *button, gpointer data)
|
||||
{
|
||||
static gint i = 0;
|
||||
|
||||
GtkTreeIter iter;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeSelection *selection;
|
||||
GtkCellRenderer *cell;
|
||||
static gint i = 0;
|
||||
gchar *label = g_strdup_printf ("Column %d", i);
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes (label, cell, "text", 0, NULL);
|
||||
gtk_tree_view_column_set_reorderable (column, TRUE);
|
||||
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_RESIZEABLE);
|
||||
gtk_tree_view_column_set_clickable (column, FALSE);
|
||||
gtk_list_store_append (GTK_LIST_STORE (left_tree_model), &iter);
|
||||
gtk_list_store_set (GTK_LIST_STORE (left_tree_model), &iter, 0, label, 1, column, -1);
|
||||
g_free (label);
|
||||
i++;
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (left_tree_view));
|
||||
gtk_tree_selection_select_iter (selection, &iter);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -89,8 +96,11 @@ add_left_clicked (GtkWidget *button, gpointer data)
|
||||
|
||||
gtk_list_store_remove (GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (data))), &iter);
|
||||
|
||||
/* Put it back on the left */
|
||||
gtk_list_store_append (GTK_LIST_STORE (left_tree_model), &iter);
|
||||
gtk_list_store_set (GTK_LIST_STORE (left_tree_model), &iter, 0, label, 1, column, -1);
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (left_tree_view));
|
||||
gtk_tree_selection_select_iter (selection, &iter);
|
||||
g_free (label);
|
||||
}
|
||||
|
||||
@ -113,6 +123,9 @@ add_right_clicked (GtkWidget *button, gpointer data)
|
||||
gtk_list_store_append (GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (data))), &iter);
|
||||
gtk_list_store_set (GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (data))), &iter, 0, label, 1, column, -1);
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data));
|
||||
gtk_tree_selection_select_iter (selection, &iter);
|
||||
|
||||
if (GTK_WIDGET (data) == top_right_tree_view)
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (sample_tree_view_top), column);
|
||||
else
|
||||
@ -129,6 +142,11 @@ selection_changed (GtkTreeSelection *selection, GtkWidget *button)
|
||||
gtk_widget_set_sensitive (button, FALSE);
|
||||
}
|
||||
|
||||
|
||||
static GtkTargetEntry row_targets[] = {
|
||||
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP, 0}
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -198,7 +216,7 @@ main (int argc, char *argv[])
|
||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (left_tree_view), -1,
|
||||
"Unattached Columns", cell, "text", 0, NULL);
|
||||
cell = gtk_cell_renderer_toggle_new ();
|
||||
g_signal_connect_data (G_OBJECT (cell), "toggled", set_visible, left_tree_view, NULL, FALSE, FALSE);
|
||||
g_signal_connect_data (G_OBJECT (cell), "toggled", (GCallback) set_visible, left_tree_view, NULL, FALSE, FALSE);
|
||||
column = gtk_tree_view_column_new_with_attributes ("Visible", cell, NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (left_tree_view), column);
|
||||
g_object_unref (G_OBJECT (column));
|
||||
@ -259,7 +277,7 @@ main (int argc, char *argv[])
|
||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (top_right_tree_view), -1,
|
||||
NULL, cell, "text", 0, NULL);
|
||||
cell = gtk_cell_renderer_toggle_new ();
|
||||
g_signal_connect_data (G_OBJECT (cell), "toggled", set_visible, top_right_tree_view, NULL, FALSE, FALSE);
|
||||
g_signal_connect_data (G_OBJECT (cell), "toggled", (GCallback) set_visible, top_right_tree_view, NULL, FALSE, FALSE);
|
||||
column = gtk_tree_view_column_new_with_attributes (NULL, cell, NULL);
|
||||
gtk_tree_view_column_set_cell_data_func (column, get_visible, NULL, NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (top_right_tree_view), column);
|
||||
@ -274,7 +292,7 @@ main (int argc, char *argv[])
|
||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (bottom_right_tree_view), -1,
|
||||
NULL, cell, "text", 0, NULL);
|
||||
cell = gtk_cell_renderer_toggle_new ();
|
||||
g_signal_connect_data (G_OBJECT (cell), "toggled", set_visible, bottom_right_tree_view, NULL, FALSE, FALSE);
|
||||
g_signal_connect_data (G_OBJECT (cell), "toggled", (GCallback) set_visible, bottom_right_tree_view, NULL, FALSE, FALSE);
|
||||
column = gtk_tree_view_column_new_with_attributes (NULL, cell, NULL);
|
||||
gtk_tree_view_column_set_cell_data_func (column, get_visible, NULL, NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (bottom_right_tree_view), column);
|
||||
@ -282,6 +300,44 @@ main (int argc, char *argv[])
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), swindow, TRUE, TRUE, 0);
|
||||
|
||||
|
||||
/* Drag and Drop */
|
||||
gtk_tree_view_set_rows_drag_source (GTK_TREE_VIEW (left_tree_view),
|
||||
GDK_BUTTON1_MASK,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
GDK_ACTION_MOVE,
|
||||
NULL, NULL);
|
||||
gtk_tree_view_set_rows_drag_dest (GTK_TREE_VIEW (left_tree_view),
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
GDK_ACTION_MOVE,
|
||||
NULL, NULL);
|
||||
|
||||
gtk_tree_view_set_rows_drag_source (GTK_TREE_VIEW (top_right_tree_view),
|
||||
GDK_BUTTON1_MASK,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
GDK_ACTION_MOVE,
|
||||
NULL, NULL);
|
||||
gtk_tree_view_set_rows_drag_dest (GTK_TREE_VIEW (top_right_tree_view),
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
GDK_ACTION_MOVE,
|
||||
NULL, NULL);
|
||||
|
||||
gtk_tree_view_set_rows_drag_source (GTK_TREE_VIEW (bottom_right_tree_view),
|
||||
GDK_BUTTON1_MASK,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
GDK_ACTION_MOVE,
|
||||
NULL, NULL);
|
||||
gtk_tree_view_set_rows_drag_dest (GTK_TREE_VIEW (bottom_right_tree_view),
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
GDK_ACTION_MOVE,
|
||||
NULL, NULL);
|
||||
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 8);
|
||||
|
Loading…
Reference in New Issue
Block a user