Commit c6b279a1 authored by Benedikt Meurer's avatar Benedikt Meurer

2005-09-06 Benedikt Meurer <benny@xfce.org>

	* thunar/thunar-local-file.c: Store the VFS monitor handle in the
	  GObject dataset as it's used only for explicit file monitoring (e.g.
	  for the properties dialog).
	* thunar/thunar-list-model.c(thunar_list_model_get_iter): Skip every
	  second comparison for iter lookups.
	* icons/, configure.in.in, Makefile.am: Add the Thunar icon.




(Old svn revision: 17401)
parent c5a3c59f
2005-09-06 Benedikt Meurer <benny@xfce.org>
* thunar/thunar-local-file.c: Store the VFS monitor handle in the
GObject dataset as it's used only for explicit file monitoring (e.g.
for the properties dialog).
* thunar/thunar-list-model.c(thunar_list_model_get_iter): Skip every
second comparison for iter lookups.
* icons/, configure.in.in, Makefile.am: Add the Thunar icon.
2005-09-06 Benedikt Meurer <benny@xfce.org>
* thunar-vfs/thunar-vfs-uri.c: Invoke the parent's finalize method, as
......
......@@ -2,6 +2,7 @@
SUBDIRS = \
docs \
icons \
pixmaps \
po \
thunar-vfs \
......
......@@ -251,6 +251,9 @@ Makefile
docs/Makefile
docs/design/Makefile
docs/papers/Makefile
icons/Makefile
icons/24x24/Makefile
icons/48x48/Makefile
po/Makefile.in
pixmaps/Makefile
tests/Makefile
......
# $Id$
iconsdir = $(datadir)/icons/hicolor/24x24/apps
icons_DATA = \
Thunar.png
EXTRA_DIST = \
$(icons_DATA)
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
# $Id$
iconsdir = $(datadir)/icons/hicolor/48x48/apps
icons_DATA = \
Thunar.png
EXTRA_DIST = \
$(icons_DATA)
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
# $Id$
SUBDIRS = \
24x24 \
48x48
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
......@@ -509,8 +509,13 @@ thunar_list_model_get_iter (GtkTreeModel *model,
if (G_UNLIKELY (index >= store->nrows))
return FALSE;
for (n = 0, row = store->rows; n < index; ++n, row = row->next)
g_assert (row != NULL);
/* use fast-forward, skipping every second comparison */
for (n = index / 2, row = store->rows; n-- > 0; row = row->next->next)
;
/* advance for odd indices */
if ((index % 2) == 1)
row = row->next;
iter->stamp = store->stamp;
iter->user_data = row;
......
......@@ -79,6 +79,7 @@ static void thunar_local_file_monitor (ThunarVfsMonitor
ThunarVfsURI *handle_uri,
ThunarVfsURI *event_uri,
gpointer user_data);
static void thunar_local_file_watch_free (gpointer data);
......@@ -93,15 +94,14 @@ struct _ThunarLocalFile
{
ThunarFile __parent__;
ThunarVfsInfo *info;
ThunarVfsMonitorHandle *handle;
ThunarVfsInfo *info;
};
static ThunarVfsMonitor *monitor = NULL;
static GObjectClass *thunar_local_file_parent_class;
static GQuark thunar_local_file_watch_quark;
......@@ -142,6 +142,9 @@ thunar_local_file_class_init (ThunarLocalFileClass *klass)
ThunarFileClass *thunarfile_class;
GObjectClass *gobject_class;
/* query the thunar-local-file-watch quark */
thunar_local_file_watch_quark = g_quark_from_static_string ("thunar-local-file-watch");
/* query the parent class */
thunar_local_file_parent_class = g_type_class_peek_parent (klass);
......@@ -185,7 +188,7 @@ thunar_local_file_finalize (GObject *object)
ThunarLocalFile *local_file = THUNAR_LOCAL_FILE (object);
#ifndef G_DISABLE_CHECKS
if (G_UNLIKELY (local_file->handle != NULL))
if (G_UNLIKELY (g_object_get_qdata (object, thunar_local_file_watch_quark) != NULL))
{
g_error ("Attempt to finalize a ThunarLocalFile, which "
"is still being watched for changes");
......@@ -196,7 +199,7 @@ thunar_local_file_finalize (GObject *object)
if (G_LIKELY (local_file->info != NULL))
thunar_vfs_info_unref (local_file->info);
G_OBJECT_CLASS (thunar_local_file_parent_class)->finalize (object);
(*G_OBJECT_CLASS (thunar_local_file_parent_class)->finalize) (object);
}
......@@ -260,13 +263,13 @@ thunar_local_file_rename (ThunarFile *file,
if (G_LIKELY (succeed))
{
/* need to re-register the monitor handle for the new uri */
if (G_LIKELY (local_file->handle != NULL))
if (g_object_get_qdata (G_OBJECT (file), thunar_local_file_watch_quark) != NULL)
{
/* drop the previous handle (with the old URI) */
thunar_vfs_monitor_remove (monitor, local_file->handle);
thunar_local_file_unwatch (file);
/* register the new handle (with the new URI) */
local_file->handle = thunar_vfs_monitor_add_file (monitor, local_file->info->uri, thunar_local_file_monitor, local_file);
thunar_local_file_watch (file);
}
/* perform the rename on the file cache */
......@@ -556,9 +559,7 @@ thunar_local_file_get_icon_name (ThunarFile *file,
static void
thunar_local_file_watch (ThunarFile *file)
{
ThunarLocalFile *local_file = THUNAR_LOCAL_FILE (file);
g_return_if_fail (local_file->handle == NULL);
ThunarVfsMonitorHandle *handle;
/* take a reference on the VFS monitor for this instance */
if (G_UNLIKELY (monitor == NULL))
......@@ -572,7 +573,8 @@ thunar_local_file_watch (ThunarFile *file)
}
/* add us to the file monitor */
local_file->handle = thunar_vfs_monitor_add_file (monitor, local_file->info->uri, thunar_local_file_monitor, local_file);
handle = thunar_vfs_monitor_add_file (monitor, THUNAR_LOCAL_FILE (file)->info->uri, thunar_local_file_monitor, file);
g_object_set_qdata_full (G_OBJECT (file), thunar_local_file_watch_quark, handle, thunar_local_file_watch_free);
}
......@@ -580,16 +582,8 @@ thunar_local_file_watch (ThunarFile *file)
static void
thunar_local_file_unwatch (ThunarFile *file)
{
ThunarLocalFile *local_file = THUNAR_LOCAL_FILE (file);
g_return_if_fail (local_file->handle != NULL);
/* remove our VFS info from the monitor */
thunar_vfs_monitor_remove (monitor, local_file->handle);
local_file->handle = NULL;
/* release our reference on the VFS monitor */
g_object_unref (G_OBJECT (monitor));
/* just unset the watch handle */
g_object_set_qdata (G_OBJECT (file), thunar_local_file_watch_quark, NULL);
}
......@@ -634,7 +628,6 @@ thunar_local_file_monitor (ThunarVfsMonitor *monitor,
g_return_if_fail (THUNAR_VFS_IS_URI (handle_uri));
g_return_if_fail (THUNAR_VFS_IS_URI (event_uri));
g_return_if_fail (THUNAR_IS_LOCAL_FILE (local_file));
g_return_if_fail (local_file->handle == handle);
g_return_if_fail (thunar_vfs_uri_equal (local_file->info->uri, handle_uri));
/* just to be sure... */
......@@ -656,6 +649,18 @@ thunar_local_file_monitor (ThunarVfsMonitor *monitor,
static void
thunar_local_file_watch_free (gpointer data)
{
/* remove the watch from the VFS monitor */
thunar_vfs_monitor_remove (monitor, data);
/* release our reference on the VFS monitor */
g_object_unref (G_OBJECT (monitor));
}
/**
* thunar_local_file_new:
* @uri : the #ThunarVfsURI referrring to the local file.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment