[Xfce4-commits] r29919 - in thunar/branches/migration-to-gio: . thunar

Jannis Pohlmann jannis at xfce.org
Thu Apr 30 15:04:36 CEST 2009


Author: jannis
Date: 2009-04-30 13:04:36 +0000 (Thu, 30 Apr 2009)
New Revision: 29919

Modified:
   thunar/branches/migration-to-gio/ChangeLog
   thunar/branches/migration-to-gio/thunar/thunar-file.c
   thunar/branches/migration-to-gio/thunar/thunar-file.h
   thunar/branches/migration-to-gio/thunar/thunar-location-entry.c
   thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c
Log:
	* thunar/thunar-file.{c,h}, thunar/thunar-properties-dialog.c:
	  Re-implement thunar_file_get_volume() around
	  g_file_find_enclosing_mount(). Ideally this would be asynchronous
	  but for now it'll stay the old way. Remove the
	  ThunarVfsVolumeManager member from the properties dialog. We only
	  need thunar_file_get_volume() here now.

Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog	2009-04-30 06:50:14 UTC (rev 29918)
+++ thunar/branches/migration-to-gio/ChangeLog	2009-04-30 13:04:36 UTC (rev 29919)
@@ -1,5 +1,14 @@
 2009-04-30	Jannis Pohlmann <jannis at xfce.org>
 
+	* thunar/thunar-file.{c,h}, thunar/thunar-properties-dialog.c:
+	  Re-implement thunar_file_get_volume() around
+	  g_file_find_enclosing_mount(). Ideally this would be asynchronous
+	  but for now it'll stay the old way. Remove the
+	  ThunarVfsVolumeManager member from the properties dialog. We only
+	  need thunar_file_get_volume() here now.
+
+2009-04-30	Jannis Pohlmann <jannis at xfce.org>
+
 	* thunar/thunar-application.c: Replace "hal-udi" with
 	  G_VOLUME_IDENTIFIER_KIND_HAL_UDI. 
 	* thunar/thunar-gio-extensions.c: Change g_volume_is_removable() so

Modified: thunar/branches/migration-to-gio/thunar/thunar-file.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.c	2009-04-30 06:50:14 UTC (rev 29918)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.c	2009-04-30 13:04:36 UTC (rev 29919)
@@ -1414,23 +1414,30 @@
 /**
  * thunar_file_get_volume:
  * @file           : a #ThunarFile instance.
- * @volume_manager : the #ThunarVfsVolumeManager to use for the volume lookup.
  *
- * Attempts to determine the #ThunarVfsVolume on which @file is located
- * using the given @volume_manager. If @file cannot determine it's volume,
- * then %NULL will be returned. Else a #ThunarVfsVolume instance is returned,
- * which is owned by @volume_manager and thereby the caller must not free
- * the returned object.
+ * Attempts to determine the #GVolume on which @file is located. If @file cannot 
+ * determine it's volume, then %NULL will be returned. Else a #GVolume instance 
+ * is returned which has to be released by the caller using g_object_unref().
  *
- * Return value: the #ThunarVfsVolume for @file in @volume_manager or %NULL.
+ * Return value: the #GVolume for @file or %NULL.
  **/
-ThunarVfsVolume*
-thunar_file_get_volume (const ThunarFile       *file,
-                        ThunarVfsVolumeManager *volume_manager)
+GVolume*
+thunar_file_get_volume (const ThunarFile *file)
 {
+  GVolume *volume = NULL;
+  GMount  *mount;
+
   _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
-  _thunar_return_val_if_fail (THUNAR_VFS_IS_VOLUME_MANAGER (volume_manager), NULL);
-  return thunar_vfs_volume_manager_get_volume_by_info (volume_manager, file->info);
+
+  /* TODO make this function call asynchronous */
+  mount = g_file_find_enclosing_mount (file->gfile, NULL, NULL);
+  if (mount != NULL)
+    {
+      volume = g_mount_get_volume (mount);
+      g_object_unref (mount);
+    }
+
+  return volume;
 }
 
 

Modified: thunar/branches/migration-to-gio/thunar/thunar-file.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.h	2009-04-30 06:50:14 UTC (rev 29918)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.h	2009-04-30 13:04:36 UTC (rev 29919)
@@ -165,8 +165,7 @@
 gchar            *thunar_file_get_mode_string      (const ThunarFile       *file) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 gchar            *thunar_file_get_size_string      (const ThunarFile       *file) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
-ThunarVfsVolume  *thunar_file_get_volume           (const ThunarFile       *file,
-                                                    ThunarVfsVolumeManager *volume_manager);
+GVolume          *thunar_file_get_volume           (const ThunarFile       *file);
 
 ThunarGroup      *thunar_file_get_group            (const ThunarFile       *file);
 ThunarUser       *thunar_file_get_user             (const ThunarFile       *file);

