2006-09-17 07:23:47 -06:00
|
|
|
/* Copyright (C) 2004-2006 Bart 'plors' Hakvoort
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2014-01-23 03:59:48 -07:00
|
|
|
* GNU General Public License for more details.
|
2006-09-17 07:23:47 -06:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 03:59:48 -07:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2006-09-17 07:23:47 -06:00
|
|
|
*/
|
2016-10-18 16:45:28 -06:00
|
|
|
|
|
|
|
#include "HBoxOperations.h"
|
2018-07-31 07:36:11 -06:00
|
|
|
#include "MenuHelpers.h"
|
2019-03-27 07:07:39 -06:00
|
|
|
#include "Utils.h"
|
2016-10-18 16:45:28 -06:00
|
|
|
|
2006-09-17 07:23:47 -06:00
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
|
|
|
HBoxOperations::HBoxOperations()
|
|
|
|
{
|
|
|
|
//create listview for pending operations
|
|
|
|
liststore_operations = Gtk::ListStore::create( treeview_operations_columns );
|
|
|
|
treeview_operations .set_model( liststore_operations );
|
|
|
|
treeview_operations .set_headers_visible( false );
|
|
|
|
treeview_operations .append_column( "", treeview_operations_columns .operation_icon );
|
|
|
|
treeview_operations .append_column( "", treeview_operations_columns .operation_description );
|
|
|
|
treeview_operations .get_selection() ->set_mode( Gtk::SELECTION_NONE ) ;
|
|
|
|
treeview_operations .signal_button_press_event() .connect(
|
|
|
|
sigc::mem_fun( *this, &HBoxOperations::on_signal_button_press_event ), false ) ;
|
|
|
|
|
|
|
|
//init scrollwindow_operations
|
|
|
|
scrollwindow .set_shadow_type( Gtk::SHADOW_ETCHED_IN );
|
|
|
|
scrollwindow .set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
|
|
|
|
scrollwindow .add ( treeview_operations ) ;
|
|
|
|
pack_start( scrollwindow, Gtk::PACK_EXPAND_WIDGET );
|
|
|
|
|
|
|
|
//create popupmenu
|
2018-08-02 01:24:41 -06:00
|
|
|
Gtk::MenuItem *item;
|
|
|
|
item = manage(new GParted::Menu_Helpers::ImageMenuElem(
|
2006-09-17 07:23:47 -06:00
|
|
|
_("_Undo Last Operation"),
|
2019-03-27 07:07:39 -06:00
|
|
|
*Utils::mk_image(Gtk::Stock::UNDO, Gtk::ICON_SIZE_MENU),
|
2018-08-02 01:24:41 -06:00
|
|
|
sigc::mem_fun(*this, &HBoxOperations::on_undo)));
|
|
|
|
menu_popup.append(*item);
|
|
|
|
menu_popup_items[0] = item;
|
2006-09-17 07:23:47 -06:00
|
|
|
|
2018-08-02 01:24:41 -06:00
|
|
|
item = manage(new GParted::Menu_Helpers::ImageMenuElem(
|
2006-09-17 07:23:47 -06:00
|
|
|
_("_Clear All Operations"),
|
2019-03-27 07:07:39 -06:00
|
|
|
*Utils::mk_image(Gtk::Stock::CLEAR, Gtk::ICON_SIZE_MENU),
|
2018-08-02 01:24:41 -06:00
|
|
|
sigc::mem_fun(*this, &HBoxOperations::on_clear)));
|
|
|
|
menu_popup.append(*item);
|
|
|
|
menu_popup_items[1] = item;
|
2006-09-17 07:23:47 -06:00
|
|
|
|
2018-08-02 01:24:41 -06:00
|
|
|
item = manage(new GParted::Menu_Helpers::ImageMenuElem(
|
2006-09-17 07:23:47 -06:00
|
|
|
_("_Apply All Operations"),
|
2019-03-27 07:07:39 -06:00
|
|
|
*Utils::mk_image(Gtk::Stock::APPLY, Gtk::ICON_SIZE_MENU),
|
2018-08-02 01:24:41 -06:00
|
|
|
sigc::mem_fun(*this, &HBoxOperations::on_apply)));
|
|
|
|
menu_popup.append(*item);
|
|
|
|
menu_popup_items[2] = item;
|
2006-09-17 07:23:47 -06:00
|
|
|
|
2018-07-31 07:36:11 -06:00
|
|
|
menu_popup.append(*manage(new GParted::Menu_Helpers::SeparatorElem()));
|
|
|
|
menu_popup.append(*manage(new GParted::Menu_Helpers::StockMenuElem(
|
|
|
|
Gtk::Stock::CLOSE, sigc::mem_fun(*this, &HBoxOperations::on_close))));
|
2006-09-17 07:23:47 -06:00
|
|
|
}
|
|
|
|
|
2019-03-28 10:26:00 -06:00
|
|
|
|
|
|
|
void HBoxOperations::load_operations(const std::vector<Operation *>& operations)
|
2006-09-17 07:23:47 -06:00
|
|
|
{
|
|
|
|
liststore_operations ->clear();
|
|
|
|
|
|
|
|
Gtk::TreeRow treerow ;
|
|
|
|
for ( unsigned int t = 0 ; t < operations .size(); t++ )
|
|
|
|
{
|
|
|
|
treerow = *( liststore_operations ->append() );
|
|
|
|
treerow[ treeview_operations_columns .operation_description ] = operations[ t ] ->description ;
|
|
|
|
treerow[ treeview_operations_columns .operation_icon ] = operations[ t ] ->icon ;
|
|
|
|
}
|
|
|
|
|
|
|
|
//make scrollwindow focus on the last operation in the list
|
|
|
|
if ( liststore_operations ->children() .size() > 0 )
|
|
|
|
treeview_operations .set_cursor( static_cast<Gtk::TreePath>( static_cast<Gtk::TreeRow>(
|
|
|
|
*(--liststore_operations ->children() .end()) ) ) ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HBoxOperations::clear()
|
|
|
|
{
|
|
|
|
liststore_operations ->clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HBoxOperations::on_signal_button_press_event( GdkEventButton * event )
|
|
|
|
{
|
|
|
|
//right-click
|
|
|
|
if ( event ->button == 3 )
|
|
|
|
{
|
2018-08-02 01:24:41 -06:00
|
|
|
menu_popup_items[0]->set_sensitive(liststore_operations->children().size() > 0);
|
|
|
|
menu_popup_items[1]->set_sensitive(liststore_operations->children().size() > 0);
|
|
|
|
menu_popup_items[2]->set_sensitive(liststore_operations->children().size() > 0);
|
2006-09-17 07:23:47 -06:00
|
|
|
|
|
|
|
menu_popup .popup( event ->button, event ->time ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HBoxOperations::on_undo()
|
|
|
|
{
|
|
|
|
signal_undo .emit() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HBoxOperations::on_clear()
|
|
|
|
{
|
|
|
|
signal_clear .emit() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HBoxOperations::on_apply()
|
|
|
|
{
|
|
|
|
signal_apply .emit() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HBoxOperations::on_close()
|
|
|
|
{
|
|
|
|
signal_close .emit() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
HBoxOperations::~HBoxOperations()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
} //GParted
|
|
|
|
|
|
|
|
|