Commit 21fca22f authored by Jesse van den Kieboom's avatar Jesse van den Kieboom

Implemented phase 1 of porting gedit to gio. This first phase includes

	* gedit/gedit-tab.c:
	* gedit/gedit-gnomevfs-document-saver.c:
	* gedit/gedit-document-loader.c:
	* gedit/gedit-local-document-saver.c:
	* gedit/gedit-document-loader.h:
	* gedit/gedit-utils.c:
	* gedit/gedit-utils.h:
	* gedit/gedit-file-chooser-dialog.c:
	* gedit/gedit-io-error-message-area.c:
	* gedit/gedit-window.c:
	* gedit/gedit-mmap-document-loader.c:
	* gedit/gedit-document.c:
	* gedit/gedit-document.h:
	* gedit/gedit-gnomevfs-document-loader.c:
	* gedit/gedit-commands-file.c:
	* gedit/gedit-language-manager.c:
	* gedit/gedit-document-saver.c:
	* gedit/gedit-document-saver.h:
	* configure.ac:
	
	Implemented phase 1 of porting gedit to gio. This first phase includes
	small pieces of gnome-vfs and libgnomeui to be ported to gio. This
	includes mime type information, looking up icons, handling uri's
	and replacing gnome-vfs types like GnomeVFSFileSize.

