[gnome-disk-utility/udisks2-port] Unify display of lun, block and loop devices



commit 2bf84abdcbf0d8904aca21cfbdc1c48b8139080e
Author: David Zeuthen <davidz redhat com>
Date:   Wed Mar 9 14:25:49 2011 -0500

    Unify display of lun, block and loop devices
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 data/ui/palimpsest.ui      |  307 ++++++++++---------------------------------
 src/palimpsest/gduwindow.c |  174 ++++++++++++++++----------
 2 files changed, 180 insertions(+), 301 deletions(-)
---
diff --git a/data/ui/palimpsest.ui b/data/ui/palimpsest.ui
index 92a0b00..b63146e 100644
--- a/data/ui/palimpsest.ui
+++ b/data/ui/palimpsest.ui
@@ -116,15 +116,14 @@
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <child>
-                  <object class="GtkTable" id="lun-table">
+                  <object class="GtkTable" id="devtab-table">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="n_rows">6</property>
+                    <property name="n_rows">8</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">10</property>
-                    <property name="homogeneous">True</property>
                     <child>
-                      <object class="GtkLabel" id="lun-model-label">
+                      <object class="GtkLabel" id="devtab-model-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">1</property>
@@ -136,10 +135,11 @@
                       <packing>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="lun-model-value-label">
+                      <object class="GtkLabel" id="devtab-model-value-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="hexpand">True</property>
@@ -152,10 +152,11 @@
                         <property name="right_attach">2</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="lun-write-cache-label">
+                      <object class="GtkLabel" id="devtab-write-cache-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">1</property>
@@ -165,17 +166,19 @@
                         </attributes>
                       </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>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkHBox" id="lun-write-cache-hbox">
+                      <object class="GtkHBox" id="devtab-write-cache-hbox">
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <child>
-                          <object class="GtkSwitch" id="lun-write-cache-switch">
+                          <object class="GtkSwitch" id="devtab-write-cache-switch">
                             <property name="visible">True</property>
                           </object>
                           <packing>
@@ -184,21 +187,19 @@
                             <property name="position">0</property>
                           </packing>
                         </child>
-                        <child>
-                          <placeholder/>
-                        </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="top_attach">7</property>
+                        <property name="bottom_attach">8</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="lun-wwn-label">
+                      <object class="GtkLabel" id="devtab-wwn-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">1</property>
@@ -208,14 +209,15 @@
                         </attributes>
                       </object>
                       <packing>
-                        <property name="top_attach">4</property>
-                        <property name="bottom_attach">5</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>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="lun-firmware-version-label">
+                      <object class="GtkLabel" id="devtab-firmware-version-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">1</property>
@@ -225,14 +227,15 @@
                         </attributes>
                       </object>
                       <packing>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
+                        <property name="top_attach">5</property>
+                        <property name="bottom_attach">6</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="lun-serial-number-label">
+                      <object class="GtkLabel" id="devtab-serial-number-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">1</property>
@@ -242,32 +245,15 @@
                         </attributes>
                       </object>
                       <packing>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="lun-wwn-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">4</property>
                         <property name="bottom_attach">5</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="lun-firmware-version-value-label">
+                      <object class="GtkLabel" id="devtab-wwn-value-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="hexpand">True</property>
@@ -278,14 +264,15 @@
                       <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="top_attach">6</property>
+                        <property name="bottom_attach">7</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="lun-serial-number-value-label">
+                      <object class="GtkLabel" id="devtab-firmware-version-value-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="hexpand">True</property>
@@ -296,31 +283,15 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="lun-size-label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
-                        <property name="label" translatable="yes">Size</property>
-                        <attributes>
-                          <attribute name="foreground" value="#555555555555"/>
-                        </attributes>
-                      </object>
-                      <packing>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_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"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="lun-size-value-label">
+                      <object class="GtkLabel" id="devtab-serial-number-value-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="hexpand">True</property>
@@ -331,58 +302,15 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_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"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <placeholder/>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">lun</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkVBox" id="looptab_vbox">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkTable" id="loop-table">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="n_rows">4</property>
-                    <property name="n_columns">2</property>
-                    <property name="column_spacing">10</property>
-                    <property name="homogeneous">True</property>
-                    <child>
-                      <object class="GtkLabel" id="loop-size-label">
+                      <object class="GtkLabel" id="devtab-size-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">1</property>
@@ -396,10 +324,11 @@
                         <property name="bottom_attach">2</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="loop-size-value-label">
