mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0134-p2v-Combine-size-model-columns-into-the-device-colum.patch

e76f14
From 4ada7cd307f4cfb177e0f033eae05592030fc1e0 Mon Sep 17 00:00:00 2001
e76f14
From: "Richard W.M. Jones" <rjones@redhat.com>
e76f14
Date: Fri, 24 Jun 2016 14:53:52 +0100
e76f14
Subject: [PATCH] p2v: Combine size & model columns into the device column.
e76f14
e76f14
In the GUI disks block, instead of using separate "Size" and "Model"
e76f14
columns, combine that information into a markup column under "Device".
e76f14
e76f14
To make the GUI look consistent I also had to change the removables
e76f14
"Device" column to be a markup column and embolden the device name
e76f14
there too.
e76f14
e76f14
(cherry picked from commit 6aba5a49448d8ed9776164005080620d37bb97e0)
e76f14
---
e76f14
 p2v/gui.c        | 51 ++++++++++++++++++++++-----------------------------
e76f14
 p2v/virt-p2v.pod |  8 +++++---
e76f14
 2 files changed, 27 insertions(+), 32 deletions(-)
e76f14
e76f14
diff --git a/p2v/gui.c b/p2v/gui.c
e76f14
index 1bae4d8..49c703d 100644
e76f14
--- a/p2v/gui.c
e76f14
+++ b/p2v/gui.c
e76f14
@@ -503,8 +503,6 @@ static uint64_t get_memory_from_conv_dlg (void);
e76f14
 enum {
e76f14
   DISKS_COL_CONVERT = 0,
e76f14
   DISKS_COL_DEVICE,
e76f14
-  DISKS_COL_SIZE,
e76f14
-  DISKS_COL_MODEL,
e76f14
   NUM_DISKS_COLS,
e76f14
 };
e76f14
 
e76f14
@@ -859,33 +857,39 @@ static void
e76f14
 populate_disks (GtkTreeView *disks_list)
e76f14
 {
e76f14
   GtkListStore *disks_store;
e76f14
-  GtkCellRenderer *disks_col_convert, *disks_col_device,
e76f14
-    *disks_col_size, *disks_col_model;
e76f14
+  GtkCellRenderer *disks_col_convert, *disks_col_device;
e76f14
   GtkTreeIter iter;
e76f14
   size_t i;
e76f14
 
e76f14
   disks_store = gtk_list_store_new (NUM_DISKS_COLS,
e76f14
-                                    G_TYPE_BOOLEAN, G_TYPE_STRING,
e76f14
-                                    G_TYPE_STRING, G_TYPE_STRING);
e76f14
+                                    G_TYPE_BOOLEAN, G_TYPE_STRING);
e76f14
   if (all_disks != NULL) {
e76f14
     for (i = 0; all_disks[i] != NULL; ++i) {
e76f14
       uint64_t size;
e76f14
       CLEANUP_FREE char *size_gb = NULL;
e76f14
       CLEANUP_FREE char *model = NULL;
e76f14
+      CLEANUP_FREE char *device_descr = NULL;
e76f14
 
e76f14
       if (all_disks[i][0] != '/') { /* not using --test-disk */
e76f14
         size = get_blockdev_size (all_disks[i]);
e76f14
-        if (asprintf (&size_gb, "%" PRIu64, size) == -1)
e76f14
+        if (asprintf (&size_gb, "%" PRIu64 "G", size) == -1)
e76f14
           error (EXIT_FAILURE, errno, "asprintf");
e76f14
         model = get_blockdev_model (all_disks[i]);
e76f14
       }
e76f14
 
e76f14
+      if (asprintf (&device_descr,
e76f14
+                    "%s\n"
e76f14
+                    "<small>"
e76f14
+                    "%s %s"
e76f14
+                    "</small>\n",
e76f14
+                    all_disks[i],
e76f14
+                    size_gb ? size_gb : "", model ? model : "") == -1)
e76f14
+        error (EXIT_FAILURE, errno, "asprintf");
e76f14
+
e76f14
       gtk_list_store_append (disks_store, &iter);
e76f14
       gtk_list_store_set (disks_store, &iter,
e76f14
                           DISKS_COL_CONVERT, TRUE,
e76f14
-                          DISKS_COL_DEVICE, all_disks[i],
e76f14
-                          DISKS_COL_SIZE, size_gb ? size_gb : "",
e76f14
-                          DISKS_COL_MODEL, model ? model : "",
e76f14
+                          DISKS_COL_DEVICE, device_descr,
e76f14
                           -1);
e76f14
     }
e76f14
   }
