Add editable interface. This should be the last big GtkTreeView API

Mon Sep 17 17:39:52 2001  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtkcelleditable.[ch]: Add editable interface.  This should
	be the last big GtkTreeView API change.

	* gtk/gtkcellrenderer.[ch]: Get rid of the "event" vfunc, and
	replace with "activate" and "start_editing".  Also, added a
	"can_activate" and "can_edit" property.

	* gtk/gtktreeviewcolumn.c: modify to use above.
This commit is contained in:
Jonathan Blandford 2001-09-17 21:44:20 +00:00 committed by Jonathan Blandford
parent ef79a175b5
commit a251679148
20 changed files with 528 additions and 293 deletions

View File

@ -1,7 +1,17 @@
Mon Sep 17 17:39:52 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcelleditable.[ch]: Add editable interface. This should
be the last big GtkTreeView API change.
* gtk/gtkcellrenderer.[ch]: Get rid of the "event" vfunc, and
replace with "activate" and "start_editing". Also, added a
"can_activate" and "can_edit" property.
* gtk/gtktreeviewcolumn.c: modify to use above.
2001-09-16 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkoptionmenu.c:
Handle scroll wheel events.
* gtk/gtkoptionmenu.c: Handle scroll wheel events.
Fri Sep 14 22:31:25 2001 Matthias Clasen <matthiasc@poet.de>

View File

@ -1,7 +1,17 @@
Mon Sep 17 17:39:52 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcelleditable.[ch]: Add editable interface. This should
be the last big GtkTreeView API change.
* gtk/gtkcellrenderer.[ch]: Get rid of the "event" vfunc, and
replace with "activate" and "start_editing". Also, added a
"can_activate" and "can_edit" property.
* gtk/gtktreeviewcolumn.c: modify to use above.
2001-09-16 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkoptionmenu.c:
Handle scroll wheel events.
* gtk/gtkoptionmenu.c: Handle scroll wheel events.
Fri Sep 14 22:31:25 2001 Matthias Clasen <matthiasc@poet.de>

View File

@ -1,7 +1,17 @@
Mon Sep 17 17:39:52 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcelleditable.[ch]: Add editable interface. This should
be the last big GtkTreeView API change.
* gtk/gtkcellrenderer.[ch]: Get rid of the "event" vfunc, and
replace with "activate" and "start_editing". Also, added a
"can_activate" and "can_edit" property.
* gtk/gtktreeviewcolumn.c: modify to use above.
2001-09-16 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkoptionmenu.c:
Handle scroll wheel events.
* gtk/gtkoptionmenu.c: Handle scroll wheel events.
Fri Sep 14 22:31:25 2001 Matthias Clasen <matthiasc@poet.de>

View File

@ -1,7 +1,17 @@
Mon Sep 17 17:39:52 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcelleditable.[ch]: Add editable interface. This should
be the last big GtkTreeView API change.
* gtk/gtkcellrenderer.[ch]: Get rid of the "event" vfunc, and
replace with "activate" and "start_editing". Also, added a
"can_activate" and "can_edit" property.
* gtk/gtktreeviewcolumn.c: modify to use above.
2001-09-16 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkoptionmenu.c:
Handle scroll wheel events.
* gtk/gtkoptionmenu.c: Handle scroll wheel events.
Fri Sep 14 22:31:25 2001 Matthias Clasen <matthiasc@poet.de>

View File

@ -1,7 +1,17 @@
Mon Sep 17 17:39:52 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcelleditable.[ch]: Add editable interface. This should
be the last big GtkTreeView API change.
* gtk/gtkcellrenderer.[ch]: Get rid of the "event" vfunc, and
replace with "activate" and "start_editing". Also, added a
"can_activate" and "can_edit" property.
* gtk/gtktreeviewcolumn.c: modify to use above.
2001-09-16 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkoptionmenu.c:
Handle scroll wheel events.
* gtk/gtkoptionmenu.c: Handle scroll wheel events.
Fri Sep 14 22:31:25 2001 Matthias Clasen <matthiasc@poet.de>

View File

@ -1,7 +1,17 @@
Mon Sep 17 17:39:52 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcelleditable.[ch]: Add editable interface. This should
be the last big GtkTreeView API change.
* gtk/gtkcellrenderer.[ch]: Get rid of the "event" vfunc, and
replace with "activate" and "start_editing". Also, added a
"can_activate" and "can_edit" property.
* gtk/gtktreeviewcolumn.c: modify to use above.
2001-09-16 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkoptionmenu.c:
Handle scroll wheel events.
* gtk/gtkoptionmenu.c: Handle scroll wheel events.
Fri Sep 14 22:31:25 2001 Matthias Clasen <matthiasc@poet.de>

