2009-11-05 11:08:32 -07:00
|
|
|
/* Copyright (C) 2004 Bart
|
2011-02-22 13:22:49 -07:00
|
|
|
* Copyright (C) 2008, 2009, 2010, 2011 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
|
|
|
|
* 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/Dialog_Progress.h"
|
2006-01-19 12:15:15 -07:00
|
|
|
|
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
#include <gtkmm/main.h>
|
|
|
|
#include <gtkmm/messagedialog.h>
|
2006-02-07 08:17:44 -07:00
|
|
|
#include <gtkmm/filechooserdialog.h>
|
2006-01-19 12:15:15 -07:00
|
|
|
|
2004-10-06 13:06:43 -06:00
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
2006-03-24 12:08:41 -07:00
|
|
|
Dialog_Progress::Dialog_Progress( const std::vector<Operation *> & operations )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
|
|
|
this ->set_has_separator( false ) ;
|
|
|
|
this ->set_title( _("Applying pending operations") ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
this ->operations = operations ;
|
|
|
|
succes = true ;
|
2006-01-25 16:30:43 -07:00
|
|
|
cancel = false ;
|
2006-09-09 04:58:48 -06:00
|
|
|
warnings = 0 ;
|
2006-01-19 12:15:15 -07:00
|
|
|
|
|
|
|
fraction = 1.00 / operations .size() ;
|
2013-01-30 14:23:48 -07:00
|
|
|
this->property_default_width() = 700;
|
|
|
|
|
2011-06-26 06:03:37 -06:00
|
|
|
{
|
|
|
|
Gtk::VBox* vbox(manage(new Gtk::VBox()));
|
|
|
|
|
|
|
|
vbox->set_border_width(10);
|
2013-01-30 14:23:48 -07:00
|
|
|
this->get_vbox()->pack_start(*vbox, Gtk::PACK_EXPAND_WIDGET);
|
2011-06-26 06:03:37 -06:00
|
|
|
|
|
|
|
Glib::ustring str_temp(_("Depending on the number and type of operations this might take a long time."));
|
|
|
|
str_temp += "\n";
|
|
|
|
vbox->pack_start(*Utils::mk_label(str_temp), Gtk::PACK_SHRINK);
|
|
|
|
|
|
|
|
label_current.set_alignment(Gtk::ALIGN_LEFT);
|
|
|
|
vbox->pack_start(label_current, Gtk::PACK_SHRINK);
|
|
|
|
|
|
|
|
progressbar_current.set_pulse_step(0.01);
|
|
|
|
vbox->pack_start(progressbar_current, Gtk::PACK_SHRINK);
|
|
|
|
|
|
|
|
label_current_sub.set_alignment(Gtk::ALIGN_LEFT);
|
|
|
|
vbox->pack_start(label_current_sub, Gtk::PACK_SHRINK);
|
|
|
|
|
|
|
|
vbox->pack_start(*Utils::mk_label("<b>" + Glib::ustring(_("Completed Operations:")) + "</b>"),
|
|
|
|
Gtk::PACK_SHRINK);
|
|
|
|
vbox->pack_start(progressbar_all, Gtk::PACK_SHRINK);
|
|
|
|
|
|
|
|
//create some icons here, instead of recreating them every time
|
|
|
|
icon_execute = render_icon(Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_LARGE_TOOLBAR);
|
|
|
|
icon_succes = render_icon(Gtk::Stock::APPLY, Gtk::ICON_SIZE_LARGE_TOOLBAR);
|
|
|
|
icon_error = render_icon(Gtk::Stock::DIALOG_ERROR, Gtk::ICON_SIZE_LARGE_TOOLBAR);
|
|
|
|
icon_info = render_icon(Gtk::Stock::INFO, Gtk::ICON_SIZE_LARGE_TOOLBAR);
|
|
|
|
icon_n_a = render_icon(Gtk::Stock::DIALOG_WARNING, Gtk::ICON_SIZE_LARGE_TOOLBAR);
|
|
|
|
|
|
|
|
treestore_operations = Gtk::TreeStore::create( treeview_operations_columns);
|
|
|
|
treeview_operations.set_model(treestore_operations);
|
|
|
|
treeview_operations.set_headers_visible(false);
|
|
|
|
treeview_operations.set_rules_hint(true);
|
2013-01-30 14:23:48 -07:00
|
|
|
treeview_operations.set_size_request(700, 250);
|
2011-06-26 06:03:37 -06:00
|
|
|
treeview_operations.append_column("", treeview_operations_columns.operation_description);
|
|
|
|
treeview_operations.append_column("", treeview_operations_columns.elapsed_time);
|
|
|
|
treeview_operations.append_column("", treeview_operations_columns.status_icon);
|
|
|
|
|
|
|
|
treeview_operations.get_column(0)->set_expand(true);
|
|
|
|
treeview_operations.get_column(0)->set_cell_data_func(
|
|
|
|
*(treeview_operations.get_column(0)->get_first_cell_renderer()),
|
|
|
|
sigc::mem_fun(*this, &Dialog_Progress::on_cell_data_description) );
|
|
|
|
|
|
|
|
//fill 'er up
|
|
|
|
for (unsigned int t = 0; t < operations.size(); ++t)
|
|
|
|
{
|
|
|
|
this->operations[t]->operation_detail.set_description(operations[t]->description, FONT_BOLD);
|
|
|
|
this->operations[t]->operation_detail.set_treepath(Utils::num_to_str(t));
|
2009-10-22 10:19:47 -06:00
|
|
|
|
2011-06-26 06:03:37 -06:00
|
|
|
treerow = *(treestore_operations->append());
|
|
|
|
treerow[treeview_operations_columns.operation_description] =
|
|
|
|
this ->operations[t]->operation_detail.get_description();
|
|
|
|
}
|
2009-10-22 10:19:47 -06:00
|
|
|
|
2011-06-26 06:03:37 -06:00
|
|
|
scrolledwindow.set_shadow_type(Gtk::SHADOW_ETCHED_IN);
|
|
|
|
scrolledwindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
2013-01-30 14:23:48 -07:00
|
|
|
scrolledwindow.set_size_request (700, 250);
|
2011-06-26 06:03:37 -06:00
|
|
|
scrolledwindow.add(treeview_operations);
|
2006-05-23 15:17:34 -06:00
|
|
|
|
2011-06-26 06:03:37 -06:00
|
|
|
expander_details.set_label("<b>" + Glib::ustring(_("Details")) + "</b>");
|
|
|
|
expander_details.set_use_markup(true);
|
|
|
|
expander_details.add(scrolledwindow);
|
|
|
|
|
|
|
|
vbox ->pack_start(expander_details, Gtk::PACK_EXPAND_WIDGET);
|
|
|
|
vbox ->set_spacing(5);
|
2006-01-19 12:15:15 -07:00
|
|
|
}
|
2011-06-26 06:03:37 -06:00
|
|
|
|
2012-01-24 18:15:20 -07:00
|
|
|
cancelbutton = this ->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
this ->signal_show() .connect( sigc::mem_fun(*this, &Dialog_Progress::on_signal_show) );
|
|
|
|
this ->show_all_children() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2006-08-20 03:33:54 -06:00
|
|
|
void Dialog_Progress::on_signal_update( const OperationDetail & operationdetail )
|
2004-11-17 06:00:25 -07:00
|
|
|
{
|
2006-08-20 03:33:54 -06:00
|
|
|
Gtk::TreeModel::iterator iter = treestore_operations ->get_iter( operationdetail .get_treepath() ) ;
|
|
|
|
|
2006-10-22 12:19:23 -06:00
|
|
|
//i added the second check after get_iter() in gtk+-2.10 seems to behave differently from gtk+-2.8
|
|
|
|
if ( iter && treestore_operations ->get_string( iter ) == operationdetail .get_treepath() )
|
2004-11-17 06:00:25 -07:00
|
|
|
{
|
2006-08-20 03:33:54 -06:00
|
|
|
Gtk::TreeRow treerow = *iter ;
|
2006-01-19 12:15:15 -07:00
|
|
|
|
2006-08-20 03:33:54 -06:00
|
|
|
treerow[ treeview_operations_columns .operation_description ] = operationdetail .get_description() ;
|
2006-08-22 13:29:59 -06:00
|
|
|
treerow[ treeview_operations_columns .elapsed_time ] = operationdetail .get_elapsed_time() ;
|
2006-08-20 03:33:54 -06:00
|
|
|
|
|
|
|
switch ( operationdetail .get_status() )
|
2006-01-19 12:15:15 -07:00
|
|
|
{
|
2006-07-29 02:27:28 -06:00
|
|
|
case STATUS_EXECUTE:
|
2006-02-07 08:17:44 -07:00
|
|
|
treerow[ treeview_operations_columns .status_icon ] = icon_execute ;
|
|
|
|
break ;
|
2006-07-29 02:27:28 -06:00
|
|
|
case STATUS_SUCCES:
|
2006-02-07 08:17:44 -07:00
|
|
|
treerow[ treeview_operations_columns .status_icon ] = icon_succes ;
|
|
|
|
break ;
|
2006-07-29 02:27:28 -06:00
|
|
|
case STATUS_ERROR:
|
2006-02-07 08:17:44 -07:00
|
|
|
treerow[ treeview_operations_columns .status_icon ] = icon_error ;
|
2006-07-30 09:13:41 -06:00
|
|
|
break ;
|
|
|
|
case STATUS_INFO:
|
|
|
|
treerow[ treeview_operations_columns .status_icon ] = icon_info ;
|
2006-02-07 08:17:44 -07:00
|
|
|
break ;
|
2006-07-29 02:27:28 -06:00
|
|
|
case STATUS_N_A:
|
2006-07-19 14:54:08 -06:00
|
|
|
treerow[ treeview_operations_columns .status_icon ] = icon_n_a ;
|
2006-09-09 04:58:48 -06:00
|
|
|
warnings++ ;
|
2006-07-19 14:54:08 -06:00
|
|
|
break ;
|
2006-08-20 03:33:54 -06:00
|
|
|
case STATUS_NONE:
|
|
|
|
static_cast< Glib::RefPtr<Gdk::Pixbuf> >(
|
|
|
|
treerow[ treeview_operations_columns .status_icon ] ) .clear() ;
|
2006-02-07 08:17:44 -07:00
|
|
|
break ;
|
2006-01-19 12:15:15 -07:00
|
|
|
}
|
2006-02-07 08:17:44 -07:00
|
|
|
|
2006-08-20 03:33:54 -06:00
|
|
|
//update the gui elements..
|
|
|
|
this ->operationdetail = operationdetail ;
|
2006-05-23 15:17:34 -06:00
|
|
|
|
2006-08-20 03:33:54 -06:00
|
|
|
if ( operationdetail .get_status() == STATUS_EXECUTE )
|
|
|
|
label_current_sub_text = operationdetail .get_description() ;
|
|
|
|
|
2013-01-14 19:20:49 -07:00
|
|
|
if ( operationdetail.fraction >= 0 ) {
|
|
|
|
pulsetimer.disconnect();
|
|
|
|
progressbar_current.set_fraction( operationdetail.fraction > 1.0 ? 1.0 : operationdetail.fraction );
|
|
|
|
} else if( !pulsetimer.connected() )
|
|
|
|
pulsetimer = Glib::signal_timeout().connect( sigc::mem_fun(*this, &Dialog_Progress::pulsebar_pulse), 100 );
|
2013-02-21 17:57:33 -07:00
|
|
|
update_gui_elements();
|
2006-08-20 03:33:54 -06:00
|
|
|
}
|
|
|
|
else//it's an new od which needs to be added to the model.
|
2006-05-23 15:17:34 -06:00
|
|
|
{
|
2006-08-20 03:33:54 -06:00
|
|
|
unsigned int pos = operationdetail .get_treepath() .rfind( ":" ) ;
|
2011-07-16 09:55:31 -06:00
|
|
|
if ( pos < operationdetail .get_treepath() .length() )
|
2006-08-22 13:29:59 -06:00
|
|
|
iter = treestore_operations ->get_iter( operationdetail .get_treepath()
|
|
|
|
.substr( 0, operationdetail .get_treepath() .rfind( ":" ) ) ) ;
|
2006-08-20 03:33:54 -06:00
|
|
|
else
|
2006-08-22 13:29:59 -06:00
|
|
|
iter = treestore_operations ->get_iter( operationdetail .get_treepath() ) ;
|
2006-08-20 03:33:54 -06:00
|
|
|
|
|
|
|
if ( iter)
|
|
|
|
{
|
|
|
|
treestore_operations ->append( static_cast<Gtk::TreeRow>( *iter) .children() ) ;
|
|
|
|
on_signal_update( operationdetail ) ;
|
|
|
|
}
|
2006-05-23 15:17:34 -06:00
|
|
|
}
|
2006-08-20 03:33:54 -06:00
|
|
|
}
|
2006-05-23 15:17:34 -06:00
|
|
|
|
2013-02-21 17:57:33 -07:00
|
|
|
void Dialog_Progress::update_gui_elements()
|
2006-08-20 03:33:54 -06:00
|
|
|
{
|
|
|
|
label_current_sub .set_markup( "<i>" + label_current_sub_text + "</i>\n" ) ;
|
|
|
|
|
2010-04-25 11:09:18 -06:00
|
|
|
//To ensure progress bar height remains the same, add a space in case message is empty
|
|
|
|
progressbar_current .set_text( operationdetail .progress_text + " " ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2013-01-14 19:20:49 -07:00
|
|
|
bool Dialog_Progress::pulsebar_pulse()
|
|
|
|
{
|
|
|
|
progressbar_current.pulse();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
void Dialog_Progress::on_signal_show()
|
2004-10-16 09:42:08 -06:00
|
|
|
{
|
2006-01-25 16:30:43 -07:00
|
|
|
for ( t = 0 ; t < operations .size() && succes && ! cancel ; t++ )
|
2004-11-17 06:00:25 -07:00
|
|
|
{
|
2006-08-20 03:33:54 -06:00
|
|
|
operations[ t ] ->operation_detail .signal_update .connect(
|
|
|
|
sigc::mem_fun( this, &Dialog_Progress::on_signal_update ) ) ;
|
|
|
|
|
2006-05-23 15:17:34 -06:00
|
|
|
label_current .set_markup( "<b>" + operations[ t ] ->description + "</b>" ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
|
|
|
|
progressbar_all .set_text( String::ucompose( _("%1 of %2 operations completed"), t, operations .size() ) ) ;
|
2006-09-10 06:17:33 -06:00
|
|
|
progressbar_all .set_fraction( fraction * t > 1.0 ? 1.0 : fraction * t ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
|
2006-02-07 08:17:44 -07:00
|
|
|
treerow = treestore_operations ->children()[ t ] ;
|
|
|
|
|
|
|
|
//set status to 'execute'
|
2006-08-20 03:33:54 -06:00
|
|
|
operations[ t ] ->operation_detail .set_status( STATUS_EXECUTE ) ;
|
2006-02-07 08:17:44 -07:00
|
|
|
|
|
|
|
//set focus...
|
|
|
|
treeview_operations .set_cursor( static_cast<Gtk::TreePath>( treerow ) ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
|
2013-02-21 17:57:33 -07:00
|
|
|
succes = signal_apply_operation.emit( operations[t] );
|
2012-01-24 18:15:20 -07:00
|
|
|
|
2006-02-07 08:17:44 -07:00
|
|
|
//set status (succes/error) for this operation
|
2006-08-20 03:33:54 -06:00
|
|
|
operations[ t ] ->operation_detail .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
|
2004-11-17 06:00:25 -07:00
|
|
|
}
|
2006-01-25 16:30:43 -07:00
|
|
|
|
2006-02-07 08:17:44 -07:00
|
|
|
//add save button
|
|
|
|
this ->add_button( _("_Save Details"), Gtk::RESPONSE_OK ) ; //there's no enum for SAVE
|
|
|
|
|
2006-01-19 12:15:15 -07:00
|
|
|
//replace 'cancel' with 'close'
|
2013-01-20 19:50:55 -07:00
|
|
|
canceltimer.disconnect();
|
2012-01-24 18:15:20 -07:00
|
|
|
delete cancelbutton;
|
|
|
|
cancelbutton = 0;
|
2006-02-07 08:17:44 -07:00
|
|
|
this ->add_button( Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE );
|
2006-01-19 12:15:15 -07:00
|
|
|
|
2013-01-14 19:20:49 -07:00
|
|
|
pulsetimer.disconnect();
|
|
|
|
|
2006-01-25 16:30:43 -07:00
|
|
|
if ( cancel )
|
|
|
|
{
|
2008-06-10 13:16:26 -06:00
|
|
|
progressbar_current .set_text( _("Operation cancelled") ) ;
|
2006-01-25 16:30:43 -07:00
|
|
|
progressbar_current .set_fraction( 0.0 ) ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//hide 'current operation' stuff
|
|
|
|
label_current .hide() ;
|
2006-05-23 15:17:34 -06:00
|
|
|
progressbar_current .hide() ;
|
|
|
|
label_current_sub .hide() ;
|
2006-01-25 16:30:43 -07:00
|
|
|
}
|
2006-01-19 12:15:15 -07:00
|
|
|
|
|
|
|
//deal with succes/error...
|
|
|
|
if ( succes )
|
|
|
|
{
|
2011-06-26 06:03:37 -06:00
|
|
|
Glib::ustring str_temp(_("All operations successfully completed"));
|
2006-09-09 04:58:48 -06:00
|
|
|
|
|
|
|
if ( warnings > 0 )
|
2008-06-10 13:16:26 -06:00
|
|
|
str_temp += " ("
|
|
|
|
+ String::ucompose( ngettext("%1 warning", "%1 warnings", warnings), warnings )
|
|
|
|
+ ")" ;
|
2006-09-09 04:58:48 -06:00
|
|
|
|
|
|
|
progressbar_all .set_text( str_temp ) ;
|
2006-01-19 12:15:15 -07:00
|
|
|
progressbar_all .set_fraction( 1.0 ) ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
expander_details .set_expanded( true ) ;
|
|
|
|
|
2006-01-25 16:30:43 -07:00
|
|
|
if ( ! cancel )
|
|
|
|
{
|
|
|
|
Gtk::MessageDialog dialog( *this,
|
|
|
|
_("An error occurred while applying the operations"),
|
|
|
|
false,
|
|
|
|
Gtk::MESSAGE_ERROR,
|
|
|
|
Gtk::BUTTONS_OK,
|
|
|
|
true ) ;
|
2011-06-26 06:03:37 -06:00
|
|
|
Glib::ustring str_temp(_("See the details for more information."));
|
|
|
|
|
2006-09-09 04:58:48 -06:00
|
|
|
str_temp += "\n\n<i><b>" + Glib::ustring( _("IMPORTANT") ) + "</b>\n" ;
|
|
|
|
str_temp += _("If you want support, you need to provide the saved details!") ;
|
2010-10-12 18:14:30 -06:00
|
|
|
str_temp += "\n" + String::ucompose(
|
2010-10-20 17:32:56 -06:00
|
|
|
/* TO TRANSLATORS: looks like See http://gparted.org/save-details.htm for more information. */
|
|
|
|
_("See %1 for more information."), "http://gparted.org/save-details.htm" ) + "</i>" ;
|
2004-11-17 06:00:25 -07:00
|
|
|
|
2006-01-25 16:30:43 -07:00
|
|
|
dialog .set_secondary_text( str_temp, true ) ;
|
|
|
|
dialog .run() ;
|
|
|
|
}
|
2006-01-26 08:54:44 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-28 08:09:50 -07:00
|
|
|
void Dialog_Progress::on_cell_data_description( Gtk::CellRenderer * renderer, const Gtk::TreeModel::iterator & iter )
|
2006-07-29 02:27:28 -06:00
|
|
|
{
|
2006-01-28 08:09:50 -07:00
|
|
|
dynamic_cast<Gtk::CellRendererText *>( renderer ) ->property_markup() =
|
2006-04-02 15:26:27 -06:00
|
|
|
static_cast<Gtk::TreeRow>( *iter )[ treeview_operations_columns .operation_description ] ;
|
2006-01-28 08:09:50 -07:00
|
|
|
}
|
|
|
|
|
2013-01-20 19:50:55 -07:00
|
|
|
bool Dialog_Progress::cancel_timeout()
|
|
|
|
{
|
|
|
|
if (--cancel_countdown)
|
|
|
|
cancelbutton->set_label( Glib::ustring::compose("Force Cancel (%1)", cancel_countdown ) );
|
|
|
|
else {
|
|
|
|
cancelbutton->set_label( "Force Cancel" );
|
|
|
|
canceltimer.disconnect();
|
|
|
|
cancelbutton->set_sensitive();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-01-26 15:49:37 -07:00
|
|
|
void Dialog_Progress::on_cancel()
|
2006-01-24 05:31:58 -07:00
|
|
|
{
|
2006-01-26 15:49:37 -07:00
|
|
|
Gtk::MessageDialog dialog( *this,
|
|
|
|
_("Are you sure you want to cancel the current operation?"),
|
|
|
|
false,
|
|
|
|
Gtk::MESSAGE_QUESTION,
|
|
|
|
Gtk::BUTTONS_NONE,
|
|
|
|
true ) ;
|
2006-01-25 16:30:43 -07:00
|
|
|
|
2008-11-04 15:16:06 -07:00
|
|
|
dialog .set_secondary_text( _("Canceling an operation might cause SEVERE file system damage.") ) ;
|
2006-01-24 05:31:58 -07:00
|
|
|
|
2006-01-26 15:49:37 -07:00
|
|
|
dialog .add_button( _("Continue Operation"), Gtk::RESPONSE_NONE ) ;
|
|
|
|
dialog .add_button( _("Cancel Operation"), Gtk::RESPONSE_CANCEL ) ;
|
2006-01-25 16:30:43 -07:00
|
|
|
|
2013-01-20 19:50:55 -07:00
|
|
|
if ( !cancel || dialog .run() == Gtk::RESPONSE_CANCEL )
|
2006-01-26 15:49:37 -07:00
|
|
|
{
|
2012-01-24 18:15:20 -07:00
|
|
|
cancelbutton->set_sensitive( false );
|
2013-01-20 19:50:55 -07:00
|
|
|
if (!cancel) {
|
|
|
|
cancel_countdown = 5;
|
|
|
|
cancelbutton->set_label( Glib::ustring::compose("Force Cancel (%1)", cancel_countdown ) );
|
|
|
|
canceltimer = Glib::signal_timeout().connect(
|
|
|
|
sigc::mem_fun(*this, &Dialog_Progress::cancel_timeout), 1000 );
|
|
|
|
}
|
|
|
|
else cancelbutton->set_label( "Force Cancel" );
|
|
|
|
operations[t]->operation_detail.signal_cancel( cancel );
|
|
|
|
cancel = true;
|
2006-01-25 16:30:43 -07:00
|
|
|
}
|
2006-01-24 05:31:58 -07:00
|
|
|
}
|
|
|
|
|
2006-02-07 08:17:44 -07:00
|
|
|
void Dialog_Progress::on_save()
|
|
|
|
{
|
|
|
|
Gtk::FileChooserDialog dialog( _("Save Details"), Gtk::FILE_CHOOSER_ACTION_SAVE ) ;
|
|
|
|
dialog .set_transient_for( *this ) ;
|
|
|
|
dialog .set_current_folder( Glib::get_home_dir() ) ;
|
|
|
|
dialog .set_current_name( "gparted_details.htm" ) ;
|
2006-08-20 12:13:40 -06:00
|
|
|
dialog .set_do_overwrite_confirmation( true ) ;
|
2006-02-07 08:17:44 -07:00
|
|
|
dialog .add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL ) ;
|
|
|
|
dialog .add_button( Gtk::Stock::SAVE, Gtk::RESPONSE_OK ) ; //there's no enum for SAVE
|
|
|
|
|
|
|
|
if ( dialog .run() == Gtk::RESPONSE_OK )
|
|
|
|
{
|
|
|
|
std::ofstream out( dialog .get_filename() .c_str() ) ;
|
|
|
|
if ( out )
|
|
|
|
{
|
2008-09-24 17:42:04 -06:00
|
|
|
//Write out proper HTML start
|
2008-10-14 15:57:56 -06:00
|
|
|
out << "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>" << std::endl
|
2008-10-16 13:59:30 -06:00
|
|
|
<< "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='" << Utils::get_lang() << "'"
|
|
|
|
<< " lang='" << Utils::get_lang() << "'>" << std::endl
|
2008-10-14 15:57:56 -06:00
|
|
|
<< "<head>" << std::endl
|
|
|
|
<< "<meta http-equiv='Content-Type' content='text/html;charset=utf-8' />" << std::endl
|
2008-10-17 13:33:26 -06:00
|
|
|
<< "<title>" << _("GParted Details") << "</title>" << std::endl
|
2008-10-14 15:57:56 -06:00
|
|
|
<< "</head>" << std::endl
|
|
|
|
<< "<body>" << std::endl
|
2011-02-22 13:22:49 -07:00
|
|
|
<< "<p>" << _("GParted") << " " << VERSION
|
|
|
|
#ifdef USE_LIBPARTED_DMRAID
|
|
|
|
<< " --enable-libparted-dmraid"
|
|
|
|
#endif
|
|
|
|
<< "</p>" << std::endl
|
2008-10-17 13:33:26 -06:00
|
|
|
<< "<p>" << _("Libparted") << " " << signal_get_libparted_version .emit() << "</p>" << std::endl ;
|
2008-10-14 15:57:56 -06:00
|
|
|
|
|
|
|
//Write out each operation
|
2006-02-07 08:17:44 -07:00
|
|
|
for ( unsigned int t = 0 ; t < operations .size() ; t++ )
|
|
|
|
{
|
2006-07-29 02:27:28 -06:00
|
|
|
echo_operation_details( operations[ t ] ->operation_detail, out ) ;
|
2008-10-14 15:57:56 -06:00
|
|
|
out << "<p>========================================</p>" << std::endl ;
|
2006-02-07 08:17:44 -07:00
|
|
|
}
|
2008-09-24 17:42:04 -06:00
|
|
|
|
|
|
|
//Write out proper HTML finish
|
2008-10-14 15:57:56 -06:00
|
|
|
out << "</body>" << std::endl << "</html>" ;
|
2006-02-07 08:17:44 -07:00
|
|
|
out .close() ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-20 03:33:54 -06:00
|
|
|
void Dialog_Progress::echo_operation_details( const OperationDetail & operationdetail, std::ofstream & out )
|
2006-02-07 08:17:44 -07:00
|
|
|
{
|
|
|
|
//replace '\n' with '<br>'
|
2006-08-20 03:33:54 -06:00
|
|
|
Glib::ustring temp = operationdetail .get_description() ;
|
2006-02-07 08:17:44 -07:00
|
|
|
for ( unsigned int index = temp .find( "\n" ) ; index < temp .length() ; index = temp .find( "\n" ) )
|
2008-10-14 15:57:56 -06:00
|
|
|
temp .replace( index, 1, "<br />" ) ;
|
2006-02-07 08:17:44 -07:00
|
|
|
|
|
|
|
//and export everything to some kind of html...
|
2008-10-14 15:57:56 -06:00
|
|
|
out << "<table border='0'>" << std::endl
|
|
|
|
<< "<tr>" << std::endl
|
|
|
|
<< "<td colspan='2'>" << std::endl
|
|
|
|
<< temp ;
|
2006-08-22 13:29:59 -06:00
|
|
|
if ( ! operationdetail .get_elapsed_time() .empty() )
|
|
|
|
out << " " << operationdetail .get_elapsed_time() ;
|
2006-02-07 08:17:44 -07:00
|
|
|
|
|
|
|
//show status...
|
2006-08-20 03:33:54 -06:00
|
|
|
if ( operationdetail .get_status() != STATUS_NONE )
|
2006-02-07 08:17:44 -07:00
|
|
|
{
|
|
|
|
out << " " ;
|
2006-08-20 03:33:54 -06:00
|
|
|
switch ( operationdetail .get_status() )
|
2006-02-07 08:17:44 -07:00
|
|
|
{
|
2006-07-29 02:27:28 -06:00
|
|
|
case STATUS_EXECUTE:
|
2010-10-12 18:14:30 -06:00
|
|
|
out << "( " <<
|
|
|
|
/* TO TRANSLATORS: EXECUTING
|
|
|
|
* means that the status for this operation is
|
|
|
|
* executing or currently in progress.
|
|
|
|
*/
|
|
|
|
_("EXECUTING") << " )" ;
|
2006-02-07 08:17:44 -07:00
|
|
|
break ;
|
2006-07-29 02:27:28 -06:00
|
|
|
case STATUS_SUCCES:
|
2010-10-12 18:14:30 -06:00
|
|
|
out << "( " <<
|
|
|
|
/* TO" TRANSLATORS: SUCCESS
|
|
|
|
* means that the status for this operation is
|
|
|
|
* completed successfully.
|
|
|
|
*/
|
|
|
|
_("SUCCESS") << " )" ;
|
2006-02-07 08:17:44 -07:00
|
|
|
break ;
|
2006-07-29 02:27:28 -06:00
|
|
|
case STATUS_ERROR:
|
2010-10-12 18:14:30 -06:00
|
|
|
out << "( "
|
|
|
|
/* TO TRANSLATORS: ERROR
|
|
|
|
* means that the status for this operation is
|
|
|
|
* completed with errors.
|
|
|
|
*/
|
|
|
|
<< _("ERROR") << " )" ;
|
2006-02-07 08:17:44 -07:00
|
|
|
break ;
|
2006-08-20 03:33:54 -06:00
|
|
|
case STATUS_INFO:
|
2010-10-12 18:14:30 -06:00
|
|
|
out << "( " <<
|
|
|
|
/* TO TRANSLATORS: INFO
|
|
|
|
* means that the status for this operation is
|
|
|
|
* for your information , or messages from the
|
|
|
|
* libparted library.
|
|
|
|
*/
|
|
|
|
_("INFO") << " )" ;
|
2006-08-20 03:33:54 -06:00
|
|
|
break ;
|
|
|
|
case STATUS_N_A:
|
2010-10-12 18:14:30 -06:00
|
|
|
out << "( " <<
|
|
|
|
/* TO TRANSLATORS: N/A
|
|
|
|
* means that the status for this operation is
|
|
|
|
* not applicable because the operation is not
|
|
|
|
* supported on the file system in the partition.
|
|
|
|
*/
|
|
|
|
_("N/A") << " )" ;
|
2006-08-20 03:33:54 -06:00
|
|
|
break ;
|
2006-02-07 08:17:44 -07:00
|
|
|
|
|
|
|
default:
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-14 15:57:56 -06:00
|
|
|
out << std::endl << "</td>" << std::endl << "</tr>" << std::endl ;
|
2006-02-07 08:17:44 -07:00
|
|
|
|
2006-08-20 03:33:54 -06:00
|
|
|
if ( operationdetail .get_childs(). size() )
|
2006-02-07 08:17:44 -07:00
|
|
|
{
|
2008-10-14 15:57:56 -06:00
|
|
|
out << "<tr>" << std::endl
|
|
|
|
<< "<td> </td>" << std::endl
|
|
|
|
<< "<td>" << std::endl ;
|
2006-02-07 08:17:44 -07:00
|
|
|
|
2006-08-20 03:33:54 -06:00
|
|
|
for ( unsigned int t = 0 ; t < operationdetail .get_childs() .size() ; t++ )
|
|
|
|
echo_operation_details( operationdetail .get_childs()[ t ], out ) ;
|
2006-02-07 08:17:44 -07:00
|
|
|
|
2008-10-14 15:57:56 -06:00
|
|
|
out << "</td>" << std::endl << "</tr>" << std::endl ;
|
2006-02-07 08:17:44 -07:00
|
|
|
}
|
2008-10-14 15:57:56 -06:00
|
|
|
out << "</table>" << std::endl ;
|
|
|
|
|
2006-02-07 08:17:44 -07:00
|
|
|
}
|
|
|
|
|
2006-01-26 15:49:37 -07:00
|
|
|
void Dialog_Progress::on_response( int response_id )
|
|
|
|
{
|
2006-02-07 08:17:44 -07:00
|
|
|
switch ( response_id )
|
|
|
|
{
|
|
|
|
case Gtk::RESPONSE_OK:
|
|
|
|
on_save() ;
|
|
|
|
break ;
|
|
|
|
case Gtk::RESPONSE_CANCEL:
|
|
|
|
on_cancel() ;
|
|
|
|
break ;
|
|
|
|
}
|
2006-01-26 15:49:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Dialog_Progress::on_delete_event( GdkEventAny * event )
|
|
|
|
{
|
|
|
|
//it seems this get only called at runtime
|
|
|
|
on_cancel() ;
|
|
|
|
return true ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-16 09:42:08 -06:00
|
|
|
Dialog_Progress::~Dialog_Progress()
|
|
|
|
{
|
2012-01-24 18:15:20 -07:00
|
|
|
delete cancelbutton;
|
2004-10-16 09:42:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-06 13:06:43 -06:00
|
|
|
}//GParted
|