diff --git a/ChangeLog b/ChangeLog index 323399823d..517d227818 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2004-01-16 Federico Mena Quintero + + Fix #130969. + + * gtk/gtkcellrenderer.h (struct _GtkCellRendererClass): Added an + editing_canceled signal. + + * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Create the + "editing-canceled" signal. + (gtk_cell_renderer_editing_canceled): New function. + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done): + Call gtk_cell_renderer_editing_canceled(). + 2004-01-16 Federico Mena Quintero * gtk/gtkfilechooserdefault.c diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 323399823d..517d227818 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +2004-01-16 Federico Mena Quintero + + Fix #130969. + + * gtk/gtkcellrenderer.h (struct _GtkCellRendererClass): Added an + editing_canceled signal. + + * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Create the + "editing-canceled" signal. + (gtk_cell_renderer_editing_canceled): New function. + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done): + Call gtk_cell_renderer_editing_canceled(). + 2004-01-16 Federico Mena Quintero * gtk/gtkfilechooserdefault.c diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 323399823d..517d227818 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,17 @@ +2004-01-16 Federico Mena Quintero + + Fix #130969. + + * gtk/gtkcellrenderer.h (struct _GtkCellRendererClass): Added an + editing_canceled signal. + + * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Create the + "editing-canceled" signal. + (gtk_cell_renderer_editing_canceled): New function. + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done): + Call gtk_cell_renderer_editing_canceled(). + 2004-01-16 Federico Mena Quintero * gtk/gtkfilechooserdefault.c diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 323399823d..517d227818 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,17 @@ +2004-01-16 Federico Mena Quintero + + Fix #130969. + + * gtk/gtkcellrenderer.h (struct _GtkCellRendererClass): Added an + editing_canceled signal. + + * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Create the + "editing-canceled" signal. + (gtk_cell_renderer_editing_canceled): New function. + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done): + Call gtk_cell_renderer_editing_canceled(). + 2004-01-16 Federico Mena Quintero * gtk/gtkfilechooserdefault.c diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 323399823d..517d227818 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +2004-01-16 Federico Mena Quintero + + Fix #130969. + + * gtk/gtkcellrenderer.h (struct _GtkCellRendererClass): Added an + editing_canceled signal. + + * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Create the + "editing-canceled" signal. + (gtk_cell_renderer_editing_canceled): New function. + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done): + Call gtk_cell_renderer_editing_canceled(). + 2004-01-16 Federico Mena Quintero * gtk/gtkfilechooserdefault.c diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c index 153cc9dd13..c19ee74976 100644 --- a/gtk/gtkcellrenderer.c +++ b/gtk/gtkcellrenderer.c @@ -19,6 +19,7 @@ #include "gtkcellrenderer.h" #include "gtkintl.h" +#include "gtkmarshalers.h" #include "gtktreeprivate.h" static void gtk_cell_renderer_init (GtkCellRenderer *cell); @@ -61,6 +62,15 @@ enum { PROP_CELL_BACKGROUND_SET }; +/* Signal IDs */ +enum { + EDITING_CANCELED, + LAST_SIGNAL +}; + +static guint cell_renderer_signals[LAST_SIGNAL] = { 0 }; + + GType gtk_cell_renderer_get_type (void) { @@ -113,6 +123,27 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class) class->render = NULL; class->get_size = NULL; + /** + * GtkCellRenderer::editing-canceled: + * + * This signal gets emitted when the user cancels the process of editing a + * cell. For example, an editable cell renderer could be written to cancel + * editing when the user presses Escape. + * + * See also: gtk_cell_renderer_editing_canceled() + * + * Since: 2.4 + */ + + cell_renderer_signals[EDITING_CANCELED] = + g_signal_new ("editing-canceled", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GtkCellRendererClass, editing_canceled), + NULL, NULL, + _gtk_marshal_VOID__VOID, + G_TYPE_NONE, 0); + g_object_class_install_property (object_class, PROP_MODE, g_param_spec_enum ("mode", @@ -654,3 +685,22 @@ gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell, if (height) (* height) = cell->height; } + +/** + * gtk_cell_renderer_editing_canceled: + * @cell: A #GtkCellRenderer + * + * Causes the cell renderer to emit the "editing-canceled" signal. This + * function is for use only by implementations of cell renderers that need to + * notify the client program that an editing process was canceled and the + * changes were not committed. + * + * Since: 2.4 + **/ +void +gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell) +{ + g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); + + g_signal_emit (cell, cell_renderer_signals[EDITING_CANCELED], 0); +} diff --git a/gtk/gtkcellrenderer.h b/gtk/gtkcellrenderer.h index 0dd241b9ff..5b681aeb97 100644 --- a/gtk/gtkcellrenderer.h +++ b/gtk/gtkcellrenderer.h @@ -107,11 +107,13 @@ struct _GtkCellRendererClass GdkRectangle *cell_area, GtkCellRendererState flags); + /* Signals */ + void (* editing_canceled) (GtkCellRenderer *cell); + /* Padding for future expansion */ void (*_gtk_reserved1) (void); void (*_gtk_reserved2) (void); void (*_gtk_reserved3) (void); - void (*_gtk_reserved4) (void); }; GType gtk_cell_renderer_get_type (void) G_GNUC_CONST; @@ -151,8 +153,10 @@ void gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell, gint *width, gint *height); +/* For use by cell renderer implementations only */ +void gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell); + - G_END_DECLS #endif /* __GTK_CELL_RENDERER_H__ */ diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index fe79f6cfae..f03f6e45ce 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -1439,7 +1439,10 @@ gtk_cell_renderer_text_editing_done (GtkCellEditable *entry, } if (GTK_ENTRY (entry)->editing_canceled) - return; + { + gtk_cell_renderer_editing_canceled (GTK_CELL_RENDERER (data)); + return; + } path = g_object_get_data (G_OBJECT (entry), GTK_CELL_RENDERER_TEXT_PATH); new_text = gtk_entry_get_text (GTK_ENTRY (entry));