View File

@ -1,7 +1,17 @@
Mon Sep 17 17:39:52 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkcelleditable.[ch]: Add editable interface. This should
be the last big GtkTreeView API change.
* gtk/gtkcellrenderer.[ch]: Get rid of the "event" vfunc, and
replace with "activate" and "start_editing". Also, added a
"can_activate" and "can_edit" property.
* gtk/gtktreeviewcolumn.c: modify to use above.
2001-09-16 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkoptionmenu.c:
Handle scroll wheel events.
* gtk/gtkoptionmenu.c: Handle scroll wheel events.
Fri Sep 14 22:31:25 2001 Matthias Clasen <matthiasc@poet.de>

View File

@ -1402,6 +1402,20 @@ Sets the default size of child buttons.
@accel_group:
@Returns:
<!-- ##### FUNCTION gtk_cell_renderer_event ##### -->
<para>
</para>
@cell:
@event:
@widget:
@path:
@background_area:
@cell_area:
@flags:
@Returns:
<!-- ##### FUNCTION gtk_cell_renderer_text_pixbuf_new ##### -->
<para>

View File

@ -37,6 +37,7 @@ GtkCellRenderer
@xpad:
@ypad:
@can_activate:
@can_edit:
@visible:
@is_expander:
@is_expanded:
@ -69,18 +70,3 @@ GtkCellRenderer
@flags:
<!-- ##### FUNCTION gtk_cell_renderer_event ##### -->
<para>
</para>
@cell:
@event:
@widget:
@path:
@background_area:
@cell_area:
@flags:
@Returns:

View File

@ -69,6 +69,7 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
gtkctree.h \
gtkcurve.h \
gtkcellrenderer.h \
gtkcelleditable.h \
gtkcellrenderertext.h \
gtkcellrenderertoggle.h \
gtkcellrendererpixbuf.h \
@ -215,6 +216,7 @@ gtk_c_sources = @STRIP_BEGIN@ \
gtkbutton.c \
gtkcalendar.c \
gtkcellrenderer.c \
gtkcelleditable.c \
gtkcellrenderertext.c \
gtkcellrenderertoggle.c \
gtkcellrendererpixbuf.c \

98
gtk/gtkcelleditable.c Normal file
View File

@ -0,0 +1,98 @@
/* gtkcelleditable.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 "gtkcelleditable.h"
#include "gtksignal.h"
static void gtk_cell_editable_base_init (gpointer g_class);
GtkType
gtk_cell_editable_get_type (void)
{
static GtkType cell_editable_type = 0;
if (! cell_editable_type)
{
static const GTypeInfo cell_editable_info =
{
sizeof (GtkCellEditableIface), /* class_size */
gtk_cell_editable_base_init, /* base_init */
NULL, /* base_finalize */
NULL,
NULL, /* class_finalize */
NULL, /* class_data */
0,
0,
NULL
};
cell_editable_type = g_type_register_static (G_TYPE_INTERFACE, "GtkCellEditable", &cell_editable_info, 0);
g_type_interface_add_prerequisite (cell_editable_type, GTK_TYPE_WIDGET);
}
return cell_editable_type;
}
static void
gtk_cell_editable_base_init (gpointer g_class)
{
static gboolean initialized = FALSE;
if (! initialized)
{
g_signal_new ("editing_done",
GTK_TYPE_CELL_EDITABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkCellEditableIface, editing_done),
NULL, NULL,
gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_new ("remove_widget",
GTK_TYPE_CELL_EDITABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkCellEditableIface, remove_widget),
NULL, NULL,
gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
initialized = TRUE;
}
}
void
gtk_cell_editable_start_editing (GtkCellEditable *cell_editable,
GdkEvent *event)
{
}
void
gtk_cell_editable_stop_editing (GtkCellEditable *cell_editable)
{
}
void
gtk_cell_editable_editing_done (GtkCellEditable *cell_editable)
{
}
void
gtk_cell_editable_remove_widget (GtkCellEditable *cell_editable)
{
}

62
gtk/gtkcelleditable.h Normal file
View File

