[gnome-disk-utility/udisks2-port] Show the "unfused" path of backing file, e.g. sftp://, not /home/davidz/.gvfs



commit f4a2aff3d44be91ed761696daa65f5966aff17c3
Author: David Zeuthen <davidz redhat com>
Date:   Wed Dec 7 17:42:01 2011 -0500

    Show the "unfused" path of backing file, e.g. sftp://, not /home/davidz/.gvfs
    
    http://people.freedesktop.org/~david/gdu2-unfused-backing-file-path.png
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 data/ui/palimpsest.ui               |   81 +++++++++++++++++++++++++---------
 src/palimpsest/gdudevicetreemodel.c |    6 ++-
 src/palimpsest/gduutils.c           |   25 +++++++++++
 src/palimpsest/gduutils.h           |    2 +
 src/palimpsest/gduwindow.c          |   13 ++++++
 5 files changed, 104 insertions(+), 23 deletions(-)
---
diff --git a/data/ui/palimpsest.ui b/data/ui/palimpsest.ui
index 7e0c6d3..ad1e951 100644
--- a/data/ui/palimpsest.ui
+++ b/data/ui/palimpsest.ui
@@ -787,7 +787,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">9</property>
                             <property name="n_columns">2</property>
                             <property name="column_spacing">10</property>
                             <child>
@@ -834,8 +834,8 @@
                                 </attributes>
                               </object>
                               <packing>
-                                <property name="top_attach">3</property>
-                                <property name="bottom_attach">4</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>
@@ -853,8 +853,8 @@
                               <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">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>
@@ -908,8 +908,8 @@
                                 </attributes>
                               </object>
                               <packing>
-                                <property name="top_attach">4</property>
-                                <property name="bottom_attach">5</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>
@@ -927,8 +927,8 @@
                               <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="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>
@@ -945,8 +945,8 @@
                                 </attributes>
                               </object>
                               <packing>
-                                <property name="top_attach">5</property>
-                                <property name="bottom_attach">6</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>
@@ -964,8 +964,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">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>
@@ -982,8 +982,8 @@
                                 </attributes>
                               </object>
                               <packing>
-                                <property name="top_attach">6</property>
-                                <property name="bottom_attach">7</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>
@@ -1001,8 +1001,8 @@
                               <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="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>
@@ -1019,8 +1019,8 @@
                                 </attributes>
                               </object>
                               <packing>
-                                <property name="top_attach">7</property>
-                                <property name="bottom_attach">8</property>
+                                <property name="top_attach">8</property>
+                                <property name="bottom_attach">9</property>
                                 <property name="x_options">GTK_FILL</property>
                                 <property name="y_options"></property>
                                 <property name="y_padding">4</property>
@@ -1038,8 +1038,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">8</property>
+                                <property name="bottom_attach">9</property>
                                 <property name="x_options">GTK_FILL</property>
                                 <property name="y_options"></property>
                                 <property name="y_padding">4</property>
@@ -1056,6 +1056,43 @@
                                 </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="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>
+                                <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">Backing File</property>
+                                <attributes>
+                                  <attribute name="foreground" value="#555555555555"/>
+                                </attributes>
+                              </object>
+                              <packing>
                                 <property name="top_attach">2</property>
                                 <property name="bottom_attach">3</property>
                                 <property name="x_options">GTK_FILL</property>
@@ -1064,7 +1101,7 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkLabel" id="devtab-partition-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>
diff --git a/src/palimpsest/gdudevicetreemodel.c b/src/palimpsest/gdudevicetreemodel.c
index bd6674e..38c2512 100644
--- a/src/palimpsest/gdudevicetreemodel.c
+++ b/src/palimpsest/gdudevicetreemodel.c
@@ -899,6 +899,9 @@ update_block (GduDeviceTreeModel  *model,
   if (loop_backing_file != NULL)
     {
       gchar *loop_name;
+      gchar *backing_file_unfused;
+
+      backing_file_unfused = gdu_utils_unfuse_path (loop_backing_file);
 
       /* Translators: This is for a /dev/loop device - %s is the size of the device e.g. "230 MB". */
       loop_name = g_strdup_printf (_("%s Loop Device"), size_str);
@@ -908,8 +911,9 @@ update_block (GduDeviceTreeModel  *model,
       s = g_strdup_printf ("%s\n"
                            "<small><span foreground=\"#555555\">%s</span></small>",
                            loop_name,
-                           loop_backing_file);
+                           backing_file_unfused);
       g_free (loop_name);
+      g_free (backing_file_unfused);
     }
   else
     {
diff --git a/src/palimpsest/gduutils.c b/src/palimpsest/gduutils.c
index 51b328a..d89c7b5 100644
--- a/src/palimpsest/gduutils.c
+++ b/src/palimpsest/gduutils.c
@@ -192,3 +192,28 @@ gdu_utils_create_info_bar (GtkMessageType   message_type,
   return info_bar;
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
+gchar *
+gdu_utils_unfuse_path (const gchar *path)
+{
+  gchar *ret;
+  GFile *file;
+  gchar *uri;
+
+  file = g_file_new_for_path (path);
+  uri = g_file_get_uri (file);
+  if (g_str_has_prefix (uri, "file:"))
+    {
+      ret = g_strdup (path);
+    }
+  else
+    {
+      ret = uri;
+      uri = NULL;
+    }
+  g_object_unref (file);
+  g_free (uri);
+
+  return ret;
+}
diff --git a/src/palimpsest/gduutils.h b/src/palimpsest/gduutils.h
index 22838bb..7b3f6de 100644
--- a/src/palimpsest/gduutils.h
+++ b/src/palimpsest/gduutils.h
@@ -41,6 +41,8 @@ GtkWidget *gdu_utils_create_info_bar (GtkMessageType  message_type,
                                       const gchar    *markup,
                                       GtkWidget     **out_label);
 
+gchar *gdu_utils_unfuse_path (const gchar *path);
+
 G_END_DECLS
 
 #endif /* __GDU_UTILS_H__ */
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index ed84dea..07cf8ad 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -1857,12 +1857,14 @@ update_device_page_for_block (GduWindow          *window,
   const gchar *version;
   UDisksFilesystem *filesystem;
   UDisksPartition *partition;
+  UDisksLoop *loop;
   gboolean read_only;
   gchar *s;
 
   read_only = udisks_block_get_read_only (block);
   partition = udisks_object_peek_partition (object);
   filesystem = udisks_object_peek_filesystem (object);
+  loop = udisks_object_peek_loop (window->current_object);
 
   /* TODO: don't show on CD-ROM drives etc. */
   if (udisks_block_get_size (block) > 0)
@@ -1945,6 +1947,17 @@ update_device_page_for_block (GduWindow          *window,
       g_free (s);
     }
 
+  if (loop != NULL)
+    {
+      gchar *s;
+      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);
+    }
+
   usage = udisks_block_get_id_usage (block);
   type = udisks_block_get_id_type (block);
   version = udisks_block_get_id_version (block);



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