2014-12-12 00:00:02 -07:00
|
|
|
/* Copyright (C) 2015 Michael Zimmermann
|
|
|
|
*
|
|
|
|
* 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../include/OperationNamePartition.h"
|
2015-05-23 13:22:37 -06:00
|
|
|
#include "../include/Partition.h"
|
|
|
|
#include "../include/PartitionVector.h"
|
2014-12-12 00:00:02 -07:00
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
|
|
|
OperationNamePartition::OperationNamePartition( const Device & device,
|
|
|
|
const Partition & partition_orig,
|
|
|
|
const Partition & partition_new )
|
|
|
|
{
|
|
|
|
type = OPERATION_NAME_PARTITION;
|
|
|
|
|
2015-05-24 07:13:37 -06:00
|
|
|
this->device = device.get_copy_without_partitions();
|
2015-09-20 03:50:57 -06:00
|
|
|
this->partition_original = new Partition( partition_orig );
|
|
|
|
this->partition_new = new Partition( partition_new );
|
|
|
|
}
|
|
|
|
|
|
|
|
OperationNamePartition::~OperationNamePartition()
|
|
|
|
{
|
|
|
|
delete partition_original;
|
|
|
|
delete partition_new;
|
|
|
|
partition_original = NULL;
|
|
|
|
partition_new = NULL;
|
2014-12-12 00:00:02 -07:00
|
|
|
}
|
|
|
|
|
2015-05-23 13:22:37 -06:00
|
|
|
void OperationNamePartition::apply_to_visual( PartitionVector & partitions )
|
2014-12-12 00:00:02 -07:00
|
|
|
{
|
2015-09-26 07:25:58 -06:00
|
|
|
substitute_new( partitions );
|
2014-12-12 00:00:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void OperationNamePartition::create_description()
|
|
|
|
{
|
2015-09-20 03:50:57 -06:00
|
|
|
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later
|
|
|
|
|
|
|
|
if( partition_new->name.empty() )
|
2014-12-12 00:00:02 -07:00
|
|
|
{
|
|
|
|
/* TO TRANSLATORS: looks like Clear partition name on /dev/hda3 */
|
|
|
|
description = String::ucompose( _("Clear partition name on %1"),
|
2015-09-20 03:50:57 -06:00
|
|
|
partition_new->get_path() );
|
2014-12-12 00:00:02 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* TO TRANSLATORS: looks like Set partition name "My Name" on /dev/hda3 */
|
|
|
|
description = String::ucompose( _("Set partition name \"%1\" on %2"),
|
2015-09-20 03:50:57 -06:00
|
|
|
partition_new->name,
|
|
|
|
partition_new->get_path() );
|
2014-12-12 00:00:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-12 07:59:40 -06:00
|
|
|
bool OperationNamePartition::merge_operations( const Operation & candidate )
|
|
|
|
{
|
2015-09-20 03:50:57 -06:00
|
|
|
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later
|
|
|
|
|
2015-09-19 08:57:39 -06:00
|
|
|
if ( candidate.type == OPERATION_NAME_PARTITION &&
|
2015-09-20 03:50:57 -06:00
|
|
|
*partition_new == candidate.get_partition_original() )
|
2015-09-12 07:59:40 -06:00
|
|
|
{
|
2015-09-20 03:50:57 -06:00
|
|
|
partition_new->name = candidate.get_partition_new().name;
|
2015-09-12 07:59:40 -06:00
|
|
|
create_description();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-12-12 00:00:02 -07:00
|
|
|
} //GParted
|