Commit cee3778c authored by Sébastien Wilmet's avatar Sébastien Wilmet

Port to GtkSourceCompressionType

And remove GeditDocumentCompressionType. This is an API break, but the
port is trivial.
parent ad6d88bd
......@@ -46,7 +46,6 @@ GeditDocument
GeditDocumentSaveFlags
GeditDocumentNewlineType
GEDIT_DOCUMENT_NEWLINE_TYPE_DEFAULT
GeditDocumentCompressionType
GEDIT_DOCUMENT_ERROR
gedit_document_error_quark
gedit_document_new
......
......@@ -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);
......
......@@ -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);
......
......@@ -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,
......
......@@ -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;
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment