Allow custom initialization of cell editables. (#147221)

2004-07-20  Matthias Clasen  <mclasen@redhat.com>

	Allow custom initialization of cell editables.  (#147221)

	* gtk/gtkcellrenderer.h (struct _GtkCellRendererClass):
	* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Add a
	::editing-started signal as a hook for setting up the
	GtkCellEditable.
	(gtk_cell_renderer_start_editing): ...and emit it here.
This commit is contained in:
Matthias Clasen 2004-07-20 16:06:02 +00:00 committed by Matthias Clasen
parent 1093e2c646
commit 9aeba99da0
6 changed files with 107 additions and 10 deletions

View File

@ -1,3 +1,13 @@
2004-07-20 Matthias Clasen <mclasen@redhat.com>
Allow custom initialization of cell editables. (#147221)
* gtk/gtkcellrenderer.h (struct _GtkCellRendererClass):
* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Add a
::editing-started signal as a hook for setting up the
GtkCellEditable.
(gtk_cell_renderer_start_editing): ...and emit it here.
Mon Jul 19 23:51:50 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktreeview.c (gtk_tree_view_button_press): Set drag_pos

View File

@ -1,3 +1,13 @@
2004-07-20 Matthias Clasen <mclasen@redhat.com>
Allow custom initialization of cell editables. (#147221)
* gtk/gtkcellrenderer.h (struct _GtkCellRendererClass):
* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Add a
::editing-started signal as a hook for setting up the
GtkCellEditable.
(gtk_cell_renderer_start_editing): ...and emit it here.
Mon Jul 19 23:51:50 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktreeview.c (gtk_tree_view_button_press): Set drag_pos

View File

@ -1,3 +1,13 @@
2004-07-20 Matthias Clasen <mclasen@redhat.com>
Allow custom initialization of cell editables. (#147221)
* gtk/gtkcellrenderer.h (struct _GtkCellRendererClass):
* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Add a
::editing-started signal as a hook for setting up the
GtkCellEditable.
(gtk_cell_renderer_start_editing): ...and emit it here.
Mon Jul 19 23:51:50 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktreeview.c (gtk_tree_view_button_press): Set drag_pos

View File

@ -1,3 +1,13 @@
2004-07-20 Matthias Clasen <mclasen@redhat.com>
Allow custom initialization of cell editables. (#147221)
* gtk/gtkcellrenderer.h (struct _GtkCellRendererClass):
* gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Add a
::editing-started signal as a hook for setting up the
GtkCellEditable.
(gtk_cell_renderer_start_editing): ...and emit it here.
Mon Jul 19 23:51:50 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktreeview.c (gtk_tree_view_button_press): Set drag_pos

View File

@ -67,6 +67,7 @@ enum {
/* Signal IDs */
enum {
EDITING_CANCELED,
EDITING_STARTED,
LAST_SIGNAL
};
@ -140,7 +141,6 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
*
* Since: 2.4
*/
cell_renderer_signals[EDITING_CANCELED] =
g_signal_new ("editing-canceled",
G_OBJECT_CLASS_TYPE (object_class),
@ -150,6 +150,53 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* GtkCellRenderer::editing-started:
* @renderer: the object which received the signal
* @editable: the #GtkCellEditable
* @path: the path identifying the edited cell
*
* This signal gets emitted when a cell starts to be edited.
* The indended use of this signal is to do special setup
* on @editable, e.g. adding a #GtkEntryCompletion or setting
* up additional columns in a #GtkComboBox.
*
* Note that GTK+ doesn't guarantee that cell renderers will
* continue to use the same kind of widget for editing in future
* releases, therefore you should check the type of @editable
* before doing any specific setup, as in the following example:
*
* <informalexample><programlisting>
* static void
* text_editing_started (GtkCellRenderer *cell,
* GtkCellEditable *editable,
* const gchar *path,
* gpointer data)
* {
* if (GTK_IS_ENTRY (editable))
* {
* GtkEntry *entry = GTK_ENTRY (editable);
*
* /* ... create a GtkEntryCompletion *<!-- -->/
*
* gtk_entry_set_completion (entry, completion);
* }
* }
* </programlisting></informalexample>
*
* Since: 2.6
*/
cell_renderer_signals[EDITING_STARTED] =
g_signal_new ("editing-started",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkCellRendererClass, editing_started),
NULL, NULL,
_gtk_marshal_VOID__OBJECT_STRING,
G_TYPE_NONE, 2,
GTK_TYPE_CELL_EDITABLE,
G_TYPE_STRING);
g_object_class_install_property (object_class,
PROP_MODE,
g_param_spec_enum ("mode",
@ -629,6 +676,8 @@ gtk_cell_renderer_start_editing (GtkCellRenderer *cell,
GtkCellRendererState flags)
{
GtkCellEditable *editable;
g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), NULL);
if (cell->mode != GTK_CELL_RENDERER_MODE_EDITABLE)
@ -638,13 +687,19 @@ gtk_cell_renderer_start_editing (GtkCellRenderer *cell,
return NULL;
return GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing (cell,
editable = GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing (cell,
event,
widget,
path,
background_area,
cell_area,
flags);
g_signal_emit (cell,
cell_renderer_signals[EDITING_STARTED], 0,
editable, path);
return editable;
}
/**

View File

@ -110,11 +110,13 @@ struct _GtkCellRendererClass
/* Signals */
void (* editing_canceled) (GtkCellRenderer *cell);
void (* editing_started) (GtkCellRenderer *cell,
GtkCellEditable *editable,
const gchar *path);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
};
GType gtk_cell_renderer_get_type (void) G_GNUC_CONST;