Commit Graph

3726 Commits

Author SHA1 Message Date
Antoine Viallon e550509781 Enhance F2FS support (!29)
- Adds reading of file system usage
- Adds resize (grow) support
- Adds verify support

Closes !29 - Enhance F2FS support
2019-03-26 08:08:10 +00:00
Mike Fleetwood 45fd146fd0 Go back to symbolic label widget alignment constants
Now that GParted requires Gtk3 there is no need to use floating point
numbers for compatibility with Gtk <= 2.22.  Replace with symbolic
alignment constants.

Relevant commit history:

*   6efa623401
    Add optional yalign argument to Utils::mk_label() method

*   be2689ad25
    Stop using deprecated widget alignment enumerators (#652044)
2019-03-23 11:13:30 -06:00
Mike Fleetwood 454ac64d19 Pass message parameters by reference to 2 Partition methods (#788813)
Note that this almost certainly has no performance benefit what so ever
because the methods are implicitly defined as inline [1][2] and the
compiler will have simply inlined the method bodies thus avoiding having
to construct copies of the passed parameters.

Do this anyway as constant objects are typically passed by reference
[3].  Also C++'s std::vector::push_back() [4] takes a const reference
parameter so update the kind of equivalent push_back_message() to take
a const reference parameter too.

[1] C++ reference / inline specifier
    https://en.cppreference.com/w/cpp/language/inline

        A function defined entirely inside a class/struct/union
        definition, whether it's a member function or a non-member
        friend function, is implicitly an inline function.

[2] When should I write the keyword 'inline' for a function/method?
    https://stackoverflow.com/questions/1759300/when-should-i-write-the-keyword-inline-for-a-function-method/1759575#1759575

[3] How to pass objects to functions in C++?
    https://stackoverflow.com/questions/2139224/how-to-pass-objects-to-functions-in-c/2139254#2139254

[4] C++ reference / std::vector::push
    https://en.cppreference.com/w/cpp/container/vector/push_back

        void push_back(const T& value);

Bug 788813 - gparted-0.30.0/include/Partition.h:137]: performance
             problem
2019-03-23 11:13:30 -06:00
Mike Fleetwood 0b5cfd3496 Stop checking for 'btrfs filesystem label' support (!26)
btrfs-progs 3.12 includes 'btrfs filesystem label /dev/PTN NEWLABEL'
functionality so stop checking for this before enabling setting the
label.

    $ btrfs version
    Btrfs v3.12
    $ btrfs filesystem label --help
    usage: btrfs filesystem label [<device>|<mount_point>] [<newlabel>]

        Get or change the label of a filesystem

        With one argument, get the label of filesystem on <device>.
        If <newlabel> is passed, set the filesystem label on <newlabel>.

    $ echo $?
    0

Worst case scenario is that some how an old version of the btrfs command
is used which doesn't support the labelling functionality.  Then this
commit would change GParted from disallowing labelling of a btrfs, to
allowing it, but presumably it would fail with an error from the btrfs
command reporting so.  Arguably better from a support point of view.

Closes !26 - Remove support for btrfs-progs < 3.12
2019-03-15 16:01:50 +00:00
Mike Fleetwood 05d9919afa Replace use of deprecated btrfsck (!26)
In btrfs-progs 3.12, btrfsck is a hard link to the multi-tool btrfs
executable.  When run as 'btrfsck' it just implements 'btrfs check'
[1][2][3][4].

In btrfs-progs 3.14.2 the btrfsck man page is re-added as a symlink to
the btrfs-check man page and reports that btrfsck is deprecated [5].

Therefore replace use of 'btrfsck' with 'btrfs check'.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git/commit/?id=fac45410e9a783c187ae83d993d3bf3350d05149
    Btrfs-progs: Rename btrfsck.c -> cmds-check.c

[2] https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git/commit/?id=5956f752c66d5259bbb17a2dd47ee8c8cc0e5f4f
    Btrfs-progs: add btrfsck functionality to btrfs

[3] https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git/commit/?id=d5d2046ae3b216af22a8a37c940f2412ba519b6e
    Btrfs-progs: add btrfsck name detection to btrfs

[4] https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git/commit/?id=e31f6172aa1d6ec5d562f56086819a0f4bc8a914
    btrfs-progs: build btrsfck to keep compatibility

[5] https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git/commit/?id=fddeecb7d424d5bb1a93a19a5e537057a4a7f597
    btrfs-progs: doc: link btrfsck to btrfs-check

Closes !26 - Remove support for btrfs-progs < 3.12
2019-03-15 16:01:50 +00:00
Mike Fleetwood f697d1e7ce Stop using removed btrfsctl (!26)
That commit [1] also removed btrfsctl from btrfs-progs 3.12 so also stop
using it as a fallback.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git/commit/?id=f243fcd1b2aa55ffadfbcc032c66dedbee56e79e
    Removing btrfsctl, btrfs-vol, btrfs-show

Closes !26 - Remove support for btrfs-progs < 3.12
2019-03-15 16:01:50 +00:00
Mike Fleetwood 3607ede307 Finish removal of btrfs-show (!26)
Remove use of btrfs-show from everywhere else in the btrfs module.

Closes !26 - Remove support for btrfs-progs < 3.12
2019-03-15 16:01:50 +00:00
Mike Fleetwood 9c40b7fff0 Stop using removed btrfs-show to read the label (!26)
This commit [1] from btrfs-progs 3.12 removed the previously deprecated
programs btrfsctl and btrfs-show.  As btrfs-progs 3.12 is now the
minimum requirement, remove support for those removed programs.

This commit is just removing the use of btrfs-show as a fallback to read
the label.

Note that 'btrfs-show /dev/PTN' didn't distinguish between a label of
"none" and no label.  Hence the logic in btrfs::read_label() to do with
matching the label "none", or matching the label with or without single
quotes.  Unfortunately as identified in this commit [2]
'btrfs filesystem show /dev/PTN' is subject to the same issue, but only
when the file system is mounted and only for btrfs-progs 3.12.  This was
fixed by this commit [3] from btrfs-progs 3.14.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git/commit/?id=f243fcd1b2aa55ffadfbcc032c66dedbee56e79e
    Removing btrfsctl, btrfs-vol, btrfs-show

[2] eca732fb0c
    Update parsing of btrfs filesystem show for the label (#733601)

[3] https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git/commit/?id=a156b967ed9bd606afa8dc402451abcf07226c17
    btrfs-progs: make filesystem show by label work

Closes !26 - Remove support for btrfs-progs < 3.12
2019-03-15 16:01:50 +00:00
Mike Fleetwood d7dbbe4979 Remove old workaround for btrfs resizing on Linux < 3.2 (!26)
PATCHSET OVERVIEW

The oldest supported distributions have these versions of the Linux
kernel and btrfs-progs:
  Distro             EOL        kernel    btrfs-progs
- RHEL / CentOS 7    2024-Jun   3.10.0    4.9.1
- Ubuntu 14.04 LTS   2019-Apr   4.4.0     3.12
- Debian 8           2020-Jun   3.16.0    3.17
- SLES 12            2027-Oct   3.12.28   3.16

Making the oldest supported packages be kernel 3.10 and btrfs-progs 3.12
allows the btrfs support code to be simplified by removing backward
compatibility.

THIS CHANGE

Remove old workaround for ignoring the error when resizing a btrfs to
the same size on Linux kernel < 3.2.

Also now that only exit status 0 is considered successful from btrfs
resize, the EXEC_CHECK_STATUS flag to execute_command() can be used,
rather than having to separately call set_status() afterwards.

Relevant commit history:
*   11d044dba0
    Don't ignore any errors resizing btrfs on Linux >= 3.2 (#669389)
*   a580abbc30
    Use newer btrfs multi-tool control command first

Closes !26 - Remove support for btrfs-progs < 3.12
2019-03-15 16:01:50 +00:00
Mike Fleetwood 2aae7b0688 Set title of Resize/Move dialog for an extended partition (#44)
The title has never been set in this case, and defaulted to the name of
the executable 'gpartedbin'.  Fix this.

Closes #44 - Title not set in Resize/Move dialog for extended partitions
2019-03-14 17:08:50 +00:00
Trần Ngọc Quân e6e3f75d7d Updated Vietnamese translation
Signed-off-by: Trần Ngọc Quân <vnwildman@gmail.com>
2019-03-03 14:51:51 +07:00
Mike Fleetwood 8effaf4f22 Initialise local POD 'launched' variable in show_help()
'launched' local POD (Plain Old Data) variable was left uninitialised,
but was set in both the try and catch clauses.  Best practice is to
initialise when defined, so do that instead.  Cosmetic change.
2019-03-01 16:46:56 +00:00
Mike Fleetwood f5e870d6c4 Rename Win_GParted method to show_help()
It is not creating a dialog (a pop-up window managed by GParted code
itself).  It is launching independent yelp program to display the help,
so remove the "_dialog" from the name to avoid any possible confusion.
2019-03-01 16:46:56 +00:00
Mike Fleetwood e3ae8a6f26 Restore specific error message on failure to launch yelp
Originally, if the yelp command was not installed, attempting to display
help produced an error dialog with this message:
    Failed to execute child process "yelp" (No such file or directory)

However since this commit during the Gtk 3 port [1] the error message
became this less useful one:
    Operation not supported

Two attempts are made to display the GParted Manual, first using
gtk_show_uri() and second by executing the yelp command directly.  Prior
to the aforementioned commit [1] both methods returned the failure
reason using the same 'error' variable.  Hence reported the message
"Failed to execute child process "yelp" ..." from the second attempt.
However that commit had to re-code the second method as part of the Gtk
3 port and use a different error returning mechanism, thus the use of
different variable 'e'.  But the dialog was left reporting the message
from the original 'error' variable, thus reporting "Operation not
supported" message from the first attempt using gtk_show_uri().

Fix by again displaying the message from the second failure into the
error dialog.  Also make it very clear there are two error returning
variables by naming them 'error1' and 'error2_msg'.

[1] 2953778a4c
    port-to-gtk3: Use Gdk::AppLaunchContext to launch yelp (#7)
2019-03-01 16:46:56 +00:00
Mike Fleetwood 3ce3683df5 Remove deprecated PKG_NAME from autogen.sh
Use of PKG_NAME is deprecated in GNOME 3 and produced this warning:

    $ ./autogen.sh
    /usr/bin/gnome-autogen.sh
    /usr/bin/yelp-build
    ***Warning*** PKG_NAME is deprecated, you may remove it from autogen.sh
    ...

Now that GParted is a GNOME 3 application with GNOME 3 yelp-tools
managed documentation this is redundant and can be removed.  Previous
further analysis:

    GNOME Bugzilla, Bug 743318, comment 18
    https://bugzilla.gnome.org/show_bug.cgi?id=743318#c18
    "
    PKG_NAME is still used in GNOME 2.28's gnome-autogen.sh in error
    messages.  (GNOME 3's gnome-autogen.sh queries it from configure.ac
    instead of requiring it to be set).
    "

Also confirmed that it makes no difference by running ./autogen.sh with
and without PKG_NAME being set.  The produced GParted build trees were
the same.  Therefore the release and executable can't be affected.
2019-03-01 16:46:56 +00:00
Mike Fleetwood 83777932c6 Drop now unnecessary editing of xmllint command line in CI tests (!24)
GNOME 3's yelp doesn't use scrollkeeper or the OMF catalog, so the
constructed Makefile doesn't use xmllint to validate the scrollkeeper
DTD file.  Therefore remove attempted sed edit of that line which no
longer exists in the Makefile.

Note that help/Makefile.am's @YELP_HELP_RULES@ automake macro expansion
comes from /usr/share/aclocal/yelp.m4 [1].

Commit which previously needed to add the sed edit:
    cbb25a2511
    Stop xmllint scrollkeeper-omf.dtd fetch failure breaking CI tests (#9)

[1] Yelp > Yelp Tools > yelp.m4
    http://yelp.io/tools/yelp.m4.html

Closes !24 - Port to GNOME 3 yelp-tools documentation infrastructure
2019-03-01 16:46:56 +00:00
Mike Fleetwood 5aca85e4ad Launch help from GParted using the new GNOME 3 help: prefix (!24)
Update GParted to specify the GParted Manual using the new GNOME 3 way
with the 'help:' prefix to avoid yelp reporting this error:
    Document Not Found
    The URI 'ghelp:gparted' does not point to a valid page.

Closes !24 - Port to GNOME 3 yelp-tools documentation infrastructure
2019-03-01 16:46:56 +00:00
Mike Fleetwood 4ef3ef3312 Allow GNOME 3 yelp to display the GParted Manual (!24)
Now with GNOME 3 style help installed, running 'yelp help:gparted'
results in this error being displayed in yelp:
    Page Not Found
    The requested page was not found in the document 'help:gparted'.

Where as running 'yelp help:gparted/gparted' correctly displays the
GParted Manual.

Fix by renaming the article tag to the default 'index' that yelp is
expecting when using the new GNOME 3 'help:' prefix.

Closes !24 - Port to GNOME 3 yelp-tools documentation infrastructure
2019-03-01 16:46:56 +00:00
Mike Fleetwood a725921a22 Add use of new GNOME 3 yelp-tools documentation infrastructure (!24)
Second part is to use yelp-tools to build and install the documentation.
Have to rename the help Manual from help/C/gparted.xml to
help/C/index.docbook in accordance with this note from the GNOME Goal:
Port to New Documentation Infrastructure [1]:
    IMPORTANT: If this is for a DocBook document, the top-level DocBook
    file MUST be renamed to index.docbook.  Do a "git mv" and include
    index.docbook in HELP_FILES.

Commits from gucharmap [4] and totem [5], projects which have DocBook
documentation, making this same change are also useful references.

[1] GNOME Goal: Port To New Documentation Infrastructure
    https://wiki.gnome.org/Initiatives/GnomeGoals/NewDocumentationInfrastructure

[2] Yelp > Yelp Tools > yelp.m4
    http://yelp.io/tools/yelp.m4.html

[3] GNOME application developement overview / User help / Set up your
    build system
    https://developer.gnome.org/platform-overview/stable/dev-help-build.html.en

[4] gucharmap commit "Port to new documentation infrastructure"
    3e1526c056

[5] totem commit "Use new documentation infrastructure"
    59a6bd6064

Closes !24 - Port to GNOME 3 yelp-tools documentation infrastructure
2019-03-01 16:46:56 +00:00
Mike Fleetwood e62b352eed Remove use of GNOME 2 gnome-doc-utils documentation infrastructure (!24)
Details of old GNOME 2 gnome-doc-utils:
    Migrating your documentation to gnome-doc-utils
    https://wiki.gnome.org/Projects/GnomeDocUtils/MigrationHowTo

First part is to stop using gnome-doc-utils to build and install the
documentation.  Also since updating the OMF catalog was only needed for
GNOME 2 yelp, use of scrollkeeper is completely removed too.

Closes !24 - Port to GNOME 3 yelp-tools documentation infrastructure
2019-03-01 16:46:56 +00:00
Jeremy Bicha 12adade3ab Fix FDL help link for gnome-desktop 3.5+ (!24)
I generated this by running:
    find ./ -type f -exec sed -i 's/ghelp:fdl/help:fdl/g' {} \;

By updating the translations at the same time, it should be easier on
the translators as there's no reason to invalidate these strings.

https://bugzilla.gnome.org/show_bug.cgi?id=704634#c8

[Mike Fleetwood: Explain the underlying cause and distro versions.]
This gnome-desktop commit, first included in version 3.5.5, switched the
package from using gnome-doc-utils to yelp-tools so changed the
installed location of the GNU FDL license file from
/usr/share/gnome/help/fdl/C/fdl.xml to
/usr/share/help/C/fdl/index.docbook, thus changing the yelp URI from
'ghelp:fdl' to 'help:fdl':
    8b7e059e2c
    Port to new documentation infrastructure

The oldest supported distributions with Gtk/GNOME 3 all have at least
3.10, therefore use this fix unconditionally.

    Distribution        EOL         Gtk/GNOME 3
    RHEL / CentOS 7     2024-Jun    3.22
    Ubuntu 14.04 LTS    2019-Apr    3.10
    Ubuntu 16.04 LTS    2021-Apr    3.18
    Debian 8            2023-Apr    3.14
    SLES 12             2027-Oct    3.10

Closes !24 - Port to GNOME 3 yelp-tools documentation infrastructure
2019-03-01 16:46:56 +00:00
Mike Fleetwood 8412dcfe72 Remove redundant file help/C/Makefile.am (!24)
The file has been redundant since it was first added [1].  It was never
listed in configure.ac (or configure.in) in AC_CONFIG_FILES.  Therefore
autoconf has never produced help/C/Makefile.in and ./configure has never
produced help/C/Makefile.  Therefore it isn't used during the build and
install of GParted.  Remove it.

[1] 46ca7c74dc
    Added code hooks to prepare for GParted Manual

Closes !24 - Port to GNOME 3 yelp-tools documentation infrastructure
2019-03-01 16:46:55 +00:00
Kukuh Syafaat 2c3c897fed Update Indonesian translation 2019-02-28 07:15:44 +00:00
Nathan Follens 8b112a35e4 Update Dutch translation 2019-02-26 12:09:37 +00:00
Mike Fleetwood 4fcd182992 Remove left behind configuration summary lines (!22)
These lines in the final configuration report from ./configure were left
behind [1] when determination of the underlying definitions were remove.
So they no longer report 'yes' or 'no' like the other lines in the file
configuration report.

       Need partition table re-read workaround?  :
     Supports large sector sizes (> 512 bytes)?  :

Remove them now.

[1] 8df975c7d1
    Increase minimum required libparted to 2.2 (!22)

Closes !22 - Increase minimums to libparted 2.2 and glibmm 2.32
2019-02-20 16:15:17 +00:00
Mike Fleetwood d0281a3264 Remove left behind commented #includes from fat16.cc
According to the GIT history the lines were added by this commit:
    8d808c0b62
    gparted-0.3.6 - code recreation from Source Forge

Looking at the SVN history this commit actually fleshed out the
implementations of fat16::get_label() and fat32::get_label() and added
the commented #includes:
    https://sourceforge.net/p/gparted/svn/118
    Added read label support for fat16 and fat32 using mtools mlabel command
    2008-02-12

Then this SVN commit moved the mtools temporary file handling code into
Utils.cc, leaving behind the commented #includes:
    https://sourceforge.net/p/gparted/svn/124
    Added MTools temporary file handling functions
    2008-02-19

Finally this commit removed fat32.cc by merging the code with fat16.cc:
    519af1a7c0
    Combine duplicate code for fat16/32

So remove the left behind commented #includes from fat16.cc.
2019-02-20 16:15:17 +00:00
Mike Fleetwood 24d9599f66 Enable online resizing of extended partitions (!23)
A forum user had a case where they wanted to grow their in use root,
ext4 file system.  GParted supports this, but the partition was a
logical partition inside an extended partition and GParted doesn't
support resizing an extended partition while any contained logical
partitions are busy.

Example layout:

    Partition              File System   Mount Point
    /dev/sdb1              ntfs
    /dev/sdb2     [busy]
        /dev/sdb5 [busy]   ext4          /
    unallocated            unallocated

So just allow extended partitions to be resized online when online
partition resizing is available via libparted.

NOTE:
The block device that the Linux kernel provides for an extended
partition just maps to the first 1 KiB of the extended partition where
the Extended Boot Record is stored, and does not include any of the
contained logical partitions.  Therefore no application can care that
the extended partition is resized while a logical partition is in use
because it can't use the extended partition block device to access any
data.

The on disk layout looks like this:

    # fdisk -l /dev/sdb

    Disk /dev/sdb: 8589 MB, 8589934592 bytes, 16777216 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x0007650e

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048     1050623      524288    7  HPFS/NTFS/exFAT
    /dev/sdb2         1050624     2101247      525312    5  Extended
    /dev/sdb5         1052672     2101247      524288   83  Linux

    # parted /dev/sdb unit s print free
    Model: ATA VBOX HARDDISK (scsi)
    Disk /dev/sdb: 16777216s
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:

    Number  Start     End        Size       Type      File system  Flags
            63s       2047s      1985s                Free Space
     1      2048s     1050623s   1048576s   primary   ntfs
     2      1050624s  2101247s   1050624s   extended
     5      1052672s  2101247s   1048576s   logical   ext4
            2101248s  16777215s  14675968s            Free Space

The kernel's partition sizes from /sys/block/sdb/sdb${N}/{start,size}
shows extended partition 2 has a size of only 2 sectors:

    # for N in 1 2 5
    > do
    > echo -e "/dev/sdb${N}\tstart=`cat /sys/block/sdb/sdb${N}/start`\tsize=`cat /sys/block/sdb/sdb${N}/size`"
    > done
    /dev/sdb1       start=2048      size=1048576
    /dev/sdb2       start=1050624   size=2
    /dev/sdb5       start=1052672   size=1048576

The EBR read from the whole of extended partition 2 block device:

    # hexdump -C /dev/sdb2
    00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 86  |................|
    000001c0  06 41 83 cb 09 82 00 08  00 00 00 00 10 00 00 00  |.A..............|
    000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
    00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00000400

Closes !23 - Enable online resizing of extended partitions
2019-02-20 16:15:17 +00:00
Mike Fleetwood 1ed30495f1 Recognise contribution by Luca Bacci 2019-02-11 09:21:01 +00:00
Luca Bacci c091c9f458 Prevent the legend text making the features dialog too wide (#7)
With the Gtk3 port the File System Support dialog has become too wide
because the legend text is no longer wrapped.  Set the max-width-chars
property to specify the natural size of the widget in terms of
characters [1].  It is converted to pixels using the average character
width in the current font.

Also use PACK_EXPAND_WIDGET when adding the label to the box so that if
the dialog is resized extra space is used to increase the size of this
child widget [2].

[1] GNOME HowDoI / Labels
    https://wiki.gnome.org/HowDoI/Labels

[2] Gtkmm 3.0 Enums and Flags, enum Gtk::PackOptions
    "PACK_EXPAND_WIDGET  Space is expanded, with extra space filled by
    increasing the child widget size."
    https://developer.gnome.org/gtkmm/3.0/group__gtkmmEnums.html#ga83727a1b6fed51566dfd5c8e58890dba

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci bf39c221b8 Enable display of progress bar text when applying operations (#7)
In Gtk2 progress bars show optional text superimposed over the bar.  In
Gtk3 the text is not displayed by default, so set the show-text property
to re-enable this [1].

Also note that since Gtk 3.14.0 the optional text is not superimposed
over the progress bar, but instead displayed just above it [2][3][4].

References:

[1] Gtkmm 3.0 Gtk::ProgressBar Class Reference, set_show_text()
    "Sets whether the progressbar will show text superimposed over the
    bar."
    https://developer.gnome.org/gtkmm/3.0/classGtk_1_1ProgressBar.html#a0bfa6042f5d4b3509967abc2d8af57fe

[2] Commit - Update the design for progress bars
    74405cc964

[3] Bug 748784 - GtkProgressBar text cannot be superimposed on the
    progress bar
    https://bugzilla.gnome.org/show_bug.cgi?id=748784

[4] Gtkmm 3.18 Gtk:ProgressBar Class Reference, set_show_text()
    "Set whether the progress bar will show text next to the bar."
    https://developer.gnome.org/gtkmm/3.18/classGtk_1_1ProgressBar.html#a0bfa6042f5d4b3509967abc2d8af57fe

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci d626a636d3 Ensure SpinButtons have space to display 7 digits (#7)
In Gtk2 the up and down buttons in a SpinButton were smaller leaving
space for 7 digits before scrolling the entry.  In Gtk3 the up and down
buttons are much larger leaving only space for 4 digits.  This occurs in
the SpinButtons in the Dialog_Base_Partition class as displayed in the
New Partition, Paste and Resize/Move dialogs.

Set width-chars property of all Gtk::SpinButtons to ensure 7 digits can
be displayed before scrolling the entry.

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 6aba93d8c0 Change Gtk::ProgressBar appearance by providing custom CSS (#7)
In Gtk3 the progress bar height is fixed and defined by the CSS theme in
use.  Changing the widget allocation size does nothing, it is always
rendered the same way.

In many themes, including Adwaita, the progressbar is very, very thin.
Provide custom CSS to specify a height of 8 pixels.

The CSS source string has to be differentiated for Gtk pre and post
3.20, because Gtk 3.20 introduced some breaking changes in the way CSS
is handled.

References:

[1] Migrating from GTK+ 2.x to GTK+ 3 - Parsing of custom resources
    https://developer.gnome.org/gtk3/stable/gtk-migrating-GtkStyleContext-parsing.html

[2] Gtk3 Reference Documentation - Changes in GTK+ 3.20
    https://developer.gnome.org/gtk3/stable/ch32s10.html

[3] Gnome/HowDoI - Custom Style
    https://wiki.gnome.org/HowDoI/CustomStyle

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 6c47561bf6 Change packing of pulsebar in statusbar (#7)
The pulsebar looks very small and needs to be widened.  The pulsebar is
packed inside the statusbar so that it displays activity text on the
left side and the pulsebar on the right side.  Ideally we want the space
to be evenly divided for the textual messages and for the pulsebar
activity indicator.

For this we just have to set the 'homogeneous' property to TRUE for the
statusbar (note that GtkStatusBar inherits from GtkBox).

Also vertically align the pulsebar to the center of the statusbar.  This
is achieved setting the 'valign' property to Gtk::ALIGN_CENTER for the
pulsebar widget.

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 892f5542a4 Work around Gtk3 Gtk-CRITICAL messages when closing some dialogs (#7)
There is a bug affecting Gtk+ 3.22.8 to 3.22.30 in which destroying a
GtkComboBox when it is not hidden results in this message:

    Gtk-CRITICAL **: gtk_widget_is_drawable: assertion 'GTK_IS_WIDGET (widget)' failed

This happens in GParted when some dialogs are closed, for example the
Create New Partition and Create Partition Table dialogs.  To work around
the issue we call Gtk::Dialog::hide() in the destructors of our dialog
classes.

The issue was fixed in Gtk 3.24.0.

 * Gtk 3.22.8 was released in February 2017.
 * Gtk 3.24.0 was released in September 2018.

References:

[1] Gtk Issue - GtkComboBox::private::popup_window can be NULL
    https://gitlab.gnome.org/GNOME/gtk/issues/125

[2] Gtk commit - combobox: popdown() the menu during unmap()
    7401794de6

[3] Gtk commit - Check for NULL priv->popup_window in
    gtk_combo_box_popdown()
    aa5d926c84

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 392bbba534 Work around Gtkmm3 issue where menu accelerators are not shown (#7)
There is a bug in Gtkmm3 when setting accelerator keys on a
Gtk::MenuItem, the accelerator keys work but are not displayed when the
menu is drawn.  This happens for Gtk::MenuItems, including derived
objects, that are constructed with a non-default constructor.

All non-default constructors of Gtk::MenuItem, and subclasses, work by
creating themselves a Gtk::AccelLabel and packing it inside the menu
item.  But in Gtk3 GtkMenuItem are created with a GtkAccelLabel already
packed in as a child and that accel label should be used instead.

To workaround the issue we only use the default constructor for
Gtk::MenuItem and subclasses.  This is easy to do because we only have
to change the wrappers in MenuHelpers.cc.

This bug affects Gtkmm version 3.0.0 to 3.22.2 and was fixed in
Gtkmm 3.22.3.

 * Gtkmm 3.0.0 was released in April 2011
 * Gtkmm 3.22.3 was released in November 2018

References:

[1] Bug Report on the Gtkmm mailing list
    https://mail.gnome.org/archives/gtkmm-list/2018-February/msg00006.html

[2] Commit - Gtk::MenuItem: Fix add_accel_label()
    e5c8c2df67

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 244f4bcd22 Simplify code using Gtk::Container::get_children() (#7)
GParted uses Gtk::Container::get_children().  In Gtkmm2
Gtk::Container::get_children() returns a Glibmm intermediate container
[1].  Gtkmm3 dropped the use of Glibmm intermediate containers in favour
of STL containers [2][3].

Now that Gtk::Container::get_children() directly returns a std::vector<>
simplify the code.

References:

[1] Gtkmm 2.24 Gtk::Container Class Reference
    "Glib::ListHandle<Widget*> Gtk::Container::get_children()"
    https://developer.gnome.org/gtkmm/2.24/classGtk_1_1Container.html#acd2f9b9ac16ba96178d3f5169b07f4d0

[2] Gtkmm 3.0 Gtk::Container Class Reference
    "std::vector<Widget*> Gtk::Container::get_children()"
    https://developer.gnome.org/gtkmm/3.0/classGtk_1_1Container.html#a3a2111e255cb5b72bd91a3be087cff27

[1] Programming with gtkmm3 / Changes in gtkmm3
    "11. We now use std::vector in several methods instead of the
    intermediate *Handle types to make the API clearer."
    https://developer.gnome.org/gtkmm-tutorial/3.0/changes-gtkmm3.html.en

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 0078cf01cc port-to-gtk3: Block Gtk::TreeSelection changed handler on tree model clear (#7)
Now GParted compiles with Gtkmm3, but we get a failed assertion doing
the following:
 * Select a device with more than 1 partition
 * Select a partition
 * Activate 'Refresh Devices' (or do any operation that causes it, like
   mount/unmount etc.)

This is the failed assertion:
    **
    ERROR:Win_GParted.cc:1152:void GParted::Win_GParted::set_valid_operations(): assertion failed: (valid_display_partition_ptr( selected_partition_ptr ))
    Aborted (core dumped)

Where is the problem?

Win_GParted::Refresh_Visual() calls TreeView_Detail::load_partitions()
to clear and refill the treeview.

The problem is in GParted::TreeView_Detail::load_partitions() at
TreeView_Detail.cc:91:
    treestore_detail->clear();

This activates TreeView_Detail::on_selection_changed() which in turn
activates Win_GParted::on_partition_selected() passing an old, stale
pointer as an argument.  This triggers the failed assertion.

Why does this happen with Gtk3 and not with Gtk2?

First a bit of background of GtkTreeView:

What happens to the selection in a GtkTreeView when the selected row
is removed?

With Gtk2 the selection simply becomes empty, so nothing is selected
afterwards.  With Gtk3 this was changed [1] and selection moves to an
adjacent row.

gtk_tree_store_clear() removes rows one by one.  While removing rows the
selection changed signal is emitted.  With Gtk2 it is emitted only one
time, to indicate that selection has become empty.  With Gtk3 it is
instead emitted several times, each time indicating that selection has
moved to the adjacent row.

The handler TreeView_Detail::on_selection_changed() only takes action
when the selection is not empty.  So with Gtk3 it really takes action
and activates Win_GParted::on_partition_selected() with a pointer to old
data.

What's the purpose of TreeView_Detail::on_selection_changed()?

Its task is to update the selection in the drawing area above the
TreeViewDetail, the DrawingAreaVisualDisk, so that the selected
partition stays in sync on the two widgets.

Fix by blocking the signal handler during the treeview clear.

Reference:
[1] Commit - treeview: Handle the case where the cursor row gets deleted
    1a2932ba29

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 2953778a4c port-to-gtk3: Use Gdk::AppLaunchContext to launch yelp (#7)
gdk_spawn_command_line_on_screen() is not present in Gtk3.  The
documentation from Gtkmm 2.24 states [1]:

    gdk_spawn_command_line_on_screen has been deprecated since version
    2.24 and should not be used in newly-written code.  This function is
    being removed in 3.0.  Use either g_spawn_command_line_sync(),
    g_spawn_command_line_async() or GdkAppLaunchContext instead.

g_spawn_command_line_sync() and g_spawn_command_line_async() are screen
/ display agnostic, as such we would loose functionality.  There is a
workaround, which involves setting the DISPLAY environment variable [2],
but it's a weak solution (and I don't know if it works on backends
other than X11).

GdkAppLaunchContext is an implementation of GIO's GAppLaunchContext that
handles launching an application in a graphical context [3].  Therefore
use GdkAppLaunchContext and GIO's GAppInfo.

GdkAppLaunchContext was introduced in Gtk2 version 2.14.  The C++
wrapper Gdk::AppLaunchContext was introduced only in Gtkmm3 version 3.4
[4].  Bump the minimum required version of Gtkmm to 3.4.0 for this
requirement.

GAppInfo was introduced in GLib version 2.16.  The C++ wrapper
Gio::AppInfo was introduced in Giomm version 2.16.  Note that the
minimum required version for glibmm is already 2.32.

[1] GDK 2 Reference Manual, GdkScreen, gdk_spawn_on_screen()
    https://developer.gnome.org/gdk2/2.24/GdkScreen.html#gdk-spawn-on-screen

[2] Migrating from GTK+ 2.x to GTK+ 3 - "Use GIO for launching applications"
    https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html#id-1.6.3.3.7

[3] GDK 3 Reference Manual - "Application launching"
    https://developer.gnome.org/gdk3/stable/gdk3-Application-launching.html

[4] Gtkmm 3.4 Gdk::AppLaunchContext Class Reference, Detailed Description
    https://developer.gnome.org/gtkmm/3.4/classGdk_1_1AppLaunchContext.html#details

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 202e6e9034 port-to-gtk3: Use Gtk::CellLayout::get_cells() (#7)
GParted uses Gtk::TreeViewColumn::get_cell_renderers().  This is not
present in Gtkmm3.  Now Gtk::TreeViewColumn inherits from
Gtk::CellLayout and we have to use Gtk::CellLayout::get_cells() instead.

GtkCellLayout was introduced in Gtk2 version 2.18 as the common
interface for containers of cell renderers.

The C++ wrapper Gtk::CellLayout was introduced in Gtkmm2 version 2.18,
but Gtk::TreeViewColumn was never made to inherit from Gtk::CellLayout
to avoid breaking the API / ABI.  That change was made for Gtkmm3.

This is an excerpt from gtkmm/treeviewcolumn.h header in Gtkmm2:
  // TODO: Should be deprecated, but we cannot derive from CellLayout
  // without breaking API and ABI.

  /** Returns a list of all the cell renderers in the column,
   * in no particular order.
   *
   * @return A list of Gtk::CellRenderers.
   */
  Glib::ListHandle<CellRenderer*> get_cell_renderers();

Replace Gtk::TreeViewColumn::get_cell_renderers() with base class
method Gtk::CellLayout::get_cells().

Reference:

[1] Commit - "Deprecate get_cell_renderers implementations"
    6abc52a29d

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 21d8ad218e port-to-gtk3: Use draw signal in the partition resizer (#7)
In Gtk2 widgets draw themselves in response to the expose event signal.
In Gtk3 widgets draw themselves in response to the GtkWidget::draw
signal, and the signal handler gets a Cairo context as an argument.

Convert Gtk::DrawingArea rendering code to respond to the
GtkWidget::draw signal.

This commit is specific to the drawing area in the Create new Partition
dialog and the Resize/Move dialog.

Reference:

[1] Migrating from GTK+ 2.x to GTK+ 3 - "The GtkWidget::draw signal":
    https://developer.gnome.org/gtk3/stable/ch26s02.html#id-1.6.3.4.11

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 93b1425549 port-to-gtk3: Use draw signal in the partition visualizer (#7)
In Gtk2 widgets draw themselves in response to the expose event signal.
In Gtk3 widgets draw themselves in response to the GtkWidget::draw
signal, and the signal handler gets a Cairo context as an argument.

Convert Gtk::DrawingArea rendering code to respond to the
GtkWidget::draw signal.

This commit is specific to the drawing area contained in the main
application window (also called the DrawingAreaVisualDisk).

Reference:

[1] Migrating from GTK+ 2.x to GTK+ 3 - "The GtkWidget::draw signal":
    https://developer.gnome.org/gtk3/stable/ch26s02.html#id-1.6.3.4.11

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 4c1fe3bf7a port-to-gtk3: Use draw signal in the partition info dialog (#7)
In Gtk2 widgets draw themselves in response to the expose event signal.
In Gtk3 widgets draw themselves in response to the GtkWidget::draw
signal, and the signal handler gets a Cairo context as an argument.

Convert Gtk::DrawingArea rendering code to respond to the
GtkWidget::draw signal.

This commit is specific to the drawing area in the Partition Info
dialog.

Reference:

[1] Migrating from GTK+ 2.x to GTK+ 3 - "The GtkWidget::draw signal":
    https://developer.gnome.org/gtk3/stable/ch26s02.html#id-1.6.3.4.11

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci e3f77966c9 port-to-gtk3: Use Gtk::Widget::render_icon_pixbuf() (#7)
In Gtk3/C, gtk_widget_render_icon() was deprecated in Gtk 3.0 [1].  In
Gtkmm3/C++, Gtk::Widget::render_icon() was abruptly removed from Gtkmm
3.0 and replaced with Gtk::Widget::render_icon_pixbuf() [2].

Gtk::Widget::render_icon() [3] had an optional 3rd parameter which
GParted never used.  Replace with Gtk::Widget::render_icon_pixbuf() [4].

References:

[1] GTK+ 3 Reference Manual, GtkWidget
    https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-render-icon
    "gtk_widget_render_icon has been deprecated since version 3.0 and
    should not be used in newly-written code."

[2] Gtkmm 3.0.0 NEWS file
    "... Removed render_icon(), adding render_icon_pixbuf()."
    https://gitlab.gnome.org/GNOME/gtkmm/blob/3.0.0/NEWS#L187

[3] Gtkmm 2.24 Gtk::Widget Class Reference, render_icon()
    https://developer.gnome.org/gtkmm/2.24/classGtk_1_1Widget.html#a91efd1b5aed7c184506ddd5721710584

[4] Gtkmm 3.0 Gtk::Widget Class Reference, render_icon_pixbuf()
    https://developer.gnome.org/gtkmm/3.0/classGtk_1_1Widget.html#a28bbbd0c1717e58343df56f7f422b106

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 5fb58f8877 port-to-gtk3: Use Gdk::Cursor via Glib::RefPtr<> (#7)
Starting from Gtkmm3 Gdk::Cursor objects cannot be constructed directly,
but instead you have to get a smart pointer to an instance by calling
the static member function Gdk::Cursor::create().

Gdk::Cursor::create() returns a Glib::RefPtr<Gdk::Cursor> object.

Gtkmm3 always uses Glib::RefPtr<Gdk::Cursor> in its interface and never
plain Gdk::Cursor.

Reference:

[1] Programming with gtkmm3, Changes in gtkmm3:
    https://developer.gnome.org/gtkmm-tutorial/3.24/changes-gtkmm3.html.en
    "... Gdk::Cursor are now used via Glib::RefPtr."

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 29a21a5a4c port-to-gtk3: Rework Gtk header includes (#7)
In Gtk3 individual headers cannot be included directly in application
code, only the header <gtk/gtk.h> can be included (with a few exceptions
for some platform specific headers).

This has always been considered good practice even for Gtk2, though was
not a hard requirement.

In Gtk3 this is enforced by preprocessor checks.  Failure to do so
yields a preprocessor error and compilation fails:

  "error: Only <gtk/gtk.h> can be included directly."

Change specific Gtk header includes to:

  #include <gtk/gtk.h>

References:

[1] Migrating from GTK+ 2.x to GTK+ 3 - "Do not include individual headers"
    https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html#id-1.6.3.3.3

[2] Commit - "Remove all traces of GDK_PIXBUF/GTK_DISABLE_SINGLE_INCLUDES"
    5e29973773

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 05da10775c port-to-gtk3: Rework Gtkmm header includes (#7)
Now that we are compiling against Gtkmm3 there are missing declarations
of Gtkmm identifiers due to changes in Gtkmm internal header structure.

All we have to do is bring back the declarations by including the
appropriate headers where needed.

Add necessary Gtkmm header includes.

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 4b87839502 port-to-gtk3: Rework Glibmm header includes (#7)
Now that we are compiling against Gtkmm3 there are missing declarations
of Glibmm identifiers due to changes in Gtkmm internal header structure.

All we have to do is bring back the declarations by including the
appropriate headers where needed.

Add necessary Glibmm header includes.

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci cc0740148e port-to-gtk3: Switch to Gtkmm3 (#7)
Switch to Gtkmm3 in configure.ac.  Require version 3.0.0.

Also update the build instructions in README and the package list in
.gitlab-ci.yml.

Starting from version 3.18.0 Gtkmm requires C++11 compilation [1][2][3].
Add a check for Gtkmm >= 3.18.0 in configure.ac and enable C++11
compilation accordingly.

References:

[1] Gtkmm 3.18.1 NEWS
    "Changes in 3.18 ... Use, and require C++11, ..."
    https://gitlab.gnome.org/GNOME/gtkmm/blob/3.18.1/NEWS#L35

[2] Murray's Blog - "gtkmm now uses C++11"
    https://www.murrayc.com/permalink/2015/07/31/gtkmm-now-uses-c11

[3] Murray's Blog - "gtkmm 3.18 and glibmm 2.46"
    https://www.murrayc.com/permalink/2015/09/25/gtkmm-3-18-and-glibmm-2-46

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 5379352766 prepare-for-gtk3: Prepare for removal of Gtk::Widget::modify_fg() (#7)
The Gtk::Widget::modify_fs() API was removed in Gtkmm3 [1] and also
there is no direct replacement.  GParted uses this in one place.  So
instead use the C gtk_widget_modify_fg() version that is still present
in Gtk3.

This is just a temporary change to port GParted to Gtk3.  In future this
will be replaced as part of the switch from Gdk::Color to Gtk::RGBA,
since Gdk::Color was deprecated in Gtkmm 3.10 [2].

Reference:

[1] ee432e2190
    commit message "... Remove the modify_*() methods, ..."

[2] Gtkmm 3.10 Gdk::Color Class Reference
    https://developer.gnome.org/gtkmm/3.10/classGdk_1_1Color.html#details
        Deprecated:
        Use Gdk::RGBA instead.

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00
Luca Bacci 0d73ff83d9 prepare-for-gtk3: Prepare for removal of Gtk::Menu_Helpers::MenuList (#7)
GParted uses Gtk::Menu_Helpers::MenuList helper class to access
individual menu items.  This helper class made it easy to navigate menu
items by index.

Gtk::Menu_Helpers::MenuList was removed in the switch from Gtkmm2 to
Gtkmm3 [1].  Instead, use a separate std::map<Gtk::MenuItem*> to keep
track of individual Gtk::MenuItem objects.

Reference:
[1] Gtkmm 3 commit "MenuShell: Remove items()." removed the code
    c8e47b0db5

Closes #7 - Port to Gtk3
2019-02-11 08:57:18 +00:00