[gparted] Display more version and configuration info to stdout when starting (!34)



commit c626b4cea667751cc22b39bdae92568dbf5fa507
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sat Mar 30 11:41:54 2019 +0000

    Display more version and configuration info to stdout when starting (!34)
    
    So that we might get more information from users when helping them.
    Starting GParted from the command line now looks like this:
        # ./gpartedbin
        GParted 0.33.0-git
        configuration --enable-online-resize
        libparted 3.2
    
    Closes !34 - Display more version and configuration information

 include/GParted_Core.h |  2 ++
 src/GParted_Core.cc    | 34 +++++++++++++++++++++++++++++-----
 2 files changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index 571b14e7..e740a34d 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -30,6 +30,7 @@
 #include <vector>
 #include <fstream>
 #include <glibmm/thread.h>
+#include <glibmm/ustring.h>
 
 
 namespace GParted
@@ -42,6 +43,7 @@ public:
        GParted_Core() ;
        ~GParted_Core() ;
 
+       static Glib::ustring get_version_and_config_string();
        static void find_supported_core();
        void find_supported_filesystems() ;
        void set_user_devices( const std::vector<Glib::ustring> & user_devices ) ;
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 3528d6bf..f9f0fff8 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -33,6 +33,7 @@
 #include "Proc_Partitions_Info.h"
 #include "SWRaid_Info.h"
 #include "Utils.h"
+#include "../config.h"
 
 #include "btrfs.h"
 #include "exfat.h"
@@ -90,11 +91,9 @@ GParted_Core::GParted_Core()
              flag ;
              flag = ped_partition_flag_next( flag ) )
                flags .push_back( flag ) ;
-       
-       //throw libpartedversion to the stdout to see which version is actually used.
-       std::cout << "======================" << std::endl ;
-       std::cout << "libparted : " << ped_get_version() << std::endl ;
-       std::cout << "======================" << std::endl ;
+
+       // Display version and configuration info when starting for command line users.
+       std::cout << get_version_and_config_string() << std::endl;
 
        find_supported_core();
 
@@ -105,6 +104,31 @@ GParted_Core::GParted_Core()
        find_supported_filesystems() ;
 }
 
+
+Glib::ustring GParted_Core::get_version_and_config_string()
+{
+       Glib::ustring str = Glib::ustring("GParted ") + VERSION + "\n";
+
+       str += "configuration";
+       bool added_config_flag = false;
+#ifdef USE_LIBPARTED_DMRAID
+       str += " --enable-libparted-dmraid";
+       added_config_flag = true;
+#endif
+#ifdef ENABLE_ONLINE_RESIZE
+       str += " --enable-online-resize";
+       added_config_flag = true;
+#endif
+       if (! added_config_flag)
+               str += " (none)";
+       str += "\n";
+
+       str += Glib::ustring("libparted ") + ped_get_version();
+
+       return str;
+}
+
+
 void GParted_Core::find_supported_core()
 {
        udevadm_found = ! Glib::find_program_in_path( "udevadm" ).empty();


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