[gedit/wip/loader-saver: 24/54] Port to GtkSourceCompressionType



commit df4e0d809da74e3d1d893766a187f89f193ab1c1
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Jun 26 20:08:25 2014 +0200

    Port to GtkSourceCompressionType
    
    And remove GeditDocumentCompressionType. This is an API break, but the
    port is trivial.

 docs/reference/gedit-sections.txt |    1 -
 gedit/gedit-commands-file.c       |   14 +++++++-------
 gedit/gedit-document.c            |   18 +++++++++---------
 gedit/gedit-document.h            |   31 +++++++------------------------
 gedit/gedit-tab.c                 |   12 ++++++------
 gedit/gedit-tab.h                 |    2 +-
 gedit/gedit-utils.c               |    8 ++++----
 gedit/gedit-utils.h               |    2 +-
 8 files changed, 35 insertions(+), 53 deletions(-)
---
diff --git a/docs/reference/gedit-sections.txt b/docs/reference/gedit-sections.txt
index 16838ba..1810791 100644
--- a/docs/reference/gedit-sections.txt
+++ b/docs/reference/gedit-sections.txt
@@ -46,7 +46,6 @@ GeditDocument
 GeditDocumentSaveFlags
 GeditDocumentNewlineType
 GEDIT_DOCUMENT_NEWLINE_TYPE_DEFAULT
-GeditDocumentCompressionType
 GEDIT_DOCUMENT_ERROR
 gedit_document_error_quark
 gedit_document_new
diff --git a/gedit/gedit-commands-file.c b/gedit/gedit-commands-file.c
index 0f7d126..290c94a 100644
--- a/gedit/gedit-commands-file.c
+++ b/gedit/gedit-commands-file.c
@@ -653,12 +653,12 @@ change_compression (GtkWindow *parent,
        return (ret == GTK_RESPONSE_YES);
 }
 
