[gnome-disk-utility/udisks2-port] Add some helpful explanation of the selected device file when editing fstab



commit 2d2af00f75c29ea32e58dd68bf83e8bf4c9e318b
Author: David Zeuthen <davidz redhat com>
Date:   Wed Aug 10 11:37:38 2011 -0400

    Add some helpful explanation of the selected device file when editing fstab
    
    http://people.freedesktop.org/~david/palimpsest-fstab-by-path.png
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 data/ui/palimpsest.ui      |  170 ++++++++++++++++++++++++--------------------
 src/palimpsest/gduwindow.c |   58 +++++++++++++++
 2 files changed, 152 insertions(+), 76 deletions(-)
---
diff --git a/data/ui/palimpsest.ui b/data/ui/palimpsest.ui
index 42593ab..ff5f807 100644
--- a/data/ui/palimpsest.ui
+++ b/data/ui/palimpsest.ui
@@ -1,61 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkActionGroup" id="devtab-actions">
-    <child>
-      <object class="GtkAction" id="devtab-action-partition-create">
-        <property name="tooltip" translatable="yes">Create a new partition in the free space</property>
-        <property name="icon_name">list-add-symbolic</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkAction" id="devtab-action-mount">
-        <property name="tooltip" translatable="yes">Mount the filesystem</property>
-        <property name="icon_name">media-playback-start-symbolic</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkAction" id="devtab-action-unmount">
-        <property name="tooltip" translatable="yes">Unmount the filesystem</property>
-        <property name="icon_name">media-playback-stop-symbolic</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkAction" id="devtab-action-eject">
-        <property name="tooltip" translatable="yes">Eject the media</property>
-        <property name="icon_name">media-eject-symbolic</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkAction" id="devtab-action-unlock">
-        <property name="tooltip" translatable="yes">Unlock the encrypted device</property>
-        <property name="icon_name">changes-allow-symbolic</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkAction" id="devtab-action-activate-swap">
-        <property name="tooltip" translatable="yes">Activate the swap space</property>
-        <property name="icon_name">media-playback-start-symbolic</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkAction" id="devtab-action-deactivate-swap">
-        <property name="tooltip" translatable="yes">Deactivate the swap space</property>
-        <property name="icon_name">media-playback-stop-symbolic</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkAction" id="devtab-action-lock">
-        <property name="tooltip" translatable="yes">Lock the encrypted device</property>
-        <property name="icon_name">changes-prevent-symbolic</property>
-      </object>
-    </child>
-    <child>
-      <object class="GtkAction" id="devtab-action-generic">
-        <property name="icon_name">system-run-symbolic</property>
-      </object>
-    </child>
-  </object>
   <object class="GtkDialog" id="change-filesystem-label-dialog">
     <property name="can_focus">False</property>
     <property name="border_width">12</property>
@@ -374,7 +319,7 @@
                   <object class="GtkTable" id="fstab-table">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="n_rows">6</property>
+                    <property name="n_rows">7</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">10</property>
                     <property name="row_spacing">6</property>
@@ -407,8 +352,8 @@
                         </attributes>
                       </object>
                       <packing>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
                         <property name="x_options">GTK_FILL</property>
                       </packing>
                     </child>
@@ -425,8 +370,8 @@
                         </attributes>
                       </object>
                       <packing>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
                         <property name="x_options">GTK_FILL</property>
                       </packing>
                     </child>
@@ -443,8 +388,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>
                       </packing>
                     </child>
@@ -458,8 +403,8 @@
                       <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">2</property>
+                        <property name="bottom_attach">3</property>
                       </packing>
                     </child>
                     <child>
@@ -472,8 +417,8 @@
                       <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="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
                       </packing>
                     </child>
                     <child>
@@ -486,8 +431,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>
                       </packing>
                     </child>
                     <child>
@@ -503,8 +448,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>
                       </packing>
                     </child>
@@ -521,8 +466,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>
                       </packing>
                     </child>
@@ -538,8 +483,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>
                       </packing>
                     </child>
                     <child>
@@ -554,8 +499,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>
                       </packing>
                     </child>
                     <child>
@@ -570,6 +515,24 @@
                         <property name="right_attach">2</property>
                       </packing>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="fstab-device-explanation-label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="yalign">0</property>
+                        <property name="wrap">True</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>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -616,6 +579,61 @@
       <action-widget response="-10">button8</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkActionGroup" id="devtab-actions">
