[gnome-disk-utility] Always show upper section, even for loop and fake block devices



commit 2087030243a9de6a41717c21de98a16ffa05fc68
Author: David Zeuthen <zeuthen gmail com>
Date:   Fri Oct 5 18:01:42 2012 -0400

    Always show upper section, even for loop and fake block devices
    
    This makes it easier to work with such devices if they are partitioned
    - in particular, it allows imaging (creating, restoreing images) and
    creating partition tables.
    
    Also move the loop-specific stuff to upper section since it concerns
    the whole disk and not just a partition.
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 data/ui/disks.ui      |  238 ++++++++++++++++++++++++------------------------
 src/disks/gduwindow.c |  199 ++++++++++++++++++++++++++++++++++++-----
 2 files changed, 296 insertions(+), 141 deletions(-)
---
diff --git a/data/ui/disks.ui b/data/ui/disks.ui
index 7ccabee..32753ef 100644
--- a/data/ui/disks.ui
+++ b/data/ui/disks.ui
@@ -253,7 +253,7 @@
                   <object class="GtkTable" id="devtab-drive-table">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="n_rows">12</property>
+                    <property name="n_rows">14</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">10</property>
                     <child>
@@ -304,8 +304,8 @@
                         </style>
                       </object>
                       <packing>
-                        <property name="top_attach">7</property>
-                        <property name="bottom_attach">8</property>
+                        <property name="top_attach">9</property>
+                        <property name="bottom_attach">10</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -323,8 +323,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">7</property>
-                        <property name="bottom_attach">8</property>
+                        <property name="top_attach">9</property>
+                        <property name="bottom_attach">10</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -341,8 +341,8 @@
                         </style>
                       </object>
                       <packing>
-                        <property name="top_attach">8</property>
-                        <property name="bottom_attach">9</property>
+                        <property name="top_attach">10</property>
+                        <property name="bottom_attach">11</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -360,8 +360,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">8</property>
-                        <property name="bottom_attach">9</property>
+                        <property name="top_attach">10</property>
+                        <property name="bottom_attach">11</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -378,8 +378,8 @@
                         </style>
                       </object>
                       <packing>
-                        <property name="top_attach">9</property>
-                        <property name="bottom_attach">10</property>
+                        <property name="top_attach">11</property>
+                        <property name="bottom_attach">12</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -397,8 +397,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">9</property>
-                        <property name="bottom_attach">10</property>
+                        <property name="top_attach">11</property>
+                        <property name="bottom_attach">12</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -465,8 +465,8 @@
                         </style>
                       </object>
                       <packing>
-                        <property name="top_attach">10</property>
-                        <property name="bottom_attach">11</property>
+                        <property name="top_attach">12</property>
+                        <property name="bottom_attach">13</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -484,8 +484,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">10</property>
-                        <property name="bottom_attach">11</property>
+                        <property name="top_attach">12</property>
+                        <property name="bottom_attach">13</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -683,8 +683,8 @@
                         </style>
                       </object>
                       <packing>
-                        <property name="top_attach">11</property>
-                        <property name="bottom_attach">12</property>
+                        <property name="top_attach">13</property>
+                        <property name="bottom_attach">14</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options">GTK_FILL</property>
                         <property name="y_padding">4</property>
@@ -765,8 +765,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">11</property>
-                        <property name="bottom_attach">12</property>
+                        <property name="top_attach">13</property>
+                        <property name="bottom_attach">14</property>
                         <property name="y_options"/>
                       </packing>
                     </child>
@@ -819,8 +819,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">5</property>
-                        <property name="bottom_attach">6</property>
+                        <property name="top_attach">7</property>
+                        <property name="bottom_attach">8</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -837,8 +837,8 @@
                         </style>
                       </object>
                       <packing>
-                        <property name="top_attach">5</property>
-                        <property name="bottom_attach">6</property>
+                        <property name="top_attach">7</property>
+                        <property name="bottom_attach">8</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -893,8 +893,8 @@
                         </style>
                       </object>
                       <packing>
