Git Repositories

2005-09-06 Benedikt Meurer <benny@xfce.org>
authorBenedikt Meurer <benny@xfce.org>
Tue, 6 Sep 2005 16:06:40 +0000 (16:06 +0000)
committerBenedikt Meurer <benny@xfce.org>
Tue, 6 Sep 2005 16:06:40 +0000 (16:06 +0000)
* 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)

ChangeLog
Makefile.am
configure.in.in
icons/24x24/Makefile.am [new file with mode: 0644]
icons/24x24/Thunar.png [new file with mode: 0644]
icons/48x48/Makefile.am [new file with mode: 0644]
icons/48x48/Thunar.png [new file with mode: 0644]
icons/Makefile.am [new file with mode: 0644]
thunar/thunar-list-model.c
thunar/thunar-local-file.c

index 62cf740..1dacafd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 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
          that will be required for language bindings once we have weak/toggle
          references for ExoObject.
index 5ac96bd..8f0b329 100644 (file)
@@ -2,6 +2,7 @@
 
 SUBDIRS =                                                              \
        docs                                                            \
+       icons                                                           \
        pixmaps                                                         \
        po                                                              \
        thunar-vfs                                                      \
index 1bc372e..809b17c 100644 (file)
@@ -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
diff --git a/icons/24x24/Makefile.am b/icons/24x24/Makefile.am
new file mode 100644 (file)
index 0000000..3c6cf97
--- /dev/null
@@ -0,0 +1,10 @@
+# $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:
diff --git a/icons/24x24/Thunar.png b/icons/24x24/Thunar.png
new file mode 100644 (file)
index 0000000..de5f313
Binary files /dev/null and b/icons/24x24/Thunar.png differ
diff --git a/icons/48x48/Makefile.am b/icons/48x48/Makefile.am
new file mode 100644 (file)
index 0000000..0445160
--- /dev/null
@@ -0,0 +1,10 @@
+# $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:
diff --git a/icons/48x48/Thunar.png b/icons/48x48/Thunar.png
new file mode 100644 (file)
index 0000000..367a373
Binary files /dev/null and b/icons/48x48/Thunar.png differ
diff --git a/icons/Makefile.am b/icons/Makefile.am
new file mode 100644 (file)
index 0000000..4f736ce
--- /dev/null
@@ -0,0 +1,7 @@
+# $Id$
+
+SUBDIRS =                                                              \
+       24x24                                                           \
+       48x48
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
index 8efaf40..3d08df3 100644 (file)
@@ -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;
index 15ddf18..601c0bc 100644 (file)
@@ -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.