Modified: thunar/branches/migration-to-gio/thunar/thunar-location-entry.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-location-entry.c	2009-04-30 06:50:14 UTC (rev 29918)
+++ thunar/branches/migration-to-gio/thunar/thunar-location-entry.c	2009-04-30 13:04:36 UTC (rev 29919)
@@ -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

Modified: thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c	2009-04-30 06:50:14 UTC (rev 29918)
+++ thunar/branches/migration-to-gio/thunar/thunar-properties-dialog.c	2009-04-30 13:04:36 UTC (rev 29919)
@@ -111,7 +111,6 @@
 
   ThunarPreferences      *preferences;
 
-  ThunarVfsVolumeManager *volume_manager;
   ThunarFile             *file;
 
   GtkWidget              *notebook;
@@ -243,7 +242,6 @@
                             G_CALLBACK (thunar_properties_dialog_reload), dialog);
 
   dialog->provider_factory = thunarx_provider_factory_get_default ();
-  dialog->volume_manager = thunar_vfs_volume_manager_get_default ();
 
   gtk_dialog_add_buttons (GTK_DIALOG (dialog),
                           GTK_STOCK_HELP, GTK_RESPONSE_HELP,
@@ -545,19 +543,16 @@
   ThunarPropertiesDialog *dialog = THUNAR_PROPERTIES_DIALOG (object);
 
   /* disconnect from the preferences */
-  g_signal_handlers_disconnect_by_func (G_OBJECT (dialog->preferences), thunar_properties_dialog_reload, dialog);
-  g_object_unref (G_OBJECT (dialog->preferences));
+  g_signal_handlers_disconnect_by_func (dialog->preferences, thunar_properties_dialog_reload, dialog);
+  g_object_unref (dialog->preferences);
 
   /* release the provider property pages */
   g_list_foreach (dialog->provider_pages, (GFunc) g_object_unref, NULL);
   g_list_free (dialog->provider_pages);
 
   /* drop the reference on the provider factory */
-  g_object_unref (G_OBJECT (dialog->provider_factory));
+  g_object_unref (dialog->provider_factory);
 
-  /* drop the reference on the volume manager */
-  g_object_unref (G_OBJECT (dialog->volume_manager));
-
   /* be sure to cancel any pending rename idle source */
   if (G_UNLIKELY (dialog->rename_idle_id != 0))
     g_source_remove (dialog->rename_idle_id);
@@ -785,19 +780,20 @@
 {
   ThunarIconFactory *icon_factory;
   ThunarDateStyle    date_style;
-  ThunarVfsVolume   *volume;
   GtkIconTheme      *icon_theme;
   const gchar       *content_type;
-  const gchar       *icon_name;
   const gchar       *name;
   const gchar       *path;
   GdkPixbuf         *icon;
+  GVolume           *volume;
   guint64            size;
+  GIcon             *gicon;
   glong              offset;
+  gchar             *date;
   gchar             *display_name;
   gchar             *size_string;
   gchar             *str;
-  gchar             *date;
+  gchar             *volume_name;
 
   _thunar_return_if_fail (THUNAR_IS_PROPERTIES_DIALOG (dialog));
   _thunar_return_if_fail (THUNAR_IS_FILE (dialog->file));
@@ -957,18 +953,18 @@
     }
 
   /* update the volume */
-  volume = thunar_file_is_local (dialog->file) ? thunar_file_get_volume (dialog->file, dialog->volume_manager) : NULL;
+  volume = thunar_file_get_volume (dialog->file);
   if (G_LIKELY (volume != NULL))
     {
-      icon_name = thunar_vfs_volume_lookup_icon_name (volume, icon_theme);
-      icon = thunar_icon_factory_load_icon (icon_factory, icon_name, 16, NULL, FALSE);
-      gtk_image_set_from_pixbuf (GTK_IMAGE (dialog->volume_image), icon);
-      if (G_LIKELY (icon != NULL))
-        g_object_unref (G_OBJECT (icon));
+      gicon = g_volume_get_icon (volume);
+      gtk_image_set_from_gicon (GTK_IMAGE (dialog->volume_image), gicon, GTK_ICON_SIZE_MENU);
+      if (G_LIKELY (gicon != NULL))
+        g_object_unref (gicon);
 
-      name = thunar_vfs_volume_get_name (volume);
-      gtk_label_set_text (GTK_LABEL (dialog->volume_label), name);
+      volume_name = g_volume_get_name (volume);
+      gtk_label_set_text (GTK_LABEL (dialog->volume_label), volume_name);
       gtk_widget_show (dialog->volume_label);
+      g_free (volume_name);
     }
   else
     {




More information about the Xfce4-commits mailing list