[gedit/wip/loader-saver: 18/54] GeditDocument: make load and save functions private



commit bc7fd4b46f1af3cc88c02b2ed5b631d69da27c54
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Jun 22 18:18:21 2014 +0200

    GeditDocument: make load and save functions private
    
    Make the following functions private:
    gedit_document_load
    gedit_document_load_stream
    gedit_document_load_cancel
    gedit_document_save
    gedit_document_save_as
    
    They are normally not needed by plugins. What plugins need is to do some
    stuff before/after a file loading or saving, i.e. the following signals
    are needed: "load", "loaded", "save", "saved".
    
    By making the above functions private, it'll be easier to port
    GeditDocument and GeditTab to GtkSourceFile.

 docs/reference/gedit-sections.txt |    5 --
 gedit/gedit-document.c            |   64 +++++++++++++----------------
 gedit/gedit-document.h            |   55 ++++++++++++-------------
 gedit/gedit-tab.c                 |   82 ++++++++++++++++++------------------
 4 files changed, 96 insertions(+), 110 deletions(-)
---
diff --git a/docs/reference/gedit-sections.txt b/docs/reference/gedit-sections.txt
index 898ded7..16838ba 100644
--- a/docs/reference/gedit-sections.txt
+++ b/docs/reference/gedit-sections.txt
@@ -59,11 +59,6 @@ gedit_document_set_short_name_for_display
 gedit_document_get_mime_type
 gedit_document_get_readonly
 gedit_document_is_local
-gedit_document_load
-gedit_document_load_stream
-gedit_document_load_cancel
-gedit_document_save
-gedit_document_save_as
 gedit_document_is_untouched
 gedit_document_is_untitled
 gedit_document_get_deleted
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index 068a4eb..598e14d 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -1465,20 +1465,12 @@ gedit_document_load_real (GeditDocument       *doc,
        gedit_document_loader_load (doc->priv->loader);
 }
 
-/**
- * gedit_document_load_stream:
- * @doc:
- * @stream:
- * @encoding: (allow-none):
- * @line_pos:
- * @column_pos:
- **/
 void
-gedit_document_load_stream (GeditDocument       *doc,
-                            GInputStream        *stream,
-                            const GeditEncoding *encoding,
-                            gint                 line_pos,
-                            gint                 column_pos)
+_gedit_document_load_stream (GeditDocument       *doc,
+                            GInputStream        *stream,
+                            const GeditEncoding *encoding,
+                            gint                 line_pos,
+                            gint                 column_pos)
 {
        g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
        g_return_if_fail (G_IS_INPUT_STREAM (stream));
@@ -1504,8 +1496,8 @@ gedit_document_load_stream (GeditDocument       *doc,
        gedit_document_loader_load (doc->priv->loader);
 }
 
-/**
- * gedit_document_load:
+/*
+ * _gedit_document_load:
  * @doc: the #GeditDocument.
  * @location: the location where to load the document from.
  * @encoding: (allow-none): the #GeditEncoding to encode the document, or %NULL.
@@ -1516,12 +1508,12 @@ gedit_document_load_stream (GeditDocument       *doc,
  * Load a document. This results in the "load" signal to be emitted.
  */
 void
-gedit_document_load (GeditDocument       *doc,
-                    GFile               *location,
-                    const GeditEncoding *encoding,
-                    gint                 line_pos,
-                    gint                 column_pos,
-                    gboolean             create)
+_gedit_document_load (GeditDocument       *doc,
+                     GFile               *location,
+                     const GeditEncoding *encoding,
+                     gint                 line_pos,
+                     gint                 column_pos,
+                     gboolean             create)
 {
        g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
        g_return_if_fail (location != NULL);
@@ -1531,14 +1523,14 @@ gedit_document_load (GeditDocument       *doc,
                       line_pos, column_pos, create);
 }
 
-/**
- * gedit_document_load_cancel:
+/*
+ * _gedit_document_load_cancel:
  * @doc: the #GeditDocument.
  *
  * Cancel load of a document.
  */
 gboolean
-gedit_document_load_cancel (GeditDocument *doc)
+_gedit_document_load_cancel (GeditDocument *doc)
 {
        g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE);
 
@@ -1706,8 +1698,8 @@ gedit_document_save_real (GeditDocument                *doc,
        }
 }
 
