summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--ChangeLog.pre-2-015
-rw-r--r--ChangeLog.pre-2-1015
-rw-r--r--ChangeLog.pre-2-215
-rw-r--r--ChangeLog.pre-2-415
-rw-r--r--ChangeLog.pre-2-615
-rw-r--r--ChangeLog.pre-2-815
-rw-r--r--gtk/gtkcellrenderer.c55
-rw-r--r--gtk/gtkcellrenderer.h7
-rw-r--r--gtk/gtkcellrendererpixbuf.c60
-rw-r--r--gtk/gtkcellrenderertext.c38
-rw-r--r--gtk/gtkcellrenderertextpixbuf.c49
-rw-r--r--gtk/gtkcellrenderertoggle.c52
-rw-r--r--gtk/gtkstyle.c13
-rw-r--r--gtk/gtktreemodel.h1
-rw-r--r--gtk/gtktreeview.c247
-rw-r--r--gtk/gtktreeviewcolumn.c2
-rw-r--r--gtk/gtktreeviewcolumn.h5
-rw-r--r--gtk/testdnd.c11
-rw-r--r--tests/testdnd.c11
-rw-r--r--tests/testtreefocus.c223
21 files changed, 663 insertions, 216 deletions
diff --git a/ChangeLog b/ChangeLog
index 97f2170127..7a5ef98328 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 97f2170127..7a5ef98328 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,16 @@
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 97f2170127..7a5ef98328 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,16 @@
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 97f2170127..7a5ef98328 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,16 @@
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 97f2170127..7a5ef98328 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,16 @@
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 97f2170127..7a5ef98328 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,16 @@
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 97f2170127..7a5ef98328 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,16 @@
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
@@ -17,7 +30,7 @@
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c
index 3bf1893248..b1c9abe236 100644
--- a/gtk/gtkcellrenderer.c
+++ b/gtk/gtkcellrenderer.c
@@ -34,6 +34,7 @@ static void gtk_cell_renderer_set_property (GObject *object,
enum {
PROP_ZERO,
+ PROP_CAN_ACTIVATE,
PROP_VISIBLE,
PROP_XALIGN,
PROP_YALIGN,
@@ -75,6 +76,7 @@ gtk_cell_renderer_init (GtkCellRenderer *cell)
gtk_object_ref (GTK_OBJECT (cell));
gtk_object_sink (GTK_OBJECT (cell));
+ cell->can_activate = FALSE;
cell->visible = TRUE;
cell->xalign = 0.5;
cell->yalign = 0.5;
@@ -94,6 +96,15 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
class->get_size = NULL;
g_object_class_install_property (object_class,
+ PROP_CAN_ACTIVATE,
+ g_param_spec_boolean ("can_activate",
+ _("can_activate"),
+ _("Cell can get activate events."),
+ FALSE,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE));
+
+ g_object_class_install_property (object_class,
PROP_VISIBLE,
g_param_spec_boolean ("visible",
_("visible"),
@@ -101,7 +112,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
TRUE,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
-
+
g_object_class_install_property (object_class,
PROP_XALIGN,
g_param_spec_float ("xalign",
@@ -112,7 +123,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
0.0,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
-
+
g_object_class_install_property (object_class,
PROP_YALIGN,
g_param_spec_float ("yalign",
@@ -123,7 +134,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
0.5,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
-
+
g_object_class_install_property (object_class,
PROP_XPAD,
g_param_spec_uint ("xpad",
@@ -134,7 +145,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
2,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
-
+
g_object_class_install_property (object_class,
PROP_YPAD,
g_param_spec_uint ("ypad",
@@ -157,6 +168,9 @@ gtk_cell_renderer_get_property (GObject *object,
switch (param_id)
{
+ case PROP_CAN_ACTIVATE:
+ g_value_set_boolean (value, cell->can_activate);
+ break;
case PROP_VISIBLE:
g_value_set_boolean (value, cell->visible);
break;
@@ -189,6 +203,10 @@ gtk_cell_renderer_set_property (GObject *object,
switch (param_id)
{
+ case PROP_CAN_ACTIVATE:
+ cell->can_activate = g_value_get_boolean (value);
+ g_object_notify (object, "can_activate");
+ break;
case PROP_VISIBLE:
cell->visible = g_value_get_boolean (value);
g_object_notify (object, "visible");
@@ -219,23 +237,30 @@ gtk_cell_renderer_set_property (GObject *object,
* gtk_cell_renderer_get_size:
* @cell: a #GtkCellRenderer
* @widget: the widget the renderer is rendering to
+ * @cell_area: The area a cell will be allocated, or %NULL
+ * @x_offset: location to return x offset of cell relative to @cell_area, or %NULL
+ * @y_offset: location to return y offset of cell relative to @cell_area, or %NULL
* @width: location to return width needed to render a cell, or %NULL
* @height: location to return height needed to render a cell, or %NULL
- *
- * Obtains the width and height needed to render the cell. Used by
- * view widgets to determine the appropriate size for the cell_area
- * passed to gtk_cell_renderer_render().
+ *
+ * Obtains the width and height needed to render the cell. Used by view widgets
+ * to determine the appropriate size for the cell_area passed to
+ * gtk_cell_renderer_render(). If @cell_area is not %NULL, fills in the x and y
+ * offsets (if set) of the cell relative to this location.
**/
void
gtk_cell_renderer_get_size (GtkCellRenderer *cell,
- GtkWidget *widget,
- gint *width,
- gint *height)
+ GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
+ gint *width,
+ gint *height)
{
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size != NULL);
- GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, width, height);
+ GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, cell_area, x_offset, y_offset, width, height);
}
/**
@@ -257,7 +282,7 @@ gtk_cell_renderer_get_size (GtkCellRenderer *cell,
* @background_area rectangles for all cells tile to cover the entire
* @window. Cell renderers can use the @background_area to draw custom expanders, for
* example. @expose_area is a clip rectangle.
- *
+ *
**/
void
gtk_cell_renderer_render (GtkCellRenderer *cell,
@@ -294,11 +319,11 @@ gtk_cell_renderer_render (GtkCellRenderer *cell,
* @background_area: background area as passed to gtk_cell_renderer_render()
* @cell_area: cell area as passed to gtk_cell_renderer_render()
* @flags: render flags
- *
+ *
* Passes an event to the cell renderer for possible processing. Some
* cell renderers may use events; for example, #GtkCellRendererToggle
* toggles when it gets a mouse click.
- *
+ *
* Return value: %TRUE if the event was consumed/handled
**/
gint
diff --git a/gtk/gtkcellrenderer.h b/gtk/gtkcellrenderer.h
index bca36e4627..079794a5f7 100644
--- a/gtk/gtkcellrenderer.h
+++ b/gtk/gtkcellrenderer.h
@@ -51,6 +51,7 @@ struct _GtkCellRenderer
{
GtkObject parent;
+ gboolean can_activate;
gboolean visible;
gfloat xalign;
@@ -67,6 +68,9 @@ struct _GtkCellRendererClass
/* vtable - not signals */
void (* get_size) (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
@@ -90,6 +94,9 @@ struct _GtkCellRendererClass
GtkType gtk_cell_renderer_get_type (void);
void gtk_cell_renderer_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
void gtk_cell_renderer_render (GtkCellRenderer *cell,
diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c
index 67db583562..36ead4e08b 100644
--- a/gtk/gtkcellrendererpixbuf.c
+++ b/gtk/gtkcellrendererpixbuf.c
@@ -33,6 +33,9 @@ static void gtk_cell_renderer_pixbuf_init (GtkCellRendererPixbuf *cel
static void gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class);
static void gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *rectangle,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
static void gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
@@ -172,18 +175,47 @@ gtk_cell_renderer_pixbuf_new (void)
static void
gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height)
{
GtkCellRendererPixbuf *cellpixbuf = (GtkCellRendererPixbuf *) cell;
+ GdkPixbuf *pixbuf;
+ gint calc_width;
+ gint calc_height;
+
+ pixbuf = cellpixbuf->pixbuf;
+
+ calc_width = (gint) GTK_CELL_RENDERER (cellpixbuf)->xpad * 2 +
+ (cellpixbuf->pixbuf ? gdk_pixbuf_get_width (cellpixbuf->pixbuf) : 0);
- if (width)
- *width = (gint) GTK_CELL_RENDERER (cellpixbuf)->xpad * 2 +
- (cellpixbuf->pixbuf ? gdk_pixbuf_get_width (cellpixbuf->pixbuf) : 0);
+ calc_height = (gint) GTK_CELL_RENDERER (cellpixbuf)->ypad * 2 +
+ (cellpixbuf->pixbuf ? gdk_pixbuf_get_height (cellpixbuf->pixbuf) : 0);
+
+ if (x_offset) *x_offset = 0;
+ if (y_offset) *y_offset = 0;
+
+ if (cell_area && pixbuf)
+ {
+ if (x_offset)
+ {
+ *x_offset = GTK_CELL_RENDERER (cellpixbuf)->xalign * (cell_area->width - calc_width - (2 * GTK_CELL_RENDERER (cellpixbuf)->xpad));
+ *x_offset = MAX (*x_offset, 0) + GTK_CELL_RENDERER (cellpixbuf)->xpad;
+ }
+ if (y_offset)
+ {
+ *y_offset = GTK_CELL_RENDERER (cellpixbuf)->yalign * (cell_area->height - calc_height - (2 * GTK_CELL_RENDERER (cellpixbuf)->ypad));
+ *y_offset = MAX (*y_offset, 0) + GTK_CELL_RENDERER (cellpixbuf)->ypad;
+ }
+ }
+
+ if (calc_width)
+ *width = calc_width;
if (height)
- *height = (gint) GTK_CELL_RENDERER (cellpixbuf)->ypad * 2 +
- (cellpixbuf->pixbuf ? gdk_pixbuf_get_height (cellpixbuf->pixbuf) : 0);
+ *height = calc_height;
}
static void
@@ -200,8 +232,6 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
GdkPixbuf *pixbuf;
guchar *pixels;
gint rowstride;
- gint real_xoffset;
- gint real_yoffset;
GdkRectangle pix_rect;
GdkRectangle draw_rect;
@@ -213,15 +243,13 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
pixels = gdk_pixbuf_get_pixels (pixbuf);
- real_xoffset = GTK_CELL_RENDERER (cellpixbuf)->xalign * (cell_area->width - gdk_pixbuf_get_width (pixbuf) - (2 * GTK_CELL_RENDERER (cellpixbuf)->xpad));
- real_xoffset = MAX (real_xoffset, 0) + GTK_CELL_RENDERER (cellpixbuf)->xpad;
- real_yoffset = GTK_CELL_RENDERER (cellpixbuf)->yalign * (cell_area->height - gdk_pixbuf_get_height (pixbuf) - (2 * GTK_CELL_RENDERER (cellpixbuf)->ypad));
- real_yoffset = MAX (real_yoffset, 0) + GTK_CELL_RENDERER (cellpixbuf)->ypad;
-
- pix_rect.x = cell_area->x + real_xoffset;
- pix_rect.y = cell_area->y + real_yoffset;
- pix_rect.width = gdk_pixbuf_get_width (pixbuf);
- pix_rect.height = gdk_pixbuf_get_height (pixbuf);
+ gtk_cell_renderer_pixbuf_get_size (cell, widget, cell_area,
+ &pix_rect.x,
+ &pix_rect.x,
+ &pix_rect.width,
+ &pix_rect.height);
+ pix_rect.x += cell_area->x;
+ pix_rect.y += cell_area->y;
if (gdk_rectangle_intersect (cell_area, &pix_rect, &draw_rect))
gdk_pixbuf_render_to_drawable_alpha (pixbuf,
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index 8e297cd84e..c3a0e52cd0 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -35,6 +35,9 @@ static void gtk_cell_renderer_text_set_property (GObject *obje
GParamSpec *pspec);
static void gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
static void gtk_cell_renderer_text_render (GtkCellRenderer *cell,
@@ -1048,6 +1051,9 @@ get_layout (GtkCellRendererText *celltext,
static void
gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height)
{
@@ -1056,7 +1062,6 @@ gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
PangoLayout *layout;
layout = get_layout (celltext, widget, FALSE, 0);
-
pango_layout_get_pixel_extents (layout, NULL, &rect);
if (width)
@@ -1065,6 +1070,20 @@ gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
if (height)
*height = GTK_CELL_RENDERER (celltext)->ypad * 2 + rect.height;
+ if (cell_area)
+ {
+ if (x_offset)
+ {
+ *x_offset = cell->xalign * (cell_area->width - rect.width - (2 * cell->xpad));
+ *x_offset = MAX (*x_offset, 0) + cell->xpad;
+ }
+ if (y_offset)
+ {
+ *y_offset = cell->yalign * (cell_area->height - rect.height - (2 * cell->ypad));
+ *y_offset = MAX (*y_offset, 0) + cell->ypad;
+ }
+ }
+
g_object_unref (G_OBJECT (layout));
}
@@ -1079,21 +1098,14 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
{
GtkCellRendererText *celltext = (GtkCellRendererText *) cell;
- PangoRectangle rect;
PangoLayout *layout;
GtkStateType state;
-
- gint real_xoffset;
- gint real_yoffset;
+ gint x_offset;
+ gint y_offset;
layout = get_layout (celltext, widget, TRUE, flags);
- pango_layout_get_pixel_extents (layout, NULL, &rect);
-
- real_xoffset = cell->xalign * (cell_area->width - rect.width - (2 * cell->xpad));
- real_xoffset = MAX (real_xoffset, 0) + cell->xpad;
- real_yoffset = cell->yalign * (cell_area->height - rect.height - (2 * cell->ypad));
- real_yoffset = MAX (real_yoffset, 0) + cell->ypad;
+ gtk_cell_renderer_text_get_size (cell, widget, cell_area, &x_offset, &y_offset, NULL, NULL);
if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
state = GTK_STATE_SELECTED;
@@ -1130,8 +1142,8 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
cell_area,
widget,
"cellrenderertext",
- cell_area->x + real_xoffset,
- cell_area->y + real_yoffset,
+ cell_area->x + x_offset,
+ cell_area->y + y_offset,
layout);
g_object_unref (G_OBJECT (layout));
diff --git a/gtk/gtkcellrenderertextpixbuf.c b/gtk/gtkcellrenderertextpixbuf.c
index 9be2e15306..62da0d6c73 100644
--- a/gtk/gtkcellrenderertextpixbuf.c
+++ b/gtk/gtkcellrenderertextpixbuf.c
@@ -44,6 +44,9 @@ static void gtk_cell_renderer_text_pixbuf_init (GtkCellRendererTextPixbuf
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,
@@ -285,6 +288,9 @@ gtk_cell_renderer_text_pixbuf_new (void)
typedef void (* CellSizeFunc) (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *rectangle,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
typedef void (* CellRenderFunc) (GtkCellRenderer *cell,
@@ -298,6 +304,9 @@ typedef void (* CellRenderFunc) (GtkCellRenderer *cell,
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)
{
@@ -306,26 +315,44 @@ gtk_cell_renderer_text_pixbuf_get_size (GtkCellRenderer *cell,
gint pixbuf_height;
gint text_width;
gint text_height;
-
- (* GTK_CELL_RENDERER_CLASS (parent_class)->get_size) (cell, widget, &text_width, &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)
{
- if (width)
- *width = pixbuf_width + text_width;
- if (height)
- *height = MAX (pixbuf_height, text_height);
+ calc_width = pixbuf_width + text_width;
+ calc_height = MAX (pixbuf_height, text_height);
}
else
{
- if (width)
- *width = MAX (pixbuf_width, text_width);
- if (height)
- *height = pixbuf_height + text_height;
+ 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;
+ }
}
}
@@ -369,7 +396,7 @@ gtk_cell_renderer_text_pixbuf_render (GtkCellRenderer *cell,
cell2 = GTK_CELL_RENDERER (celltextpixbuf->pixbuf);
}
- (size_func1) (cell1, widget, &tmp_width, &tmp_height);
+ (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;
diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c
index 66f20eccae..1649021574 100644
--- a/gtk/gtkcellrenderertoggle.c
+++ b/gtk/gtkcellrenderertoggle.c
@@ -34,6 +34,9 @@ static void gtk_cell_renderer_toggle_init (GtkCellRendererToggle *cel
static void gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class);
static void gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
static void gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
@@ -100,6 +103,7 @@ gtk_cell_renderer_toggle_init (GtkCellRendererToggle *celltoggle)
{
celltoggle->active = FALSE;
celltoggle->radio = FALSE;
+ GTK_CELL_RENDERER (celltoggle)->can_activate = TRUE;
GTK_CELL_RENDERER (celltoggle)->xpad = 2;
GTK_CELL_RENDERER (celltoggle)->ypad = 2;
}
@@ -215,14 +219,37 @@ gtk_cell_renderer_toggle_new (void)
static void
gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height)
{
+ gint calc_width;
+ gint calc_height;
+
+ calc_width = (gint) cell->xpad * 2 + TOGGLE_WIDTH;
+ calc_height = (gint) cell->ypad * 2 + TOGGLE_WIDTH;
+
if (width)
- *width = (gint) cell->xpad * 2 + TOGGLE_WIDTH;
+ *width = calc_width;
if (height)
- *height = (gint) cell->ypad * 2 + TOGGLE_WIDTH;
+ *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
@@ -236,25 +263,26 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
{
GtkCellRendererToggle *celltoggle = (GtkCellRendererToggle *) cell;
gint width, height;
- gint real_xoffset, real_yoffset;
+ gint x_offset, y_offset;
GtkShadowType shadow;
GtkStateType state;
width = MIN (TOGGLE_WIDTH, cell_area->width - cell->xpad * 2);
height = MIN (TOGGLE_WIDTH, cell_area->height - cell->ypad * 2);
+ gtk_cell_renderer_toggle_get_size (cell, widget, cell_area,
+ &x_offset, &y_offset,
+ &width, &height);
+
if (width <= 0 || height <= 0)
return;
- real_xoffset = cell->xalign * (cell_area->width - width - (2 * cell->xpad));
- real_xoffset = MAX (real_xoffset, 0) + cell->xpad;
- real_yoffset = cell->yalign * (cell_area->height - height - (2 * cell->ypad));
- real_yoffset = MAX (real_yoffset, 0) + cell->ypad;
-
shadow = celltoggle->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
state = GTK_STATE_SELECTED;
+ else if (! cell->can_activate)
+ state = GTK_STATE_INSENSITIVE;
else
state = GTK_STATE_NORMAL;
@@ -264,8 +292,8 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
window,
state, shadow,
cell_area, widget, "cellradio",
- cell_area->x + real_xoffset,
- cell_area->y + real_yoffset,
+ cell_area->x + x_offset,
+ cell_area->y + y_offset,
width, height);
}
else
@@ -274,8 +302,8 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
window,
state, shadow,
cell_area, widget, "cellcheck",
- cell_area->x + real_xoffset,
- cell_area->y + real_yoffset,
+ cell_area->x + x_offset,
+ cell_area->y + y_offset,
width, height);
}
}
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 9b70e58e69..4f4922d7b9 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -3332,6 +3332,19 @@ gtk_default_draw_focus (GtkStyle *style,
gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
}
+ else if (detail && strcmp (detail, "treeview") == 0)
+ {
+
+ gdk_gc_set_background (style->black_gc, &style->white);
+ gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_DOUBLE_DASH, 0, 0);
+ gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
+
+ gdk_draw_rectangle (window,
+ style->black_gc, FALSE,
+ x, y, width, height);
+
+ gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
+ }
else
{
gdk_draw_rectangle (window,
diff --git a/gtk/gtktreemodel.h b/gtk/gtktreemodel.h
index f16fc12f3f..9d3c5422fa 100644
--- a/gtk/gtktreemodel.h
+++ b/gtk/gtktreemodel.h
@@ -30,7 +30,6 @@ extern "C" {
#define GTK_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_MODEL, GtkTreeModel))
#define GTK_IS_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_MODEL))
#define GTK_TREE_MODEL_GET_IFACE(obj) ((GtkTreeModelIface *)g_type_interface_peek (((GTypeInstance *)GTK_TREE_MODEL (obj))->g_class, GTK_TYPE_TREE_MODEL))
-
typedef struct _GtkTreeIter GtkTreeIter;
typedef struct _GtkTreePath GtkTreePath;
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 2c074fe84e..c11af64552 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -108,6 +108,8 @@ static gboolean gtk_tree_view_button_press (GtkWidget *widget,
GdkEventButton *event);
static gboolean gtk_tree_view_button_release (GtkWidget *widget,
GdkEventButton *event);
+static void gtk_tree_view_set_focus_child (GtkContainer *container,
+ GtkWidget *child);
static void gtk_tree_view_draw_focus (GtkWidget *widget);
static gint gtk_tree_view_focus_in (GtkWidget *widget,
GdkEventFocus *event);
@@ -288,7 +290,7 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
o_class->get_property = gtk_tree_view_get_property;
object_class->destroy = gtk_tree_view_destroy;
-
+
widget_class->realize = gtk_tree_view_realize;
widget_class->unrealize = gtk_tree_view_unrealize;
widget_class->map = gtk_tree_view_map;
@@ -452,6 +454,7 @@ gtk_tree_view_destroy (GtkObject *object)
GtkTreeView *tree_view = (GtkTreeView *) object;
GList *list;
+ g_object_unref (G_OBJECT (tree_view->priv->model));
gtk_tree_view_unref_tree (tree_view, tree_view->priv->tree);
for (list = tree_view->priv->columns; list; list = list->next)
@@ -937,38 +940,6 @@ gtk_tree_view_size_allocate (GtkWidget *widget,
}
-static void
-gtk_tree_view_draw_node_focus_rect (GtkWidget *widget,
- GtkTreePath *path)
-{
- GtkTreeView *tree_view;
- GtkRBTree *tree = NULL;
- GtkRBNode *node = NULL;
- gint bin_window_width = 0;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_TREE_VIEW (widget));
-
- tree_view = GTK_TREE_VIEW (widget);
-
- _gtk_tree_view_find_node (tree_view, path, &tree, &node);
-
- if (tree == NULL)
- return;
-
- gdk_drawable_get_size (tree_view->priv->bin_window,
- &bin_window_width, NULL);
-
- /* FIXME need a style function appropriate for this */
- gdk_draw_rectangle (tree_view->priv->bin_window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- FALSE,
- 0,
- BACKGROUND_FIRST_PIXEL (tree_view, tree, node),
- bin_window_width - 2,
- BACKGROUND_HEIGHT (node) - 1);
-}
-
GdkPixmap*
gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
GtkTreePath *path)
@@ -1036,6 +1007,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
{
GtkTreeViewColumn *column = list->data;
GdkRectangle cell_area;
+ gboolean visible;
if (!column->visible)
continue;
@@ -1059,7 +1031,9 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
cell_area.x += depth * tree_view->priv->tab_offset;
cell_area.width -= depth * tree_view->priv->tab_offset;
}
- if (cell->visible)
+
+ g_object_get (G_OBJECT (cell), "visible", &visible, NULL);
+ if (visible)
gtk_cell_renderer_render (cell,
drawable,
widget,
@@ -1292,6 +1266,8 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
if (i == tree_view->priv->expander_column &&
TREE_VIEW_DRAW_EXPANDERS(tree_view))
{
+ gboolean visible;
+
cell_area.x += depth*tree_view->priv->tab_offset;
cell_area.width -= depth*tree_view->priv->tab_offset;
@@ -1301,7 +1277,8 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
*/
highlight_x = cell_area.x;
- if (cell->visible)
+ g_object_get (G_OBJECT (cell), "visible", &visible, NULL);
+ if (visible)
gtk_cell_renderer_render (cell,
event->window,
widget,
@@ -1322,7 +1299,10 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
}
else
{
- if (cell->visible)
+ gboolean visible;
+ g_object_get (G_OBJECT (cell), "visible", &visible, NULL);
+
+ if (visible)
gtk_cell_renderer_render (cell,
event->window,
widget,
@@ -1334,8 +1314,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
cell_offset += column->displayed_width;
}
- if (node == cursor &&
- GTK_WIDGET_HAS_FOCUS (widget))
+ if (node == cursor && GTK_WIDGET_HAS_FOCUS (widget))
gtk_tree_view_draw_focus (widget);
if (node == drag_highlight)
@@ -1343,6 +1322,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
/* Draw indicator for the drop
*/
gint highlight_y = -1;
+ GtkRBTree *tree = NULL;
+ GtkRBNode *node = NULL;
+ gint width;
switch (tree_view->priv->drag_dest_pos)
{
@@ -1356,8 +1338,20 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
- gtk_tree_view_draw_node_focus_rect (widget,
- drag_dest_path);
+ _gtk_tree_view_find_node (tree_view, drag_dest_path, &tree, &node);
+
+ if (tree == NULL)
+ break;
+ gdk_drawable_get_size (tree_view->priv->bin_window,
+ &width, NULL);
+ gtk_paint_focus (widget->style,
+ tree_view->priv->bin_window,
+ NULL,
+ widget,
+ "add-mode",
+ 0, BACKGROUND_FIRST_PIXEL (tree_view, tree, node),
+ width - 1, BACKGROUND_HEIGHT (node) - 1);
+
break;
}
@@ -1776,6 +1770,7 @@ gtk_tree_view_button_press (GtkWidget *widget,
GtkTreeViewColumn *column = list->data;
GtkCellRenderer *cell;
GtkTreeIter iter;
+ gboolean visible;
if (!column->visible)
continue;
@@ -1812,14 +1807,15 @@ gtk_tree_view_button_press (GtkWidget *widget,
&iter);
path_string = gtk_tree_path_to_string (path);
- if (cell->visible &&
- gtk_cell_renderer_event (cell,
- (GdkEvent *)event,
- widget,
- path_string,
- &background_area,
- &cell_area,
- 0))
+
+ g_object_get (G_OBJECT (cell), "visible", &visible, NULL);
+ if (visible && gtk_cell_renderer_event (cell,
+ (GdkEvent *)event,
+ widget,
+ path_string,
+ &background_area,
+ &cell_area,
+ 0))
{
g_free (path_string);
gtk_tree_path_free (path);
@@ -1989,12 +1985,21 @@ gtk_tree_view_button_release (GtkWidget *widget,
return TRUE;
}
+static void
+gtk_tree_view_set_focus_child (GtkContainer *container,
+ GtkWidget *child)
+{
+}
static void
gtk_tree_view_draw_focus (GtkWidget *widget)
{
GtkTreeView *tree_view;
GtkTreePath *cursor_path;
+ GtkRBTree *tree = NULL;
+ GtkRBNode *node = NULL;
+ gint x, y;
+ gint width, height;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW (widget));
@@ -2011,7 +2016,65 @@ gtk_tree_view_draw_focus (GtkWidget *widget)
if (cursor_path == NULL)
return;
- gtk_tree_view_draw_node_focus_rect (widget, cursor_path);
+ _gtk_tree_view_find_node (tree_view, cursor_path, &tree, &node);
+
+ if (tree == NULL)
+ {
+ gtk_tree_path_free (cursor_path);
+ return;
+ }
+
+ gdk_drawable_get_size (tree_view->priv->bin_window,
+ &width, NULL);
+
+
+ x = 0;
+ y = BACKGROUND_FIRST_PIXEL (tree_view, tree, node);
+ gdk_drawable_get_size (tree_view->priv->bin_window,
+ &width, NULL);
+ width = width - 1;
+ height = BACKGROUND_HEIGHT (node) - 1;
+ if (tree_view->priv->focus_column != NULL)
+ {
+ GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (tree_view->priv->focus_column->data);
+ gboolean visible;
+ gboolean can_focus;
+
+ g_object_get (G_OBJECT (column->cell),
+ "can_activate", &can_focus,
+ "visible", &visible,
+ NULL);
+ if (can_focus && visible)
+ {
+ GtkTreeIter iter;
+ GdkRectangle cell_area;
+ gint x_offset;
+ gint y_offset;
+
+ cell_area.x = column->button->allocation.x;
+ cell_area.y = y;
+ cell_area.width = column->displayed_width;
+ cell_area.height = CELL_HEIGHT (node);
+
+ gtk_tree_model_get_iter (tree_view->priv->model, &iter, cursor_path);
+ gtk_tree_view_column_set_cell_data (column, tree_view->priv->model, &iter);
+
+ gtk_cell_renderer_get_size (column->cell, GTK_WIDGET (tree_view), &cell_area, &x_offset, &y_offset, &width, &height);
+ width += 2;
+ height += 2;
+ x = cell_area.x + x_offset - 1;
+ y = cell_area.y + y_offset - 1 + TREE_VIEW_VERTICAL_SEPARATOR/2;
+ }
+ }
+
+ gtk_paint_focus (widget->style,
+ tree_view->priv->bin_window,
+ NULL,
+ widget,
+ "add-mode",
+ x, y, width, height);
+
+ gtk_tree_path_free (cursor_path);
}
@@ -2096,10 +2159,10 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view,
case GTK_DIR_DOWN:
if (focus_child == NULL)
{
- if (tree_view->priv->focus_column == NULL)
- focus_child = GTK_TREE_VIEW_COLUMN (first_column->data)->button;
- else
+ if (tree_view->priv->focus_column != NULL)
focus_child = GTK_TREE_VIEW_COLUMN (tree_view->priv->focus_column->data)->button;
+ else
+ focus_child = GTK_TREE_VIEW_COLUMN (first_column->data)->button;
gtk_widget_grab_focus (focus_child);
break;
}
@@ -2109,8 +2172,14 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view,
case GTK_DIR_RIGHT:
if (focus_child == NULL)
{
- g_assert_not_reached ();
- return FALSE;
+ if (tree_view->priv->focus_column != NULL)
+ focus_child = GTK_TREE_VIEW_COLUMN (tree_view->priv->focus_column->data)->button;
+ else if (dir == GTK_DIR_LEFT)
+ focus_child = GTK_TREE_VIEW_COLUMN (last_column->data)->button;
+ else
+ focus_child = GTK_TREE_VIEW_COLUMN (first_column->data)->button;
+ gtk_widget_grab_focus (focus_child);
+ break;
}
if (gtk_container_focus (GTK_CONTAINER (focus_child), dir))
@@ -2172,6 +2241,12 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view,
*/
if (focus_child)
{
+ for (tmp_list = tree_view->priv->columns; tmp_list; tmp_list = tmp_list->next)
+ if (GTK_TREE_VIEW_COLUMN (tmp_list->data)->button == focus_child)
+ break;
+
+ tree_view->priv->focus_column = tmp_list;
+
/* If the following isn't true, then the view is smaller then the scrollpane.
*/
if ((focus_child->allocation.x + focus_child->allocation.width) <=
@@ -2192,7 +2267,10 @@ gtk_tree_view_header_focus (GtkTreeView *tree_view,
return (focus_child != NULL);
}
-/* WARNING: Scary function */
+/* WARNING: Somewhat scary function */
+/* We make the assumption that if container->focus_child != NULL, the focus must
+ * be in the header. For now, this is accurate. It may not be in the future.
+ */
static gint
gtk_tree_view_focus (GtkContainer *container,
GtkDirectionType direction)
@@ -2212,8 +2290,6 @@ gtk_tree_view_focus (GtkContainer *container,
if (!GTK_WIDGET_IS_SENSITIVE (container))
return FALSE;
- if (tree_view->priv->tree == NULL)
- return FALSE;
focus_child = container->focus_child;
@@ -2230,6 +2306,10 @@ gtk_tree_view_focus (GtkContainer *container,
return FALSE;
case GTK_DIR_TAB_FORWARD:
case GTK_DIR_DOWN:
+
+ if (tree_view->priv->tree == NULL)
+ return FALSE;
+
GTK_TREE_VIEW_SET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
gtk_widget_grab_focus (GTK_WIDGET (container));
@@ -2273,11 +2353,10 @@ gtk_tree_view_focus (GtkContainer *container,
{
if ((direction == GTK_DIR_TAB_FORWARD) ||
(direction == GTK_DIR_RIGHT) ||
- (direction == GTK_DIR_DOWN))
- {
- if (gtk_tree_view_header_focus (tree_view, direction))
- return TRUE;
- }
+ (direction == GTK_DIR_DOWN) ||
+ (direction == GTK_DIR_LEFT) ||
+ (tree_view->priv->tree == NULL))
+ return gtk_tree_view_header_focus (tree_view, direction);
/* The headers didn't want the focus, so we take it. */
GTK_TREE_VIEW_SET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
@@ -2313,14 +2392,21 @@ gtk_tree_view_focus (GtkContainer *container,
return TRUE;
}
+ /* Case 3. We have focus already. */
+ if (tree_view->priv->tree == NULL)
+ return FALSE;
+
+ if (direction == GTK_DIR_TAB_BACKWARD)
+ return (gtk_tree_view_header_focus (tree_view, direction));
+ else if (direction == GTK_DIR_TAB_FORWARD)
+ return FALSE;
+
cursor_path = NULL;
if (tree_view->priv->cursor)
cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
- /* Case 3. We have focus already, but no cursor. We pick the first one
- * and run with it.
- */
-
+ /* Do we have a focus path? We should, unless it was deleted. */
+ /* in that case, we pick the first one arbitrarily */
if (cursor_path == NULL)
{
GtkTreePath *tmp_path = gtk_tree_path_new_root ();
@@ -2447,9 +2533,7 @@ gtk_tree_view_focus (GtkContainer *container,
/* At this point, we've progressed beyond the edge of the rows. */
- if ((direction == GTK_DIR_LEFT) ||
- (direction == GTK_DIR_TAB_BACKWARD) ||
- (direction == GTK_DIR_UP))
+ if (direction == GTK_DIR_UP)
/* We can't go back anymore. Try the headers */
return (gtk_tree_view_header_focus (tree_view, direction));
@@ -2616,6 +2700,9 @@ gtk_tree_view_inserted (GtkTreeModel *model,
gint i = 0;
gboolean free_path = FALSE;
+ if (tree_view->priv->tree == NULL)
+ tree_view->priv->tree = _gtk_rbtree_new ();
+
tmptree = tree = tree_view->priv->tree;
g_return_if_fail (path != NULL || iter != NULL);
@@ -2749,6 +2836,7 @@ gtk_tree_view_has_child_toggled (GtkTreeModel *model,
if (GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_SHOW_EXPANDERS))
{
GList *list;
+
for (list = tree_view->priv->columns; list; list = list->next)
if (GTK_TREE_VIEW_COLUMN (list->data)->visible)
{
@@ -2825,9 +2913,11 @@ gtk_tree_view_deleted (GtkTreeModel *model,
g_assert (tree_view->priv->prelight_node == NULL);
- if ((tree->root->count == 1) &&
- (tree_view->priv->tree != tree))
+ if (tree->root->count == 1)
{
+ if (tree_view->priv->tree == tree)
+ tree_view->priv->tree = NULL;
+
_gtk_rbtree_remove (tree);
}
else
@@ -2871,7 +2961,7 @@ gtk_tree_view_insert_iter_height (GtkTreeView *tree_view,
cell = column->cell;
gtk_tree_view_column_set_cell_data (column, tree_view->priv->model, iter);
- gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), &width, &height);
+ gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, &height);
max_height = MAX (max_height, TREE_VIEW_VERTICAL_SEPARATOR + height);
if (i == tree_view->priv->expander_column &&
@@ -2965,7 +3055,7 @@ gtk_tree_view_calc_size (GtkTreeView *tree_view,
gtk_tree_view_column_set_cell_data (column, tree_view->priv->model, iter);
cell = column->cell;
- gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), &width, &height);
+ gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, &height);
max_height = MAX (max_height, TREE_VIEW_VERTICAL_SEPARATOR + height);
/* FIXME: I'm getting the width of all nodes here. )-: */
@@ -3022,12 +3112,12 @@ gtk_tree_view_discover_dirty_iter (GtkTreeView *tree_view,
if (height)
{
- gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), &width, &tmpheight);
+ gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, &tmpheight);
*height = MAX (*height, tmpheight);
}
else
{
- gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), &width, NULL);
+ gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, NULL);
}
if (i == tree_view->priv->expander_column &&
TREE_VIEW_DRAW_EXPANDERS (tree_view))
@@ -3680,7 +3770,7 @@ gtk_tree_view_setup_model (GtkTreeView *tree_view)
GtkTreePath *path;
GtkTreeIter iter;
- tree_view->priv->tree = _gtk_rbtree_new ();
+ tree_view->priv->tree = NULL;
g_signal_connectc (tree_view->priv->model,
"changed",
@@ -3710,6 +3800,7 @@ gtk_tree_view_setup_model (GtkTreeView *tree_view)
if (gtk_tree_model_get_iter (tree_view->priv->model, &iter, path))
{
+ tree_view->priv->tree = _gtk_rbtree_new ();
gtk_tree_view_build_tree (tree_view, tree_view->priv->tree, &iter, 1, FALSE, GTK_WIDGET_REALIZED (tree_view));
}
@@ -3766,6 +3857,7 @@ gtk_tree_view_set_model (GtkTreeView *tree_view,
}
tree_view->priv->model = model;
+ g_object_ref (model);
if (model == NULL)
{
tree_view->priv->tree = NULL;
@@ -4133,7 +4225,8 @@ gtk_tree_view_remove_column (GtkTreeView *tree_view,
_gtk_tree_view_column_unset_tree_view (column);
- if (GTK_TREE_VIEW_COLUMN (tree_view->priv->focus_column->data) == column)
+ if (tree_view->priv->focus_column &&
+ GTK_TREE_VIEW_COLUMN (tree_view->priv->focus_column->data) == column)
tree_view->priv->focus_column = NULL;
tree_view->priv->columns = g_list_remove (tree_view->priv->columns, column);
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index 09e5104558..76ced1d85e 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -1504,6 +1504,8 @@ gtk_tree_view_column_set_sort_indicator (GtkTreeViewColumn *tree_column,
update_button_contents (tree_column);
g_object_notify (G_OBJECT (tree_column), "sort_indicator");
+ if (GTK_WIDGET_REALIZED (tree_column->tree_view))
+ gtk_widget_queue_draw (tree_column->tree_view);
}
}
diff --git a/gtk/gtktreeviewcolumn.h b/gtk/gtktreeviewcolumn.h
index a903129173..e59cd3c14b 100644
--- a/gtk/gtktreeviewcolumn.h
+++ b/gtk/gtktreeviewcolumn.h
@@ -118,7 +118,7 @@ void gtk_tree_view_column_set_visible (GtkTreeViewColumn
gboolean visible);
gboolean gtk_tree_view_column_get_visible (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column,
- GtkTreeViewColumnSizing type);
+ GtkTreeViewColumnSizing type);
gint gtk_tree_view_column_get_sizing (GtkTreeViewColumn *tree_column);
gint gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_width (GtkTreeViewColumn *tree_column,
@@ -143,7 +143,7 @@ void gtk_tree_view_column_set_clickable (GtkTreeViewColumn
gboolean gtk_tree_view_column_get_clickable (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column,
GtkWidget *widget);
-GtkWidget * gtk_tree_view_column_get_widget (GtkTreeViewColumn *tree_column);
+GtkWidget *gtk_tree_view_column_get_widget (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_alignment (GtkTreeViewColumn *tree_column,
gfloat xalign);
gfloat gtk_tree_view_column_get_alignment (GtkTreeViewColumn *tree_column);
@@ -163,3 +163,4 @@ GtkTreeSortOrder gtk_tree_view_column_get_sort_order (GtkTreeViewColumn
#endif /* __cplusplus */
#endif /* __GTK_TREE_VIEW_COLUMN_H__ */
+
diff --git a/gtk/testdnd.c b/gtk/testdnd.c
index 203272996d..a35115fec1 100644
--- a/gtk/testdnd.c
+++ b/gtk/testdnd.c
@@ -303,6 +303,7 @@ target_drag_motion (GtkWidget *widget,
guint time)
{
GtkWidget *source_widget;
+ GList *tmp_list;
if (!have_drag)
{
@@ -315,6 +316,16 @@ target_drag_motion (GtkWidget *widget,
GTK_OBJECT_TYPE_NAME (source_widget) :
"NULL");
+ tmp_list = context->targets;
+ while (tmp_list)
+ {
+ char *name = gdk_atom_name (GPOINTER_TO_UINT (tmp_list->data));
+ g_print ("%s\n", name);
+ g_free (name);
+
+ tmp_list = tmp_list->next;
+ }
+
gdk_drag_status (context, context->suggested_action, time);
return TRUE;
}
diff --git a/tests/testdnd.c b/tests/testdnd.c
index 203272996d..a35115fec1 100644
--- a/tests/testdnd.c
+++ b/tests/testdnd.c
@@ -303,6 +303,7 @@ target_drag_motion (GtkWidget *widget,
guint time)
{
GtkWidget *source_widget;
+ GList *tmp_list;
if (!have_drag)
{
@@ -315,6 +316,16 @@ target_drag_motion (GtkWidget *widget,
GTK_OBJECT_TYPE_NAME (source_widget) :
"NULL");
+ tmp_list = context->targets;
+ while (tmp_list)
+ {
+ char *name = gdk_atom_name (GPOINTER_TO_UINT (tmp_list->data));
+ g_print ("%s\n", name);
+ g_free (name);
+
+ tmp_list = tmp_list->next;
+ }
+
gdk_drag_status (context, context->suggested_action, time);
return TRUE;
}
diff --git a/tests/testtreefocus.c b/tests/testtreefocus.c
index f46d6992e4..c768a70d54 100644
--- a/tests/testtreefocus.c
+++ b/tests/testtreefocus.c
@@ -4,127 +4,130 @@ typedef struct _TreeStruct TreeStruct;
struct _TreeStruct
{
const gchar *label;
+ gboolean alex;
gboolean havoc;
+ gboolean tim;
gboolean owen;
+ gboolean world_holiday; /* shared by the european hackers */
TreeStruct *children;
};
static TreeStruct january[] =
{
- {"New Years Day", TRUE, TRUE, NULL},
- {"Presidential Inauguration", TRUE, TRUE, NULL},
- {"Martin Luther King Jr. day", TRUE, TRUE, NULL},
+ {"New Years Day", TRUE, TRUE, TRUE, TRUE, TRUE, NULL},
+ {"Presidential Inauguration", FALSE, TRUE, FALSE, TRUE, FALSE, NULL},
+ {"Martin Luther King Jr. day", FALSE, TRUE, FALSE, TRUE, FALSE, NULL},
{ NULL }
};
static TreeStruct february[] =
{
- { "Presidents' Day", TRUE, TRUE, NULL },
- { "Groundhog Day", FALSE, FALSE, NULL },
- { "Valentine's Day", FALSE, FALSE, NULL },
+ { "Presidents' Day", FALSE, TRUE, FALSE, TRUE, FALSE, NULL },
+ { "Groundhog Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Valentine's Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ NULL }
};
static TreeStruct march[] =
{
- { "National Tree Planting Day", FALSE, FALSE, NULL },
- { "St Patrick's Day", FALSE, FALSE, NULL },
+ { "National Tree Planting Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "St Patrick's Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ NULL }
};
static TreeStruct april[] =
{
- { "April Fools' Day", FALSE, FALSE, NULL },
- { "Army Day", FALSE, FALSE, NULL },
- { "Earth Day", FALSE, FALSE, NULL },
- { "Administrative Professionals' Day", FALSE, FALSE, NULL },
+ { "April Fools' Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Army Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Earth Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Administrative Professionals' Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeStruct may[] =
{
- { "Nurses' Day", FALSE, FALSE, NULL },
- { "National Day of Prayer", FALSE, FALSE, NULL },
- { "Mothers' Day", FALSE, FALSE, NULL },
- { "Armed Forces Day", FALSE, FALSE, NULL },
- { "Memorial Day", TRUE, TRUE, NULL },
+ { "Nurses' Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "National Day of Prayer", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Mothers' Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Armed Forces Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Memorial Day", TRUE, TRUE, TRUE, TRUE, TRUE, NULL },
{ NULL }
};
static TreeStruct june[] =
{
- { "June Fathers' Day", FALSE, FALSE, NULL },
- { "Juneteenth (Liberation of Slaves)", FALSE, FALSE, NULL },
- { "Flag Day", TRUE, TRUE, NULL },
+ { "June Fathers' Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Juneteenth (Liberation of Slaves)", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Flag Day", FALSE, TRUE, FALSE, TRUE, FALSE, NULL },
{ NULL }
};
static TreeStruct july[] =
{
- { "Parents' Day", FALSE, FALSE, NULL },
- { "Independence Day", TRUE, TRUE, NULL },
+ { "Parents' Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Independence Day", FALSE, TRUE, FALSE, TRUE, FALSE, NULL },
{ NULL }
};
static TreeStruct august[] =
{
- { "Air Force Day", FALSE, FALSE, NULL },
- { "Coast Guard Day", FALSE, FALSE, NULL },
- { "Friendship Day", FALSE, FALSE, NULL },
+ { "Air Force Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Coast Guard Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Friendship Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeStruct september[] =
{
- { "Grandparents' Day", FALSE, FALSE, NULL },
- { "Citizenship Day or Constitution Day", FALSE, FALSE, NULL },
- { "Labor Day", TRUE, TRUE, NULL },
+ { "Grandparents' Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Citizenship Day or Constitution Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Labor Day", TRUE, TRUE, TRUE, TRUE, TRUE, NULL },
{ NULL }
};
static TreeStruct october[] =
{
- { "National Children's Day", FALSE, FALSE, NULL },
- { "Bosses' Day", FALSE, FALSE, NULL },
- { "Sweetest Day", FALSE, FALSE, NULL },
- { "Mother-in-Law's Day", FALSE, FALSE, NULL },
- { "Navy Day", FALSE, FALSE, NULL },
- { "Columbus Day", TRUE, TRUE, NULL },
- { "Halloween", FALSE, FALSE, NULL },
+ { "National Children's Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Bosses' Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Sweetest Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Mother-in-Law's Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Navy Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Columbus Day", FALSE, TRUE, FALSE, TRUE, FALSE, NULL },
+ { "Halloween", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ NULL }
};
static TreeStruct november[] =
{
- { "Marine Corps Day", FALSE, FALSE, NULL },
- { "Veterans' Day", TRUE, TRUE, NULL },
- { "Thanksgiving", TRUE, TRUE, NULL },
+ { "Marine Corps Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Veterans' Day", TRUE, TRUE, TRUE, TRUE, TRUE, NULL },
+ { "Thanksgiving", FALSE, TRUE, FALSE, TRUE, FALSE, NULL },
{ NULL }
};
static TreeStruct december[] =
{
- { "Pearl Harbor Remembrance Day", FALSE, FALSE, NULL },
- { "Christmas", TRUE, TRUE, NULL },
- { "Kwanzaa", FALSE, FALSE, NULL },
+ { "Pearl Harbor Remembrance Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Christmas", TRUE, TRUE, TRUE, TRUE, TRUE, NULL },
+ { "Kwanzaa", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeStruct toplevel[] =
{
- {"January", FALSE, FALSE, january},
- {"February", FALSE, FALSE, february},
- {"March", FALSE, FALSE, march},
- {"April", FALSE, FALSE, april},
- {"May", FALSE, FALSE, may},
- {"June", FALSE, FALSE, june},
- {"July", FALSE, FALSE, july},
- {"August", FALSE, FALSE, august},
- {"September", FALSE, FALSE, september},
- {"October", FALSE, FALSE, october},
- {"November", FALSE, FALSE, november},
- {"December", FALSE, FALSE, december},
+ {"January", FALSE, FALSE, FALSE, FALSE, FALSE, january},
+ {"February", FALSE, FALSE, FALSE, FALSE, FALSE, february},
+ {"March", FALSE, FALSE, FALSE, FALSE, FALSE, march},
+ {"April", FALSE, FALSE, FALSE, FALSE, FALSE, april},
+ {"May", FALSE, FALSE, FALSE, FALSE, FALSE, may},
+ {"June", FALSE, FALSE, FALSE, FALSE, FALSE, june},
+ {"July", FALSE, FALSE, FALSE, FALSE, FALSE, july},
+ {"August", FALSE, FALSE, FALSE, FALSE, FALSE, august},
+ {"September", FALSE, FALSE, FALSE, FALSE, FALSE, september},
+ {"October", FALSE, FALSE, FALSE, FALSE, FALSE, october},
+ {"November", FALSE, FALSE, FALSE, FALSE, FALSE, november},
+ {"December", FALSE, FALSE, FALSE, FALSE, FALSE, december},
{NULL}
};
@@ -132,9 +135,12 @@ static TreeStruct toplevel[] =
enum
{
HOLIDAY_COLUMN = 0,
+ ALEX_COLUMN,
HAVOC_COLUMN,
+ TIM_COLUMN,
OWEN_COLUMN,
VISIBLE_COLUMN,
+ WORLD_COLUMN,
NUM_COLUMNS
};
@@ -145,7 +151,7 @@ make_model (void)
TreeStruct *month = toplevel;
GtkTreeIter iter;
- model = gtk_tree_store_new_with_types (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
+ model = gtk_tree_store_new_with_types (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
while (month->label)
{
@@ -154,9 +160,12 @@ make_model (void)
gtk_tree_store_append (model, &iter, NULL);
gtk_tree_store_set (model, &iter,
HOLIDAY_COLUMN, month->label,
+ ALEX_COLUMN, FALSE,
HAVOC_COLUMN, FALSE,
+ TIM_COLUMN, FALSE,
OWEN_COLUMN, FALSE,
VISIBLE_COLUMN, FALSE,
+ WORLD_COLUMN, FALSE,
-1);
while (holiday->label)
{
@@ -165,9 +174,12 @@ make_model (void)
gtk_tree_store_append (model, &child_iter, &iter);
gtk_tree_store_set (model, &child_iter,
HOLIDAY_COLUMN, holiday->label,
+ ALEX_COLUMN, holiday->alex,
HAVOC_COLUMN, holiday->havoc,
+ TIM_COLUMN, holiday->tim,
OWEN_COLUMN, holiday->owen,
VISIBLE_COLUMN, TRUE,
+ WORLD_COLUMN, holiday->world_holiday,
-1);
holiday ++;
@@ -179,6 +191,25 @@ make_model (void)
}
static void
+alex_toggled (GtkCellRendererToggle *cell,
+ gchar *path_str,
+ gpointer data)
+{
+ GtkTreeModel *model = (GtkTreeModel *) data;
+ GtkTreeIter iter;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ gboolean alex;
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, ALEX_COLUMN, &alex, -1);
+
+ alex = !alex;
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter, ALEX_COLUMN, alex, -1);
+
+ gtk_tree_path_free (path);
+}
+
+static void
havoc_toggled (GtkCellRendererToggle *cell,
gchar *path_str,
gpointer data)
@@ -199,8 +230,8 @@ havoc_toggled (GtkCellRendererToggle *cell,
static void
owen_toggled (GtkCellRendererToggle *cell,
- gchar *path_str,
- gpointer data)
+ gchar *path_str,
+ gpointer data)
{
GtkTreeModel *model = (GtkTreeModel *) data;
GtkTreeIter iter;
@@ -216,6 +247,26 @@ owen_toggled (GtkCellRendererToggle *cell,
gtk_tree_path_free (path);
}
+static void
+tim_toggled (GtkCellRendererToggle *cell,
+ gchar *path_str,
+ gpointer data)
+{
+ GtkTreeModel *model = (GtkTreeModel *) data;
+ GtkTreeIter iter;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ gboolean tim;
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, TIM_COLUMN, &tim, -1);
+
+ tim = !tim;
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter, TIM_COLUMN, tim, -1);
+
+ gtk_tree_path_free (path);
+}
+
+
int
main (int argc, char *argv[])
{
@@ -225,6 +276,8 @@ main (int argc, char *argv[])
GtkWidget *tree_view;
GtkTreeModel *model;
GtkCellRenderer *renderer;
+ gint col_offset;
+ GtkTreeViewColumn *column;
gtk_init (&argc, &argv);
@@ -242,39 +295,85 @@ main (int argc, char *argv[])
model = make_model ();
tree_view = gtk_tree_view_new_with_model (model);
- // g_object_set (G_OBJECT (tree_view), "model", model, NULL);
+ g_object_unref (G_OBJECT (model));
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
+
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
-1, "Holiday",
renderer,
"text", HOLIDAY_COLUMN, NULL);
g_object_unref (renderer);
+
+ /* Alex Column */
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_signal_connect_data (G_OBJECT (renderer), "toggled", alex_toggled, model, NULL, FALSE, FALSE);
+
+ g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
+ col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+ -1, "Alex",
+ renderer,
+ "active", ALEX_COLUMN,
+ "visible", VISIBLE_COLUMN,
+ "can_activate", WORLD_COLUMN,
+ 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);
+ g_object_unref (renderer);
+
+ /* Havoc Column */
renderer = gtk_cell_renderer_toggle_new ();
g_signal_connect_data (G_OBJECT (renderer), "toggled", havoc_toggled, model, NULL, FALSE, FALSE);
g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
- -1, "Havoc",
+ col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+ -1, "Havoc",
+ renderer,
+ "active", HAVOC_COLUMN,
+ "visible", VISIBLE_COLUMN,
+ 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);
+ g_object_unref (renderer);
+
+ /* Tim Column */
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_signal_connect_data (G_OBJECT (renderer), "toggled", tim_toggled, model, NULL, FALSE, FALSE);
+
+ g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
+ col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+ -1, "Tim",
renderer,
- "active", HAVOC_COLUMN,
+ "active", TIM_COLUMN,
"visible", VISIBLE_COLUMN,
+ "can_activate", WORLD_COLUMN,
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);
g_object_unref (renderer);
+
+ /* Owen Column */
renderer = gtk_cell_renderer_toggle_new ();
g_signal_connect_data (G_OBJECT (renderer), "toggled", owen_toggled, model, NULL, FALSE, FALSE);
g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+ col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
-1, "Owen",
renderer,
"active", OWEN_COLUMN,
"visible", VISIBLE_COLUMN,
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);
g_object_unref (renderer);
- gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
gtk_widget_show_all (window);
+
gtk_main ();
return 0;