Commit Graph

25 Commits

Author SHA1 Message Date
Mike Fleetwood 24fa553385 Remove unnecessary sector_size parameter from Get_New_Partition methods
The sector_size parameter is unnecessary as the value can be retrieved
from the sector size of the selected Partition object on which the
create new, copy & paste or resize/move operation is being performed.

For the create new and resize/move operations it is trivial as the
existing unallocated or in use Partition object on which the operation
is being perform already contains the correct sector size.  For the copy
& paste operation, which can copy across disk devices of different
sector sizes, we merely have to use the sector size of the existing
selected (destination) Partition object rather than copied (source)
Partition object.  Hence these relevant lines in the new code:

    Dialog_Partition_Copy::set_data(selected_partition, copied_partition)
        new_partition = copied_partition.clone();
        ...
        new_partition->sector_size = selected_partition.sector_size;
2016-01-26 10:11:35 -07:00
Mike Fleetwood 4a6cbcd0f1 Use pointer to Partition in Dialog_Base_Partition and derived classes (#759726)
Now use a pointer to the Partition object in Dialog_Base_Partition class
and derived classes, Dialog_Partition_{Copy,New,Resize_Move}.  This is
equivalent to how the Partition objects are managed in the Operation and
derived classes.

The Partition object is allocated and copy constructed in each derived
classes' set_data() method, called from each constructor and deallocated
in the destructors.  Considering the remaining Big 3, these classes are
never copy constructed or copy assigned so provide private definitions
and no implementations so the compiler enforces this.

Bug 759726 - Implement Partition object polymorphism
2016-01-26 10:11:35 -07:00
Mike Fleetwood 48d898ebfd Include Partition.h header everywhere it's used
Lots of files which use the Partition class relied on the declaration
being included via other header files.  This is bad practice.

Add #include "Partition.h" into every file which uses the Partition
class which doesn't already include it.  Header file #include guards are
specifically to allow this.
2016-01-26 10:11:35 -07:00
Mike Fleetwood 2c4df87a2c Return reference from Get_New_Partition() (#757671)
Return newly constructed partition object by reference rather than by
copy from the Copy, Resize/Move and New dialog classes.  This is another
case of stopping copying partition objects in preparation for using
polymorphic Partition objects.  In C++ polymorphism has to use pass by
pointer and reference and not pass by value, copying, to avoid object
slicing.

The returned reference to the partition is only valid until the dialog
object containing the new_partition member is destroyed.  This is okay
because in all three cases the returned referenced partition is copied
into a context with new lifetime expectations before the dialog object
is destroyed.

Case 1: GParted_Core::activate_paste()
    Referenced new_partition is copied in the OperationCopy constructor
    before the dialog object goes out of scope.

    Operation * operation = new OperationCopy( ...,
                                               dialog.Get_New_Partition( ... ),
                                               ... );

Case 2: GParted_Core::activate_new()
    Referenced new_partition is copied in the OperationCreate
    constructor before the dialog object goes out of scope.

    Operation * operation = new OperationCreate( ...,
                                                 dialog.Get_New_Partition( ... ) );

Case 3: GParted_Core::activate_resize()
    Temporary partition object is copied from the referenced
    new_partition before the dialog object goes out of scope.

    Partition part_temp = dialog.Get_New_Partition( ... );

Bug 757671 - Rework Dialog_Partition_New::Get_New_Partition() a bit
2015-11-11 10:12:18 -07:00
Mike Fleetwood 451c2eac43 Rename parameter to selected_partition in Dialog_Partition_New methods (#757671)
This is just to make the parameter name in the Dialog_Partition_New
constructor and set_data() method match the name of the equivalent
parameter in the Dialog_Partition_Copy and Dialog_Partition_Resize_Move
classes.  (All three classes inherit from Dialog_Base_Partition and have
similar interfaces).

Bug 757671 - Rework Dialog_Partition_New::Get_New_Partition() a bit
2015-11-11 10:12:18 -07:00
Mike Fleetwood 7a4a375ed6 Remove Set_Data() from the copy, resize/move and new dialog class APIs
The copy, resize/move and new dialog classes (Dialog_Partition_Copy,
Dialog_Partition_Resize_Move and Dialog_Partition_New respectively) had
to be used like this:

    construct dialog object passing some parameters
    call Set_Data() to pass more parameters
    run() dialog
    call Get_New_Partition()

There is nothing in the classes which forces Set_Data() to be called,
but it must be called for the dialogs to work and prevent GParted from
crashing.

Make these class APIs safer by making it impossible to program
incorrectly in this regard.  Move all the additional parameters from
each Set_Data() method to each constructor.  The constructors just call
the now private set_data() methods.
2015-06-10 10:44:33 -06:00
Mike Fleetwood 5fd7c92671 Add partition name to Create New Partition dialog (#746214)
Add a partition name entry box to the Create New Partition dialog.  The
entry box is greyed out (not sensitive) for partition table types which
don't support partition naming.  Currently only supported for GPTs.  See
Utils::get_max_partition_name_length() for details.

There was a slightly wider gap between the file system combobox row and
the label entry row when there were only three widgets on the right hand
side of the dialog.  This has been removed now that there are four
widgets so that they are all evenly spaced and they line up with the
four widgets on the left hand side.

So far the partition name can be entered and previewed, but isn't yet
applied to the disk.

Bug 746214 - Partition naming enhancements
2015-03-25 10:02:43 -06:00
Mike Fleetwood 6a9a06af0e Pass Device object when setting up Dialog_Partition_New (#746214)
Adding a partition name entry to the Create New Partition dialog will
need access to these two Device methods: partition_naming_supported()
and get_max_partition_length().  The Set_Data() function already takes
two parameters, only_unformatted and disktype, taken from Device member
variables.

Rather than add two more parameters to the Set_Data() function pass the
Device object instead, replacing the current only_unformatted and
disktype parameters.

Bug 746214 - Partition name enhancements
2015-03-25 10:02:43 -06:00
Mike Fleetwood fc599270c2 Rename member object to filesystem_label_entry (#746214)
Rename Gtk::Entry object entry -> filesystem_label_entry in the
Dialog_Partition_New class.  This is in preparation for the introduction
of the partition name entry box in the Create New Partition dialog.

Bug 746214 - Partition name enhancements
2015-03-25 10:02:43 -06:00
Daniel Mustieles 3861b9257b Replace obsolete FSF postal address in copyright notices (#721565)
This is part of parent bug:
    Bug #721455 - Obsolete info in license text on multiple modules

and GNOME Goal:
    https://wiki.gnome.org/Initiatives/GnomeGoals/Proposals

    * verify all source files to make sure they have a license and a
      copyright, and that both are up-to-date

Bug #721565 -  License text contains obsolete FSF postal address
2014-01-26 10:53:23 +00:00
Mike Fleetwood 2b51d87147 Make include guards unique (#539297)
Include guards need to be unique within GParted code and all included
library header files.
    http://en.wikipedia.org/wiki/Include_guard#Difficulties

Use this model for all include guards:
    #ifndef GPARTED_FILE_NAME_H
    #define GPARTED_FILE_NAME_H
    ...
    #endif /* GPARTED_FILE_NAME_H */

Closes Bug #539297 - Make include guards unique
2013-06-05 10:57:39 -06:00
Curtis Gedak 55b71a77bc Fix unused parameter compiler warning
Removed unused parameter.  Prior to this change the compiler would
complain with the following message:

error: unused parameter ‘cylinder_size’
2011-07-18 13:31:54 -06:00
Markus Elfring 91b971691d Bug #634090: Change some attributes to local variables
Some classes contained private attributes which were used only by a single
member function. Such items were moved to the corresponding function implementations
to stress their limited usage scope.

A few unused variables were also deleted.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
2011-07-18 13:28:49 -06:00
Curtis Gedak 2cdfb4c55a Change partition alignment check box to a drop down menu
Also add signal handler to alignment menu to update file system
minimum size.
This enhancement is to prepare for adding a third alignment
option to align to MiB.
2010-05-09 14:45:26 -06:00
Curtis Gedak 74ecd2ed3f Set sector size and add to operation and dialog methods
This change is in preparation for supporting sectors sizes > 512 bytes.
2010-04-19 19:22:31 -06:00
Curtis Gedak 70584176de Disable extended option for non-MSDOS and non-DVH disk types (#583906)
According to parted documentation, only "msdos" and "dvh" disk
types (or partition table types) support extended partitions.
All other disk types support primary partitions only.
2010-02-24 11:39:42 -07:00
Curtis Gedak 8cfb27b718 Cleanup file copyright entries
Restore copyright entries by original author to those of his last
known repository commit titled "released gparted-0.3.4 on
LarryT's request." on Feb 25, 2007.

Add my own copyright entries for files in which I changed source
code.  Files in which I only made spelling changes do not have my
copyright entry added.
2009-11-05 11:08:49 -07:00
Curtis Gedak b10f2325d7 Migrated Round to cylinders checkbutton from dialog partition new to dialog base partition so that it can be used by all dialogs that inherit from dialog base partion (e.g., New, Copy, and Resize/Move)
svn path=/trunk/; revision=856
2008-06-15 17:18:26 +00:00
Curtis Gedak 8d808c0b62 gparted-0.3.6 - code recreation from Source Forge
svn path=/trunk/; revision=810
2008-04-07 19:41:18 +00:00
Bart Hakvoort 391ca32a2b in some places i still used MiB's instead of sectors to store sizes. this
* in some places i still used MiB's instead of sectors to store sizes.
  this has been fixed everywhere. Only the spinbuttons still use
  MiB's. I have a few ideas on how to solve this, but i'll take it up
  with #usability first.
2006-02-25 10:09:30 +00:00
Bart Hakvoort f9ab3cdd3c commented 'ss .imbue( std::locale( "" ) )' (#157871) cleanups allow forced
* src/Utils.cc: commented 'ss .imbue( std::locale( "" ) )' (#157871)
* src/Win_GParted.cc,
  src/TreeView_Detail.cc,
  src/Dialog_Base_Partition.cc: cleanups
* include/Dialog_Partition_New.h,
  include/Partition.h,
  src/Dialog_Partition_New.cc,
  src/GParted_Core.cc,
  src/Partition.cc: allow forced partitionsizes (aka: do not round to
  cylinder). (#169486)
2006-01-07 15:04:42 +00:00
Bart Hakvoort a42a0c2fee Fixed a bunch of issues with min. and max. sizes of filesystems.
* Fixed a bunch of issues with min. and max. sizes of filesystems.
2004-12-10 20:42:23 +00:00
Bart Hakvoort 286579d578 Every devicescan now tests on beforehand if the kernel is able to reread
* Every devicescan now tests on beforehand if the kernel is able to reread the partitiontable. If the kernel is unable to do
  this, i disallow most operations. This may seem weird and even a bad thing to do, but the fact is it protects
  the innocent user from a lot of potential damage. Till the linuxkernel is able to reread partitiontables no matter what, this seems
  to be the best option. Of course a dialog with information will popup whenever such a situation is encountered.
  In a next release i might consider adding an 'advanced mode' for users who know what they're doing.
2004-11-29 13:20:05 +00:00
Bart Hakvoort 18b47725f8 enabled support for reiserfs 2004-10-06 15:32:40 +00:00
Bart Hakvoort 26d433260d Initial revision 2004-09-19 20:24:53 +00:00