Re: gtk_text_buffer_delete_interactive
- From: vishnu pobox com
- To: gtk-devel-list gnome org
- Cc: Havoc Pennington <hp redhat com>
- Subject: Re: gtk_text_buffer_delete_interactive
- Date: Mon, 10 Sep 2001 18:21:34 -0700
On Mon, Sep 10, 2001 at 05:09:41PM -0700, vishnu pobox com wrote:
> > I hate to have so many extra signals for this though. :-(
> > Seems cluttered.
>
> Then i'll just start with a patch for delete_interactive.
Here is the patch. i'm not sure about the accumulator, it
seems a little weird ..
Index: gtkmarshal.list
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmarshal.list,v
retrieving revision 1.36
diff -u -p -r1.36 gtkmarshal.list
--- gtkmarshal.list 2001/07/25 13:36:02 1.36
+++ gtkmarshal.list 2001/09/11 01:08:37
@@ -23,6 +23,7 @@
BOOLEAN:BOXED
BOOLEAN:BOXED,BOXED
+BOOLEAN:BOXED,BOXED,BOOLEAN
BOOLEAN:ENUM
BOOLEAN:OBJECT,INT,INT,UINT
BOOLEAN:OBJECT,STRING,STRING,BOXED
Index: gtktextbuffer.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextbuffer.c,v
retrieving revision 1.55
diff -u -p -r1.55 gtktextbuffer.c
--- gtktextbuffer.c 2001/09/07 22:32:02 1.55
+++ gtktextbuffer.c 2001/09/11 01:08:40
@@ -51,6 +51,7 @@ enum {
INSERT_TEXT,
INSERT_PIXBUF,
INSERT_CHILD_ANCHOR,
+ DELETE_INTERACTIVE,
DELETE_RANGE,
CHANGED,
MODIFIED_CHANGED,
@@ -81,6 +82,10 @@ static void gtk_text_buffer_class_init (
static void gtk_text_buffer_finalize (GObject *object);
+static gboolean gtk_text_buffer_boolean_or_accumulator (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer dummy);
static void gtk_text_buffer_real_insert_text (GtkTextBuffer *buffer,
GtkTextIter *iter,
const gchar *text,
@@ -91,6 +96,10 @@ static void gtk_text_buffer_real_insert_
static void gtk_text_buffer_real_insert_anchor (GtkTextBuffer *buffer,
GtkTextIter *iter,
GtkTextChildAnchor *anchor);
+static gboolean gtk_text_buffer_real_delete_interactive (GtkTextBuffer *buffer,
+ GtkTextIter *start_iter,
+ GtkTextIter *end_iter,
+ gboolean default_editable);
static void gtk_text_buffer_real_delete_range (GtkTextBuffer *buffer,
GtkTextIter *start,
GtkTextIter *end);
@@ -155,6 +164,7 @@ gtk_text_buffer_class_init (GtkTextBuffe
klass->insert_text = gtk_text_buffer_real_insert_text;
klass->insert_pixbuf = gtk_text_buffer_real_insert_pixbuf;
klass->insert_child_anchor = gtk_text_buffer_real_insert_anchor;
+ klass->delete_interactive = gtk_text_buffer_real_delete_interactive;
klass->delete_range = gtk_text_buffer_real_delete_range;
klass->apply_tag = gtk_text_buffer_real_apply_tag;
klass->remove_tag = gtk_text_buffer_real_remove_tag;
@@ -197,6 +207,19 @@ gtk_text_buffer_class_init (GtkTextBuffe
GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE,
GTK_TYPE_TEXT_CHILD_ANCHOR);
+ signals[DELETE_INTERACTIVE] =
+ g_signal_new ("delete_interactive",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkTextBufferClass, delete_interactive),
+ gtk_text_buffer_boolean_or_accumulator, NULL,
+ gtk_marshal_BOOLEAN__BOXED_BOXED_BOOLEAN,
+ G_TYPE_BOOLEAN,
+ 3,
+ GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE,
+ GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE,
+ G_TYPE_BOOLEAN);
+
signals[DELETE_RANGE] =
g_signal_new ("delete_range",
G_OBJECT_CLASS_TYPE (object_class),
@@ -299,6 +322,22 @@ gtk_text_buffer_class_init (GtkTextBuffe
0);
}
+static gboolean
+gtk_text_buffer_boolean_or_accumulator (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer dummy)
+{
+ gboolean yes;
+
+ yes = g_value_get_boolean (handler_return);
+
+ if (yes && !g_value_get_boolean (return_accu))
+ g_value_set_boolean (return_accu, TRUE);
+
+ return TRUE;
+}
+
void
gtk_text_buffer_init (GtkTextBuffer *buffer)
{
@@ -1204,6 +1243,29 @@ gtk_text_buffer_delete_interactive (GtkT
GtkTextIter *end_iter,
gboolean default_editable)
{
+ gboolean ret;
+
+ g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), FALSE);
+ g_return_val_if_fail (start_iter != NULL, FALSE);
+ g_return_val_if_fail (end_iter != NULL, FALSE);
+ g_return_val_if_fail (gtk_text_iter_get_buffer (start_iter) == buffer, FALSE);
+ g_return_val_if_fail (gtk_text_iter_get_buffer (end_iter) == buffer, FALSE);
+
+ gtk_text_iter_order (start_iter, end_iter);
+
+ g_signal_emit (G_OBJECT (buffer), signals[DELETE_INTERACTIVE], 0,
+ start_iter, end_iter, default_editable,
+ &ret);
+
+ return ret;
+}
+
+static gboolean
+gtk_text_buffer_real_delete_interactive (GtkTextBuffer *buffer,
+ GtkTextIter *start_iter,
+ GtkTextIter *end_iter,
+ gboolean default_editable)
+{
GtkTextMark *end_mark;
GtkTextMark *start_mark;
GtkTextIter iter;
@@ -1221,8 +1283,6 @@ gtk_text_buffer_delete_interactive (GtkT
gtk_text_buffer_begin_user_action (buffer);
- gtk_text_iter_order (start_iter, end_iter);
-
start_mark = gtk_text_buffer_create_mark (buffer, NULL,
start_iter, TRUE);
end_mark = gtk_text_buffer_create_mark (buffer, NULL,
Index: gtktextbuffer.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextbuffer.h,v
retrieving revision 1.30
diff -u -p -r1.30 gtktextbuffer.h
--- gtktextbuffer.h 2001/08/31 01:33:11 1.30
+++ gtktextbuffer.h 2001/09/11 01:08:40
@@ -78,6 +78,17 @@ struct _GtkTextBufferClass
{
GObjectClass parent_class;
+ gboolean ( *delete_interactive) (GtkTextBuffer *buffer,
+ GtkTextIter *start_iter,
+ GtkTextIter *end_iter,
+ gboolean default_editable);
+
void (* insert_text) (GtkTextBuffer *buffer,
GtkTextIter *pos,
const gchar *text,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]