mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
Removed 'fill' attribute. It was silly b/c that was a property of the cell
Fri Sep 7 20:45:29 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_pack_{start,end}): Removed 'fill' attribute. It was silly b/c that was a property of the cell renderer, anyway. (gtk_tree_view_column_render): Actually render the packed renderers. * doc/tree-column-sizing.txt: initial devel documentation. * gtk/gtktreeview.c (gtk_tree_view_expand_all): Fix bug. * gtk/gtkcellrenderertextpixbuf.[ch]: removed. * tests/testtreefocus.c: fix up to reflect above changes. * tests/testtreeview.c: ditto * demos/gtk-demo/stock_browser.c: ditto
This commit is contained in:
parent
27401e1e46
commit
4a9a6249d0
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
||||
Fri Sep 7 20:45:29 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_pack_{start,end}):
|
||||
Removed 'fill' attribute. It was silly b/c that was a property of
|
||||
the cell renderer, anyway.
|
||||
(gtk_tree_view_column_render): Actually render the packed
|
||||
renderers.
|
||||
* doc/tree-column-sizing.txt: initial devel documentation.
|
||||
* gtk/gtktreeview.c (gtk_tree_view_expand_all): Fix bug.
|
||||
* gtk/gtkcellrenderertextpixbuf.[ch]: removed.
|
||||
|
||||
* tests/testtreefocus.c: fix up to reflect above changes.
|
||||
* tests/testtreeview.c: ditto
|
||||
* demos/gtk-demo/stock_browser.c: ditto
|
||||
|
||||
2001-09-07 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* gdk/linux-fb/gdkcolor-fb.c:
|
||||
|
@ -1,3 +1,18 @@
|
||||
Fri Sep 7 20:45:29 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_pack_{start,end}):
|
||||
Removed 'fill' attribute. It was silly b/c that was a property of
|
||||
the cell renderer, anyway.
|
||||
(gtk_tree_view_column_render): Actually render the packed
|
||||
renderers.
|
||||
* doc/tree-column-sizing.txt: initial devel documentation.
|
||||
* gtk/gtktreeview.c (gtk_tree_view_expand_all): Fix bug.
|
||||
* gtk/gtkcellrenderertextpixbuf.[ch]: removed.
|
||||
|
||||
* tests/testtreefocus.c: fix up to reflect above changes.
|
||||
* tests/testtreeview.c: ditto
|
||||
* demos/gtk-demo/stock_browser.c: ditto
|
||||
|
||||
2001-09-07 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* gdk/linux-fb/gdkcolor-fb.c:
|
||||
|
@ -1,3 +1,18 @@
|
||||
Fri Sep 7 20:45:29 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_pack_{start,end}):
|
||||
Removed 'fill' attribute. It was silly b/c that was a property of
|
||||
the cell renderer, anyway.
|
||||
(gtk_tree_view_column_render): Actually render the packed
|
||||
renderers.
|
||||
* doc/tree-column-sizing.txt: initial devel documentation.
|
||||
* gtk/gtktreeview.c (gtk_tree_view_expand_all): Fix bug.
|
||||
* gtk/gtkcellrenderertextpixbuf.[ch]: removed.
|
||||
|
||||
* tests/testtreefocus.c: fix up to reflect above changes.
|
||||
* tests/testtreeview.c: ditto
|
||||
* demos/gtk-demo/stock_browser.c: ditto
|
||||
|
||||
2001-09-07 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* gdk/linux-fb/gdkcolor-fb.c:
|
||||
|
@ -1,3 +1,18 @@
|
||||
Fri Sep 7 20:45:29 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_pack_{start,end}):
|
||||
Removed 'fill' attribute. It was silly b/c that was a property of
|
||||
the cell renderer, anyway.
|
||||
(gtk_tree_view_column_render): Actually render the packed
|
||||
renderers.
|
||||
* doc/tree-column-sizing.txt: initial devel documentation.
|
||||
* gtk/gtktreeview.c (gtk_tree_view_expand_all): Fix bug.
|
||||
* gtk/gtkcellrenderertextpixbuf.[ch]: removed.
|
||||
|
||||
* tests/testtreefocus.c: fix up to reflect above changes.
|
||||
* tests/testtreeview.c: ditto
|
||||
* demos/gtk-demo/stock_browser.c: ditto
|
||||
|
||||
2001-09-07 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* gdk/linux-fb/gdkcolor-fb.c:
|
||||
|
@ -1,3 +1,18 @@
|
||||
Fri Sep 7 20:45:29 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_pack_{start,end}):
|
||||
Removed 'fill' attribute. It was silly b/c that was a property of
|
||||
the cell renderer, anyway.
|
||||
(gtk_tree_view_column_render): Actually render the packed
|
||||
renderers.
|
||||
* doc/tree-column-sizing.txt: initial devel documentation.
|
||||
* gtk/gtktreeview.c (gtk_tree_view_expand_all): Fix bug.
|
||||
* gtk/gtkcellrenderertextpixbuf.[ch]: removed.
|
||||
|
||||
* tests/testtreefocus.c: fix up to reflect above changes.
|
||||
* tests/testtreeview.c: ditto
|
||||
* demos/gtk-demo/stock_browser.c: ditto
|
||||
|
||||
2001-09-07 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* gdk/linux-fb/gdkcolor-fb.c:
|
||||
|
@ -1,3 +1,18 @@
|
||||
Fri Sep 7 20:45:29 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_pack_{start,end}):
|
||||
Removed 'fill' attribute. It was silly b/c that was a property of
|
||||
the cell renderer, anyway.
|
||||
(gtk_tree_view_column_render): Actually render the packed
|
||||
renderers.
|
||||
* doc/tree-column-sizing.txt: initial devel documentation.
|
||||
* gtk/gtktreeview.c (gtk_tree_view_expand_all): Fix bug.
|
||||
* gtk/gtkcellrenderertextpixbuf.[ch]: removed.
|
||||
|
||||
* tests/testtreefocus.c: fix up to reflect above changes.
|
||||
* tests/testtreeview.c: ditto
|
||||
* demos/gtk-demo/stock_browser.c: ditto
|
||||
|
||||
2001-09-07 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* gdk/linux-fb/gdkcolor-fb.c:
|
||||
|
@ -1,3 +1,18 @@
|
||||
Fri Sep 7 20:45:29 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_pack_{start,end}):
|
||||
Removed 'fill' attribute. It was silly b/c that was a property of
|
||||
the cell renderer, anyway.
|
||||
(gtk_tree_view_column_render): Actually render the packed
|
||||
renderers.
|
||||
* doc/tree-column-sizing.txt: initial devel documentation.
|
||||
* gtk/gtktreeview.c (gtk_tree_view_expand_all): Fix bug.
|
||||
* gtk/gtkcellrenderertextpixbuf.[ch]: removed.
|
||||
|
||||
* tests/testtreefocus.c: fix up to reflect above changes.
|
||||
* tests/testtreeview.c: ditto
|
||||
* demos/gtk-demo/stock_browser.c: ditto
|
||||
|
||||
2001-09-07 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* gdk/linux-fb/gdkcolor-fb.c:
|
||||
|
@ -304,11 +304,11 @@ selection_changed (GtkTreeSelection *selection)
|
||||
}
|
||||
|
||||
static void
|
||||
macro_set_func (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
macro_set_func_text (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
StockItemInfo *info;
|
||||
|
||||
@ -318,6 +318,25 @@ macro_set_func (GtkTreeViewColumn *tree_column,
|
||||
|
||||
g_object_set (GTK_CELL_RENDERER (cell),
|
||||
"text", info->macro,
|
||||
NULL);
|
||||
|
||||
stock_item_info_free (info);
|
||||
}
|
||||
|
||||
static void
|
||||
macro_set_func_pixbuf (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
StockItemInfo *info;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
0, &info,
|
||||
-1);
|
||||
|
||||
g_object_set (GTK_CELL_RENDERER (cell),
|
||||
"pixbuf", info->small_icon,
|
||||
NULL);
|
||||
|
||||
@ -399,7 +418,8 @@ do_stock_browser (void)
|
||||
GtkCellRenderer *cell_renderer;
|
||||
StockItemDisplay *display;
|
||||
GtkTreeSelection *selection;
|
||||
|
||||
GtkTreeViewColumn *column;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Stock Icons and Items");
|
||||
|
||||
@ -423,15 +443,25 @@ do_stock_browser (void)
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (sw), treeview);
|
||||
|
||||
cell_renderer = gtk_cell_renderer_text_pixbuf_new ();
|
||||
column = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_set_title (column, "Macro");
|
||||
|
||||
cell_renderer = gtk_cell_renderer_pixbuf_new ();
|
||||
gtk_tree_view_column_pack_start (column,
|
||||
cell_renderer,
|
||||
FALSE);
|
||||
gtk_tree_view_column_set_cell_data_func (column, cell_renderer,
|
||||
macro_set_func_pixbuf, NULL, NULL);
|
||||
cell_renderer = gtk_cell_renderer_text_new ();
|
||||
gtk_tree_view_column_pack_start (column,
|
||||
cell_renderer,
|
||||
TRUE);
|
||||
gtk_tree_view_column_set_cell_data_func (column, cell_renderer,
|
||||
macro_set_func_text, NULL, NULL);
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview),
|
||||
column);
|
||||
|
||||
gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (treeview),
|
||||
-1,
|
||||
"Macro",
|
||||
cell_renderer,
|
||||
macro_set_func,
|
||||
NULL,
|
||||
NULL);
|
||||
cell_renderer = gtk_cell_renderer_text_new ();
|
||||
|
||||
gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (treeview),
|
||||
|
67
docs/tree-column-sizing.txt
Normal file
67
docs/tree-column-sizing.txt
Normal file
@ -0,0 +1,67 @@
|
||||
The way that the GtkTreeView calculates sizing is pretty confusing.
|
||||
This is written down to help keep track of it in my head, and thus help
|
||||
anyone who hopes to work with the code in the future.
|
||||
|
||||
HOW THE GTKTREEVIEW CALCULATES SIZE:
|
||||
====================================
|
||||
When the view is given a new model, the first thing it does is walk
|
||||
through the model at the top level, creating an GtkRBNode for each
|
||||
element of the model. Each node has a height of 0. The RBTree is kept
|
||||
updated as the models structure changes. Additionally, the user can
|
||||
expand, collapse, and select rows at this stage. The RBTree is accurate
|
||||
-- it just doesn't have a height for any row.
|
||||
|
||||
When the TreeView is realized, it calculates the actual height of each
|
||||
row by walking the tree and measuring them. While doing so, it gets the
|
||||
size of each column.
|
||||
|
||||
|
||||
|
||||
Columns are initially marked as 'dirty'. When sized,
|
||||
gtk_tree_view_check_dirty_and_clean () is called on each column. This
|
||||
function walks through all visible columns, and sees if they're dirty or
|
||||
not. If any are dirty, it then walks the tree, calling
|
||||
gtk_tree_view_calc_size on each row. gtk_tree_view_calc_size requests
|
||||
the size of every dirty column in the tree. Finally, it updates the
|
||||
size of the widget (including adjustments).
|
||||
|
||||
|
||||
HOW THE GTKTREEVIEWCOLUMN STORES SIZE:
|
||||
======================================
|
||||
|
||||
There are a number of size related fields in the GtkTreeViewColumn
|
||||
structure:
|
||||
|
||||
sizing The sizing method to use when calculating the size
|
||||
of the column. Can be grow_only, resizable, auto, and fixed.
|
||||
|
||||
requested_width The width of the column as requested by the column
|
||||
|
||||
width The actual width. This is requested width for all
|
||||
columns but possibly the last one.
|
||||
|
||||
fixed_width The requested fixed width for the column iff it's
|
||||
sizing type is set to GTK_TREE_VIEW_COLUMN_FIXED.
|
||||
|
||||
min_width The minimum width the column can be
|
||||
|
||||
max_width The maximum width the column can be. This can be
|
||||
overridden for the last column, if the tree_view is
|
||||
actually wider than the sum of all of the columns
|
||||
requested_widths.
|
||||
|
||||
The following invariants are true:
|
||||
|
||||
min_width is less than or equal to width
|
||||
|
||||
max_width is greater than or equal to width
|
||||
|
||||
(sizing == GTK_TREE_VIEW_COLUMN_FIXED) => (requested_width == fixed_width)
|
||||
|
||||
(column != last visible column) => width == requested_width
|
||||
|
||||
|
||||
/* Functions needed by gtktreeview for gtktreeviewcolumn */
|
||||
size_request_button
|
||||
set_width (for resizing resizable columns)
|
||||
calculate_width
|
@ -69,7 +69,6 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
|
||||
gtkcurve.h \
|
||||
gtkcellrenderer.h \
|
||||
gtkcellrenderertext.h \
|
||||
gtkcellrenderertextpixbuf.h \
|
||||
gtkcellrenderertoggle.h \
|
||||
gtkcellrendererpixbuf.h \
|
||||
gtkdebug.h \
|
||||
@ -216,7 +215,6 @@ gtk_c_sources = @STRIP_BEGIN@ \
|
||||
gtkcalendar.c \
|
||||
gtkcellrenderer.c \
|
||||
gtkcellrenderertext.c \
|
||||
gtkcellrenderertextpixbuf.c \
|
||||
gtkcellrenderertoggle.c \
|
||||
gtkcellrendererpixbuf.c \
|
||||
gtkcheckbutton.c \
|
||||
|
@ -1,443 +0,0 @@
|
||||
/* gtkcellrenderertextpixbuf.c
|
||||
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "gtkcellrenderertextpixbuf.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
enum {
|
||||
PROP_ZERO,
|
||||
PROP_PIXBUF_POS,
|
||||
PROP_PIXBUF,
|
||||
PROP_PIXBUF_XALIGN,
|
||||
PROP_PIXBUF_YALIGN,
|
||||
PROP_PIXBUF_XPAD,
|
||||
PROP_PIXBUF_YPAD
|
||||
};
|
||||
|
||||
|
||||
static void gtk_cell_renderer_text_pixbuf_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_text_pixbuf_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_text_pixbuf_init (GtkCellRendererTextPixbuf *celltextpixbuf);
|
||||
static void gtk_cell_renderer_text_pixbuf_class_init (GtkCellRendererTextPixbufClass *class);
|
||||
static void gtk_cell_renderer_text_pixbuf_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *view,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height);
|
||||
static void gtk_cell_renderer_text_pixbuf_render (GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *view,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
guint flags);
|
||||
|
||||
|
||||
static GtkCellRendererTextClass *parent_class = NULL;
|
||||
|
||||
|
||||
GtkType
|
||||
gtk_cell_renderer_text_pixbuf_get_type (void)
|
||||
{
|
||||
static GtkType cell_text_pixbuf_type = 0;
|
||||
|
||||
if (!cell_text_pixbuf_type)
|
||||
{
|
||||
static const GTypeInfo cell_text_pixbuf_info =
|
||||
{
|
||||
sizeof (GtkCellRendererTextPixbufClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gtk_cell_renderer_text_pixbuf_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GtkCellRendererTextPixbuf),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gtk_cell_renderer_text_pixbuf_init,
|
||||
};
|
||||
|
||||
cell_text_pixbuf_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TEXT, "GtkCellRendererTextPixbuf", &cell_text_pixbuf_info, 0);
|
||||
}
|
||||
|
||||
return cell_text_pixbuf_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_text_pixbuf_init (GtkCellRendererTextPixbuf *celltextpixbuf)
|
||||
{
|
||||
celltextpixbuf->pixbuf = GTK_CELL_RENDERER_PIXBUF (gtk_cell_renderer_pixbuf_new ());
|
||||
celltextpixbuf->pixbuf_pos = GTK_POS_LEFT;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_text_pixbuf_class_init (GtkCellRendererTextPixbufClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
object_class->get_property = gtk_cell_renderer_text_pixbuf_get_property;
|
||||
object_class->set_property = gtk_cell_renderer_text_pixbuf_set_property;
|
||||
|
||||
cell_class->get_size = gtk_cell_renderer_text_pixbuf_get_size;
|
||||
cell_class->render = gtk_cell_renderer_text_pixbuf_render;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PIXBUF_POS,
|
||||
g_param_spec_int ("pixbuf_pos",
|
||||
_("Pixbuf location"),
|
||||
_("The relative location of the pixbuf to the text."),
|
||||
GTK_POS_LEFT,
|
||||
GTK_POS_BOTTOM,
|
||||
GTK_POS_LEFT,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PIXBUF,
|
||||
g_param_spec_object ("pixbuf",
|
||||
_("Pixbuf Object"),
|
||||
_("The pixbuf to render."),
|
||||
GDK_TYPE_PIXBUF,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PIXBUF_XALIGN,
|
||||
g_param_spec_float ("pixbuf_xalign",
|
||||
_("pixbuf xalign"),
|
||||
_("The x-align of the pixbuf."),
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PIXBUF_YALIGN,
|
||||
g_param_spec_float ("pixbuf_yalign",
|
||||
_("pixbuf yalign"),
|
||||
_("The y-align of the pixbuf."),
|
||||
0.0,
|
||||
1.0,
|
||||
0.5,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PIXBUF_XPAD,
|
||||
g_param_spec_uint ("pixbuf_xpad",
|
||||
_("pixbuf xpad"),
|
||||
_("The xpad of the pixbuf."),
|
||||
0,
|
||||
100,
|
||||
2,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_PIXBUF_YPAD,
|
||||
g_param_spec_uint ("pixbuf_ypad",
|
||||
_("pixbuf ypad"),
|
||||
_("The ypad of the pixbuf."),
|
||||
0,
|
||||
100,
|
||||
2,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_WRITABLE));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_text_pixbuf_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkCellRendererTextPixbuf *celltextpixbuf = GTK_CELL_RENDERER_TEXT_PIXBUF (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_PIXBUF_POS:
|
||||
g_value_set_int (value, celltextpixbuf->pixbuf_pos);
|
||||
break;
|
||||
case PROP_PIXBUF:
|
||||
g_object_get_property (G_OBJECT (celltextpixbuf->pixbuf),
|
||||
"pixbuf",
|
||||
value);
|
||||
break;
|
||||
case PROP_PIXBUF_XALIGN:
|
||||
g_object_get_property (G_OBJECT (celltextpixbuf->pixbuf),
|
||||
"xalign",
|
||||
value);
|
||||
break;
|
||||
case PROP_PIXBUF_YALIGN:
|
||||
g_object_get_property (G_OBJECT (celltextpixbuf->pixbuf),
|
||||
"yalign",
|
||||
value);
|
||||
break;
|
||||
case PROP_PIXBUF_XPAD:
|
||||
g_object_get_property (G_OBJECT (celltextpixbuf->pixbuf),
|
||||
"xpad",
|
||||
value);
|
||||
break;
|
||||
case PROP_PIXBUF_YPAD:
|
||||
g_object_get_property (G_OBJECT (celltextpixbuf->pixbuf),
|
||||
"ypad",
|
||||
value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_text_pixbuf_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkCellRendererTextPixbuf *celltextpixbuf = GTK_CELL_RENDERER_TEXT_PIXBUF (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_PIXBUF:
|
||||
g_object_set_property (G_OBJECT (celltextpixbuf->pixbuf),
|
||||
"pixbuf",
|
||||
value);
|
||||
g_object_notify (G_OBJECT(object), "pixbuf");
|
||||
break;
|
||||
case PROP_PIXBUF_POS:
|
||||
celltextpixbuf->pixbuf_pos = g_value_get_int (value);
|
||||
g_object_notify (G_OBJECT(object), "pixbuf_pos");
|
||||
break;
|
||||
case PROP_PIXBUF_XALIGN:
|
||||
g_object_set_property (G_OBJECT (celltextpixbuf->pixbuf),
|
||||
"xalign",
|
||||
value);
|
||||
g_object_notify (G_OBJECT(object), "pixbuf_xalign");
|
||||
break;
|
||||
case PROP_PIXBUF_YALIGN:
|
||||
g_object_set_property (G_OBJECT (celltextpixbuf->pixbuf),
|
||||
"yalign",
|
||||
value);
|
||||
g_object_notify (G_OBJECT(object), "pixbuf_yalign");
|
||||
break;
|
||||
case PROP_PIXBUF_XPAD:
|
||||
g_object_set_property (G_OBJECT (celltextpixbuf->pixbuf),
|
||||
"xpad",
|
||||
value);
|
||||
g_object_notify (G_OBJECT(object), "pixbuf_xpad");
|
||||
break;
|
||||
case PROP_PIXBUF_YPAD:
|
||||
g_object_set_property (G_OBJECT (celltextpixbuf->pixbuf),
|
||||
"ypad",
|
||||
value);
|
||||
g_object_notify (G_OBJECT(object), "pixbuf_ypad");
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_cell_renderer_text_pixbuf_new:
|
||||
*
|
||||
* Creates a new #GtkCellRendererTextPixbuf. Adjust rendering
|
||||
* parameters using object properties. Object properties can be set
|
||||
* globally (with g_object_set()). Also, with #GtkTreeViewColumn, you
|
||||
* can bind a property to a value in a #GtkTreeModel. For example, you
|
||||
* can bind the "text" property on the cell renderer to a string value
|
||||
* in the model, thus rendering a different string in each row of the
|
||||
* #GtkTreeView
|
||||
*
|
||||
* Return value: the new cell renderer
|
||||
**/
|
||||
GtkCellRenderer *
|
||||
gtk_cell_renderer_text_pixbuf_new (void)
|
||||
{
|
||||
return GTK_CELL_RENDERER (gtk_type_new (gtk_cell_renderer_text_pixbuf_get_type ()));
|
||||
}
|
||||
|
||||
typedef void (* CellSizeFunc) (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *rectangle,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height);
|
||||
typedef void (* CellRenderFunc) (GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
guint flags);
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_text_pixbuf_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GtkCellRendererTextPixbuf *celltextpixbuf = (GtkCellRendererTextPixbuf *)cell;
|
||||
gint pixbuf_width;
|
||||
gint pixbuf_height;
|
||||
gint text_width;
|
||||
gint text_height;
|
||||
gint calc_width;
|
||||
gint calc_height;
|
||||
|
||||
(* GTK_CELL_RENDERER_CLASS (parent_class)->get_size) (cell, widget, NULL, NULL, NULL, &text_width, &text_height);
|
||||
(* GTK_CELL_RENDERER_CLASS (G_OBJECT_GET_CLASS (celltextpixbuf->pixbuf))->get_size) (GTK_CELL_RENDERER (celltextpixbuf->pixbuf),
|
||||
widget,
|
||||
NULL, NULL, NULL,
|
||||
&pixbuf_width,
|
||||
&pixbuf_height);
|
||||
if (celltextpixbuf->pixbuf_pos == GTK_POS_LEFT ||
|
||||
celltextpixbuf->pixbuf_pos == GTK_POS_RIGHT)
|
||||
{
|
||||
calc_width = pixbuf_width + text_width;
|
||||
calc_height = MAX (pixbuf_height, text_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
calc_width = MAX (pixbuf_width, text_width);
|
||||
calc_height = pixbuf_height + text_height;
|
||||
}
|
||||
|
||||
if (width)
|
||||
*width = calc_width;
|
||||
if (height)
|
||||
*height = calc_height;
|
||||
|
||||
if (cell_area)
|
||||
{
|
||||
if (x_offset)
|
||||
{
|
||||
*x_offset = cell->xalign * (cell_area->width - calc_width - (2 * cell->xpad));
|
||||
*x_offset = MAX (*x_offset, 0) + cell->xpad;
|
||||
}
|
||||
if (y_offset)
|
||||
{
|
||||
*y_offset = cell->yalign * (cell_area->height - calc_height - (2 * cell->ypad));
|
||||
*y_offset = MAX (*y_offset, 0) + cell->ypad;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_text_pixbuf_render (GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
guint flags)
|
||||
|
||||
{
|
||||
GtkCellRendererTextPixbuf *celltextpixbuf = (GtkCellRendererTextPixbuf *) cell;
|
||||
CellSizeFunc size_func1, size_func2;
|
||||
CellRenderFunc render_func1, render_func2;
|
||||
GtkCellRenderer *cell1, *cell2;
|
||||
gint tmp_width;
|
||||
gint tmp_height;
|
||||
GdkRectangle real_cell_area;
|
||||
|
||||
if (celltextpixbuf->pixbuf_pos == GTK_POS_LEFT ||
|
||||
celltextpixbuf->pixbuf_pos == GTK_POS_TOP)
|
||||
{
|
||||
size_func1 = GTK_CELL_RENDERER_CLASS (G_OBJECT_GET_CLASS (celltextpixbuf->pixbuf))->get_size;
|
||||
render_func1 = GTK_CELL_RENDERER_CLASS (G_OBJECT_GET_CLASS (celltextpixbuf->pixbuf))->render;
|
||||
cell1 = GTK_CELL_RENDERER (celltextpixbuf->pixbuf);
|
||||
|
||||
size_func2 = GTK_CELL_RENDERER_CLASS (parent_class)->get_size;
|
||||
render_func2 = GTK_CELL_RENDERER_CLASS (parent_class)->render;
|
||||
cell2 = cell;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_func1 = GTK_CELL_RENDERER_CLASS (parent_class)->get_size;
|
||||
render_func1 = GTK_CELL_RENDERER_CLASS (parent_class)->render;
|
||||
cell1 = cell;
|
||||
|
||||
size_func2 = GTK_CELL_RENDERER_CLASS (G_OBJECT_GET_CLASS (celltextpixbuf->pixbuf))->get_size;
|
||||
render_func2 = GTK_CELL_RENDERER_CLASS (G_OBJECT_GET_CLASS (celltextpixbuf->pixbuf))->render;
|
||||
cell2 = GTK_CELL_RENDERER (celltextpixbuf->pixbuf);
|
||||
}
|
||||
|
||||
(size_func1) (cell1, widget, NULL, NULL, NULL, &tmp_width, &tmp_height);
|
||||
|
||||
real_cell_area.x = cell_area->x;
|
||||
real_cell_area.y = cell_area->y;
|
||||
|
||||
if (celltextpixbuf->pixbuf_pos == GTK_POS_LEFT ||
|
||||
celltextpixbuf->pixbuf_pos == GTK_POS_RIGHT)
|
||||
{
|
||||
real_cell_area.width = MIN (tmp_width, cell_area->width);
|
||||
real_cell_area.height = cell_area->height;
|
||||
}
|
||||
else
|
||||
{
|
||||
real_cell_area.height = MIN (tmp_height, cell_area->height);
|
||||
real_cell_area.width = cell_area->width;
|
||||
}
|
||||
|
||||
(render_func1) (cell1,
|
||||
window,
|
||||
widget,
|
||||
background_area,
|
||||
&real_cell_area,
|
||||
expose_area,
|
||||
flags);
|
||||
|
||||
if (celltextpixbuf->pixbuf_pos == GTK_POS_LEFT ||
|
||||
celltextpixbuf->pixbuf_pos == GTK_POS_RIGHT)
|
||||
{
|
||||
real_cell_area.x = real_cell_area.x + real_cell_area.width;
|
||||
real_cell_area.width = cell_area->width - real_cell_area.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
real_cell_area.y = real_cell_area.y + real_cell_area.height;
|
||||
real_cell_area.height = cell_area->height - real_cell_area.height;
|
||||
}
|
||||
|
||||
(render_func2 ) (cell2,
|
||||
window,
|
||||
widget,
|
||||
background_area,
|
||||
&real_cell_area,
|
||||
expose_area,
|
||||
flags);
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/* gtkcellrenderertextpixbuf.h
|
||||
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CELL_RENDERER_TEXT_PIXBUF_H__
|
||||
#define __GTK_CELL_RENDERER_TEXT_PIXBUF_H__
|
||||
|
||||
#include <gtk/gtkcellrenderertext.h>
|
||||
#include <gtk/gtkcellrendererpixbuf.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define GTK_TYPE_CELL_RENDERER_TEXT_PIXBUF (gtk_cell_renderer_text_pixbuf_get_type ())
|
||||
#define GTK_CELL_RENDERER_TEXT_PIXBUF(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_CELL_RENDERER_TEXT_PIXBUF, GtkCellRendererTextPixbuf))
|
||||
#define GTK_CELL_RENDERER_TEXT_PIXBUF_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_RENDERER_TEXT_PIXBUF, GtkCellRendererTextPixbufClass))
|
||||
#define GTK_IS_CELL_RENDERER_TEXT_PIXBUF(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_CELL_RENDERER_TEXT_PIXBUF))
|
||||
#define GTK_IS_CELL_RENDERER_TEXT_PIXBUF_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GTK_TYPE_CELL_RENDERER_TEXT_PIXBUF))
|
||||
#define GTK_CELL_RENDERER_TEXT_PIXBUF_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_TEXT_PIXBUF, GtkCellRendererTextPixbufClass))
|
||||
|
||||
typedef struct _GtkCellRendererTextPixbuf GtkCellRendererTextPixbuf;
|
||||
typedef struct _GtkCellRendererTextPixbufClass GtkCellRendererTextPixbufClass;
|
||||
|
||||
struct _GtkCellRendererTextPixbuf
|
||||
{
|
||||
GtkCellRendererText parent;
|
||||
|
||||
/*< private >*/
|
||||
GtkCellRendererPixbuf *pixbuf;
|
||||
GtkPositionType pixbuf_pos;
|
||||
};
|
||||
|
||||
struct _GtkCellRendererTextPixbufClass
|
||||
{
|
||||
GtkCellRendererTextClass parent_class;
|
||||
};
|
||||
|
||||
GtkType gtk_cell_renderer_text_pixbuf_get_type (void);
|
||||
GtkCellRenderer *gtk_cell_renderer_text_pixbuf_new (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif /* __GTK_CELL_RENDERER_TEXT_PIXBUF_H__ */
|
@ -17,6 +17,8 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* A Red-Black Tree implementation used specifically by GtkTreeView.
|
||||
*/
|
||||
#ifndef __GTK_RBTREE_H__
|
||||
#define __GTK_RBTREE_H__
|
||||
|
||||
|
@ -314,7 +314,7 @@ static void gtk_tree_view_discover_dirty (GtkTreeView
|
||||
GtkRBTree *tree,
|
||||
GtkTreeIter *iter,
|
||||
gint depth);
|
||||
static void gtk_tree_view_check_dirty (GtkTreeView *tree_view);
|
||||
static void gtk_tree_view_check_dirty_and_clean (GtkTreeView *tree_view);
|
||||
static void gtk_tree_view_clamp_node_visible (GtkTreeView *tree_view,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
@ -1126,7 +1126,7 @@ gtk_tree_view_realize (GtkWidget *widget)
|
||||
|
||||
tree_view = GTK_TREE_VIEW (widget);
|
||||
|
||||
gtk_tree_view_check_dirty (GTK_TREE_VIEW (widget));
|
||||
gtk_tree_view_check_dirty_and_clean (GTK_TREE_VIEW (widget));
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
|
||||
|
||||
/* Make the main, clipping window */
|
||||
@ -1380,7 +1380,7 @@ gtk_tree_view_size_allocate_buttons (GtkWidget *widget)
|
||||
continue;
|
||||
|
||||
allocation.x = width;
|
||||
allocation.width = column->displayed_width;
|
||||
allocation.width = column->width;
|
||||
width += column->width;
|
||||
gtk_widget_size_allocate (column->button, &allocation);
|
||||
|
||||
@ -1405,7 +1405,7 @@ gtk_tree_view_size_allocate (GtkWidget *widget,
|
||||
|
||||
tree_view = GTK_TREE_VIEW (widget);
|
||||
|
||||
gtk_tree_view_check_dirty (tree_view);
|
||||
gtk_tree_view_check_dirty_and_clean (tree_view);
|
||||
|
||||
tmp_list = tree_view->priv->children;
|
||||
|
||||
@ -1547,7 +1547,7 @@ gtk_tree_view_button_press (GtkWidget *widget,
|
||||
if (!column->visible)
|
||||
continue;
|
||||
|
||||
background_area.width = column->displayed_width;
|
||||
background_area.width = column->width;
|
||||
if (gtk_tree_view_is_expander_column (tree_view, column) &&
|
||||
TREE_VIEW_DRAW_EXPANDERS(tree_view))
|
||||
{
|
||||
@ -2419,7 +2419,7 @@ gtk_tree_view_draw_focus (GtkWidget *widget)
|
||||
|
||||
cell_area.x = tree_view->priv->focus_column->button->allocation.x;
|
||||
cell_area.y = y;
|
||||
cell_area.width = tree_view->priv->focus_column->displayed_width;
|
||||
cell_area.width = tree_view->priv->focus_column->width;
|
||||
cell_area.height = CELL_HEIGHT (node, vertical_separator);
|
||||
|
||||
gtk_tree_view_column_cell_get_size (tree_view->priv->focus_column,
|
||||
@ -2482,7 +2482,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
if (tree_view->priv->tree == NULL)
|
||||
return TRUE;
|
||||
|
||||
gtk_tree_view_check_dirty (GTK_TREE_VIEW (widget));
|
||||
gtk_tree_view_check_dirty_and_clean (GTK_TREE_VIEW (widget));
|
||||
/* we want to account for a potential HEADER offset.
|
||||
* That is, if the header exists, we want to offset our event by its
|
||||
* height to find the right node.
|
||||
@ -2572,9 +2572,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
continue;
|
||||
|
||||
if (cell_offset > event->area.x + event->area.width ||
|
||||
cell_offset + column->displayed_width < event->area.x)
|
||||
cell_offset + column->width < event->area.x)
|
||||
{
|
||||
cell_offset += column->displayed_width;
|
||||
cell_offset += column->width;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2591,7 +2591,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
|
||||
|
||||
background_area.x = cell_offset;
|
||||
background_area.width = column->displayed_width;
|
||||
background_area.width = column->width;
|
||||
|
||||
cell_area = background_area;
|
||||
cell_area.y += vertical_separator / 2;
|
||||
@ -2697,7 +2697,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
&event->area,
|
||||
flags);
|
||||
}
|
||||
cell_offset += column->displayed_width;
|
||||
cell_offset += column->width;
|
||||
}
|
||||
|
||||
if (node == cursor && GTK_WIDGET_HAS_FOCUS (widget))
|
||||
@ -4477,6 +4477,7 @@ gtk_tree_view_has_child_toggled (GtkTreeModel *model,
|
||||
if (GTK_TREE_VIEW_COLUMN (list->data)->visible)
|
||||
{
|
||||
GTK_TREE_VIEW_COLUMN (list->data)->dirty = TRUE;
|
||||
gtk_tree_view_column_cell_set_dirty (GTK_TREE_VIEW_COLUMN (list->data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -4530,7 +4531,7 @@ gtk_tree_view_deleted (GtkTreeModel *model,
|
||||
for (list = tree_view->priv->columns; list; list = list->next)
|
||||
if (((GtkTreeViewColumn *)list->data)->visible &&
|
||||
((GtkTreeViewColumn *)list->data)->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE)
|
||||
((GtkTreeViewColumn *)list->data)->dirty = TRUE;
|
||||
gtk_tree_view_column_cell_set_dirty ((GtkTreeViewColumn *)list->data);
|
||||
|
||||
/* Ensure we don't have a dangling pointer to a dead node */
|
||||
ensure_unprelighted (tree_view);
|
||||
@ -4717,7 +4718,7 @@ gtk_tree_view_get_cell_xrange (GtkTreeView *tree_view,
|
||||
if (x2)
|
||||
{
|
||||
if (column->visible)
|
||||
*x2 = total_width + column->displayed_width;
|
||||
*x2 = total_width + column->width;
|
||||
else
|
||||
*x2 = total_width; /* width of 0 */
|
||||
}
|
||||
@ -4959,12 +4960,13 @@ gtk_tree_view_discover_dirty_iter (GtkTreeView *tree_view,
|
||||
NULL, NULL, NULL,
|
||||
&width, NULL);
|
||||
}
|
||||
|
||||
if (gtk_tree_view_is_expander_column (tree_view, column) &&
|
||||
TREE_VIEW_DRAW_EXPANDERS (tree_view))
|
||||
{
|
||||
if (depth * tree_view->priv->tab_offset + width > column->width)
|
||||
{
|
||||
column->dirty = TRUE;
|
||||
gtk_tree_view_column_cell_set_dirty (column);
|
||||
retval = TRUE;
|
||||
}
|
||||
}
|
||||
@ -4972,7 +4974,7 @@ gtk_tree_view_discover_dirty_iter (GtkTreeView *tree_view,
|
||||
{
|
||||
if (width > column->width)
|
||||
{
|
||||
column->dirty = TRUE;
|
||||
gtk_tree_view_column_cell_set_dirty (column);
|
||||
retval = TRUE;
|
||||
}
|
||||
}
|
||||
@ -5029,8 +5031,14 @@ gtk_tree_view_discover_dirty (GtkTreeView *tree_view,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_tree_view_check_dirty_and_clean:
|
||||
* @tree_view: A #GtkTreeView
|
||||
*
|
||||
* Does all the actual sizing for
|
||||
**/
|
||||
static void
|
||||
gtk_tree_view_check_dirty (GtkTreeView *tree_view)
|
||||
gtk_tree_view_check_dirty_and_clean (GtkTreeView *tree_view)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
gboolean dirty = FALSE;
|
||||
@ -5679,10 +5687,10 @@ _gtk_tree_view_update_col_width (GtkTreeView *tree_view)
|
||||
continue;
|
||||
|
||||
width += column->width;
|
||||
column->displayed_width = (CLAMP (column->width, (column->min_width!=-1)?column->min_width:column->width, (column->max_width!=-1)?column->max_width:column->width));
|
||||
column->width = (CLAMP (column->width, (column->min_width!=-1)?column->min_width:column->width, (column->max_width!=-1)?column->max_width:column->width));
|
||||
}
|
||||
column = GTK_TREE_VIEW_COLUMN (last_column->data);
|
||||
column->displayed_width = MAX (GTK_WIDGET (tree_view)->allocation.width, tree_view->priv->width) - width;
|
||||
column->width = MAX (GTK_WIDGET (tree_view)->allocation.width, tree_view->priv->width) - width;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -5805,19 +5813,72 @@ gtk_tree_view_move_cursor_left_right (GtkTreeView *tree_view,
|
||||
GtkRBTree *cursor_tree = NULL;
|
||||
GtkRBNode *cursor_node = NULL;
|
||||
GtkTreePath *cursor_path = NULL;
|
||||
|
||||
g_print ("gtk_tree_view_move_cursor_left_right\n");
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeIter iter;
|
||||
GList *list;
|
||||
gboolean found_column = FALSE;
|
||||
|
||||
if (gtk_tree_row_reference_valid (tree_view->priv->cursor))
|
||||
cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
|
||||
else
|
||||
return;
|
||||
|
||||
_gtk_tree_view_find_node (tree_view, cursor_path,
|
||||
&cursor_tree, &cursor_node);
|
||||
_gtk_tree_view_find_node (tree_view, cursor_path, &cursor_tree, &cursor_node);
|
||||
if (cursor_tree == NULL)
|
||||
return;
|
||||
if (gtk_tree_model_get_iter (tree_view->priv->model, &iter, cursor_path) == FALSE)
|
||||
{
|
||||
gtk_tree_path_free (cursor_path);
|
||||
return;
|
||||
}
|
||||
gtk_tree_path_free (cursor_path);
|
||||
|
||||
list = tree_view->priv->columns;
|
||||
if (tree_view->priv->focus_column)
|
||||
{
|
||||
for (list = tree_view->priv->columns; list; list = list->next)
|
||||
{
|
||||
if (list->data == tree_view->priv->focus_column)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (list)
|
||||
{
|
||||
column = list->data;
|
||||
if (column->visible == FALSE)
|
||||
goto loop_end;
|
||||
|
||||
gtk_tree_view_column_cell_set_cell_data (column,
|
||||
tree_view->priv->model,
|
||||
&iter,
|
||||
GTK_RBNODE_FLAG_SET (cursor_node, GTK_RBNODE_IS_PARENT),
|
||||
cursor_node->children?TRUE:FALSE);
|
||||
if (gtk_tree_view_column_cell_can_focus (column))
|
||||
{
|
||||
if (gtk_tree_view_column_cell_focus (column, count, FALSE))
|
||||
{
|
||||
tree_view->priv->focus_column = column;
|
||||
found_column = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
loop_end:
|
||||
if (count == 1)
|
||||
list = list->next;
|
||||
else
|
||||
list = list->prev;
|
||||
}
|
||||
|
||||
if (found_column)
|
||||
{
|
||||
gtk_tree_view_queue_draw_node (tree_view,
|
||||
cursor_tree,
|
||||
cursor_node,
|
||||
NULL);
|
||||
return;
|
||||
}
|
||||
g_print ("scroll now!\n");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -6483,7 +6544,7 @@ gtk_tree_view_columns_autosize (GtkTreeView *tree_view)
|
||||
column = list->data;
|
||||
if (column->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE)
|
||||
continue;
|
||||
column->dirty = TRUE;
|
||||
gtk_tree_view_column_cell_set_dirty (column);
|
||||
dirty = TRUE;
|
||||
}
|
||||
|
||||
@ -6626,7 +6687,7 @@ gtk_tree_view_remove_column (GtkTreeView *tree_view,
|
||||
|
||||
tmp_column = GTK_TREE_VIEW_COLUMN (list->data);
|
||||
if (tmp_column->visible)
|
||||
tmp_column->dirty = TRUE;
|
||||
gtk_tree_view_column_cell_set_dirty (tmp_column);
|
||||
}
|
||||
|
||||
if (tree_view->priv->n_columns == 0 &&
|
||||
@ -6688,7 +6749,7 @@ gtk_tree_view_insert_column (GtkTreeView *tree_view,
|
||||
{
|
||||
column = GTK_TREE_VIEW_COLUMN (list->data);
|
||||
if (column->visible)
|
||||
column->dirty = TRUE;
|
||||
gtk_tree_view_column_cell_set_dirty (column);
|
||||
}
|
||||
gtk_widget_queue_resize (GTK_WIDGET (tree_view));
|
||||
}
|
||||
@ -7178,35 +7239,6 @@ gtk_tree_view_expand_all (GtkTreeView *tree_view)
|
||||
_gtk_tree_view_update_size (tree_view);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_collapse_all_helper (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
gpointer data)
|
||||
{
|
||||
if (node->children)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
|
||||
path = _gtk_tree_view_find_path (GTK_TREE_VIEW (data),
|
||||
node->children,
|
||||
node->children->root);
|
||||
gtk_tree_model_get_iter (GTK_TREE_VIEW (data)->priv->model,
|
||||
&iter,
|
||||
path);
|
||||
gtk_tree_view_discover_dirty (GTK_TREE_VIEW (data),
|
||||
node->children,
|
||||
&iter,
|
||||
gtk_tree_path_get_depth (path));
|
||||
|
||||
/* Ensure we don't have a dangling pointer to a dead node */
|
||||
ensure_unprelighted (GTK_TREE_VIEW (data));
|
||||
|
||||
_gtk_rbtree_remove (node->children);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
}
|
||||
|
||||
/* Timeout to animate the expander during expands and collapses */
|
||||
static gboolean
|
||||
expand_collapse_timeout (gpointer data)
|
||||
@ -7286,17 +7318,32 @@ expand_collapse_timeout (gpointer data)
|
||||
void
|
||||
gtk_tree_view_collapse_all (GtkTreeView *tree_view)
|
||||
{
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreePath *path;
|
||||
guint *indices;
|
||||
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
|
||||
g_return_if_fail (tree_view->priv->tree != NULL);
|
||||
|
||||
_gtk_rbtree_traverse (tree_view->priv->tree,
|
||||
tree_view->priv->tree->root,
|
||||
G_PRE_ORDER,
|
||||
gtk_tree_view_collapse_all_helper,
|
||||
tree_view);
|
||||
path = gtk_tree_path_new ();
|
||||
gtk_tree_path_append_index (path, 0);
|
||||
indices = gtk_tree_path_get_indices (path);
|
||||
|
||||
if (GTK_WIDGET_MAPPED (tree_view))
|
||||
gtk_widget_queue_draw (GTK_WIDGET (tree_view));
|
||||
tree = tree_view->priv->tree;
|
||||
node = tree->root;
|
||||
while (node && node->left != tree->nil)
|
||||
node = node->left;
|
||||
|
||||
while (node)
|
||||
{
|
||||
if (node->children)
|
||||
gtk_tree_view_real_collapse_row (tree_view, path, tree, node);
|
||||
indices[0]++;
|
||||
node = _gtk_rbtree_next (tree, node);
|
||||
}
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
/* FIXME the bool return values for expand_row and collapse_row are
|
||||
@ -7412,6 +7459,7 @@ gtk_tree_view_real_collapse_row (GtkTreeView *tree_view,
|
||||
GtkTreeIter children;
|
||||
gboolean collapse;
|
||||
gint x, y;
|
||||
GList *list;
|
||||
|
||||
gtk_tree_model_get_iter (tree_view->priv->model, &iter, path);
|
||||
|
||||
@ -7444,11 +7492,16 @@ gtk_tree_view_real_collapse_row (GtkTreeView *tree_view,
|
||||
|
||||
TREE_VIEW_INTERNAL_ASSERT (gtk_tree_model_iter_children (tree_view->priv->model, &children, &iter), FALSE);
|
||||
|
||||
gtk_tree_view_discover_dirty (tree_view,
|
||||
node->children,
|
||||
&children,
|
||||
gtk_tree_path_get_depth (path));
|
||||
for (list = tree_view->priv->columns; list; list = list->next)
|
||||
{
|
||||
GtkTreeViewColumn *column = list->data;
|
||||
|
||||
if (column->visible == FALSE)
|
||||
continue;
|
||||
if (gtk_tree_view_column_get_sizing (column) == GTK_TREE_VIEW_COLUMN_AUTOSIZE)
|
||||
gtk_tree_view_column_cell_set_dirty (column);
|
||||
}
|
||||
|
||||
if (tree_view->priv->destroy_count_func)
|
||||
{
|
||||
GtkTreePath *child_path;
|
||||
@ -8469,7 +8522,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
|
||||
node->children?TRUE:FALSE);
|
||||
|
||||
background_area.x = cell_offset;
|
||||
background_area.width = column->displayed_width;
|
||||
background_area.width = column->width;
|
||||
|
||||
cell_area = background_area;
|
||||
|
||||
@ -8492,7 +8545,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
cell_offset += column->displayed_width;
|
||||
cell_offset += column->width;
|
||||
}
|
||||
|
||||
return drawable;
|
||||
|
@ -33,8 +33,9 @@ enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_VISIBLE,
|
||||
PROP_SIZING,
|
||||
PROP_WIDTH,
|
||||
PROP_SIZING,
|
||||
PROP_FIXED_WIDTH,
|
||||
PROP_MIN_WIDTH,
|
||||
PROP_MAX_WIDTH,
|
||||
PROP_TITLE,
|
||||
@ -61,10 +62,9 @@ struct _GtkTreeViewColumnCellInfo
|
||||
gpointer func_data;
|
||||
GtkDestroyNotify destroy;
|
||||
gint requested_width;
|
||||
guint16 padding;
|
||||
guint expand : 1;
|
||||
guint fill : 1;
|
||||
guint pack : 1;
|
||||
guint has_focus : 1;
|
||||
};
|
||||
|
||||
/* Type methods */
|
||||
@ -108,6 +108,10 @@ static void gtk_tree_view_column_set_attributesv (GtkTreeViewColum
|
||||
va_list args);
|
||||
static GtkTreeViewColumnCellInfo *gtk_tree_view_column_get_cell_info (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell_renderer);
|
||||
static void gtk_tree_view_column_cell_foreach (GtkTreeViewColumn *tree_column,
|
||||
gboolean direction,
|
||||
GFunc function,
|
||||
gpointer data);
|
||||
|
||||
|
||||
|
||||
@ -173,6 +177,15 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
|
||||
TRUE,
|
||||
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"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
0,
|
||||
G_PARAM_READABLE));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_SIZING,
|
||||
g_param_spec_enum ("sizing",
|
||||
@ -183,10 +196,10 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
|
||||
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"),
|
||||
PROP_FIXED_WIDTH,
|
||||
g_param_spec_int ("fixed_width",
|
||||
_("Fixed Width"),
|
||||
_("Current fixed width of the column"),
|
||||
1,
|
||||
G_MAXINT,
|
||||
1, /* not useful */
|
||||
@ -199,7 +212,7 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
|
||||
_("Minimum allowed width of the column"),
|
||||
-1,
|
||||
G_MAXINT,
|
||||
1,
|
||||
-1,
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
@ -209,7 +222,7 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
|
||||
_("Maximum allowed width of the column"),
|
||||
-1,
|
||||
G_MAXINT,
|
||||
G_MAXINT,
|
||||
-1,
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
@ -279,11 +292,11 @@ gtk_tree_view_column_init (GtkTreeViewColumn *tree_column)
|
||||
{
|
||||
tree_column->button = NULL;
|
||||
tree_column->xalign = 0.0;
|
||||
tree_column->width = 1;
|
||||
tree_column->width = 0;
|
||||
tree_column->requested_width = -1;
|
||||
tree_column->min_width = -1;
|
||||
tree_column->max_width = -1;
|
||||
tree_column->column_type = GTK_TREE_VIEW_COLUMN_AUTOSIZE;
|
||||
tree_column->column_type = GTK_TREE_VIEW_COLUMN_GROW_ONLY;
|
||||
tree_column->visible = TRUE;
|
||||
tree_column->clickable = FALSE;
|
||||
tree_column->dirty = TRUE;
|
||||
@ -340,9 +353,9 @@ gtk_tree_view_column_set_property (GObject *object,
|
||||
g_value_get_enum (value));
|
||||
break;
|
||||
|
||||
case PROP_WIDTH:
|
||||
gtk_tree_view_column_set_width (tree_column,
|
||||
g_value_get_int (value));
|
||||
case PROP_FIXED_WIDTH:
|
||||
gtk_tree_view_column_set_fixed_width (tree_column,
|
||||
g_value_get_int (value));
|
||||
break;
|
||||
|
||||
case PROP_MIN_WIDTH:
|
||||
@ -413,14 +426,19 @@ gtk_tree_view_column_get_property (GObject *object,
|
||||
gtk_tree_view_column_get_visible (tree_column));
|
||||
break;
|
||||
|
||||
case PROP_WIDTH:
|
||||
g_value_set_int (value,
|
||||
gtk_tree_view_column_get_width (tree_column));
|
||||
break;
|
||||
|
||||
case PROP_SIZING:
|
||||
g_value_set_enum (value,
|
||||
gtk_tree_view_column_get_sizing (tree_column));
|
||||
break;
|
||||
|
||||
case PROP_WIDTH:
|
||||
case PROP_FIXED_WIDTH:
|
||||
g_value_set_int (value,
|
||||
gtk_tree_view_column_get_width (tree_column));
|
||||
gtk_tree_view_column_get_fixed_width (tree_column));
|
||||
break;
|
||||
|
||||
case PROP_MIN_WIDTH:
|
||||
@ -685,8 +703,7 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
|
||||
}
|
||||
}
|
||||
|
||||
tree_column->dirty = TRUE;
|
||||
gtk_widget_queue_resize (tree_column->tree_view);
|
||||
gtk_tree_view_column_cell_set_dirty (tree_column);
|
||||
}
|
||||
|
||||
/* Button signal handlers
|
||||
@ -1053,7 +1070,7 @@ void
|
||||
gtk_tree_view_column_set_cell_renderer (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell)
|
||||
{
|
||||
gtk_tree_view_column_pack_start (tree_column, cell, TRUE, TRUE, 0);
|
||||
gtk_tree_view_column_pack_start (tree_column, cell, TRUE);
|
||||
}
|
||||
|
||||
static GtkTreeViewColumnCellInfo *
|
||||
@ -1067,22 +1084,18 @@ gtk_tree_view_column_get_cell_info (GtkTreeViewColumn *tree_column,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_tree_view_column_pack_start:
|
||||
* @tree_column: A #GtkTreeViewColumn.
|
||||
* @cell: The #GtkCellRenderer,
|
||||
* @expand: TRUE if @cell is to be given extra space allocated to box.
|
||||
* @fill: TRUE if @cell is to fill space allocated to it.
|
||||
* @padding: extra space in pixels to place on the outside of the cell
|
||||
*
|
||||
* Packs a cell into
|
||||
**/
|
||||
void
|
||||
gtk_tree_view_column_pack_start (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
gboolean expand,
|
||||
gboolean fill,
|
||||
guint padding)
|
||||
gboolean expand)
|
||||
{
|
||||
GtkTreeViewColumnCellInfo *cell_info;
|
||||
|
||||
@ -1096,8 +1109,8 @@ gtk_tree_view_column_pack_start (GtkTreeViewColumn *tree_column,
|
||||
cell_info = g_new0 (GtkTreeViewColumnCellInfo, 1);
|
||||
cell_info->cell = cell;
|
||||
cell_info->expand = expand ? TRUE : FALSE;
|
||||
cell_info->fill = fill ? TRUE : FALSE;
|
||||
cell_info->pack = GTK_PACK_START;
|
||||
cell_info->has_focus = 0;
|
||||
cell_info->attributes = NULL;
|
||||
|
||||
tree_column->cell_list = g_list_append (tree_column->cell_list, cell_info);
|
||||
@ -1106,9 +1119,7 @@ gtk_tree_view_column_pack_start (GtkTreeViewColumn *tree_column,
|
||||
void
|
||||
gtk_tree_view_column_pack_end (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
gboolean expand,
|
||||
gboolean fill,
|
||||
guint padding)
|
||||
gboolean expand)
|
||||
{
|
||||
GtkTreeViewColumnCellInfo *cell_info;
|
||||
|
||||
@ -1122,8 +1133,8 @@ gtk_tree_view_column_pack_end (GtkTreeViewColumn *tree_column,
|
||||
cell_info = g_new (GtkTreeViewColumnCellInfo, 1);
|
||||
cell_info->cell = cell;
|
||||
cell_info->expand = expand ? TRUE : FALSE;
|
||||
cell_info->fill = fill ? TRUE : FALSE;
|
||||
cell_info->pack = GTK_PACK_END;
|
||||
cell_info->has_focus = 0;
|
||||
cell_info->attributes = NULL;
|
||||
|
||||
tree_column->cell_list = g_list_append (tree_column->cell_list, cell_info);
|
||||
@ -1192,10 +1203,7 @@ gtk_tree_view_column_add_attribute (GtkTreeViewColumn *tree_column,
|
||||
info->attributes = g_slist_prepend (info->attributes, g_strdup (attribute));
|
||||
|
||||
if (tree_column->tree_view)
|
||||
{
|
||||
tree_column->dirty = TRUE;
|
||||
gtk_widget_queue_resize (tree_column->tree_view);
|
||||
}
|
||||
gtk_tree_view_column_cell_set_dirty (tree_column);
|
||||
|
||||
}
|
||||
|
||||
@ -1286,10 +1294,7 @@ gtk_tree_view_column_set_cell_data_func (GtkTreeViewColumn *tree_column,
|
||||
info->destroy = destroy;
|
||||
|
||||
if (tree_column->tree_view)
|
||||
{
|
||||
tree_column->dirty = TRUE;
|
||||
gtk_widget_queue_resize (tree_column->tree_view);
|
||||
}
|
||||
gtk_tree_view_column_cell_set_dirty (tree_column);
|
||||
}
|
||||
|
||||
|
||||
@ -1323,10 +1328,7 @@ gtk_tree_view_column_clear_attributes (GtkTreeViewColumn *tree_column,
|
||||
info->attributes = NULL;
|
||||
|
||||
if (tree_column->tree_view)
|
||||
{
|
||||
tree_column->dirty = TRUE;
|
||||
gtk_widget_queue_resize (tree_column->tree_view);
|
||||
}
|
||||
gtk_tree_view_column_cell_set_dirty (tree_column);
|
||||
}
|
||||
|
||||
|
||||
@ -1350,10 +1352,7 @@ gtk_tree_view_column_set_spacing (GtkTreeViewColumn *tree_column,
|
||||
|
||||
tree_column->spacing = spacing;
|
||||
if (tree_column->tree_view)
|
||||
{
|
||||
tree_column->dirty = TRUE;
|
||||
gtk_widget_queue_resize (tree_column->tree_view);
|
||||
}
|
||||
gtk_tree_view_column_cell_set_dirty (tree_column);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1459,53 +1458,12 @@ gtk_tree_view_column_get_sizing (GtkTreeViewColumn *tree_column)
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_tree_view_column_get_size:
|
||||
* gtk_tree_view_column_get_width:
|
||||
* @tree_column: A #GtkTreeViewColumn.
|
||||
*
|
||||
* Returns the current size of the @tree_column in pixels.
|
||||
*
|
||||
* Return value: The current size of the @tree_column.
|
||||
**/
|
||||
gint
|
||||
gtk_tree_view_column_get_size (GtkTreeViewColumn *tree_column)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), 0);
|
||||
|
||||
return tree_column->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_tree_view_column_set_width:
|
||||
* @tree_column: A #GtkTreeViewColumn.
|
||||
* @width: The size to set the @tree_column to.
|
||||
*
|
||||
* 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. The
|
||||
* width is clamped to the min/max width for the column.
|
||||
**/
|
||||
void
|
||||
gtk_tree_view_column_set_width (GtkTreeViewColumn *tree_column,
|
||||
gint width)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
|
||||
g_return_if_fail (width > 0);
|
||||
|
||||
if (tree_column->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE)
|
||||
return;
|
||||
|
||||
tree_column->requested_width = width;
|
||||
_gtk_tree_view_column_set_width (tree_column, width);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_tree_view_column_get_width:
|
||||
* @tree_column: a #GtkTreeViewColumn
|
||||
*
|
||||
* Gets the value set by gtk_tree_view_column_set_width(). This may not be the
|
||||
* actual width of the column on the screen, just what is requested.
|
||||
*
|
||||
* Return value: the width of the column
|
||||
* Return value: The current width of the @tree_column.
|
||||
**/
|
||||
gint
|
||||
gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column)
|
||||
@ -1515,6 +1473,48 @@ gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column)
|
||||
return tree_column->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_tree_view_column_set_fixed_width:
|
||||
* @tree_column: A #GtkTreeViewColumn.
|
||||
* @width: The size to set the @tree_column to.
|
||||
*
|
||||
* Sets the size of the column in pixels. This is meaningful only if the sizing
|
||||
* type is #GTK_TREE_VIEW_COLUMN_FIXED. In this case, the value is discarded
|
||||
* as the 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_fixed_width (GtkTreeViewColumn *tree_column,
|
||||
gint width)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
|
||||
g_return_if_fail (width > 0);
|
||||
|
||||
if (tree_column->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE)
|
||||
return;
|
||||
|
||||
tree_column->fixed_width = width;
|
||||
tree_column->requested_width = width;
|
||||
_gtk_tree_view_column_set_width (tree_column, width);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_tree_view_column_get_fixed_width:
|
||||
* @tree_column: a #GtkTreeViewColumn
|
||||
*
|
||||
* Gets the fixed width of the column. This value is only meaning may not be the
|
||||
* actual width of the column on the screen, just what is requested.
|
||||
*
|
||||
* Return value: the fixed width of the column
|
||||
**/
|
||||
gint
|
||||
gtk_tree_view_column_get_fixed_width (GtkTreeViewColumn *tree_column)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column), 0);
|
||||
|
||||
return tree_column->fixed_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_tree_view_column_set_min_width:
|
||||
* @tree_column: A #GtkTreeViewColumn.
|
||||
@ -2065,7 +2065,7 @@ gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* gtk_tree_view_column_cell_get_size:
|
||||
* @tree_column: A #GtkTreeViewColumn.
|
||||
@ -2097,6 +2097,55 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
|
||||
height);
|
||||
|
||||
}
|
||||
#endif
|
||||
void
|
||||
gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GList *list;
|
||||
gboolean first_cell = TRUE;
|
||||
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
|
||||
|
||||
if (height)
|
||||
* height = 0;
|
||||
if (width)
|
||||
* width = 0;
|
||||
|
||||
for (list = tree_column->cell_list; list; list = list->next)
|
||||
{
|
||||
GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
|
||||
gboolean visible;
|
||||
gint new_height = 0;
|
||||
gint new_width = 0;
|
||||
g_object_get (info->cell, "visible", &visible, NULL);
|
||||
|
||||
if (visible == FALSE)
|
||||
continue;
|
||||
|
||||
if (first_cell == FALSE && *width)
|
||||
*width += tree_column->spacing;
|
||||
|
||||
gtk_cell_renderer_get_size (info->cell,
|
||||
tree_column->tree_view,
|
||||
cell_area,
|
||||
x_offset,
|
||||
y_offset,
|
||||
&new_width,
|
||||
&new_height);
|
||||
|
||||
if (height)
|
||||
* height = MAX (*height, new_height);
|
||||
info->requested_width = MAX (info->requested_width, new_width);
|
||||
if (width)
|
||||
* width += info->requested_width;
|
||||
first_cell = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_tree_view_column_cell_render:
|
||||
@ -2118,18 +2167,84 @@ gtk_tree_view_column_cell_render (GtkTreeViewColumn *tree_column,
|
||||
GdkRectangle *expose_area,
|
||||
guint flags)
|
||||
{
|
||||
gboolean visible;
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
|
||||
GList *list;
|
||||
GdkRectangle real_cell_area;
|
||||
gint expand_cell_count = 0;
|
||||
gint full_requested_width = 0;
|
||||
gint extra_space;
|
||||
|
||||
g_object_get (G_OBJECT ((((GtkTreeViewColumnCellInfo *) tree_column->cell_list->data)->cell)), "visible", &visible, NULL);
|
||||
if (visible)
|
||||
gtk_cell_renderer_render (((GtkTreeViewColumnCellInfo *) tree_column->cell_list->data)->cell,
|
||||
window,
|
||||
tree_column->tree_view,
|
||||
background_area,
|
||||
cell_area,
|
||||
expose_area,
|
||||
flags);
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
|
||||
g_return_if_fail (background_area != NULL);
|
||||
g_return_if_fail (cell_area != NULL);
|
||||
g_return_if_fail (expose_area != NULL);
|
||||
|
||||
real_cell_area = *cell_area;
|
||||
|
||||
/* Find out how my extra space we have to allocate */
|
||||
for (list = tree_column->cell_list; list; list = list->next)
|
||||
{
|
||||
GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
|
||||
gboolean visible;
|
||||
|
||||
g_object_get (info->cell, "visible", &visible, NULL);
|
||||
if (visible == FALSE)
|
||||
continue;
|
||||
|
||||
if (info->expand == TRUE)
|
||||
expand_cell_count ++;
|
||||
full_requested_width += info->requested_width;
|
||||
}
|
||||
|
||||
extra_space = cell_area->width - full_requested_width;
|
||||
if (extra_space < 0)
|
||||
extra_space = 0;
|
||||
|
||||
for (list = tree_column->cell_list; list; list = list->next)
|
||||
{
|
||||
GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
|
||||
gboolean visible;
|
||||
|
||||
if (info->pack == GTK_PACK_END)
|
||||
continue;
|
||||
|
||||
g_object_get (info->cell, "visible", &visible, NULL);
|
||||
if (visible == FALSE)
|
||||
continue;
|
||||
|
||||
real_cell_area.width = info->requested_width +
|
||||
(info->expand?extra_space:0);
|
||||
gtk_cell_renderer_render (info->cell,
|
||||
window,
|
||||
tree_column->tree_view,
|
||||
background_area,
|
||||
&real_cell_area,
|
||||
expose_area,
|
||||
flags);
|
||||
real_cell_area.x += (info->requested_width + tree_column->spacing);
|
||||
}
|
||||
for (list = g_list_last (tree_column->cell_list); list; list = list->prev)
|
||||
{
|
||||
GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
|
||||
gboolean visible;
|
||||
|
||||
if (info->pack == GTK_PACK_START)
|
||||
continue;
|
||||
|
||||
g_object_get (info->cell, "visible", &visible, NULL);
|
||||
if (visible == FALSE)
|
||||
continue;
|
||||
|
||||
real_cell_area.width = info->requested_width +
|
||||
(info->expand?extra_space:0);
|
||||
gtk_cell_renderer_render (info->cell,
|
||||
window,
|
||||
tree_column->tree_view,
|
||||
background_area,
|
||||
&real_cell_area,
|
||||
expose_area,
|
||||
flags);
|
||||
real_cell_area.x += (info->requested_width + tree_column->spacing);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2176,6 +2291,18 @@ gtk_tree_view_column_cell_event (GtkTreeViewColumn *tree_column,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
|
||||
gint direction,
|
||||
gboolean unfocus)
|
||||
{
|
||||
GList *list;
|
||||
gboolean visible;
|
||||
gboolean can_activate;
|
||||
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_tree_view_column_cell_can_focus (GtkTreeViewColumn *tree_column)
|
||||
{
|
||||
@ -2202,17 +2329,89 @@ gboolean
|
||||
gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column)
|
||||
{
|
||||
GList *list;
|
||||
gboolean visible;
|
||||
|
||||
for (list = tree_column->cell_list; list; list = list->next)
|
||||
{
|
||||
GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
|
||||
g_object_get (G_OBJECT (info->cell),
|
||||
"visible", &visible,
|
||||
NULL);
|
||||
gboolean visible;
|
||||
|
||||
g_object_get (G_OBJECT (info->cell), "visible", &visible, NULL);
|
||||
|
||||
if (visible)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_tree_view_column_cell_set_dirty (GtkTreeViewColumn *tree_column)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
for (list = tree_column->cell_list; list; list = list->next)
|
||||
{
|
||||
GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
|
||||
|
||||
info->requested_width = 0;
|
||||
}
|
||||
tree_column->dirty = TRUE;
|
||||
|
||||
g_print ("in gtk_tree_view_column_cell_set_dirty\n");
|
||||
if (tree_column->tree_view)
|
||||
gtk_widget_queue_resize (tree_column->tree_view);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void
|
||||
gtk_tree_view_column_cell_foreach (GtkTreeViewColumn *tree_column,
|
||||
gboolean direction,
|
||||
GFunc function,
|
||||
gpointer data)
|
||||
{
|
||||
GList *list;
|
||||
GtkTreeViewColumnCellInfo *info;
|
||||
|
||||
if (direction == 1)
|
||||
{
|
||||
for (list = tree_column->cell_list; list; list = list->next)
|
||||
{
|
||||
info = list->data;
|
||||
if (info->pack == GTK_PACK_END)
|
||||
continue;
|
||||
if ((*function) (info, data))
|
||||
return;
|
||||
}
|
||||
|
||||
for (list = g_list_llast (tree_column->cell_list); list; list = list->prev)
|
||||
{
|
||||
info = list->data;
|
||||
if (info->pack == GTK_PACK_START)
|
||||
continue;
|
||||
if ((*function) (info, data))
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (list = g_list_llast (tree_column->cell_list); list; list = list->prev)
|
||||
{
|
||||
info = list->data;
|
||||
if (info->pack == GTK_PACK_START)
|
||||
continue;
|
||||
if ((*function) (info, data))
|
||||
return;
|
||||
}
|
||||
for (list = tree_column->cell_list; list; list = list->next)
|
||||
{
|
||||
info = list->data;
|
||||
if (info->pack == GTK_PACK_END)
|
||||
continue;
|
||||
if ((*function) (info, data))
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -38,6 +38,7 @@ extern "C" {
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_TREE_VIEW_COLUMN_GROW_ONLY,
|
||||
GTK_TREE_VIEW_COLUMN_RESIZABLE,
|
||||
GTK_TREE_VIEW_COLUMN_AUTOSIZE,
|
||||
GTK_TREE_VIEW_COLUMN_FIXED
|
||||
@ -67,11 +68,11 @@ struct _GtkTreeViewColumn
|
||||
guint property_changed_signal;
|
||||
|
||||
gint spacing;
|
||||
gint fixed_width;
|
||||
gint width;
|
||||
gint requested_width;
|
||||
gint min_width;
|
||||
gint max_width;
|
||||
gint displayed_width;
|
||||
|
||||
/* dragging columns */
|
||||
gint drag_x;
|
||||
@ -112,14 +113,10 @@ void gtk_tree_view_column_set_cell_renderer (GtkTreeViewCol
|
||||
GtkCellRenderer *cell);
|
||||
void gtk_tree_view_column_pack_start (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
gboolean expand,
|
||||
gboolean fill,
|
||||
guint padding);
|
||||
gboolean expand);
|
||||
void gtk_tree_view_column_pack_end (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
gboolean expand,
|
||||
gboolean fill,
|
||||
guint padding);
|
||||
gboolean expand);
|
||||
void gtk_tree_view_column_clear (GtkTreeViewColumn *tree_column);
|
||||
GList *gtk_tree_view_column_get_cell_renderers (GtkTreeViewColumn *tree_column);
|
||||
void gtk_tree_view_column_add_attribute (GtkTreeViewColumn *tree_column,
|
||||
@ -146,8 +143,9 @@ void gtk_tree_view_column_set_sizing (GtkTreeViewCol
|
||||
GtkTreeViewColumnSizing type);
|
||||
GtkTreeViewColumnSizing 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 width);
|
||||
gint gtk_tree_view_column_get_fixed_width (GtkTreeViewColumn *tree_column);
|
||||
void gtk_tree_view_column_set_fixed_width (GtkTreeViewColumn *tree_column,
|
||||
gint fixed_width);
|
||||
void gtk_tree_view_column_set_min_width (GtkTreeViewColumn *tree_column,
|
||||
gint min_width);
|
||||
gint gtk_tree_view_column_get_min_width (GtkTreeViewColumn *tree_column);
|
||||
@ -217,8 +215,12 @@ gboolean gtk_tree_view_column_cell_event (GtkTreeViewCol
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
guint flags);
|
||||
gboolean gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
|
||||
gint direction,
|
||||
gboolean unfocus);
|
||||
gboolean gtk_tree_view_column_cell_can_focus (GtkTreeViewColumn *tree_column);
|
||||
gboolean gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column);
|
||||
void gtk_tree_view_column_cell_set_dirty (GtkTreeViewColumn *tree_column);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -352,7 +352,7 @@ main (int argc, char *argv[])
|
||||
NULL);
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
|
||||
/* Havoc Column */
|
||||
@ -368,7 +368,7 @@ main (int argc, char *argv[])
|
||||
NULL);
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
|
||||
/* Tim Column */
|
||||
@ -386,7 +386,7 @@ main (int argc, char *argv[])
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
|
||||
/* Owen Column */
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
@ -401,7 +401,7 @@ main (int argc, char *argv[])
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
|
||||
/* Owen Column */
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
@ -415,7 +415,7 @@ main (int argc, char *argv[])
|
||||
NULL);
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 50);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
|
||||
|
@ -279,13 +279,15 @@ set_columns_type (GtkTreeView *tree_view, ColumnsType type)
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);
|
||||
|
||||
rend = gtk_cell_renderer_text_pixbuf_new ();
|
||||
col = gtk_tree_view_column_new();
|
||||
gtk_tree_view_column_set_title (col, "Column 2");
|
||||
|
||||
col = gtk_tree_view_column_new_with_attributes ("Column 2",
|
||||
rend,
|
||||
"text", 0,
|
||||
"pixbuf", 2,
|
||||
NULL);
|
||||
rend = gtk_cell_renderer_pixbuf_new ();
|
||||
gtk_tree_view_column_pack_start (col, rend, FALSE);
|
||||
gtk_tree_view_column_add_attribute (col, rend, "pixbuf", 2);
|
||||
rend = gtk_cell_renderer_text_new ();
|
||||
gtk_tree_view_column_pack_start (col, rend, TRUE);
|
||||
gtk_tree_view_column_add_attribute (col, rend, "text", 0);
|
||||
|
||||
setup_column (col);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user