+                      <object class="GtkLabel" id="devtab-size-value-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="hexpand">True</property>
@@ -414,14 +343,15 @@
                         <property name="bottom_attach">2</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="loop-file-label">
+                      <object class="GtkLabel" id="devtab-device-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">1</property>
-                        <property name="label" translatable="yes">File</property>
+                        <property name="label" translatable="yes">Device</property>
                         <attributes>
                           <attribute name="foreground" value="#555555555555"/>
                         </attributes>
@@ -431,10 +361,11 @@
                         <property name="bottom_attach">3</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="loop-file-value-label">
+                      <object class="GtkLabel" id="devtab-device-value-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="hexpand">True</property>
@@ -449,25 +380,29 @@
                         <property name="bottom_attach">3</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="loop-device-label">
+                      <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">Device</property>
+                        <property name="label" translatable="yes">Backing File</property>
                         <attributes>
                           <attribute name="foreground" value="#555555555555"/>
                         </attributes>
                       </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>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="loop-device-value-label">
+                      <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>
@@ -478,16 +413,13 @@
                       <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>
+                        <property name="y_padding">4</property>
                       </packing>
                     </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
                   </object>
                   <packing>
                     <property name="expand">True</property>
@@ -503,128 +435,41 @@
                 </child>
               </object>
               <packing>
-                <property name="position">2</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child type="tab">
-              <object class="GtkLabel" id="looptab_label">
+              <object class="GtkLabel" id="label1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">loop</property>
+                <property name="label" translatable="yes">devtab</property>
               </object>
               <packing>
-                <property name="position">2</property>
+                <property name="position">1</property>
                 <property name="tab_fill">False</property>
               </packing>
             </child>
             <child>
-              <object class="GtkVBox" id="blocktab_vbox">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkTable" id="block-table">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="n_rows">3</property>
-                    <property name="n_columns">2</property>
-                    <property name="column_spacing">10</property>
-                    <property name="homogeneous">True</property>
-                    <child>
-                      <object class="GtkLabel" id="block-size-label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
-                        <property name="label" translatable="yes">Size</property>
-                        <attributes>
-                          <attribute name="foreground" value="#555555555555"/>
-                        </attributes>
-                      </object>
-                      <packing>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="block-size-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">1</property>
-                        <property name="bottom_attach">2</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="block-device-label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
-                        <property name="label" translatable="yes">Device</property>
-                        <attributes>
-                          <attribute name="foreground" value="#555555555555"/>
-                        </attributes>
-                      </object>
-                      <packing>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="block-device-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="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="position">3</property>
-              </packing>
+              <placeholder/>
             </child>
             <child type="tab">
-              <object class="GtkLabel" id="blocktab_label">
+              <object class="GtkLabel" id="newtab_label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">block</property>
+                <property name="label" translatable="yes">new</property>
               </object>
               <packing>
-                <property name="position">3</property>
+                <property name="position">2</property>
                 <property name="tab_fill">False</property>
               </packing>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child type="tab">
+              <placeholder/>
+            </child>
+            <child>
               <object class="GtkVBox" id="newtab_vbox">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -639,19 +484,11 @@
                 </child>
               </object>
               <packing>
-                <property name="position">4</property>
+                <property name="position">2</property>
               </packing>
             </child>
             <child type="tab">
-              <object class="GtkLabel" id="newtab_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">new</property>
-              </object>
-              <packing>
-                <property name="position">3</property>
-                <property name="tab_fill">False</property>
-              </packing>
+              <placeholder/>
             </child>
           </object>
           <packing>
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index f74b776..7a052f0 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -32,9 +32,7 @@
 typedef enum
 {
   DETAILS_PAGE_NOT_SELECTED,
-  DETAILS_PAGE_LUN,
-  DETAILS_PAGE_LOOP,
-  DETAILS_PAGE_BLOCK
+  DETAILS_PAGE_DEVICE,
 } DetailsPage;
 
 struct _GduWindow