-                        <property name="top_attach">6</property>
-                        <property name="bottom_attach">7</property>
+                        <property name="top_attach">8</property>
+                        <property name="bottom_attach">9</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options">GTK_FILL</property>
                         <property name="y_padding">4</property>
@@ -949,9 +949,89 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
+                        <property name="top_attach">8</property>
+                        <property name="bottom_attach">9</property>
+                        <property name="y_options"/>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="devtab-loop-autoclear-label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes">Auto-clear</property>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
+                      </object>
+                      <packing>
+                        <property name="top_attach">5</property>
+                        <property name="bottom_attach">6</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"/>
+                        <property name="y_padding">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="devtab-loop-autoclear-switch-box">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <child>
+                          <object class="GtkSwitch" id="devtab-loop-autoclear-switch">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">5</property>
+                        <property name="bottom_attach">6</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"/>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="devtab-backing-file-label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes" comments="The filename or URI of the file that is used as backing store for the loop device.">Backing File</property>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
+                      </object>
+                      <packing>
+                        <property name="top_attach">6</property>
+                        <property name="bottom_attach">7</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"/>
+                        <property name="y_padding">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="devtab-backing-file-value-label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="hexpand">True</property>
+                        <property name="xalign">0</property>
+                        <property name="selectable">True</property>
+                        <property name="ellipsize">end</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
                         <property name="top_attach">6</property>
                         <property name="bottom_attach">7</property>
+                        <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                   </object>
@@ -1148,7 +1228,7 @@
                           <object class="GtkTable" id="devtab-table">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="n_rows">8</property>
+                            <property name="n_rows">6</property>
                             <property name="n_columns">2</property>
                             <property name="column_spacing">10</property>
                             <child>
@@ -1195,8 +1275,8 @@
                                 </style>
                               </object>
                               <packing>
-                                <property name="top_attach">5</property>
-                                <property name="bottom_attach">6</property>
+                                <property name="top_attach">3</property>
+                                <property name="bottom_attach">4</property>
                                 <property name="x_options">GTK_FILL</property>
                                 <property name="y_options"/>
                                 <property name="y_padding">4</property>
@@ -1214,8 +1294,8 @@
                               <packing>
                                 <property name="left_attach">1</property>
                                 <property name="right_attach">2</property>
-                                <property name="top_attach">5</property>
-                                <property name="bottom_attach">6</property>
+                                <property name="top_attach">3</property>
+                                <property name="bottom_attach">4</property>
                                 <property name="x_options">GTK_FILL</property>
                                 <property name="y_options"/>
                                 <property name="y_padding">4</property>
@@ -1269,8 +1349,8 @@
                                 </style>
                               </object>
                               <packing>
-                                <property name="top_attach">6</property>
-                                <property name="bottom_attach">7</property>
+                                <property name="top_attach">4</property>
+                                <property name="bottom_attach">5</property>
                                 <property name="x_options">GTK_FILL</property>
                                 <property name="y_options"/>
                                 <property name="y_padding">4</property>
@@ -1288,24 +1368,6 @@
                               <packing>
                                 <property name="left_attach">1</property>
                                 <property name="right_attach">2</property>
-                                <property name="top_attach">6</property>
-                                <property name="bottom_attach">7</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
-                                <property name="y_padding">4</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="devtab-loop-autoclear-label">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xalign">1</property>
-                                <property name="label" translatable="yes">Auto-clear</property>
-                                <style>
-                                  <class name="dim-label"/>
-                                </style>
-                              </object>
-                              <packing>
                                 <property name="top_attach">4</property>
                                 <property name="bottom_attach">5</property>
                                 <property name="x_options">GTK_FILL</property>
@@ -1314,31 +1376,6 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkBox" id="devtab-loop-autoclear-switch-box">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <object class="GtkSwitch" id="devtab-loop-autoclear-switch">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                  </object>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">0</property>
-                                  </packing>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="top_attach">4</property>
-                                <property name="bottom_attach">5</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
-                              </packing>
-                            </child>
-                            <child>
                               <object class="GtkLabel" id="devtab-partition-label">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