@ -0,0 +1,62 @@
/* gtkcelleditable.h
* Copyright (C) 2001 Red Hat, Inc.
*
* 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_EDITABLE_H__
#define __GTK_CELL_EDITABLE_H__
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
#define GTK_TYPE_CELL_EDITABLE (gtk_cell_editable_get_type ())
#define GTK_CELL_EDITABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_EDITABLE, GtkCellEditable))
#define GTK_CELL_EDITABLE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GTK_TYPE_CELL_EDITABLE, GtkCellEditableIface))
#define GTK_IS_CELL_EDITABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_EDITABLE))
#define GTK_CELL_EDITABLE_GET_IFACE(obj) ((GtkCellEditableIface *)g_type_interface_peek (((GTypeInstance *) GTK_CELL_EDITABLE (obj))->g_class, GTK_TYPE_CELL_EDITABLE))
typedef struct _GtkCellEditable GtkCellEditable; /* Dummy typedef */
typedef struct _GtkCellEditableIface GtkCellEditableIface;
struct _GtkCellEditableIface
{
GTypeInterface g_iface;
/* signals */
void (* editing_done) (GtkCellEditable *cell_editable);
void (* remove_widget) (GtkCellEditable *cell_editable);
/* virtual table */
void (* start_editing) (GtkCellEditable *cell_editable,
GdkEvent *event);
void (* stop_editing) (GtkCellEditable *cell_editable);
};
GType gtk_cell_editable_get_type (void) G_GNUC_CONST;
void gtk_cell_editable_start_editing (GtkCellEditable *cell_editable,
GdkEvent *event);
void gtk_cell_editable_stop_editing (GtkCellEditable *cell_editable);
void gtk_cell_editable_editing_done (GtkCellEditable *cell_editable);
void gtk_cell_editable_remove_widget (GtkCellEditable *cell_editable);
G_END_DECLS
#endif /* __GTK_CELL_EDITABLE_H__ */

View File