-static GeditDocumentCompressionType
+static GtkSourceCompressionType
 get_compression_type_from_file (GFile *file)
 {
        gchar *name;
        gchar *content_type;
-       GeditDocumentCompressionType type;
+       GtkSourceCompressionType type;
 
        name = g_file_get_basename (file);
        content_type = g_content_type_guess (name, NULL, 0, NULL);
@@ -698,8 +698,8 @@ save_dialog_response_cb (GeditFileChooserDialog *dialog,
                GeditDocument *doc;
                gchar *parse_name;
                GeditDocumentNewlineType newline_type;
-               GeditDocumentCompressionType compression_type;
-               GeditDocumentCompressionType current_compression_type;
+               GtkSourceCompressionType compression_type;
+               GtkSourceCompressionType current_compression_type;
                const GtkSourceEncoding *encoding;
 
                doc = gedit_tab_get_document (tab);
@@ -710,12 +710,12 @@ save_dialog_response_cb (GeditFileChooserDialog *dialog,
                compression_type = get_compression_type_from_file (file);
                current_compression_type = gedit_document_get_compression_type (doc);
 
-               if ((compression_type == GEDIT_DOCUMENT_COMPRESSION_TYPE_NONE) !=
-                   (current_compression_type == GEDIT_DOCUMENT_COMPRESSION_TYPE_NONE))
+               if ((compression_type == GTK_SOURCE_COMPRESSION_TYPE_NONE) !=
+                   (current_compression_type == GTK_SOURCE_COMPRESSION_TYPE_NONE))
                {
                        if (!change_compression (GTK_WINDOW (dialog),
                                                 file,
-                                                compression_type != GEDIT_DOCUMENT_COMPRESSION_TYPE_NONE))
+                                                compression_type != GTK_SOURCE_COMPRESSION_TYPE_NONE))
                        {
                                gtk_widget_destroy (GTK_WIDGET (dialog));
                                g_object_unref (file);
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index 148525d..28999da 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -77,7 +77,7 @@ struct _GeditDocumentPrivate
        GtkSourceSearchContext *search_context;
 
        GeditDocumentNewlineType newline_type;
-       GeditDocumentCompressionType compression_type;
+       GtkSourceCompressionType compression_type;
 
        /* Temp data while loading */
        gboolean             create; /* Create file if uri points
@@ -186,8 +186,8 @@ set_newline_type (GeditDocument           *doc,
 }
 
 static void
-set_compression_type (GeditDocument *doc,
-                      GeditDocumentCompressionType compression_type)
+set_compression_type (GeditDocument            *doc,
+                     GtkSourceCompressionType  compression_type)
 {
        if (doc->priv->compression_type != compression_type)
        {
@@ -500,8 +500,8 @@ gedit_document_class_init (GeditDocumentClass *klass)
                                         g_param_spec_enum ("compression-type",
                                                            "Compression type",
                                                            "The save compression type",
-                                                           GEDIT_TYPE_DOCUMENT_COMPRESSION_TYPE,
-                                                           GEDIT_DOCUMENT_COMPRESSION_TYPE_NONE,
+                                                           GTK_SOURCE_TYPE_COMPRESSION_TYPE,
+                                                           GTK_SOURCE_COMPRESSION_TYPE_NONE,
                                                            G_PARAM_READWRITE |
                                                            G_PARAM_CONSTRUCT |
                                                            G_PARAM_STATIC_NAME |
@@ -586,7 +586,7 @@ gedit_document_class_init (GeditDocumentClass *klass)
         * @location: the location where the document is about to be saved.
         * @encoding: the #GeditEncoding used to save the document.
         * @newline_type: the #GeditDocumentNewlineType used to save the document.
-        * @compression_type: the #GeditDocumentCompressionType used to save the document.
+        * @compression_type: the #GtkSourceCompressionType used to save the document.
         * @flags: the #GeditDocumentSaveFlags for the save operation.
         *
         * The "save" signal is emitted when the document is saved.
@@ -607,7 +607,7 @@ gedit_document_class_init (GeditDocumentClass *klass)
                               * the same forever */
                              GEDIT_TYPE_ENCODING | G_SIGNAL_TYPE_STATIC_SCOPE,
                              GEDIT_TYPE_DOCUMENT_NEWLINE_TYPE,
-                             GEDIT_TYPE_DOCUMENT_COMPRESSION_TYPE,
+                             GTK_SOURCE_TYPE_COMPRESSION_TYPE,
                              GEDIT_TYPE_DOCUMENT_SAVE_FLAGS);
 
        document_signals[SAVED] =
@@ -956,7 +956,7 @@ set_content_type_no_guess (GeditDocument *doc,
 
        /* For compression types, we try to just guess from the content */
        if (gedit_utils_get_compression_type_from_content_type (content_type) !=
-           GEDIT_DOCUMENT_COMPRESSION_TYPE_NONE)
+           GTK_SOURCE_COMPRESSION_TYPE_NONE)
        {
                dupped_content_type = get_content_type_from_content (doc);
        }
@@ -1594,7 +1594,7 @@ gedit_document_get_newline_type (GeditDocument *doc)
        return doc->priv->newline_type;
 }
 
-GeditDocumentCompressionType
+GtkSourceCompressionType
 gedit_document_get_compression_type (GeditDocument *doc)
 {
        g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), 0);
diff --git a/gedit/gedit-document.h b/gedit/gedit-document.h
index b74af04..ee0eaaf 100644
--- a/gedit/gedit-document.h
+++ b/gedit/gedit-document.h
@@ -63,23 +63,6 @@ typedef enum
 #define GEDIT_DOCUMENT_NEWLINE_TYPE_DEFAULT GEDIT_DOCUMENT_NEWLINE_TYPE_LF
 #endif
 