@@ -1349,43 +1386,6 @@
                                 </style>
                               </object>
                               <packing>
-                                <property name="top_attach">3</property>
-                                <property name="bottom_attach">4</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
-                                <property name="y_padding">4</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="devtab-partition-value-label">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="hexpand">True</property>
-                                <property name="xalign">0</property>
-                                <property name="selectable">True</property>
-                                <property name="ellipsize">end</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="top_attach">3</property>
-                                <property name="bottom_attach">4</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
-                                <property name="y_padding">4</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="devtab-backing-file-label">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xalign">1</property>
-                                <property name="label" translatable="yes" comments="The filename or URI of the file that is used as backing store for the loop device.">Backing File</property>
-                                <style>
-                                  <class name="dim-label"/>
-                                </style>
-                              </object>
-                              <packing>
                                 <property name="top_attach">2</property>
                                 <property name="bottom_attach">3</property>
                                 <property name="x_options">GTK_FILL</property>
@@ -1394,7 +1394,7 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkLabel" id="devtab-backing-file-value-label">
+                              <object class="GtkLabel" id="devtab-partition-value-label">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="hexpand">True</property>
@@ -1424,8 +1424,8 @@
                                 </style>
                               </object>
                               <packing>
-                                <property name="top_attach">7</property>
-                                <property name="bottom_attach">8</property>
+                                <property name="top_attach">5</property>
+                                <property name="bottom_attach">6</property>
                                 <property name="x_options">GTK_FILL</property>
                                 <property name="y_padding">4</property>
                               </packing>
@@ -1505,8 +1505,8 @@
                               <packing>
                                 <property name="left_attach">1</property>
                                 <property name="right_attach">2</property>