@ -35,6 +35,7 @@ static void gtk_cell_renderer_set_property (GObject *object,
enum {
PROP_ZERO,
PROP_CAN_ACTIVATE,
PROP_CAN_EDIT,
PROP_VISIBLE,
PROP_XALIGN,
PROP_YALIGN,
@ -77,6 +78,7 @@ static void
gtk_cell_renderer_init (GtkCellRenderer *cell)
{
cell->can_activate = FALSE;
cell->can_edit = FALSE;
cell->visible = TRUE;
cell->width = -1;
cell->height = -1;
@ -106,6 +108,15 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
G_PARAM_READABLE |
G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_CAN_EDIT,
g_param_spec_boolean ("can_edit",
_("can_edit"),
_("Cell supports CellEditable interface."),
FALSE,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_VISIBLE,
g_param_spec_boolean ("visible",
@ -214,6 +225,9 @@ gtk_cell_renderer_get_property (GObject *object,
case PROP_CAN_ACTIVATE:
g_value_set_boolean (value, cell->can_activate);
break;
case PROP_CAN_EDIT:
g_value_set_boolean (value, cell->can_edit);
break;
case PROP_VISIBLE:
g_value_set_boolean (value, cell->visible);
break;
@ -261,6 +275,22 @@ gtk_cell_renderer_set_property (GObject *object,
case PROP_CAN_ACTIVATE:
cell->can_activate = g_value_get_boolean (value);
g_object_notify (object, "can_activate");
/* can_activate and can_edit are mutually exclusive */
if (cell->can_activate && cell->can_edit)
{
cell->can_edit = FALSE;
g_object_notify (object, "can_edit");
}
break;
case PROP_CAN_EDIT:
cell->can_edit = g_value_get_boolean (value);
g_object_notify (object, "can_edit");
/* can_activate and can_edit are mutually exclusive */
if (cell->can_activate && cell->can_edit)
{
cell->can_activate = FALSE;
g_object_notify (object, "can_activate");
}
break;
case PROP_VISIBLE:
cell->visible = g_value_get_boolean (value);
@ -401,7 +431,7 @@ gtk_cell_renderer_render (GtkCellRenderer *cell,
}
/**
* gtk_cell_renderer_event:
* gtk_cell_renderer_activate:
* @cell: a #GtkCellRenderer
* @event: a #GdkEvent
* @widget: widget that received the event
@ -410,37 +440,79 @@ gtk_cell_renderer_render (GtkCellRenderer *cell,
* @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.
* Passes an activate 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
**/
gboolean
gtk_cell_renderer_event (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags)
gtk_cell_renderer_activate (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags)
{
/* It's actually okay to pass in a NULL cell, as we run into that
* a lot
*/
if (cell == NULL)
return FALSE;
g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE);
if (GTK_CELL_RENDERER_GET_CLASS (cell)->event == NULL)
if (! cell->can_activate)
return FALSE;
return GTK_CELL_RENDERER_GET_CLASS (cell)->event (cell,
event,
widget,
path,
background_area,
cell_area,
flags);
if (GTK_CELL_RENDERER_GET_CLASS (cell)->activate == NULL)
return FALSE;
return GTK_CELL_RENDERER_GET_CLASS (cell)->activate (cell,
event,
widget,
path,
background_area,
cell_area,
flags);
}
/**
* gtk_cell_renderer_start_editing:
* @cell: a #GtkCellRenderer
* @event: a #GdkEvent
* @widget: widget that received the event
* @path: widget-dependent string representation of the event location; e.g. for #GtkTreeView, a string representation of #GtkTreePath
* @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 activate event to the cell renderer for possible processing.
*
* Return value: A new #GtkCellEditable, or %NULL
**/
GtkCellEditable *
gtk_cell_renderer_start_editing (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags)
{
g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), NULL);
if (! cell->can_edit)
return NULL;
if (GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing == NULL)
return NULL;
return GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing (cell,
event,
widget,
path,
background_area,
cell_area,
flags);
}
/**

View File

@ -22,11 +22,9 @@
#include <gtk/gtkobject.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtkcelleditable.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
G_BEGIN_DECLS
typedef enum
{
@ -61,6 +59,7 @@ struct _GtkCellRenderer
guint16 ypad;
guint can_activate : 1;
guint can_edit : 1;
guint visible : 1;
guint is_expander : 1;
guint is_expanded : 1;
@ -71,64 +70,75 @@ struct _GtkCellRendererClass
GtkObjectClass parent_class;
/* vtable - not signals */
void (* get_size) (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height);
void (* render) (GtkCellRenderer *cell,
GdkWindow *window,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
GtkCellRendererState flags);
gboolean (* event) (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags);
void (* get_size) (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height);
void (* render) (GtkCellRenderer *cell,
GdkWindow *window,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
GtkCellRendererState flags);
gboolean (* activate) (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags);
GtkCellEditable *(* start_editing) (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags);
};
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,
GdkWindow *window,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
GtkCellRendererState flags);
gboolean gtk_cell_renderer_event (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags);
void gtk_cell_renderer_set_fixed_size (GtkCellRenderer *cell,
gint width,
gint height);
void gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell,
gint *width,
gint *height);
GType gtk_cell_renderer_get_type (void) G_GNUC_CONST;
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,
GdkWindow *window,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
GtkCellRendererState flags);
gboolean gtk_cell_renderer_activate (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags);
GtkCellEditable *gtk_cell_renderer_start_editing (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags);
void gtk_cell_renderer_set_fixed_size (GtkCellRenderer *cell,
gint width,
gint height);
void gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell,
gint *width,
gint *height);
#ifdef __cplusplus
}
#endif /* __cplusplus */
G_END_DECLS
#endif /* __GTK_CELL_RENDERER_H__ */

View File