-/*
- * NOTE: when adding a new compression type, make sure to update:
- *   1) The document loader to support it
- *   2) gedit_document_compression_type_for_display
- */
-
-/**
- * GeditDocumentCompressionType:
- * @GEDIT_DOCUMENT_COMPRESSION_TYPE_NONE: save file in plain text.
- * @GEDIT_DOCUMENT_COMPRESSION_TYPE_GZIP: save file using gzip compression.
- */
-typedef enum
-{
-       GEDIT_DOCUMENT_COMPRESSION_TYPE_NONE,
-       GEDIT_DOCUMENT_COMPRESSION_TYPE_GZIP
-} GeditDocumentCompressionType;
-
 /**
  * GeditDocumentSaveFlags:
  * @GEDIT_DOCUMENT_SAVE_IGNORE_MTIME: save file despite external modifications.
@@ -121,12 +104,12 @@ struct _GeditDocumentClass
        void (* loaded)                 (GeditDocument    *document,
                                         const GError     *error);
 
-       void (* save)                   (GeditDocument                *document,
-                                        GFile                        *location,
-                                        const GeditEncoding          *encoding,
-                                        GeditDocumentNewlineType      newline_type,
-                                        GeditDocumentCompressionType  compression_type,
-                                        GeditDocumentSaveFlags        flags);
+       void (* save)                   (GeditDocument            *document,
+                                        GFile                    *location,
+                                        const GeditEncoding      *encoding,
+                                        GeditDocumentNewlineType  newline_type,
+                                        GtkSourceCompressionType  compression_type,
+                                        GeditDocumentSaveFlags    flags);
 
        void (* saved)                  (GeditDocument    *document,
                                         const GError     *error);
@@ -199,7 +182,7 @@ const GeditEncoding
 GeditDocumentNewlineType
                 gedit_document_get_newline_type (GeditDocument      *doc);
 
-GeditDocumentCompressionType
+GtkSourceCompressionType
                 gedit_document_get_compression_type (GeditDocument  *doc);
 
 gchar          *gedit_document_get_metadata    (GeditDocument       *doc,
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index edbe118..be55d31 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -2315,13 +2315,13 @@ gedit_tab_auto_save (GeditTab *tab)
        return G_SOURCE_REMOVE;
 }
 
-/* TODO port to GtkSourceNewlineType and GtkSourceCompressionType */
+/* TODO port to GtkSourceNewlineType */
 void
-_gedit_tab_save_as (GeditTab                     *tab,
-                   GFile                        *location,
-                   const GtkSourceEncoding      *encoding,
-                   GeditDocumentNewlineType      newline_type,
-                   GeditDocumentCompressionType  compression_type)
+_gedit_tab_save_as (GeditTab                 *tab,
+                   GFile                    *location,
+                   const GtkSourceEncoding  *encoding,
+                   GeditDocumentNewlineType  newline_type,
+                   GtkSourceCompressionType  compression_type)
 {
        GeditDocument *doc;
        GtkSourceFile *file;
diff --git a/gedit/gedit-tab.h b/gedit/gedit-tab.h
index 2d8c461..831418a 100644
--- a/gedit/gedit-tab.h
+++ b/gedit/gedit-tab.h
@@ -140,7 +140,7 @@ void                 _gedit_tab_save_as             (GeditTab            *tab,
                                                 GFile               *location,
                                                 const GtkSourceEncoding *encoding,
                                                 GeditDocumentNewlineType newline_type,
-                                                GeditDocumentCompressionType compression_type);
+                                                GtkSourceCompressionType compression_type);
 
 void            _gedit_tab_print               (GeditTab            *tab);
 void            _gedit_tab_print_preview       (GeditTab            *tab);
diff --git a/gedit/gedit-utils.c b/gedit/gedit-utils.c
index 5d87008..4e13553 100644
--- a/gedit/gedit-utils.c
+++ b/gedit/gedit-utils.c
@@ -1357,20 +1357,20 @@ gedit_utils_decode_uri (const gchar  *uri,
        return TRUE;
 }
 
-GeditDocumentCompressionType
+GtkSourceCompressionType
 gedit_utils_get_compression_type_from_content_type (const gchar *content_type)
 {
        if (content_type == NULL)
        {
-               return GEDIT_DOCUMENT_COMPRESSION_TYPE_NONE;
+               return GTK_SOURCE_COMPRESSION_TYPE_NONE;
        }
 
        if (g_content_type_is_a (content_type, "application/x-gzip"))
        {
-               return GEDIT_DOCUMENT_COMPRESSION_TYPE_GZIP;
+               return GTK_SOURCE_COMPRESSION_TYPE_GZIP;
        }
 
-       return GEDIT_DOCUMENT_COMPRESSION_TYPE_NONE;
+       return GTK_SOURCE_COMPRESSION_TYPE_NONE;
 }
 
 /* Copied from nautilus */
diff --git a/gedit/gedit-utils.h b/gedit/gedit-utils.h
index 478e034..3229ae2 100644
--- a/gedit/gedit-utils.h
+++ b/gedit/gedit-utils.h
@@ -123,7 +123,7 @@ gboolean     gedit_utils_decode_uri                 (const gchar      *uri,
 /* Turns data from a drop into a list of well formatted uris */
 gchar          **gedit_utils_drop_get_uris             (GtkSelectionData *selection_data);
 
-GeditDocumentCompressionType
+GtkSourceCompressionType
                 gedit_utils_get_compression_type_from_content_type
                                                        (const gchar      *content_type);
 


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