2004-09-19 14:24:53 -06:00
/* Copyright (C) 2004 Bart
*
* 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
* GNU Library General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
# include "../include/Win_GParted.h"
2006-01-24 05:31:58 -07:00
# include "../include/Dialog_Progress.h"
2006-01-26 13:58:55 -07:00
# include "../include/Dialog_Filesystems.h"
# include "../include/Dialog_Disklabel.h"
# 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"
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>
2005-11-25 15:41:49 -07:00
2006-01-07 14:23:09 -07:00
# include <cerrno>
# include <sys/swap.h>
2004-09-19 14:24:53 -06:00
namespace GParted
{
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
{
2005-01-09 12:33:48 -07:00
copied_partition . Reset ( ) ;
selected_partition . Reset ( ) ;
2004-09-19 14:24:53 -06:00
new_count = 1 ;
2004-11-17 06:00:25 -07:00
current_device = 0 ;
2005-12-29 16:35:37 -07:00
pulse = false ;
2006-02-02 06:50:37 -07:00
gparted_core . set_user_devices ( user_devices ) ;
2004-10-06 09:32:40 -06:00
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 ) ;
2005-11-25 15:41:49 -07:00
2005-12-24 16:55:54 -07:00
try
{
2005-11-25 15:41:49 -07:00
this - > set_icon_from_file ( GNOME_ICONDIR " /gparted.png " ) ;
2005-12-24 16:55:54 -07:00
}
catch ( Glib : : Exception & e )
{
std : : cout < < e . what ( ) < < std : : endl ;
}
2005-11-25 15:41:49 -07:00
2004-09-19 14:24:53 -06:00
//Pack the main box
2004-12-17 12:45:04 -07:00
this - > add ( vbox_main ) ;
2004-09-19 14:24:53 -06:00
//menubar....
2004-12-17 12:45:04 -07:00
init_menubar ( ) ;
2004-09-19 14:24:53 -06:00
vbox_main . pack_start ( menubar_main , Gtk : : PACK_SHRINK ) ;
//toolbar....
2004-12-17 12:45:04 -07:00
init_toolbar ( ) ;
2004-09-19 14:24:53 -06:00
vbox_main . pack_start ( hbox_toolbar , Gtk : : PACK_SHRINK ) ;
2006-02-10 16:47:02 -07:00
//frame_visualdisk... ( contains the visual represenation of the disks )
frame_visualdisk . signal_partition_selected . connect ( sigc : : mem_fun ( this , & Win_GParted : : on_partition_selected ) ) ;
frame_visualdisk . signal_partition_activated . connect ( sigc : : mem_fun ( this , & Win_GParted : : on_partition_activated ) ) ;
frame_visualdisk . signal_popup_menu . connect ( sigc : : mem_fun ( this , & Win_GParted : : on_partition_popup_menu ) ) ;
vbox_main . pack_start ( frame_visualdisk , Gtk : : PACK_SHRINK ) ;
2004-09-19 14:24:53 -06:00
//hpaned_main (NOTE: added to vpaned_main)
2004-12-17 12:45:04 -07:00
init_hpaned_main ( ) ;
2004-09-19 14:24:53 -06:00
vpaned_main . pack1 ( hpaned_main , true , true ) ;
//vpaned_main....
2004-12-17 12:45:04 -07:00
vbox_main . pack_start ( vpaned_main ) ;
2004-09-19 14:24:53 -06:00
//device info...
2004-12-17 12:45:04 -07:00
init_device_info ( ) ;
2004-09-19 14:24:53 -06:00
//operationslist...
2004-10-11 08:19:56 -06:00
init_operationslist ( ) ;
2004-09-19 14:24:53 -06:00
vpaned_main . pack2 ( hbox_operations , true , true ) ;
//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 ) ;
2004-09-19 14:24:53 -06:00
2004-12-17 12:45:04 -07:00
this - > show_all_children ( ) ;
2004-09-27 14:12:47 -06:00
2004-10-11 08:19:56 -06:00
//make sure harddisk information and operationlist are closed..
hpaned_main . get_child1 ( ) - > hide ( ) ;
close_operationslist ( ) ;
2004-10-16 09:42:08 -06:00
conn = dispatcher . connect ( sigc : : mem_fun ( * this , & Win_GParted : : menu_gparted_refresh_devices ) ) ;
2006-01-07 14:23:09 -07:00
dispatcher ( ) ;
2004-09-19 14:24:53 -06:00
}
2005-01-30 07:31:29 -07:00
void Win_GParted : : init_menubar ( )
2004-09-19 14:24:53 -06:00
{
//fill menubar_main and connect callbacks
//gparted
2004-12-15 09:38:37 -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 ) ) ;
2005-01-30 07:31:29 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : ImageMenuElem ( _ ( " _Refresh devices " ) , Gtk : : AccelKey ( " <control>r " ) , * image , sigc : : mem_fun ( * this , & Win_GParted : : menu_gparted_refresh_devices ) ) ) ;
2006-02-02 03:59:44 -07:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : HARDDISK , Gtk : : ICON_SIZE_MENU ) ) ;
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : ImageMenuElem ( _ ( " Devices " ) , * image ) ) ;
2004-12-15 09:38:37 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " Filesystems " ) , sigc : : mem_fun ( * this , & Win_GParted : : menu_gparted_filesystems ) ) ) ;
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : QUIT , sigc : : mem_fun ( * this , & Win_GParted : : menu_gparted_quit ) ) ) ;
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _GParted " ) , * menu ) ) ;
2004-09-19 14:24:53 -06:00
2005-11-27 12:48:00 -07:00
//edit
menu = manage ( new Gtk : : Menu ( ) ) ;
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : UNDO , Gtk : : AccelKey ( " <control>z " ) , sigc : : mem_fun ( * this , & Win_GParted : : activate_undo ) ) ) ;
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : APPLY , sigc : : mem_fun ( * this , & Win_GParted : : activate_apply ) ) ) ;
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _Edit " ) , * menu ) ) ;
2004-09-27 14:12:47 -06:00
//view
2005-01-30 07:31:29 -07:00
menu = manage ( new Gtk : : Menu ( ) ) ;
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : CheckMenuElem ( _ ( " Harddisk Information " ) , sigc : : mem_fun ( * this , & Win_GParted : : menu_view_harddisk_info ) ) ) ;
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : CheckMenuElem ( _ ( " Operations " ) , sigc : : mem_fun ( * this , & Win_GParted : : menu_view_operations ) ) ) ;
2005-01-09 12:33:48 -07:00
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _View " ) , * menu ) ) ;
2004-09-27 14:12:47 -06:00
2005-01-30 07:31:29 -07:00
//device
menu = manage ( new Gtk : : Menu ( ) ) ;
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " Set Disklabel " ) , sigc : : mem_fun ( * this , & Win_GParted : : activate_disklabel ) ) ) ;
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _Device " ) , * menu ) ) ;
//partition
init_partition_menu ( ) ;
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _Partition " ) , menu_partition ) ) ;
2004-09-19 14:24:53 -06:00
//help
menu = manage ( new Gtk : : Menu ( ) ) ;
2005-01-30 07:31:29 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : HELP , sigc : : mem_fun ( * this , & Win_GParted : : menu_help_contents ) ) ) ;
2005-11-25 15:41:49 -07:00
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : ABOUT , sigc : : mem_fun ( * this , & Win_GParted : : menu_help_about ) ) ) ;
2005-01-30 07:31:29 -07:00
menubar_main . items ( ) . push_back ( Gtk : : Menu_Helpers : : MenuElem ( _ ( " _Help " ) , * menu ) ) ;
2004-09-19 14:24:53 -06:00
}
2005-01-30 07:31:29 -07:00
void Win_GParted : : init_toolbar ( )
2004-09-19 14:24:53 -06:00
{
//initialize and pack toolbar_main
hbox_toolbar . pack_start ( toolbar_main ) ;
//NEW and DELETE
toolbutton = Gtk : : manage ( new Gtk : : ToolButton ( Gtk : : Stock : : NEW ) ) ;
2006-02-02 03:59:44 -07:00
toolbutton - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : activate_new ) ) ;
toolbar_main . append ( * toolbutton ) ;
2004-09-19 14:24:53 -06:00
toolbutton - > set_tooltip ( tooltips , _ ( " Create a new partition in the selected unallocated space " ) ) ;
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 ) ;
2004-09-19 14:24:53 -06:00
toolbutton - > set_tooltip ( tooltips , _ ( " Delete the selected partition " ) ) ;
toolbar_main . append ( * ( Gtk : : manage ( new Gtk : : SeparatorToolItem ) ) ) ;
//RESIZE/MOVE
image = manage ( new Gtk : : Image ( Gtk : : Stock : : GOTO_LAST , Gtk : : ICON_SIZE_BUTTON ) ) ;
toolbutton = Gtk : : manage ( new Gtk : : ToolButton ( * image , _ ( " Resize/Move " ) ) ) ;
2006-02-02 03:59:44 -07:00
toolbutton - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : activate_resize ) ) ;
toolbar_main . append ( * toolbutton ) ;
2004-09-19 14:24:53 -06:00
toolbutton - > set_tooltip ( tooltips , _ ( " Resize/Move the selected partition " ) ) ;
toolbar_main . append ( * ( Gtk : : manage ( new Gtk : : SeparatorToolItem ) ) ) ;
//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 ) ;
2004-09-19 14:24:53 -06:00
toolbutton - > set_tooltip ( tooltips , _ ( " Copy the selected partition to the clipboard " ) ) ;
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 ) ;
2004-09-19 14:24:53 -06:00
toolbutton - > set_tooltip ( tooltips , _ ( " Paste the partition from the clipboard " ) ) ;
toolbar_main . append ( * ( Gtk : : manage ( new Gtk : : SeparatorToolItem ) ) ) ;
//UNDO and APPLY
toolbutton = Gtk : : manage ( new Gtk : : ToolButton ( Gtk : : Stock : : UNDO ) ) ;
2006-02-02 03:59:44 -07:00
toolbutton - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : activate_undo ) ) ;
toolbar_main . append ( * toolbutton ) ;
toolbutton - > set_sensitive ( false ) ;
2004-09-19 14:24:53 -06:00
toolbutton - > set_tooltip ( tooltips , _ ( " Undo last operation " ) ) ;
2006-02-02 03:59:44 -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 ) ;
toolbutton - > set_sensitive ( false ) ;
2004-09-19 14:24:53 -06: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 ) ;
2005-12-29 16:35:37 -07:00
combo_devices . signal_changed ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : combo_devices_changed ) ) ;
hbox_toolbar . pack_start ( combo_devices , Gtk : : PACK_SHRINK ) ;
2004-09-19 14:24:53 -06:00
}
2005-01-30 07:31:29 -07:00
void Win_GParted : : init_partition_menu ( )
2004-09-19 14:24:53 -06:00
{
2005-01-30 07:31:29 -07:00
//fill menu_partition
2006-01-02 08:18:29 -07:00
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : NEW ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_new ) ) ) ;
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : DELETE ,
Gtk : : AccelKey ( GDK_Delete , Gdk : : BUTTON1_MASK ) ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_delete ) ) ) ;
menu_partition . items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
2004-09-19 14:24:53 -06:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : GOTO_LAST , Gtk : : ICON_SIZE_MENU ) ) ;
2006-01-02 08:18:29 -07:00
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : ImageMenuElem ( _ ( " Resize/Move " ) ,
* image ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_resize ) ) ) ;
menu_partition . items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : COPY ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_copy ) ) ) ;
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : PASTE ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_paste ) ) ) ;
menu_partition . items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
2004-09-19 14:24:53 -06:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : CONVERT , Gtk : : ICON_SIZE_MENU ) ) ;
2004-09-24 19:10:21 -06:00
/*TO TRANSLATORS: menuitem which holds a submenu with filesystems.. */
2006-01-02 08:18:29 -07:00
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : ImageMenuElem ( _ ( " _Format to " ) ,
* image ,
* create_format_menu ( ) ) ) ;
menu_partition . items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
menu_partition . items ( ) . push_back (
2006-02-15 09:05:26 -07:00
Gtk : : Menu_Helpers : : MenuElem ( _ ( " unmount " ) ,
2006-01-02 08:18:29 -07:00
sigc : : mem_fun ( * this , & Win_GParted : : activate_unmount ) ) ) ;
2006-01-07 14:23:09 -07:00
menu_partition . items ( ) . push_back (
2006-02-15 09:05:26 -07:00
Gtk : : Menu_Helpers : : MenuElem ( _ ( " swapoff " ) ,
2006-02-08 13:36:18 -07:00
sigc : : mem_fun ( * this , & Win_GParted : : activate_toggle_swap ) ) ) ;
2006-01-07 14:23:09 -07:00
2006-01-02 08:18:29 -07:00
menu_partition . items ( ) . push_back ( Gtk : : Menu_Helpers : : SeparatorElem ( ) ) ;
menu_partition . items ( ) . push_back (
Gtk : : Menu_Helpers : : StockMenuElem ( Gtk : : Stock : : DIALOG_INFO ,
sigc : : mem_fun ( * this , & Win_GParted : : activate_info ) ) ) ;
2004-09-19 14:24:53 -06:00
2005-01-30 07:31:29 -07:00
menu_partition . accelerate ( * this ) ;
2004-09-19 14:24:53 -06:00
}
2006-01-02 08:18:29 -07:00
Gtk : : Menu * Win_GParted : : create_format_menu ( )
2004-09-19 14:24:53 -06:00
{
2006-01-02 08:18:29 -07:00
menu = manage ( new Gtk : : Menu ( ) ) ;
for ( unsigned int t = 0 ; t < gparted_core . get_filesystems ( ) . size ( ) - 1 ; t + + )
2004-09-19 14:24:53 -06:00
{
2006-01-02 08:18:29 -07:00
hbox = manage ( new Gtk : : HBox ( ) ) ;
2004-09-19 14:24:53 -06:00
2004-10-06 09:32:40 -06:00
//the colored square
2006-01-02 08:18:29 -07:00
hbox - > pack_start ( * manage ( new Gtk : : Image (
Utils : : get_color_as_pixbuf (
gparted_core . get_filesystems ( ) [ t ] . filesystem , 16 , 16 ) ) ) ,
Gtk : : PACK_SHRINK ) ;
2005-12-15 08:10:34 -07:00
2004-10-06 09:32:40 -06:00
//the label...
2006-01-02 08:18:29 -07:00
hbox - > pack_start ( * Utils : : mk_label (
" " +
Utils : : Get_Filesystem_String ( gparted_core . get_filesystems ( ) [ t ] . filesystem ) ) ,
Gtk : : PACK_SHRINK ) ;
2004-09-19 14:24:53 -06:00
2006-01-02 08:18:29 -07:00
menu - > items ( ) . push_back ( * manage ( new Gtk : : MenuItem ( * hbox ) ) ) ;
if ( gparted_core . get_filesystems ( ) [ t ] . create )
menu - > items ( ) . back ( ) . signal_activate ( ) . connect (
sigc : : bind < GParted : : FILESYSTEM > ( sigc : : mem_fun ( * this , & Win_GParted : : activate_format ) ,
gparted_core . get_filesystems ( ) [ t ] . filesystem ) ) ;
else
menu - > items ( ) . back ( ) . set_sensitive ( false ) ;
2004-09-19 14:24:53 -06:00
}
2006-01-02 08:18:29 -07:00
return menu ;
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 ) ;
2004-09-29 06:33:40 -06:00
int top = 0 , bottom = 1 ;
2004-09-25 15:59:53 -06:00
//title
2005-12-13 14:30:13 -07:00
vbox_info . pack_start ( * Utils : : mk_label ( " <b> " + ( Glib : : ustring ) _ ( " Harddisk Information " ) + " :</b> " ) , Gtk : : PACK_SHRINK ) ;
2004-09-19 14:24:53 -06: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 ) ;
2004-09-19 14:24:53 -06:00
2004-09-29 06:33:40 -06:00
//model
2005-12-13 14:30:13 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + ( Glib : : ustring ) _ ( " Model: " ) + " </b> " ) , 0 , 1 , top , bottom , Gtk : : FILL ) ;
device_info . push_back ( Utils : : mk_label ( " " ) ) ;
2004-09-29 06:33:40 -06:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2004-09-19 14:24:53 -06:00
2004-09-29 06:33:40 -06:00
//size
2005-12-13 14:30:13 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + ( Glib : : ustring ) _ ( " Size: " ) + " </b> " ) , 0 , 1 , top , bottom , Gtk : : FILL ) ;
device_info . push_back ( Utils : : mk_label ( " " ) ) ;
2004-09-29 06:33:40 -06:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
//path
2005-12-13 14:30:13 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + ( Glib : : ustring ) _ ( " Path: " ) + " </b> " ) , 0 , 1 , top , bottom , Gtk : : FILL ) ;
device_info . push_back ( Utils : : mk_label ( " " ) ) ;
2004-09-29 06:33:40 -06:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2004-12-17 12:45:04 -07:00
//real path
2005-12-13 14:30:13 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + ( Glib : : ustring ) _ ( " Real Path: " ) + " </b> " ) , 0 , 1 , top , bottom , Gtk : : FILL ) ;
device_info . push_back ( Utils : : mk_label ( " " ) ) ;
2004-12-17 12:45:04 -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
2004-09-29 06:33:40 -06:00
//DETAILED DEVICE INFO
2004-12-27 05:08:01 -07:00
top = 0 ; bottom = 1 ;
table = manage ( new Gtk : : Table ( ) ) ;
table - > set_col_spacings ( 10 ) ;
2004-09-19 14:24:53 -06: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 ) ;
2004-09-29 06:33:40 -06:00
//disktype
2005-12-13 14:30:13 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + ( Glib : : ustring ) _ ( " DiskLabelType: " ) + " </b> " ) , 0 , 1 , top , bottom , Gtk : : FILL ) ;
device_info . push_back ( Utils : : mk_label ( " " ) ) ;
2004-12-27 05:08:01 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2004-09-29 06:33:40 -06:00
//heads
2005-12-13 14:30:13 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + ( Glib : : ustring ) _ ( " Heads: " ) + " </b> " ) , 0 , 1 , top , bottom , Gtk : : FILL ) ;
device_info . push_back ( Utils : : mk_label ( " " ) ) ;
2004-12-27 05:08:01 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2004-09-29 06:33:40 -06:00
//sectors/track
2005-12-13 14:30:13 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + ( Glib : : ustring ) _ ( " Sectors/Track: " ) + " </b> " ) , 0 , 1 , top , bottom , Gtk : : FILL ) ;
device_info . push_back ( Utils : : mk_label ( " " ) ) ;
2004-12-27 05:08:01 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2004-09-29 06:33:40 -06:00
//cylinders
2005-12-13 14:30:13 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + ( Glib : : ustring ) _ ( " Cylinders: " ) + " </b> " ) , 0 , 1 , top , bottom , Gtk : : FILL ) ;
device_info . push_back ( Utils : : mk_label ( " " ) ) ;
2004-12-27 05:08:01 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2004-09-29 06:33:40 -06:00
//total sectors
2005-12-13 14:30:13 -07:00
table - > attach ( * Utils : : mk_label ( " <b> " + ( Glib : : ustring ) _ ( " Total Sectors: " ) + " </b> " ) , 0 , 1 , top , bottom , Gtk : : FILL ) ;
device_info . push_back ( Utils : : mk_label ( " " ) ) ;
2004-12-27 05:08:01 -07:00
table - > attach ( * device_info . back ( ) , 1 , 2 , top + + , bottom + + , Gtk : : FILL ) ;
2004-09-29 06:33:40 -06:00
2004-09-25 15:59:53 -06:00
vbox_info . pack_start ( * table , Gtk : : PACK_SHRINK ) ;
2004-09-19 14:24:53 -06:00
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : init_operationslist ( )
2004-09-19 14:24:53 -06:00
{
//create listview for pending operations
liststore_operations = Gtk : : ListStore : : create ( treeview_operations_columns ) ;
2004-12-27 05:08:01 -07:00
treeview_operations . set_model ( liststore_operations ) ;
treeview_operations . set_headers_visible ( false ) ;
2006-01-19 12:15:15 -07:00
treeview_operations . append_column ( " " , treeview_operations_columns . operation_icon ) ;
2004-12-27 05:08:01 -07:00
treeview_operations . append_column ( " " , treeview_operations_columns . operation_description ) ;
treeview_operations . get_selection ( ) - > set_mode ( Gtk : : SELECTION_NONE ) ;
2004-09-19 14:24:53 -06:00
//init scrollwindow_operations
2004-12-27 05:08:01 -07:00
scrollwindow = manage ( new Gtk : : ScrolledWindow ( ) ) ;
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
scrollwindow - > add ( treeview_operations ) ;
//set up the close and clear buttons and pack them in a vbox
2004-12-27 05:08:01 -07:00
vbox = manage ( new Gtk : : VBox ( ) ) ;
2004-09-19 14:24:53 -06:00
//CLOSE
2004-12-27 05:08:01 -07:00
button = manage ( new Gtk : : Button ( ) ) ;
2004-09-19 14:24:53 -06:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : CLOSE , Gtk : : ICON_SIZE_MENU ) ) ;
button - > add ( * image ) ;
button - > set_relief ( Gtk : : RELIEF_NONE ) ;
tooltips . set_tip ( * button , _ ( " Hide operationslist " ) ) ;
2004-12-27 05:08:01 -07:00
button - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : close_operationslist ) ) ;
2004-09-19 14:24:53 -06:00
vbox - > pack_start ( * button , Gtk : : PACK_SHRINK ) ;
//CLEAR
2004-12-27 05:08:01 -07:00
button = manage ( new Gtk : : Button ( ) ) ;
2004-09-19 14:24:53 -06:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : CLEAR , Gtk : : ICON_SIZE_MENU ) ) ;
button - > add ( * image ) ;
button - > set_relief ( Gtk : : RELIEF_NONE ) ;
tooltips . set_tip ( * button , _ ( " Clear operationslist " ) ) ;
2004-12-27 05:08:01 -07:00
button - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & Win_GParted : : clear_operationslist ) ) ;
2004-09-19 14:24:53 -06:00
vbox - > pack_start ( * button , Gtk : : PACK_SHRINK ) ;
//add vbox and scrollwindow_operations to hbox_operations
hbox_operations . pack_start ( * vbox , Gtk : : PACK_SHRINK ) ;
2004-12-27 05:08:01 -07:00
hbox_operations . pack_start ( * scrollwindow , Gtk : : PACK_EXPAND_WIDGET ) ;
2004-09-19 14:24:53 -06:00
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : init_hpaned_main ( )
2004-09-19 14:24:53 -06:00
{
//left scrollwindow (holds device info)
2004-12-27 05:08:01 -07:00
scrollwindow = manage ( new Gtk : : ScrolledWindow ( ) ) ;
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
2004-12-27 05:08:01 -07: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)
2004-12-27 05:08:01 -07:00
scrollwindow = manage ( new Gtk : : ScrolledWindow ( ) ) ;
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
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 ) ;
2005-02-01 10:04:03 -07: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
{
2005-12-29 16:35:37 -07:00
liststore_devices - > clear ( ) ;
2005-02-01 10:04:03 -07:00
2006-02-02 03:59:44 -07:00
menu = manage ( new Gtk : : Menu ( ) ) ;
Gtk : : RadioButtonGroup radio_group ;
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 ) ;
treerow [ treeview_devices_columns . device ] = devices [ i ] . path ;
2006-01-04 11:54:46 -07:00
treerow [ treeview_devices_columns . size ] = " ( " + Utils : : format_size ( devices [ i ] . length ) + " ) " ;
2006-02-02 03:59:44 -07:00
//devices submenu....
menu - > items ( ) . push_back ( Gtk : : Menu_Helpers : : RadioMenuElem (
radio_group ,
devices [ i ] . path + " \t ( " + Utils : : format_size ( devices [ i ] . length ) + " ) " ,
sigc : : bind < unsigned int > ( sigc : : mem_fun ( * this , & Win_GParted : : radio_devices_changed ) , i ) ) ) ;
2004-09-19 14:24:53 -06:00
}
2006-02-02 03:59:44 -07:00
menubar_main . items ( ) [ 0 ] . get_submenu ( ) - > items ( ) [ 1 ] . remove_submenu ( ) ;
if ( menu - > items ( ) . size ( ) )
menubar_main . items ( ) [ 0 ] . get_submenu ( ) - > items ( ) [ 1 ] . set_submenu ( * menu ) ;
2005-12-29 16:35:37 -07:00
combo_devices . set_active ( current_device ) ;
2004-10-11 04:23:24 -06:00
}
2006-01-08 08:20:14 -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 ) ;
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-02-10 16:47:02 -07:00
frame_visualdisk . set_sensitive ( false ) ;
2004-10-11 04:23:24 -06:00
//the actual 'pulsing'
while ( pulse )
{
2006-01-07 14:23:09 -07:00
pulsebar . pulse ( ) ;
2005-12-29 07:21:45 -07:00
while ( Gtk : : Main : : events_pending ( ) )
Gtk : : Main : : iteration ( ) ;
2004-12-17 12:45:04 -07:00
usleep ( 10000 ) ;
2004-10-11 04:23:24 -06:00
}
2004-09-27 14:12:47 -06:00
2005-12-29 07:21:45 -07:00
thread - > join ( ) ;
conn . disconnect ( ) ;
2004-10-11 04:23:24 -06:00
2006-01-07 14:23:09 -07:00
pulsebar . hide ( ) ;
2005-12-29 07:21:45 -07:00
statusbar . pop ( ) ;
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-02-10 16:47:02 -07:00
frame_visualdisk . set_sensitive ( true ) ;
2004-09-19 14:24:53 -06:00
}
2005-02-01 10:04:03 -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 ( " " ) ;
else
{
short t = 0 ;
//global info...
device_info [ t + + ] - > set_text ( devices [ current_device ] . model ) ;
2006-01-04 11:54:46 -07:00
device_info [ t + + ] - > set_text ( Utils : : format_size ( devices [ current_device ] . length ) ) ;
2005-02-01 10:04:03 -07:00
device_info [ t + + ] - > set_text ( devices [ current_device ] . path ) ;
device_info [ t + + ] - > set_text ( devices [ current_device ] . realpath ) ;
//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 ) ) ;
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
{
2004-12-27 05:08:01 -07:00
return ! Quit_Check_Operations ( ) ;
2004-09-19 14:24:53 -06:00
}
void Win_GParted : : Add_Operation ( OperationType operationtype , const Partition & new_partition )
{
2004-12-27 05:08:01 -07:00
Operation operation ( devices [ current_device ] , selected_partition , new_partition , operationtype ) ;
2004-11-17 06:00:25 -07:00
2006-01-19 12:15:15 -07:00
switch ( operationtype )
{
case GParted : : DELETE :
operation . operation_icon =
render_icon ( Gtk : : Stock : : DELETE , Gtk : : ICON_SIZE_MENU ) ;
break ;
case GParted : : CREATE :
operation . operation_icon =
render_icon ( Gtk : : Stock : : NEW , Gtk : : ICON_SIZE_MENU ) ;
break ;
case GParted : : RESIZE_MOVE :
operation . operation_icon =
render_icon ( Gtk : : Stock : : GOTO_LAST , Gtk : : ICON_SIZE_MENU ) ;
break ;
case GParted : : FORMAT :
operation . operation_icon =
render_icon ( Gtk : : Stock : : CONVERT , Gtk : : ICON_SIZE_MENU ) ;
break ;
case GParted : : COPY :
operation . operation_icon =
render_icon ( Gtk : : Stock : : COPY , Gtk : : ICON_SIZE_MENU ) ;
break ;
}
2004-09-19 14:24:53 -06:00
operations . push_back ( operation ) ;
allow_undo ( true ) ;
allow_apply ( true ) ;
2006-01-07 08:04:42 -07:00
Refresh_Visual ( ) ;
2004-09-19 14:24:53 -06:00
2006-01-07 08:04:42 -07:00
if ( operations . size ( ) = = 1 ) //first operation, open operationslist
open_operationslist ( ) ;
2004-10-11 08:19:56 -06:00
2004-09-19 14:24:53 -06:00
//make scrollwindow focus on the last operation in the list
2006-01-07 08:04:42 -07:00
Gtk : : TreeIter iter = liststore_operations - > children ( ) . end ( ) ;
2004-09-19 14:24:53 -06:00
iter - - ;
2006-01-07 08:04:42 -07:00
treeview_operations . set_cursor ( static_cast < Gtk : : TreePath > ( static_cast < Gtk : : TreeRow > ( * iter ) ) ) ;
2004-09-19 14:24:53 -06:00
}
void Win_GParted : : Refresh_Visual ( )
{
2006-01-05 13:01:34 -07:00
std : : vector < Partition > partitions = devices [ current_device ] . partitions ;
2005-12-22 15:20:55 -07:00
liststore_operations - > clear ( ) ;
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 + + )
2004-11-06 04:55:03 -07:00
{
2004-12-27 05:08:01 -07:00
if ( operations [ t ] . device . path = = devices [ current_device ] . path )
2004-11-07 06:13:11 -07:00
operations [ t ] . Apply_Operation_To_Visual ( partitions ) ;
2004-11-06 04:55:03 -07:00
2005-12-22 15:20:55 -07:00
treerow = * ( liststore_operations - > append ( ) ) ;
2004-11-06 04:55:03 -07:00
treerow [ treeview_operations_columns . operation_description ] = operations [ t ] . str_operation ;
2006-01-19 12:15:15 -07:00
treerow [ treeview_operations_columns . operation_icon ] = operations [ t ] . operation_icon ;
2004-09-19 14:24:53 -06:00
}
//set new statusbartext
2005-12-22 15:20:55 -07:00
statusbar . pop ( ) ;
if ( operations . size ( ) ! = 1 )
statusbar . push ( String : : ucompose ( _ ( " %1 operations pending " ) , operations . size ( ) ) ) ;
2004-09-24 19:10:21 -06:00
else
statusbar . push ( _ ( " 1 operation pending " ) ) ;
2005-12-22 15:20:55 -07:00
if ( ! operations . size ( ) )
2004-09-19 14:24:53 -06:00
{
allow_undo ( false ) ;
allow_apply ( false ) ;
}
2006-02-09 10:02:40 -07:00
//count primary's and check for extended
any_extended = false ;
2004-11-06 04:55:03 -07:00
primary_count = 0 ;
2005-12-22 15:20:55 -07:00
for ( unsigned int t = 0 ; t < partitions . size ( ) ; t + + )
2004-09-19 14:24:53 -06:00
{
if ( partitions [ t ] . partition = = copied_partition . partition )
copied_partition = partitions [ t ] ;
2004-11-06 04:55:03 -07:00
switch ( partitions [ t ] . type )
2004-09-19 14:24:53 -06:00
{
2005-12-07 04:21:27 -07:00
case GParted : : TYPE_PRIMARY :
primary_count + + ;
break ;
case GParted : : TYPE_EXTENDED :
any_extended = true ;
primary_count + + ;
break ;
default :
break ;
2004-09-19 14:24:53 -06:00
}
}
2006-02-10 16:47:02 -07:00
//frame visualdisk
frame_visualdisk . load_partitions ( partitions , devices [ current_device ] . length ) ;
2004-09-19 14:24:53 -06:00
//treeview details
2005-12-23 17:06:05 -07:00
treeview_detail . load_partitions ( partitions ) ;
2005-01-09 12:33:48 -07:00
//no partition can be selected after a refresh..
2005-12-22 15:20:55 -07:00
selected_partition . Reset ( ) ;
2006-02-08 13:36:18 -07:00
set_valid_operations ( ) ;
2004-09-19 14:24:53 -06:00
}
2004-12-27 05:08:01 -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 ) ;
2005-12-22 15:20:55 -07:00
if ( operations . size ( ) ! = 1 )
2006-02-08 13:36:18 -07:00
str_temp = String : : ucompose ( _ ( " %1 operations are currently pending. " ) , operations . size ( ) ) ;
2004-09-24 19:10:21 -06:00
else
2006-02-08 13:36:18 -07:00
str_temp = _ ( " 1 operation is currently pending. " ) ;
dialog . set_secondary_text ( str_temp ) ;
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 ) ;
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-08 13:36:18 -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 ) ;
2006-01-02 08:18:29 -07:00
allow_paste ( false ) ; allow_format ( false ) ; allow_unmount ( false ) ; allow_info ( false ) ;
2006-02-08 13:36:18 -07:00
allow_toggle_swap ( false ) ;
2006-02-15 09:05:26 -07:00
dynamic_cast < Gtk : : Label * > ( menu_partition . items ( ) [ 11 ] . get_child ( ) ) - > set_label ( _ ( " swapoff " ) ) ;
2005-01-09 12:33:48 -07:00
//no partition selected...
2006-01-07 14:23:09 -07:00
if ( selected_partition . partition . empty ( ) )
2005-01-09 12:33:48 -07:00
return ;
//if there's something, there's some info ;)
2006-02-08 13:36:18 -07:00
allow_info ( true ) ;
//deal with swap...
if ( selected_partition . filesystem = = GParted : : FS_LINUX_SWAP )
{
allow_toggle_swap ( true ) ;
if ( selected_partition . busy )
return ;
else
dynamic_cast < Gtk : : Label * > ( menu_partition . items ( ) [ 11 ] . get_child ( ) )
2006-02-15 09:05:26 -07:00
- > set_label ( _ ( " swapon " ) ) ;
2006-02-08 13:36:18 -07:00
}
2005-01-09 12:33:48 -07:00
2004-11-06 12:48:24 -07:00
//only unmount is allowed
2006-02-08 13:36:18 -07:00
if ( selected_partition . busy & & selected_partition . type ! = GParted : : TYPE_EXTENDED )
2004-11-06 12:48:24 -07:00
{
2006-02-08 13:36:18 -07:00
allow_unmount ( true ) ;
2004-11-06 12:48:24 -07:00
2006-02-08 13:36:18 -07:00
return ;
2004-11-06 12:48:24 -07:00
}
2004-09-19 14:24:53 -06:00
//UNALLOCATED
2005-12-07 04:21:27 -07:00
if ( selected_partition . type = = GParted : : TYPE_UNALLOCATED )
2004-09-19 14:24:53 -06:00
{
allow_new ( true ) ;
//find out if there is a copied partition and if it fits inside this unallocated space
2006-01-07 14:23:09 -07:00
if ( ! copied_partition . partition . empty ( ) & & ! devices [ current_device ] . readonly )
2004-11-25 12:21:42 -07:00
{
2006-01-07 14:23:09 -07:00
if ( ( copied_partition . Get_Length_MB ( ) + devices [ current_device ] . cylsize ) < selected_partition . Get_Length_MB ( ) | |
( copied_partition . filesystem = = GParted : : FS_XFS & & ( copied_partition . Get_Used_MB ( ) + devices [ current_device ] . cylsize ) < selected_partition . Get_Length_MB ( ) )
2004-12-20 12:09:48 -07:00
)
2004-11-25 12:21:42 -07:00
allow_paste ( true ) ;
}
2004-09-19 14:24:53 -06:00
return ;
}
2004-12-14 15:49:44 -07:00
//EXTENDED
2005-12-07 04:21:27 -07:00
if ( selected_partition . type = = GParted : : TYPE_EXTENDED )
2004-12-14 15:49:44 -07:00
{
2006-02-09 10:02:40 -07:00
//deletion is only allowed when there are no logical partitions inside.
if ( selected_partition . logicals . size ( ) = = 1 & &
selected_partition . logicals . back ( ) . type = = GParted : : TYPE_UNALLOCATED )
2004-12-14 15:49:44 -07:00
allow_delete ( true ) ;
if ( ! devices [ current_device ] . readonly )
allow_resize ( true ) ;
return ;
}
2004-09-19 14:24:53 -06:00
//PRIMARY and LOGICAL
2005-12-07 04:21:27 -07:00
if ( selected_partition . type = = GParted : : TYPE_PRIMARY | | selected_partition . type = = GParted : : TYPE_LOGICAL )
2004-09-19 14:24:53 -06:00
{
2004-12-25 14:40:18 -07:00
fs = gparted_core . get_fs ( selected_partition . filesystem ) ;
2004-12-15 03:33:12 -07:00
2004-09-19 14:24:53 -06:00
allow_delete ( true ) ;
2006-01-02 08:18:29 -07:00
allow_format ( true ) ;
2004-09-19 14:24:53 -06:00
2004-12-17 09:26:49 -07:00
//find out if resizing/moving is possible
2005-11-28 10:04:13 -07:00
if ( ( fs . grow | | fs . shrink ) & & ! devices [ current_device ] . readonly )
2004-09-19 14:24:53 -06:00
allow_resize ( true ) ;
2004-12-17 09:26:49 -07:00
//only allow copying of real partitions
2005-11-28 10:04:13 -07:00
if ( selected_partition . status = = GParted : : STAT_REAL & & fs . copy )
2004-12-17 09:26:49 -07:00
allow_copy ( true ) ;
2004-09-19 14:24:53 -06:00
return ;
}
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : open_operationslist ( )
2004-10-11 08:19:56 -06:00
{
hbox_operations . show ( ) ;
int x , y ; this - > get_size ( x , y ) ;
y - = 300 ;
2004-11-23 12:03:39 -07:00
for ( int t = vpaned_main . get_position ( ) ; t > y ; t - = 5 )
2004-10-11 08:19:56 -06:00
{
2004-11-23 12:03:39 -07:00
vpaned_main . set_position ( t ) ;
while ( Gtk : : Main : : events_pending ( ) )
Gtk : : Main : : iteration ( ) ;
2004-10-11 08:19:56 -06:00
}
2005-11-27 12:48:00 -07:00
( ( Gtk : : CheckMenuItem * ) & menubar_main . items ( ) [ 2 ] . get_submenu ( ) - > items ( ) [ 1 ] ) - > set_active ( true ) ;
2004-10-11 08:19:56 -06:00
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : close_operationslist ( )
2004-09-19 14:24:53 -06:00
{
2006-02-15 09:05:26 -07:00
//FIXME: when started like 'gparted bla' it wil crash in this function
//most likely this has something to do with the removal of the legend which rendered
//the '210' incorrect. This static numbering sucks anyway, so i should find a way to open and
//close the operationslist without these static numbers. See also open_operationslist()
2004-10-01 15:09:19 -06:00
int x , y ; this - > get_size ( x , y ) ;
2004-09-19 14:24:53 -06:00
y - = 210 ; //height of whole app - menubar - visualdisk - statusbar ....
2006-02-15 09:05:26 -07:00
for ( int t = vpaned_main . get_position ( ) ; t < y ; t + = 5 )
2004-09-19 14:24:53 -06:00
{
2004-11-23 12:03:39 -07:00
vpaned_main . set_position ( t ) ;
2006-02-15 09:05:26 -07:00
while ( Gtk : : Main : : events_pending ( ) )
Gtk : : Main : : iteration ( ) ;
2004-09-19 14:24:53 -06:00
}
2004-10-11 08:19:56 -06:00
2006-02-15 09:05:26 -07:00
hbox_operations . hide ( ) ;
2006-02-02 03:59:44 -07:00
static_cast < Gtk : : CheckMenuItem * > (
2006-02-15 09:05:26 -07:00
& menubar_main . items ( ) [ 2 ] . get_submenu ( ) - >
items ( ) [ 1 ] ) - > set_active ( false ) ;
2004-09-19 14:24:53 -06:00
}
2006-02-02 03:59:44 -07:00
void Win_GParted : : clear_operationslist ( )
2004-09-19 14:24:53 -06:00
{
2006-02-02 03:59:44 -07:00
operations . clear ( ) ;
Refresh_Visual ( ) ;
2004-09-19 14:24:53 -06:00
}
2006-02-02 03:59:44 -07:00
void Win_GParted : : combo_devices_changed ( )
{
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 ( ) ;
2006-01-24 05:31:58 -07:00
this - > set_title ( String : : ucompose ( _ ( " %1 - GParted " ) , devices [ current_device ] . path ) ) ;
2004-09-19 14:24:53 -06:00
//refresh label_device_info
2006-02-02 03:59:44 -07:00
Fill_Label_Device_Info ( ) ;
2004-09-19 14:24:53 -06:00
//rebuild visualdisk and treeview
2006-02-02 03:59:44 -07:00
Refresh_Visual ( ) ;
//uodate radiobuttons..
if ( menubar_main . items ( ) [ 0 ] . get_submenu ( ) - > items ( ) [ 1 ] . get_submenu ( ) )
static_cast < Gtk : : RadioMenuItem * > (
& menubar_main . items ( ) [ 0 ] . get_submenu ( ) - > items ( ) [ 1 ] . get_submenu ( ) - >
items ( ) [ current_device ] ) - > set_active ( true ) ;
}
void Win_GParted : : radio_devices_changed ( unsigned int item )
{
if ( static_cast < Gtk : : RadioMenuItem * > (
& 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-01-08 08:20:14 -07:00
void Win_GParted : : thread_refresh_devices ( )
{
gparted_core . get_devices ( devices ) ;
pulse = false ;
}
2004-12-27 05:08:01 -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
pulse = true ;
thread = Glib : : Thread : : create ( sigc : : mem_fun ( * this , & Win_GParted : : thread_refresh_devices ) , true ) ;
show_pulsebar ( _ ( " Scanning all devices... " ) ) ;
2006-01-24 05:31:58 -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
2004-11-29 06:20:05 -07:00
//show read-only warning if necessary
Glib : : ustring readonly_paths ;
2005-12-22 15:20:55 -07:00
for ( unsigned int t = 0 ; t < devices . size ( ) ; t + + )
2004-11-29 06:20:05 -07:00
if ( devices [ t ] . readonly )
readonly_paths + = " \n - " + devices [ t ] . path ;
2005-12-22 15:20:55 -07:00
if ( ! readonly_paths . empty ( ) )
2004-11-29 06:20:05 -07:00
{
str_temp = " <span weight= \" bold \" size= \" larger \" > " ;
str_temp + = _ ( " The kernel is unable to re-read the partitiontables on the following devices: " ) ;
str_temp + = readonly_paths ;
str_temp + = " </span> \n \n " ;
2004-11-29 08:27:33 -07:00
str_temp + = _ ( " Because of this you will only have limited access to these devices. " ) ;
2004-11-29 06:20:05 -07:00
str_temp + = " \n " ;
str_temp + = _ ( " Unmount all mounted partitions on a device to get full access. " ) ;
Gtk : : MessageDialog dialog ( * this , str_temp , true , Gtk : : MESSAGE_WARNING , Gtk : : BUTTONS_OK , true ) ;
2004-12-27 05:08:01 -07:00
dialog . run ( ) ;
2004-11-29 06:20:05 -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 :-)
unsigned int i ;
for ( unsigned int t = 0 ; t < operations . size ( ) ; t + + )
{
for ( i = 0 ; i < devices . size ( ) & & devices [ i ] . path ! = operations [ t ] . device . path ; i + + ) { }
if ( i > = devices . size ( ) )
operations . erase ( operations . begin ( ) + t - - ) ; //decrease t bij one..
}
//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 ( ) ;
2005-02-01 10:04:03 -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-02-10 16:47:02 -07:00
frame_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 ) ;
2006-02-10 16:47:02 -07:00
frame_visualdisk . clear ( ) ;
2005-12-23 17:06:05 -07:00
treeview_detail . clear ( ) ;
2005-02-01 10:04:03 -07:00
//hmzz, this is really paranoid, but i think it's the right thing to do ;)
2005-12-29 16:35:37 -07:00
liststore_operations - > clear ( ) ;
2005-12-22 15:20:55 -07:00
close_operationslist ( ) ;
operations . clear ( ) ;
2005-02-01 10:04:03 -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 ( ) ;
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-02-10 16:47:02 -07:00
frame_visualdisk . set_sensitive ( true ) ;
2005-12-29 16:35:37 -07:00
treeview_detail . set_sensitive ( true ) ;
2005-02-01 10:04:03 -07:00
2005-12-29 16:35:37 -07:00
refresh_combo_devices ( ) ;
2005-02-01 10:04:03 -07:00
}
2004-09-19 14:24:53 -06:00
}
2004-12-15 09:38:37 -07:00
void Win_GParted : : menu_gparted_filesystems ( )
{
Dialog_Filesystems dialog ;
dialog . set_transient_for ( * this ) ;
2006-01-02 08:18:29 -07:00
dialog . Load_Filesystems ( gparted_core . get_filesystems ( ) ) ;
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 ( ) ;
dialog . Load_Filesystems ( gparted_core . get_filesystems ( ) ) ;
//recreate format menu...
menu_partition . items ( ) [ 8 ] . remove_submenu ( ) ;
menu_partition . items ( ) [ 8 ] . set_submenu ( * create_format_menu ( ) ) ;
menu_partition . show_all_children ( ) ;
2004-12-15 09:38:37 -07:00
}
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : menu_gparted_quit ( )
2004-09-19 14:24:53 -06:00
{
2004-11-23 12:03:39 -07:00
if ( Quit_Check_Operations ( ) )
this - > hide ( ) ;
2004-09-19 14:24:53 -06:00
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : menu_view_harddisk_info ( )
2004-09-27 14:12:47 -06:00
{
2005-11-27 12:48:00 -07:00
if ( ( ( Gtk : : CheckMenuItem * ) & menubar_main . items ( ) [ 2 ] . get_submenu ( ) - > items ( ) [ 0 ] ) - > get_active ( ) )
2004-09-27 14:12:47 -06:00
{ //open harddisk information
2004-11-23 12:03:39 -07:00
hpaned_main . get_child1 ( ) - > show ( ) ;
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 ) ;
while ( Gtk : : Main : : events_pending ( ) )
Gtk : : Main : : iteration ( ) ;
2004-09-27 14:12:47 -06:00
}
}
else
{ //close harddisk information
2004-11-23 12:03:39 -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 ) ;
while ( Gtk : : Main : : events_pending ( ) )
Gtk : : Main : : iteration ( ) ;
2004-09-27 14:12:47 -06:00
}
2004-11-23 12:03:39 -07:00
hpaned_main . get_child1 ( ) - > hide ( ) ;
2004-09-27 14:12:47 -06:00
}
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : menu_view_operations ( )
2004-10-11 08:19:56 -06:00
{
2005-11-27 12:48:00 -07:00
if ( ( ( Gtk : : CheckMenuItem * ) & menubar_main . items ( ) [ 2 ] . get_submenu ( ) - > items ( ) [ 1 ] ) - > get_active ( ) )
2004-10-11 08:19:56 -06:00
open_operationslist ( ) ;
else
close_operationslist ( ) ;
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : menu_help_contents ( )
2004-09-19 14:24:53 -06:00
{
2004-10-02 03:39:16 -06:00
str_temp = _ ( " Sorry, not yet implemented. " ) ;
str_temp + = " \n " ;
str_temp + = _ ( " Please visit http://gparted.sf.net for more information and support. " ) ;
2004-11-23 12:03:39 -07:00
Gtk : : MessageDialog dialog ( * this , str_temp , false , Gtk : : MESSAGE_INFO , Gtk : : BUTTONS_OK , true ) ;
dialog . run ( ) ;
2004-09-19 14:24:53 -06:00
}
2004-12-27 05:08:01 -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 ;
Gtk : : AboutDialog dialog ;
2004-09-19 14:24:53 -06:00
dialog . set_transient_for ( * this ) ;
2005-11-25 15:41:49 -07:00
dialog . set_name ( _ ( " GParted " ) ) ;
dialog . set_logo ( this - > get_icon ( ) ) ;
dialog . set_version ( VERSION ) ;
2006-01-26 05:50:46 -07:00
dialog . set_comments ( _ ( " GNOME Partition Editor " ) ) ;
2005-11-25 15:41:49 -07:00
dialog . set_copyright ( " Copyright © 2004-2005 Bart Hakvoort " ) ;
//authors
strings . push_back ( " Bart Hakvoort <gparted@users.sf.net> " ) ;
dialog . set_authors ( strings ) ;
strings . clear ( ) ;
//artists
strings . push_back ( " http://gparted.sourceforge.net/artwork.php " ) ;
dialog . set_artists ( strings ) ;
strings . clear ( ) ;
/*TO TRANSLATORS: your name(s) here please, if there are more translators put newlines (\n) between the names.
It ' s a good idea to provide the url of your translationteam as well . Thanks ! */
Glib : : ustring str_credits = _ ( " translator-credits " ) ;
if ( str_credits ! = " translator-credits " )
dialog . set_translator_credits ( str_credits ) ;
//the url is not clickable because this would introduce an new dep (gnome-vfsmm)
dialog . set_website ( " http://gparted.sourceforge.net " ) ;
dialog . run ( ) ;
2004-09-19 14:24:53 -06:00
}
2005-12-23 17:06:05 -07:00
void Win_GParted : : on_partition_selected ( const Partition & partition , bool src_is_treeview )
2004-09-19 14:24:53 -06:00
{
selected_partition = partition ;
2006-02-09 10:02:40 -07:00
2006-02-08 13:36:18 -07:00
set_valid_operations ( ) ;
2004-09-19 14:24:53 -06:00
2005-12-23 17:06:05 -07:00
if ( src_is_treeview )
2006-02-10 16:47:02 -07:00
frame_visualdisk . set_selected ( partition ) ;
2005-12-23 17:06:05 -07:00
else
treeview_detail . set_selected ( partition ) ;
}
void Win_GParted : : on_partition_activated ( )
{
2006-01-08 08:20:14 -07:00
activate_info ( ) ;
2005-12-23 17:06:05 -07:00
}
void Win_GParted : : on_partition_popup_menu ( unsigned int button , unsigned int time )
{
menu_partition . popup ( button , time ) ;
2004-09-19 14:24:53 -06:00
}
2004-11-06 04:55:03 -07:00
bool Win_GParted : : max_amount_prim_reached ( )
{
//Display error if user tries to create more primary partitions than the partition table can hold.
2004-11-17 06:00:25 -07:00
if ( ! selected_partition . inside_extended & & primary_count > = devices [ current_device ] . max_prims )
2004-11-06 04:55:03 -07:00
{
str_temp = " <span weight= \" bold \" size= \" larger \" > " ;
2004-11-17 06:00:25 -07:00
str_temp + = String : : ucompose ( _ ( " It is not possible to create more than %1 primary partitions " ) , devices [ current_device ] . max_prims ) ;
2004-11-06 04:55:03 -07:00
str_temp + = " </span> \n \n " ;
str_temp + = _ ( " If you want more partitions you should first create an extended partition. Such a partition can contain other partitions. " ) ;
Gtk : : MessageDialog dialog ( * this , str_temp , true , Gtk : : MESSAGE_ERROR , Gtk : : BUTTONS_OK , true ) ;
2004-12-27 05:08:01 -07:00
dialog . run ( ) ;
2004-11-06 04:55:03 -07:00
return true ;
}
return false ;
}
2004-09-19 14:24:53 -06:00
2005-02-01 10:04:03 -07:00
void Win_GParted : : activate_resize ( )
2004-09-19 14:24:53 -06:00
{
//show warning when one tries to resize a fat16 filesystem
2005-12-07 04:21:27 -07:00
if ( selected_partition . filesystem = = GParted : : FS_FAT16 )
2004-09-19 14:24:53 -06:00
{
2004-10-02 03:39:16 -06:00
str_temp = " <span weight= \" bold \" size= \" larger \" > " ;
str_temp + = _ ( " Are you sure you want to resize/move this partition? " ) ;
str_temp + = " </span> \n \n " ;
str_temp + = _ ( " Resizing a fat16 partition can be quite tricky! Especially growing such a partition is very error-prone. It is advisable to first convert the filesystem to fat32. " ) ;
str_temp + = " \n " ;
2004-09-19 14:24:53 -06:00
2004-10-02 03:39:16 -06:00
Gtk : : MessageDialog dialog ( * this , str_temp , true , Gtk : : MESSAGE_WARNING , Gtk : : BUTTONS_CANCEL , true ) ;
2004-09-19 14:24:53 -06:00
//pffff this whole mess only for this f*cked up filesystem :-(
Gtk : : Button button_resize_move ;
Gtk : : HBox hbox_resize_move ;
2004-10-06 13:06:43 -06:00
2004-09-19 14:24:53 -06:00
image = manage ( new Gtk : : Image ( Gtk : : Stock : : GOTO_LAST , Gtk : : ICON_SIZE_BUTTON ) ) ;
hbox_resize_move . pack_start ( * image , Gtk : : PACK_SHRINK ) ;
2005-12-13 14:30:13 -07:00
hbox_resize_move . pack_start ( * Utils : : mk_label ( _ ( " Resize/Move " ) ) , Gtk : : PACK_SHRINK ) ;
2004-09-19 14:24:53 -06:00
button_resize_move . add ( hbox_resize_move ) ;
2004-12-13 06:58:51 -07:00
dialog . add_action_widget ( button_resize_move , Gtk : : RESPONSE_OK ) ;
2004-11-06 04:55:03 -07:00
dialog . show_all_children ( ) ;
2004-09-19 14:24:53 -06:00
2004-12-15 03:33:12 -07:00
if ( dialog . run ( ) = = Gtk : : RESPONSE_CANCEL )
2004-09-19 14:24:53 -06:00
return ;
}
2006-01-05 13:01:34 -07:00
std : : vector < Partition > partitions = devices [ current_device ] . partitions ;
2004-09-19 14:24:53 -06:00
2004-11-21 14:49:38 -07:00
if ( operations . size ( ) )
for ( unsigned int t = 0 ; t < operations . size ( ) ; t + + )
2004-12-27 05:08:01 -07:00
if ( operations [ t ] . device . path = = devices [ current_device ] . path )
2004-11-07 06:13:11 -07:00
operations [ t ] . Apply_Operation_To_Visual ( partitions ) ;
2004-09-19 14:24:53 -06:00
2004-12-27 05:08:01 -07:00
Dialog_Partition_Resize_Move dialog ( gparted_core . get_fs ( selected_partition . filesystem ) , devices [ current_device ] . cylsize ) ;
2004-11-06 04:55:03 -07:00
2005-12-07 04:21:27 -07:00
if ( selected_partition . type = = GParted : : TYPE_LOGICAL )
2004-11-06 04:55:03 -07:00
{
unsigned int ext = 0 ;
2005-12-07 04:21:27 -07:00
while ( ext < partitions . size ( ) & & partitions [ ext ] . type ! = GParted : : TYPE_EXTENDED ) ext + + ;
2004-11-06 04:55:03 -07:00
dialog . Set_Data ( selected_partition , partitions [ ext ] . logicals ) ;
}
else
dialog . Set_Data ( selected_partition , partitions ) ;
2004-09-19 14:24:53 -06:00
dialog . set_transient_for ( * this ) ;
2004-12-15 03:33:12 -07:00
if ( dialog . run ( ) = = Gtk : : RESPONSE_OK )
2004-09-19 14:24:53 -06:00
{
2004-12-15 03:33:12 -07:00
dialog . hide ( ) ; //i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation)
2004-09-19 14:24:53 -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 )
2005-12-07 04:21:27 -07:00
if ( selected_partition . status = = GParted : : STAT_NEW & & selected_partition . type ! = GParted : : TYPE_EXTENDED )
2004-09-19 14:24:53 -06:00
{
//remove operation which creates this partition
2004-12-15 03:33:12 -07:00
for ( unsigned int t = 0 ; t < operations . size ( ) ; t + + )
2004-09-19 14:24:53 -06:00
{
2004-12-15 03:33:12 -07:00
if ( operations [ t ] . partition_new . partition = = selected_partition . partition )
2004-09-19 14:24:53 -06:00
{
2004-12-15 03:33:12 -07:00
operations . erase ( operations . begin ( ) + t ) ;
2004-09-19 14:24:53 -06:00
//And add the new partition to the end of the operations list
2004-12-15 03:33:12 -07:00
Add_Operation ( GParted : : CREATE , dialog . Get_New_Partition ( ) ) ;
2004-09-19 14:24:53 -06:00
break ;
}
}
}
else //normal move/resize on existing partition
2004-12-15 03:33:12 -07:00
Add_Operation ( GParted : : RESIZE_MOVE , dialog . Get_New_Partition ( ) ) ;
2004-09-19 14:24:53 -06:00
}
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : activate_copy ( )
2004-09-19 14:24:53 -06:00
{
copied_partition = selected_partition ;
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : activate_paste ( )
2004-09-19 14:24:53 -06:00
{
2006-01-22 14:16:36 -07:00
if ( ! max_amount_prim_reached ( ) )
2004-09-19 14:24:53 -06:00
{
2006-01-22 14:16:36 -07:00
Dialog_Partition_Copy dialog ( gparted_core . get_fs ( copied_partition . filesystem ) ,
devices [ current_device ] . cylsize ) ;
//we don't need the errors of the source partition.
copied_partition . error . clear ( ) ;
2004-11-06 04:55:03 -07:00
dialog . Set_Data ( selected_partition , copied_partition ) ;
dialog . set_transient_for ( * this ) ;
2006-01-22 14:16:36 -07:00
if ( dialog . run ( ) = = Gtk : : RESPONSE_OK )
2004-11-06 04:55:03 -07:00
{
2006-01-22 14:16:36 -07:00
dialog . hide ( ) ;
Add_Operation ( GParted : : COPY , dialog . Get_New_Partition ( ) ) ;
2004-11-06 04:55:03 -07:00
}
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
{
2004-11-27 16:31:19 -07:00
//if max_prims == -1 the current device has an unrecognised disklabel (see also GParted_Core::get_devices)
if ( devices [ current_device ] . max_prims = = - 1 )
2006-02-09 10:02:40 -07:00
activate_disklabel ( ) ;
2004-11-27 16:31:19 -07:00
2006-02-09 10:02:40 -07:00
else if ( ! max_amount_prim_reached ( ) )
2004-11-06 04:55:03 -07:00
{
Dialog_Partition_New dialog ;
2004-12-10 13:42:23 -07:00
2006-02-09 10:02:40 -07:00
dialog . Set_Data ( selected_partition ,
any_extended ,
new_count ,
gparted_core . get_filesystems ( ) ,
devices [ current_device ] . readonly ,
devices [ current_device ] . cylsize ) ;
2004-11-06 04:55:03 -07:00
dialog . set_transient_for ( * this ) ;
2004-09-19 14:24:53 -06:00
2006-02-09 10:02:40 -07:00
if ( dialog . run ( ) = = Gtk : : RESPONSE_OK )
2004-11-06 04:55:03 -07:00
{
2006-02-09 10:02:40 -07:00
dialog . hide ( ) ; //make sure the dialog is gone _before_ operationslist shows up (only matters if first operation)
2004-11-06 04:55:03 -07:00
new_count + + ;
2006-02-09 10:02:40 -07:00
Add_Operation ( GParted : : CREATE , dialog . Get_New_Partition ( ) ) ;
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 ( )
2004-09-19 14:24:53 -06:00
{
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
* the new situation is now / dev / hda5 / dev / hda6 . If / dev / hda7 was mounted
* 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 . */
if ( selected_partition . type = = GParted : : TYPE_LOGICAL & &
2004-11-06 04:55:03 -07:00
selected_partition . status ! = GParted : : STAT_NEW & &
2006-01-02 08:18:29 -07:00
selected_partition . partition_number < devices [ current_device ] . highest_busy )
2004-09-19 14:24:53 -06:00
{
2004-10-02 03:39:16 -06:00
str_temp = " <span weight= \" bold \" size= \" larger \" > " ;
str_temp + = _ ( " Unable to delete partition! " ) ;
str_temp + = " </span> \n \n " ;
2006-01-02 08:18:29 -07:00
str_temp + = String : : ucompose (
_ ( " Please unmount any logical partitions having a number higher than %1 " ) ,
selected_partition . partition_number ) ;
2004-11-06 04:55:03 -07:00
Gtk : : MessageDialog dialog ( * this , str_temp , true , Gtk : : MESSAGE_ERROR , Gtk : : BUTTONS_OK , true ) ;
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
}
2006-01-02 08:18:29 -07:00
//if partition is on the clipboard...
2004-09-19 14:24:53 -06:00
if ( selected_partition . partition = = copied_partition . partition )
2004-10-02 03:39:16 -06:00
{
2006-01-02 08:18:29 -07:00
str_temp = " <span weight= \" bold \" size= \" larger \" > " ;
str_temp + = String : : ucompose ( _ ( " Are you sure you want to delete %1? " ) ,
selected_partition . partition ) + " </span> \n \n " ;
2004-10-02 03:39:16 -06:00
str_temp + = _ ( " After deletion this partition is no longer available for copying. " ) ;
2006-01-02 08:18:29 -07:00
Gtk : : MessageDialog dialog ( * this , str_temp , true , Gtk : : MESSAGE_QUESTION , Gtk : : BUTTONS_NONE , true ) ;
2006-01-20 16:35:06 -07:00
/*TO TRANSLATORS: dialogtitle, looks like Delete /dev/hda2 (ntfs, 2345 MiB) */
dialog . set_title ( String : : ucompose ( _ ( " Delete %1 (%2, %3 MiB) " ) ,
2006-01-02 08:18:29 -07:00
selected_partition . partition ,
selected_partition . filesystem ,
selected_partition . Get_Length_MB ( ) ) ) ;
dialog . add_button ( Gtk : : Stock : : CANCEL , Gtk : : RESPONSE_CANCEL ) ;
dialog . add_button ( Gtk : : Stock : : DELETE , Gtk : : RESPONSE_OK ) ;
dialog . show_all_children ( ) ;
if ( dialog . run ( ) ! = Gtk : : RESPONSE_OK )
return ;
2004-10-02 03:39:16 -06:00
}
2004-09-19 14:24:53 -06:00
2006-01-02 08:18:29 -07:00
//if deleted partition was on the clipboard we erase it...
if ( selected_partition . partition = = copied_partition . partition )
copied_partition . Reset ( ) ;
2004-11-17 06:00:25 -07:00
2006-01-02 08:18:29 -07: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 . status = = GParted : : STAT_NEW )
{
//remove all operations done on this new partition (this includes creation)
for ( int t = 0 ; t < static_cast < int > ( operations . size ( ) ) ; t + + )
if ( operations [ t ] . partition_new . partition = = selected_partition . partition )
operations . erase ( operations . begin ( ) + t - - ) ;
2004-09-19 14:24:53 -06:00
2006-01-02 08:18:29 -07:00
//determine lowest possible new_count
new_count = 0 ;
for ( unsigned int t = 0 ; t < operations . size ( ) ; t + + )
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 ;
2004-09-19 14:24:53 -06:00
2006-01-02 08:18:29 -07:00
new_count + = 1 ;
2004-11-06 04:55:03 -07:00
2006-01-02 08:18:29 -07:00
Refresh_Visual ( ) ;
2004-09-19 14:24:53 -06:00
2006-01-02 08:18:29 -07:00
if ( ! operations . size ( ) )
close_operationslist ( ) ;
2004-09-19 14:24:53 -06:00
}
2006-01-02 08:18:29 -07:00
else //deletion of a real partition...(now selected_partition is just a dummy)
Add_Operation ( GParted : : DELETE , selected_partition ) ;
2004-09-19 14:24:53 -06:00
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : activate_info ( )
2004-09-19 14:24:53 -06:00
{
Dialog_Partition_Info dialog ( selected_partition ) ;
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
{
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 ) ;
2004-12-09 15:56:33 -07:00
2006-01-02 08:18:29 -07:00
if ( selected_partition . Get_Length_MB ( ) < fs . MIN | |
fs . MAX & & selected_partition . Get_Length_MB ( ) > fs . MAX )
2004-09-19 14:24:53 -06:00
{
2004-12-09 15:56:33 -07:00
str_temp = " <span weight= \" bold \" size= \" larger \" > " ;
2006-01-02 08:18:29 -07:00
str_temp + = String : : ucompose (
2006-01-03 04:34:08 -07:00
_ ( " Cannot format this filesystem to %1. " ) ,
2006-01-02 08:18:29 -07:00
Utils : : Get_Filesystem_String ( new_fs ) ) ;
2004-12-09 15:56:33 -07:00
str_temp + = " </span> \n \n " ;
2004-09-19 14:24:53 -06:00
2004-12-09 15:56:33 -07:00
if ( selected_partition . Get_Length_MB ( ) < fs . MIN )
2006-01-02 08:18:29 -07:00
str_temp + = String : : ucompose (
2006-01-20 16:35:06 -07:00
_ ( " A %1 filesystem requires a partition of at least %2 MiB. " ) ,
2006-01-02 08:18:29 -07:00
Utils : : Get_Filesystem_String ( new_fs ) ,
fs . MIN ) ;
2004-12-09 15:56:33 -07:00
else
2006-01-02 08:18:29 -07:00
str_temp + = String : : ucompose (
2006-01-20 16:35:06 -07:00
_ ( " A partition with a %1 filesystem has a maximum size of %2 MiB. " ) ,
2006-01-02 08:18:29 -07:00
Utils : : Get_Filesystem_String ( new_fs ) ,
fs . MAX ) ;
2004-12-09 15:56:33 -07:00
Gtk : : MessageDialog dialog ( * this , str_temp , true , Gtk : : MESSAGE_ERROR , Gtk : : BUTTONS_OK , true ) ;
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
}
//ok we made it :P lets create an fitting partition object
Partition part_temp ;
2005-12-07 15:44:40 -07:00
part_temp . Set ( devices [ current_device ] . path ,
selected_partition . partition ,
selected_partition . partition_number ,
selected_partition . type , new_fs ,
selected_partition . sector_start ,
selected_partition . sector_end ,
selected_partition . inside_extended ,
false ) ;
2004-09-19 14:24:53 -06:00
2006-01-02 08:18:29 -07:00
//if selected_partition is NEW we simply remove the NEW operation from the list and
//add it again with the new filesystem
if ( selected_partition . status = = GParted : : 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
{
2004-12-27 05:08:01 -07:00
if ( operations [ t ] . partition_new . partition = = selected_partition . partition )
2004-09-19 14:24:53 -06:00
{
2006-01-02 08:18:29 -07:00
operations . erase ( operations . begin ( ) + t ) ;
2004-09-19 14:24:53 -06:00
2006-01-02 08:18:29 -07:00
//And add the new partition to the end of the operations list
//(NOTE: in this case we set status to STAT_NEW)
2004-09-26 12:41:43 -06:00
part_temp . status = STAT_NEW ;
2004-12-27 05:08:01 -07:00
Add_Operation ( GParted : : CREATE , part_temp ) ;
2004-09-19 14:24:53 -06:00
break ;
}
}
}
2006-01-02 08:18:29 -07:00
else //normal formatting of an existing partition
Add_Operation ( GParted : : FORMAT , part_temp ) ;
2004-09-19 14:24:53 -06:00
}
2006-02-15 09:05:26 -07:00
void Win_GParted : : thread_unmount_partition ( bool * succes , Glib : : ustring * error )
2006-01-08 08:20:14 -07:00
{
2006-02-15 15:32:54 -07:00
* succes = true ;
for ( unsigned int t = 0 ; t < selected_partition . mountpoints . size ( ) & & * succes ; t + + )
* succes = ! Utils : : execute_command ( " umount -v " + selected_partition . mountpoints [ t ] , str_temp , * error ) ;
2006-02-15 09:05:26 -07:00
2006-01-08 08:20:14 -07:00
pulse = false ;
}
2006-02-15 09:05:26 -07:00
void Win_GParted : : activate_unmount ( )
2004-11-06 12:48:24 -07:00
{
2006-02-15 15:32:54 -07:00
bool succes ;
2006-02-15 09:05:26 -07:00
Glib : : ustring error ;
2006-01-08 08:20:14 -07:00
pulse = true ;
2006-02-15 09:05:26 -07:00
thread = Glib : : Thread : : create ( sigc : : bind < bool * , Glib : : ustring * > (
sigc : : mem_fun ( * this , & Win_GParted : : thread_unmount_partition ) , & succes , & error ) , true ) ;
2006-01-08 08:20:14 -07:00
show_pulsebar ( String : : ucompose ( _ ( " Unmounting %1 " ) , selected_partition . partition ) ) ;
2006-02-15 09:05:26 -07:00
if ( ! succes )
2004-11-06 12:48:24 -07:00
{
2006-01-08 08:20:14 -07:00
Gtk : : MessageDialog dialog ( * this ,
2006-02-15 09:05:26 -07:00
String : : ucompose ( _ ( " Could not unmount %1 " ) , selected_partition . partition ) ,
false ,
2006-01-08 08:20:14 -07:00
Gtk : : MESSAGE_ERROR ,
Gtk : : BUTTONS_OK ,
true ) ;
2006-02-15 09:05:26 -07:00
dialog . set_secondary_text ( error ) ;
2006-01-08 08:20:14 -07:00
dialog . run ( ) ;
2005-12-14 07:47:58 -07:00
}
2006-01-08 08:20:14 -07:00
2006-01-07 14:23:09 -07:00
menu_gparted_refresh_devices ( ) ;
}
2006-02-15 09:05:26 -07:00
void Win_GParted : : thread_toggle_swap ( bool * succes , Glib : : ustring * error )
2006-01-07 14:23:09 -07:00
{
2006-02-08 13:36:18 -07:00
if ( selected_partition . busy )
2006-02-16 04:41:10 -07:00
* succes = ! Utils : : execute_command ( " swapoff -v " + selected_partition . partition + " && sync " , str_temp , * error ) ;
2006-01-08 08:20:14 -07:00
else
2006-02-16 04:41:10 -07:00
* succes = ! Utils : : execute_command ( " swapon -v " + selected_partition . partition + " && sync " , str_temp , * error ) ;
2006-01-08 08:20:14 -07:00
pulse = false ;
}
2006-02-08 13:36:18 -07:00
void Win_GParted : : activate_toggle_swap ( )
2006-01-08 08:20:14 -07:00
{
2006-02-15 09:05:26 -07:00
bool succes = false ;
Glib : : ustring error ;
2006-01-08 08:20:14 -07:00
pulse = true ;
2006-02-15 09:05:26 -07:00
thread = Glib : : Thread : : create ( sigc : : bind < bool * , Glib : : ustring * > (
sigc : : mem_fun ( * this , & Win_GParted : : thread_toggle_swap ) , & succes , & error ) , true ) ;
2006-01-08 08:20:14 -07:00
2006-02-08 13:36:18 -07:00
show_pulsebar (
String : : ucompose ( selected_partition . busy ? _ ( " Deactivating swap on %1 " ) : _ ( " Activating swap on %1 " ) ,
selected_partition . partition ) ) ;
2006-01-08 08:20:14 -07:00
2006-02-15 09:05:26 -07:00
if ( ! succes )
2006-01-07 14:23:09 -07:00
{
2006-02-08 13:36:18 -07:00
Gtk : : MessageDialog dialog (
* this ,
selected_partition . busy ? _ ( " Could not deactivate swap " ) : _ ( " Could not activate swap " ) ,
false ,
Gtk : : MESSAGE_ERROR ,
Gtk : : BUTTONS_OK ,
true ) ;
2006-02-15 09:05:26 -07:00
dialog . set_secondary_text ( error ) ;
2006-02-08 13:36:18 -07:00
2006-01-07 14:23:09 -07:00
dialog . run ( ) ;
}
menu_gparted_refresh_devices ( ) ;
2004-11-06 12:48:24 -07:00
}
2005-01-30 07:31:29 -07:00
void Win_GParted : : activate_disklabel ( )
{
2005-09-13 11:09:20 -06:00
Dialog_Disklabel dialog ( devices [ current_device ] . path , gparted_core . get_disklabeltypes ( ) ) ;
2005-01-30 07:31:29 -07:00
dialog . set_transient_for ( * this ) ;
if ( dialog . run ( ) = = Gtk : : RESPONSE_OK )
{
str_temp = " <span weight= \" bold \" size= \" larger \" > " ;
str_temp + = String : : ucompose ( _ ( " Are you sure you want to create a %1 disklabel on %2? " ) , dialog . Get_Disklabel ( ) , devices [ current_device ] . path ) ;
str_temp + = " </span> \n \n " ;
str_temp + = String : : ucompose ( _ ( " This operation will destroy all data on %1 " ) , devices [ current_device ] . path ) ;
Gtk : : MessageDialog m_dialog ( * this , str_temp , true , Gtk : : MESSAGE_QUESTION , Gtk : : BUTTONS_CANCEL , true ) ;
m_dialog . add_button ( _ ( " Create " ) , Gtk : : RESPONSE_OK ) ;
if ( m_dialog . run ( ) = = Gtk : : RESPONSE_OK & & ! gparted_core . Set_Disklabel ( devices [ current_device ] . path , dialog . Get_Disklabel ( ) ) )
{
Gtk : : MessageDialog dialog ( * this , _ ( " Error while setting new disklabel " ) , true , Gtk : : MESSAGE_ERROR , Gtk : : BUTTONS_OK , true ) ;
dialog . run ( ) ;
}
menu_gparted_refresh_devices ( ) ;
}
}
2004-12-27 05:08:01 -07:00
void Win_GParted : : activate_undo ( )
2004-09-19 14:24:53 -06:00
{
//when undoing an creation it's safe to decrease the newcount by one
2004-12-27 05:08:01 -07:00
if ( operations . back ( ) . operationtype = = GParted : : CREATE )
2004-10-06 09:32:40 -06:00
new_count - - ;
2004-09-19 14:24:53 -06:00
2004-12-27 05:08:01 -07:00
operations . erase ( operations . end ( ) ) ;
2004-09-19 14:24:53 -06:00
2004-12-27 05:08:01 -07:00
Refresh_Visual ( ) ;
2004-09-19 14:24:53 -06:00
2004-12-27 05:08:01 -07:00
if ( ! operations . size ( ) )
close_operationslist ( ) ;
2004-09-19 14:24:53 -06:00
}
2004-12-27 05:08:01 -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 ,
_ ( " Are you sure you want to apply the pending operations? " ) ,
false ,
Gtk : : MESSAGE_WARNING ,
Gtk : : BUTTONS_NONE ,
true ) ;
dialog . set_secondary_text ( _ ( " It is recommended to backup valuable data before proceeding. " ) ) ;
2004-11-17 06:00:25 -07:00
dialog . set_title ( _ ( " Apply operations to harddisk " ) ) ;
2004-09-19 14:24:53 -06: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 ) ;
2004-09-19 14:24:53 -06: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
2004-10-16 09:42:08 -06: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-02-07 08:17:44 -07:00
int response ;
do
{
response = dialog_progress . run ( ) ;
}
while ( response = = Gtk : : RESPONSE_CANCEL | | response = = Gtk : : RESPONSE_OK ) ;
2006-01-19 12:15:15 -07:00
dialog_progress . hide ( ) ;
2004-09-21 12:04:48 -06:00
2004-09-19 14:24:53 -06:00
//wipe operations...
2006-01-19 12:15:15 -07:00
operations . clear ( ) ;
liststore_operations - > clear ( ) ;
close_operationslist ( ) ;
2004-10-11 04:23:24 -06:00
//reset new_count to 1
2004-10-16 09:42:08 -06:00
new_count = 1 ;
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
}
}
} // GParted