[gnome-disk-utility/udisks2-port] Use new udisks API to set partition label, types and flags



commit a80403ed126a6325c6e8f3200a82acfbbd0e55dc
Author: David Zeuthen <davidz redhat com>
Date:   Mon Oct 31 16:13:30 2011 -0400

    Use new udisks API to set partition label, types and flags
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 data/ui/edit-gpt-partition-dialog.ui |    2 +-
 src/palimpsest/gdupartitiondialog.c  |   41 +++++++++++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 4 deletions(-)
---
diff --git a/data/ui/edit-gpt-partition-dialog.ui b/data/ui/edit-gpt-partition-dialog.ui
index 407254a..0d477b7 100644
--- a/data/ui/edit-gpt-partition-dialog.ui
+++ b/data/ui/edit-gpt-partition-dialog.ui
@@ -192,7 +192,7 @@
             </child>
             <child>
               <object class="GtkCheckButton" id="hidden-checkbutton">
-                <property name="label" translatable="yes">_Hidden</property>
+                <property name="label" translatable="yes">H_idden</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
diff --git a/src/palimpsest/gdupartitiondialog.c b/src/palimpsest/gdupartitiondialog.c
index 94668f1..6b1e017 100644
--- a/src/palimpsest/gdupartitiondialog.c
+++ b/src/palimpsest/gdupartitiondialog.c
@@ -270,25 +270,60 @@ gdu_partition_dialog_show (GduWindow    *window,
   gtk_widget_show_all (data->dialog);
   gtk_widget_grab_focus (data->type_combobox);
 
+  /* TODO: do this async */
   response = gtk_dialog_run (GTK_DIALOG (data->dialog));
   if (response == GTK_RESPONSE_OK)
     {
       gchar *type;
       gchar *name;
       guint64 flags;
+      GError *error;
+
       edit_partition_get (data, &type, &name, &flags);
+
       if (g_strcmp0 (udisks_partition_get_type_ (data->partition), type) != 0)
         {
-          g_debug ("TODO: set partition type to %s", type);
+          error = NULL;
+          if (!udisks_partition_call_set_type_sync (data->partition,
+                                                    type,
+                                                    g_variant_new ("a{sv}", NULL), /* options */
+                                                    NULL, /* GCancellable */
+                                                    &error))
+            {
+              gdu_window_show_error (window, _("Error setting partition type"), error);
+              g_error_free (error);
+              goto set_out;
+            }
         }
       if (g_strcmp0 (udisks_partition_get_name (data->partition), name) != 0)
         {
-          g_debug ("TODO: set partition name to %s", type);
+          error = NULL;
+          if (!udisks_partition_call_set_name_sync (data->partition,
+                                                    name,
+                                                    g_variant_new ("a{sv}", NULL), /* options */
+                                                    NULL, /* GCancellable */
+                                                    &error))
+            {
+              gdu_window_show_error (window, _("Error setting partition name"), error);
+              g_error_free (error);
+              goto set_out;
+            }
         }
       if (udisks_partition_get_flags (data->partition) != flags)
         {
-          g_debug ("TODO: set partition flags");
+          error = NULL;
+          if (!udisks_partition_call_set_flags_sync (data->partition,
+                                                     flags,
+                                                     g_variant_new ("a{sv}", NULL), /* options */
+                                                     NULL, /* GCancellable */
+                                                     &error))
+            {
+              gdu_window_show_error (window, _("Error setting partition flags"), error);
+              g_error_free (error);
+              goto set_out;
+            }
         }
+    set_out:
       g_free (type);
       g_free (name);
     }



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