Get rid of URIs and use GFile instead.

parent 256ed6e9
......@@ -120,7 +120,7 @@ is_duplicated_file (GSList *files, GFile *file)
/* File loading */
static gint
load_file_list (GeditWindow *window,
GSList *files,
const GSList *files,
const GeditEncoding *encoding,
gint line_pos,
gboolean create)
......@@ -130,7 +130,7 @@ load_file_list (GeditWindow *window,
gboolean jump_to = TRUE; /* Whether to jump to the new tab */
GList *win_docs;
GSList *files_to_load = NULL;
GSList *l;
const GSList *l;
gedit_debug (DEBUG_COMMANDS);
......@@ -192,16 +192,11 @@ load_file_list (GeditWindow *window,
if (gedit_document_is_untouched (doc) &&
(gedit_tab_get_state (tab) == GEDIT_TAB_STATE_NORMAL))
{
gchar *uri;
// FIXME: pass the GFile to tab when api is there
uri = g_file_get_uri (l->data);
_gedit_tab_load (tab,
uri,
l->data,
encoding,
line_pos,
create);
g_free (uri);
l = g_slist_next (l);
jump_to = FALSE;
......@@ -212,19 +207,14 @@ load_file_list (GeditWindow *window,
while (l != NULL)
{
gchar *uri;
g_return_val_if_fail (l->data != NULL, 0);
// FIXME: pass the GFile to tab when api is there
uri = g_file_get_uri (l->data);
tab = gedit_window_create_tab_from_uri (window,
uri,
encoding,
line_pos,
create,
jump_to);
g_free (uri);
tab = gedit_window_create_tab_from_location (window,
l->data,
encoding,
line_pos,
create,
jump_to);
if (tab != NULL)
{
......@@ -268,100 +258,52 @@ load_file_list (GeditWindow *window,
return loaded_files;
}
// FIXME: we should expose API with GFile and just make the uri
// variants backward compat wrappers
static gint
load_uri_list (GeditWindow *window,
const GSList *uris,
const GeditEncoding *encoding,
gint line_pos,
gboolean create)
{
GSList *files = NULL;
const GSList *u;
gint ret;
for (u = uris; u != NULL; u = u->next)
{
gchar *uri = u->data;
if (gedit_utils_is_valid_uri (uri))
files = g_slist_prepend (files, g_file_new_for_uri (uri));
else
g_warning ("invalid uri: %s", uri);
}
files = g_slist_reverse (files);
ret = load_file_list (window, files, encoding, line_pos, create);
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
g_slist_free (files);
return ret;
}
/**
* gedit_commands_load_uri:
*
* Do nothing if URI does not exist
* Do nothing if location does not exist
*/
void
gedit_commands_load_uri (GeditWindow *window,
const gchar *uri,
const GeditEncoding *encoding,
gint line_pos)
gedit_commands_load_location (GeditWindow *window,
GFile *location,
const GeditEncoding *encoding,
gint line_pos)
{
GSList *uris = NULL;
GSList *locations = NULL;
gchar *uri;
g_return_if_fail (GEDIT_IS_WINDOW (window));
g_return_if_fail (uri != NULL);
g_return_if_fail (gedit_utils_is_valid_uri (uri));
g_return_if_fail (G_IS_FILE (location));
g_return_if_fail (gedit_utils_is_valid_location (location));
uri = g_file_get_uri (location);
gedit_debug_message (DEBUG_COMMANDS, "Loading URI '%s'", uri);
g_free (uri);
uris = g_slist_prepend (uris, (gchar *)uri);
locations = g_slist_prepend (locations, location);
load_uri_list (window, uris, encoding, line_pos, FALSE);
load_file_list (window, locations, encoding, line_pos, FALSE);
g_slist_free (uris);
g_slist_free (locations);
}
/**
* gedit_commands_load_uris:
*
* Ignore non-existing URIs
* Ignore non-existing locations
*/
gint
gedit_commands_load_uris (GeditWindow *window,
const GSList *uris,
const GeditEncoding *encoding,
gint line_pos)
gedit_commands_load_locations (GeditWindow *window,
const GSList *locations,
const GeditEncoding *encoding,
gint line_pos)
{
g_return_val_if_fail (GEDIT_IS_WINDOW (window), 0);
g_return_val_if_fail ((uris != NULL) && (uris->data != NULL), 0);
g_return_val_if_fail ((locations != NULL) && (locations->data != NULL), 0);
gedit_debug (DEBUG_COMMANDS);
return load_uri_list (window, uris, encoding, line_pos, FALSE);
}
/*
* This should become public once we convert all api to GFile:
*/
static gint
gedit_commands_load_files (GeditWindow *window,
GSList *files,
const GeditEncoding *encoding,
gint line_pos)
{
g_return_val_if_fail (GEDIT_IS_WINDOW (window), 0);
g_return_val_if_fail ((files != NULL) && (files->data != NULL), 0);
gedit_debug (DEBUG_COMMANDS);
return load_file_list (window, files, encoding, line_pos, FALSE);
return load_file_list (window, locations, encoding, line_pos, FALSE);
}
/*
......@@ -418,10 +360,10 @@ open_dialog_response_cb (GeditFileChooserDialog *dialog,
/* Remember the folder we navigated to */
_gedit_window_set_default_location (window, files->data);
gedit_commands_load_files (window,
files,
encoding,
0);
gedit_commands_load_locations (window,
files,
encoding,
0);
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
g_slist_free (files);
......@@ -626,7 +568,6 @@ save_dialog_response_cb (GeditFileChooserDialog *dialog,
{
GeditDocument *doc;
gchar *parse_name;
gchar *uri;
doc = gedit_tab_get_document (tab);
g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
......@@ -644,10 +585,7 @@ save_dialog_response_cb (GeditFileChooserDialog *dialog,
* even if the saving fails... */
_gedit_window_set_default_location (window, file);
// FIXME: pass the GFile to tab when api is there
uri = g_file_get_uri (file);
_gedit_tab_save_as (tab, uri, encoding, newline_type);
g_free (uri);
_gedit_tab_save_as (tab, file, encoding, newline_type);
}
g_object_unref (file);
......
......@@ -40,14 +40,14 @@
G_BEGIN_DECLS
/* Do nothing if URI does not exist */
void gedit_commands_load_uri (GeditWindow *window,
const gchar *uri,
void gedit_commands_load_location (GeditWindow *window,
GFile *location,
const GeditEncoding *encoding,
gint line_pos);
/* Ignore non-existing URIs */
gint gedit_commands_load_uris (GeditWindow *window,
const GSList *uris,
gint gedit_commands_load_locations (GeditWindow *window,
const GSList *locations,
const GeditEncoding *encoding,
gint line_pos);
......
......@@ -62,7 +62,7 @@ enum
{
PROP_0,
PROP_DOCUMENT,
PROP_URI,
PROP_LOCATION,
PROP_ENCODING,
PROP_NEWLINE_TYPE
};
......@@ -81,9 +81,9 @@ gedit_document_loader_set_property (GObject *object,
g_return_if_fail (loader->document == NULL);
loader->document = g_value_get_object (value);
break;
case PROP_URI:
g_return_if_fail (loader->uri == NULL);
loader->uri = g_value_dup_string (value);
case PROP_LOCATION:
g_return_if_fail (loader->location == NULL);
loader->location = g_value_dup_object (value);
break;
case PROP_ENCODING:
g_return_if_fail (loader->encoding == NULL);
......@@ -111,8 +111,8 @@ gedit_document_loader_get_property (GObject *object,
case PROP_DOCUMENT:
g_value_set_object (value, loader->document);
break;
case PROP_URI:
g_value_set_string (value, loader->uri);
case PROP_LOCATION:
g_value_set_object (value, loader->location);
break;
case PROP_ENCODING:
g_value_set_boxed (value, gedit_document_loader_get_encoding (loader));
......@@ -129,13 +129,6 @@ gedit_document_loader_get_property (GObject *object,
static void
gedit_document_loader_finalize (GObject *object)
{
GeditDocumentLoader *loader = GEDIT_DOCUMENT_LOADER (object);
g_free (loader->uri);
if (loader->info)
g_object_unref (loader->info);
G_OBJECT_CLASS (gedit_document_loader_parent_class)->finalize (object);
}
......@@ -149,6 +142,12 @@ gedit_document_loader_dispose (GObject *object)
g_object_unref (loader->info);
loader->info = NULL;
}
if (loader->location != NULL)
{
g_object_unref (loader->location);
loader->location = NULL;
}
G_OBJECT_CLASS (gedit_document_loader_parent_class)->dispose (object);
}
......@@ -174,11 +173,11 @@ gedit_document_loader_class_init (GeditDocumentLoaderClass *klass)
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_URI,
g_param_spec_string ("uri",
"URI",
"The URI this GeditDocumentLoader loads the document from",
"",
PROP_LOCATION,
g_param_spec_object ("location",
"LOCATION",
"The LOCATION this GeditDocumentLoader loads the document from",
G_TYPE_FILE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
......@@ -249,11 +248,11 @@ gedit_document_loader_loading (GeditDocumentLoader *loader,
}
/* This is a factory method that returns an appopriate loader
* for the given uri.
* for the given location.
*/
GeditDocumentLoader *
gedit_document_loader_new (GeditDocument *doc,
const gchar *uri,
GFile *location,
const GeditEncoding *encoding)
{
GeditDocumentLoader *loader;
......@@ -268,7 +267,7 @@ gedit_document_loader_new (GeditDocument *doc,
loader = GEDIT_DOCUMENT_LOADER (g_object_new (loader_type,
"document", doc,
"uri", uri,
"location", location,
"encoding", encoding,
NULL));
......@@ -309,12 +308,12 @@ gedit_document_loader_get_document (GeditDocumentLoader *loader)
}
/* Returns STDIN_URI if loading from stdin */
const gchar *
gedit_document_loader_get_uri (GeditDocumentLoader *loader)
GFile *
gedit_document_loader_get_location (GeditDocumentLoader *loader)
{
g_return_val_if_fail (GEDIT_IS_DOCUMENT_LOADER (loader), NULL);
return loader->uri;
return g_file_dup (loader->location);
}
goffset
......
......@@ -63,7 +63,7 @@ struct _GeditDocumentLoader
/* Info on the current file */
GFileInfo *info;
gchar *uri;
GFile *location;
const GeditEncoding *encoding;
const GeditEncoding *auto_detected_encoding;
GeditDocumentNewlineType auto_detected_newline_type;
......@@ -96,7 +96,7 @@ GType gedit_document_loader_get_type (void) G_GNUC_CONST;
/* If enconding == NULL, the encoding will be autodetected */
GeditDocumentLoader *gedit_document_loader_new (GeditDocument *doc,
const gchar *uri,
GFile *location,
const GeditEncoding *encoding);
void gedit_document_loader_loading (GeditDocumentLoader *loader,
......@@ -113,7 +113,7 @@ GeditDocument *gedit_document_loader_get_document (GeditDocumentLoader *loader)
/* Returns STDIN_URI if loading from stdin */
#define STDIN_URI "stdin:"
const gchar *gedit_document_loader_get_uri (GeditDocumentLoader *loader);
GFile *gedit_document_loader_get_location (GeditDocumentLoader *loader);
const GeditEncoding *gedit_document_loader_get_encoding (GeditDocumentLoader *loader);
......
......@@ -61,7 +61,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
enum {
PROP_0,
PROP_DOCUMENT,
PROP_URI,
PROP_LOCATION,
PROP_ENCODING,
PROP_NEWLINE_TYPE,
PROP_FLAGS
......@@ -81,9 +81,9 @@ gedit_document_saver_set_property (GObject *object,
g_return_if_fail (saver->document == NULL);
saver->document = g_value_get_object (value);
break;
case PROP_URI:
g_return_if_fail (saver->uri == NULL);
saver->uri = g_value_dup_string (value);
case PROP_LOCATION:
g_return_if_fail (saver->location == NULL);
saver->location = g_value_dup_object (value);
break;
case PROP_ENCODING:
g_return_if_fail (saver->encoding == NULL);
......@@ -114,8 +114,8 @@ gedit_document_saver_get_property (GObject *object,
case PROP_DOCUMENT:
g_value_set_object (value, saver->document);
break;
case PROP_URI:
g_value_set_string (value, saver->uri);
case PROP_LOCATION:
g_value_set_object (value, saver->location);
break;
case PROP_ENCODING:
g_value_set_boxed (value, saver->encoding);
......@@ -132,16 +132,6 @@ gedit_document_saver_get_property (GObject *object,
}
}
static void
gedit_document_saver_finalize (GObject *object)
{
GeditDocumentSaver *saver = GEDIT_DOCUMENT_SAVER (object);
g_free (saver->uri);
G_OBJECT_CLASS (gedit_document_saver_parent_class)->finalize (object);
}
static void
gedit_document_saver_dispose (GObject *object)
{
......@@ -152,6 +142,12 @@ gedit_document_saver_dispose (GObject *object)
g_object_unref (saver->info);
saver->info = NULL;
}
if (saver->location != NULL)
{
g_object_unref (saver->location);
saver->location = NULL;
}
G_OBJECT_CLASS (gedit_document_saver_parent_class)->dispose (object);
}
......@@ -161,7 +157,6 @@ gedit_document_saver_class_init (GeditDocumentSaverClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gedit_document_saver_finalize;
object_class->dispose = gedit_document_saver_dispose;
object_class->set_property = gedit_document_saver_set_property;
object_class->get_property = gedit_document_saver_get_property;
......@@ -177,11 +172,11 @@ gedit_document_saver_class_init (GeditDocumentSaverClass *klass)
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_URI,
g_param_spec_string ("uri",
"URI",
"The URI this GeditDocumentSaver saves the document to",
"",
PROP_LOCATION,
g_param_spec_object ("location",
"LOCATION",
"The LOCATION this GeditDocumentSaver saves the document to",
G_TYPE_FILE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
......@@ -189,7 +184,7 @@ gedit_document_saver_class_init (GeditDocumentSaverClass *klass)
g_object_class_install_property (object_class,
PROP_ENCODING,
g_param_spec_boxed ("encoding",
"URI",
"ENCODING",
"The encoding of the saved file",
GEDIT_TYPE_ENCODING,
G_PARAM_READWRITE |
......@@ -239,7 +234,7 @@ gedit_document_saver_init (GeditDocumentSaver *saver)
GeditDocumentSaver *
gedit_document_saver_new (GeditDocument *doc,
const gchar *uri,
GFile *location,
const GeditEncoding *encoding,
GeditDocumentNewlineType newline_type,
GeditDocumentSaveFlags flags)
......@@ -256,7 +251,7 @@ gedit_document_saver_new (GeditDocument *doc,
saver = GEDIT_DOCUMENT_SAVER (g_object_new (saver_type,
"document", doc,
"uri", uri,
"location", location,
"encoding", encoding,
"newline_type", newline_type,
"flags", flags,
......@@ -298,15 +293,14 @@ gedit_document_saver_save (GeditDocumentSaver *saver,
gedit_debug (DEBUG_SAVER);
g_return_if_fail (GEDIT_IS_DOCUMENT_SAVER (saver));
g_return_if_fail (saver->uri != NULL && strlen (saver->uri) > 0);
g_return_if_fail (saver->location != NULL);
g_return_if_fail (saver->used == FALSE);
saver->used = TRUE;
// CHECK:
// - sanity check a max len for the uri?
// report async (in an idle handler) or sync (bool ret)
// async is extra work here, sync is special casing in the caller
/* CHECK:
report async (in an idle handler) or sync (bool ret)
async is extra work here, sync is special casing in the caller */
/* never keep backup of autosaves */
if ((saver->flags & GEDIT_DOCUMENT_SAVE_PRESERVE_BACKUP) != 0)
......@@ -325,12 +319,12 @@ gedit_document_saver_get_document (GeditDocumentSaver *saver)
return saver->document;
}
const gchar *
gedit_document_saver_get_uri (GeditDocumentSaver *saver)
GFile *
gedit_document_saver_get_location (GeditDocumentSaver *saver)
{
g_return_val_if_fail (GEDIT_IS_DOCUMENT_SAVER (saver), NULL);
return saver->uri;
return g_file_dup (saver->location);
}
/* Returns 0 if file size is unknown */
......
......@@ -60,7 +60,7 @@ struct _GeditDocumentSaver
GeditDocument *document;
gboolean used;
gchar *uri;
GFile *location;
const GeditEncoding *encoding;
GeditDocumentNewlineType newline_type;
......@@ -97,7 +97,7 @@ GType gedit_document_saver_get_type (void) G_GNUC_CONST;
/* If enconding == NULL, the encoding will be autodetected */
GeditDocumentSaver *gedit_document_saver_new (GeditDocument *doc,
const gchar *uri,
GFile *location,
const GeditEncoding *encoding,
GeditDocumentNewlineType newline_type,
GeditDocumentSaveFlags flags);
......@@ -114,7 +114,7 @@ void gedit_document_saver_cancel (GeditDocumentSaver *saver);
GeditDocument *gedit_document_saver_get_document (GeditDocumentSaver *saver);
const gchar *gedit_document_saver_get_uri (GeditDocumentSaver *saver);
GFile *gedit_document_saver_get_location (GeditDocumentSaver *saver);
/* If backup_uri is NULL no backup will be made */
const gchar *gedit_document_saver_get_backup_uri (GeditDocumentSaver *saver);
......
......@@ -79,12 +79,12 @@ PROFILE (static GTimer *timer = NULL)
#define GEDIT_DOCUMENT_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GEDIT_TYPE_DOCUMENT, GeditDocumentPrivate))
static void gedit_document_load_real (GeditDocument *doc,
const gchar *uri,
GFile *location,
const GeditEncoding *encoding,
gint line_pos,
gboolean create);
static void gedit_document_save_real (GeditDocument *doc,
const gchar *uri,
GFile *location,
const GeditEncoding *encoding,
GeditDocumentSaveFlags flags);
static void to_search_region_range (GeditDocument *doc,
......@@ -101,7 +101,7 @@ static void delete_range_cb (GeditDocument *doc,
struct _GeditDocumentPrivate
{
gchar *uri;
GFile *location;
gint untitled_number;
gchar *short_name;
......@@ -148,7 +148,7 @@ struct _GeditDocumentPrivate
enum {
PROP_0,
PROP_URI,
PROP_LOCATION,
PROP_SHORTNAME,
PROP_CONTENT_TYPE,
PROP_MIME_TYPE,
......@@ -232,7 +232,7 @@ gedit_document_dispose (GObject *object)
* because the language is gone by the time finalize runs.
* beside if some plugin prevents proper finalization by
* holding a ref to the doc, we still save the metadata */
if ((!doc->priv->dispose_has_run) && (doc->priv->uri != NULL))
if ((!doc->priv->dispose_has_run) && (doc->priv->location != NULL))
{
GtkTextIter iter;
gchar *position;
......@@ -280,6 +280,12 @@ gedit_document_dispose (GObject *object)
doc->priv->metadata_info = NULL;
}
if (doc->priv->location != NULL)
{
g_object_unref (doc->priv->location);
doc->priv->location = NULL;
}
doc->priv->dispose_has_run = TRUE;
G_OBJECT_CLASS (gedit_document_parent_class)->dispose (object);
......@@ -294,11 +300,9 @@ gedit_document_finalize (GObject *object)
if (doc->priv->untitled_number > 0)
{
g_return_if_fail (doc->priv->uri == NULL);
release_untitled_number (doc->priv->untitled_number);
}
g_free (doc->priv->uri);
g_free (doc->priv->content_type);
g_free (doc->priv->search_text);
......@@ -321,8 +325,8 @@ gedit_document_get_property (GObject *object,
switch (prop_id)
{
case PROP_URI:
g_value_set_string (value, doc->priv->uri);
case PROP_LOCATION:
g_value_set_object (value, doc->priv->location);
break;
case PROP_SHORTNAME:
g_value_take_string (value, gedit_document_get_short_name_for_display (doc));
......@@ -440,11 +444,11 @@ gedit_document_class_init (GeditDocumentClass *klass)
klass->load = gedit_document_load_real;
klass->save = gedit_document_save_real;
g_object_class_install_property (object_class, PROP_URI,
g_param_spec_string ("uri",
"URI",
"The document's URI",
NULL,
g_object_class_install_property (object_class, PROP_LOCATION,
g_param_spec_object ("location",
"LOCATION",
"The document's location",
G_TYPE_FILE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
......@@ -539,7 +543,7 @@ gedit_document_class_init (GeditDocumentClass *klass)
/**
* GeditDocument::load:
* @document: the #GeditDocument.
* @uri: the uri where to load the document from.
* @location: the location where to load the document from.
* @encoding: the #GeditEncoding to encode the document.
* @line_pos: the line to show.
* @create: whether the document should be created if it doesn't exist.
......@@ -554,10 +558,10 @@ gedit_document_class_init (GeditDocumentClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GeditDocumentClass, load),
NULL, NULL,
gedit_marshal_VOID__STRING_BOXED_INT_BOOLEAN,
gedit_marshal_VOID__OBJECT_BOXED_INT_BOOLEAN,
G_TYPE_NONE,
4,
G_TYPE_STRING,
G_TYPE_FILE,
/* we rely on the fact that the GeditEncoding pointer stays
* the same forever */
GEDIT_TYPE_ENCODING | G_SIGNAL_TYPE_STATIC_SCOPE,
......@@ -591,7 +595,7 @@ gedit_document_class_init (GeditDocumentClass *klass)
/**
* GeditDocument::save:
* @document: the #GeditDocument.
* @uri: the uri where the document is about to be saved.
* @location: the location where the document is about to be saved.
* @encoding: the #GeditEncoding used to save the document.
* @flags: the #GeditDocumentSaveFlags for the save operation.
*
......@@ -605,10 +609,10 @@ gedit_document_class_init (GeditDocumentClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GeditDocumentClass, save),
NULL, NULL,
gedit_marshal_VOID__STRING_BOXED_FLAGS,
gedit_marshal_VOID__OBJECT_BOXED_FLAGS,
G_TYPE_NONE,
3,
G_TYPE_STRING,
G_TYPE_FILE,
/* we rely on the fact that the GeditEncoding pointer stays
* the same forever */
GEDIT_TYPE_ENCODING | G_SIGNAL_TYPE_STATIC_SCOPE,
......@@ -675,7 +679,7 @@ set_language (GeditDocument *doc,
gtk_source_buffer_set_highlight_syntax (GTK_SOURCE_BUFFER (doc),
FALSE);
if (set_by_user && (doc->priv->uri != NULL))
if (set_by_user)
{
gedit_document_set_metadata (doc, GEDIT_METADATA_ATTRIBUTE_LANGUAGE,
(lang == NULL) ? "_NORMAL_" : gtk_source_language_get_id (lang),
......@@ -741,18 +745,18 @@ get_default_style_scheme (void)
}
static void
on_uri_changed (GeditDocument *doc,
GParamSpec *pspec,
gpointer useless)
on_location_changed (GeditDocument *doc,
GParamSpec *pspec,
gpointer useless)
{
#ifdef ENABLE_GVFS_METADATA
GFile *location;
location = gedit_document_get_location (doc);
/* load metadata for this uri: we load sync since metadata is
/* load metadata for this location: we load sync since metadata is
* always local so it should be fast and we need the information
* right after the uri was set.
* right after the location was set.
*/
if (location != NULL)
{
......@@ -808,15 +812,15 @@ guess_language (GeditDocument *doc,
}
else
{
GFile *file;
GFile *location;
gchar *basename = NULL;
file = gedit_document_get_location (doc);
location = gedit_document_get_location (doc);
gedit_debug_message (DEBUG_DOCUMENT, "Sniffing Language");
if (file)
if (location)
{
basename = g_file_get_basename (file);
basename = g_file_get_basename (location);
}
else if (doc->priv->short_name != NULL)
{
......@@ -830,9 +834,9 @@ guess_language (GeditDocument *doc,
g_free (basename);
if (file != NULL)
if (location != NULL)
{
g_object_unref (file);
g_object_unref (location);
}