@ -46,13 +46,13 @@ static void gtk_cell_renderer_toggle_render (GtkCellRenderer *cel
GdkRectangle *cell_area,
GdkRectangle *expose_area,
guint flags);
static gboolean gtk_cell_renderer_toggle_event (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
guint flags);
static gboolean gtk_cell_renderer_toggle_activate (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
guint flags);
enum {
@ -119,7 +119,7 @@ gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class)
cell_class->get_size = gtk_cell_renderer_toggle_get_size;
cell_class->render = gtk_cell_renderer_toggle_render;
cell_class->event = gtk_cell_renderer_toggle_event;
cell_class->activate = gtk_cell_renderer_toggle_activate;
g_object_class_install_property (object_class,
PROP_ACTIVE,
@ -321,13 +321,13 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
}
static gint
gtk_cell_renderer_toggle_event (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
guint flags)
gtk_cell_renderer_toggle_activate (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
guint flags)
{
GtkCellRendererToggle *celltoggle;
gboolean retval = FALSE;

View File

@ -408,6 +408,8 @@ static GdkColor gtk_default_active_bg = { 0, 0xc350, 0xc350, 0xc350 };
static GdkColor gtk_default_prelight_bg = { 0, 0xea60, 0xea60, 0xea60 };
static GdkColor gtk_default_selected_bg = { 0, 0, 0, 0x9c40 };
static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
static GdkColor gtk_default_selected_base = { 0, 0xa4a4, 0xdfdf, 0xffff };
static GdkColor gtk_default_active_base = { 0, 0xbcbc, 0xd2d2, 0xeeee };
static gpointer parent_class = NULL;
static GdkFont *static_default_font = NULL;
@ -496,7 +498,10 @@ gtk_style_init (GtkStyle *style)
style->base[i] = style->white;
}
style->base[GTK_STATE_SELECTED] = gtk_default_selected_bg;
style->base[GTK_STATE_SELECTED] = gtk_default_selected_base;
style->text[GTK_STATE_SELECTED] = style->black;
style->base[GTK_STATE_ACTIVE] = gtk_default_active_base;
style->text[GTK_STATE_ACTIVE] = style->black;
style->base[GTK_STATE_INSENSITIVE] = gtk_default_prelight_bg;
style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
@ -2941,12 +2946,10 @@ gtk_default_draw_flat_box (GtkStyle *style,
!strncmp ("cell_odd", detail, strlen ("cell_odd")))
{
/* This has to be really broken; alex made me do it. -jrb */
/* Red rum!!! REd RUM!!! */
if (GTK_WIDGET_HAS_FOCUS (widget))
gc1 = style->bg_gc[state_type];
gc1 = style->base_gc[state_type];
else
gc1 = style->bg_gc[GTK_STATE_ACTIVE];
gc1 = style->base_gc[GTK_STATE_ACTIVE];
}
else
{

View File

@ -43,7 +43,7 @@ gtk_tree_sortable_get_type (void)
NULL
};
tree_sortable_type = g_type_register_static (G_TYPE_INTERFACE, "GtkTreeSortable", &tree_sortable_info, 0);
g_type_interface_add_prerequisite (tree_sortable_type, G_TYPE_OBJECT);
g_type_interface_add_prerequisite (tree_sortable_type, GTK_TYPE_TREE_MODEL);
}
return tree_sortable_type;

View File

@ -165,7 +165,6 @@ 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);
static gint gtk_tree_view_focus_out (GtkWidget *widget,
@ -340,6 +339,7 @@ static gboolean gtk_tree_view_real_expand_row (GtkTreeView
static void gtk_tree_view_real_set_cursor (GtkTreeView *tree_view,
GtkTreePath *path,
gboolean clear_and_select);
static void gtk_tree_view_ensure_focus_column (GtkTreeView *tree_view);
/* interactive search */
@ -1897,6 +1897,29 @@ ensure_unprelighted (GtkTreeView *tree_view)
g_assert (tree_view->priv->prelight_node == NULL);
}
static void
gtk_tree_view_ensure_focus_column (GtkTreeView *tree_view)
{
GList *list;
if (tree_view->priv->focus_column != NULL &&
tree_view->priv->focus_column->visible)
return;
if (tree_view->priv->focus_column)
gtk_tree_view_column_cell_focus (tree_view->priv->focus_column, 0, TRUE);
for (list = tree_view->priv->columns; list; list = list->next)
{
GtkTreeViewColumn *column = list->data;
if (column->visible)
{
gtk_tree_view_column_cell_focus (column, 1, FALSE);
return;
}
}
}
/* Our motion arrow is either a box (in the case of the original spot)
@ -2354,93 +2377,6 @@ gtk_tree_view_motion (GtkWidget *widget,
return FALSE;
}
/* Draws the focus rectangle around the cursor row */
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;
gint vertical_separator;
g_return_if_fail (GTK_IS_TREE_VIEW (widget));
tree_view = GTK_TREE_VIEW (widget);
gtk_widget_style_get (widget, "vertical_separator", &vertical_separator, NULL);
if (! GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS))
return;
if (! gtk_tree_row_reference_valid (tree_view->priv->cursor))
return;
cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
_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)
{
GtkTreeIter iter;
gtk_tree_model_get_iter (tree_view->priv->model, &iter, cursor_path);
gtk_tree_view_column_cell_set_cell_data (tree_view->priv->focus_column,
tree_view->priv->model,
&iter,
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_PARENT),
node->children?TRUE:FALSE);
if (gtk_tree_view_column_cell_can_focus (tree_view->priv->focus_column))
{
GdkRectangle cell_area;
gint x_offset;
gint y_offset;
cell_area.x = tree_view->priv->focus_column->button->allocation.x;
cell_area.y = y;
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,
&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 + vertical_separator/2;
}
}
gtk_paint_focus (widget->style,
tree_view->priv->bin_window,
NULL,
widget,
"treeview",
x, y, width, height);
gtk_tree_path_free (cursor_path);
}
/* Warning: Very scary function.
* Modify at your own risk
*/
@ -2481,14 +2417,11 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
return TRUE;
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.
gtk_tree_view_ensure_focus_column (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.
*/
new_y = (event->area.y<TREE_VIEW_HEADER_HEIGHT (tree_view))?TREE_VIEW_HEADER_HEIGHT (tree_view):event->area.y;
/* y_offset is the */
y_offset = -_gtk_rbtree_find_offset (tree_view->priv->tree,
TREE_WINDOW_Y_TO_RBTREE_Y (tree_view, new_y),
&tree,
@ -2645,7 +2578,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
else
state = GTK_STATE_NORMAL;
/* Draw background */
/* Draw background */
gtk_paint_flat_box (widget->style,
event->window,
state,
@ -2695,11 +2628,20 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
&event->area,
flags);
}
if (node == cursor &&
GTK_WIDGET_HAS_FOCUS (widget) &&
column == tree_view->priv->focus_column)
{
gtk_tree_view_column_cell_draw_focus (column,
event->window,
&background_area,
&cell_area,
&event->area,
flags);
}
cell_offset += column->width;
}
if (node == cursor && GTK_WIDGET_HAS_FOCUS (widget))
gtk_tree_view_draw_focus (widget);
if (node == drag_highlight)
{
@ -5853,14 +5795,11 @@ gtk_tree_view_move_cursor_left_right (GtkTreeView *tree_view,
&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))
{
if (gtk_tree_view_column_cell_focus (column, count, FALSE))
{
tree_view->priv->focus_column = column;
found_column = TRUE;
break;
}
tree_view->priv->focus_column = column;
found_column = TRUE;
break;
}
loop_end:
if (count == 1)

