2009-11-05 11:08:32 -07:00
/* Copyright (C) 2004 Bart
2015-02-01 13:14:05 -07:00
* Copyright ( C ) 2008 , 2009 , 2010 , 2011 , 2012 , 2013 , 2014 , 2015 Curtis Gedak
2004-09-19 14:24:53 -06:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
2014-01-23 03:59:48 -07:00
* GNU General Public License for more details .
2004-09-19 14:24:53 -06:00
*
* You should have received a copy of the GNU General Public License
2014-01-23 03:59:48 -07:00
* along with this program ; if not , see < http : //www.gnu.org/licenses/>.
2004-09-19 14:24:53 -06:00
*/
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
# include "../include/Win_GParted.h"
2006-01-24 05:31:58 -07:00
# include "../include/Dialog_Progress.h"
2009-01-06 15:22:09 -07:00
# include "../include/DialogFeatures.h"
2006-01-26 13:58:55 -07:00
# include "../include/Dialog_Disklabel.h"
2011-01-28 11:09:21 -07:00
# include "../include/Dialog_Rescue_Data.h"
2006-01-26 13:58:55 -07:00
# include "../include/Dialog_Partition_Resize_Move.h"
# include "../include/Dialog_Partition_Copy.h"
# include "../include/Dialog_Partition_New.h"
# include "../include/Dialog_Partition_Info.h"
2014-12-19 14:08:28 -07:00
# include "../include/Dialog_FileSystem_Label.h"
2014-12-12 00:00:02 -07:00
# include "../include/Dialog_Partition_Name.h"
2006-03-31 03:49:27 -07:00
# include "../include/DialogManageFlags.h"
2006-03-24 12:08:41 -07:00
# include "../include/OperationCopy.h"
2006-11-26 07:27:16 -07:00
# include "../include/OperationCheck.h"
2006-03-24 12:08:41 -07:00
# include "../include/OperationCreate.h"
# include "../include/OperationDelete.h"
# include "../include/OperationFormat.h"
# include "../include/OperationResizeMove.h"
2012-01-22 13:49:52 -07:00
# include "../include/OperationChangeUUID.h"
2014-12-19 13:41:08 -07:00
# include "../include/OperationLabelFileSystem.h"
2014-12-12 00:00:02 -07:00
# include "../include/OperationNamePartition.h"
2012-07-05 16:33:04 -06:00
# include "../include/LVM2_PV_Info.h"
2010-01-02 04:13:31 -07:00
# include "../config.h"
2004-09-19 14:24:53 -06:00
2005-11-25 15:41:49 -07:00
# include <gtkmm/aboutdialog.h>
2006-01-19 12:15:15 -07:00
# include <gtkmm/messagedialog.h>
2006-02-02 03:59:44 -07:00
# include <gtkmm/radiobuttongroup.h>
2006-02-10 15:16:31 -07:00
# include <gtkmm/main.h>
2012-07-05 16:33:04 -06:00
# include <gtkmm/separator.h>
2005-11-25 15:41:49 -07:00
2004-09-19 14:24:53 -06:00
namespace GParted
{
2009-01-06 15:22:09 -07:00
2006-02-02 06:50:37 -07:00
Win_GParted : : Win_GParted ( const std : : vector < Glib : : ustring > & user_devices )
2004-09-19 14:24:53 -06:00
{
2006-02-22 15:05:15 -07:00
copied_partition . Reset ( ) ;
2015-05-17 07:01:48 -06:00
selected_partition_ptr = NULL ;
2004-09-19 14:24:53 -06:00
new_count = 1 ;
2004-11-17 06:00:25 -07:00
current_device = 0 ;
2006-02-22 15:05:15 -07:00
OPERATIONSLIST_OPEN = true ;
2006-02-02 06:50:37 -07:00
gparted_core . set_user_devices ( user_devices ) ;
2009-01-06 15:22:09 -07:00
2006-08-20 10:51:18 -06:00
MENU_NEW = TOOLBAR_NEW =
MENU_DEL = TOOLBAR_DEL =
MENU_RESIZE_MOVE = TOOLBAR_RESIZE_MOVE =
MENU_COPY = TOOLBAR_COPY =
MENU_PASTE = TOOLBAR_PASTE =
MENU_FORMAT =
2012-06-17 05:26:49 -06:00
MENU_TOGGLE_BUSY =
2006-08-20 10:51:18 -06:00
MENU_MOUNT =
2014-12-12 00:00:02 -07:00
MENU_NAME_PARTITION =
2006-08-20 10:51:18 -06:00
MENU_FLAGS =
MENU_INFO =
2008-04-07 13:41:18 -06:00
MENU_LABEL_PARTITION =
2012-01-22 13:49:52 -07:00
MENU_CHANGE_UUID =
2006-08-20 10:51:18 -06:00
TOOLBAR_UNDO =
TOOLBAR_APPLY = - 1 ;
2004-09-19 14:24:53 -06:00
//==== GUI =========================
2004-12-17 12:45:04 -07:00
this - > set_title ( _ ( " GParted " ) ) ;
this - > set_default_size ( 775 , 500 ) ;
2009-01-06 15:22:09 -07:00
2005-12-24 16:55:54 -07:00
try
{
2013-04-24 10:50:53 -06:00
# ifdef HAVE_SET_DEFAULT_ICON_NAME
2008-09-22 16:41:49 -06:00
this - > set_default_icon_name ( " gparted " ) ;
2013-04-24 10:50:53 -06:00
# else
this - > set_icon_from_file ( GNOME_ICONDIR " /gparted.png " ) ;
# endif
2005-12-24 16:55:54 -07:00
}
catch ( Glib : : Exception & e )
2013-03-03 16:01:05 -07:00
{
2005-12-24 16:55:54 -07:00
std : : cout < < e . what ( ) < < std : : endl ;
2013-03-03 16:01:05 -07:00
}
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//Pack the main box
2009-01-06 15:22:09 -07:00
this - > add ( vbox_main ) ;
2004-09-19 14:24:53 -06:00
//menubar....
2006-02-22 15:05:15 -07:00
init_menubar ( ) ;
2004-09-19 14:24:53 -06:00
vbox_main . pack_start ( menubar_main , Gtk : : PACK_SHRINK ) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//toolbar....
2006-02-22 15:05:15 -07:00
init_toolbar ( ) ;
2004-09-19 14:24:53 -06:00
vbox_main . pack_start ( hbox_toolbar , Gtk : : PACK_SHRINK ) ;
2009-01-06 15:22:09 -07:00
2006-03-09 06:12:44 -07:00
//drawingarea_visualdisk... ( contains the visual represenation of the disks )
2009-01-06 15:22:09 -07:00
drawingarea_visualdisk . signal_partition_selected . connect (
2006-03-07 04:55:27 -07:00
sigc : : mem_fun ( this , & Win_GParted : : on_partition_selected ) ) ;
2009-01-06 15:22:09 -07:00
drawingarea_visualdisk . signal_partition_activated . connect (
2006-03-07 04:55:27 -07:00
sigc : : mem_fun ( this , & Win_GParted : : on_partition_activated ) ) ;
2009-01-06 15:22:09 -07:00
drawingarea_visualdisk . signal_popup_menu . connect (
2006-03-07 04:55:27 -07:00
sigc : : mem_fun ( this , & Win_GParted : : on_partition_popup_menu ) ) ;
2006-03-09 06:12:44 -07:00
vbox_main . pack_start ( drawingarea_visualdisk , Gtk : : PACK_SHRINK ) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//hpaned_main (NOTE: added to vpaned_main)
2006-02-22 15:05:15 -07:00
init_hpaned_main ( ) ;
2004-09-19 14:24:53 -06:00
vpaned_main . pack1 ( hpaned_main , true , true ) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//vpaned_main....
2004-12-17 12:45:04 -07:00
vbox_main . pack_start ( vpaned_main ) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//device info...
2006-02-22 15:05:15 -07:00
init_device_info ( ) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//operationslist...
2006-09-17 07:23:47 -06:00
hbox_operations . signal_undo . connect ( sigc : : mem_fun ( this , & Win_GParted : : activate_undo ) ) ;
hbox_operations . signal_clear . connect ( sigc : : mem_fun ( this , & Win_GParted : : clear_operationslist ) ) ;
hbox_operations . signal_apply . connect ( sigc : : mem_fun ( this , & Win_GParted : : activate_apply ) ) ;
hbox_operations . signal_close . connect ( sigc : : mem_fun ( this , & Win_GParted : : close_operationslist ) ) ;
2004-09-19 14:24:53 -06:00
vpaned_main . pack2 ( hbox_operations , true , true ) ;
2006-09-17 07:23:47 -06:00
2009-01-06 15:22:09 -07:00
//statusbar...
2006-01-07 14:23:09 -07:00
pulsebar . set_pulse_step ( 0.01 ) ;
statusbar . add ( pulsebar ) ;
2004-10-11 08:19:56 -06:00
vbox_main . pack_start ( statusbar , Gtk : : PACK_SHRINK ) ;
2009-01-06 15:22:09 -07:00
2006-02-22 15:05:15 -07:00
this - > show_all_children ( ) ;
2009-01-06 15:22:09 -07:00
2006-02-22 15:05:15 -07:00
//make sure harddisk information is closed..
hpaned_main . get_child1 ( ) - > hide ( ) ;
2004-09-19 14:24:53 -06:00
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : init_menubar ( )
2004-09-19 14:24:53 -06:00
{
2009-01-06 15:22:09 -07:00
//fill menubar_main and connect callbacks
2004-09-19 14:24:53 -06:00
//gparted
2006-02-22 15:05:15 -07:00
menu = manage ( new Gtk : : Menu ( ) ) ;
2004-09-19 14:24:53 -06:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : REFRESH , Gtk : : ICON_SIZE_MENU ) ) ;
2006-09-17 07:23:47 -06:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : ImageMenuElem (
_ ( " _Refresh Devices " ) ,
Gtk : : AccelKey ( " <control>r " ) ,
2009-01-06 15:22:09 -07:00
* image ,
2006-09-17 07:23:47 -06:00
sigc : : mem_fun ( * this , & Win_GParted : : menu_gparted_refresh_devices ) ) ) ;
2009-01-06 15:22:09 -07:00
2006-02-02 03:59:44 -07:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : HARDDISK , Gtk : : ICON_SIZE_MENU ) ) ;
2009-01-06 15:22:09 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : ImageMenuElem ( _ ( " _Devices " ) , * image ) ) ;
2006-02-22 15:05:15 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
2009-01-06 15:22:09 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : StockMenuElem (
2006-09-17 07:23:47 -06:00
Gtk : : Stock : : QUIT , sigc : : mem_fun ( * this , & Win_GParted : : menu_gparted_quit ) ) ) ;
2006-02-22 15:05:15 -07:00
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _GParted " ) , * menu ) ) ;
2009-01-06 15:22:09 -07:00
2005-11-27 12:48:00 -07:00
//edit
2006-02-22 15:05:15 -07:00
menu = manage ( new Gtk : : Menu ( ) ) ;
2009-01-06 15:22:09 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : ImageMenuElem (
_ ( " _Undo Last Operation " ) ,
2006-09-17 07:23:47 -06:00
Gtk : : AccelKey ( " <control>z " ) ,
2009-01-06 15:22:09 -07:00
* manage ( new Gtk : : Image ( Gtk : : Stock : : UNDO , Gtk : : ICON_SIZE_MENU ) ) ,
2006-09-17 07:23:47 -06:00
sigc : : mem_fun ( * this , & Win_GParted : : activate_undo ) ) ) ;
2009-01-06 15:22:09 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : ImageMenuElem (
_ ( " _Clear All Operations " ) ,
* manage ( new Gtk : : Image ( Gtk : : Stock : : CLEAR , Gtk : : ICON_SIZE_MENU ) ) ,
2006-09-17 07:23:47 -06:00
sigc : : mem_fun ( * this , & Win_GParted : : clear_operationslist ) ) ) ;
2009-01-06 15:22:09 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : ImageMenuElem (
2013-01-20 21:20:11 -07:00
_ ( " _Apply All Operations " ) ,
Gtk : : AccelKey ( GDK_Return , Gdk : : CONTROL_MASK ) ,
2009-01-06 15:22:09 -07:00
* manage ( new Gtk : : Image ( Gtk : : Stock : : APPLY , Gtk : : ICON_SIZE_MENU ) ) ,
2006-09-17 07:23:47 -06:00
sigc : : mem_fun ( * this , & Win_GParted : : activate_apply ) ) ) ;
2006-02-22 15:05:15 -07:00
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _Edit " ) , * menu ) ) ;
2008-08-05 09:34:10 -06:00
2004-09-27 14:12:47 -06:00
//view
2006-04-05 03:33:04 -06:00
menu = manage ( new Gtk : : Menu ( ) ) ;
2006-09-17 07:23:47 -06:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : CheckMenuElem (
_ ( " Device _Information " ) , sigc : : mem_fun ( * this , & Win_GParted : : menu_view_harddisk_info ) ) ) ;
2009-01-06 15:22:09 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : CheckMenuElem (
2006-09-17 07:23:47 -06:00
_ ( " Pending _Operations " ) , sigc : : mem_fun ( * this , & Win_GParted : : menu_view_operations ) ) ) ;
2006-02-22 15:05:15 -07:00
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _View " ) , * menu ) ) ;
2008-08-05 09:34:10 -06:00
2008-11-14 12:41:14 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem (
_ ( " _File System Support " ) , sigc : : mem_fun ( * this , & Win_GParted : : menu_gparted_features ) ) ) ;
2005-01-30 07:31:29 -07:00
//device
2006-02-22 15:05:15 -07:00
menu = manage ( new Gtk : : Menu ( ) ) ;
2009-01-13 11:14:20 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( Glib : : ustring ( _ ( " _Create Partition Table " ) ) + " ... " ,
2006-08-28 14:11:58 -06:00
sigc : : mem_fun ( * this , & Win_GParted : : activate_disklabel ) ) ) ;
2011-01-28 11:09:21 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( Glib : : ustring ( _ ( " _Attempt Data Rescue " ) ) + " ... " ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_attempt_rescue_data ) ) ) ;
2006-02-22 15:05:15 -07:00
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _Device " ) , * menu ) ) ;
2008-08-05 09:34:10 -06:00
2005-01-30 07:31:29 -07:00
//partition
2006-02-22 15:05:15 -07:00
init_partition_menu ( ) ;
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _Partition " ) , menu_partition ) ) ;
2008-08-05 09:34:10 -06:00
2004-09-19 14:24:53 -06:00
//help
menu = manage ( new Gtk : : Menu ( ) ) ;
2009-01-06 15:22:09 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : ImageMenuElem (
_ ( " _Contents " ) ,
2008-08-05 09:34:10 -06:00
Gtk : : AccelKey ( " F1 " ) ,
2009-01-06 15:22:09 -07:00
* manage ( new Gtk : : Image ( Gtk : : Stock : : HELP , Gtk : : ICON_SIZE_MENU ) ) ,
2008-08-05 09:34:10 -06:00
sigc : : mem_fun ( * this , & Win_GParted : : menu_help_contents ) ) ) ;
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
2006-09-17 07:23:47 -06:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : StockMenuElem (
Gtk : : Stock : : ABOUT , sigc : : mem_fun ( * this , & Win_GParted : : menu_help_about ) ) ) ;
2005-11-25 15:41:49 -07:00
2006-02-22 15:05:15 -07:00
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _Help " ) , * menu ) ) ;
2004-09-19 14:24:53 -06:00
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : init_toolbar ( )
2004-09-19 14:24:53 -06:00
{
2006-08-20 10:51:18 -06:00
int index = 0 ;
2009-01-06 15:22:09 -07:00
//initialize and pack toolbar_main
2004-09-19 14:24:53 -06:00
hbox_toolbar . pack_start ( toolbar_main ) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//NEW and DELETE
2010-02-22 10:30:14 -07:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : NEW , Gtk : : ICON_SIZE_BUTTON ) ) ;
/*TO TRANSLATORS: "New" is a tool bar item for partition actions. */
Glib : : ustring str_temp = _ ( " New " ) ;
toolbutton = Gtk : : manage ( new Gtk : : ToolButton ( * image , str_temp ) ) ;
2006-08-20 10:51:18 -06:00
toolbutton - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : activate_new ) ) ;
toolbar_main . append ( * toolbutton ) ;
TOOLBAR_NEW = index + + ;
2009-01-06 15:22:09 -07:00
toolbutton - > set_tooltip ( tooltips , _ ( " Create a new partition in the selected unallocated space " ) ) ;
2004-09-19 14:24:53 -06:00
toolbutton = Gtk : : manage ( new Gtk : : ToolButton ( Gtk : : Stock : : DELETE ) ) ;
2006-02-02 03:59:44 -07:00
toolbutton - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : activate_delete ) ) ;
toolbar_main . append ( * toolbutton ) ;
2006-08-20 10:51:18 -06:00
TOOLBAR_DEL = index + + ;
2009-01-06 15:22:09 -07:00
toolbutton - > set_tooltip ( tooltips , _ ( " Delete the selected partition " ) ) ;
2004-09-19 14:24:53 -06:00
toolbar_main . append ( * ( Gtk : : manage ( new Gtk : : SeparatorToolItem ) ) ) ;
2006-08-20 10:51:18 -06:00
index + + ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//RESIZE/MOVE
image = manage ( new Gtk : : Image ( Gtk : : Stock : : GOTO_LAST , Gtk : : ICON_SIZE_BUTTON ) ) ;
2010-02-22 10:30:14 -07:00
str_temp = _ ( " Resize/Move " ) ;
2008-11-19 13:17:32 -07:00
//Condition string split and Undo button.
// for longer translated string, split string in two and skip the Undo button to permit full toolbar to display
// FIXME: Is there a better way to do this, perhaps without the conditional? At the moment this seems to be the best compromise.
bool display_undo = true ;
if ( str_temp . length ( ) > 14 ) {
2009-02-09 10:58:42 -07:00
size_t index = str_temp . find ( " / " ) ;
if ( index ! = Glib : : ustring : : npos ) {
str_temp . replace ( index , 1 , " \n / " ) ;
display_undo = false ;
}
2008-11-19 13:17:32 -07:00
}
toolbutton = Gtk : : manage ( new Gtk : : ToolButton ( * image , str_temp ) ) ;
2006-02-02 03:59:44 -07:00
toolbutton - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : activate_resize ) ) ;
toolbar_main . append ( * toolbutton ) ;
2006-08-20 10:51:18 -06:00
TOOLBAR_RESIZE_MOVE = index + + ;
2009-01-06 15:22:09 -07:00
toolbutton - > set_tooltip ( tooltips , _ ( " Resize/Move the selected partition " ) ) ;
2004-09-19 14:24:53 -06:00
toolbar_main . append ( * ( Gtk : : manage ( new Gtk : : SeparatorToolItem ) ) ) ;
2006-08-20 10:51:18 -06:00
index + + ;
2004-09-19 14:24:53 -06:00
//COPY and PASTE
toolbutton = Gtk : : manage ( new Gtk : : ToolButton ( Gtk : : Stock : : COPY ) ) ;
2006-02-02 03:59:44 -07:00
toolbutton - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : activate_copy ) ) ;
toolbar_main . append ( * toolbutton ) ;
2006-08-20 10:51:18 -06:00
TOOLBAR_COPY = index + + ;
2009-01-06 15:22:09 -07:00
toolbutton - > set_tooltip ( tooltips , _ ( " Copy the selected partition to the clipboard " ) ) ;
2004-09-19 14:24:53 -06:00
toolbutton = Gtk : : manage ( new Gtk : : ToolButton ( Gtk : : Stock : : PASTE ) ) ;
2006-02-02 03:59:44 -07:00
toolbutton - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : activate_paste ) ) ;
toolbar_main . append ( * toolbutton ) ;
2006-08-20 10:51:18 -06:00
TOOLBAR_PASTE = index + + ;
2009-01-06 15:22:09 -07:00
toolbutton - > set_tooltip ( tooltips , _ ( " Paste the partition from the clipboard " ) ) ;
2004-09-19 14:24:53 -06:00
toolbar_main . append ( * ( Gtk : : manage ( new Gtk : : SeparatorToolItem ) ) ) ;
2006-08-20 10:51:18 -06:00
index + + ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//UNDO and APPLY
2008-11-19 13:17:32 -07:00
if ( display_undo ) {
//Undo button is displayed only if translated language "Resize/Move" is not too long. See above setting of this condition.
toolbutton = Gtk : : manage ( new Gtk : : ToolButton ( Gtk : : Stock : : UNDO ) ) ;
toolbutton - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : activate_undo ) ) ;
toolbar_main . append ( * toolbutton ) ;
TOOLBAR_UNDO = index + + ;
toolbutton - > set_sensitive ( false ) ;
toolbutton - > set_tooltip ( tooltips , _ ( " Undo Last Operation " ) ) ;
}
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
toolbutton = Gtk : : manage ( new Gtk : : ToolButton ( Gtk : : Stock : : APPLY ) ) ;
2006-02-02 03:59:44 -07:00
toolbutton - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : activate_apply ) ) ;
toolbar_main . append ( * toolbutton ) ;
2006-08-20 10:51:18 -06:00
TOOLBAR_APPLY = index + + ;
2006-02-02 03:59:44 -07:00
toolbutton - > set_sensitive ( false ) ;
2009-01-06 15:22:09 -07:00
toolbutton - > set_tooltip ( tooltips , _ ( " Apply All Operations " ) ) ;
2005-12-29 16:35:37 -07:00
//initialize and pack combo_devices
liststore_devices = Gtk : : ListStore : : create ( treeview_devices_columns ) ;
combo_devices . set_model ( liststore_devices ) ;
2005-12-30 11:11:03 -07:00
combo_devices . pack_start ( treeview_devices_columns . icon , false ) ;
2005-12-29 16:35:37 -07:00
combo_devices . pack_start ( treeview_devices_columns . device ) ;
2005-12-30 11:11:03 -07:00
combo_devices . pack_start ( treeview_devices_columns . size , false ) ;
2009-01-06 15:22:09 -07:00
Prevent flashing redraw of the devices combobox (#696149)
The device combobox was getting drawn blank, then getting drawn again
with the selected device. This was happening because at the start of
Win_GParted::refresh_combo_devices() the GTK model behind the combobox,
liststore_devices, was cleared, changing the active item, causing the
combobox to get redrawn empty. After the GTK model had been repopulated
the active item was reset causing the comboxbox to get redrawn again,
now showing the selected device. Call flow:
Win_GParted::refresh_combo_devices()
liststore_devices->clear()
//Gtk::Combobox emits signal_change. Registered callbacks
//called.
Win_GParted::combo_devices_changed()
Win_GParted::Refresh_Visual()
...
...
combo_devices.set_active(current_device);
//Gtk::Combobox emits signal_change. Registered callbacks
//called.
Win_GParted::combo_devices_changed()
Win_GParted::Refresh_Visual()
...
This has always been the case, since the device combobox was first added
to GParted before version 0.1 by commit:
3a4b43e0adb3974dea656fcbe90d5e191e0e9784
replaced deprecated OptionMenu with ComboBox ...
Fix by temporarily blocking the devices comboxbox from emitting
signal_changed while the GTK model behind the combobox is recreated.
However, since automatic selection of the largest free space was added
[1] in GParted 0.15.0, a more noticeable flashing redraw issue was
caused in which the partition graphic and partition list were both drawn
blank then redrawn fully populated. Some distributions were not
affected by this at all, some only experienced a single flash and others
suffered from two or more flashing redraws. Some affected
distributions: CentOS 5.10, 6.5, 7.0, Debian 6, Fedora 14, 19, 20,
Ubuntu 13.10, Xubuntu 14.04 LTS. Did not occur on Kubuntu 12.04 LTS.
[1] 5b53c12f6ee12312a9bacb44b8b05b12a540d3d6
Select largest unallocated partition by default (#667365)
Bug #696149 - Double refresh of display introduced with default
unallocated space
2014-08-22 04:35:39 -06:00
combo_devices_changed_connection =
combo_devices . signal_changed ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : combo_devices_changed ) ) ;
2005-12-29 16:35:37 -07:00
hbox_toolbar . pack_start ( combo_devices , Gtk : : PACK_SHRINK ) ;
2004-09-19 14:24:53 -06:00
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : init_partition_menu ( )
2004-09-19 14:24:53 -06:00
{
2006-08-20 10:51:18 -06:00
int index = 0 ;
2012-01-27 12:41:31 -07:00
2005-01-30 07:31:29 -07:00
//fill menu_partition
2010-02-22 10:30:14 -07:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : NEW , Gtk : : ICON_SIZE_MENU ) ) ;
2009-01-06 15:22:09 -07:00
menu_partition . items ( ) . push_back (
2010-02-22 10:30:14 -07:00
/*TO TRANSLATORS: "_New" is a sub menu item for the partition menu. */
2013-01-20 20:52:52 -07:00
Gtk : : Menu_Helpers : : ImageMenuElem ( _ ( " _New " ) ,
Gtk : : AccelKey ( GDK_Insert , Gdk : : BUTTON1_MASK ) ,
* image ,
2006-01-02 08:18:29 -07:00
sigc : : mem_fun ( * this , & Win_GParted : : activate_new ) ) ) ;
2006-08-20 10:51:18 -06:00
MENU_NEW = index + + ;
2009-01-06 15:22:09 -07:00
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : DELETE ,
2006-01-02 08:18:29 -07:00
Gtk : : AccelKey ( GDK_Delete , Gdk : : BUTTON1_MASK ) ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_delete ) ) ) ;
2006-08-20 10:51:18 -06:00
MENU_DEL = index + + ;
2006-01-02 08:18:29 -07:00
menu_partition . items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
2006-08-20 10:51:18 -06:00
index + + ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : GOTO_LAST , Gtk : : ICON_SIZE_MENU ) ) ;
2009-01-06 15:22:09 -07:00
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : ImageMenuElem ( _ ( " _Resize/Move " ) ,
* image ,
2006-01-02 08:18:29 -07:00
sigc : : mem_fun ( * this , & Win_GParted : : activate_resize ) ) ) ;
2006-08-20 10:51:18 -06:00
MENU_RESIZE_MOVE = index + + ;
2009-01-06 15:22:09 -07:00
2006-01-02 08:18:29 -07:00
menu_partition . items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
2006-08-20 10:51:18 -06:00
index + + ;
2009-01-06 15:22:09 -07:00
menu_partition . items ( ) . push_back (
2006-01-02 08:18:29 -07:00
Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : COPY ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_copy ) ) ) ;
2006-08-20 10:51:18 -06:00
MENU_COPY = index + + ;
2009-01-06 15:22:09 -07:00
menu_partition . items ( ) . push_back (
2006-01-02 08:18:29 -07:00
Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : PASTE ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_paste ) ) ) ;
2006-08-20 10:51:18 -06:00
MENU_PASTE = index + + ;
2009-01-06 15:22:09 -07:00
2006-01-02 08:18:29 -07:00
menu_partition . items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
2006-08-20 10:51:18 -06:00
index + + ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : CONVERT , Gtk : : ICON_SIZE_MENU ) ) ;
2008-11-18 16:58:17 -07:00
/*TO TRANSLATORS: menuitem which holds a submenu with file systems.. */
2006-01-02 08:18:29 -07:00
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : ImageMenuElem ( _ ( " _Format to " ) ,
* image ,
* create_format_menu ( ) ) ) ;
2006-08-20 10:51:18 -06:00
MENU_FORMAT = index + + ;
2009-01-06 15:22:09 -07:00
2006-08-20 10:51:18 -06:00
menu_partition . items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
index + + ;
2009-01-06 15:22:09 -07:00
2006-01-02 08:18:29 -07:00
menu_partition . items ( ) . push_back (
2012-01-27 12:41:31 -07:00
//This is a placeholder text. It will be replaced with some other text before it is used
Gtk : : Menu_Helpers : : MenuElem ( " --placeholder-- " ,
2012-06-17 05:26:49 -06:00
sigc : : mem_fun ( * this , & Win_GParted : : toggle_busy_state ) ) ) ;
MENU_TOGGLE_BUSY = index + + ;
2008-11-18 16:58:17 -07:00
/*TO TRANSLATORS: menuitem which holds a submenu with mount points.. */
2006-03-16 10:09:17 -07:00
menu_partition . items ( ) . push_back (
2006-08-28 14:11:58 -06:00
Gtk : : Menu_Helpers : : MenuElem ( _ ( " _Mount on " ) , * manage ( new Gtk : : Menu ( ) ) ) ) ;
2006-08-20 10:51:18 -06:00
MENU_MOUNT = index + + ;
2006-03-16 10:09:17 -07:00
2006-03-31 03:49:27 -07:00
menu_partition . items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
2006-08-20 10:51:18 -06:00
index + + ;
2006-03-31 03:49:27 -07:00
2014-12-12 00:00:02 -07:00
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : MenuElem ( _ ( " _Name Partition " ) ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_name_partition ) ) ) ;
MENU_NAME_PARTITION = index + + ;
2006-03-31 03:49:27 -07:00
menu_partition . items ( ) . push_back (
2006-08-28 14:11:58 -06:00
Gtk : : Menu_Helpers : : MenuElem ( _ ( " M_anage Flags " ) ,
2006-03-31 03:49:27 -07:00
sigc : : mem_fun ( * this , & Win_GParted : : activate_manage_flags ) ) ) ;
2006-08-20 10:51:18 -06:00
MENU_FLAGS = index + + ;
2006-03-31 03:49:27 -07:00
2006-11-26 07:27:16 -07:00
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : MenuElem ( _ ( " C_heck " ) ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_check ) ) ) ;
MENU_CHECK = index + + ;
2008-04-07 13:41:18 -06:00
menu_partition . items ( ) . push_back (
2014-12-15 16:20:12 -07:00
Gtk : : Menu_Helpers : : MenuElem ( _ ( " _Label File System " ) ,
2014-12-18 15:18:33 -07:00
sigc : : mem_fun ( * this , & Win_GParted : : activate_label_filesystem ) ) ) ;
2008-04-07 13:41:18 -06:00
MENU_LABEL_PARTITION = index + + ;
2012-01-22 13:49:52 -07:00
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : MenuElem ( _ ( " New UU_ID " ) ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_change_uuid ) ) ) ;
MENU_CHANGE_UUID = index + + ;
2006-03-31 03:49:27 -07:00
menu_partition . items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
2006-08-20 10:51:18 -06:00
index + + ;
2009-01-06 15:22:09 -07:00
menu_partition . items ( ) . push_back (
2006-01-02 08:18:29 -07:00
Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : DIALOG_INFO ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_info ) ) ) ;
2006-08-20 10:51:18 -06:00
MENU_INFO = index + + ;
2009-01-06 15:22:09 -07:00
menu_partition . accelerate ( * this ) ;
2004-09-19 14:24:53 -06:00
}
2012-12-07 14:30:15 -07:00
//Create the Partition --> Format to --> (file system list) menu
2006-01-02 08:18:29 -07:00
Gtk : : Menu * Win_GParted : : create_format_menu ( )
2004-09-19 14:24:53 -06:00
{
2012-12-07 14:30:15 -07:00
const std : : vector < FS > & fss = gparted_core . get_filesystems ( ) ;
2006-01-02 08:18:29 -07:00
menu = manage ( new Gtk : : Menu ( ) ) ;
2012-12-07 14:30:15 -07:00
for ( unsigned int t = 0 ; t < fss . size ( ) ; t + + )
2004-09-19 14:24:53 -06:00
{
2014-10-11 13:58:18 -06:00
if ( GParted_Core : : supported_filesystem ( fss [ t ] . filesystem ) )
create_format_menu_add_item ( fss [ t ] . filesystem , fss [ t ] . create ) ;
2004-09-19 14:24:53 -06:00
}
2012-12-08 12:41:00 -07:00
//Add cleared at the end of the list
create_format_menu_add_item ( FS_CLEARED , true ) ;
2012-12-07 14:30:15 -07:00
2006-01-02 08:18:29 -07:00
return menu ;
2004-09-19 14:24:53 -06:00
}
2012-12-07 14:30:15 -07:00
//Add one entry to the Partition --> Format to --> (file system list) menu
void Win_GParted : : create_format_menu_add_item ( FILESYSTEM filesystem , bool activate )
{
hbox = manage ( new Gtk : : HBox ( ) ) ;
//the colored square
hbox - > pack_start ( * manage ( new Gtk : : Image ( Utils : : get_color_as_pixbuf ( filesystem , 16 , 16 ) ) ) ,
Gtk : : PACK_SHRINK ) ;
//the label...
hbox - > pack_start ( * Utils : : mk_label ( " " + Utils : : get_filesystem_string ( filesystem ) ) ,
Gtk : : PACK_SHRINK ) ;
menu - > items ( ) . push_back ( * manage ( new Gtk : : MenuItem ( * hbox ) ) ) ;
if ( activate )
menu - > items ( ) . back ( ) . signal_activate ( ) . connect (
sigc : : bind < GParted : : FILESYSTEM > ( sigc : : mem_fun ( * this , & Win_GParted : : activate_format ) ,
filesystem ) ) ;
else
menu - > items ( ) . back ( ) . set_sensitive ( false ) ;
}
2004-09-19 14:24:53 -06:00
void Win_GParted : : init_device_info ( )
{
2004-09-25 15:59:53 -06:00
vbox_info . set_spacing ( 5 ) ;
2006-03-28 05:40:29 -07:00
int top = 0 , bottom = 1 ;
2009-01-06 15:22:09 -07:00
2004-09-25 15:59:53 -06:00
//title
2009-01-06 15:22:09 -07:00
vbox_info . pack_start (
2009-12-06 14:36:39 -07:00
* Utils : : mk_label ( " <b> " + static_cast < Glib : : ustring > ( _ ( " Device Information " ) ) + " </b> " ) ,
2006-03-28 05:40:29 -07:00
Gtk : : PACK_SHRINK ) ;
2009-01-06 15:22:09 -07:00
2004-09-29 06:33:40 -06:00
//GENERAL DEVICE INFO
2004-09-19 14:24:53 -06:00
table = manage ( new Gtk : : Table ( ) ) ;
2004-09-29 06:33:40 -06:00
table - > set_col_spacings ( 10 ) ;
2009-01-06 15:22:09 -07:00
2004-09-29 06:33:40 -06:00
//model
2006-03-28 05:40:29 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + static_cast < Glib : : ustring > ( _ ( " Model: " ) ) + " </b> " ) ,
0 , 1 ,
top , bottom ,
Gtk : : FILL ) ;
2013-10-16 15:44:03 -06:00
device_info . push_back ( Utils : : mk_label ( " " , true , false , true ) ) ;
2006-03-28 05:40:29 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2009-01-06 15:22:09 -07:00
2004-09-29 06:33:40 -06:00
//size
2006-03-28 05:40:29 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + static_cast < Glib : : ustring > ( _ ( " Size: " ) ) + " </b> " ) ,
0 , 1 ,
top , bottom ,
Gtk : : FILL ) ;
2013-10-16 15:44:03 -06:00
device_info . push_back ( Utils : : mk_label ( " " , true , false , true ) ) ;
2006-03-28 05:40:29 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2009-01-06 15:22:09 -07:00
2004-09-29 06:33:40 -06:00
//path
2013-10-16 15:44:03 -06:00
table - > attach ( * Utils : : mk_label ( " <b> " + static_cast < Glib : : ustring > ( _ ( " Path: " ) ) + " </b> " ) ,
2006-03-28 05:40:29 -07:00
0 , 1 ,
top , bottom ,
Gtk : : FILL ) ;
2013-10-16 15:44:03 -06:00
device_info . push_back ( Utils : : mk_label ( " " , true , false , true ) ) ;
2006-03-28 05:40:29 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2009-01-06 15:22:09 -07:00
2004-09-25 15:59:53 -06:00
vbox_info . pack_start ( * table , Gtk : : PACK_SHRINK ) ;
2009-01-06 15:22:09 -07:00
//DETAILED DEVICE INFO
2006-03-28 05:40:29 -07:00
top = 0 ; bottom = 1 ;
table = manage ( new Gtk : : Table ( ) ) ;
2004-12-27 05:08:01 -07:00
table - > set_col_spacings ( 10 ) ;
2009-01-06 15:22:09 -07:00
2004-09-29 06:33:40 -06:00
//one blank line
2005-12-13 14:30:13 -07:00
table - > attach ( * Utils : : mk_label ( " " ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2009-01-06 15:22:09 -07:00
2004-09-29 06:33:40 -06:00
//disktype
2009-12-06 14:32:12 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + static_cast < Glib : : ustring > ( _ ( " Partition table: " ) ) + " </b> " ) ,
2006-03-28 05:40:29 -07:00
0 , 1 ,
top , bottom ,
Gtk : : FILL ) ;
2013-10-16 15:44:03 -06:00
device_info . push_back ( Utils : : mk_label ( " " , true , false , true ) ) ;
2006-03-28 05:40:29 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2009-01-06 15:22:09 -07:00
2004-09-29 06:33:40 -06:00
//heads
2006-03-28 05:40:29 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + static_cast < Glib : : ustring > ( _ ( " Heads: " ) ) + " </b> " ) ,
0 , 1 ,
top , bottom ,
Gtk : : FILL ) ;
2013-10-16 15:44:03 -06:00
device_info . push_back ( Utils : : mk_label ( " " , true , false , true ) ) ;
2006-03-28 05:40:29 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2009-01-06 15:22:09 -07:00
2004-09-29 06:33:40 -06:00
//sectors/track
2009-12-06 14:36:39 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + static_cast < Glib : : ustring > ( _ ( " Sectors/track: " ) ) + " </b> " ) ,
2006-03-28 05:40:29 -07:00
0 , 1 ,
top , bottom ,
Gtk : : FILL ) ;
2013-10-16 15:44:03 -06:00
device_info . push_back ( Utils : : mk_label ( " " , true , false , true ) ) ;
2006-03-28 05:40:29 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2009-01-06 15:22:09 -07:00
2004-09-29 06:33:40 -06:00
//cylinders
2006-03-28 05:40:29 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + static_cast < Glib : : ustring > ( _ ( " Cylinders: " ) ) + " </b> " ) ,
0 , 1 ,
top , bottom ,
Gtk : : FILL ) ;
2013-10-16 15:44:03 -06:00
device_info . push_back ( Utils : : mk_label ( " " , true , false , true ) ) ;
2006-03-28 05:40:29 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2009-01-06 15:22:09 -07:00
2004-09-29 06:33:40 -06:00
//total sectors
2009-12-06 14:36:39 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + static_cast < Glib : : ustring > ( _ ( " Total sectors: " ) ) + " </b> " ) ,
2006-03-28 05:40:29 -07:00
0 , 1 ,
top , bottom ,
Gtk : : FILL ) ;
2013-10-16 15:44:03 -06:00
device_info . push_back ( Utils : : mk_label ( " " , true , false , true ) ) ;
2006-03-28 05:40:29 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2010-02-20 15:12:26 -07:00
//sector size
table - > attach ( * Utils : : mk_label ( " <b> " + static_cast < Glib : : ustring > ( _ ( " Sector size: " ) ) + " </b> " ) ,
0 , 1 ,
top , bottom ,
Gtk : : FILL ) ;
2013-10-16 15:44:03 -06:00
device_info . push_back ( Utils : : mk_label ( " " , true , false , true ) ) ;
2010-02-20 15:12:26 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2004-09-25 15:59:53 -06:00
vbox_info . pack_start ( * table , Gtk : : PACK_SHRINK ) ;
2004-09-19 14:24:53 -06:00
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : init_hpaned_main ( )
2004-09-19 14:24:53 -06:00
{
//left scrollwindow (holds device info)
2006-09-17 07:23:47 -06:00
scrollwindow = manage ( new Gtk : : ScrolledWindow ( ) ) ;
2004-12-27 05:08:01 -07:00
scrollwindow - > set_shadow_type ( Gtk : : SHADOW_ETCHED_IN ) ;
scrollwindow - > set_policy ( Gtk : : POLICY_AUTOMATIC , Gtk : : POLICY_AUTOMATIC ) ;
2004-09-19 14:24:53 -06:00
2006-09-17 07:23:47 -06:00
hpaned_main . pack1 ( * scrollwindow , true , true ) ;
2004-09-19 14:24:53 -06:00
scrollwindow - > add ( vbox_info ) ;
//right scrollwindow (holds treeview with partitions)
2006-09-17 07:23:47 -06:00
scrollwindow = manage ( new Gtk : : ScrolledWindow ( ) ) ;
2004-12-27 05:08:01 -07:00
scrollwindow - > set_shadow_type ( Gtk : : SHADOW_ETCHED_IN ) ;
scrollwindow - > set_policy ( Gtk : : POLICY_AUTOMATIC , Gtk : : POLICY_AUTOMATIC ) ;
2009-01-06 15:22:09 -07:00
2005-12-23 17:06:05 -07:00
//connect signals and add treeview_detail
treeview_detail . signal_partition_selected . connect ( sigc : : mem_fun ( this , & Win_GParted : : on_partition_selected ) ) ;
treeview_detail . signal_partition_activated . connect ( sigc : : mem_fun ( this , & Win_GParted : : on_partition_activated ) ) ;
treeview_detail . signal_popup_menu . connect ( sigc : : mem_fun ( this , & Win_GParted : : on_partition_popup_menu ) ) ;
2004-12-27 05:08:01 -07:00
scrollwindow - > add ( treeview_detail ) ;
2006-09-17 07:23:47 -06:00
hpaned_main . pack2 ( * scrollwindow , true , true ) ;
2004-09-19 14:24:53 -06:00
}
2005-12-29 16:35:37 -07:00
void Win_GParted : : refresh_combo_devices ( )
2004-10-11 04:23:24 -06:00
{
Prevent flashing redraw of the devices combobox (#696149)
The device combobox was getting drawn blank, then getting drawn again
with the selected device. This was happening because at the start of
Win_GParted::refresh_combo_devices() the GTK model behind the combobox,
liststore_devices, was cleared, changing the active item, causing the
combobox to get redrawn empty. After the GTK model had been repopulated
the active item was reset causing the comboxbox to get redrawn again,
now showing the selected device. Call flow:
Win_GParted::refresh_combo_devices()
liststore_devices->clear()
//Gtk::Combobox emits signal_change. Registered callbacks
//called.
Win_GParted::combo_devices_changed()
Win_GParted::Refresh_Visual()
...
...
combo_devices.set_active(current_device);
//Gtk::Combobox emits signal_change. Registered callbacks
//called.
Win_GParted::combo_devices_changed()
Win_GParted::Refresh_Visual()
...
This has always been the case, since the device combobox was first added
to GParted before version 0.1 by commit:
3a4b43e0adb3974dea656fcbe90d5e191e0e9784
replaced deprecated OptionMenu with ComboBox ...
Fix by temporarily blocking the devices comboxbox from emitting
signal_changed while the GTK model behind the combobox is recreated.
However, since automatic selection of the largest free space was added
[1] in GParted 0.15.0, a more noticeable flashing redraw issue was
caused in which the partition graphic and partition list were both drawn
blank then redrawn fully populated. Some distributions were not
affected by this at all, some only experienced a single flash and others
suffered from two or more flashing redraws. Some affected
distributions: CentOS 5.10, 6.5, 7.0, Debian 6, Fedora 14, 19, 20,
Ubuntu 13.10, Xubuntu 14.04 LTS. Did not occur on Kubuntu 12.04 LTS.
[1] 5b53c12f6ee12312a9bacb44b8b05b12a540d3d6
Select largest unallocated partition by default (#667365)
Bug #696149 - Double refresh of display introduced with default
unallocated space
2014-08-22 04:35:39 -06:00
// Temporarily block the on change callback while re-creating the device list
// behind the combobox to prevent flashing redraw by being redrawn with an empty
// device list.
combo_devices_changed_connection . block ( ) ;
2005-12-29 16:35:37 -07:00
liststore_devices - > clear ( ) ;
2009-01-06 15:22:09 -07:00
2006-02-02 03:59:44 -07:00
menu = manage ( new Gtk : : Menu ( ) ) ;
Gtk : : RadioButtonGroup radio_group ;
2009-01-06 15:22:09 -07:00
2004-12-27 05:08:01 -07:00
for ( unsigned int i = 0 ; i < devices . size ( ) ; i + + )
2006-02-02 03:59:44 -07:00
{
//combo...
2005-12-29 16:35:37 -07:00
treerow = * ( liststore_devices - > append ( ) ) ;
treerow [ treeview_devices_columns . icon ] =
render_icon ( Gtk : : Stock : : HARDDISK , Gtk : : ICON_SIZE_LARGE_TOOLBAR ) ;
2006-03-14 14:37:47 -07:00
treerow [ treeview_devices_columns . device ] = devices [ i ] . get_path ( ) ;
2010-04-26 11:42:23 -06:00
treerow [ treeview_devices_columns . size ] = " ( " + Utils : : format_size ( devices [ i ] . length , devices [ i ] . sector_size ) + " ) " ;
2009-01-06 15:22:09 -07:00
2006-02-02 03:59:44 -07:00
//devices submenu....
2006-03-20 03:12:55 -07:00
hbox = manage ( new Gtk : : HBox ( ) ) ;
2013-10-16 15:12:29 -06:00
hbox - > pack_start ( * Utils : : mk_label ( devices [ i ] . get_path ( ) ) , Gtk : : PACK_EXPAND_WIDGET ) ;
2013-10-16 15:44:03 -06:00
hbox - > pack_start ( * Utils : : mk_label ( " ( " + Utils : : format_size ( devices [ i ] . length , devices [ i ] . sector_size ) + " ) " ) ,
2013-10-16 15:12:29 -06:00
Gtk : : PACK_SHRINK ) ;
2006-03-20 03:12:55 -07:00
menu - > items ( ) . push_back ( * manage ( new Gtk : : RadioMenuItem ( radio_group ) ) ) ;
menu - > items ( ) . back ( ) . add ( * hbox ) ;
2009-01-06 15:22:09 -07:00
menu - > items ( ) . back ( ) . signal_activate ( ) . connect (
2006-03-20 03:12:55 -07:00
sigc : : bind < unsigned int > ( sigc : : mem_fun ( * this , & Win_GParted : : radio_devices_changed ) , i ) ) ;
2004-09-19 14:24:53 -06:00
}
2009-01-06 15:22:09 -07:00
2006-02-02 03:59:44 -07:00
menubar_main . items ( ) [ 0 ] . get_submenu ( ) - > items ( ) [ 1 ] . remove_submenu ( ) ;
if ( menu - > items ( ) . size ( ) )
2006-03-20 03:12:55 -07:00
{
menu - > show_all ( ) ;
2006-02-02 03:59:44 -07:00
menubar_main . items ( ) [ 0 ] . get_submenu ( ) - > items ( ) [ 1 ] . set_submenu ( * menu ) ;
2006-03-20 03:12:55 -07:00
}
Prevent flashing redraw of the devices combobox (#696149)
The device combobox was getting drawn blank, then getting drawn again
with the selected device. This was happening because at the start of
Win_GParted::refresh_combo_devices() the GTK model behind the combobox,
liststore_devices, was cleared, changing the active item, causing the
combobox to get redrawn empty. After the GTK model had been repopulated
the active item was reset causing the comboxbox to get redrawn again,
now showing the selected device. Call flow:
Win_GParted::refresh_combo_devices()
liststore_devices->clear()
//Gtk::Combobox emits signal_change. Registered callbacks
//called.
Win_GParted::combo_devices_changed()
Win_GParted::Refresh_Visual()
...
...
combo_devices.set_active(current_device);
//Gtk::Combobox emits signal_change. Registered callbacks
//called.
Win_GParted::combo_devices_changed()
Win_GParted::Refresh_Visual()
...
This has always been the case, since the device combobox was first added
to GParted before version 0.1 by commit:
3a4b43e0adb3974dea656fcbe90d5e191e0e9784
replaced deprecated OptionMenu with ComboBox ...
Fix by temporarily blocking the devices comboxbox from emitting
signal_changed while the GTK model behind the combobox is recreated.
However, since automatic selection of the largest free space was added
[1] in GParted 0.15.0, a more noticeable flashing redraw issue was
caused in which the partition graphic and partition list were both drawn
blank then redrawn fully populated. Some distributions were not
affected by this at all, some only experienced a single flash and others
suffered from two or more flashing redraws. Some affected
distributions: CentOS 5.10, 6.5, 7.0, Debian 6, Fedora 14, 19, 20,
Ubuntu 13.10, Xubuntu 14.04 LTS. Did not occur on Kubuntu 12.04 LTS.
[1] 5b53c12f6ee12312a9bacb44b8b05b12a540d3d6
Select largest unallocated partition by default (#667365)
Bug #696149 - Double refresh of display introduced with default
unallocated space
2014-08-22 04:35:39 -06:00
combo_devices_changed_connection . unblock ( ) ;
2005-12-29 16:35:37 -07:00
combo_devices . set_active ( current_device ) ;
2004-10-11 04:23:24 -06:00
}
2013-01-14 19:20:49 -07:00
bool Win_GParted : : pulsebar_pulse ( )
{
pulsebar . pulse ( ) ;
Glib : : ustring tmp_msg = gparted_core . get_thread_status_message ( ) ;
if ( tmp_msg ! = " " ) {
statusbar . pop ( ) ;
statusbar . push ( tmp_msg ) ;
}
return true ;
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : show_pulsebar ( const Glib : : ustring & status_message )
2004-10-11 04:23:24 -06:00
{
2006-01-07 14:23:09 -07:00
pulsebar . show ( ) ;
2006-01-08 08:20:14 -07:00
statusbar . push ( status_message ) ;
2009-01-06 15:22:09 -07:00
2004-10-11 04:23:24 -06:00
//disable all input stuff
toolbar_main . set_sensitive ( false ) ;
menubar_main . set_sensitive ( false ) ;
2005-12-29 16:35:37 -07:00
combo_devices . set_sensitive ( false ) ;
2005-01-30 07:31:29 -07:00
menu_partition . set_sensitive ( false ) ;
2005-12-29 07:21:45 -07:00
treeview_detail . set_sensitive ( false ) ;
2006-03-09 06:12:44 -07:00
drawingarea_visualdisk . set_sensitive ( false ) ;
2009-01-06 15:22:09 -07:00
2013-01-14 19:20:49 -07:00
// connect pulse update timer
pulsetimer = Glib : : signal_timeout ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : pulsebar_pulse ) , 100 ) ;
2013-02-21 17:57:33 -07:00
}
void Win_GParted : : hide_pulsebar ( )
{
2013-01-14 19:20:49 -07:00
pulsetimer . disconnect ( ) ;
2006-01-07 14:23:09 -07:00
pulsebar . hide ( ) ;
2005-12-29 07:21:45 -07:00
statusbar . pop ( ) ;
2009-01-06 15:22:09 -07:00
2004-10-11 04:23:24 -06:00
//enable all disabled stuff
toolbar_main . set_sensitive ( true ) ;
menubar_main . set_sensitive ( true ) ;
2005-12-29 16:35:37 -07:00
combo_devices . set_sensitive ( true ) ;
2005-01-30 07:31:29 -07:00
menu_partition . set_sensitive ( true ) ;
2005-12-29 07:21:45 -07:00
treeview_detail . set_sensitive ( true ) ;
2006-03-09 06:12:44 -07:00
drawingarea_visualdisk . set_sensitive ( true ) ;
2004-09-19 14:24:53 -06:00
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : Fill_Label_Device_Info ( bool clear )
2004-09-19 14:24:53 -06:00
{
2005-02-01 10:04:03 -07:00
if ( clear )
for ( unsigned int t = 0 ; t < device_info . size ( ) ; t + + )
device_info [ t ] - > set_text ( " " ) ;
2009-01-06 15:22:09 -07:00
2005-02-01 10:04:03 -07:00
else
2009-01-06 15:22:09 -07:00
{
2005-02-01 10:04:03 -07:00
short t = 0 ;
2009-01-06 15:22:09 -07:00
2005-02-01 10:04:03 -07:00
//global info...
device_info [ t + + ] - > set_text ( devices [ current_device ] . model ) ;
2010-04-26 11:42:23 -06:00
device_info [ t + + ] - > set_text ( Utils : : format_size ( devices [ current_device ] . length , devices [ current_device ] . sector_size ) ) ;
2006-03-14 14:37:47 -07:00
device_info [ t + + ] - > set_text ( Glib : : build_path ( " \n " , devices [ current_device ] . get_paths ( ) ) ) ;
2009-01-06 15:22:09 -07:00
2005-02-01 10:04:03 -07:00
//detailed info
device_info [ t + + ] - > set_text ( devices [ current_device ] . disktype ) ;
2005-12-13 14:30:13 -07:00
device_info [ t + + ] - > set_text ( Utils : : num_to_str ( devices [ current_device ] . heads ) ) ;
device_info [ t + + ] - > set_text ( Utils : : num_to_str ( devices [ current_device ] . sectors ) ) ;
device_info [ t + + ] - > set_text ( Utils : : num_to_str ( devices [ current_device ] . cylinders ) ) ;
device_info [ t + + ] - > set_text ( Utils : : num_to_str ( devices [ current_device ] . length ) ) ;
2010-02-20 15:12:26 -07:00
device_info [ t + + ] - > set_text ( Utils : : num_to_str ( devices [ current_device ] . sector_size ) ) ;
2005-02-01 10:04:03 -07:00
}
2004-09-19 14:24:53 -06:00
}
2004-12-27 05:08:01 -07:00
bool Win_GParted : : on_delete_event ( GdkEventAny * event )
2004-09-19 14:24:53 -06:00
{
2006-03-24 12:08:41 -07:00
return ! Quit_Check_Operations ( ) ;
2009-01-06 15:22:09 -07:00
}
2004-09-19 14:24:53 -06:00
2006-08-01 14:19:17 -06:00
void Win_GParted : : Add_Operation ( Operation * operation , int index )
2004-09-19 14:24:53 -06:00
{
2006-07-20 13:14:44 -06:00
if ( operation )
2009-01-06 15:22:09 -07:00
{
2006-07-20 13:14:44 -06:00
Glib : : ustring error ;
2012-03-23 09:51:08 -06:00
//Add any of the listed operations without further checking, but
// for the other operations (_CREATE, _RESIZE_MOVE and _COPY)
// ensure the partition is correctly aligned.
2006-11-26 07:27:16 -07:00
//FIXME: this is becoming a mess.. maybe it's better to check if partition_new > 0
2010-05-20 10:00:14 -06:00
if ( operation - > type = = OPERATION_DELETE | |
operation - > type = = OPERATION_FORMAT | |
2006-11-26 07:27:16 -07:00
operation - > type = = OPERATION_CHECK | |
2012-01-22 13:49:52 -07:00
operation - > type = = OPERATION_CHANGE_UUID | |
2014-12-16 14:06:20 -07:00
operation - > type = = OPERATION_LABEL_FILESYSTEM | |
2014-12-12 00:00:02 -07:00
operation - > type = = OPERATION_NAME_PARTITION | |
2010-05-20 10:00:14 -06:00
gparted_core . snap_to_alignment ( operation - > device , operation - > partition_new , error )
)
2006-07-20 13:14:44 -06:00
{
operation - > create_description ( ) ;
if ( index > = 0 & & index < static_cast < int > ( operations . size ( ) ) )
operations . insert ( operations . begin ( ) + index , operation ) ;
else
operations . push_back ( operation ) ;
}
2006-03-24 12:08:41 -07:00
else
2006-07-20 13:14:44 -06:00
{
Gtk : : MessageDialog dialog ( * this ,
2012-07-27 05:05:49 -06:00
_ ( " Could not add this operation to the list " ) ,
2006-07-20 13:14:44 -06:00
false ,
Gtk : : MESSAGE_ERROR ,
Gtk : : BUTTONS_OK ,
true ) ;
dialog . set_secondary_text ( error ) ;
2006-03-24 12:08:41 -07:00
2006-07-20 13:14:44 -06:00
dialog . run ( ) ;
}
2006-03-24 12:08:41 -07:00
}
2004-09-19 14:24:53 -06:00
}
2011-10-13 11:26:16 -06:00
bool Win_GParted : : Merge_Operations ( unsigned int first , unsigned int second )
2011-10-05 12:15:16 -06:00
{
2011-10-13 11:26:16 -06:00
if ( first > = operations . size ( ) | | second > = operations . size ( ) )
return false ;
2011-10-05 12:15:16 -06:00
// Two resize operations of the same partition
if ( operations [ first ] - > type = = OPERATION_RESIZE_MOVE & &
operations [ second ] - > type = = OPERATION_RESIZE_MOVE & &
operations [ first ] - > partition_new = = operations [ second ] - > partition_original
)
{
operations [ first ] - > partition_new = operations [ second ] - > partition_new ;
operations [ first ] - > create_description ( ) ;
remove_operation ( second ) ;
return true ;
}
// Two label change operations on the same partition
2014-12-16 14:06:20 -07:00
else if ( operations [ first ] - > type = = OPERATION_LABEL_FILESYSTEM & &
operations [ second ] - > type = = OPERATION_LABEL_FILESYSTEM & &
2011-10-05 12:15:16 -06:00
operations [ first ] - > partition_new = = operations [ second ] - > partition_original
)
{
2014-12-16 15:04:34 -07:00
operations [ first ] - > partition_new . set_filesystem_label (
operations [ second ] - > partition_new . get_filesystem_label ( ) ) ;
2011-10-05 12:15:16 -06:00
operations [ first ] - > create_description ( ) ;
remove_operation ( second ) ;
return true ;
}
2014-12-12 00:00:02 -07:00
// Two name change operations on the same partition
else if ( operations [ first ] - > type = = OPERATION_NAME_PARTITION & &
operations [ second ] - > type = = OPERATION_NAME_PARTITION & &
operations [ first ] - > partition_new = = operations [ second ] - > partition_original
)
{
operations [ first ] - > partition_new . name = operations [ second ] - > partition_new . name ;
operations [ first ] - > create_description ( ) ;
remove_operation ( second ) ;
return true ;
}
2012-01-22 13:49:52 -07:00
// Two change-uuid change operations on the same partition
else if ( operations [ first ] - > type = = OPERATION_CHANGE_UUID & &
operations [ second ] - > type = = OPERATION_CHANGE_UUID & &
operations [ first ] - > partition_new = = operations [ second ] - > partition_original
)
{
2012-01-30 11:33:33 -07:00
// Changing half the UUID should not override changing all of it
if ( operations [ first ] - > partition_new . uuid = = UUID_RANDOM_NTFS_HALF | |
operations [ second ] - > partition_new . uuid = = UUID_RANDOM )
operations [ first ] - > partition_new . uuid = operations [ second ] - > partition_new . uuid ;
2012-01-22 13:49:52 -07:00
operations [ first ] - > create_description ( ) ;
remove_operation ( second ) ;
return true ;
}
2011-10-05 12:15:16 -06:00
// Two check operations of the same partition
else if ( operations [ first ] - > type = = OPERATION_CHECK & &
operations [ second ] - > type = = OPERATION_CHECK & &
operations [ first ] - > partition_original = = operations [ second ] - > partition_original
)
{
remove_operation ( second ) ;
return true ;
}
// Two format operations of the same partition
else if ( operations [ first ] - > type = = OPERATION_FORMAT & &
operations [ second ] - > type = = OPERATION_FORMAT & &
operations [ first ] - > partition_new = = operations [ second ] - > partition_original
2011-10-13 11:26:16 -06:00
)
2011-10-05 12:15:16 -06:00
{
operations [ first ] - > partition_new = operations [ second ] - > partition_new ;
operations [ first ] - > create_description ( ) ;
remove_operation ( second ) ;
return true ;
}
return false ;
}
2006-03-01 14:50:52 -07:00
void Win_GParted : : Refresh_Visual ( )
2004-09-19 14:24:53 -06:00
{
2015-05-19 13:25:07 -06:00
// How GParted displays partitions in the GUI and manages the lifetime and
// ownership of that data:
//
// (1) Queries the devices and partitions on disk and refreshes the model.
//
// Data owner: std::vector<Devices> Win_GParted::devices
// Lifetime: Valid until the next call to Refresh_Visual()
// Call chain:
//
// Win_GParted::menu_gparted_refresh_devices()
// gparted_core.set_devices( devices )
// GParted_Core::set_devices_thread( devices )
// devices.clear()
// etc.
//
// (2) Takes a copy of the partitions for the device currently being shown in the
// GUI and visually applies pending operations.
//
// Data owner: std::vector<Partition> Win_GParted::display_partitions
// Lifetime: Valid until the next call to Refresh_Visual().
// Function: Refresh_Visual()
//
// (3) Loads the disk graphic and partition list with partitions to be shown in
// the GUI. Both classes store pointers pointing back to each partition
// object in the vector of display partitions.
//
// Aliases: Win_GParted::display_partitions[]
// Call chain:
//
// Win_GParted::Refresh_Visual()
// drawingarea_visualdisk.load_partitions( display_partitions, device_sectors )
// DrawingAreaVisualDisk::set_static_data( ... )
// treeview_detail.load_partitions( display_partitions )
// TreeView_Detail::create_row()
// TreeView_Detail::load_partitions()
// TreeView_Detail::create_row()
//
// (4) Selecting a partition in the disk graphic or in the partition list fires
// the callback which passes a pointer to the selected partition stored in
// step (3). The callback saves the selected partition and calls the opposite
// class to update it's selection.
//
// Data owner: const Partition * Win_GParted::selected_partition_ptr
// Aliases: Win_GParted::display_partitions[]
// Lifetime: Valid until the next call to Refresh_Visual().
// Call chain: (example clicking on a partition in the disk graphic)
//
// DrawingAreaVisualDisk::on_button_press_event()
// DawingAreaVisualDisk::set_selected( visual_partitions, x, y )
// signal_partition_selected.emit( ..., false )
// Win_GParted::on_partition_selected( partition_ptr, src_is_treeview )
// treeview_detail.set_selected( treestore_detail->children(), partition_ptr )
// TreeView::set_selected( rows, partition_ptr, inside_extended )
// set_cursor()
// TreeView::set_selected( rows, partition_ptr, true )
// set_cursor()
//
// (5) Each new operation is added to the vector of pending operations.
// Eventually Refresh_Visual() is call to update the GUI. This goes to step
// (2) which visually reapplies all pending operations again, including the
// newly added operation.
//
// Data owner: std::vector<Operation *> Win_GParted::operations
// Lifetime: Valid until operations have been applied by
// GParted_Core::apply_operation_to_disk(). Specifically longer
// than the next call call to Refresh_Visual().
// Call chain: (example setting a file system label)
//
// Win_GParted::activate_label_filesystem()
// Win_GParted::Add_Operation( operation )
// Win_GParted::Merge_Operations( ... )
// Win_GParted::show_operationslist()
// Win_GParted::Refresh_Visual()
//
// (6) Selecting a partition as a copy source makes a copy of that partition
// object.
//
// Data owner: Partition Win_GParted::copied_partition
// Lifetime: Valid until GParted closed or the device is removed.
// Specifically longer than the next call to Refresh_Visual().
// Function: Win_GParted::activate_copy()
2015-05-15 08:51:26 -06:00
display_partitions = devices [ current_device ] . partitions ;
2004-09-19 14:24:53 -06:00
//make all operations visible
2005-12-22 15:20:55 -07:00
for ( unsigned int t = 0 ; t < operations . size ( ) ; t + + )
2006-03-24 12:08:41 -07:00
if ( operations [ t ] - > device = = devices [ current_device ] )
2015-05-15 08:51:26 -06:00
operations [ t ] - > apply_to_visual ( display_partitions ) ;
2009-01-06 15:22:09 -07:00
2006-09-17 07:23:47 -06:00
hbox_operations . load_operations ( operations ) ;
2004-09-19 14:24:53 -06:00
//set new statusbartext
2005-12-22 15:20:55 -07:00
statusbar . pop ( ) ;
2008-06-10 13:16:26 -06:00
statusbar . push ( String : : ucompose ( ngettext ( " %1 operation pending "
, " %1 operations pending "
, operations . size ( )
)
, operations . size ( )
)
) ;
2009-01-06 15:22:09 -07:00
if ( ! operations . size ( ) )
2006-09-16 05:27:05 -06:00
allow_undo_clear_apply ( false ) ;
2013-03-17 06:22:28 -06:00
//Count primary partitions for check in max_amount_prim_reached(),
// check for an extended partition and select the largest unallocated
// partition if there is one.
2006-03-24 12:08:41 -07:00
index_extended = - 1 ;
2004-11-06 04:55:03 -07:00
primary_count = 0 ;
2013-03-17 06:22:28 -06:00
2015-05-17 07:01:48 -06:00
selected_partition_ptr = NULL ;
2013-03-17 06:22:28 -06:00
Sector largest_unalloc_size = - 1 ;
Sector current_size ;
2015-05-15 08:51:26 -06:00
for ( unsigned int t = 0 ; t < display_partitions . size ( ) ; t + + )
2004-09-19 14:24:53 -06:00
{
2015-05-15 08:51:26 -06:00
if ( display_partitions [ t ] . get_path ( ) = = copied_partition . get_path ( ) )
copied_partition = display_partitions [ t ] ;
switch ( display_partitions [ t ] . type )
2004-09-19 14:24:53 -06:00
{
2013-03-17 06:22:28 -06:00
case TYPE_PRIMARY :
2005-12-07 04:21:27 -07:00
primary_count + + ;
break ;
2013-03-17 06:22:28 -06:00
case TYPE_EXTENDED :
2006-03-24 12:08:41 -07:00
index_extended = t ;
2005-12-07 04:21:27 -07:00
primary_count + + ;
2013-03-17 06:22:28 -06:00
2015-05-15 08:51:26 -06:00
for ( unsigned int u = 0 ; u < display_partitions [ t ] . logicals . size ( ) ; u + + )
2013-03-17 06:22:28 -06:00
{
2015-05-15 08:51:26 -06:00
switch ( display_partitions [ t ] . logicals [ u ] . type )
2013-03-17 06:22:28 -06:00
{
case TYPE_UNALLOCATED :
2015-05-15 08:51:26 -06:00
current_size = display_partitions [ t ] . logicals [ u ] . get_sector_length ( ) ;
2013-03-17 06:22:28 -06:00
if ( current_size > largest_unalloc_size )
{
largest_unalloc_size = current_size ;
2015-05-17 07:01:48 -06:00
selected_partition_ptr = & display_partitions [ t ] . logicals [ u ] ;
2013-03-17 06:22:28 -06:00
}
break ;
default :
break ;
}
}
2005-12-07 04:21:27 -07:00
break ;
2013-03-17 06:22:28 -06:00
case TYPE_UNALLOCATED :
2015-05-15 08:51:26 -06:00
current_size = display_partitions [ t ] . get_sector_length ( ) ;
2013-03-17 06:22:28 -06:00
if ( current_size > largest_unalloc_size )
{
largest_unalloc_size = current_size ;
2015-05-17 07:01:48 -06:00
selected_partition_ptr = & display_partitions [ t ] ;
2013-03-17 06:22:28 -06:00
}
break ;
2005-12-07 04:21:27 -07:00
default :
break ;
2004-09-19 14:24:53 -06:00
}
}
2015-05-15 08:51:26 -06:00
// frame visualdisk
drawingarea_visualdisk . load_partitions ( display_partitions , devices [ current_device ] . length ) ;
// treeview details
treeview_detail . load_partitions ( display_partitions ) ;
2013-03-17 06:22:28 -06:00
set_valid_operations ( ) ;
2014-08-23 03:41:42 -06:00
// Process Gtk events to redraw visuals with reloaded partition details
while ( Gtk : : Main : : events_pending ( ) )
Gtk : : Main : : iteration ( ) ;
2013-03-17 06:22:28 -06:00
if ( largest_unalloc_size > = 0 )
{
2014-08-23 03:41:42 -06:00
// Flashing redraw work around. Inform visuals of selection of the
// largest unallocated partition after drawing those visuals above.
2015-05-17 07:01:48 -06:00
drawingarea_visualdisk . set_selected ( selected_partition_ptr ) ;
treeview_detail . set_selected ( selected_partition_ptr ) ;
2013-03-17 06:22:28 -06:00
2014-08-23 03:41:42 -06:00
// Process Gtk events to draw selection
while ( Gtk : : Main : : events_pending ( ) )
Gtk : : Main : : iteration ( ) ;
}
2004-09-19 14:24:53 -06:00
}
2015-05-31 09:32:23 -06:00
// Confirms that the pointer points to one of the partition objects in the vector of
// displayed partitions, Win_GParted::display_partitions[].
// Usage: g_assert( valid_display_partition_ptr( my_partition_ptr ) );
bool Win_GParted : : valid_display_partition_ptr ( const Partition * partition_ptr )
{
for ( unsigned int i = 0 ; i < display_partitions . size ( ) ; i + + )
{
if ( & display_partitions [ i ] = = partition_ptr )
return true ;
else if ( display_partitions [ i ] . type = = TYPE_EXTENDED )
{
for ( unsigned int j = 0 ; j < display_partitions [ i ] . logicals . size ( ) ; j + + )
{
if ( & display_partitions [ i ] . logicals [ j ] = = partition_ptr )
return true ;
}
}
}
return false ;
}
2006-02-17 14:18:07 -07:00
bool Win_GParted : : Quit_Check_Operations ( )
2004-09-19 14:24:53 -06:00
{
2005-12-22 15:20:55 -07:00
if ( operations . size ( ) )
2004-09-19 14:24:53 -06:00
{
2006-02-08 13:36:18 -07:00
Gtk : : MessageDialog dialog ( * this ,
_ ( " Quit GParted? " ) ,
false ,
Gtk : : MESSAGE_QUESTION ,
Gtk : : BUTTONS_NONE ,
true ) ;
2008-06-10 13:16:26 -06:00
dialog . set_secondary_text ( String : : ucompose ( ngettext ( " %1 operation is currently pending. "
, " %1 operations are currently pending. "
, operations . size ( )
)
, operations . size ( )
)
) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
dialog . add_button ( Gtk : : Stock : : QUIT , Gtk : : RESPONSE_CLOSE ) ;
dialog . add_button ( Gtk : : Stock : : CANCEL , Gtk : : RESPONSE_CANCEL ) ;
2009-01-06 15:22:09 -07:00
2005-12-22 15:20:55 -07:00
if ( dialog . run ( ) = = Gtk : : RESPONSE_CANCEL )
2004-11-23 12:03:39 -07:00
return false ; //don't close GParted
2004-09-19 14:24:53 -06:00
}
return true ; //close GParted
}
2006-02-17 14:18:07 -07:00
void Win_GParted : : set_valid_operations ( )
2004-09-19 14:24:53 -06:00
{
2004-11-06 12:48:24 -07:00
allow_new ( false ) ; allow_delete ( false ) ; allow_resize ( false ) ; allow_copy ( false ) ;
2012-06-17 05:26:49 -06:00
allow_paste ( false ) ; allow_format ( false ) ; allow_toggle_busy_state ( false ) ;
2014-12-12 00:00:02 -07:00
allow_name_partition ( false ) ; allow_manage_flags ( false ) ; allow_check ( false ) ;
allow_label_filesystem ( false ) ; allow_change_uuid ( false ) ; allow_info ( false ) ;
2012-06-17 05:26:49 -06:00
dynamic_cast < Gtk : : Label * > ( menu_partition . items ( ) [ MENU_TOGGLE_BUSY ] . get_child ( ) )
2012-01-27 12:41:31 -07:00
- > set_label ( FileSystem : : get_generic_text ( CTEXT_DEACTIVATE_FILESYSTEM ) ) ;
2006-08-20 10:51:18 -06:00
2012-06-17 05:26:49 -06:00
menu_partition . items ( ) [ MENU_TOGGLE_BUSY ] . show ( ) ;
2009-01-06 15:22:09 -07:00
menu_partition . items ( ) [ MENU_MOUNT ] . hide ( ) ;
2006-03-16 10:09:17 -07:00
2015-05-17 07:01:48 -06:00
// No partition selected ...
if ( ! selected_partition_ptr )
2005-01-09 12:33:48 -07:00
return ;
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2013-11-15 09:27:12 -07:00
2015-05-17 07:01:48 -06:00
// Get filesystem capabilities
fs = gparted_core . get_fs ( selected_partition_ptr - > filesystem ) ;
2013-11-15 09:27:12 -07:00
2005-01-09 12:33:48 -07:00
//if there's something, there's some info ;)
2006-02-08 13:36:18 -07:00
allow_info ( true ) ;
2014-12-28 06:18:58 -07:00
2014-12-28 07:21:34 -07:00
// Set an appropriate name for the activate/deactivate menu item.
2015-05-17 07:01:48 -06:00
const FileSystem * filesystem_object = gparted_core . get_filesystem_object ( selected_partition_ptr - > filesystem ) ;
2015-05-16 02:58:58 -06:00
if ( filesystem_object )
2012-06-17 05:26:49 -06:00
dynamic_cast < Gtk : : Label * > ( menu_partition . items ( ) [ MENU_TOGGLE_BUSY ] . get_child ( ) )
2015-05-17 07:01:48 -06:00
- > set_label ( filesystem_object - > get_custom_text ( selected_partition_ptr - > busy
2015-05-16 02:58:58 -06:00
? CTEXT_DEACTIVATE_FILESYSTEM
: CTEXT_ACTIVATE_FILESYSTEM ) ) ;
2012-01-27 12:41:31 -07:00
else
2012-06-17 05:26:49 -06:00
dynamic_cast < Gtk : : Label * > ( menu_partition . items ( ) [ MENU_TOGGLE_BUSY ] . get_child ( ) )
2015-05-17 07:01:48 -06:00
- > set_label ( FileSystem : : get_generic_text ( selected_partition_ptr - > busy
2012-01-27 12:41:31 -07:00
? CTEXT_DEACTIVATE_FILESYSTEM
: CTEXT_ACTIVATE_FILESYSTEM )
) ;
2015-05-17 07:01:48 -06:00
// Only permit mount/unmount, swapon/swapoff, activate/deactivate if action is available
if ( selected_partition_ptr - > status = = STAT_REAL
& & selected_partition_ptr - > type ! = TYPE_EXTENDED
& & selected_partition_ptr - > filesystem ! = FS_LVM2_PV
& & selected_partition_ptr - > filesystem ! = FS_LINUX_SWRAID
& & ( selected_partition_ptr - > busy
| | selected_partition_ptr - > get_mountpoints ( ) . size ( ) /* Have mount point(s) */
| | selected_partition_ptr - > filesystem = = FS_LINUX_SWAP
2012-01-27 12:41:31 -07:00
)
)
2012-06-17 05:26:49 -06:00
allow_toggle_busy_state ( true ) ;
2006-03-09 12:37:50 -07:00
2012-02-13 05:44:45 -07:00
//Only permit VG deactivation if busy, or activation if not busy and a member of a VG.
// For now specifically allow activation of an exported VG, which LVM will fail
// with "Volume group "VGNAME" is exported", otherwise user won't know why the
// inactive PV can't be activated.
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > status = = STAT_REAL
& & selected_partition_ptr - > type ! = TYPE_EXTENDED
& & selected_partition_ptr - > filesystem = = FS_LVM2_PV
& & ( selected_partition_ptr - > busy
| | ( ! selected_partition_ptr - > busy
& & ! selected_partition_ptr - > get_mountpoints ( ) . empty ( ) // VGNAME from mount point
2012-02-13 05:44:45 -07:00
)
)
)
2012-06-17 05:26:49 -06:00
allow_toggle_busy_state ( true ) ;
2012-02-13 05:44:45 -07:00
2015-03-13 11:38:48 -06:00
// Allow naming on devices that support it
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > type ! = TYPE_UNALLOCATED & &
selected_partition_ptr - > status = = STAT_REAL & &
2015-03-13 16:36:08 -06:00
devices [ current_device ] . partition_naming_supported ( ) )
2015-03-13 11:38:48 -06:00
allow_name_partition ( true ) ;
2014-12-28 07:21:34 -07:00
// Manage flags
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > type ! = TYPE_UNALLOCATED & &
selected_partition_ptr - > status = = STAT_REAL & &
! selected_partition_ptr - > whole_device )
2014-12-28 07:21:34 -07:00
allow_manage_flags ( true ) ;
2013-11-15 09:27:12 -07:00
# ifdef ENABLE_ONLINE_RESIZE
2015-05-17 07:01:48 -06:00
// Find out if online resizing is possible
if ( selected_partition_ptr - > busy )
2013-11-15 09:27:12 -07:00
{
if ( ( fs . online_grow | | fs . online_shrink ) & & ! devices [ current_device ] . readonly )
allow_resize ( true ) ;
}
# endif
2015-05-17 07:01:48 -06:00
// Only unmount/swapoff/VG deactivate or online actions allowed if busy
if ( selected_partition_ptr - > busy )
2006-02-08 13:36:18 -07:00
return ;
2012-01-27 12:41:31 -07:00
2015-05-17 07:01:48 -06:00
// UNALLOCATED
if ( selected_partition_ptr - > type = = TYPE_UNALLOCATED )
2004-09-19 14:24:53 -06:00
{
allow_new ( true ) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//find out if there is a copied partition and if it fits inside this unallocated space
2006-03-14 14:37:47 -07:00
if ( ! copied_partition . get_path ( ) . empty ( ) & & ! devices [ current_device ] . readonly )
2004-11-25 12:21:42 -07:00
{
2010-04-27 11:41:43 -06:00
Byte_Value required_size ;
2006-02-25 03:09:30 -07:00
if ( copied_partition . filesystem = = GParted : : FS_XFS )
Don't show intrinsic unallocated space (#499202)
Most file systems report intrinsic unallocated space using the statvfs()
system call when mounted, but not using their own tools. They are:
ext2/3/4, fat16/32, hfs, nilfs2, reiserfs and xfs. Showing either a
little or no unallocated space, depending on whether a file system is
mounted or not, could be confusing to the user.
When all file systems are created filling their partitions the unused
figure reported by statvfs() and their own tools are the same or very
close. Also the used plus unallocated figure from statvfs() agrees with
the used figure from their own tools.
For all file systems don't display intrinsic unallocated space (that
below the threshold of 2 to 5%), instead include it as used space. As
soon as the amount of unallocated space becomes significant display it
everywhere and also trigger the warning.
For display purposes always use the new Partition methods:
get_sectors_used(), get_sectors_unused(), and get_sectors_unallocated().
When calculating new usage figures during Paste and Resize/Move
operations directly access sectors_used, sectors_unused and
sectors_unallocated members.
Bug #499202 - gparted does not see the difference if partition size
differs from filesystem size
2012-06-15 06:16:30 -06:00
required_size = copied_partition . estimated_min_size ( ) * copied_partition . sector_size ;
2006-02-25 03:09:30 -07:00
else
2010-04-27 11:41:43 -06:00
required_size = copied_partition . get_byte_length ( ) ;
2006-02-25 03:09:30 -07:00
2010-05-20 10:00:14 -06:00
//Determine if space is needed for the Master Boot Record or
// the Extended Boot Record. Generally an an additional track or MEBIBYTE
// is required so for our purposes reserve a MEBIBYTE in front of the partition.
// NOTE: This logic also contained in Dialog_Base_Partition::MB_Needed_for_Boot_Record
2015-05-17 07:01:48 -06:00
if ( ( selected_partition_ptr - > inside_extended
& & selected_partition_ptr - > type = = TYPE_UNALLOCATED
2010-05-20 10:00:14 -06:00
)
2015-05-17 07:01:48 -06:00
| | ( selected_partition_ptr - > type = = TYPE_LOGICAL )
2010-05-20 10:00:14 -06:00
/* Beginning of disk device */
2015-05-17 07:01:48 -06:00
| | ( selected_partition_ptr - > sector_start < = ( MEBIBYTE / selected_partition_ptr - > sector_size ) )
2010-05-20 10:00:14 -06:00
)
required_size + = MEBIBYTE ;
//Determine if space is needed for the Extended Boot Record for a logical partition
// after this partition. Generally an an additional track or MEBIBYTE
// is required so for our purposes reserve a MEBIBYTE in front of the partition.
2015-05-17 07:01:48 -06:00
if ( ( ( selected_partition_ptr - > inside_extended
& & selected_partition_ptr - > type = = TYPE_UNALLOCATED
2010-05-20 10:00:14 -06:00
)
2015-05-17 07:01:48 -06:00
| | ( selected_partition_ptr - > type = = TYPE_LOGICAL )
2010-05-20 10:00:14 -06:00
)
2015-05-17 07:01:48 -06:00
& & ( selected_partition_ptr - > sector_end
2010-05-20 10:00:14 -06:00
< ( devices [ current_device ] . length
- ( 2 * MEBIBYTE / devices [ current_device ] . sector_size )
)
)
2009-01-24 10:16:57 -07:00
)
2010-05-20 10:00:14 -06:00
required_size + = MEBIBYTE ;
2009-01-24 10:16:57 -07:00
2010-05-20 15:12:14 -06:00
//Determine if space is needed for the backup partition on a GPT partition table
if ( ( devices [ current_device ] . disktype = = " gpt " )
2015-05-17 07:01:48 -06:00
& & ( ( devices [ current_device ] . length - selected_partition_ptr - > sector_end )
2010-05-20 15:12:14 -06:00
< ( MEBIBYTE / devices [ current_device ] . sector_size )
)
)
required_size + = MEBIBYTE ;
2015-05-17 07:01:48 -06:00
if ( required_size < = selected_partition_ptr - > get_byte_length ( ) )
2004-11-25 12:21:42 -07:00
allow_paste ( true ) ;
2009-01-24 10:16:57 -07:00
}
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
return ;
}
2009-01-06 15:22:09 -07:00
2015-05-17 07:01:48 -06:00
// EXTENDED
if ( selected_partition_ptr - > type = = TYPE_EXTENDED )
2004-12-14 15:49:44 -07:00
{
2015-05-17 07:01:48 -06:00
// Deletion is only allowed when there are no logical partitions inside.
if ( selected_partition_ptr - > logicals . size ( ) = = 1 & &
selected_partition_ptr - > logicals . back ( ) . type = = TYPE_UNALLOCATED )
2004-12-14 15:49:44 -07:00
allow_delete ( true ) ;
2009-01-06 15:22:09 -07:00
2004-12-14 15:49:44 -07:00
if ( ! devices [ current_device ] . readonly )
2009-01-06 15:22:09 -07:00
allow_resize ( true ) ;
2006-03-31 03:49:27 -07:00
2004-12-14 15:49:44 -07:00
return ;
2009-01-06 15:22:09 -07:00
}
2015-05-17 07:01:48 -06:00
// PRIMARY and LOGICAL
if ( selected_partition_ptr - > type = = TYPE_PRIMARY | | selected_partition_ptr - > type = = TYPE_LOGICAL )
2004-09-19 14:24:53 -06:00
{
2006-01-02 08:18:29 -07:00
allow_format ( true ) ;
Enable operations on whole disk device virtual partitions (#743181)
Enable operations on whole disk devices containing any recognised file
system.
The new partition operation on an empty whole disk device continues to
display the "No partition table found on device /dev/DEVICE" information
dialog.
Specifically unsupported operations:
* Delete -
Deletion of a partition only involves removal of the entry in the
partition table leaving the file system intact on the disk. However
this doesn't work for a whole disk device file system. Instead the
file system signatures would have to be erased which is much more
destructive and virtually impossible to undo. Therefore don't
implement whole disk device file system deletion. Alternatives are
to format the file system to cleared or create a partition table on
the device. Both of these imply overwriting the existing data and
set the expectation that undo is not possible.
* Manage flags -
There's no partition table, so there's no partition, so there's no
flags.
Resize/Move operation is being supported so that a whole disk device
file system can be resized to handle devices which can be resize, such
as those from SANs or Linux Software RAID arrays. The start of the file
system must remain fixed so move won't be allowed.
So far only simple operations work if they don't need libparted support
at all [1], or only need libparted support for the calibrate step AND
the file system on the whole disk device is recognised by libparted [2].
(Needs libparted to provide a "loop" partition, hence the recognition
requirement, so that the calibrate step can successfully read the
virtual "loop" partition table. Doesn't matter whether it's an old
version of libparted and it gets the name of the device wrong as GParted
is already using the whole disk device name anyway).
[1] Operations not needing any libparted support:
Mount on, Unmount, Swapon, Swapoff, Activate and Deactivate
[2] Operations only needing libparted support for the calibrate step:
Check, Label, New UUID
Bug 743181 - Add unpartitioned drive read-write support
2014-12-31 05:41:03 -07:00
// only allow deletion of partitions within a partition table
2015-05-17 07:01:48 -06:00
if ( ! selected_partition_ptr - > whole_device )
Enable operations on whole disk device virtual partitions (#743181)
Enable operations on whole disk devices containing any recognised file
system.
The new partition operation on an empty whole disk device continues to
display the "No partition table found on device /dev/DEVICE" information
dialog.
Specifically unsupported operations:
* Delete -
Deletion of a partition only involves removal of the entry in the
partition table leaving the file system intact on the disk. However
this doesn't work for a whole disk device file system. Instead the
file system signatures would have to be erased which is much more
destructive and virtually impossible to undo. Therefore don't
implement whole disk device file system deletion. Alternatives are
to format the file system to cleared or create a partition table on
the device. Both of these imply overwriting the existing data and
set the expectation that undo is not possible.
* Manage flags -
There's no partition table, so there's no partition, so there's no
flags.
Resize/Move operation is being supported so that a whole disk device
file system can be resized to handle devices which can be resize, such
as those from SANs or Linux Software RAID arrays. The start of the file
system must remain fixed so move won't be allowed.
So far only simple operations work if they don't need libparted support
at all [1], or only need libparted support for the calibrate step AND
the file system on the whole disk device is recognised by libparted [2].
(Needs libparted to provide a "loop" partition, hence the recognition
requirement, so that the calibrate step can successfully read the
virtual "loop" partition table. Doesn't matter whether it's an old
version of libparted and it gets the name of the device wrong as GParted
is already using the whole disk device name anyway).
[1] Operations not needing any libparted support:
Mount on, Unmount, Swapon, Swapoff, Activate and Deactivate
[2] Operations only needing libparted support for the calibrate step:
Check, Label, New UUID
Bug 743181 - Add unpartitioned drive read-write support
2014-12-31 05:41:03 -07:00
allow_delete ( true ) ;
2004-12-17 09:26:49 -07:00
//find out if resizing/moving is possible
2009-01-06 15:22:09 -07:00
if ( ( fs . grow | | fs . shrink | | fs . move ) & & ! devices [ current_device ] . readonly )
2004-09-19 14:24:53 -06:00
allow_resize ( true ) ;
2009-01-06 15:22:09 -07:00
2004-12-17 09:26:49 -07:00
//only allow copying of real partitions
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > status = = STAT_REAL & & fs . copy )
2008-04-07 13:41:18 -06:00
allow_copy ( true ) ;
2009-01-06 15:22:09 -07:00
2008-04-07 13:41:18 -06:00
//only allow labelling of real partitions that support labelling
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > status = = STAT_REAL & & fs . write_label )
2014-12-18 15:18:33 -07:00
allow_label_filesystem ( true ) ;
2008-04-07 13:41:18 -06:00
2012-01-22 13:49:52 -07:00
//only allow changing UUID of real partitions that support it
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > status = = STAT_REAL & & fs . write_uuid )
2012-01-22 13:49:52 -07:00
allow_change_uuid ( true ) ;
2015-05-17 07:01:48 -06:00
// Generate Mount on submenu, except for LVM2 PVs
// borrowing mount point to display the VGNAME
if ( selected_partition_ptr - > filesystem ! = FS_LVM2_PV & &
selected_partition_ptr - > get_mountpoints ( ) . size ( ) )
2006-03-09 12:37:50 -07:00
{
2006-08-20 10:51:18 -06:00
menu = menu_partition . items ( ) [ MENU_MOUNT ] . get_submenu ( ) ;
2006-03-16 10:09:17 -07:00
menu - > items ( ) . clear ( ) ;
2015-05-17 07:01:48 -06:00
for ( unsigned int t = 0 ; t < selected_partition_ptr - > get_mountpoints ( ) . size ( ) ; t + + )
2006-03-17 03:07:49 -07:00
{
2009-01-06 15:22:09 -07:00
menu - > items ( ) . push_back (
Gtk : : Menu_Helpers : : MenuElem (
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > get_mountpoints ( ) [ t ] ,
2006-03-16 10:09:17 -07:00
sigc : : bind < unsigned int > ( sigc : : mem_fun ( * this , & Win_GParted : : activate_mount_partition ) , t ) ) ) ;
2006-03-09 12:37:50 -07:00
2006-03-17 03:07:49 -07:00
dynamic_cast < Gtk : : Label * > ( menu - > items ( ) . back ( ) . get_child ( ) ) - > set_use_underline ( false ) ;
}
2012-06-17 05:26:49 -06:00
menu_partition . items ( ) [ MENU_TOGGLE_BUSY ] . hide ( ) ;
2009-01-06 15:22:09 -07:00
menu_partition . items ( ) [ MENU_MOUNT ] . show ( ) ;
2006-03-09 12:37:50 -07:00
}
2006-03-29 12:21:42 -07:00
//see if there is an copied partition and if it passes all tests
if ( ! copied_partition . get_path ( ) . empty ( ) & &
2015-05-17 07:01:48 -06:00
copied_partition . get_byte_length ( ) < = selected_partition_ptr - > get_byte_length ( ) & &
selected_partition_ptr - > status = = STAT_REAL & &
copied_partition ! = * selected_partition_ptr )
2006-03-29 12:21:42 -07:00
allow_paste ( true ) ;
2006-11-26 07:27:16 -07:00
2008-11-18 16:58:17 -07:00
//see if we can somehow check/repair this file system....
2015-05-17 07:01:48 -06:00
if ( fs . check & & selected_partition_ptr - > status = = STAT_REAL )
2006-11-26 07:27:16 -07:00
allow_check ( true ) ;
2004-09-19 14:24:53 -06:00
}
}
2013-05-17 10:01:42 -06:00
void Win_GParted : : show_operationslist ( )
{
//Enable (or disable) Undo and Apply buttons
allow_undo_clear_apply ( operations . size ( ) ) ;
//Updates view of operations list and sensitivity of Undo and Apply buttons
Refresh_Visual ( ) ;
if ( operations . size ( ) = = 1 ) //first operation, open operationslist
open_operationslist ( ) ;
//FIXME: A slight flicker may be introduced by this extra display refresh.
//An extra display refresh seems to prevent the disk area visual disk from
// disappearing when enough operations are added to require a scrollbar
// (about 4 operations with default window size).
// Note that commenting out the code to
// "//make scrollwindow focus on the last operation in the list"
// in HBoxOperations::load_operations() prevents this problem from occurring as well.
// See also Win_GParted::activate_undo().
drawingarea_visualdisk . queue_draw ( ) ;
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : open_operationslist ( )
2004-10-11 08:19:56 -06:00
{
2006-02-22 15:05:15 -07:00
if ( ! OPERATIONSLIST_OPEN )
2004-10-11 08:19:56 -06:00
{
2006-02-22 15:05:15 -07:00
OPERATIONSLIST_OPEN = true ;
hbox_operations . show ( ) ;
2009-01-06 15:22:09 -07:00
2006-02-22 15:05:15 -07:00
for ( int t = vpaned_main . get_height ( ) ; t > ( vpaned_main . get_height ( ) - 100 ) ; t - = 5 )
{
vpaned_main . set_position ( t ) ;
2009-01-06 15:22:09 -07:00
while ( Gtk : : Main : : events_pending ( ) )
2006-02-22 15:05:15 -07:00
Gtk : : Main : : iteration ( ) ;
}
2005-11-27 12:48:00 -07:00
2006-02-22 15:05:15 -07:00
static_cast < Gtk : : CheckMenuItem * > ( & menubar_main . items ( ) [ 2 ] . get_submenu ( ) - > items ( ) [ 1 ] )
- > set_active ( true ) ;
}
2004-10-11 08:19:56 -06:00
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : close_operationslist ( )
2004-09-19 14:24:53 -06:00
{
2006-02-22 15:05:15 -07:00
if ( OPERATIONSLIST_OPEN )
2004-09-19 14:24:53 -06:00
{
2006-02-22 15:05:15 -07:00
OPERATIONSLIST_OPEN = false ;
2009-01-06 15:22:09 -07:00
2006-02-22 15:05:15 -07:00
for ( int t = vpaned_main . get_position ( ) ; t < vpaned_main . get_height ( ) ; t + = 5 )
{
vpaned_main . set_position ( t ) ;
2009-01-06 15:22:09 -07:00
2006-02-22 15:05:15 -07:00
while ( Gtk : : Main : : events_pending ( ) )
Gtk : : Main : : iteration ( ) ;
}
2009-01-06 15:22:09 -07:00
2006-02-22 15:05:15 -07:00
hbox_operations . hide ( ) ;
static_cast < Gtk : : CheckMenuItem * > ( & menubar_main . items ( ) [ 2 ] . get_submenu ( ) - > items ( ) [ 1 ] )
- > set_active ( false ) ;
2004-09-19 14:24:53 -06:00
}
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : clear_operationslist ( )
2004-09-19 14:24:53 -06:00
{
2006-03-24 12:08:41 -07:00
remove_operation ( - 1 , true ) ;
2006-09-16 05:27:05 -06:00
close_operationslist ( ) ;
2006-03-24 12:08:41 -07:00
2006-02-02 03:59:44 -07:00
Refresh_Visual ( ) ;
2004-09-19 14:24:53 -06:00
}
2006-02-02 03:59:44 -07:00
void Win_GParted : : combo_devices_changed ( )
{
2008-04-07 09:26:19 -06:00
unsigned int old_current_device = current_device ;
2004-09-19 14:24:53 -06:00
//set new current device
2005-12-29 16:35:37 -07:00
current_device = combo_devices . get_active_row_number ( ) ;
2008-04-07 09:26:19 -06:00
if ( current_device = = ( unsigned int ) - 1 )
current_device = old_current_device ;
if ( current_device > = devices . size ( ) )
current_device = 0 ;
2006-03-14 14:37:47 -07:00
set_title ( String : : ucompose ( _ ( " %1 - GParted " ) , devices [ current_device ] . get_path ( ) ) ) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//refresh label_device_info
2006-02-02 03:59:44 -07:00
Fill_Label_Device_Info ( ) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//rebuild visualdisk and treeview
2006-02-02 03:59:44 -07:00
Refresh_Visual ( ) ;
2009-01-06 15:22:09 -07:00
2006-02-02 03:59:44 -07:00
//uodate radiobuttons..
if ( menubar_main . items ( ) [ 0 ] . get_submenu ( ) - > items ( ) [ 1 ] . get_submenu ( ) )
2009-01-06 15:22:09 -07:00
static_cast < Gtk : : RadioMenuItem * > (
2006-02-02 03:59:44 -07:00
& menubar_main . items ( ) [ 0 ] . get_submenu ( ) - > items ( ) [ 1 ] . get_submenu ( ) - >
items ( ) [ current_device ] ) - > set_active ( true ) ;
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : radio_devices_changed ( unsigned int item )
2006-02-02 03:59:44 -07:00
{
2009-01-06 15:22:09 -07:00
if ( static_cast < Gtk : : RadioMenuItem * > (
2006-02-02 03:59:44 -07:00
& menubar_main . items ( ) [ 0 ] . get_submenu ( ) - > items ( ) [ 1 ] . get_submenu ( ) - >
items ( ) [ item ] ) - > get_active ( ) )
{
combo_devices . set_active ( item ) ;
}
2004-09-19 14:24:53 -06:00
}
2006-04-02 08:04:44 -06:00
void Win_GParted : : on_show ( )
{
Gtk : : Window : : on_show ( ) ;
2009-01-06 15:22:09 -07:00
2006-02-22 15:05:15 -07:00
vpaned_main . set_position ( vpaned_main . get_height ( ) ) ;
close_operationslist ( ) ;
menu_gparted_refresh_devices ( ) ;
}
2009-01-06 15:22:09 -07:00
2006-03-15 14:44:24 -07:00
void Win_GParted : : menu_gparted_refresh_devices ( )
2004-09-19 14:24:53 -06:00
{
2006-01-08 08:20:14 -07:00
show_pulsebar ( _ ( " Scanning all devices... " ) ) ;
2013-02-21 17:57:33 -07:00
gparted_core . set_devices ( devices ) ;
hide_pulsebar ( ) ;
2009-01-06 15:22:09 -07:00
2006-01-08 08:20:14 -07:00
//check if current_device is still available (think about hotpluggable stuff like usbdevices)
2005-12-22 15:20:55 -07:00
if ( current_device > = devices . size ( ) )
2004-12-03 03:53:01 -07:00
current_device = 0 ;
2005-12-22 15:20:55 -07:00
2005-02-01 10:04:03 -07:00
//see if there are any pending operations on non-existent devices
//NOTE that this isn't 100% foolproof since some stuff (e.g. sourcedevice of copy) may slip through.
//but anyone who removes the sourcedevice before applying the operations gets what he/she deserves :-)
2006-03-15 14:44:24 -07:00
//FIXME: this actually sucks ;) see if we can use STL predicates here..
2005-02-01 10:04:03 -07:00
unsigned int i ;
2006-02-17 14:18:07 -07:00
for ( unsigned int t = 0 ; t < operations . size ( ) ; t + + )
2006-03-15 14:44:24 -07:00
{
2006-03-24 12:08:41 -07:00
for ( i = 0 ; i < devices . size ( ) & & devices [ i ] ! = operations [ t ] - > device ; i + + ) { }
2009-01-06 15:22:09 -07:00
2006-02-17 14:18:07 -07:00
if ( i > = devices . size ( ) )
2006-03-24 12:08:41 -07:00
remove_operation ( t - - ) ;
2005-02-01 10:04:03 -07:00
}
2009-01-06 15:22:09 -07:00
2005-02-01 10:04:03 -07:00
//if no devices were detected we disable some stuff and show a message in the statusbar
2005-12-22 15:20:55 -07:00
if ( devices . empty ( ) )
2006-02-15 09:05:26 -07:00
{
2006-01-24 05:31:58 -07:00
this - > set_title ( _ ( " GParted " ) ) ;
2005-12-29 16:35:37 -07:00
combo_devices . hide ( ) ;
2009-01-06 15:22:09 -07:00
2006-02-02 06:50:37 -07:00
menubar_main . items ( ) [ 0 ] . get_submenu ( ) - > items ( ) [ 1 ] . set_sensitive ( false ) ;
2005-12-22 15:20:55 -07:00
menubar_main . items ( ) [ 1 ] . set_sensitive ( false ) ;
menubar_main . items ( ) [ 2 ] . set_sensitive ( false ) ;
menubar_main . items ( ) [ 3 ] . set_sensitive ( false ) ;
menubar_main . items ( ) [ 4 ] . set_sensitive ( false ) ;
2005-02-01 10:04:03 -07:00
toolbar_main . set_sensitive ( false ) ;
2006-03-09 06:12:44 -07:00
drawingarea_visualdisk . set_sensitive ( false ) ;
2005-12-29 16:35:37 -07:00
treeview_detail . set_sensitive ( false ) ;
2005-02-01 10:04:03 -07:00
Fill_Label_Device_Info ( true ) ;
2009-01-06 15:22:09 -07:00
2006-03-09 06:12:44 -07:00
drawingarea_visualdisk . clear ( ) ;
2005-12-23 17:06:05 -07:00
treeview_detail . clear ( ) ;
2009-01-06 15:22:09 -07:00
2005-02-01 10:04:03 -07:00
//hmzz, this is really paranoid, but i think it's the right thing to do ;)
2006-09-17 07:23:47 -06:00
hbox_operations . clear ( ) ;
2005-12-22 15:20:55 -07:00
close_operationslist ( ) ;
2006-03-24 12:08:41 -07:00
remove_operation ( - 1 , true ) ;
2009-01-06 15:22:09 -07:00
2005-12-22 15:20:55 -07:00
statusbar . pop ( ) ;
2005-02-01 10:04:03 -07:00
statusbar . push ( _ ( " No devices detected " ) ) ;
}
else //at least one device detected
{
2005-12-29 16:35:37 -07:00
combo_devices . show ( ) ;
2009-01-06 15:22:09 -07:00
2006-02-02 06:50:37 -07:00
menubar_main . items ( ) [ 0 ] . get_submenu ( ) - > items ( ) [ 1 ] . set_sensitive ( true ) ;
2005-12-29 16:35:37 -07:00
menubar_main . items ( ) [ 1 ] . set_sensitive ( true ) ;
menubar_main . items ( ) [ 2 ] . set_sensitive ( true ) ;
menubar_main . items ( ) [ 3 ] . set_sensitive ( true ) ;
menubar_main . items ( ) [ 4 ] . set_sensitive ( true ) ;
toolbar_main . set_sensitive ( true ) ;
2006-03-09 06:12:44 -07:00
drawingarea_visualdisk . set_sensitive ( true ) ;
2005-12-29 16:35:37 -07:00
treeview_detail . set_sensitive ( true ) ;
2009-01-06 15:22:09 -07:00
refresh_combo_devices ( ) ;
2005-02-01 10:04:03 -07:00
}
2004-09-19 14:24:53 -06:00
}
2006-04-05 03:33:04 -06:00
void Win_GParted : : menu_gparted_features ( )
2004-12-15 09:38:37 -07:00
{
2006-04-05 03:33:04 -06:00
DialogFeatures dialog ;
2004-12-15 09:38:37 -07:00
dialog . set_transient_for ( * this ) ;
2009-01-06 15:22:09 -07:00
2006-04-05 03:33:04 -06:00
dialog . load_filesystems ( gparted_core . get_filesystems ( ) ) ;
2006-01-02 08:18:29 -07:00
while ( dialog . run ( ) = = Gtk : : RESPONSE_OK )
2004-12-15 09:38:37 -07:00
{
2006-01-02 08:18:29 -07:00
gparted_core . find_supported_filesystems ( ) ;
2006-04-05 03:33:04 -06:00
dialog . load_filesystems ( gparted_core . get_filesystems ( ) ) ;
2006-01-02 08:18:29 -07:00
//recreate format menu...
2006-08-20 10:51:18 -06:00
menu_partition . items ( ) [ MENU_FORMAT ] . remove_submenu ( ) ;
menu_partition . items ( ) [ MENU_FORMAT ] . set_submenu ( * create_format_menu ( ) ) ;
2006-08-28 14:11:58 -06:00
menu_partition . items ( ) [ MENU_FORMAT ] . get_submenu ( ) - > show_all_children ( ) ;
2004-12-15 09:38:37 -07:00
}
}
2006-02-17 14:18:07 -07:00
void Win_GParted : : menu_gparted_quit ( )
2004-09-19 14:24:53 -06:00
{
2006-02-17 14:18:07 -07:00
if ( Quit_Check_Operations ( ) )
this - > hide ( ) ;
2004-09-19 14:24:53 -06:00
}
2006-03-16 10:09:17 -07:00
void Win_GParted : : menu_view_harddisk_info ( )
2009-01-06 15:22:09 -07:00
{
2006-02-17 14:18:07 -07:00
if ( static_cast < Gtk : : CheckMenuItem * > ( & menubar_main . items ( ) [ 2 ] . get_submenu ( ) - > items ( ) [ 0 ] ) - > get_active ( ) )
{ //open harddisk information
2009-01-06 15:22:09 -07:00
hpaned_main . get_child1 ( ) - > show ( ) ;
2006-02-17 14:18:07 -07:00
for ( int t = hpaned_main . get_position ( ) ; t < 250 ; t + = 15 )
2004-09-27 14:12:47 -06:00
{
2004-11-23 12:03:39 -07:00
hpaned_main . set_position ( t ) ;
2006-02-17 14:18:07 -07:00
while ( Gtk : : Main : : events_pending ( ) )
Gtk : : Main : : iteration ( ) ;
2004-09-27 14:12:47 -06:00
}
}
2009-01-06 15:22:09 -07:00
else
2004-09-27 14:12:47 -06:00
{ //close harddisk information
2006-02-17 14:18:07 -07:00
for ( int t = hpaned_main . get_position ( ) ; t > 0 ; t - = 15 )
2004-09-27 14:12:47 -06:00
{
2004-11-23 12:03:39 -07:00
hpaned_main . set_position ( t ) ;
2006-02-17 14:18:07 -07:00
while ( Gtk : : Main : : events_pending ( ) )
Gtk : : Main : : iteration ( ) ;
2004-09-27 14:12:47 -06:00
}
2006-02-17 14:18:07 -07:00
hpaned_main . get_child1 ( ) - > hide ( ) ;
2004-09-27 14:12:47 -06:00
}
}
2006-02-17 14:18:07 -07:00
void Win_GParted : : menu_view_operations ( )
2004-10-11 08:19:56 -06:00
{
2006-02-17 14:18:07 -07:00
if ( static_cast < Gtk : : CheckMenuItem * > ( & menubar_main . items ( ) [ 2 ] . get_submenu ( ) - > items ( ) [ 1 ] ) - > get_active ( ) )
open_operationslist ( ) ;
2009-01-06 15:22:09 -07:00
else
2006-02-17 14:18:07 -07:00
close_operationslist ( ) ;
2004-10-11 08:19:56 -06:00
}
2009-10-24 14:16:40 -06:00
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 ( ) ;
}
2009-11-03 10:27:35 -07:00
void Win_GParted : : show_help_dialog ( const Glib : : ustring & filename /* E.g., gparted */
, const Glib : : ustring & link_id /* For context sensitive help */
)
2004-09-19 14:24:53 -06:00
{
2009-11-03 10:27:35 -07:00
GError * error = NULL ;
GdkScreen * gscreen = NULL ;
2006-02-17 14:18:07 -07:00
2009-11-03 10:27:35 -07:00
Glib : : ustring uri = " ghelp: " + filename ;
if ( link_id . size ( ) > 0 ) {
uri = uri + " ? " + link_id ;
2008-08-05 09:34:10 -06:00
}
2006-02-17 14:18:07 -07:00
2009-11-03 10:27:35 -07:00
gscreen = gdk_screen_get_default ( ) ;
# ifdef HAVE_GTK_SHOW_URI
gtk_show_uri ( gscreen , uri . c_str ( ) , gtk_get_current_event_time ( ) , & error ) ;
# else
Glib : : ustring command = " gnome-open " + uri ;
gdk_spawn_command_line_on_screen ( gscreen , command . c_str ( ) , & error ) ;
# endif
2011-01-17 09:26:28 -07:00
if ( error ! = NULL )
{
//Try opening yelp application directly
g_clear_error ( & error ) ; //Clear error from trying to open gparted help manual above (gtk_show_uri or gnome-open).
Glib : : ustring command = " yelp " + uri ;
gdk_spawn_command_line_on_screen ( gscreen , command . c_str ( ) , & error ) ;
}
2009-11-03 10:27:35 -07:00
if ( error ! = NULL )
{
Gtk : : MessageDialog dialog ( * this
2012-07-27 05:05:49 -06:00
, _ ( " Unable to open GParted Manual help file " )
2009-11-03 10:27:35 -07:00
, false
, Gtk : : MESSAGE_ERROR
, Gtk : : BUTTONS_OK
, true
) ;
dialog . set_secondary_text ( error - > message ) ;
dialog . run ( ) ;
}
2004-09-19 14:24:53 -06:00
}
2008-08-05 09:34:10 -06:00
void Win_GParted : : menu_help_contents ( )
{
2014-08-12 14:36:08 -06:00
# ifdef ENABLE_HELP_DOC
//GParted was built with help documentation
show_help_dialog ( " gparted " , " " ) ;
# else
//GParted was built *without* help documentation using --disable-doc
2009-10-17 15:43:20 -06:00
Gtk : : MessageDialog dialog ( * this ,
2012-07-27 05:05:49 -06:00
_ ( " Documentation is not available " ) ,
2009-10-17 15:43:20 -06:00
false ,
Gtk : : MESSAGE_INFO ,
Gtk : : BUTTONS_OK ,
true ) ;
Glib : : ustring tmp_msg = _ ( " This build of gparted is configured without documentation. " ) ;
tmp_msg + = " \n " ;
tmp_msg + = _ ( " Documentation is available at the project web site. " ) ;
tmp_msg + = " \n " ;
2010-10-12 11:35:26 -06:00
tmp_msg + = " http://gparted.org " ;
2009-10-17 15:43:20 -06:00
dialog . set_secondary_text ( tmp_msg ) ;
dialog . run ( ) ;
# endif
2008-08-05 09:34:10 -06:00
}
2004-09-19 14:24:53 -06:00
2006-02-17 14:18:07 -07:00
void Win_GParted : : menu_help_about ( )
2004-09-19 14:24:53 -06:00
{
2005-11-25 15:41:49 -07:00
std : : vector < Glib : : ustring > strings ;
2009-01-06 15:22:09 -07:00
2005-11-25 15:41:49 -07:00
Gtk : : AboutDialog dialog ;
2004-09-19 14:24:53 -06:00
dialog . set_transient_for ( * this ) ;
2009-01-06 15:22:09 -07:00
2005-11-25 15:41:49 -07:00
dialog . set_name ( _ ( " GParted " ) ) ;
2008-09-22 16:41:49 -06:00
dialog . set_logo_icon_name ( " gparted " ) ;
2005-11-25 15:41:49 -07:00
dialog . set_version ( VERSION ) ;
2006-01-26 05:50:46 -07:00
dialog . set_comments ( _ ( " GNOME Partition Editor " ) ) ;
2015-02-01 13:14:05 -07:00
std : : string names ;
names = " Copyright © 2004-2006 Bart Hakvoort " ;
names + = " \n Copyright © 2008-2015 Curtis Gedak " ;
names + = " \n Copyright © 2011-2015 Mike Fleetwood " ;
dialog . set_copyright ( names ) ;
2005-11-25 15:41:49 -07:00
//authors
2012-06-30 11:26:34 -06:00
//Names listed in alphabetical order by LAST name.
//See also AUTHORS file -- names listed in opposite order to try to be fair.
2013-01-02 11:53:50 -07:00
strings . push_back ( " Sinlu Bes <e80f00@gmail.com> " ) ;
2012-06-30 11:26:34 -06:00
strings . push_back ( " Luca Bruno <lucab@debian.org> " ) ;
strings . push_back ( " Jérôme Dumesnil <jerome.dumesnil@gmail.com> " ) ;
strings . push_back ( " Markus Elfring <elfring@users.sourceforge.net> " ) ;
strings . push_back ( " Mike Fleetwood <mike.fleetwood@googlemail.com> " ) ;
2008-04-07 13:41:18 -06:00
strings . push_back ( " Curtis Gedak <gedakc@users.sf.net> " ) ;
2012-11-30 13:32:31 -07:00
strings . push_back ( " Matthias Gehre <m.gehre@gmx.de> " ) ;
2012-06-30 11:26:34 -06:00
strings . push_back ( " Rogier Goossens <goossens.rogier@gmail.com> " ) ;
strings . push_back ( " Bart Hakvoort <gparted@users.sf.net> " ) ;
strings . push_back ( " Seth Heeren <sgheeren@gmail.com> " ) ;
strings . push_back ( " Joan Lledó <joanlluislledo@gmail.com> " ) ;
strings . push_back ( " Phillip Susi <psusi@cfl.rr.com> " ) ;
2015-02-01 11:01:41 -07:00
strings . push_back ( " Michael Zimmermann <sigmaepsilon92@gmail.com> " ) ;
2005-11-25 15:41:49 -07:00
dialog . set_authors ( strings ) ;
2006-02-17 14:18:07 -07:00
strings . clear ( ) ;
2005-11-25 15:41:49 -07:00
//artists
2012-06-21 14:52:04 -06:00
strings . push_back ( " Sebastian Kraft <kraft.sebastian@gmail.com> " ) ;
2005-11-25 15:41:49 -07:00
dialog . set_artists ( strings ) ;
2006-02-17 14:18:07 -07:00
strings . clear ( ) ;
2005-11-25 15:41:49 -07:00
/*TO TRANSLATORS: your name(s) here please, if there are more translators put newlines (\n) between the names.
2008-11-04 15:16:06 -07:00
It ' s a good idea to provide the url of your translation team as well . Thanks ! */
2005-11-25 15:41:49 -07:00
Glib : : ustring str_credits = _ ( " translator-credits " ) ;
if ( str_credits ! = " translator-credits " )
dialog . set_translator_credits ( str_credits ) ;
2009-01-06 15:22:09 -07:00
//the url is not clickable because this would introduce an new dep (gnome-vfsmm)
2010-10-12 11:35:26 -06:00
dialog . set_website ( " http://gparted.org " ) ;
2005-11-25 15:41:49 -07:00
2006-02-17 14:18:07 -07:00
dialog . run ( ) ;
2004-09-19 14:24:53 -06:00
}
2015-05-16 10:06:22 -06:00
void Win_GParted : : on_partition_selected ( const Partition * partition_ptr , bool src_is_treeview )
2004-09-19 14:24:53 -06:00
{
2015-05-17 07:01:48 -06:00
selected_partition_ptr = partition_ptr ;
2006-02-09 10:02:40 -07:00
2006-02-08 13:36:18 -07:00
set_valid_operations ( ) ;
2015-05-16 10:06:22 -06:00
2005-12-23 17:06:05 -07:00
if ( src_is_treeview )
2015-05-16 10:06:22 -06:00
drawingarea_visualdisk . set_selected ( partition_ptr ) ;
2005-12-23 17:06:05 -07:00
else
2015-05-16 10:06:22 -06:00
treeview_detail . set_selected ( partition_ptr ) ;
2005-12-23 17:06:05 -07:00
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : on_partition_activated ( )
2005-12-23 17:06:05 -07:00
{
2006-01-08 08:20:14 -07:00
activate_info ( ) ;
2005-12-23 17:06:05 -07:00
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : on_partition_popup_menu ( unsigned int button , unsigned int time )
2005-12-23 17:06:05 -07:00
{
menu_partition . popup ( button , time ) ;
2004-09-19 14:24:53 -06:00
}
2009-01-06 15:22:09 -07:00
bool Win_GParted : : max_amount_prim_reached ( )
2004-11-06 04:55:03 -07:00
{
2006-11-26 16:24:39 -07:00
//FIXME: this is the only place where primary_count is used... instead of counting the primaries on each
//refresh, we could just count them here.
2009-01-06 15:22:09 -07:00
//Display error if user tries to create more primary partitions than the partition table can hold.
2015-05-17 07:01:48 -06:00
if ( ! selected_partition_ptr - > inside_extended & & primary_count > = devices [ current_device ] . max_prims )
2006-03-06 04:56:59 -07:00
{
2009-01-06 15:22:09 -07:00
Gtk : : MessageDialog dialog (
2006-02-17 14:18:07 -07:00
* this ,
2010-10-13 08:54:08 -06:00
String : : ucompose ( ngettext ( " It is not possible to create more than %1 primary partition "
, " It is not possible to create more than %1 primary partitions "
, devices [ current_device ] . max_prims
)
, devices [ current_device ] . max_prims
) ,
2006-02-17 14:18:07 -07:00
false ,
Gtk : : MESSAGE_ERROR ,
Gtk : : BUTTONS_OK ,
true ) ;
2009-01-06 15:22:09 -07:00
2006-02-17 14:18:07 -07:00
dialog . set_secondary_text (
2006-03-06 04:56:59 -07:00
_ ( " If you want more partitions you should first create an extended partition. Such a partition can contain other partitions. Because an extended partition is also a primary partition it might be necessary to remove a primary partition first. " ) ) ;
2009-01-06 15:22:09 -07:00
2006-02-17 14:18:07 -07:00
dialog . run ( ) ;
2009-01-06 15:22:09 -07:00
2004-11-06 04:55:03 -07:00
return true ;
}
2009-01-06 15:22:09 -07:00
2004-11-06 04:55:03 -07:00
return false ;
}
2004-09-19 14:24:53 -06:00
2006-02-17 14:18:07 -07:00
void Win_GParted : : activate_resize ( )
2004-09-19 14:24:53 -06:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-05-17 07:01:48 -06:00
Dialog_Partition_Resize_Move dialog ( gparted_core . get_fs ( selected_partition_ptr - > filesystem ) ) ;
2015-05-25 11:18:17 -06:00
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > type = = TYPE_LOGICAL )
2004-11-06 04:55:03 -07:00
{
unsigned int ext = 0 ;
2015-05-23 04:34:08 -06:00
while ( ext < display_partitions . size ( ) & & display_partitions [ ext ] . type ! = TYPE_EXTENDED )
ext + + ;
dialog . Set_Data ( * selected_partition_ptr , display_partitions [ ext ] . logicals ) ;
2004-11-06 04:55:03 -07:00
}
else
2015-05-23 04:34:08 -06:00
dialog . Set_Data ( * selected_partition_ptr , display_partitions ) ;
2015-05-17 07:01:48 -06:00
2009-01-06 15:22:09 -07:00
dialog . set_transient_for ( * this ) ;
2006-03-07 04:55:27 -07:00
if ( dialog . run ( ) = = Gtk : : RESPONSE_OK )
2004-09-19 14:24:53 -06:00
{
2006-03-07 04:55:27 -07:00
dialog . hide ( ) ;
2009-01-06 15:22:09 -07:00
2015-05-17 07:01:48 -06:00
// If selected partition is NEW we simply remove the NEW operation from the list and add
// it again with the new size and position ( unless it's an EXTENDED )
if ( selected_partition_ptr - > status = = STAT_NEW & & selected_partition_ptr - > type ! = TYPE_EXTENDED )
2004-09-19 14:24:53 -06:00
{
//remove operation which creates this partition
2006-03-07 04:55:27 -07:00
for ( unsigned int t = 0 ; t < operations . size ( ) ; t + + )
2004-09-19 14:24:53 -06:00
{
2015-05-17 07:01:48 -06:00
if ( operations [ t ] - > partition_new = = * selected_partition_ptr )
2004-09-19 14:24:53 -06:00
{
2006-03-24 12:08:41 -07:00
remove_operation ( t ) ;
2009-01-06 15:22:09 -07:00
2015-05-17 07:01:48 -06:00
// And add the new partition to the end of the operations list.
// Create a suitable partition from the selected partition.
Partition temp_partition = * selected_partition_ptr ;
temp_partition . Set_Unallocated ( devices [ current_device ] . get_path ( ) ,
selected_partition_ptr - > whole_device ,
selected_partition_ptr - > sector_start ,
selected_partition_ptr - > sector_end ,
devices [ current_device ] . sector_size ,
selected_partition_ptr - > inside_extended ) ;
2006-08-01 14:19:17 -06:00
Operation * operation = new OperationCreate ( devices [ current_device ] ,
2015-05-17 07:01:48 -06:00
temp_partition ,
dialog . Get_New_Partition ( devices [ current_device ] . sector_size ) ) ;
2006-08-01 14:19:17 -06:00
operation - > icon = render_icon ( Gtk : : Stock : : NEW , Gtk : : ICON_SIZE_MENU ) ;
Add_Operation ( operation ) ;
2004-09-19 14:24:53 -06:00
break ;
}
}
}
2015-05-17 07:01:48 -06:00
else // Normal move/resize on existing partition
2006-08-01 14:19:17 -06:00
{
2015-05-17 07:01:48 -06:00
Operation * operation = new OperationResizeMove ( devices [ current_device ] ,
* selected_partition_ptr ,
dialog . Get_New_Partition ( devices [ current_device ] . sector_size ) ) ;
2006-08-01 14:19:17 -06:00
operation - > icon = render_icon ( Gtk : : Stock : : GOTO_LAST , Gtk : : ICON_SIZE_MENU ) ;
Add_Operation ( operation ) ;
2010-09-01 13:54:00 -06:00
//Display notification if move operation has been queued
2012-01-24 11:20:43 -07:00
if ( operation - > partition_original . sector_start ! = operation - > partition_new . sector_start
& & operation - > partition_original . type ! = TYPE_EXTENDED
)
2010-09-01 13:54:00 -06:00
{
//Warn that move operation might break boot process
Gtk : : MessageDialog dialog ( * this
2012-07-27 05:05:49 -06:00
, _ ( " Moving a partition might cause your operating system to fail to boot " )
2010-09-01 13:54:00 -06:00
, false
, Gtk : : MESSAGE_WARNING
, Gtk : : BUTTONS_OK
, true
) ;
2010-10-13 09:04:20 -06:00
Glib : : ustring tmp_msg =
/*TO TRANSLATORS: looks like You queued an operation to move the start sector of partition /dev/sda3. */
String : : ucompose ( _ ( " You have queued an operation to move the start sector of partition %1. " )
, operation - > partition_original . get_path ( )
) ;
2012-03-19 10:58:39 -06:00
tmp_msg + = _ ( " Failure to boot is most likely to occur if you move the GNU/Linux partition containing /boot, or if you move the Windows system partition C:. " ) ;
2010-09-01 13:54:00 -06:00
tmp_msg + = " \n " ;
tmp_msg + = _ ( " You can learn how to repair the boot configuration in the GParted FAQ. " ) ;
tmp_msg + = " \n " ;
2010-10-12 11:35:26 -06:00
tmp_msg + = " http://gparted.org/faq.php " ;
2010-09-01 13:54:00 -06:00
tmp_msg + = " \n \n " ;
2012-03-19 10:58:39 -06:00
tmp_msg + = _ ( " Moving a partition might take a very long time to apply. " ) ;
2010-09-01 13:54:00 -06:00
dialog . set_secondary_text ( tmp_msg ) ;
dialog . run ( ) ;
}
2011-10-05 12:15:16 -06:00
// Try to merge with previous operation
if ( operations . size ( ) > = 2 )
{
Merge_Operations ( operations . size ( ) - 2 , operations . size ( ) - 1 ) ;
}
2006-08-01 14:19:17 -06:00
}
2004-09-19 14:24:53 -06:00
}
2013-05-17 10:01:42 -06:00
show_operationslist ( ) ;
2004-09-19 14:24:53 -06:00
}
2006-03-07 04:55:27 -07:00
void Win_GParted : : activate_copy ( )
2004-09-19 14:24:53 -06:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-05-17 07:01:48 -06:00
copied_partition = * selected_partition_ptr ;
2004-09-19 14:24:53 -06:00
}
2006-03-07 04:55:27 -07:00
void Win_GParted : : activate_paste ( )
2004-09-19 14:24:53 -06:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-02-17 08:14:23 -07:00
// Unrecognised whole disk device (See GParted_Core::get_devices_threads(), "unrecognized")
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > whole_device & & selected_partition_ptr - > type = = TYPE_UNALLOCATED )
2004-09-19 14:24:53 -06:00
{
2009-10-24 14:16:40 -06:00
show_disklabel_unrecognized ( devices [ current_device ] . get_path ( ) ) ;
2006-11-26 16:24:39 -07:00
return ;
}
2006-03-29 12:21:42 -07:00
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > type = = TYPE_UNALLOCATED )
2006-11-26 16:24:39 -07:00
{
2006-03-29 12:21:42 -07:00
if ( ! max_amount_prim_reached ( ) )
2004-11-06 04:55:03 -07:00
{
2015-05-25 13:09:46 -06:00
Dialog_Partition_Copy dialog ( gparted_core . get_fs ( copied_partition . filesystem ) ) ;
2014-12-12 00:00:02 -07:00
// We don't want the messages, mount points or name of the source
// partition for the new partition being created.
2006-07-30 09:13:41 -06:00
copied_partition . messages . clear ( ) ;
2006-03-29 12:21:42 -07:00
copied_partition . clear_mountpoints ( ) ;
2014-12-12 00:00:02 -07:00
copied_partition . name . clear ( ) ;
2015-05-17 07:01:48 -06:00
dialog . Set_Data ( * selected_partition_ptr , copied_partition ) ;
2006-03-29 12:21:42 -07:00
dialog . set_transient_for ( * this ) ;
2009-01-06 15:22:09 -07:00
2006-03-29 12:21:42 -07:00
if ( dialog . run ( ) = = Gtk : : RESPONSE_OK )
{
dialog . hide ( ) ;
2006-08-01 14:19:17 -06:00
2015-05-17 07:01:48 -06:00
Operation * operation = new OperationCopy ( devices [ current_device ] ,
* selected_partition_ptr ,
dialog . Get_New_Partition ( devices [ current_device ] . sector_size ) ,
copied_partition ) ;
2006-08-01 14:19:17 -06:00
operation - > icon = render_icon ( Gtk : : Stock : : COPY , Gtk : : ICON_SIZE_MENU ) ;
Add_Operation ( operation ) ;
2006-03-29 12:21:42 -07:00
}
2004-11-06 04:55:03 -07:00
}
2004-09-19 14:24:53 -06:00
}
2006-03-29 12:21:42 -07:00
else
{
2012-07-05 16:33:04 -06:00
bool shown_dialog = false ;
2015-05-17 07:01:48 -06:00
// VGNAME from mount mount
if ( selected_partition_ptr - > filesystem = = FS_LVM2_PV & &
! selected_partition_ptr - > get_mountpoint ( ) . empty ( ) )
2012-07-05 16:33:04 -06:00
{
if ( ! remove_non_empty_lvm2_pv_dialog ( OPERATION_COPY ) )
return ;
shown_dialog = true ;
}
2015-05-17 07:01:48 -06:00
Partition partition_new = * selected_partition_ptr ;
2012-03-23 09:51:08 -06:00
partition_new . alignment = ALIGN_STRICT ;
2006-03-29 12:21:42 -07:00
partition_new . filesystem = copied_partition . filesystem ;
2014-12-16 15:04:34 -07:00
partition_new . set_filesystem_label ( copied_partition . get_filesystem_label ( ) ) ;
2012-01-22 13:49:52 -07:00
partition_new . uuid = copied_partition . uuid ;
2006-03-29 12:21:42 -07:00
partition_new . color = copied_partition . color ;
2012-04-11 14:07:52 -06:00
Sector new_size = partition_new . get_sector_length ( ) ;
if ( copied_partition . get_sector_length ( ) = = new_size )
{
//Pasting into same size existing partition, therefore only block copy operation
// will be performed maintaining the file system size.
partition_new . set_sector_usage (
copied_partition . sectors_used + copied_partition . sectors_unused ,
copied_partition . sectors_unused ) ;
}
else
{
//Pasting into larger existing partition, therefore block copy followed by file system
// grow operations (if supported) will be performed making the file system fill the
// partition.
partition_new . set_sector_usage (
new_size ,
new_size - copied_partition . sectors_used ) ;
}
2006-07-30 09:13:41 -06:00
partition_new . messages . clear ( ) ;
2009-01-06 15:22:09 -07:00
2015-05-17 07:01:48 -06:00
Operation * operation = new OperationCopy ( devices [ current_device ] ,
* selected_partition_ptr ,
partition_new ,
copied_partition ) ;
2006-08-01 14:19:17 -06:00
operation - > icon = render_icon ( Gtk : : Stock : : COPY , Gtk : : ICON_SIZE_MENU ) ;
Add_Operation ( operation ) ;
2009-11-25 12:36:43 -07:00
2012-07-05 16:33:04 -06:00
if ( ! shown_dialog )
{
//Only warn that this paste operation will overwrite data in the existing
// partition if not already shown the remove non-empty LVM2 PV dialog.
Gtk : : MessageDialog dialog ( * this
2012-07-27 05:05:49 -06:00
, _ ( " You have pasted into an existing partition " )
2012-07-05 16:33:04 -06:00
, false
, Gtk : : MESSAGE_WARNING
, Gtk : : BUTTONS_OK
, true
) ;
/*TO TRANSLATORS: looks like The data in /dev/sda3 will be lost if you apply this operation. */
dialog . set_secondary_text (
String : : ucompose ( _ ( " The data in %1 will be lost if you apply this operation. " ) ,
partition_new . get_path ( ) ) ) ;
dialog . run ( ) ;
}
2006-03-29 12:21:42 -07:00
}
2013-05-17 10:01:42 -06:00
show_operationslist ( ) ;
2004-09-19 14:24:53 -06:00
}
2006-02-09 10:02:40 -07:00
void Win_GParted : : activate_new ( )
2004-09-19 14:24:53 -06:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-02-17 08:14:23 -07:00
// Unrecognised whole disk device (See GParted_Core::get_devices_threads(), "unrecognized")
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > whole_device & & selected_partition_ptr - > type = = TYPE_UNALLOCATED )
2009-10-24 14:16:40 -06:00
{
show_disklabel_unrecognized ( devices [ current_device ] . get_path ( ) ) ;
}
2006-02-09 10:02:40 -07:00
else if ( ! max_amount_prim_reached ( ) )
2009-01-06 15:22:09 -07:00
{
2004-11-06 04:55:03 -07:00
Dialog_Partition_New dialog ;
2009-01-06 15:22:09 -07:00
2015-05-17 07:01:48 -06:00
dialog . Set_Data ( devices [ current_device ] ,
* selected_partition_ptr ,
index_extended > - 1 ,
new_count ,
gparted_core . get_filesystems ( ) ) ;
2015-03-17 15:14:31 -06:00
2004-11-06 04:55:03 -07:00
dialog . set_transient_for ( * this ) ;
2009-01-06 15:22:09 -07:00
2006-02-09 10:02:40 -07:00
if ( dialog . run ( ) = = Gtk : : RESPONSE_OK )
2004-11-06 04:55:03 -07:00
{
2006-03-07 04:55:27 -07:00
dialog . hide ( ) ;
2009-01-06 15:22:09 -07:00
2004-11-06 04:55:03 -07:00
new_count + + ;
2015-05-17 07:01:48 -06:00
Operation * operation = new OperationCreate ( devices [ current_device ] ,
* selected_partition_ptr ,
dialog . Get_New_Partition ( devices [ current_device ] . sector_size ) ) ;
2006-08-01 14:19:17 -06:00
operation - > icon = render_icon ( Gtk : : Stock : : NEW , Gtk : : ICON_SIZE_MENU ) ;
Add_Operation ( operation ) ;
2013-05-17 10:01:42 -06:00
show_operationslist ( ) ;
2004-11-06 04:55:03 -07:00
}
}
2004-09-19 14:24:53 -06:00
}
2006-01-02 08:18:29 -07:00
void Win_GParted : : activate_delete ( )
2009-01-06 15:22:09 -07:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-05-17 07:01:48 -06:00
// VGNAME from mount mount
if ( selected_partition_ptr - > filesystem = = FS_LVM2_PV & & ! selected_partition_ptr - > get_mountpoint ( ) . empty ( ) )
2012-07-05 16:33:04 -06:00
{
if ( ! remove_non_empty_lvm2_pv_dialog ( OPERATION_DELETE ) )
return ;
}
2006-01-02 08:18:29 -07:00
/* since logicals are *always* numbered from 5 to <last logical> there can be a shift
* in numbers after deletion .
* e . g . consider / dev / hda5 / dev / hda6 / dev / hda7 . Now after removal of / dev / hda6 ,
* / dev / hda7 is renumbered to / dev / hda6
2009-01-06 15:22:09 -07:00
* the new situation is now / dev / hda5 / dev / hda6 . If / dev / hda7 was mounted
2006-01-02 08:18:29 -07:00
* the OS cannot find / dev / hda7 anymore and the results aren ' t that pretty .
* It seems best to check for this and prohibit deletion with some explanation to the user . */
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > type = = TYPE_LOGICAL & &
selected_partition_ptr - > status ! = STAT_NEW & &
selected_partition_ptr - > partition_number < devices [ current_device ] . highest_busy )
2009-01-06 15:22:09 -07:00
{
2006-02-17 14:18:07 -07:00
Gtk : : MessageDialog dialog ( * this ,
2015-05-17 07:01:48 -06:00
String : : ucompose ( _ ( " Unable to delete %1! " ) , selected_partition_ptr - > get_path ( ) ) ,
false ,
Gtk : : MESSAGE_ERROR ,
Gtk : : BUTTONS_OK ,
true ) ;
2006-02-17 14:18:07 -07:00
2009-01-06 15:22:09 -07:00
dialog . set_secondary_text (
2006-02-17 14:18:07 -07:00
String : : ucompose ( _ ( " Please unmount any logical partitions having a number higher than %1 " ) ,
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > partition_number ) ) ;
2006-01-02 08:18:29 -07:00
dialog . run ( ) ;
2004-09-24 19:10:21 -06:00
return ;
2004-09-19 14:24:53 -06:00
}
2009-01-06 15:22:09 -07:00
2006-03-14 14:37:47 -07:00
//if partition is on the clipboard...(NOTE: we can't use Partition::== here..)
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > get_path ( ) = = copied_partition . get_path ( ) )
2004-10-02 03:39:16 -06:00
{
2006-02-17 14:18:07 -07:00
Gtk : : MessageDialog dialog ( * this ,
2015-05-17 07:01:48 -06:00
String : : ucompose ( _ ( " Are you sure you want to delete %1? " ) ,
selected_partition_ptr - > get_path ( ) ) ,
false ,
Gtk : : MESSAGE_QUESTION ,
Gtk : : BUTTONS_NONE ,
true ) ;
2006-02-17 14:18:07 -07:00
dialog . set_secondary_text ( _ ( " After deletion this partition is no longer available for copying. " ) ) ;
2009-01-06 15:22:09 -07:00
2006-01-20 16:35:06 -07:00
/*TO TRANSLATORS: dialogtitle, looks like Delete /dev/hda2 (ntfs, 2345 MiB) */
2015-05-17 07:01:48 -06:00
dialog . set_title ( String : : ucompose ( _ ( " Delete %1 (%2, %3) " ) ,
selected_partition_ptr - > get_path ( ) ,
Utils : : get_filesystem_string ( selected_partition_ptr - > filesystem ) ,
Utils : : format_size ( selected_partition_ptr - > get_sector_length ( ) , selected_partition_ptr - > sector_size ) ) ) ;
2006-01-02 08:18:29 -07:00
dialog . add_button ( Gtk : : Stock : : CANCEL , Gtk : : RESPONSE_CANCEL ) ;
dialog . add_button ( Gtk : : Stock : : DELETE , Gtk : : RESPONSE_OK ) ;
2009-01-06 15:22:09 -07:00
2006-01-02 08:18:29 -07:00
dialog . show_all_children ( ) ;
if ( dialog . run ( ) ! = Gtk : : RESPONSE_OK )
return ;
2004-10-02 03:39:16 -06:00
}
2009-01-06 15:22:09 -07:00
2006-01-02 08:18:29 -07:00
//if deleted partition was on the clipboard we erase it...
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > get_path ( ) = = copied_partition . get_path ( ) )
2006-01-02 08:18:29 -07:00
copied_partition . Reset ( ) ;
2009-01-06 15:22:09 -07:00
2015-05-17 07:01:48 -06:00
// If deleted one is NEW, it doesn't make sense to add it to the operationslist,
// we erase its creation and possible modifications like resize etc.. from the operationslist.
// Calling Refresh_Visual will wipe every memory of its existence ;-)
if ( selected_partition_ptr - > status = = STAT_NEW )
2006-01-02 08:18:29 -07:00
{
2009-01-06 15:22:09 -07:00
//remove all operations done on this new partition (this includes creation)
for ( int t = 0 ; t < static_cast < int > ( operations . size ( ) ) ; t + + )
2015-05-17 07:01:48 -06:00
if ( operations [ t ] - > partition_new . get_path ( ) = = selected_partition_ptr - > get_path ( ) )
2006-03-24 12:08:41 -07:00
remove_operation ( t - - ) ;
2009-01-06 15:22:09 -07:00
2006-01-02 08:18:29 -07:00
//determine lowest possible new_count
2009-01-06 15:22:09 -07:00
new_count = 0 ;
2006-01-02 08:18:29 -07:00
for ( unsigned int t = 0 ; t < operations . size ( ) ; t + + )
2006-03-24 12:08:41 -07:00
if ( operations [ t ] - > partition_new . status = = GParted : : STAT_NEW & &
operations [ t ] - > partition_new . partition_number > new_count )
new_count = operations [ t ] - > partition_new . partition_number ;
2009-01-06 15:22:09 -07:00
2006-01-02 08:18:29 -07:00
new_count + = 1 ;
2009-01-06 15:22:09 -07:00
2011-10-05 12:15:16 -06:00
// Verify if the two operations can be merged
for ( int t = 0 ; t < static_cast < int > ( operations . size ( ) - 1 ) ; t + + )
{
Merge_Operations ( t , t + 1 ) ;
}
2009-01-06 15:22:09 -07:00
Refresh_Visual ( ) ;
2006-01-02 08:18:29 -07:00
if ( ! operations . size ( ) )
close_operationslist ( ) ;
2004-09-19 14:24:53 -06:00
}
2006-08-01 14:19:17 -06:00
else //deletion of a real partition...
{
2015-05-17 07:01:48 -06:00
Operation * operation = new OperationDelete ( devices [ current_device ] , * selected_partition_ptr ) ;
2006-08-01 14:19:17 -06:00
operation - > icon = render_icon ( Gtk : : Stock : : DELETE , Gtk : : ICON_SIZE_MENU ) ;
Add_Operation ( operation ) ;
}
2013-05-17 10:01:42 -06:00
show_operationslist ( ) ;
2004-09-19 14:24:53 -06:00
}
2006-02-17 14:18:07 -07:00
void Win_GParted : : activate_info ( )
2004-09-19 14:24:53 -06:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-05-17 07:01:48 -06:00
Dialog_Partition_Info dialog ( * selected_partition_ptr ) ;
2004-12-27 05:08:01 -07:00
dialog . set_transient_for ( * this ) ;
2006-01-02 08:18:29 -07:00
dialog . run ( ) ;
2004-09-19 14:24:53 -06:00
}
2006-01-02 08:18:29 -07:00
void Win_GParted : : activate_format ( GParted : : FILESYSTEM new_fs )
2004-09-19 14:24:53 -06:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-05-17 07:01:48 -06:00
// VGNAME from mount mount
if ( selected_partition_ptr - > filesystem = = FS_LVM2_PV & & ! selected_partition_ptr - > get_mountpoint ( ) . empty ( ) )
2012-07-05 16:33:04 -06:00
{
if ( ! remove_non_empty_lvm2_pv_dialog ( OPERATION_FORMAT ) )
return ;
}
2004-12-09 15:56:33 -07:00
//check for some limits...
2005-01-11 14:18:15 -07:00
fs = gparted_core . get_fs ( new_fs ) ;
2012-07-05 16:33:04 -06:00
2015-05-17 07:01:48 -06:00
if ( ( selected_partition_ptr - > get_byte_length ( ) < fs . MIN ) | |
( fs . MAX & & selected_partition_ptr - > get_byte_length ( ) > fs . MAX ) )
2004-09-19 14:24:53 -06:00
{
2006-02-17 14:18:07 -07:00
Gtk : : MessageDialog dialog ( * this ,
2010-10-12 18:14:30 -06:00
String : : ucompose (
/* TO TRANSLATORS: looks like
* Cannot format this file system to fat16 .
*/
2012-07-27 05:05:49 -06:00
_ ( " Cannot format this file system to %1 " ) ,
2010-10-12 18:14:30 -06:00
Utils : : get_filesystem_string ( new_fs ) ) ,
2006-02-17 14:18:07 -07:00
false ,
Gtk : : MESSAGE_ERROR ,
Gtk : : BUTTONS_OK ,
true ) ;
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > get_byte_length ( ) < fs . MIN )
2010-10-12 18:14:30 -06:00
dialog . set_secondary_text ( String : : ucompose (
/* TO TRANSLATORS: looks like
* A fat16 file system requires a partition of at least 16.00 MiB .
*/
2008-11-18 16:58:17 -07:00
_ ( " A %1 file system requires a partition of at least %2. " ) ,
2006-03-28 05:40:29 -07:00
Utils : : get_filesystem_string ( new_fs ) ,
2010-04-26 11:42:23 -06:00
Utils : : format_size ( fs . MIN , 1 /* Byte */ ) ) ) ;
2004-12-09 15:56:33 -07:00
else
2010-10-12 18:14:30 -06:00
dialog . set_secondary_text ( String : : ucompose (
/* TO TRANSLATORS: looks like
* A partition with a hfs file system has a maximum size of 2.00 GiB .
*/
2008-11-18 16:58:17 -07:00
_ ( " A partition with a %1 file system has a maximum size of %2. " ) ,
2006-03-28 05:40:29 -07:00
Utils : : get_filesystem_string ( new_fs ) ,
2010-04-26 11:42:23 -06:00
Utils : : format_size ( fs . MAX , 1 /* Byte */ ) ) ) ;
2009-01-06 15:22:09 -07:00
2006-01-02 08:18:29 -07:00
dialog . run ( ) ;
2004-12-09 15:56:33 -07:00
return ;
2004-09-19 14:24:53 -06:00
}
2009-01-06 15:22:09 -07:00
2006-02-17 14:18:07 -07:00
//ok we made it. lets create an fitting partition object
2006-03-14 14:37:47 -07:00
Partition part_temp ;
2015-01-04 04:29:01 -07:00
part_temp . Set ( devices [ current_device ] . get_path ( ) ,
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > get_path ( ) ,
selected_partition_ptr - > partition_number ,
selected_partition_ptr - > type ,
selected_partition_ptr - > whole_device ,
2015-01-04 04:29:01 -07:00
new_fs ,
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > sector_start ,
selected_partition_ptr - > sector_end ,
2015-01-04 04:29:01 -07:00
devices [ current_device ] . sector_size ,
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > inside_extended ,
2015-01-04 04:29:01 -07:00
false ) ;
2015-05-17 07:01:48 -06:00
part_temp . name = selected_partition_ptr - > name ;
2012-04-11 14:07:52 -06:00
//Leave sector usage figures to new Partition object defaults of
// -1, -1, 0 (_used, _unused, _unallocated) representing unknown.
2009-01-06 15:22:09 -07:00
2006-03-18 14:38:19 -07:00
part_temp . status = GParted : : STAT_FORMATTED ;
2009-01-06 15:22:09 -07:00
2015-05-17 07:01:48 -06:00
// If selected partition is NEW we simply remove the NEW operation from the list and
// add it again with the new file system
if ( selected_partition_ptr - > status = = STAT_NEW )
2004-09-19 14:24:53 -06:00
{
//remove operation which creates this partition
2006-01-02 08:18:29 -07:00
for ( unsigned int t = 0 ; t < operations . size ( ) ; t + + )
2004-09-19 14:24:53 -06:00
{
2015-05-17 07:01:48 -06:00
if ( operations [ t ] - > partition_new = = * selected_partition_ptr )
2004-09-19 14:24:53 -06:00
{
2006-03-24 12:08:41 -07:00
remove_operation ( t ) ;
2009-01-06 15:22:09 -07:00
2006-08-01 14:19:17 -06:00
//And insert the new partition at the old position in the operations list
2006-01-02 08:18:29 -07:00
//(NOTE: in this case we set status to STAT_NEW)
2004-09-26 12:41:43 -06:00
part_temp . status = STAT_NEW ;
2009-01-06 15:22:09 -07:00
2015-05-17 07:01:48 -06:00
Operation * operation = new OperationCreate ( devices [ current_device ] ,
* selected_partition_ptr ,
part_temp ) ;
2006-08-01 14:19:17 -06:00
operation - > icon = render_icon ( Gtk : : Stock : : NEW , Gtk : : ICON_SIZE_MENU ) ;
Add_Operation ( operation , t ) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
break ;
}
}
}
2006-01-02 08:18:29 -07:00
else //normal formatting of an existing partition
2006-08-01 14:19:17 -06:00
{
2015-05-17 07:01:48 -06:00
Operation * operation = new OperationFormat ( devices [ current_device ] ,
* selected_partition_ptr ,
part_temp ) ;
2006-08-01 14:19:17 -06:00
operation - > icon = render_icon ( Gtk : : Stock : : CONVERT , Gtk : : ICON_SIZE_MENU ) ;
Add_Operation ( operation ) ;
2011-10-05 12:15:16 -06:00
// Try to merge with previous operation
if ( operations . size ( ) > = 2 )
{
Merge_Operations ( operations . size ( ) - 2 , operations . size ( ) - 1 ) ;
}
2006-08-01 14:19:17 -06:00
}
2013-05-17 10:01:42 -06:00
show_operationslist ( ) ;
2004-09-19 14:24:53 -06:00
}
2013-02-21 17:57:33 -07:00
void Win_GParted : : unmount_partition ( bool * succes , Glib : : ustring * error )
2006-01-08 08:20:14 -07:00
{
2014-02-16 06:29:33 -07:00
std : : vector < Glib : : ustring > errors , failed_mountpoints , mountpoints = GParted_Core : : get_all_mountpoints ( ) ;
2006-02-17 14:18:07 -07:00
Glib : : ustring dummy ;
2006-02-20 07:41:05 -07:00
2009-01-06 15:22:09 -07:00
* succes = true ;
2015-05-17 07:01:48 -06:00
for ( unsigned int t = 0 ; t < selected_partition_ptr - > get_mountpoints ( ) . size ( ) ; t + + )
if ( std : : count ( mountpoints . begin ( ) ,
mountpoints . end ( ) ,
selected_partition_ptr - > get_mountpoints ( ) [ t ] ) < = 1 )
2006-02-20 07:41:05 -07:00
{
2015-05-17 07:01:48 -06:00
Glib : : ustring cmd = " umount -v \" " + selected_partition_ptr - > get_mountpoints ( ) [ t ] + " \" " ;
2015-01-11 05:49:52 -07:00
if ( Utils : : execute_command ( cmd , dummy , * error ) )
2006-02-20 07:41:05 -07:00
{
* succes = false ;
2015-01-11 05:49:52 -07:00
errors . push_back ( " # " + cmd + " \n " + * error ) ;
2006-02-20 07:41:05 -07:00
}
}
else
2015-05-17 07:01:48 -06:00
failed_mountpoints . push_back ( selected_partition_ptr - > get_mountpoints ( ) [ t ] ) ;
2006-02-20 07:41:05 -07:00
if ( * succes & & failed_mountpoints . size ( ) )
{
* succes = false ;
2008-11-18 16:58:17 -07:00
* error = _ ( " The partition could not be unmounted from the following mount points: " ) ;
2006-02-20 07:41:05 -07:00
* error + = " \n \n <i> " + Glib : : build_path ( " \n " , failed_mountpoints ) + " </i> \n \n " ;
2008-11-18 16:58:17 -07:00
* error + = _ ( " Most likely other partitions are also mounted on these mount points. You are advised to unmount them manually. " ) ;
2006-02-20 07:41:05 -07:00
}
else
* error = " <i> " + Glib : : build_path ( " \n " , errors ) + " </i> " ;
2006-01-08 08:20:14 -07:00
}
2009-01-06 15:22:09 -07:00
2012-06-17 05:26:49 -06:00
void Win_GParted : : toggle_busy_state ( )
2010-08-09 13:37:08 -06:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-05-17 07:01:48 -06:00
int operation_count = partition_in_operation_queue_count ( * selected_partition_ptr ) ;
2013-02-21 17:57:33 -07:00
bool success = false ;
2015-01-11 05:49:52 -07:00
Glib : : ustring cmd ;
2013-02-21 17:57:33 -07:00
Glib : : ustring output ;
2015-01-11 05:49:52 -07:00
Glib : : ustring error ;
2013-02-21 17:57:33 -07:00
2010-08-09 13:37:08 -06:00
if ( operation_count > 0 )
{
2012-02-13 05:44:45 -07:00
//Note that this situation will only occur when trying to swapon a partition
// or activate the Volume Group of a Physical Volume. This is because
// GParted does not permit queueing operations on partitions that are
// currently active (i.e., swap enabled, mounted or active VG). Hence
// this situation will not occur for the swapoff, unmount or deactivate VG
// actions that this method handles.
2010-08-09 13:37:08 -06:00
/*TO TRANSLATORS: Singular case looks like 1 operation is currently pending for partition /dev/sdd8. */
Glib : : ustring tmp_msg =
2012-07-27 05:05:49 -06:00
String : : ucompose ( ngettext ( " %1 operation is currently pending for partition %2 "
, " %1 operations are currently pending for partition %2 "
2010-08-09 13:37:08 -06:00
, operation_count
)
, operation_count
2015-05-17 07:01:48 -06:00
, selected_partition_ptr - > get_path ( )
2010-08-09 13:37:08 -06:00
) ;
Gtk : : MessageDialog dialog ( * this
, tmp_msg
, false
, Gtk : : MESSAGE_INFO
, Gtk : : BUTTONS_OK
, true
) ;
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > filesystem = = FS_LINUX_SWAP )
2012-02-13 05:44:45 -07:00
{
tmp_msg = _ ( " The swapon action cannot be performed if an operation is pending for the partition. " ) ;
tmp_msg + = " \n " ;
tmp_msg + = _ ( " Use the Edit menu to undo, clear, or apply operations before using swapon with this partition. " ) ;
}
2015-05-17 07:01:48 -06:00
else if ( selected_partition_ptr - > filesystem = = FS_LVM2_PV )
2012-02-13 05:44:45 -07:00
{
tmp_msg = _ ( " The activate Volume Group action cannot be performed if an operation is pending for the partition. " ) ;
tmp_msg + = " \n " ;
tmp_msg + = _ ( " Use the Edit menu to undo, clear, or apply operations before using activate Volume Group with this partition. " ) ;
}
2010-08-09 13:37:08 -06:00
dialog . set_secondary_text ( tmp_msg ) ;
dialog . run ( ) ;
return ;
}
2015-05-17 07:01:48 -06:00
if ( selected_partition_ptr - > filesystem = = FS_LINUX_SWAP )
2006-03-09 12:37:50 -07:00
{
2009-01-06 15:22:09 -07:00
show_pulsebar (
String : : ucompose (
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > busy ? _ ( " Deactivating swap on %1 " ) : _ ( " Activating swap on %1 " ) ,
selected_partition_ptr - > get_path ( ) ) ) ;
if ( selected_partition_ptr - > busy )
cmd = " swapoff -v " + selected_partition_ptr - > get_path ( ) ;
2013-02-21 17:57:33 -07:00
else
2015-05-17 07:01:48 -06:00
cmd = " swapon -v " + selected_partition_ptr - > get_path ( ) ;
2015-01-11 05:49:52 -07:00
success = ! Utils : : execute_command ( cmd , output , error ) ;
2013-02-21 17:57:33 -07:00
hide_pulsebar ( ) ;
if ( ! success )
2006-03-09 12:37:50 -07:00
{
2009-01-06 15:22:09 -07:00
Gtk : : MessageDialog dialog (
2006-03-09 12:37:50 -07:00
* this ,
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > busy ? _ ( " Could not deactivate swap " ) : _ ( " Could not activate swap " ) ,
2006-03-09 12:37:50 -07:00
false ,
Gtk : : MESSAGE_ERROR ,
Gtk : : BUTTONS_OK ,
true ) ;
2015-01-11 05:49:52 -07:00
dialog . set_secondary_text ( " # " + cmd + " \n " + error ) ;
2006-03-09 12:37:50 -07:00
dialog . run ( ) ;
}
}
2015-05-17 07:01:48 -06:00
else if ( selected_partition_ptr - > filesystem = = FS_LVM2_PV )
2012-02-13 05:44:45 -07:00
{
show_pulsebar (
String : : ucompose (
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > busy ? _ ( " Deactivating Volume Group %1 " )
: _ ( " Activating Volume Group %1 " ) ,
// VGNAME from mount point
selected_partition_ptr - > get_mountpoint ( ) ) ) ;
if ( selected_partition_ptr - > busy )
// VGNAME from mount point
cmd = " lvm vgchange -a n " + selected_partition_ptr - > get_mountpoint ( ) ;
2013-02-21 17:57:33 -07:00
else
2015-05-17 07:01:48 -06:00
cmd = " lvm vgchange -a y " + selected_partition_ptr - > get_mountpoint ( ) ;
2015-01-11 05:49:52 -07:00
success = ! Utils : : execute_command ( cmd , output , error ) ;
2013-02-21 17:57:33 -07:00
hide_pulsebar ( ) ;
2012-02-13 05:44:45 -07:00
2013-02-21 17:57:33 -07:00
if ( ! success )
2012-02-13 05:44:45 -07:00
{
Gtk : : MessageDialog dialog (
* this ,
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > busy ? _ ( " Could not deactivate Volume Group " )
: _ ( " Could not activate Volume Group " ) ,
2012-02-13 05:44:45 -07:00
false ,
Gtk : : MESSAGE_ERROR ,
Gtk : : BUTTONS_OK ,
true ) ;
2015-01-11 05:49:52 -07:00
dialog . set_secondary_text ( " # " + cmd + " \n " + error ) ;
2012-02-13 05:44:45 -07:00
dialog . run ( ) ;
}
}
2015-05-17 07:01:48 -06:00
else if ( selected_partition_ptr - > busy )
2006-01-07 14:23:09 -07:00
{
2015-05-17 07:01:48 -06:00
show_pulsebar ( String : : ucompose ( _ ( " Unmounting %1 " ) , selected_partition_ptr - > get_path ( ) ) ) ;
2013-02-21 17:57:33 -07:00
unmount_partition ( & success , & error ) ;
hide_pulsebar ( ) ;
if ( ! success )
2006-03-09 12:37:50 -07:00
{
2009-01-06 15:22:09 -07:00
Gtk : : MessageDialog dialog ( * this ,
2015-05-17 07:01:48 -06:00
String : : ucompose ( _ ( " Could not unmount %1 " ) ,
selected_partition_ptr - > get_path ( ) ) ,
false ,
Gtk : : MESSAGE_ERROR ,
Gtk : : BUTTONS_OK ,
true ) ;
2006-03-09 12:37:50 -07:00
dialog . set_secondary_text ( error , true ) ;
2009-01-06 15:22:09 -07:00
2006-03-09 12:37:50 -07:00
dialog . run ( ) ;
}
2006-01-07 14:23:09 -07:00
}
2006-03-09 12:37:50 -07:00
2006-01-07 14:23:09 -07:00
menu_gparted_refresh_devices ( ) ;
2004-11-06 12:48:24 -07:00
}
2010-08-09 13:37:08 -06:00
2009-01-06 15:22:09 -07:00
void Win_GParted : : activate_mount_partition ( unsigned int index )
2006-03-16 10:09:17 -07:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-05-17 07:01:48 -06:00
int operation_count = partition_in_operation_queue_count ( * selected_partition_ptr ) ;
2010-08-09 13:37:08 -06:00
if ( operation_count > 0 )
{
/*TO TRANSLATORS: Plural case looks like 4 operations are currently pending for partition /dev/sdd8. */
Glib : : ustring tmp_msg =
2012-07-27 05:05:49 -06:00
String : : ucompose ( ngettext ( " %1 operation is currently pending for partition %2 "
, " %1 operations are currently pending for partition %2 "
2010-08-09 13:37:08 -06:00
, operation_count
)
, operation_count
2015-05-17 07:01:48 -06:00
, selected_partition_ptr - > get_path ( )
2010-08-09 13:37:08 -06:00
) ;
Gtk : : MessageDialog dialog ( * this
, tmp_msg
, false
, Gtk : : MESSAGE_INFO
, Gtk : : BUTTONS_OK
, true
) ;
tmp_msg = _ ( " The mount action cannot be performed if an operation is pending for the partition. " ) ;
tmp_msg + = " \n " ;
tmp_msg + = _ ( " Use the Edit menu to undo, clear, or apply operations before using mount with this partition. " ) ;
dialog . set_secondary_text ( tmp_msg ) ;
dialog . run ( ) ;
return ;
}
2013-02-21 17:57:33 -07:00
bool success = false ;
2015-01-10 09:00:11 -07:00
Glib : : ustring cmd ;
Glib : : ustring output ;
Glib : : ustring error ;
2015-01-11 03:14:47 -07:00
Glib : : ustring message ;
2006-03-16 10:09:17 -07:00
show_pulsebar ( String : : ucompose ( _ ( " mounting %1 on %2 " ) ,
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > get_path ( ) ,
selected_partition_ptr - > get_mountpoints ( ) [ index ] ) ) ;
2015-01-11 03:14:47 -07:00
// First try mounting letting mount (libblkid) determine the file system type.
// Do this because GParted uses libparted first and blkid second and when there
// are multiple signatures GParted may report a different result to blkid alone.
2015-05-17 07:01:48 -06:00
cmd = " mount -v " + selected_partition_ptr - > get_path ( ) +
" \" " + selected_partition_ptr - > get_mountpoints ( ) [ index ] + " \" " ;
2015-01-10 09:00:11 -07:00
success = ! Utils : : execute_command ( cmd , output , error ) ;
2015-01-11 03:14:47 -07:00
if ( ! success )
{
message = " # " + cmd + " \n " + error ;
2015-05-17 07:01:48 -06:00
Glib : : ustring type = Utils : : get_filesystem_kernel_name ( selected_partition_ptr - > filesystem ) ;
2015-01-11 03:14:47 -07:00
if ( ! type . empty ( ) )
{
// Second try mounting specifying the GParted determined file
// system type.
2015-05-17 07:01:48 -06:00
cmd = " mount -v -t " + type + " " + selected_partition_ptr - > get_path ( ) +
" \" " + selected_partition_ptr - > get_mountpoints ( ) [ index ] + " \" " ;
2015-01-11 03:14:47 -07:00
success = ! Utils : : execute_command ( cmd , output , error ) ;
if ( ! success )
message + = " \n # " + cmd + " \n " + error ;
}
}
2013-02-21 17:57:33 -07:00
hide_pulsebar ( ) ;
if ( ! success )
2006-03-16 10:09:17 -07:00
{
2009-01-06 15:22:09 -07:00
Gtk : : MessageDialog dialog ( * this ,
2015-05-17 07:01:48 -06:00
String : : ucompose ( _ ( " Could not mount %1 on %2 " ) ,
selected_partition_ptr - > get_path ( ) ,
selected_partition_ptr - > get_mountpoints ( ) [ index ] ) ,
false ,
Gtk : : MESSAGE_ERROR ,
Gtk : : BUTTONS_OK ,
true ) ;
2006-03-16 10:09:17 -07:00
2015-01-11 03:14:47 -07:00
dialog . set_secondary_text ( message ) ;
2015-01-10 09:00:11 -07:00
2006-03-16 10:09:17 -07:00
dialog . run ( ) ;
}
menu_gparted_refresh_devices ( ) ;
}
2004-11-06 12:48:24 -07:00
2006-02-17 14:18:07 -07:00
void Win_GParted : : activate_disklabel ( )
2005-01-30 07:31:29 -07:00
{
2010-08-10 12:59:26 -06:00
//If there are active mounted partitions on the device then warn
// the user that all partitions must be unactive before creating
// a new partition table
int active_count = active_partitions_on_device_count ( devices [ current_device ] ) ;
if ( active_count > 0 )
{
Glib : : ustring tmp_msg =
2012-07-27 05:05:49 -06:00
String : : ucompose ( /*TO TRANSLATORS: Singular case looks like 1 partition is currently active on device /dev/sda */
ngettext ( " %1 partition is currently active on device %2 "
/*TO TRANSLATORS: Plural case looks like 3 partitions are currently active on device /dev/sda */
, " %1 partitions are currently active on device %2 "
2010-08-10 12:59:26 -06:00
, active_count
)
, active_count
, devices [ current_device ] . get_path ( )
) ;
Gtk : : MessageDialog dialog ( * this
, tmp_msg
, false
, Gtk : : MESSAGE_INFO
, Gtk : : BUTTONS_OK
, true
) ;
tmp_msg = _ ( " A new partition table cannot be created when there are active partitions. " ) ;
tmp_msg + = " " ;
tmp_msg + = _ ( " Active partitions are those that are in use, such as a mounted file system, or enabled swap space. " ) ;
tmp_msg + = " \n " ;
tmp_msg + = _ ( " Use Partition menu options, such as unmount or swapoff, to deactivate all partitions on this device before creating a new partition table. " ) ;
dialog . set_secondary_text ( tmp_msg ) ;
dialog . run ( ) ;
return ;
}
2009-10-25 14:33:36 -06:00
//If there are pending operations then warn the user that these
// operations must either be applied or cleared before creating
// a new partition table.
if ( operations . size ( ) )
{
Glib : : ustring tmp_msg =
2012-07-27 05:05:49 -06:00
String : : ucompose ( ngettext ( " %1 operation is currently pending "
, " %1 operations are currently pending "
2009-10-25 14:33:36 -06:00
, operations . size ( )
)
, operations . size ( )
) ;
Gtk : : MessageDialog dialog ( * this
, tmp_msg
, false
, Gtk : : MESSAGE_INFO
, Gtk : : BUTTONS_OK
, true
) ;
tmp_msg = _ ( " A new partition table cannot be created when there are pending operations. " ) ;
tmp_msg + = " \n " ;
tmp_msg + = _ ( " Use the Edit menu to either clear or apply all operations before creating a new partition table. " ) ;
dialog . set_secondary_text ( tmp_msg ) ;
dialog . run ( ) ;
return ;
}
//Display dialog for creating a new partition table.
2014-01-03 13:56:57 -07:00
Dialog_Disklabel dialog ( devices [ current_device ] ) ;
2005-01-30 07:31:29 -07:00
dialog . set_transient_for ( * this ) ;
2009-07-06 15:58:08 -06:00
if ( dialog . run ( ) = = Gtk : : RESPONSE_APPLY )
2005-01-30 07:31:29 -07:00
{
2015-02-14 13:49:45 -07:00
if ( ! gparted_core . set_disklabel ( devices [ current_device ] , dialog . Get_Disklabel ( ) ) )
2005-01-30 07:31:29 -07:00
{
2006-02-17 14:18:07 -07:00
Gtk : : MessageDialog dialog ( * this ,
2012-07-27 05:05:49 -06:00
_ ( " Error while creating partition table " ) ,
2006-02-17 14:18:07 -07:00
true ,
Gtk : : MESSAGE_ERROR ,
Gtk : : BUTTONS_OK ,
true ) ;
dialog . run ( ) ;
2005-01-30 07:31:29 -07:00
}
2006-04-15 06:42:57 -06:00
dialog . hide ( ) ;
2009-01-06 15:22:09 -07:00
2006-02-17 14:18:07 -07:00
menu_gparted_refresh_devices ( ) ;
2005-01-30 07:31:29 -07:00
}
}
2011-01-28 11:09:21 -07:00
//Runs when the Device->Attempt Rescue Data is clicked
void Win_GParted : : activate_attempt_rescue_data ( )
{
if ( Glib : : find_program_in_path ( " gpart " ) . empty ( ) ) //Gpart must be installed to continue
{
Gtk : : MessageDialog errorDialog ( * this , " " , true , Gtk : : MESSAGE_ERROR , Gtk : : BUTTONS_OK , true ) ;
errorDialog . set_message ( _ ( " Command gpart was not found " ) ) ;
errorDialog . set_secondary_text ( _ ( " This feature uses gpart. Please install gpart and try again. " ) ) ;
errorDialog . run ( ) ;
return ;
}
//Dialog information
Glib : : ustring sec_text = _ ( " A full disk scan is needed to find file systems. " ) ;
sec_text + = " \n " ;
sec_text + = _ ( " The scan might take a very long time. " ) ;
sec_text + = " \n " ;
sec_text + = _ ( " After the scan you can mount any discovered file systems and copy the data to other media. " ) ;
sec_text + = " \n " ;
sec_text + = _ ( " Do you want to continue? " ) ;
Gtk : : MessageDialog messageDialog ( * this , " " , true , Gtk : : MESSAGE_WARNING , Gtk : : BUTTONS_OK_CANCEL , true ) ;
/*TO TRANSLATORS: looks like Search for file systems on /deb/sdb */
messageDialog . set_message ( String : : ucompose ( _ ( " Search for file systems on %1 " ) , devices [ current_device ] . get_path ( ) ) ) ;
messageDialog . set_secondary_text ( sec_text ) ;
if ( messageDialog . run ( ) ! = Gtk : : RESPONSE_OK )
{
return ;
}
messageDialog . hide ( ) ;
/*TO TRANSLATORS: looks like Searching for file systems on /deb/sdb */
show_pulsebar ( String : : ucompose ( _ ( " Searching for file systems on %1 " ) , devices [ current_device ] . get_path ( ) ) ) ;
2013-02-21 17:57:33 -07:00
gpart_output = " " ;
gparted_core . guess_partition_table ( devices [ current_device ] , gpart_output ) ;
hide_pulsebar ( ) ;
2011-01-28 11:09:21 -07:00
Dialog_Rescue_Data dialog ;
dialog . set_transient_for ( * this ) ;
//Reads the output of gpart
dialog . init_partitions ( & devices [ current_device ] , this - > gpart_output ) ;
if ( dialog . get_partitions ( ) . size ( ) = = 0 ) //No partitions found
{
//Dialog information
Gtk : : MessageDialog errorDialog ( * this , " " , true , Gtk : : MESSAGE_ERROR , Gtk : : BUTTONS_OK , true ) ;
/*TO TRANSLATORS: looks like No file systems found on /deb/sdb */
errorDialog . set_message ( String : : ucompose ( _ ( " No file systems found on %1 " ) , devices [ current_device ] . get_path ( ) ) ) ;
errorDialog . set_secondary_text ( _ ( " The disk scan by gpart did not find any recognizable file systems on this disk. " ) ) ;
errorDialog . run ( ) ;
return ;
}
dialog . run ( ) ;
dialog . hide ( ) ;
Glib : : ustring commandUmount = " umount /tmp/gparted-roview* " ;
Utils : : execute_command ( commandUmount ) ;
menu_gparted_refresh_devices ( ) ;
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : activate_manage_flags ( )
2006-03-31 03:49:27 -07:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2006-04-02 05:18:34 -06:00
get_window ( ) - > set_cursor ( Gdk : : Cursor ( Gdk : : WATCH ) ) ;
while ( Gtk : : Main : : events_pending ( ) )
Gtk : : Main : : iteration ( ) ;
2006-03-31 03:49:27 -07:00
2015-05-17 07:01:48 -06:00
DialogManageFlags dialog ( * selected_partition_ptr , gparted_core . get_available_flags ( * selected_partition_ptr ) ) ;
2006-04-02 05:18:34 -06:00
dialog . set_transient_for ( * this ) ;
2006-03-31 03:49:27 -07:00
dialog . signal_get_flags . connect (
sigc : : mem_fun ( & gparted_core , & GParted_Core : : get_available_flags ) ) ;
dialog . signal_toggle_flag . connect (
sigc : : mem_fun ( & gparted_core , & GParted_Core : : toggle_flag ) ) ;
2006-04-02 05:18:34 -06:00
get_window ( ) - > set_cursor ( ) ;
2009-01-06 15:22:09 -07:00
2006-03-31 03:49:27 -07:00
dialog . run ( ) ;
dialog . hide ( ) ;
2009-01-06 15:22:09 -07:00
2006-03-31 03:49:27 -07:00
if ( dialog . any_change )
menu_gparted_refresh_devices ( ) ;
}
2009-01-06 15:22:09 -07:00
void Win_GParted : : activate_check ( )
2006-11-26 07:27:16 -07:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-05-17 07:01:48 -06:00
Operation * operation = new OperationCheck ( devices [ current_device ] , * selected_partition_ptr ) ;
2006-11-26 07:27:16 -07:00
operation - > icon = render_icon ( Gtk : : Stock : : EXECUTE , Gtk : : ICON_SIZE_MENU ) ;
Add_Operation ( operation ) ;
2011-10-05 12:15:16 -06:00
// Verify if the two operations can be merged
for ( unsigned int t = 0 ; t < operations . size ( ) - 1 ; t + + )
{
if ( operations [ t ] - > type = = OPERATION_CHECK )
{
if ( Merge_Operations ( t , operations . size ( ) - 1 ) )
break ;
}
}
2013-05-17 10:01:42 -06:00
show_operationslist ( ) ;
2006-11-26 07:27:16 -07:00
}
2005-01-30 07:31:29 -07:00
2014-12-18 15:18:33 -07:00
void Win_GParted : : activate_label_filesystem ( )
2008-04-07 13:41:18 -06:00
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-05-17 07:01:48 -06:00
Dialog_FileSystem_Label dialog ( * selected_partition_ptr ) ;
2008-04-07 13:41:18 -06:00
dialog . set_transient_for ( * this ) ;
2015-05-17 07:01:48 -06:00
if ( dialog . run ( ) = = Gtk : : RESPONSE_OK
& & dialog . get_new_label ( ) ! = selected_partition_ptr - > get_filesystem_label ( ) )
2008-04-07 13:41:18 -06:00
{
dialog . hide ( ) ;
2015-05-17 07:01:48 -06:00
// Make a duplicate of the selected partition (used in UNDO)
Partition part_temp = * selected_partition_ptr ;
2008-04-07 13:41:18 -06:00
2014-12-16 15:04:34 -07:00
part_temp . set_filesystem_label ( dialog . get_new_label ( ) ) ;
2008-04-07 13:41:18 -06:00
2014-12-19 13:41:08 -07:00
Operation * operation = new OperationLabelFileSystem ( devices [ current_device ] ,
2015-05-17 07:01:48 -06:00
* selected_partition_ptr , part_temp ) ;
2008-04-07 13:41:18 -06:00
operation - > icon = render_icon ( Gtk : : Stock : : EXECUTE , Gtk : : ICON_SIZE_MENU ) ;
2011-10-05 12:15:16 -06:00
2008-04-07 13:41:18 -06:00
Add_Operation ( operation ) ;
2011-10-05 12:15:16 -06:00
// Verify if the two operations can be merged
for ( unsigned int t = 0 ; t < operations . size ( ) - 1 ; t + + )
{
2014-12-16 14:06:20 -07:00
if ( operations [ t ] - > type = = OPERATION_LABEL_FILESYSTEM )
2011-10-05 12:15:16 -06:00
{
if ( Merge_Operations ( t , operations . size ( ) - 1 ) )
break ;
}
}
2013-05-17 10:01:42 -06:00
show_operationslist ( ) ;
2008-04-07 13:41:18 -06:00
}
}
2014-12-12 00:00:02 -07:00
void Win_GParted : : activate_name_partition ( )
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-05-17 07:01:48 -06:00
Dialog_Partition_Name dialog ( * selected_partition_ptr ,
2015-03-13 16:36:08 -06:00
devices [ current_device ] . get_max_partition_name_length ( ) ) ;
2014-12-12 00:00:02 -07:00
dialog . set_transient_for ( * this ) ;
2015-05-17 07:01:48 -06:00
if ( dialog . run ( ) = = Gtk : : RESPONSE_OK
& & dialog . get_new_name ( ) ! = selected_partition_ptr - > name )
2014-12-12 00:00:02 -07:00
{
dialog . hide ( ) ;
// Make a duplicate of the selected partition (used in UNDO)
2015-05-17 07:01:48 -06:00
Partition part_temp = * selected_partition_ptr ;
2014-12-12 00:00:02 -07:00
part_temp . name = dialog . get_new_name ( ) ;
Operation * operation = new OperationNamePartition ( devices [ current_device ] ,
2015-05-17 07:01:48 -06:00
* selected_partition_ptr , part_temp ) ;
2014-12-12 00:00:02 -07:00
operation - > icon = render_icon ( Gtk : : Stock : : EXECUTE , Gtk : : ICON_SIZE_MENU ) ;
Add_Operation ( operation ) ;
// Verify if the two operations can be merged
for ( unsigned int t = 0 ; t < operations . size ( ) - 1 ; t + + )
{
if ( operations [ t ] - > type = = OPERATION_NAME_PARTITION )
{
if ( Merge_Operations ( t , operations . size ( ) - 1 ) )
break ;
}
}
show_operationslist ( ) ;
}
}
2012-01-22 13:49:52 -07:00
void Win_GParted : : activate_change_uuid ( )
{
2015-06-03 14:33:21 -06:00
g_assert ( selected_partition_ptr ! = NULL ) ; // Bug: Partition callback without a selected partition
2015-05-31 09:32:23 -06:00
g_assert ( valid_display_partition_ptr ( selected_partition_ptr ) ) ; // Bug: Not pointing at a valid display partition object
2015-06-03 14:33:21 -06:00
2015-05-17 07:01:48 -06:00
const FileSystem * filesystem_object = gparted_core . get_filesystem_object ( selected_partition_ptr - > filesystem ) ;
2015-05-16 02:58:58 -06:00
if ( filesystem_object - > get_custom_text ( CTEXT_CHANGE_UUID_WARNING ) ! = " " )
{
2012-01-30 11:33:33 -07:00
int i ;
2015-05-16 02:58:58 -06:00
Gtk : : MessageDialog dialog ( * this ,
filesystem_object - > get_custom_text ( CTEXT_CHANGE_UUID_WARNING , 0 ) ,
false ,
Gtk : : MESSAGE_WARNING ,
Gtk : : BUTTONS_OK ,
true ) ;
2012-01-30 11:33:33 -07:00
Glib : : ustring tmp_msg = " " ;
2015-05-16 02:58:58 -06:00
for ( i = 1 ; filesystem_object - > get_custom_text ( CTEXT_CHANGE_UUID_WARNING , i ) ! = " " ; i + + )
{
2012-01-30 11:33:33 -07:00
if ( i > 1 )
tmp_msg + = " \n \n " ;
2015-05-16 02:58:58 -06:00
tmp_msg + = filesystem_object - > get_custom_text ( CTEXT_CHANGE_UUID_WARNING , i ) ;
2012-01-30 11:33:33 -07:00
}
dialog . set_secondary_text ( tmp_msg ) ;
dialog . run ( ) ;
}
2015-05-17 07:01:48 -06:00
// Make a duplicate of the selected partition (used in UNDO)
Partition part_temp = * selected_partition_ptr ;
2012-01-30 11:33:33 -07:00
if ( part_temp . filesystem = = GParted : : FS_NTFS )
//Explicitly ask for half, so that the user will be aware of it
//Also, keep this kind of policy out of the NTFS code.
part_temp . uuid = UUID_RANDOM_NTFS_HALF ;
else
part_temp . uuid = UUID_RANDOM ;
2012-01-22 13:49:52 -07:00
2015-05-17 07:01:48 -06:00
Operation * operation = new OperationChangeUUID ( devices [ current_device ] ,
* selected_partition_ptr , part_temp ) ;
2012-01-22 13:49:52 -07:00
operation - > icon = render_icon ( Gtk : : Stock : : EXECUTE , Gtk : : ICON_SIZE_MENU ) ;
Add_Operation ( operation ) ;
// Verify if the two operations can be merged
for ( unsigned int t = 0 ; t < operations . size ( ) - 1 ; t + + )
{
if ( operations [ t ] - > type = = OPERATION_CHANGE_UUID )
{
if ( Merge_Operations ( t , operations . size ( ) - 1 ) )
break ;
}
}
2013-05-17 10:01:42 -06:00
show_operationslist ( ) ;
2012-01-22 13:49:52 -07:00
}
2006-02-17 14:18:07 -07:00
void Win_GParted : : activate_undo ( )
2004-09-19 14:24:53 -06:00
{
2006-11-26 07:27:16 -07:00
//when undoing a creation it's safe to decrease the newcount by one
2006-07-29 09:20:32 -06:00
if ( operations . back ( ) - > type = = OPERATION_CREATE )
2004-10-06 09:32:40 -06:00
new_count - - ;
2006-03-24 12:08:41 -07:00
2009-01-06 15:22:09 -07:00
remove_operation ( ) ;
2006-02-17 14:18:07 -07:00
Refresh_Visual ( ) ;
2009-01-06 15:22:09 -07:00
2006-02-17 14:18:07 -07:00
if ( ! operations . size ( ) )
close_operationslist ( ) ;
2011-01-19 15:32:56 -07:00
//FIXME: A slight flicker may be introduced by this extra display refresh.
//An extra display refresh seems to prevent the disk area visual disk from
// disappearing when there enough operations to require a scrollbar
// (about 4+ operations with default window size) and a user clicks on undo.
// See also Win_GParted::Add_operation().
drawingarea_visualdisk . queue_draw ( ) ;
2004-09-19 14:24:53 -06:00
}
2010-08-09 13:33:28 -06:00
2009-01-06 15:22:09 -07:00
void Win_GParted : : remove_operation ( int index , bool remove_all )
2006-03-24 12:08:41 -07:00
{
if ( remove_all )
{
for ( unsigned int t = 0 ; t < operations . size ( ) ; t + + )
delete operations [ t ] ;
operations . clear ( ) ;
}
else if ( index = = - 1 & & operations . size ( ) > 0 )
{
delete operations . back ( ) ;
operations . pop_back ( ) ;
}
else if ( index > - 1 & & index < static_cast < int > ( operations . size ( ) ) )
{
delete operations [ index ] ;
operations . erase ( operations . begin ( ) + index ) ;
}
}
2004-09-19 14:24:53 -06:00
2010-08-10 11:36:10 -06:00
int Win_GParted : : partition_in_operation_queue_count ( const Partition & partition )
{
int operation_count = 0 ;
for ( unsigned int t = 0 ; t < operations . size ( ) ; t + + )
{
if ( partition . get_path ( ) = = operations [ t ] - > partition_original . get_path ( ) )
operation_count + + ;
}
return operation_count ;
}
2010-08-10 12:52:59 -06:00
int Win_GParted : : active_partitions_on_device_count ( const Device & device )
{
int active_count = 0 ;
//Count the active partitions on the device
for ( unsigned int k = 0 ; k < device . partitions . size ( ) ; k + + )
{
//Count the active primary partitions
if ( device . partitions [ k ] . busy
& & device . partitions [ k ] . type ! = TYPE_EXTENDED
& & device . partitions [ k ] . type ! = TYPE_UNALLOCATED
)
active_count + + ;
//Count the active logical partitions
if ( device . partitions [ k ] . busy
& & device . partitions [ k ] . type = = TYPE_EXTENDED
)
{
for ( unsigned int j = 0 ; j < device . partitions [ k ] . logicals . size ( ) ; j + + )
{
if ( device . partitions [ k ] . logicals [ j ] . busy
& & device . partitions [ k ] . logicals [ j ] . type ! = TYPE_UNALLOCATED
)
active_count + + ;
}
}
}
return active_count ;
}
2006-02-17 14:18:07 -07:00
void Win_GParted : : activate_apply ( )
2004-09-19 14:24:53 -06:00
{
2006-01-19 12:15:15 -07:00
Gtk : : MessageDialog dialog ( * this ,
2006-02-17 14:18:07 -07:00
_ ( " Are you sure you want to apply the pending operations? " ) ,
2006-01-19 12:15:15 -07:00
false ,
Gtk : : MESSAGE_WARNING ,
Gtk : : BUTTONS_NONE ,
true ) ;
2009-01-19 13:38:22 -07:00
Glib : : ustring temp ;
temp = _ ( " Editing partitions has the potential to cause LOSS of DATA. " ) ;
temp + = " \n " ;
temp + = _ ( " You are advised to backup your data before proceeding. " ) ;
dialog . set_secondary_text ( temp ) ;
2008-11-04 15:16:06 -07:00
dialog . set_title ( _ ( " Apply operations to device " ) ) ;
2009-01-06 15:22:09 -07:00
2004-11-17 06:00:25 -07:00
dialog . add_button ( Gtk : : Stock : : CANCEL , Gtk : : RESPONSE_CANCEL ) ;
dialog . add_button ( Gtk : : Stock : : APPLY , Gtk : : RESPONSE_OK ) ;
2009-01-06 15:22:09 -07:00
2006-01-19 12:15:15 -07:00
dialog . show_all_children ( ) ;
if ( dialog . run ( ) = = Gtk : : RESPONSE_OK )
2004-09-19 14:24:53 -06:00
{
2006-01-19 12:15:15 -07:00
dialog . hide ( ) ; //hide confirmationdialog
2009-01-06 15:22:09 -07:00
2006-01-19 12:15:15 -07:00
Dialog_Progress dialog_progress ( operations ) ;
2006-01-26 08:54:44 -07:00
dialog_progress . set_transient_for ( * this ) ;
2006-01-19 12:15:15 -07:00
dialog_progress . signal_apply_operation . connect (
sigc : : mem_fun ( gparted_core , & GParted_Core : : apply_operation_to_disk ) ) ;
2006-12-01 06:01:46 -07:00
dialog_progress . signal_get_libparted_version . connect (
sigc : : mem_fun ( gparted_core , & GParted_Core : : get_libparted_version ) ) ;
2009-01-06 15:22:09 -07:00
2006-02-07 08:17:44 -07:00
int response ;
do
{
response = dialog_progress . run ( ) ;
}
while ( response = = Gtk : : RESPONSE_CANCEL | | response = = Gtk : : RESPONSE_OK ) ;
2009-01-06 15:22:09 -07:00
2006-01-19 12:15:15 -07:00
dialog_progress . hide ( ) ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//wipe operations...
2006-03-24 12:08:41 -07:00
remove_operation ( - 1 , true ) ;
2006-09-17 07:23:47 -06:00
hbox_operations . clear ( ) ;
2006-01-19 12:15:15 -07:00
close_operationslist ( ) ;
2009-01-06 15:22:09 -07:00
2004-10-11 04:23:24 -06:00
//reset new_count to 1
2004-10-16 09:42:08 -06:00
new_count = 1 ;
2009-01-06 15:22:09 -07:00
2004-09-19 14:24:53 -06:00
//reread devices and their layouts...
2006-01-19 12:15:15 -07:00
menu_gparted_refresh_devices ( ) ;
2004-09-19 14:24:53 -06:00
}
}
2012-07-05 16:33:04 -06:00
bool Win_GParted : : remove_non_empty_lvm2_pv_dialog ( const OperationType optype )
{
Glib : : ustring tmp_msg ;
switch ( optype )
{
case OPERATION_DELETE :
tmp_msg = String : : ucompose ( _ ( " You are deleting non-empty LVM2 Physical Volume %1 " ) ,
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > get_path ( ) ) ;
2012-07-05 16:33:04 -06:00
break ;
case OPERATION_FORMAT :
tmp_msg = String : : ucompose ( _ ( " You are formatting over non-empty LVM2 Physical Volume %1 " ) ,
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > get_path ( ) ) ;
2012-07-05 16:33:04 -06:00
break ;
case OPERATION_COPY :
tmp_msg = String : : ucompose ( _ ( " You are pasting over non-empty LVM2 Physical Volume %1 " ) ,
2015-05-17 07:01:48 -06:00
selected_partition_ptr - > get_path ( ) ) ;
2012-07-05 16:33:04 -06:00
break ;
default :
break ;
}
Gtk : : MessageDialog dialog ( * this , tmp_msg ,
false , Gtk : : MESSAGE_WARNING , Gtk : : BUTTONS_NONE , true ) ;
tmp_msg = _ ( " Deleting or overwriting the Physical Volume is irrecoverable and will destroy or damage the "
" Volume Group. " ) ;
tmp_msg + = " \n \n " ;
tmp_msg + = _ ( " To avoid destroying or damaging the Volume Group, you are advised to cancel and use external "
" LVM commands to free the Physical Volume before attempting this operation. " ) ;
tmp_msg + = " \n \n " ;
tmp_msg + = _ ( " Do you want to continue to forcibly delete the Physical Volume? " ) ;
2012-07-24 06:49:44 -06:00
LVM2_PV_Info lvm2_pv_info ;
2015-05-17 07:01:48 -06:00
Glib : : ustring vgname = lvm2_pv_info . get_vg_name ( selected_partition_ptr - > get_path ( ) ) ;
2012-07-24 06:49:44 -06:00
std : : vector < Glib : : ustring > members ;
if ( ! vgname . empty ( ) )
members = lvm2_pv_info . get_vg_members ( vgname ) ;
//Single copy of each string for translation purposes
const Glib : : ustring vgname_label = _ ( " Volume Group: " ) ;
const Glib : : ustring members_label = _ ( " Members: " ) ;
# ifndef HAVE_GET_MESSAGE_AREA
//Basic method of displaying VG members by appending it to the secondary text in the dialog.
tmp_msg + = " \n ____________________ \n \n " ;
tmp_msg + = " <b> " ;
tmp_msg + = vgname_label ;
tmp_msg + = " </b> " ;
tmp_msg + = vgname ;
tmp_msg + = " \n " ;
tmp_msg + = " <b> " ;
tmp_msg + = members_label ;
tmp_msg + = " </b> " ;
if ( ! members . empty ( ) )
{
tmp_msg + = " " ;
tmp_msg + = members [ 0 ] ;
for ( unsigned int i = 1 ; i < members . size ( ) ; i + + )
{
tmp_msg + = " " ;
tmp_msg + = members [ i ] ;
}
}
# endif /* ! HAVE_GET_MESSAGE_AREA */
dialog . set_secondary_text ( tmp_msg , true ) ;
# ifdef HAVE_GET_MESSAGE_AREA
//Nicely formatted method of displaying VG members by using a table below the secondary text
// in the dialog. Uses Gtk::MessageDialog::get_message_area() which was new in gtkmm-2.22
// released September 2010.
2012-07-05 16:33:04 -06:00
Gtk : : Box * msg_area = dialog . get_message_area ( ) ;
Gtk : : HSeparator * hsep ( manage ( new Gtk : : HSeparator ( ) ) ) ;
msg_area - > pack_start ( * hsep ) ;
Gtk : : Table * table ( manage ( new Gtk : : Table ( ) ) ) ;
table - > set_border_width ( 0 ) ;
table - > set_col_spacings ( 10 ) ;
msg_area - > pack_start ( * table ) ;
int top = 0 , bottom = 1 ;
//Volume Group
2012-07-24 06:49:44 -06:00
table - > attach ( * Utils : : mk_label ( " <b> " + Glib : : ustring ( vgname_label ) + " </b> " ) ,
2012-07-05 16:33:04 -06:00
0 , 1 , top , bottom , Gtk : : FILL ) ;
2013-10-16 15:44:03 -06:00
table - > attach ( * Utils : : mk_label ( vgname , true , false , true ) ,
2012-07-05 16:33:04 -06:00
1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
//Members
2014-04-27 03:10:05 -06:00
table - > attach ( * Utils : : mk_label ( " <b> " + Glib : : ustring ( members_label ) + " </b> " ,
true , false , false , 0.0 /* ALIGN_TOP */ ) ,
0 , 1 , top , bottom , Gtk : : FILL ) ;
2012-07-05 16:33:04 -06:00
2014-04-27 03:10:05 -06:00
Glib : : ustring members_str = " " ;
if ( ! members . empty ( ) )
2012-07-05 16:33:04 -06:00
{
2014-04-27 03:10:05 -06:00
for ( unsigned int i = 0 ; i < members . size ( ) ; i + + )
2012-07-05 16:33:04 -06:00
{
2014-04-27 03:10:05 -06:00
if ( i > 0 )
members_str + = " \n " ;
members_str + = members [ i ] ;
2012-07-05 16:33:04 -06:00
}
}
2014-04-27 03:10:05 -06:00
table - > attach ( * Utils : : mk_label ( members_str , true , false , true , 0.0 /* ALIGN_TOP */ ) ,
1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2012-07-24 06:49:44 -06:00
# endif /* HAVE_GET_MESSAGE_AREA */
2012-07-05 16:33:04 -06:00
dialog . add_button ( Gtk : : Stock : : CANCEL , Gtk : : RESPONSE_CANCEL ) ;
dialog . add_button ( Gtk : : Stock : : DELETE , Gtk : : RESPONSE_OK ) ;
dialog . show_all ( ) ;
if ( dialog . run ( ) = = Gtk : : RESPONSE_OK )
return true ;
return false ;
}
2004-09-19 14:24:53 -06:00
} // GParted