[Xfce4-commits] r29770 - in thunar/branches/migration-to-gio: . thunar
Jannis Pohlmann
jannis at xfce.org
Sat Apr 11 23:42:51 CEST 2009
Author: jannis
Date: 2009-04-11 21:42:51 +0000 (Sat, 11 Apr 2009)
New Revision: 29770
Modified:
thunar/branches/migration-to-gio/ChangeLog
thunar/branches/migration-to-gio/thunar/thunar-file.c
thunar/branches/migration-to-gio/thunar/thunar-metafile.c
thunar/branches/migration-to-gio/thunar/thunar-metafile.h
thunar/branches/migration-to-gio/thunar/thunar-tree-model.c
Log:
* thunar/thunar-file.c, thunar/thunar-metafile.{c,h}: Migrate
ThunarMetadata to GIO. Update ThunarFile to pass the GFile instead
of ThunarVfsPath to thunar_metafile_fetch() and
thunar_metafile_store().
* thunar/thunar-tree-model.c: Re-implement thunar_tree_model_init()
based on GFile. Unfortunately this breaks the trash (again) and thus
the whole tree view.
Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog 2009-04-11 21:07:38 UTC (rev 29769)
+++ thunar/branches/migration-to-gio/ChangeLog 2009-04-11 21:42:51 UTC (rev 29770)
@@ -1,5 +1,15 @@
2009-04-11 Jannis Pohlmann <jannis at xfce.org>
+ * thunar/thunar-file.c, thunar/thunar-metafile.{c,h}: Migrate
+ ThunarMetadata to GIO. Update ThunarFile to pass the GFile instead
+ of ThunarVfsPath to thunar_metafile_fetch() and
+ thunar_metafile_store().
+ * thunar/thunar-tree-model.c: Re-implement thunar_tree_model_init()
+ based on GFile. Unfortunately this breaks the trash (again) and thus
+ the whole tree view.
+
+2009-04-11 Jannis Pohlmann <jannis at xfce.org>
+
* thunar/thunar-trash-action.c: Replace all ThunarVfsPath references
with GFile.
Modified: thunar/branches/migration-to-gio/thunar/thunar-file.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.c 2009-04-11 21:07:38 UTC (rev 29769)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.c 2009-04-11 21:42:51 UTC (rev 29770)
@@ -1859,7 +1859,7 @@
_thunar_return_val_if_fail (key < THUNAR_METAFILE_N_KEYS, NULL);
return thunar_metafile_fetch (thunar_file_get_metafile (file),
- file->info->path, key,
+ file->gfile, key,
default_value);
}
@@ -1887,7 +1887,7 @@
_thunar_return_if_fail (value != NULL);
thunar_metafile_store (thunar_file_get_metafile (file),
- file->info->path, key, value,
+ file->gfile, key, value,
default_value);
}
Modified: thunar/branches/migration-to-gio/thunar/thunar-metafile.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-metafile.c 2009-04-11 21:07:38 UTC (rev 29769)
+++ thunar/branches/migration-to-gio/thunar/thunar-metafile.c 2009-04-11 21:42:51 UTC (rev 29770)
@@ -1,6 +1,7 @@
/* $Id$ */
/*-
* Copyright (c) 2005-2006 Benedikt Meurer <benny at xfce.org>
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -221,7 +222,7 @@
/**
* thunar_metafile_fetch:
* @metafile : a #ThunarMetafile.
- * @path : a #ThunarVfsPath.
+ * @file : a #Gfile.
* @key : a #ThunarMetafileKey.
* @default_value : the default value for @key,
* which may be %NULL.
@@ -246,7 +247,7 @@
**/
const gchar*
thunar_metafile_fetch (ThunarMetafile *metafile,
- ThunarVfsPath *path,
+ GFile *file,
ThunarMetafileKey key,
const gchar *default_value)
{
@@ -254,20 +255,20 @@
const guchar *dp;
TDB_DATA key_data;
gssize key_size;
- gchar key_path[THUNAR_VFS_PATH_MAXSTRLEN];
+ gchar *key_path = NULL;
_thunar_return_val_if_fail (THUNAR_IS_METAFILE (metafile), NULL);
+ _thunar_return_val_if_fail (G_IS_FILE (file), NULL);
_thunar_return_val_if_fail (key < THUNAR_METAFILE_N_KEYS, NULL);
- _thunar_return_val_if_fail (path != NULL, NULL);
/* check if the database handle is available */
if (G_UNLIKELY (metafile->context == NULL))
goto use_default_value;
/* determine the string representation of the path (using the URI for non-local paths) */
- key_size = (thunar_vfs_path_get_scheme (path) == THUNAR_VFS_PATH_SCHEME_FILE)
- ? thunar_vfs_path_to_string (path, key_path, sizeof (key_path), NULL)
- : thunar_vfs_path_to_uri (path, key_path, sizeof (key_path), NULL);
+ key_path = g_file_get_uri (file);
+ key_size = strlen (key_path);
+
if (G_UNLIKELY (key_size <= 0))
goto use_default_value;
@@ -291,7 +292,10 @@
{
/* check if we have a match */
if (*dp == (guint) key)
- return (const gchar *) (dp + 1);
+ {
+ g_free (key_path);
+ return (const gchar *) (dp + 1);
+ }
/* lookup the next entry */
do
@@ -306,6 +310,7 @@
/* use the default value */
use_default_value:
+ g_free (key_path);
return default_value;
}
@@ -314,7 +319,7 @@
/**
* thunar_metafile_store:
* @metafile : a #ThunarMetafile.
- * @path : a #ThunarVfsPath.
+ * @file : a #GFile.
* @key : a #ThunarMetafileKey.
* @value : the new value for @key on @path.
* @default_value : the default value for @key on @path.
@@ -332,7 +337,7 @@
**/
void
thunar_metafile_store (ThunarMetafile *metafile,
- ThunarVfsPath *path,
+ GFile *file,
ThunarMetafileKey key,
const gchar *value,
const gchar *default_value)
@@ -343,22 +348,22 @@
gssize key_size;
gchar *buffer;
gchar *bp;
- gchar key_path[THUNAR_VFS_PATH_MAXSTRLEN];
+ gchar *key_path;
_thunar_return_if_fail (THUNAR_IS_METAFILE (metafile));
+ _thunar_return_if_fail (G_IS_FILE (file));
_thunar_return_if_fail (key < THUNAR_METAFILE_N_KEYS);
+ _thunar_return_if_fail (value != NULL);
_thunar_return_if_fail (default_value != NULL);
- _thunar_return_if_fail (value != NULL);
- _thunar_return_if_fail (path != NULL);
/* check if the database handle is available */
if (G_UNLIKELY (metafile->context == NULL))
return;
- /* determine the string representation of the path (using the URI for non-local paths) */
- key_size = (thunar_vfs_path_get_scheme (path) == THUNAR_VFS_PATH_SCHEME_FILE)
- ? thunar_vfs_path_to_string (path, key_path, sizeof (key_path), NULL)
- : thunar_vfs_path_to_uri (path, key_path, sizeof (key_path), NULL);
+ /* determine the string representation of the file */
+ key_path = g_file_get_uri (file);
+ key_size = strlen (key_path);
+
if (G_UNLIKELY (key_size <= 0))
return;
@@ -440,6 +445,9 @@
tdb_store (metafile->context, key_data, value_data, TDB_REPLACE);
}
+ /* free the file URI */
+ g_free (key_path);
+
/* free the buffer space */
g_free (buffer);
}
Modified: thunar/branches/migration-to-gio/thunar/thunar-metafile.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-metafile.h 2009-04-11 21:07:38 UTC (rev 29769)
+++ thunar/branches/migration-to-gio/thunar/thunar-metafile.h 2009-04-11 21:42:51 UTC (rev 29770)
@@ -1,6 +1,7 @@
/* $Id$ */
/*-
* Copyright (c) 2005 Benedikt Meurer <benny at xfce.org>
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -49,12 +50,12 @@
ThunarMetafile *thunar_metafile_get_default (void);
const gchar *thunar_metafile_fetch (ThunarMetafile *metafile,
- ThunarVfsPath *path,
+ GFile *file,
ThunarMetafileKey key,
const gchar *default_value);
void thunar_metafile_store (ThunarMetafile *metafile,
- ThunarVfsPath *path,
+ GFile *file,
ThunarMetafileKey key,
const gchar *value,
const gchar *default_value);
Modified: thunar/branches/migration-to-gio/thunar/thunar-tree-model.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-tree-model.c 2009-04-11 21:07:38 UTC (rev 29769)
+++ thunar/branches/migration-to-gio/thunar/thunar-tree-model.c 2009-04-11 21:42:51 UTC (rev 29770)
@@ -1,6 +1,7 @@
/* $Id$ */
/*-
* Copyright (c) 2006 Benedikt Meurer <benny at xfce.org>.
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -314,8 +315,12 @@
thunar_tree_model_init (ThunarTreeModel *model)
{
ThunarTreeModelItem *item;
- ThunarVfsPath *system_path_list[3] = { thunar_vfs_path_get_for_home (), thunar_vfs_path_get_for_trash (), thunar_vfs_path_get_for_root () };
ThunarFile *file;
+ GFile *system_path_list[3] = {
+ g_file_new_for_home (),
+ g_file_new_for_trash (),
+ g_file_new_for_root ()
+ };
GList *volumes;
GNode *node;
guint n;
@@ -348,7 +353,7 @@
for (n = 0; n < G_N_ELEMENTS (system_path_list); ++n)
{
/* determine the file for the path */
- file = thunar_file_get_for_path (system_path_list[n], NULL);
+ file = thunar_file_get (system_path_list[n], NULL);
if (G_LIKELY (file != NULL))
{
/* watch the trash bin for changes */
@@ -365,7 +370,7 @@
}
/* release the system defined path */
- thunar_vfs_path_unref (system_path_list[n]);
+ g_object_unref (system_path_list[n]);
}
/* setup the initial volumes */
More information about the Xfce4-commits
mailing list