[gtk+] GtkTextView: add create_buffer virtual method pointer



commit f75aa5fdb455b324d62b67ec9c51c98b795dbf0f
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Jun 12 13:27:17 2013 +0200

    GtkTextView: add create_buffer virtual method pointer
    
    This allows subclasses of GtkTextView that require a corresponding
    subclass of GtkTextBuffer to automatically do the right thing when
    constructed with a NULL buffer. An example of this is GtkSourceView
    which requires a GtkSourceBuffer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=708584

 gtk/gtktextview.c |   11 ++++++++++-
 gtk/gtktextview.h |    3 ++-
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 75d0d97..e34e2b3 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -357,6 +357,8 @@ static void gtk_text_view_select_all           (GtkWidget        *widget,
                                                 gboolean          select);
 static gboolean get_middle_click_paste         (GtkTextView      *text_view);
 
+static GtkTextBuffer* gtk_text_view_create_buffer (GtkTextView   *text_view);
+
 /* Source side drag signals */
 static void gtk_text_view_drag_begin       (GtkWidget        *widget,
                                             GdkDragContext   *context);
@@ -688,6 +690,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
   klass->copy_clipboard = gtk_text_view_copy_clipboard;
   klass->paste_clipboard = gtk_text_view_paste_clipboard;
   klass->toggle_overwrite = gtk_text_view_toggle_overwrite;
+  klass->create_buffer = gtk_text_view_create_buffer;
 
   /*
    * Properties
@@ -1716,12 +1719,18 @@ gtk_text_view_set_buffer (GtkTextView   *text_view,
 }
 
 static GtkTextBuffer*
+gtk_text_view_create_buffer (GtkTextView *text_view)
+{
+  return gtk_text_buffer_new (NULL);
+}
+
+static GtkTextBuffer*
 get_buffer (GtkTextView *text_view)
 {
   if (text_view->priv->buffer == NULL)
     {
       GtkTextBuffer *b;
-      b = gtk_text_buffer_new (NULL);
+      b = GTK_TEXT_VIEW_GET_CLASS (text_view)->create_buffer (text_view);
       gtk_text_view_set_buffer (text_view, b);
       g_object_unref (b);
     }
diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h
index e77c1c4..4feef3c 100644
--- a/gtk/gtktextview.h
+++ b/gtk/gtktextview.h
@@ -106,6 +106,8 @@ struct _GtkTextViewClass
   /* overwrite */
   void (* toggle_overwrite) (GtkTextView *text_view);
 
+  GtkTextBuffer * (* create_buffer) (GtkTextView *text_view);
+
   /* Padding for future expansion */
   void (*_gtk_reserved1) (void);
   void (*_gtk_reserved2) (void);
@@ -114,7 +116,6 @@ struct _GtkTextViewClass
   void (*_gtk_reserved5) (void);
   void (*_gtk_reserved6) (void);
   void (*_gtk_reserved7) (void);
-  void (*_gtk_reserved8) (void);
 };
 
 GDK_AVAILABLE_IN_ALL


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]