[gedit] Put the set_newline_type as private and follow the same behavior as encoding.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Put the set_newline_type as private and follow the same behavior as encoding.
- Date: Tue, 27 Apr 2010 11:38:42 +0000 (UTC)
commit 103b7683276efa869119dad44b17ac81f83fa4d9
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Wed Apr 7 20:20:11 2010 +0200
Put the set_newline_type as private and follow the same behavior as encoding.
gedit/gedit-document.c | 72 +++++++++++++++++++++++++---------------------
gedit/gedit-document.h | 21 ++++++-------
gedit/gedit-marshal.list | 2 +-
gedit/gedit-tab.c | 9 ++----
4 files changed, 53 insertions(+), 51 deletions(-)
---
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index ae9c61a..e7a2b86 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -83,10 +83,11 @@ static void gedit_document_load_real (GeditDocument *doc,
const GeditEncoding *encoding,
gint line_pos,
gboolean create);
-static void gedit_document_save_real (GeditDocument *doc,
- GFile *location,
- const GeditEncoding *encoding,
- GeditDocumentSaveFlags flags);
+static void gedit_document_save_real (GeditDocument *doc,
+ GFile *location,
+ const GeditEncoding *encoding,
+ GeditDocumentNewlineType newline_type,
+ GeditDocumentSaveFlags flags);
static void to_search_region_range (GeditDocument *doc,
GtkTextIter *start,
GtkTextIter *end);
@@ -222,6 +223,18 @@ release_untitled_number (gint n)
}
static void
+set_newline_type (GeditDocument *doc,
+ GeditDocumentNewlineType newline_type)
+{
+ if (doc->priv->newline_type != newline_type)
+ {
+ doc->priv->newline_type = newline_type;
+
+ g_object_notify (G_OBJECT (doc), "newline-type");
+ }
+}
+
+static void
gedit_document_dispose (GObject *object)
{
GeditDocument *doc = GEDIT_DOCUMENT (object);
@@ -373,8 +386,8 @@ gedit_document_set_property (GObject *object,
g_value_get_boolean (value));
break;
case PROP_NEWLINE_TYPE:
- gedit_document_set_newline_type (doc,
- g_value_get_enum (value));
+ set_newline_type (doc,
+ g_value_get_enum (value));
break;
case PROP_SHORTNAME:
gedit_document_set_short_name_for_display (doc,
@@ -609,13 +622,14 @@ gedit_document_class_init (GeditDocumentClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GeditDocumentClass, save),
NULL, NULL,
- gedit_marshal_VOID__OBJECT_BOXED_FLAGS,
+ gedit_marshal_VOID__OBJECT_BOXED_ENUM_FLAGS,
G_TYPE_NONE,
- 3,
+ 4,
G_TYPE_FILE,
/* we rely on the fact that the GeditEncoding pointer stays
* the same forever */
GEDIT_TYPE_ENCODING | G_SIGNAL_TYPE_STATIC_SCOPE,
+ GEDIT_TYPE_DOCUMENT_NEWLINE_TYPE,
GEDIT_TYPE_DOCUMENT_SAVE_FLAGS);
document_signals[SAVING] =
@@ -1271,8 +1285,8 @@ document_loader_loaded (GeditDocumentLoader *loader,
set_content_type (doc, content_type);
- gedit_document_set_newline_type (doc,
- gedit_document_loader_get_newline_type (loader));
+ set_newline_type (doc,
+ gedit_document_loader_get_newline_type (loader));
/* move the cursor at the requested line if any */
if (doc->priv->requested_line_pos > 0)
@@ -1523,16 +1537,17 @@ document_saver_saving (GeditDocumentSaver *saver,
}
static void
-gedit_document_save_real (GeditDocument *doc,
- GFile *location,
- const GeditEncoding *encoding,
- GeditDocumentSaveFlags flags)
+gedit_document_save_real (GeditDocument *doc,
+ GFile *location,
+ const GeditEncoding *encoding,
+ GeditDocumentNewlineType newline_type,
+ GeditDocumentSaveFlags flags)
{
g_return_if_fail (doc->priv->saver == NULL);
/* create a saver, it will be destroyed once saving is complete */
doc->priv->saver = gedit_document_saver_new (doc, location, encoding,
- doc->priv->newline_type,
+ newline_type,
flags);
g_signal_connect (doc->priv->saver,
@@ -1541,6 +1556,7 @@ gedit_document_save_real (GeditDocument *doc,
doc);
doc->priv->requested_encoding = encoding;
+ doc->priv->newline_type = newline_type;
gedit_document_saver_save (doc->priv->saver,
&doc->priv->mtime);
@@ -1566,6 +1582,7 @@ gedit_document_save (GeditDocument *doc,
0,
doc->priv->location,
doc->priv->encoding,
+ doc->priv->newline_type,
flags);
}
@@ -1574,16 +1591,18 @@ gedit_document_save (GeditDocument *doc,
* @doc: the #GeditDocument.
* @location: the location where to save the document.
* @encoding: the #GeditEncoding to encode the document.
+ * @newline_type: the #GeditDocumentNewlineType for the document.
* @flags: optionnal #GeditDocumentSaveFlags.
*
* Save the document to a new location. This results in the "save" signal
* to be emitted.
*/
void
-gedit_document_save_as (GeditDocument *doc,
- GFile *location,
- const GeditEncoding *encoding,
- GeditDocumentSaveFlags flags)
+gedit_document_save_as (GeditDocument *doc,
+ GFile *location,
+ const GeditEncoding *encoding,
+ GeditDocumentNewlineType newline_type,
+ GeditDocumentSaveFlags flags)
{
g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
g_return_if_fail (G_IS_FILE (location));
@@ -1596,6 +1615,7 @@ gedit_document_save_as (GeditDocument *doc,
0,
location,
encoding,
+ newline_type,
flags | GEDIT_DOCUMENT_SAVE_IGNORE_MTIME);
}
@@ -2511,20 +2531,6 @@ gedit_document_get_enable_search_highlighting (GeditDocument *doc)
return (doc->priv->to_search_region != NULL);
}
-void
-gedit_document_set_newline_type (GeditDocument *doc,
- GeditDocumentNewlineType newline_type)
-{
- g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
-
- if (doc->priv->newline_type != newline_type)
- {
- doc->priv->newline_type = newline_type;
-
- g_object_notify (G_OBJECT (doc), "newline-type");
- }
-}
-
GeditDocumentNewlineType
gedit_document_get_newline_type (GeditDocument *doc)
{
diff --git a/gedit/gedit-document.h b/gedit/gedit-document.h
index 09f0a9a..44b3edd 100644
--- a/gedit/gedit-document.h
+++ b/gedit/gedit-document.h
@@ -139,10 +139,11 @@ struct _GeditDocumentClass
const GError *error);
/* Document save */
- void (* save) (GeditDocument *document,
- GFile *location,
- const GeditEncoding *encoding,
- GeditDocumentSaveFlags flags);
+ void (* save) (GeditDocument *document,
+ GFile *location,
+ const GeditEncoding *encoding,
+ GeditDocumentNewlineType newline_type,
+ GeditDocumentSaveFlags flags);
void (* saving) (GeditDocument *document,
goffset size,
@@ -211,10 +212,11 @@ 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,
- GeditDocumentSaveFlags flags);
+void gedit_document_save_as (GeditDocument *doc,
+ GFile *location,
+ const GeditEncoding *encoding,
+ GeditDocumentNewlineType newline_type,
+ GeditDocumentSaveFlags flags);
gboolean gedit_document_is_untouched (GeditDocument *doc);
gboolean gedit_document_is_untitled (GeditDocument *doc);
@@ -272,9 +274,6 @@ void gedit_document_set_enable_search_highlighting
gboolean gedit_document_get_enable_search_highlighting
(GeditDocument *doc);
-void gedit_document_set_newline_type (GeditDocument *doc,
- GeditDocumentNewlineType newline_type);
-
GeditDocumentNewlineType
gedit_document_get_newline_type (GeditDocument *doc);
diff --git a/gedit/gedit-marshal.list b/gedit/gedit-marshal.list
index 03d7c9e..8a46a0b 100644
--- a/gedit/gedit-marshal.list
+++ b/gedit/gedit-marshal.list
@@ -5,7 +5,7 @@ VOID:BOOLEAN,POINTER
VOID:BOXED,BOXED
VOID:OBJECT
VOID:POINTER
-VOID:OBJECT,BOXED,FLAGS
+VOID:OBJECT,BOXED,ENUM,FLAGS
VOID:OBJECT,BOXED,INT,BOOLEAN
VOID:UINT,POINTER
VOID:UINT64,UINT64
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index cd2913a..09d7f45 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -1261,6 +1261,7 @@ recoverable_saving_error_message_area_response (GtkWidget *message_area,
gedit_document_save_as (doc,
tab->priv->tmp_save_location,
tab->priv->tmp_encoding,
+ gedit_document_get_newline_type (doc),
tab->priv->save_flags);
}
else
@@ -2217,12 +2218,8 @@ _gedit_tab_save_as (GeditTab *tab,
if (tab->priv->auto_save_timeout > 0)
remove_auto_save_timeout (tab);
- /* FIXME: this should behave the same as encoding, setting it here
- makes it persistent (if save fails, it's remembered). It's not
- a very big deal, but would be nice to have them follow the
- same pattern. This can be changed once we break API for 3.0 */
- gedit_document_set_newline_type (doc, newline_type);
- gedit_document_save_as (doc, location, encoding, tab->priv->save_flags);
+ gedit_document_save_as (doc, location, encoding, newline_type,
+ tab->priv->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]