parent
511fc3dfec
commit
5071bfe065
|
@ -806,24 +806,6 @@ _xed_cmd_file_save_as (GtkAction *action,
|
||||||
file_save_as (tab, window);
|
file_save_as (tab, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
document_needs_saving (XedDocument *doc)
|
|
||||||
{
|
|
||||||
if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)))
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we check if it was deleted only for local files
|
|
||||||
* since for remote files it may hang */
|
|
||||||
if (xed_document_is_local (doc) && xed_document_get_deleted (doc))
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The docs in the list must belong to the same XedWindow.
|
* The docs in the list must belong to the same XedWindow.
|
||||||
*/
|
*/
|
||||||
|
@ -863,7 +845,7 @@ _xed_cmd_file_save_documents_list (XedWindow *window,
|
||||||
user is running xed - Paolo (Dec. 8, 2005) */
|
user is running xed - Paolo (Dec. 8, 2005) */
|
||||||
if (xed_document_is_untitled (doc) || xed_document_get_readonly (doc))
|
if (xed_document_is_untitled (doc) || xed_document_get_readonly (doc))
|
||||||
{
|
{
|
||||||
if (document_needs_saving (doc))
|
if (_xed_document_needs_saving (doc))
|
||||||
{
|
{
|
||||||
tabs_to_save_as = g_slist_prepend (tabs_to_save_as, t);
|
tabs_to_save_as = g_slist_prepend (tabs_to_save_as, t);
|
||||||
}
|
}
|
||||||
|
@ -1214,7 +1196,7 @@ tab_state_changed_while_saving (XedTab *tab,
|
||||||
|
|
||||||
/* If the saving operation failed or was interrupted, then the
|
/* If the saving operation failed or was interrupted, then the
|
||||||
document is still "modified" -> do not close the tab */
|
document is still "modified" -> do not close the tab */
|
||||||
if (document_needs_saving (doc))
|
if (_xed_document_needs_saving (doc))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1327,7 +1309,7 @@ save_and_close_all_documents (const GList *docs,
|
||||||
(state != XED_TAB_STATE_REVERTING)) /* CHECK: is this the right behavior with REVERTING ?*/
|
(state != XED_TAB_STATE_REVERTING)) /* CHECK: is this the right behavior with REVERTING ?*/
|
||||||
{
|
{
|
||||||
/* The document must be saved before closing */
|
/* The document must be saved before closing */
|
||||||
g_return_if_fail (document_needs_saving (doc));
|
g_return_if_fail (_xed_document_needs_saving (doc));
|
||||||
|
|
||||||
/* FIXME: manage the case of local readonly files owned by the
|
/* FIXME: manage the case of local readonly files owned by the
|
||||||
user is running xed - Paolo (Dec. 8, 2005) */
|
user is running xed - Paolo (Dec. 8, 2005) */
|
||||||
|
|
|
@ -1674,6 +1674,37 @@ xed_document_get_deleted (XedDocument *doc)
|
||||||
return doc->priv->deleted;
|
return doc->priv->deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Deletion and external modification is only checked for local files.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
_xed_document_needs_saving (XedDocument *doc)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (XED_IS_DOCUMENT (doc), FALSE);
|
||||||
|
|
||||||
|
if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)))
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc->priv->externally_modified || doc->priv->deleted)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xed_document_is_local (doc))
|
||||||
|
{
|
||||||
|
check_file_on_disk (doc);
|
||||||
|
|
||||||
|
if (doc->priv->externally_modified || doc->priv->deleted)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If @line is bigger than the lines of the document, the cursor is moved
|
* If @line is bigger than the lines of the document, the cursor is moved
|
||||||
* to the last line and FALSE is returned.
|
* to the last line and FALSE is returned.
|
||||||
|
|
|
@ -41,9 +41,6 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/*
|
|
||||||
* Type checking and casting macros
|
|
||||||
*/
|
|
||||||
#define XED_TYPE_DOCUMENT (xed_document_get_type())
|
#define XED_TYPE_DOCUMENT (xed_document_get_type())
|
||||||
#define XED_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_DOCUMENT, XedDocument))
|
#define XED_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_DOCUMENT, XedDocument))
|
||||||
#define XED_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_DOCUMENT, XedDocumentClass))
|
#define XED_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_DOCUMENT, XedDocumentClass))
|
||||||
|
@ -78,13 +75,9 @@ typedef enum
|
||||||
XED_DOCUMENT_SAVE_IGNORE_INVALID_CHARS = 1 << 3
|
XED_DOCUMENT_SAVE_IGNORE_INVALID_CHARS = 1 << 3
|
||||||
} XedDocumentSaveFlags;
|
} XedDocumentSaveFlags;
|
||||||
|
|
||||||
/* Private structure type */
|
|
||||||
typedef struct _XedDocumentPrivate XedDocumentPrivate;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Main object structure
|
|
||||||
*/
|
|
||||||
typedef struct _XedDocument XedDocument;
|
typedef struct _XedDocument XedDocument;
|
||||||
|
typedef struct _XedDocumentPrivate XedDocumentPrivate;
|
||||||
|
typedef struct _XedDocumentClass XedDocumentClass;
|
||||||
|
|
||||||
struct _XedDocument
|
struct _XedDocument
|
||||||
{
|
{
|
||||||
|
@ -94,11 +87,6 @@ struct _XedDocument
|
||||||
XedDocumentPrivate *priv;
|
XedDocumentPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Class definition
|
|
||||||
*/
|
|
||||||
typedef struct _XedDocumentClass XedDocumentClass;
|
|
||||||
|
|
||||||
struct _XedDocumentClass
|
struct _XedDocumentClass
|
||||||
{
|
{
|
||||||
GtkSourceBufferClass parent_class;
|
GtkSourceBufferClass parent_class;
|
||||||
|
@ -159,20 +147,16 @@ GFile *xed_document_get_location (XedDocument *doc);
|
||||||
void xed_document_set_location (XedDocument *doc,
|
void xed_document_set_location (XedDocument *doc,
|
||||||
GFile *location);
|
GFile *location);
|
||||||
|
|
||||||
gchar *xed_document_get_uri_for_display
|
gchar *xed_document_get_uri_for_display (XedDocument *doc);
|
||||||
(XedDocument *doc);
|
|
||||||
gchar *xed_document_get_short_name_for_display
|
|
||||||
(XedDocument *doc);
|
|
||||||
|
|
||||||
void xed_document_set_short_name_for_display
|
gchar *xed_document_get_short_name_for_display (XedDocument *doc);
|
||||||
(XedDocument *doc,
|
|
||||||
|
void xed_document_set_short_name_for_display (XedDocument *doc,
|
||||||
const gchar *name);
|
const gchar *name);
|
||||||
|
|
||||||
gchar *xed_document_get_content_type
|
gchar *xed_document_get_content_type (XedDocument *doc);
|
||||||
(XedDocument *doc);
|
|
||||||
|
|
||||||
void xed_document_set_content_type
|
void xed_document_set_content_type (XedDocument *doc,
|
||||||
(XedDocument *doc,
|
|
||||||
const gchar *content_type);
|
const gchar *content_type);
|
||||||
|
|
||||||
gchar *xed_document_get_mime_type (XedDocument *doc);
|
gchar *xed_document_get_mime_type (XedDocument *doc);
|
||||||
|
@ -211,17 +195,14 @@ gboolean xed_document_goto_line_offset(XedDocument *doc,
|
||||||
|
|
||||||
void xed_document_set_language (XedDocument *doc,
|
void xed_document_set_language (XedDocument *doc,
|
||||||
GtkSourceLanguage *lang);
|
GtkSourceLanguage *lang);
|
||||||
GtkSourceLanguage
|
GtkSourceLanguage *xed_document_get_language (XedDocument *doc);
|
||||||
*xed_document_get_language (XedDocument *doc);
|
|
||||||
|
|
||||||
const XedEncoding
|
const XedEncoding *xed_document_get_encoding (XedDocument *doc);
|
||||||
*xed_document_get_encoding (XedDocument *doc);
|
|
||||||
|
|
||||||
void xed_document_set_newline_type (XedDocument *doc,
|
void xed_document_set_newline_type (XedDocument *doc,
|
||||||
XedDocumentNewlineType newline_type);
|
XedDocumentNewlineType newline_type);
|
||||||
|
|
||||||
XedDocumentNewlineType
|
XedDocumentNewlineType xed_document_get_newline_type (XedDocument *doc);
|
||||||
xed_document_get_newline_type (XedDocument *doc);
|
|
||||||
|
|
||||||
gchar *xed_document_get_metadata (XedDocument *doc,
|
gchar *xed_document_get_metadata (XedDocument *doc,
|
||||||
const gchar *key);
|
const gchar *key);
|
||||||
|
@ -236,8 +217,7 @@ void xed_document_set_metadata (XedDocument *doc,
|
||||||
void _xed_document_set_readonly (XedDocument *doc,
|
void _xed_document_set_readonly (XedDocument *doc,
|
||||||
gboolean readonly);
|
gboolean readonly);
|
||||||
|
|
||||||
glong _xed_document_get_seconds_since_last_save_or_load
|
glong _xed_document_get_seconds_since_last_save_or_load (XedDocument *doc);
|
||||||
(XedDocument *doc);
|
|
||||||
|
|
||||||
void _xed_document_apply_error_style (XedDocument *doc,
|
void _xed_document_apply_error_style (XedDocument *doc,
|
||||||
GtkTextIter *start,
|
GtkTextIter *start,
|
||||||
|
@ -248,19 +228,17 @@ void _xed_document_apply_error_style (XedDocument *doc,
|
||||||
GtkTextIter *end);
|
GtkTextIter *end);
|
||||||
|
|
||||||
/* Note: this is a sync stat: use only on local files */
|
/* Note: this is a sync stat: use only on local files */
|
||||||
gboolean _xed_document_check_externally_modified
|
gboolean _xed_document_check_externally_modified (XedDocument *doc);
|
||||||
(XedDocument *doc);
|
|
||||||
|
gboolean _xed_document_needs_saving (XedDocument *doc);
|
||||||
|
|
||||||
typedef GMountOperation *(*XedMountOperationFactory)(XedDocument *doc,
|
typedef GMountOperation *(*XedMountOperationFactory)(XedDocument *doc,
|
||||||
gpointer userdata);
|
gpointer userdata);
|
||||||
|
|
||||||
void _xed_document_set_mount_operation_factory
|
void _xed_document_set_mount_operation_factory (XedDocument *doc,
|
||||||
(XedDocument *doc,
|
|
||||||
XedMountOperationFactory callback,
|
XedMountOperationFactory callback,
|
||||||
gpointer userdata);
|
gpointer userdata);
|
||||||
GMountOperation
|
GMountOperation *_xed_document_create_mount_operation (XedDocument *doc);
|
||||||
*_xed_document_create_mount_operation
|
|
||||||
(XedDocument *doc);
|
|
||||||
|
|
||||||
void _xed_document_set_search_context (XedDocument *doc,
|
void _xed_document_set_search_context (XedDocument *doc,
|
||||||
GtkSourceSearchContext *search_context);
|
GtkSourceSearchContext *search_context);
|
||||||
|
|
|
@ -2501,10 +2501,12 @@ _xed_tab_can_close (XedTab *tab)
|
||||||
|
|
||||||
doc = xed_tab_get_document (tab);
|
doc = xed_tab_get_document (tab);
|
||||||
|
|
||||||
/* TODO: we need to save the file also if it has been externally
|
if (_xed_document_needs_saving (doc))
|
||||||
modified - Paolo (Oct 10, 2005) */
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return (!gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)) && !xed_document_get_deleted (doc));
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue