Commit a2516791 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

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.
parent ef79a175
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>
......
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>
......
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>
......
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>
......
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>
......
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>
......
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>
......
......@@ -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>
......
......@@ -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:
......@@ -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 \
......
/* 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)
{
}
/* 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__ */
......@@ -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);
}
/**
......
......@@ -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);
#ifdef __cplusplus
}
#endif /* __cplusplus */
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,