-                                <property name="top_attach">7</property>
-                                <property name="bottom_attach">8</property>
+                                <property name="top_attach">5</property>
+                                <property name="bottom_attach">6</property>
                                 <property name="y_options">GTK_FILL</property>
                               </packing>
                             </child>
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index 36a85cc..6d24213 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -2608,6 +2608,173 @@ update_device_page_for_drive (GduWindow      *window,
     udisks_object_info_unref (info);
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+update_device_page_for_loop (GduWindow      *window,
+                             UDisksObject   *object,
+                             UDisksBlock    *block,
+                             UDisksLoop     *loop,
+                             ShowFlags      *show_flags)
+{
+  GIcon *icon = NULL;
+  gchar *s = NULL;
+  gchar *desc = NULL;
+  gchar *device_desc = NULL;
+  guint64 size = 0;
+  GList *jobs = NULL;
+
+  gdu_volume_grid_set_no_media_string (GDU_VOLUME_GRID (window->volume_grid),
+                                       _("Loop device is empty"));
+
+  size = udisks_block_get_size (block);
+  jobs = udisks_client_get_jobs_for_object (window->client, object);
+
+  icon = g_themed_icon_new ("drive-removable-media"); /* for now */
+
+  if (size > 0)
+    {
+      s = udisks_client_get_size_for_display (window->client, size, FALSE, FALSE);
+      /* Translators: Used in the main window for a loop device, the first %s is the size */
+      desc = g_strdup_printf (C_("loop-window", "%s Loop Device"), s);
+      g_free (s);
+    }
+  else
+    {
+      /* Translators: Used in the main window for a block device where the size is not known  */
+      desc = g_strdup (C_("loop-window", "Loop Device"));
+    }
+  device_desc = get_device_file_for_display (block);
+
+  gtk_image_set_from_gicon (GTK_IMAGE (window->devtab_drive_image), icon, GTK_ICON_SIZE_DIALOG);
+  gtk_widget_show (window->devtab_drive_image);
+
+  s = g_strdup_printf ("<big><b>%s</b></big>", desc);
+  gtk_label_set_markup (GTK_LABEL (window->devtab_drive_desc_label), s);
+  gtk_widget_show (window->devtab_drive_desc_label);
+  g_free (s);
+  s = g_strdup_printf ("<small>%s</small>", device_desc);
+  gtk_label_set_markup (GTK_LABEL (window->devtab_drive_devices_label), s);
+  gtk_widget_show (window->devtab_drive_devices_label);
+  g_free (s);
+
+  gtk_widget_show (window->devtab_drive_box);
+  gtk_widget_show (window->devtab_drive_vbox);
+  gtk_widget_show (window->devtab_drive_buttonbox);
+  gtk_widget_show (window->devtab_drive_generic_button);
+
+  /* -------------------------------------------------- */
+  /* 'Size' field */
+
+  set_size (window,
+            "devtab-drive-size-label",
+            "devtab-drive-size-value-label",
+            size, SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
+
+  /* -------------------------------------------------- */
+  /* 'Auto-clear' and 'Backing File' fields */
+
+  if (loop != NULL)
+    {
+      s = gdu_utils_unfuse_path (udisks_loop_get_backing_file (loop));
+      set_markup (window,
+                  "devtab-backing-file-label",
+                  "devtab-backing-file-value-label",
+                  s, SET_MARKUP_FLAGS_NONE);
+      g_free (s);
+
+      set_switch (window,
+                  "devtab-loop-autoclear-label",
+                  "devtab-loop-autoclear-switch-box",
+                  "devtab-loop-autoclear-switch",
+                  udisks_loop_get_autoclear (loop));
+    }
+
+  /* -------------------------------------------------- */
+  /* 'Job' field - only shown if a job is running */
+
+  update_drive_jobs (window, jobs);
+
+  /* cleanup */
+  g_list_foreach (jobs, (GFunc) g_object_unref, NULL);
+  g_list_free (jobs);
+  g_clear_object (&icon);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+/* this is for setting the drive stuff for things any random block
+ * device that we don't have explicit support for... (typically things
+ * like LVM)
+ */
+static void
+update_device_page_for_fake_block (GduWindow      *window,
+                                   UDisksObject   *object,
+                                   UDisksBlock    *block,
+                                   ShowFlags      *show_flags)
+{
+  GIcon *icon = NULL;
+  gchar *s = NULL;
+  gchar *desc = NULL;
+  gchar *device_desc = NULL;
+  guint64 size = 0;
+  GList *jobs = NULL;
+
+  gdu_volume_grid_set_no_media_string (GDU_VOLUME_GRID (window->volume_grid),
+                                       _("Block device is empty"));
+
+  size = udisks_block_get_size (block);
+  jobs = udisks_client_get_jobs_for_object (window->client, object);
+
+  icon = g_themed_icon_new ("drive-removable-media"); /* for now */
+
+  if (size > 0)
+    {
+      s = udisks_client_get_size_for_display (window->client, size, FALSE, FALSE);
+      /* Translators: Used in the main window for a block device, the first %s is the size */
+      desc = g_strdup_printf (C_("block-window", "%s Block Device"), s);
+      g_free (s);
+    }
+  else
+    {
+      /* Translators: Used in the main window for a block device where the size is not known  */
+      desc = g_strdup (C_("block-window", "Block Device"));
+    }
+  device_desc = get_device_file_for_display (block);
+
+  gtk_image_set_from_gicon (GTK_IMAGE (window->devtab_drive_image), icon, GTK_ICON_SIZE_DIALOG);
+  gtk_widget_show (window->devtab_drive_image);
+
+  s = g_strdup_printf ("<big><b>%s</b></big>", desc);
+  gtk_label_set_markup (GTK_LABEL (window->devtab_drive_desc_label), s);
+  gtk_widget_show (window->devtab_drive_desc_label);
+  g_free (s);
+  s = g_strdup_printf ("<small>%s</small>", device_desc);
+  gtk_label_set_markup (GTK_LABEL (window->devtab_drive_devices_label), s);
+  gtk_widget_show (window->devtab_drive_devices_label);
+  g_free (s);
+
+  gtk_widget_show (window->devtab_drive_box);
+  gtk_widget_show (window->devtab_drive_vbox);
+  gtk_widget_show (window->devtab_drive_buttonbox);
+  gtk_widget_show (window->devtab_drive_generic_button);
+
+  /* -------------------------------------------------- */
+  /* 'Size' field */
+
+  set_size (window,
+            "devtab-drive-size-label",
+            "devtab-drive-size-value-label",
+            size, SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
+
+  /* cleanup */
+  g_list_foreach (jobs, (GFunc) g_object_unref, NULL);
+  g_list_free (jobs);
+  g_clear_object (&icon);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
 static UDisksObject *
 lookup_cleartext_device_for_crypto_device (UDisksClient  *client,
                                            const gchar   *object_path)
@@ -2656,7 +2823,6 @@ update_device_page_for_block (GduWindow          *window,
   const gchar *version;
   UDisksFilesystem *filesystem;
   UDisksPartition *partition;
-  UDisksLoop *loop;
   gboolean read_only;
   gchar *s, *s2, *s3;
   UDisksObject *drive_object;
@@ -2667,9 +2833,6 @@ update_device_page_for_block (GduWindow          *window,
   partition = udisks_object_peek_partition (object);
   filesystem = udisks_object_peek_filesystem (object);
 
-  /* loop device of main block device (not partition) */
-  loop = udisks_object_peek_loop (window->current_object);
-
   drive_object = (UDisksObject *) g_dbus_object_manager_get_object (udisks_client_get_object_manager (window->client),
                                                                         udisks_block_get_drive (block));
   if (drive_object != NULL)
@@ -2757,22 +2920,6 @@ update_device_page_for_block (GduWindow          *window,
       g_free (s);
     }
 
-  if (loop != NULL)
-    {
-      s = gdu_utils_unfuse_path (udisks_loop_get_backing_file (loop));
-      set_markup (window,
-                  "devtab-backing-file-label",
-                  "devtab-backing-file-value-label",
-                  s, SET_MARKUP_FLAGS_NONE);
-      g_free (s);
-
-      set_switch (window,
-                  "devtab-loop-autoclear-label",
-                  "devtab-loop-autoclear-switch-box",
-                  "devtab-loop-autoclear-switch",
-                  udisks_loop_get_autoclear (loop));
-    }
-
   usage = udisks_block_get_id_usage (block);
   type = udisks_block_get_id_type (block);
   version = udisks_block_get_id_version (block);
@@ -3077,6 +3224,7 @@ update_device_page (GduWindow      *window,
   UDisksBlock *block;
   UDisksDrive *drive;
   UDisksMDRaid *mdraid;
+  UDisksLoop *loop = NULL;
   guint64 size;
   GList *children;
   GList *l;
@@ -3110,15 +3258,20 @@ update_device_page (GduWindow      *window,
   block = udisks_object_peek_block (window->current_object);
   drive = udisks_object_peek_drive (window->current_object);
   mdraid = udisks_object_peek_mdraid (window->current_object);
+  if (block != NULL)
+    loop = udisks_client_get_loop_for_block (window->client, block);
 
   if (udisks_object_peek_loop (object) != NULL)
     show_flags->device_tree_buttons |= SHOW_FLAGS_DEVICE_TREE_BUTTON_DETACH_DISK_IMAGE;
 
   if (drive != NULL)
     update_device_page_for_drive (window, object, drive, show_flags);
-
-  if (mdraid != NULL)
+  else if (mdraid != NULL)
     update_device_page_for_mdraid (window, object, mdraid, show_flags);
+  else if (loop != NULL)
+    update_device_page_for_loop (window, object, block, loop, show_flags);
+  else
+    update_device_page_for_fake_block (window, object, block, show_flags);
 
   type = gdu_volume_grid_get_selected_type (GDU_VOLUME_GRID (window->volume_grid));
   size = gdu_volume_grid_get_selected_size (GDU_VOLUME_GRID (window->volume_grid));
@@ -3157,6 +3310,8 @@ update_device_page (GduWindow      *window,
             }
         }
     }
+
+  g_clear_object (&loop);
 }
 
 static void



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