[gedit/wip/loader-saver: 50/55] GeditView: override GtkTextView::create_buffer()



commit e1068136c93f66a5f5cfbf2025620f8267b3f575
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Jun 30 21:46:01 2014 +0200

    GeditView: override GtkTextView::create_buffer()
    
    Before this patch, two buffers were created each time a new view is
    created. Now only one buffer is created, the good one, GeditDocument.

 gedit/gedit-view-frame.ui |    2 --
 gedit/gedit-view.c        |    8 ++++++++
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gedit/gedit-view-frame.ui b/gedit/gedit-view-frame.ui
index 6e2dd63..1c35c0d 100644
--- a/gedit/gedit-view-frame.ui
+++ b/gedit/gedit-view-frame.ui
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.8 -->
-  <object class="GeditDocument" id="doc"/>
   <template class="GeditViewFrame" parent="GtkOverlay">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -18,7 +17,6 @@
           <object class="GeditView" id="view">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
-            <property name="buffer">doc</property>
           </object>
         </child>
       </object>
diff --git a/gedit/gedit-view.c b/gedit/gedit-view.c
index 0067b57..5baa8ac 100644
--- a/gedit/gedit-view.c
+++ b/gedit/gedit-view.c
@@ -730,6 +730,12 @@ gedit_view_delete_from_cursor (GtkTextView   *text_view,
        }
 }
 
+static GtkTextBuffer *
+gedit_view_create_buffer (GtkTextView *text_view)
+{
+       return GTK_TEXT_BUFFER (gedit_document_new ());
+}
+
 static void
 gedit_view_change_case (GeditView               *view,
                        GtkSourceChangeCaseType  case_type)
@@ -785,6 +791,8 @@ gedit_view_class_init (GeditViewClass *klass)
        widget_class->unrealize = gedit_view_unrealize;
 
        text_view_class->delete_from_cursor = gedit_view_delete_from_cursor;
+       text_view_class->create_buffer = gedit_view_create_buffer;
+
        klass->change_case = gedit_view_change_case;
 
        /* A new signal DROP_URIS has been added to allow plugins to intercept


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