svn path=/trunk/; revision=6351
parent 63b66477
2008-08-06 Jesse van den Kieboom <jesse@icecrew.nl>
* gedit/gedit-tab.c:
* gedit/gedit-gnomevfs-document-saver.c:
* gedit/gedit-document-loader.c:
* gedit/gedit-local-document-saver.c:
* gedit/gedit-document-loader.h:
* gedit/gedit-utils.c:
* gedit/gedit-utils.h:
* gedit/gedit-file-chooser-dialog.c:
* gedit/gedit-io-error-message-area.c:
* gedit/gedit-window.c:
* gedit/gedit-mmap-document-loader.c:
* gedit/gedit-document.c:
* gedit/gedit-document.h:
* gedit/gedit-gnomevfs-document-loader.c:
* gedit/gedit-commands-file.c:
* gedit/gedit-language-manager.c:
* gedit/gedit-document-saver.c:
* gedit/gedit-document-saver.h:
* configure.ac:
Implemented phase 1 of porting gedit to gio. This first phase includes
small pieces of gnome-vfs and libgnomeui to be ported to gio. This
includes mime type information, looking up icons, handling uri's
and replacing gnome-vfs types like GnomeVFSFileSize.
2008-07-31 Jesse van den Kieboom <jesse@icecrew.nl>
Bug 539581 – GEdit segfaults when using the FileBrowser plugin
......
......@@ -163,8 +163,8 @@ dnl Start of pkg-config checks
dnl ================================================================
PKG_CHECK_MODULES(GEDIT, [
glib-2.0 >= 2.14.0
gtk+-2.0 >= 2.12.0
glib-2.0 >= 2.13.0
gtk+-2.0 >= 2.13.0
gtksourceview-2.0 >= 2.2.0
libgnomeui-2.0 >= 2.16.0
libglade-2.0 >= 2.5.1
......
......@@ -704,7 +704,7 @@ save_dialog_response_cb (GeditFileChooserDialog *dialog,
doc = gedit_tab_get_document (tab);
g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
uri_for_display = gedit_utils_format_uri_for_display (uri);
uri_for_display = gedit_utils_uri_for_display (uri);
gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
window->priv->generic_message_cid,
......
......@@ -433,7 +433,7 @@ gedit_document_loader_get_mtime (GeditDocumentLoader *loader)
}
/* Returns 0 if file size is unknown */
GnomeVFSFileSize
goffset
gedit_document_loader_get_file_size (GeditDocumentLoader *loader)
{
g_return_val_if_fail (GEDIT_IS_DOCUMENT_LOADER (loader), 0);
......@@ -441,7 +441,7 @@ gedit_document_loader_get_file_size (GeditDocumentLoader *loader)
return GEDIT_DOCUMENT_LOADER_GET_CLASS (loader)->get_file_size (loader);
}
GnomeVFSFileSize
goffset
gedit_document_loader_get_bytes_read (GeditDocumentLoader *loader)
{
g_return_val_if_fail (GEDIT_IS_DOCUMENT_LOADER (loader), 0);
......
......@@ -88,8 +88,8 @@ struct _GeditDocumentLoaderClass
gboolean (* cancel) (GeditDocumentLoader *loader);
const gchar * (* get_mime_type) (GeditDocumentLoader *loader);
time_t (* get_mtime) (GeditDocumentLoader *loader);
GnomeVFSFileSize (* get_file_size) (GeditDocumentLoader *loader);
GnomeVFSFileSize (* get_bytes_read) (GeditDocumentLoader *loader);
goffset (* get_file_size) (GeditDocumentLoader *loader);
goffset (* get_bytes_read) (GeditDocumentLoader *loader);
gboolean (* get_readonly) (GeditDocumentLoader *loader);
};
......@@ -134,10 +134,10 @@ gboolean gedit_document_loader_get_readonly (GeditDocumentLoader *loader);
const GeditEncoding *gedit_document_loader_get_encoding (GeditDocumentLoader *loader);
/* Returns 0 if file size is unknown */
/* FIXME: change GnomeVFSFileSize to what glib provides. */
GnomeVFSFileSize gedit_document_loader_get_file_size (GeditDocumentLoader *loader);
/* FIXME: change goffset to what glib provides. */
goffset gedit_document_loader_get_file_size (GeditDocumentLoader *loader);
GnomeVFSFileSize gedit_document_loader_get_bytes_read (GeditDocumentLoader *loader);
goffset gedit_document_loader_get_bytes_read (GeditDocumentLoader *loader);
G_END_DECLS
......
......@@ -446,7 +446,7 @@ gedit_document_saver_get_mtime (GeditDocumentSaver *saver)
}
/* Returns 0 if file size is unknown */
GnomeVFSFileSize
goffset
gedit_document_saver_get_file_size (GeditDocumentSaver *saver)
{
g_return_val_if_fail (GEDIT_IS_DOCUMENT_SAVER (saver), 0);
......@@ -454,7 +454,7 @@ gedit_document_saver_get_file_size (GeditDocumentSaver *saver)
return GEDIT_DOCUMENT_SAVER_GET_CLASS (saver)->get_file_size (saver);
}
GnomeVFSFileSize
goffset
gedit_document_saver_get_bytes_written (GeditDocumentSaver *saver)
{
g_return_val_if_fail (GEDIT_IS_DOCUMENT_SAVER (saver), 0);
......
......@@ -89,8 +89,8 @@ struct _GeditDocumentSaverClass
time_t old_mtime);
const gchar * (* get_mime_type) (GeditDocumentSaver *saver);
time_t (* get_mtime) (GeditDocumentSaver *saver);
GnomeVFSFileSize (* get_file_size) (GeditDocumentSaver *saver);
GnomeVFSFileSize (* get_bytes_written) (GeditDocumentSaver *saver);
goffset (* get_file_size) (GeditDocumentSaver *saver);
goffset (* get_bytes_written) (GeditDocumentSaver *saver);
};
/*
......@@ -131,9 +131,9 @@ const gchar *gedit_document_saver_get_mime_type (GeditDocumentSaver *saver);
time_t gedit_document_saver_get_mtime (GeditDocumentSaver *saver);
/* Returns 0 if file size is unknown */
GnomeVFSFileSize gedit_document_saver_get_file_size (GeditDocumentSaver *saver);
goffset gedit_document_saver_get_file_size (GeditDocumentSaver *saver);
GnomeVFSFileSize gedit_document_saver_get_bytes_written (GeditDocumentSaver *saver);
goffset gedit_document_saver_get_bytes_written (GeditDocumentSaver *saver);
G_END_DECLS
......
......@@ -38,7 +38,6 @@
#include <stdlib.h>
#include <glib/gi18n.h>
#include <libgnomevfs/gnome-vfs.h>
#include <gtksourceview/gtksourceiter.h>
#include "gedit-prefs-manager-app.h"
......@@ -108,8 +107,6 @@ struct _GeditDocumentPrivate
gchar *uri;
gint untitled_number;
GnomeVFSURI *vfs_uri;
const GeditEncoding *encoding;
gchar *mime_type;
......@@ -277,9 +274,6 @@ gedit_document_finalize (GObject *object)
}
g_free (doc->priv->uri);
if (doc->priv->vfs_uri != NULL)
gnome_vfs_uri_unref (doc->priv->vfs_uri);
g_free (doc->priv->mime_type);
g_free (doc->priv->search_text);
......@@ -688,7 +682,6 @@ gedit_document_init (GeditDocument *doc)
doc->priv = GEDIT_DOCUMENT_GET_PRIVATE (doc);
doc->priv->uri = NULL;
doc->priv->vfs_uri = NULL;
doc->priv->untitled_number = get_untitled_number ();
doc->priv->mime_type = g_strdup ("text/plain");
......@@ -760,13 +753,6 @@ set_uri (GeditDocument *doc,
g_free (doc->priv->uri);
doc->priv->uri = g_strdup (uri);
if (doc->priv->vfs_uri != NULL)
gnome_vfs_uri_unref (doc->priv->vfs_uri);
/* Note: vfs_uri may be NULL for some valid but
* unsupported uris */
doc->priv->vfs_uri = gnome_vfs_uri_new (uri);
if (doc->priv->untitled_number > 0)
{
release_untitled_number (doc->priv->untitled_number);
......@@ -781,23 +767,16 @@ set_uri (GeditDocument *doc,
}
else
{
gchar *base_name = NULL;
/* Guess the mime type from file extension or fallback to "text/plain" */
if (doc->priv->vfs_uri != NULL)
base_name = gnome_vfs_uri_extract_short_path_name (doc->priv->vfs_uri);
if (base_name != NULL)
if (doc->priv->uri != NULL)
{
const gchar *detected_mime;
detected_mime = gnome_vfs_get_mime_type_for_name (base_name);
if (detected_mime == NULL ||
strcmp (GNOME_VFS_MIME_TYPE_UNKNOWN, detected_mime) == 0)
detected_mime = g_content_type_guess (doc->priv->uri, NULL, 0, NULL);
if (detected_mime == NULL || g_content_type_is_unknown (detected_mime))
detected_mime = "text/plain";
doc->priv->mime_type = g_strdup (detected_mime);
g_free (base_name);
}
else
{
......@@ -879,89 +858,8 @@ gedit_document_get_uri_for_display (GeditDocument *doc)
if (doc->priv->uri == NULL)
return g_strdup_printf (_("Unsaved Document %d"),
doc->priv->untitled_number);
else if (doc->priv->vfs_uri == NULL)
return gnome_vfs_format_uri_for_display (doc->priv->uri);
else
{
gchar *name;
gchar *uri_for_display;
name = gnome_vfs_uri_to_string (doc->priv->vfs_uri, GNOME_VFS_URI_HIDE_PASSWORD);
g_return_val_if_fail (name != NULL, gnome_vfs_format_uri_for_display (doc->priv->uri));
uri_for_display = gnome_vfs_format_uri_for_display (name);
g_free (name);
return uri_for_display;
}
}
/* move to gedit-utils? */
static gchar *
get_uri_shortname_for_display (GnomeVFSURI *uri)
{
gchar *name;
gboolean validated;
validated = FALSE;
name = gnome_vfs_uri_extract_short_name (uri);
if (name == NULL)
{
name = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
}
else if (g_ascii_strcasecmp (uri->method_string, "file") == 0)
{
gchar *text_uri;
gchar *local_file;
text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
local_file = gnome_vfs_get_local_path_from_uri (text_uri);
if (local_file != NULL)
{
g_free (name);
name = g_filename_display_basename (local_file);
validated = TRUE;
}
g_free (local_file);
g_free (text_uri);
}
else if (!gnome_vfs_uri_has_parent (uri))
{
const gchar *method;
method = uri->method_string;
if (name == NULL ||
strcmp (name, GNOME_VFS_URI_PATH_STR) == 0)
{
g_free (name);
name = g_strdup (method);
}
/*
else
{
gchar *tmp;
tmp = name;
name = g_strdup_printf ("%s: %s", method, name);
g_free (tmp);
}
*/
}
if (!validated && !g_utf8_validate (name, -1, NULL))
{
gchar *utf8_name;
utf8_name = gedit_utils_make_valid_utf8 (name);
g_free (name);
name = utf8_name;
}
return name;
return gedit_utils_uri_for_display (doc->priv->uri);
}
/* Never returns NULL */
......@@ -973,10 +871,8 @@ gedit_document_get_short_name_for_display (GeditDocument *doc)
if (doc->priv->uri == NULL)
return g_strdup_printf (_("Unsaved Document %d"),
doc->priv->untitled_number);
else if (doc->priv->vfs_uri == NULL)
return g_strdup (doc->priv->uri);
else
return get_uri_shortname_for_display (doc->priv->vfs_uri);
return gedit_utils_basename_for_display (doc->priv->uri);
}
/* Never returns NULL */
......@@ -1028,9 +924,8 @@ gedit_document_get_readonly (GeditDocument *doc)
gboolean
_gedit_document_check_externally_modified (GeditDocument *doc)
{
GnomeVFSFileInfo *info;
GnomeVFSResult result;
gboolean res = FALSE;
GFile *gfile;
GFileInfo *info;
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE);
......@@ -1039,27 +934,20 @@ _gedit_document_check_externally_modified (GeditDocument *doc)
return FALSE;
}
info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info_uri (doc->priv->vfs_uri,
info,
GNOME_VFS_FILE_INFO_DEFAULT|
GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
if (result != GNOME_VFS_OK)
gfile = g_file_new_for_uri (doc->priv->uri);
info = g_file_query_info (gfile, G_FILE_ATTRIBUTE_TIME_MODIFIED, G_FILE_QUERY_INFO_NONE, NULL, NULL);
g_object_unref (gfile);
if (info == NULL)
{
gnome_vfs_file_info_unref (info);
return FALSE;
}
if (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MTIME)
{
res = info->mtime > doc->priv->mtime;
}
gnome_vfs_file_info_unref (info);
return res;
GTimeVal timeval;
g_file_info_get_modification_time (info, &timeval);
g_object_unref (info);
return timeval.tv_sec > doc->priv->mtime;
}
static void
......@@ -1178,8 +1066,8 @@ document_loader_loading (GeditDocumentLoader *loader,
}
else
{
GnomeVFSFileSize size;
GnomeVFSFileSize read;
goffset size;
goffset read;
size = gedit_document_loader_get_file_size (loader);
read = gedit_document_loader_get_bytes_read (loader);
......@@ -1299,8 +1187,8 @@ document_saver_saving (GeditDocumentSaver *saver,
}
else
{
GnomeVFSFileSize size = 0;
GnomeVFSFileSize written = 0;
goffset size = 0;
goffset written = 0;
size = gedit_document_saver_get_file_size (saver);
written = gedit_document_saver_get_bytes_written (saver);
......@@ -1441,10 +1329,7 @@ gedit_document_get_deleted (GeditDocument *doc)
{
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE);
if (doc->priv->uri == NULL || doc->priv->vfs_uri == NULL)
return FALSE;
return !gnome_vfs_uri_exists (doc->priv->vfs_uri);
return doc->priv->uri && !gedit_utils_uri_exists (doc->priv->uri);
}
/*
......
......@@ -110,8 +110,8 @@ struct _GeditDocumentClass
gboolean create);
void (* loading) (GeditDocument *document,
GnomeVFSFileSize size,
GnomeVFSFileSize total_size);
goffset size,
goffset total_size);
void (* loaded) (GeditDocument *document,
const GError *error);
......@@ -123,8 +123,8 @@ struct _GeditDocumentClass
GeditDocumentSaveFlags flags);
void (* saving) (GeditDocument *document,
GnomeVFSFileSize size,
GnomeVFSFileSize total_size);
goffset size,
goffset total_size);
void (* saved) (GeditDocument *document,
const GError *error);
......
......@@ -39,7 +39,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include "gedit-file-chooser-dialog.h"
#include "gedit-encodings-option-menu.h"
......@@ -184,12 +183,7 @@ all_text_files_filter (const GtkFileFilterInfo *filter_info,
for (i = 0; mime_types[i] != NULL; i++)
{
GnomeVFSMimeEquivalence res;
res = gnome_vfs_mime_type_get_equivalence (mime_types[i],
"text/plain");
if (res == GNOME_VFS_MIME_UNRELATED)
if (!g_content_type_is_a (mime_types[i], "text/plain"))
{
gedit_debug_message (DEBUG_COMMANDS,
"Mime-type %s is not related to text/plain",
......@@ -226,11 +220,7 @@ all_text_files_filter (const GtkFileFilterInfo *filter_info,
mime_types = known_mime_types;
while (mime_types != NULL)
{
GnomeVFSMimeEquivalence res;
res = gnome_vfs_mime_type_get_equivalence (filter_info->mime_type,
(const gchar*)mime_types->data);
if (res != GNOME_VFS_MIME_UNRELATED)
if (g_content_type_is_a (filter_info->mime_type, (const gchar*)mime_types->data))
return TRUE;
mime_types = g_slist_next (mime_types);
......
......@@ -53,8 +53,8 @@ static void gedit_gnomevfs_document_loader_load (GeditDocumentLoader *loader)
static gboolean gedit_gnomevfs_document_loader_cancel (GeditDocumentLoader *loader);
static const gchar *gedit_gnomevfs_document_loader_get_mime_type (GeditDocumentLoader *loader);
static time_t gedit_gnomevfs_document_loader_get_mtime (GeditDocumentLoader *loader);
static GnomeVFSFileSize gedit_gnomevfs_document_loader_get_file_size (GeditDocumentLoader *loader);
static GnomeVFSFileSize gedit_gnomevfs_document_loader_get_bytes_read (GeditDocumentLoader *loader);
static goffset gedit_gnomevfs_document_loader_get_file_size (GeditDocumentLoader *loader);
static goffset gedit_gnomevfs_document_loader_get_bytes_read (GeditDocumentLoader *loader);
static gboolean gedit_gnomevfs_document_loader_get_readonly (GeditDocumentLoader *loader);
......@@ -178,8 +178,8 @@ static void
async_read_cb (GnomeVFSAsyncHandle *handle,
GnomeVFSResult result,
gpointer buffer,
GnomeVFSFileSize bytes_requested,
GnomeVFSFileSize bytes_read,
GnomeVFSFileSize bytes_requested,
GnomeVFSFileSize bytes_read,
GeditGnomeVFSDocumentLoader *gvloader)
{
gedit_debug (DEBUG_LOADER);
......@@ -436,18 +436,18 @@ gedit_gnomevfs_document_loader_get_mtime (GeditDocumentLoader *loader)
}
/* Returns 0 if file size is unknown */
static GnomeVFSFileSize
static goffset
gedit_gnomevfs_document_loader_get_file_size (GeditDocumentLoader *loader)
{
GeditGnomeVFSDocumentLoader *gvloader = GEDIT_GNOMEVFS_DOCUMENT_LOADER (loader);
if (gvloader->priv->info == NULL)
return (GnomeVFSFileSize) 0;
return (goffset) 0;
return (GnomeVFSFileSize) gvloader->priv->info->size;
return (goffset) gvloader->priv->info->size;
}
static GnomeVFSFileSize
static goffset
gedit_gnomevfs_document_loader_get_bytes_read (GeditDocumentLoader *loader)
{
return GEDIT_GNOMEVFS_DOCUMENT_LOADER (loader)->priv->bytes_read;
......
......@@ -46,8 +46,8 @@ static void gedit_gnomevfs_document_saver_save (GeditDocumentSaver *saver,
time_t old_mtime);
static const gchar *gedit_gnomevfs_document_saver_get_mime_type (GeditDocumentSaver *saver);
static time_t gedit_gnomevfs_document_saver_get_mtime (GeditDocumentSaver *saver);
static GnomeVFSFileSize gedit_gnomevfs_document_saver_get_file_size (GeditDocumentSaver *saver);
static GnomeVFSFileSize gedit_gnomevfs_document_saver_get_bytes_written (GeditDocumentSaver *saver);
static goffset gedit_gnomevfs_document_saver_get_file_size (GeditDocumentSaver *saver);
static goffset gedit_gnomevfs_document_saver_get_bytes_written (GeditDocumentSaver *saver);
struct _GeditGnomeVFSDocumentSaverPrivate
{
......@@ -526,13 +526,13 @@ gedit_gnomevfs_document_saver_get_mtime (GeditDocumentSaver *saver)
return GEDIT_GNOMEVFS_DOCUMENT_SAVER (saver)->priv->doc_mtime;
}
static GnomeVFSFileSize
static goffset
gedit_gnomevfs_document_saver_get_file_size (GeditDocumentSaver *saver)
{
return GEDIT_GNOMEVFS_DOCUMENT_SAVER (saver)->priv->size;
}
static GnomeVFSFileSize
static goffset
gedit_gnomevfs_document_saver_get_bytes_written (GeditDocumentSaver *saver)
{
return GEDIT_GNOMEVFS_DOCUMENT_SAVER (saver)->priv->bytes_written;
......
......@@ -166,7 +166,7 @@ gedit_io_loading_error_message_area_new (const gchar *uri,
g_return_val_if_fail (error != NULL, NULL);
g_return_val_if_fail (error->domain == GEDIT_DOCUMENT_ERROR, NULL);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -417,7 +417,7 @@ gedit_unrecoverable_reverting_error_message_area_new (const gchar *uri,
g_return_val_if_fail (error != NULL, NULL);
g_return_val_if_fail (error->domain == GEDIT_DOCUMENT_ERROR, NULL);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -751,7 +751,7 @@ gedit_conversion_error_while_loading_message_area_new (
g_return_val_if_fail ((error->domain == G_CONVERT_ERROR) ||
(error->domain == GEDIT_CONVERT_ERROR), NULL);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -819,7 +819,7 @@ gedit_conversion_error_while_saving_message_area_new (
g_return_val_if_fail (error->domain == G_CONVERT_ERROR, NULL);
g_return_val_if_fail (encoding != NULL, NULL);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -885,7 +885,7 @@ gedit_file_already_open_warning_message_area_new (const gchar *uri)
gchar *uri_for_display;
gchar *temp_uri_for_display;
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -976,7 +976,7 @@ gedit_externally_modified_saving_error_message_area_new (
g_return_val_if_fail (error->domain == GEDIT_DOCUMENT_ERROR, NULL);
g_return_val_if_fail (error->code == GEDIT_DOCUMENT_ERROR_EXTERNALLY_MODIFIED, NULL);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -1071,7 +1071,7 @@ gedit_no_backup_saving_error_message_area_new (const gchar *uri,
g_return_val_if_fail (error->domain == GEDIT_DOCUMENT_ERROR, NULL);
g_return_val_if_fail (error->code == GEDIT_DOCUMENT_ERROR_CANT_CREATE_BACKUP, NULL);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -1166,7 +1166,7 @@ gedit_unrecoverable_saving_error_message_area_new (const gchar *uri,
g_return_val_if_fail (error != NULL, NULL);
g_return_val_if_fail (error->domain == GEDIT_DOCUMENT_ERROR, NULL);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......@@ -1409,7 +1409,7 @@ gedit_externally_modified_message_area_new (const gchar *uri,
g_return_val_if_fail (uri != NULL, NULL);
full_formatted_uri = gedit_utils_format_uri_for_display (uri);
full_formatted_uri = gedit_utils_uri_for_display (uri);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
......
......@@ -177,15 +177,7 @@ gedit_language_manager_get_language_from_mime_type (GtkSourceLanguageManager *lm
for (i = 0; mime_types[i] != NULL; ++i)
{
GnomeVFSMimeEquivalence res;
/* Use gnome_vfs_mime_type_get_equivalence instead of
* strcmp, to take care of mime-types inheritance
* (see bug #324191) */
res = gnome_vfs_mime_type_get_equivalence (mime_type,
mime_types[i]);
if (res == GNOME_VFS_MIME_IDENTICAL)
if (g_content_type_equals(mime_type, mime_types[i]))
{
/* If the mime-type of lang is identical to "mime-type" then
return lang */
......@@ -197,7 +189,7 @@ gedit_language_manager_get_language_from_mime_type (GtkSourceLanguageManager *lm
break;
}
else if ((res == GNOME_VFS_MIME_PARENT) && (parent == NULL))
else if (parent == NULL && g_content_type_is_a (mime_type, mime_types[i]))
{
/* If the mime-type of lang is a parent of "mime-type" then
remember it. We will return it if we don't find
......
......@@ -61,22 +61,22 @@ static void gedit_local_document_saver_save (GeditDocumentSaver *saver,
time_t old_mtime);
static const gchar *gedit_local_document_saver_get_mime_type (GeditDocumentSaver *saver);
static time_t gedit_local_document_saver_get_mtime (GeditDocumentSaver *saver);
static GnomeVFSFileSize gedit_local_document_saver_get_file_size (GeditDocumentSaver *saver);
static GnomeVFSFileSize gedit_local_document_saver_get_bytes_written (GeditDocumentSaver *saver);
static goffset gedit_local_document_saver_get_file_size (GeditDocumentSaver *saver);
static goffset gedit_local_document_saver_get_bytes_written (GeditDocumentSaver *saver);
struct _GeditLocalDocumentSaverPrivate
{
GnomeVFSFileSize size;
GnomeVFSFileSize bytes_written;
goffset size;
goffset bytes_written;
/* temp data for local files */
gint fd;
gchar *local_path;
gchar *mime_type; //CHECK use FileInfo instead?
time_t doc_mtime;
gint fd;
gchar *local_path;
gchar *mime_type; //CHECK use FileInfo instead?
time_t doc_mtime;
GError *error;
GError *error;
};
G_DEFINE_TYPE(GeditLocalDocumentSaver, gedit_local_document_saver, GEDIT_TYPE_DOCUMENT_SAVER)
......@@ -873,13 +873,13 @@ gedit_local_document_saver_get_mtime (GeditDocumentSaver *saver)
return GEDIT_LOCAL_DOCUMENT_SAVER (saver)->priv->doc_mtime;
}
static GnomeVFSFileSize
static goffset
gedit_local_document_saver_get_file_size (GeditDocumentSaver *saver)
{
return GEDIT_LOCAL_DOCUMENT_SAVER (saver)->priv->size;
}
static GnomeVFSFileSize
static goffset
gedit_local_document_saver_get_bytes_written (GeditDocumentSaver *saver)
{
return GEDIT_LOCAL_DOCUMENT_SAVER (saver)->priv->bytes_written;
......
......@@ -64,24 +64,24 @@ static void gedit_mmap_document_loader_load (GeditDocumentLoader *loader);
static gboolean gedit_mmap_document_loader_cancel (GeditDocumentLoader *loader);
static const gchar *gedit_mmap_document_loader_get_mime_type (GeditDocumentLoader *loader);
static time_t gedit_mmap_document_loader_get_mtime (GeditDocumentLoader *loader);
static GnomeVFSFileSize gedit_mmap_document_loader_get_file_size (GeditDocumentLoader *loader);
static GnomeVFSFileSize gedit_mmap_document_loader_get_bytes_read (GeditDocumentLoader *loader);
static goffset gedit_mmap_document_loader_get_file_size (GeditDocumentLoader *loader);
static goffset gedit_mmap_document_loader_get_bytes_read (GeditDocumentLoader *loader);
static gboolean gedit_mmap_document_loader_get_readonly (GeditDocumentLoader *loader);
struct _GeditMmapDocumentLoaderPrivate
{
struct stat statbuf;
gchar *mime_type;
guint statbuf_filled : 1;
struct stat statbuf;
gchar *mime_type;
guint statbuf_filled : 1;
GnomeVFSFileSize bytes_read;
goffset bytes_read;
gint fd;
gchar *local_file_name;
gint fd;
gchar *local_file_name;
gchar *buffer;
gchar *buffer;
GError *error;
GError *error;
};
G_DEFINE_TYPE(GeditMmapDocumentLoader, gedit_mmap_document_loader, GEDIT_TYPE_DOCUMENT_LOADER)
......@@ -398,17 +398,17 @@ gedit_mmap_document_loader_get_mtime (GeditDocumentLoader *loader)
return mloader->priv->statbuf.st_mtime;
}
static GnomeVFSFileSize
static goffset
gedit_mmap_document_loader_get_file_size (GeditDocumentLoader *loader)
{
GeditMmapDocumentLoader *mloader = GEDIT_MMAP_DOCUMENT_LOADER (loader);
if (!mloader->priv->statbuf_filled)
return (GnomeVFSFileSize) 0;
return (GnomeVFSFileSize) mloader->priv->statbuf.st_size;
return (goffset) 0;
return (goffset) mloader->priv->statbuf.st_size;
}
static GnomeVFSFileSize
static goffset
gedit_mmap_document_loader_get_bytes_read (GeditDocumentLoader *loader)
{
return GEDIT_MMAP_DOCUMENT_LOADER (loader)->priv->bytes_read;
......