+    <child>
+      <object class="GtkAction" id="devtab-action-partition-create">
+        <property name="tooltip" translatable="yes">Create a new partition in the free space</property>
+        <property name="icon_name">list-add-symbolic</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="devtab-action-mount">
+        <property name="tooltip" translatable="yes">Mount the filesystem</property>
+        <property name="icon_name">media-playback-start-symbolic</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="devtab-action-unmount">
+        <property name="tooltip" translatable="yes">Unmount the filesystem</property>
+        <property name="icon_name">media-playback-stop-symbolic</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="devtab-action-eject">
+        <property name="tooltip" translatable="yes">Eject the media</property>
+        <property name="icon_name">media-eject-symbolic</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="devtab-action-unlock">
+        <property name="tooltip" translatable="yes">Unlock the encrypted device</property>
+        <property name="icon_name">changes-allow-symbolic</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="devtab-action-activate-swap">
+        <property name="tooltip" translatable="yes">Activate the swap space</property>
+        <property name="icon_name">media-playback-start-symbolic</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="devtab-action-deactivate-swap">
+        <property name="tooltip" translatable="yes">Deactivate the swap space</property>
+        <property name="icon_name">media-playback-stop-symbolic</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="devtab-action-lock">
+        <property name="tooltip" translatable="yes">Lock the encrypted device</property>
+        <property name="icon_name">changes-prevent-symbolic</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="devtab-action-generic">
+        <property name="icon_name">system-run-symbolic</property>
+      </object>
+    </child>
+  </object>
   <object class="GtkAdjustment" id="fstab-freq-adjustment">
     <property name="upper">1000000</property>
     <property name="step_increment">1</property>
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index a72868f..9278b11 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -2060,6 +2060,7 @@ typedef struct
   GtkWidget *table;
 
   GtkWidget *device_combobox;
+  GtkWidget *device_explanation_label;
   GtkWidget *directory_entry;
   GtkWidget *type_entry;
   GtkWidget *options_entry;
@@ -2154,6 +2155,58 @@ fstab_dialog_property_changed (GObject     *object,
 }
 
 static void
+fstab_update_device_explanation (FstabDialogData *data)
+{
+  const gchar *s;
+  gchar *fsname;
+  gchar *str;
+  gchar *explanation;
+  guint part_num;
+
+  fsname = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (data->device_combobox));
+
+  part_num = 0;
+  s = g_strrstr (fsname, "-part");
+  if (s != NULL)
+    sscanf (s, "-part%d", &part_num);
+
+  if (g_str_has_prefix (fsname, "/dev/disk/by-id/"))
+    {
+      if (part_num > 0)
+        explanation = g_strdup_printf (_("Matches partition %d of the device with the given vital product data"),
+                                       part_num);
+      else
+        explanation = g_strdup (_("Matches the whole disk of the device with the given vital product data"));
+    }
+  else if (g_str_has_prefix (fsname, "/dev/disk/by-path/"))
+    {
+      if (part_num > 0)
+        explanation = g_strdup_printf (_("Matches partition %d of any device connected at the given port or address"),
+                                       part_num);
+      else
+        explanation = g_strdup (_("Matches the whole disk of any device connected at the given port or address"));
+    }
+  else if (g_str_has_prefix (fsname, "/dev/disk/by-label/") || g_str_has_prefix (fsname, "LABEL="))
+    {
+      explanation = g_strdup (_("Matches any device with the given label"));
+    }
+  else if (g_str_has_prefix (fsname, "/dev/disk/by-uuid/") || g_str_has_prefix (fsname, "UUID="))
+    {
+      explanation = g_strdup (_("Matches the given UUID"));
+    }
+  else
+    {
+      explanation = g_strdup (_("Matches the given device"));
+    }
+
+  str = g_strdup_printf ("<small><i>%s</i></small>", explanation);
+  gtk_label_set_markup (GTK_LABEL (data->device_explanation_label), str);
+  g_free (str);
+  g_free (explanation);
+  g_free (fsname);
+}
+
+static void
 fstab_on_device_combobox_changed (GtkComboBox *combobox,
                                   gpointer     user_data)
 {
@@ -2169,9 +2222,12 @@ fstab_on_device_combobox_changed (GtkComboBox *combobox,
   if (s == NULL)
     s = "/disk";
   proposed_mount_point = g_strdup_printf ("/media/%s", s + 1);
+
   gtk_entry_set_text (GTK_ENTRY (data->directory_entry), proposed_mount_point);
   g_free (proposed_mount_point);
   g_free (fsname);
+
+  fstab_update_device_explanation (data);
 }
 
 static void
@@ -2364,6 +2420,7 @@ on_change_mounted (GduWindow *window)
   data.configure_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-configure-checkbutton"));
   data.table = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-table"));
   data.device_combobox = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-device-combobox"));
+  data.device_explanation_label = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-device-explanation-label"));
   data.directory_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-directory-entry"));
   data.type_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-type-entry"));
   data.options_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-options-entry"));
@@ -2436,6 +2493,7 @@ on_change_mounted (GduWindow *window)
 
   gtk_widget_show_all (dialog);
 
+  fstab_update_device_explanation (&data);
   fstab_dialog_update (&data);
 
   response = gtk_dialog_run (GTK_DIALOG (dialog));



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