[gnome-disk-utility] Add a --format-device command line option



commit 1dd44a1a5a48e1aa3218422a95ad4f6053efa624
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Feb 12 11:50:00 2013 -0500

    Add a --format-device command line option
    
    To spawn Disks directly with a Format dialog open.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=693682
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 src/disks/gduapplication.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/disks/gduapplication.c b/src/disks/gduapplication.c
index a8de7ae..0791ae6 100644
--- a/src/disks/gduapplication.c
+++ b/src/disks/gduapplication.c
@@ -16,6 +16,7 @@
 #include <unistd.h>
 
 #include "gduapplication.h"
+#include "gduformatvolumedialog.h"
 #include "gduwindow.h"
 #include "gdulocaljob.h"
 
@@ -128,9 +129,11 @@ gdu_application_command_line (GApplication            *_app,
   gchar *s;
   gchar *opt_block_device = NULL;
   gboolean opt_help = FALSE;
+  gboolean opt_format = FALSE;
   GOptionEntry opt_entries[] =
   {
     {"block-device", 0, 0, G_OPTION_ARG_STRING, &opt_block_device, N_("Select device"), NULL },
+    {"format-device", 0, 0, G_OPTION_ARG_NONE, &opt_format, N_("Format selected device"), NULL },
     {"help", '?', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_help, N_("Show help options"), NULL },
     {NULL}
   };
@@ -158,6 +161,12 @@ gdu_application_command_line (GApplication            *_app,
       goto out;
     }
 
+  if (opt_format && opt_block_device == NULL)
+    {
+      g_application_command_line_printerr (command_line, _("--format-device must be used together with 
--block-device\n"));
+      goto out;
+    }
+
   if (opt_block_device != NULL)
     {
       struct stat statbuf;
@@ -183,6 +192,7 @@ gdu_application_command_line (GApplication            *_app,
       g_object_unref (block);
     }
 
+
   if (app->window == NULL)
     {
       g_application_activate (G_APPLICATION (app));
@@ -194,7 +204,11 @@ gdu_application_command_line (GApplication            *_app,
     }
 
   if (object_to_select != NULL)
-    gdu_window_select_object (app->window, object_to_select);
+    {
+      gdu_window_select_object (app->window, object_to_select);
+      if (opt_format)
+        gdu_format_volume_dialog_show (app->window, object_to_select);
+    }
 
 
   ret = 0;


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