-/**
- * gedit_document_save:
+/*
+ * _gedit_document_save:
  * @doc: the #GeditDocument.
  * @flags: optionnal #GeditDocumentSaveFlags.
  *
@@ -1715,8 +1707,8 @@ gedit_document_save_real (GeditDocument                *doc,
  * signal to be emitted.
  */
 void
-gedit_document_save (GeditDocument          *doc,
-                    GeditDocumentSaveFlags  flags)
+_gedit_document_save (GeditDocument          *doc,
+                     GeditDocumentSaveFlags  flags)
 {
        g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
        g_return_if_fail (G_IS_FILE (doc->priv->location));
@@ -1731,8 +1723,8 @@ gedit_document_save (GeditDocument          *doc,
                       flags);
 }
 
-/**
- * gedit_document_save_as:
+/*
+ * _gedit_document_save_as:
  * @doc: the #GeditDocument.
  * @location: the location where to save the document.
  * @encoding: the #GeditEncoding to encode the document.
@@ -1744,12 +1736,12 @@ gedit_document_save (GeditDocument          *doc,
  * to be emitted.
  */
 void
-gedit_document_save_as (GeditDocument                *doc,
-                       GFile                        *location,
-                       const GeditEncoding          *encoding,
-                       GeditDocumentNewlineType      newline_type,
-                       GeditDocumentCompressionType  compression_type,
-                       GeditDocumentSaveFlags        flags)
+_gedit_document_save_as (GeditDocument                *doc,
+                        GFile                        *location,
+                        const GeditEncoding          *encoding,
+                        GeditDocumentNewlineType      newline_type,
+                        GeditDocumentCompressionType  compression_type,
+                        GeditDocumentSaveFlags        flags)
 {
        GError *error = NULL;
 
diff --git a/gedit/gedit-document.h b/gedit/gedit-document.h
index 63a84af..6db609c 100644
--- a/gedit/gedit-document.h
+++ b/gedit/gedit-document.h
@@ -182,31 +182,6 @@ gchar              *gedit_document_get_mime_type   (GeditDocument       *doc);
 
 gboolean        gedit_document_get_readonly    (GeditDocument       *doc);
 
-void            gedit_document_load            (GeditDocument       *doc,
-                                                GFile               *location,
-                                                const GeditEncoding *encoding,
-                                                gint                 line_pos,
-                                                gint                 column_pos,
-                                                gboolean             create);
-
-void            gedit_document_load_stream     (GeditDocument       *doc,
-                                                GInputStream        *stream,
-                                                const GeditEncoding *encoding,
-                                                gint                 line_pos,
-                                                gint                 column_pos);
-
-gboolean        gedit_document_load_cancel     (GeditDocument       *doc);
-
-void            gedit_document_save            (GeditDocument       *doc,
-                                                GeditDocumentSaveFlags flags);
-
-void            gedit_document_save_as         (GeditDocument                *doc,
-                                                GFile                        *location,
-                                                const GeditEncoding          *encoding,
-                                                GeditDocumentNewlineType      newline_type,
-                                                GeditDocumentCompressionType  compression_type,
-                                                GeditDocumentSaveFlags        flags);
-
 gboolean        gedit_document_is_untouched    (GeditDocument       *doc);
 gboolean        gedit_document_is_untitled     (GeditDocument       *doc);
 
@@ -247,9 +222,33 @@ void                        gedit_document_set_search_context      (GeditDocument        
  *doc,
 
 GtkSourceSearchContext *gedit_document_get_search_context      (GeditDocument          *doc);
 
-/*
- * Non exported functions
- */
+/* Non exported functions */
+
+void            _gedit_document_load           (GeditDocument       *doc,
+                                                GFile               *location,
+                                                const GeditEncoding *encoding,
+                                                gint                 line_pos,
+                                                gint                 column_pos,
+                                                gboolean             create);
+
+void            _gedit_document_load_stream    (GeditDocument       *doc,
+                                                GInputStream        *stream,
+                                                const GeditEncoding *encoding,
+                                                gint                 line_pos,
+                                                gint                 column_pos);
+
+gboolean        _gedit_document_load_cancel    (GeditDocument       *doc);
+
+void            _gedit_document_save           (GeditDocument       *doc,
+                                                GeditDocumentSaveFlags flags);
+
+void            _gedit_document_save_as        (GeditDocument                *doc,
+                                                GFile                        *location,
+                                                const GeditEncoding          *encoding,
+                                                GeditDocumentNewlineType      newline_type,
+                                                GeditDocumentCompressionType  compression_type,
+                                                GeditDocumentSaveFlags        flags);
+
 void            _gedit_document_set_readonly   (GeditDocument       *doc,
                                                 gboolean             readonly);
 
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index e8ed639..15d37e4 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -584,12 +584,12 @@ io_loading_error_info_bar_response (GtkWidget *info_bar,
                        set_info_bar (tab, NULL, GTK_RESPONSE_NONE);
                        gedit_tab_set_state (tab, GEDIT_TAB_STATE_LOADING);
 
-                       gedit_document_load (doc,
-                                            location,
-                                            tab->priv->tmp_encoding,
-                                            tab->priv->tmp_line_pos,
-                                            tab->priv->tmp_column_pos,
-                                            FALSE);
+                       _gedit_document_load (doc,
+                                             location,
+                                             tab->priv->tmp_encoding,
+                                             tab->priv->tmp_line_pos,
+                                             tab->priv->tmp_column_pos,
+                                             FALSE);
                        break;
 
                case GTK_RESPONSE_YES:
@@ -645,7 +645,7 @@ load_cancelled (GtkWidget *bar,
        doc = gedit_tab_get_document (tab);
 
        g_object_ref (tab);
-       gedit_document_load_cancel (doc);
+       _gedit_document_load_cancel (doc);
        g_object_unref (tab);
 }
 
@@ -1228,7 +1228,7 @@ invalid_character_info_bar_response (GtkWidget *info_bar,
                /* FIXME there is a bug here when the action was a "save as".
                 * See https://bugzilla.gnome.org/show_bug.cgi?id=695107
                 */
-               gedit_document_save (doc, tab->priv->save_flags);
+               _gedit_document_save (doc, tab->priv->save_flags);
        }
        else
        {
@@ -1253,7 +1253,7 @@ no_backup_error_info_bar_response (GtkWidget *info_bar,
                gedit_tab_set_state (tab, GEDIT_TAB_STATE_SAVING);
 
                /* Force saving */
-               gedit_document_save (doc, tab->priv->save_flags);
+               _gedit_document_save (doc, tab->priv->save_flags);
        }
        else
        {
@@ -1280,7 +1280,7 @@ externally_modified_error_info_bar_response (GtkWidget *info_bar,
                /* ignore mtime should not be persisted in save flags across saves */
 
                /* Force saving */
-               gedit_document_save (doc, tab->priv->save_flags | GEDIT_DOCUMENT_SAVE_IGNORE_MTIME);
+               _gedit_document_save (doc, tab->priv->save_flags | GEDIT_DOCUMENT_SAVE_IGNORE_MTIME);
        }
        else
        {
@@ -1316,12 +1316,12 @@ recoverable_saving_error_info_bar_response (GtkWidget *info_bar,
                gedit_debug_message (DEBUG_TAB, "Force saving with URI '%s'", tmp_uri);
                g_free (tmp_uri);
 
-               gedit_document_save_as (doc,
-                                       tab->priv->tmp_save_location,
-                                       tab->priv->tmp_encoding,
-                                       gedit_document_get_newline_type (doc),
-                                       gedit_document_get_compression_type (doc),
-                                       tab->priv->save_flags);
+               _gedit_document_save_as (doc,
+                                        tab->priv->tmp_save_location,
+                                        tab->priv->tmp_encoding,
+                                        gedit_document_get_newline_type (doc),
+                                        gedit_document_get_compression_type (doc),
+                                        tab->priv->save_flags);
        }
        else
        {
@@ -1997,12 +1997,12 @@ _gedit_tab_load (GeditTab                *tab,
        tab->priv->tmp_column_pos = column_pos;
        tab->priv->tmp_encoding = encoding;
 
-       gedit_document_load (doc,
-                            location,
-                            encoding,
-                            line_pos,
-                            column_pos,
-                            create);
+       _gedit_document_load (doc,
+                             location,
+                             encoding,
+                             line_pos,
+                             column_pos,
+                             create);
 }
 
 void
@@ -2026,11 +2026,11 @@ _gedit_tab_load_stream (GeditTab                *tab,
        tab->priv->tmp_column_pos = column_pos;
        tab->priv->tmp_encoding = encoding;
 
-       gedit_document_load_stream (doc,
-                                   stream,
-                                   encoding,
-                                   line_pos,
-                                   column_pos);
+       _gedit_document_load_stream (doc,
+                                    stream,
+                                    encoding,
+                                    line_pos,
+                                    column_pos);
 }
 
 void
@@ -2058,12 +2058,12 @@ _gedit_tab_revert (GeditTab *tab)
        tab->priv->tmp_line_pos = 0;
        tab->priv->tmp_encoding = gedit_document_get_encoding (doc);
 
-       gedit_document_load (doc,
-                            location,
-                            tab->priv->tmp_encoding,
-                            0,
-                            0,
-                            FALSE);
+       _gedit_document_load (doc,
+                             location,
+                             tab->priv->tmp_encoding,
+                             0,
+                             0,
+                             FALSE);
 
        g_object_unref (location);
 }
@@ -2104,7 +2104,7 @@ _gedit_tab_save (GeditTab *tab)
        tab->priv->tmp_save_location = gedit_document_get_location (doc);
        tab->priv->tmp_encoding = gedit_document_get_encoding (doc);
 
-       gedit_document_save (doc, save_flags);
+       _gedit_document_save (doc, save_flags);
 }
 
 static gboolean
@@ -2154,7 +2154,7 @@ gedit_tab_auto_save (GeditTab *tab)
           the last time the user "manually" saved the file. In the case a recoverable
           error happens while saving, the last backup is not preserved since the user
           expressed his willing of saving the file */
-       gedit_document_save (doc, tab->priv->save_flags | GEDIT_DOCUMENT_SAVE_PRESERVE_BACKUP);
+       _gedit_document_save (doc, tab->priv->save_flags | GEDIT_DOCUMENT_SAVE_PRESERVE_BACKUP);
 
        gedit_debug_message (DEBUG_TAB, "Done");
 
@@ -2207,12 +2207,12 @@ _gedit_tab_save_as (GeditTab                     *tab,
        tab->priv->tmp_save_location = g_file_dup (location);
        tab->priv->tmp_encoding = encoding;
 
-       gedit_document_save_as (doc,
-                               location,
-                               encoding,
-                               newline_type,
-                               compression_type,
-                               save_flags);
+       _gedit_document_save_as (doc,
+                                location,
+                                encoding,
+                                newline_type,
+                                compression_type,
+                                save_flags);
 }
 
 #define GEDIT_PAGE_SETUP_KEY "gedit-page-setup-key"


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