2004-01-16  Federico Mena Quintero  <federico@ximian.com>

	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().
This commit is contained in:
Federico Mena Quintero 2004-01-16 19:18:28 +00:00 committed by Federico Mena Quintero
parent c6860c111b
commit fb526d239a
8 changed files with 130 additions and 3 deletions

View File

@ -1,3 +1,17 @@
2004-01-16 Federico Mena Quintero <federico@ximian.com>
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 <federico@ximian.com> 2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c * gtk/gtkfilechooserdefault.c

View File

@ -1,3 +1,17 @@
2004-01-16 Federico Mena Quintero <federico@ximian.com>
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 <federico@ximian.com> 2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c * gtk/gtkfilechooserdefault.c

View File

@ -1,3 +1,17 @@
2004-01-16 Federico Mena Quintero <federico@ximian.com>
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 <federico@ximian.com> 2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c * gtk/gtkfilechooserdefault.c

View File

@ -1,3 +1,17 @@
2004-01-16 Federico Mena Quintero <federico@ximian.com>
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 <federico@ximian.com> 2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c * gtk/gtkfilechooserdefault.c

View File

@ -1,3 +1,17 @@
2004-01-16 Federico Mena Quintero <federico@ximian.com>
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 <federico@ximian.com> 2004-01-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c * gtk/gtkfilechooserdefault.c

View File

@ -19,6 +19,7 @@
#include "gtkcellrenderer.h" #include "gtkcellrenderer.h"
#include "gtkintl.h" #include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtktreeprivate.h" #include "gtktreeprivate.h"
static void gtk_cell_renderer_init (GtkCellRenderer *cell); static void gtk_cell_renderer_init (GtkCellRenderer *cell);
@ -61,6 +62,15 @@ enum {
PROP_CELL_BACKGROUND_SET PROP_CELL_BACKGROUND_SET
}; };
/* Signal IDs */
enum {
EDITING_CANCELED,
LAST_SIGNAL
};
static guint cell_renderer_signals[LAST_SIGNAL] = { 0 };
GType GType
gtk_cell_renderer_get_type (void) gtk_cell_renderer_get_type (void)
{ {
@ -113,6 +123,27 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
class->render = NULL; class->render = NULL;
class->get_size = 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, g_object_class_install_property (object_class,
PROP_MODE, PROP_MODE,
g_param_spec_enum ("mode", g_param_spec_enum ("mode",
@ -654,3 +685,22 @@ gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell,
if (height) if (height)
(* height) = cell->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);
}

View File

@ -107,11 +107,13 @@ struct _GtkCellRendererClass
GdkRectangle *cell_area, GdkRectangle *cell_area,
GtkCellRendererState flags); GtkCellRendererState flags);
/* Signals */
void (* editing_canceled) (GtkCellRenderer *cell);
/* Padding for future expansion */ /* Padding for future expansion */
void (*_gtk_reserved1) (void); void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void); void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void); void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
}; };
GType gtk_cell_renderer_get_type (void) G_GNUC_CONST; 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 *width,
gint *height); gint *height);
/* For use by cell renderer implementations only */
void gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell);
G_END_DECLS G_END_DECLS
#endif /* __GTK_CELL_RENDERER_H__ */ #endif /* __GTK_CELL_RENDERER_H__ */

View File

@ -1439,7 +1439,10 @@ gtk_cell_renderer_text_editing_done (GtkCellEditable *entry,
} }
if (GTK_ENTRY (entry)->editing_canceled) 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); path = g_object_get_data (G_OBJECT (entry), GTK_CELL_RENDERER_TEXT_PATH);
new_text = gtk_entry_get_text (GTK_ENTRY (entry)); new_text = gtk_entry_get_text (GTK_ENTRY (entry));