editing-canceled signal for GtkCellRendererText
- From: Federico Mena Quintero <federico ximian com>
- To: GTK+ development mailing list <gtk-devel-list gnome org>
- Subject: editing-canceled signal for GtkCellRendererText
- Date: Fri, 09 Jan 2004 00:05:54 -0600
Hi,
Please see the patch attached to
http://bugzilla.gnome.org/show_bug.cgi?id=130969
This adds an "editing-canceled" signal to GtkCellRendererText. I need
this functionality in the file chooser so that the "New Folder" button's
action can be implemented beautifully within the file list. The idea is
that you hit "New Folder", a new row appears in the file list, the user
types the name of the new folder, hits Enter, and the folder gets
created.
If the user hits Escape, however, this row must be removed. However,
right now there is no way to get notified when a text cell's editing
process gets canceled --- the "edited" signal only gets emitted when
editing is confirmed. Moreover, the corresponding GtkCellEditable is
not visible from the public API, so there is no way to connect to its
own "editing-done" signal.
The patch adds an "editing-canceled" signal to GtkCellRendererText and
removes one of the corresponding expansion slots in the class vtable.
This makes the file chooser's UI rather elegant when creating new
folders, so it would be great to get it into 2.4. Otherwise, I guess we
can use a ugly dialog box with a single entry line to type in the new
folder name :)
Federico
Index: gtkcellrenderertext.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkcellrenderertext.h,v
retrieving revision 1.14
diff -u -r1.14 gtkcellrenderertext.h
--- gtkcellrenderertext.h 7 Oct 2002 01:38:40 -0000 1.14
+++ gtkcellrenderertext.h 9 Jan 2004 05:55:10 -0000
@@ -79,15 +79,15 @@
{
GtkCellRendererClass parent_class;
- void (* edited) (GtkCellRendererText *cell_renderer_text,
- const gchar *path,
- const gchar *new_text);
+ void (* edited) (GtkCellRendererText *cell_renderer_text,
+ const gchar *path,
+ const gchar *new_text);
+ void (* editing_canceled) (GtkCellRendererText *cell_renderer_text);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
};
GType gtk_cell_renderer_text_get_type (void);
Index: gtkcellrenderertext.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkcellrenderertext.c,v
retrieving revision 1.52
diff -u -r1.52 gtkcellrenderertext.c
--- gtkcellrenderertext.c 20 Dec 2003 23:43:30 -0000 1.52
+++ gtkcellrenderertext.c 9 Jan 2004 05:55:17 -0000
@@ -62,6 +62,7 @@
enum {
EDITED,
+ EDITING_CANCELED,
LAST_SIGNAL
};
@@ -459,6 +460,14 @@
G_TYPE_NONE, 2,
G_TYPE_STRING,
G_TYPE_STRING);
+ text_cell_renderer_signals [EDITING_CANCELED] =
+ g_signal_new ("editing-canceled",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkCellRendererTextClass, editing_canceled),
+ NULL, NULL,
+ _gtk_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
g_type_class_add_private (object_class, sizeof (GtkCellRendererTextPrivate));
}
@@ -1439,7 +1448,10 @@
}
if (GTK_ENTRY (entry)->editing_canceled)
- return;
+ {
+ g_signal_emit (data, text_cell_renderer_signals[EDITING_CANCELED], 0);
+ return;
+ }
path = g_object_get_data (G_OBJECT (entry), GTK_CELL_RENDERER_TEXT_PATH);
new_text = gtk_entry_get_text (GTK_ENTRY (entry));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]