[gparted] Improve feedback when creating or pasting partition (#579266)



commit 73471032c9dd2401f3155dd604260c7180f8238f
Author: Curtis Gedak <gedakc gmail com>
Date:   Sat Oct 24 14:16:40 2009 -0600

    Improve feedback when creating or pasting partition (#579266)
    
    Improve the feedback to the user when creating or pasting a
    partition on a device with no partition table found.
    
    Prior to this enhancement if a user tried to create or paste a
    partition onto a device with no partition table found, GParted
    would present the user with a Create Partition Table dialog.
    
    When creating a new partition this could cause confusion for
    users who were trying to format the disk.  The user could
    mistakenly believe the choice of an MS-DOS file system was being
    presented.
    
    Similarly on a paste operation it could be confusing to be
    presented with a dialog to create a partition table without any
    explanation of why a partition table was suddenly required in the
    midst of the paste operation.
    
    Neither the new partition creation, nor the partition paste
    actions were performed after the Create Partition Table dialog
    was displayed.

 include/Win_GParted.h |    1 +
 src/Win_GParted.cc    |   29 ++++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/include/Win_GParted.h b/include/Win_GParted.h
index 01ac310..b602626 100644
--- a/include/Win_GParted.h
+++ b/include/Win_GParted.h
@@ -140,6 +140,7 @@ private:
 	void menu_gparted_quit();
 	void menu_view_harddisk_info();
 	void menu_view_operations();
+	void show_disklabel_unrecognized( Glib::ustring device_name );
 	void show_help_dialog (const char *link_id);
 	void menu_help_contents();
 	void menu_help_about();
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index f065505..bb1cc95 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1204,6 +1204,26 @@ void Win_GParted::menu_view_operations()
 		close_operationslist() ;
 }
 
+void Win_GParted::show_disklabel_unrecognized ( Glib::ustring device_name )
+{
+	//Display dialog box indicating that no partition table was found on the device
+	Gtk::MessageDialog dialog( *this,
+			/*TO TRANSLATORS: looks like   No partition table found on device /dev/sda */
+			String::ucompose( _( "No partition table found on device %1" ), device_name ),
+			false,
+			Gtk::MESSAGE_INFO,
+			Gtk::BUTTONS_OK,
+			true ) ;
+	Glib::ustring tmp_msg = _( "A partition table is required before partitions can be added." ) ;
+	tmp_msg += "\n" ;
+	tmp_msg += _( "To create a new partition table choose the menu item:" ) ;
+	tmp_msg += "\n" ;
+	/*TO TRANSLATORS: this message represents the menu item Create Partition Table under the Device menu. */
+	tmp_msg += _( "Device --> Create Partition Table." ) ;
+	dialog .set_secondary_text( tmp_msg ) ;
+	dialog .run() ;
+}
+
 void Win_GParted::show_help_dialog (const char *link_id /* For context sensitive help */)
 {
 /* Original concept for show_help_dialog is from file-roller project
@@ -1435,9 +1455,7 @@ void Win_GParted::activate_paste()
 	//if max_prims == -1 the current device has an unrecognised disklabel (see also GParted_Core::get_devices)
 	if ( devices [ current_device ] .max_prims == -1 )
 	{
-		//FIXME: actually we should proceed with pasting after the new disklabel is set.
-		//(the same goes when creating a new partition on a disk without disklabel)
-		activate_disklabel() ;
+		show_disklabel_unrecognized( devices [current_device ] .get_path() ) ;
 		return ;
 	}
 
@@ -1490,8 +1508,9 @@ void Win_GParted::activate_new()
 {
 	//if max_prims == -1 the current device has an unrecognised disklabel (see also GParted_Core::get_devices)
 	if ( devices [ current_device ] .max_prims == -1 )
-		activate_disklabel() ;
-			
+	{
+		show_disklabel_unrecognized( devices [current_device ] .get_path() ) ;
+	}
 	else if ( ! max_amount_prim_reached() )
 	{	
 		Dialog_Partition_New dialog;



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