e76f14
@@ -905,25 +909,9 @@ populate_disks (GtkTreeView *disks_list)
e76f14
                                                -1,
e76f14
                                                _("Device"),
e76f14
                                                disks_col_device,
e76f14
-                                               "text", DISKS_COL_DEVICE,
e76f14
+                                               "markup", DISKS_COL_DEVICE,
e76f14
                                                NULL);
e76f14
   gtk_cell_renderer_set_alignment (disks_col_device, 0.0, 0.0);
e76f14
-  disks_col_size = gtk_cell_renderer_text_new ();
e76f14
-  gtk_tree_view_insert_column_with_attributes (disks_list,
e76f14
-                                               -1,
e76f14
-                                               _("Size (GB)"),
e76f14
-                                               disks_col_size,
e76f14
-                                               "text", DISKS_COL_SIZE,
e76f14
-                                               NULL);
e76f14
-  gtk_cell_renderer_set_alignment (disks_col_size, 0.0, 0.0);
e76f14
-  disks_col_model = gtk_cell_renderer_text_new ();
e76f14
-  gtk_tree_view_insert_column_with_attributes (disks_list,
e76f14
-                                               -1,
e76f14
-                                               _("Model"),
e76f14
-                                               disks_col_model,
e76f14
-                                               "text", DISKS_COL_MODEL,
e76f14
-                                               NULL);
e76f14
-  gtk_cell_renderer_set_alignment (disks_col_model, 0.0, 0.0);
e76f14
 
e76f14
   g_signal_connect (disks_col_convert, "toggled",
e76f14
                     G_CALLBACK (toggled), disks_store);
e76f14
@@ -941,10 +929,15 @@ populate_removable (GtkTreeView *removable_list)
e76f14
                                         G_TYPE_BOOLEAN, G_TYPE_STRING);
e76f14
   if (all_removable != NULL) {
e76f14
     for (i = 0; all_removable[i] != NULL; ++i) {
e76f14
+      CLEANUP_FREE char *device_descr = NULL;
e76f14
+
e76f14
+      if (asprintf (&device_descr, "%s\n", all_removable[i]) == -1)
e76f14
+        error (EXIT_FAILURE, errno, "asprintf");
e76f14
+
e76f14
       gtk_list_store_append (removable_store, &iter);
e76f14
       gtk_list_store_set (removable_store, &iter,
e76f14
                           REMOVABLE_COL_CONVERT, TRUE,
e76f14
-                          REMOVABLE_COL_DEVICE, all_removable[i],
e76f14
+                          REMOVABLE_COL_DEVICE, device_descr,
e76f14
                           -1);
e76f14
     }
e76f14
   }
e76f14
@@ -964,7 +957,7 @@ populate_removable (GtkTreeView *removable_list)
e76f14
                                                -1,
e76f14
                                                _("Device"),
e76f14
                                                removable_col_device,
e76f14
-                                               "text", REMOVABLE_COL_DEVICE,
e76f14
+                                               "markup", REMOVABLE_COL_DEVICE,
e76f14
                                                NULL);
e76f14
   gtk_cell_renderer_set_alignment (removable_col_device, 0.0, 0.0);
e76f14
 
e76f14
diff --git a/p2v/virt-p2v.pod b/p2v/virt-p2v.pod
e76f14
index b996541..032a480 100644
e76f14
--- a/p2v/virt-p2v.pod
e76f14
+++ b/p2v/virt-p2v.pod
e76f14
@@ -194,9 +194,11 @@ settings is fine.
e76f14
  ─ ─ ───────────────────────────────────────┐
e76f14
      Fixed hard disks                       │
e76f14
e76f14
-     Convert  Device  Size (GB)  Model      │
e76f14
-     [✔]      sda     1024       HITACHI    │
e76f14
-     [✔]      sdb     119        HITACHI    │
e76f14
+     Convert  Device                        │
e76f14
+     [✔]      sda                           │
e76f14
+              1024G HITACHI                 │
e76f14
+     [✔]      sdb                           │
e76f14
+              119G HITACHI                  │
e76f14
e76f14
 
e76f14
 Normally you would want to convert all hard disks.  If you want
e76f14
-- 
e76f14
1.8.3.1
e76f14