[gvfs] [gdu] Stop assuming that drives have no enclosing presentable



commit c1994adbc67be47838d2a20bf1c6420d521cf5d7
Author: David Zeuthen <davidz redhat com>
Date:   Tue Dec 8 13:15:52 2009 -0500

    [gdu] Stop assuming that drives have no enclosing presentable
    
    This makes the gdu volume monitor works with recent gnome-disk-utility
    versions with things like GduHub presentables that represents HBAs and
    Expanders. This will not affect previous gnome-disk-utility versions.
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 monitor/gdu/ggduvolume.c        |   16 +++++++-
 monitor/gdu/ggduvolumemonitor.c |   78 +++++++++++++++++++++++++-------------
 2 files changed, 66 insertions(+), 28 deletions(-)
---
diff --git a/monitor/gdu/ggduvolume.c b/monitor/gdu/ggduvolume.c
index 28839fd..be324c9 100644
--- a/monitor/gdu/ggduvolume.c
+++ b/monitor/gdu/ggduvolume.c
@@ -988,7 +988,21 @@ mount_with_mount_operation (MountOpData *data)
 
   device = gdu_presentable_get_device (GDU_PRESENTABLE (data->volume->gdu_volume));
 
-  toplevel = gdu_presentable_get_toplevel (GDU_PRESENTABLE (data->volume->gdu_volume));
+  toplevel = gdu_presentable_get_enclosing_presentable (GDU_PRESENTABLE (data->volume->gdu_volume));
+  /* handle logical partitions enclosed by an extented partition */
+  if (GDU_IS_VOLUME (toplevel))
+    {
+      GduPresentable *temp;
+      temp = toplevel;
+      toplevel = gdu_presentable_get_enclosing_presentable (toplevel);
+      g_object_unref (temp);
+      if (!GDU_IS_DRIVE (toplevel))
+        {
+          g_object_unref (toplevel);
+          toplevel = NULL;
+        }
+    }
+
   if (toplevel != NULL)
     drive_name = gdu_presentable_get_name (toplevel);
 
diff --git a/monitor/gdu/ggduvolumemonitor.c b/monitor/gdu/ggduvolumemonitor.c
index 398fed4..c5b58a0 100644
--- a/monitor/gdu/ggduvolumemonitor.c
+++ b/monitor/gdu/ggduvolumemonitor.c
@@ -1298,24 +1298,36 @@ update_volumes (GGduVolumeMonitor *monitor,
 
       if (volume == NULL)
         {
-          GduPresentable *toplevel_presentable;
+          GduPresentable *toplevel_drive;
 
-          toplevel_presentable = gdu_presentable_get_toplevel (p);
-          if (toplevel_presentable != NULL)
+          toplevel_drive = gdu_presentable_get_enclosing_presentable (p);
+          /* handle logical partitions enclosed by an extented partition */
+          if (GDU_IS_VOLUME (toplevel_drive))
             {
-              GduDevice *toplevel_device;
+              GduPresentable *temp;
+              temp = toplevel_drive;
+              toplevel_drive = gdu_presentable_get_enclosing_presentable (toplevel_drive);
+              g_object_unref (temp);
+            }
 
-              drive = NULL;
-              toplevel_device = gdu_presentable_get_device (toplevel_presentable);
-              if (toplevel_device != NULL)
+          if (toplevel_drive != NULL)
+            {
+              if (GDU_IS_DRIVE (toplevel_drive))
                 {
-                  drive = find_drive_by_device_file (monitor, gdu_device_get_device_file (toplevel_device));
-                  /*g_debug ("adding volume %s (drive %s)",
-                           gdu_device_get_device_file (d),
-                           gdu_device_get_device_file (toplevel_device));*/
-                  g_object_unref (toplevel_device);
+                  GduDevice *toplevel_drive_device;
+
+                  drive = NULL;
+                  toplevel_drive_device = gdu_presentable_get_device (toplevel_drive);
+                  if (toplevel_drive_device != NULL)
+                    {
+                      drive = find_drive_by_device_file (monitor, gdu_device_get_device_file (toplevel_drive_device));
+                      /*g_debug ("adding volume %s (drive %s)",
+                        gdu_device_get_device_file (d),
+                        gdu_device_get_device_file (toplevel_device));*/
+                      g_object_unref (toplevel_drive_device);
+                    }
                 }
-              g_object_unref (toplevel_presentable);
+              g_object_unref (toplevel_drive);
             }
           else
             {
@@ -1512,7 +1524,7 @@ update_mounts (GGduVolumeMonitor *monitor,
       if (volume == NULL)
         volume = find_volume_for_mount_path (monitor, mount_path);
 
-      /*g_debug ("adding mount %s (vol %p)", g_unix_mount_get_device_path (mount_entry), volume);*/
+      /*g_debug ("adding mount %s (vol %p) (device %s, mount_path %s)", g_unix_mount_get_device_path (mount_entry), volume, device_file, mount_path);*/
       mount = g_gdu_mount_new (G_VOLUME_MONITOR (monitor), mount_entry, volume);
       if (mount)
         {
@@ -1640,24 +1652,36 @@ update_discs (GGduVolumeMonitor *monitor,
 
       if (volume == NULL)
         {
-          GduPresentable *toplevel_presentable;
+          GduPresentable *toplevel_drive;
 
-          toplevel_presentable = gdu_presentable_get_toplevel (p);
-          if (toplevel_presentable != NULL)
+          toplevel_drive = gdu_presentable_get_enclosing_presentable (p);
+          /* handle logical partitions enclosed by an extented partition */
+          if (GDU_IS_VOLUME (toplevel_drive))
             {
-              GduDevice *toplevel_device;
+              GduPresentable *temp;
+              temp = toplevel_drive;
+              toplevel_drive = gdu_presentable_get_enclosing_presentable (toplevel_drive);
+              g_object_unref (temp);
+            }
 
-              drive = NULL;
-              toplevel_device = gdu_presentable_get_device (toplevel_presentable);
-              if (toplevel_device != NULL)
+          if (toplevel_drive != NULL)
+            {
+              if (GDU_IS_DRIVE (toplevel_drive))
                 {
-                  drive = find_drive_by_device_file (monitor, gdu_device_get_device_file (toplevel_device));
-                  /*g_debug ("adding volume %s (drive %s)",
-                           gdu_device_get_device_file (d),
-                           gdu_device_get_device_file (toplevel_device));*/
-                  g_object_unref (toplevel_device);
+                  GduDevice *toplevel_drive_device;
+
+                  drive = NULL;
+                  toplevel_drive_device = gdu_presentable_get_device (toplevel_drive);
+                  if (toplevel_drive_device != NULL)
+                    {
+                      drive = find_drive_by_device_file (monitor, gdu_device_get_device_file (toplevel_drive_device));
+                      /*g_debug ("adding volume %s (drive %s)",
+                        gdu_device_get_device_file (d),
+                        gdu_device_get_device_file (toplevel_device));*/
+                      g_object_unref (toplevel_drive_device);
+                    }
                 }
-              g_object_unref (toplevel_presentable);
+              g_object_unref (toplevel_drive);
             }
           else
             {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]