[gedit] Remove gedit_view_frame_get_document()



commit 83758fba045f5d6f512d1f797410764046d57310
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Jun 26 12:22:48 2015 +0200

    Remove gedit_view_frame_get_document()
    
    No need to have a get_document() function at each level of the
    containment hierarchy. There is already gedit_tab_get_document().
    
    gedit_view_frame_get_document() was used mostly internally.

 gedit/gedit-commands-search.c |    2 +-
 gedit/gedit-tab.c             |    6 +++++-
 gedit/gedit-view-frame.c      |   33 +++++++++------------------------
 gedit/gedit-view-frame.h      |    2 --
 4 files changed, 15 insertions(+), 28 deletions(-)
---
diff --git a/gedit/gedit-commands-search.c b/gedit/gedit-commands-search.c
index 109d552..fd29e76 100644
--- a/gedit/gedit-commands-search.c
+++ b/gedit/gedit-commands-search.c
@@ -666,7 +666,7 @@ _gedit_cmd_search_clear_highlight (GSimpleAction *action,
        frame = _gedit_tab_get_view_frame (active_tab);
        gedit_view_frame_clear_search (frame);
 
-       doc = gedit_view_frame_get_document (frame);
+       doc = gedit_tab_get_document (active_tab);
        gedit_document_set_search_context (doc, NULL);
 }
 
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index 87c94f8..93cd535 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -1461,9 +1461,13 @@ gedit_tab_get_view (GeditTab *tab)
 GeditDocument *
 gedit_tab_get_document (GeditTab *tab)
 {
+       GeditView *view;
+
        g_return_val_if_fail (GEDIT_IS_TAB (tab), NULL);
 
-       return gedit_view_frame_get_document (tab->frame);
+       view = gedit_view_frame_get_view (tab->frame);
+
+       return GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
 }
 
 #define MAX_DOC_NAME_LENGTH 40
diff --git a/gedit/gedit-view-frame.c b/gedit/gedit-view-frame.c
index 04a70f3..f684962 100644
--- a/gedit/gedit-view-frame.c
+++ b/gedit/gedit-view-frame.c
@@ -107,12 +107,17 @@ struct _GeditViewFrame
 enum
 {
        PROP_0,
-       PROP_DOCUMENT,
        PROP_VIEW
 };
 
 G_DEFINE_TYPE (GeditViewFrame, gedit_view_frame, GTK_TYPE_OVERLAY)
 
+static GeditDocument *
+get_document (GeditViewFrame *frame)
+{
+       return GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (frame->view)));
+}
+
 static void
 gedit_view_frame_dispose (GObject *object)
 {
@@ -190,10 +195,6 @@ gedit_view_frame_get_property (GObject    *object,
 
        switch (prop_id)
        {
-               case PROP_DOCUMENT:
-                       g_value_set_object (value, gedit_view_frame_get_document (frame));
-                       break;
-
                case PROP_VIEW:
                        g_value_set_object (value, gedit_view_frame_get_view (frame));
                        break;
@@ -280,7 +281,7 @@ get_search_context (GeditViewFrame *frame)
        GtkSourceSearchContext *search_context;
        GtkSourceSearchSettings *search_settings;
 
-       doc = gedit_view_frame_get_document (frame);
+       doc = get_document (frame);
        search_context = gedit_document_get_search_context (doc);
 
        if (search_context == NULL)
@@ -1091,7 +1092,7 @@ update_goto_line (GeditViewFrame *frame)
                return;
        }
 
-       doc = gedit_view_frame_get_document (frame);
+       doc = get_document (frame);
 
        gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc),
                                          &iter,
@@ -1454,14 +1455,6 @@ gedit_view_frame_class_init (GeditViewFrameClass *klass)
        object_class->finalize = gedit_view_frame_finalize;
        object_class->get_property = gedit_view_frame_get_property;
 
-       g_object_class_install_property (object_class, PROP_DOCUMENT,
-                                        g_param_spec_object ("document",
-                                                             "Document",
-                                                             "The Document",
-                                                             GEDIT_TYPE_DOCUMENT,
-                                                             G_PARAM_READABLE |
-                                                             G_PARAM_STATIC_STRINGS));
-
        g_object_class_install_property (object_class, PROP_VIEW,
                                         g_param_spec_object ("view",
                                                              "View",
@@ -1549,7 +1542,7 @@ gedit_view_frame_init (GeditViewFrame *frame)
 
        gtk_widget_override_background_color (GTK_WIDGET (frame), 0, &transparent);
 
-       doc = gedit_view_frame_get_document (frame);
+       doc = get_document (frame);
        file = gedit_document_get_file (doc);
 
        gtk_source_file_set_mount_operation_factory (file,
@@ -1651,14 +1644,6 @@ gedit_view_frame_new (void)
        return g_object_new (GEDIT_TYPE_VIEW_FRAME, NULL);
 }
 
-GeditDocument *
-gedit_view_frame_get_document (GeditViewFrame *frame)
-{
-       g_return_val_if_fail (GEDIT_IS_VIEW_FRAME (frame), NULL);
-
-       return GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (frame->view)));
-}
-
 GeditView *
 gedit_view_frame_get_view (GeditViewFrame *frame)
 {
diff --git a/gedit/gedit-view-frame.h b/gedit/gedit-view-frame.h
index 8ce7d06..a01ee83 100644
--- a/gedit/gedit-view-frame.h
+++ b/gedit/gedit-view-frame.h
@@ -32,8 +32,6 @@ G_DECLARE_FINAL_TYPE (GeditViewFrame, gedit_view_frame, GEDIT, VIEW_FRAME, GtkOv
 
 GeditViewFrame *gedit_view_frame_new           (void);
 
-GeditDocument  *gedit_view_frame_get_document  (GeditViewFrame *frame);
-
 GeditView      *gedit_view_frame_get_view      (GeditViewFrame *frame);
 
 void            gedit_view_frame_popup_search  (GeditViewFrame *frame);


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