@@ -128,18 +126,10 @@ set_selected_object_proxy (GduWindow        *window,
 {
   if (object_proxy != NULL)
     {
-      UDisksBlockDevice *block;
-
-      if (UDISKS_PEEK_LUN (object_proxy) != NULL)
-        {
-          select_details_page (window, object_proxy, DETAILS_PAGE_LUN);
-        }
-      else if ((block = UDISKS_PEEK_BLOCK_DEVICE (object_proxy)) != NULL)
+      if (UDISKS_PEEK_LUN (object_proxy) != NULL ||
+          UDISKS_PEEK_BLOCK_DEVICE (object_proxy) != NULL)
         {
-          if (strlen (udisks_block_device_get_loop_backing_file (block)) > 0)
-            select_details_page (window, object_proxy, DETAILS_PAGE_LOOP);
-          else
-            select_details_page (window, object_proxy, DETAILS_PAGE_BLOCK);
+          select_details_page (window, object_proxy, DETAILS_PAGE_DEVICE);
         }
       else
         {
@@ -415,39 +405,131 @@ teardown_details_page (GduWindow         *window,
     {
     case DETAILS_PAGE_NOT_SELECTED:
       break;
-    case DETAILS_PAGE_LUN:
-      break;
-    case DETAILS_PAGE_LOOP:
-      break;
-    case DETAILS_PAGE_BLOCK:
+    case DETAILS_PAGE_DEVICE:
       break;
     }
 }
 
 static void
 set_string (GduWindow   *window,
+            const gchar *key_label_id,
             const gchar *label_id,
             const gchar *text)
 {
+  GtkWidget *key_label;
+  GtkWidget *label;
+
   if (text == NULL || strlen (text) == 0)
     text = "â??";
 
   /* TODO: utf-8 validate */
-  gtk_label_set_text (GTK_LABEL (gdu_window_get_widget (window, label_id)), text);
+
+  key_label = gdu_window_get_widget (window, key_label_id);
+  label = gdu_window_get_widget (window, label_id);
+
+  gtk_label_set_text (GTK_LABEL (label), text);
+  gtk_widget_show (key_label);
+  gtk_widget_show (label);
 }
 
 static void
 set_size (GduWindow   *window,
+          const gchar *key_label_id,
           const gchar *label_id,
           guint64      size)
 {
   gchar *s;
   s = udisks_util_get_size_for_display (size, FALSE, TRUE);
-  set_string (window, label_id, s);
+  set_string (window, key_label_id, label_id, s);
   g_free (s);
 }
 
 static void
+setup_device_page (GduWindow         *window,
+                   GDBusObjectProxy *object_proxy)
+{
+  UDisksLun *lun;
+  UDisksBlockDevice *block;
+  GList *children;
+  GList *l;
+
+  children = gtk_container_get_children (GTK_CONTAINER (gdu_window_get_widget (window, "devtab-table")));
+  for (l = children; l != NULL; l = l->next)
+    {
+      GtkWidget *child = GTK_WIDGET (l->data);
+      gtk_widget_hide (child);
+    }
+  g_list_free (children);
+
+  lun = UDISKS_PEEK_LUN (object_proxy);
+  block = UDISKS_PEEK_BLOCK_DEVICE (object_proxy);
+
+  if (lun != NULL)
+    {
+      const gchar *lun_vendor;
+      const gchar *lun_model;
+      gchar *s;
+
+      lun_vendor = udisks_lun_get_vendor (lun);
+      lun_model = udisks_lun_get_model (lun);
+      if (strlen (lun_vendor) == 0)
+        s = g_strdup (lun_model);
+      else if (strlen (lun_model) == 0)
+        s = g_strdup (lun_vendor);
+      else
+        s = g_strconcat (lun_vendor, " ", lun_model, NULL);
+      set_string (window,
+                  "devtab-model-label",
+                  "devtab-model-value-label", s);
+      g_free (s);
+      set_string (window,
+                  "devtab-serial-number-label",
+                  "devtab-serial-number-value-label",
+                  udisks_lun_get_serial (lun));
+      set_string (window,
+                  "devtab-firmware-version-label",
+                  "devtab-firmware-version-value-label",
+                  udisks_lun_get_revision (lun));
+      set_string (window,
+                  "devtab-wwn-label",
+                  "devtab-wwn-value-label",
+                  udisks_lun_get_wwn (lun));
+      set_size (window,
+                "devtab-size-label",
+                "devtab-size-value-label",
+                udisks_lun_get_size (lun));
+      /* TODO: get this from udisks */
+      gtk_switch_set_active (GTK_SWITCH (gdu_window_get_widget (window, "devtab-write-cache-switch")), TRUE);
+      gtk_widget_show (gdu_window_get_widget (window, "devtab-write-cache-label"));
+      gtk_widget_show (gdu_window_get_widget (window, "devtab-write-cache-switch"));
+      gtk_widget_show (gdu_window_get_widget (window, "devtab-write-cache-hbox"));
+    }
+  else if (block != NULL)
+    {
+      const gchar *backing_file;
+
+      set_string (window,
+                  "devtab-device-label",
+                  "devtab-device-value-label",
+                  udisks_block_device_get_preferred_device (block));
+      set_size (window,
+                "devtab-size-label",
+                "devtab-size-value-label",
+                udisks_block_device_get_size (block));
+      backing_file = udisks_block_device_get_loop_backing_file (block);
+      if (strlen (backing_file) > 0)
+        set_string (window,
+                    "devtab-backing-file-label",
+                    "devtab-backing-file-value-label",
+                    backing_file);
+    }
+  else
+    {
+      g_assert_not_reached ();
+    }
+}
+
+static void
 setup_details_page (GduWindow         *window,
                     GDBusObjectProxy *object_proxy,
                     gint              page)
@@ -455,54 +537,14 @@ setup_details_page (GduWindow         *window,
   //g_debug ("setup for %s, page %d",
   //         object_proxy != NULL ? g_dbus_object_proxy_get_object_path (object_proxy) : "<none>",
   //         page);
+
   switch (page)
     {
     case DETAILS_PAGE_NOT_SELECTED:
       break;
-    case DETAILS_PAGE_LUN:
-      {
-        UDisksLun *lun;
-        const gchar *lun_vendor;
-        const gchar *lun_model;
-        gchar *s;
-
-        lun = UDISKS_PEEK_LUN (object_proxy);
-        lun_vendor = udisks_lun_get_vendor (lun);
-        lun_model = udisks_lun_get_model (lun);
-        if (strlen (lun_vendor) == 0)
-          s = g_strdup (lun_model);
-        else if (strlen (lun_model) == 0)
-          s = g_strdup (lun_vendor);
-        else
-          s = g_strconcat (lun_vendor, " ", lun_model, NULL);
-        gtk_label_set_text (GTK_LABEL (gdu_window_get_widget (window, "lun-model-value-label")), s);
-        g_free (s);
-
-        set_string (window, "lun-serial-number-value-label", udisks_lun_get_serial (lun));
-        set_string (window, "lun-firmware-version-value-label", udisks_lun_get_revision (lun));
-        set_string (window, "lun-wwn-value-label", udisks_lun_get_wwn (lun));
-        set_size (window, "lun-size-value-label", udisks_lun_get_size (lun));
-        /* TODO: get this from udisks */
-        gtk_switch_set_active (GTK_SWITCH (gdu_window_get_widget (window, "lun-write-cache-switch")), TRUE);
-      }
-      break;
-    case DETAILS_PAGE_LOOP:
-      {
-        UDisksBlockDevice *block;
-        block = UDISKS_PEEK_BLOCK_DEVICE (object_proxy);
-        set_string (window, "loop-device-value-label", udisks_block_device_get_preferred_device (block));
-        set_string (window, "loop-file-value-label", udisks_block_device_get_loop_backing_file (block));
-        set_size (window, "loop-size-value-label", udisks_block_device_get_size (block));
-      }
-      break;
 
-    case DETAILS_PAGE_BLOCK:
-      {
-        UDisksBlockDevice *block;
-        block = UDISKS_PEEK_BLOCK_DEVICE (object_proxy);
-        set_string (window, "block-device-value-label", udisks_block_device_get_preferred_device (block));
-        set_size (window, "block-size-value-label", udisks_block_device_get_size (block));
-      }
+    case DETAILS_PAGE_DEVICE:
+      setup_device_page (window, object_proxy);
       break;
     }
 }
@@ -525,9 +567,9 @@ select_details_page (GduWindow         *window,
     g_object_unref (window->current_object_proxy);
   window->current_object_proxy = object_proxy != NULL ? g_object_ref (object_proxy) : NULL;
 
+  gtk_notebook_set_current_page (notebook, page);
+
   setup_details_page (window,
                       window->current_object_proxy,
                       window->current_page);
-
-  gtk_notebook_set_current_page (notebook, page);
 }



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