View File

@ -108,10 +108,6 @@ 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);
@ -2071,7 +2067,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.
@ -2085,26 +2081,6 @@ gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
* primarily by the GtkTreeView.
**/
void
gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height)
{
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
gtk_cell_renderer_get_size (((GtkTreeViewColumnCellInfo *) tree_column->cell_list->data)->cell,
tree_column->tree_view,
cell_area,
x_offset,
y_offset,
width,
height);
}
#endif
void
gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
GdkRectangle *cell_area,
gint *x_offset,
@ -2284,13 +2260,13 @@ gtk_tree_view_column_cell_event (GtkTreeViewColumn *tree_column,
NULL);
if (visible && can_activate)
{
if (gtk_cell_renderer_event (((GtkTreeViewColumnCellInfo *) tree_column->cell_list->data)->cell,
event,
tree_column->tree_view,
path_string,
background_area,
cell_area,
flags))
if (gtk_cell_renderer_activate (((GtkTreeViewColumnCellInfo *) tree_column->cell_list->data)->cell,
event,
tree_column->tree_view,
path_string,
background_area,
cell_area,
flags))
return TRUE;
}
@ -2303,34 +2279,32 @@ gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
gint direction,
gboolean unfocus)
{
GList *list;
gboolean visible;
gboolean can_activate;
if (unfocus)
GTK_TREE_VIEW (tree_column->tree_view)->priv->focus_column = NULL;
else
GTK_TREE_VIEW (tree_column->tree_view)->priv->focus_column = tree_column;
return TRUE;
}
gboolean
gtk_tree_view_column_cell_can_focus (GtkTreeViewColumn *tree_column)
void
gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn *tree_column,
GdkWindow *window,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
guint flags)
{
GList *list;
gboolean visible;
gboolean can_activate;
for (list = tree_column->cell_list; list; list = list->next)
{
GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
g_object_get (G_OBJECT (info->cell),
"can_activate", &can_activate,
"visible", &visible,
NULL);
if (can_activate && visible)
return TRUE;
}
return FALSE;
gtk_paint_focus (tree_column->tree_view->style,
window,
NULL,
tree_column->tree_view,
"treeview",
cell_area->x,
cell_area->y,
cell_area->width-1,
cell_area->height);
}
gboolean
gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column)
{

View File

@ -218,7 +218,12 @@ gboolean gtk_tree_view_column_cell_event (GtkTreeViewCol
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);
void gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn *tree_column,
GdkWindow *window,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
guint flags);
gboolean gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_cell_set_dirty (GtkTreeViewColumn *tree_column);