1

Topic: GParted Gtk3, working experimental branch

Hello, I'd like to contribute on a port to Gtk3.
I already have a working branch that compiles and seems to work just fine

  github.com/lb90/gparted-gtk3

Of course, it is not yet finished because I want to move away from deprecated parts of Gtk3, but It would be great if you can test it out and make a fast review

The strategy has been to first make a port to Gtk3 that just compiles and runs, with minimal code change. That has involved

  • Rework header includes

  • Move away from OptionMenu widget to ComboBox

  • Use Cairo for drawing

  • Not operate on GtkMenuShell using items() method that has been removed in Gtkmm3

Then I want to use modern parts of Gtk3:

  • Move away from GtkTable to GtkGrid

  • Use icon names in place of Stock Items

  • Use GApplication / GtkApplication

  • Use GAction and GMenu/GmenuModel

For that to work we only target Gtk version at least 3.4, which I find very reasonable.

Please, that fork is just experimental to see how to get the work done. It wasn't meant to be merged as it is, let me know how you think is the best away to make a good PR.

Thanks!
Luca Bacci

2

Re: GParted Gtk3, working experimental branch

Thank you Luca for your interest in GParted, and extra effort to migrate to newer libraries.

There is an open bug report related to the migration.

See Bug 652044 - uses deprecated APIs

See also the GParted Development and Developing GParted using Git web pages.

Currently I am busy so unfortunately I will not have much time to look at your work in the near term.

3

Re: GParted Gtk3, working experimental branch

Well I'll write in that Bug Report

Thank you!
Luca

4

Re: GParted Gtk3, working experimental branch

In the not so far future (rather sooner than later!) GParted will have to be split up in a front-end & back-end part (the backend could be 'udisksd' for some operations, but not for all), so that the frontend doesn't have to run as root.

It would be useful if you could somehow keep that in mind when working on this…

5

Re: GParted Gtk3, working experimental branch

Hello Luca,

Thank you for your interest in porting GParted to Gtk3.  Yes targeting Gtk >= 3.4 is good. [1]  I like your overall strategy of porting to Gtk3 first and then incrementing the requirement to 3.4 and then removing use of deprecated APIs.


A successful pull request would meet the following criteria:

  • Each commit makes a small independent change.

  • The commit message explains why the change is necessary.  References to and optional small quotes from porting guides and deprecated classes / methods are encouraged where appropriate.

  • Every commit passes './autogen.sh && make'.  Ideally also passes 'make distcheck'.  This is for git bisectability.

As gedakc mentioned above also see Developing GParted using Git.  For examples see commits authored by myself, Mike Fleetwood.


I had a look at your first commit "change configure.ac to use gtkmm-3.0".  It requires C++11 compilation.  If Gtkmm >= 3.4 *requires* C++11 that is OK, but please provide a reference in the changelog.  If not please don't add it, as it is forcing a requirement which otherwise doesn't exist.  There are distros which meet the Gtkmm >= 3.4 requirement but have slightly older versions of glibmm and libsigc++ which don't required C++11 compilation.  E.g. Debian 8 with glibmm 2.42.0 and libsigc++ 2.4.0.


I also have a question for you about running GParted as root under Wayland.  I thought that Gtk3 used native Wayland display API when available and that Wayland only allows processes run by the logged in user to communicate with the Wayland display process.  As such I expected GParted run as root under Wayland to fail to work.  However when I tested it it did work.  GParted/Gtk3 made use of the X11 display API and worked.  Do you know why?  It is important to make sure GParted runs on GNOME and Xfce desktops using Wayland and X11 display.
References to how we had to work around this for Gtk2 making X11 display calls on Wayland display.
* GParted Forum Thread: [SOLVED] How to run GParted on a GNOME Wayland desktop
* GParted Bug 776437 - Interim fix for GParted fails to run as root under Wayland


Happy to help and review more when you're ready.


Thanks,
Mike
--

[1] Targeting Gtk >= 3.4 consideration:

  • We try to keep GParted HEAD compiling on all still supported versions of distros.  RHEL/CentOS 6, and I think SLES 11, are the only/major old still supported distros which are Gtk 2 only.  As they are very old and newer releases exist, RHEL/CentOS 7 and SLES 12, which do support Gtk 3 then we are OK do drop support for them.

  • I've looked at the version of Gtkmm 3.0 in the major distros and the oldest is 3.4 in Debian 7.  Debian 7 is due to end support this month, May 2018.  After that the oldest version of Gtkmm is 3.10.1.

  Distro             EOL        Gtkmm 3.0
- RHEL / CentOS 6    2020-Nov   None
- RHEL / CentOS 7    2024-Jun   3.22.0
- Ubuntu 14.04 LTS   2019-Apr   3.10.1
- Ubuntu 16.04 LTS   2021-Apr   3.18.0
- Ubuntu 18.04 LTS   2023-Apr   3.22.2
- Debian 7           2018-May   3.4.2
- Debian 8           2020-Jun   3.14.0
- Debian 9           2020-Jun   3.22.0
- SLES 11            2022-Mar   None
- SLES 12            2027-Oct   3.10.1

6

Re: GParted Gtk3, working experimental branch

To answer my own question about how can a Gtk application still display when run as root, this is because Gtk3 still uses X11 display backend as the default rather than the wayland one.  Quoting relevant parts of the "Gtk+ 3 Reference Manual":

Part VII. GTK+ Platform Support / Using GTK+ on the X Window System

GTK+ for the X Windows System

On UNIX, the X backend is the default build for GTK+.  So you don't need to do anything special when compiling it, and everything should "just work."

Part VII. GTK+ Platform Support / Using GTK+ with Wayland

Using GTK+ with Wayland

The GDK Wayland backend provides support for running GTK+ applications under the Wayland display server. To run your application in this way, select the Wayland backend by setting GDK_BACKEND=wayland.

7

Re: GParted Gtk3, working experimental branch

Thank you both Luca and Mike for your efforts to port GParted to Gtkmm 3.  This was a significant undertaking.  Your work is appreciated.

I've just begun testing the latest master (commit 1ed30495f1) and encountered some visual anomalies with the display.  More specifically I'm testing on Kubuntu 16.04 (KDE) and the active/in-use/mounted icons are overly large.  See linked screenshot.

GParted Gtk3 - large active icons on KDE

Note that the disk icon representing the device path is also large.

If desired I can create a new Issue report to track this.  I'm flexible on how you would like to handle issues involving the Gtkmm 3 port.

8 (edited by mfleetwo 2019-02-12 00:01:34)

Re: GParted Gtk3, working experimental branch

New GitLab issue please, with before (Gtk2) and after (Gtk3) pictures.

Edit:
This is what GParted after the GTK3 port looks like on my Ubuntu 16.04 LTS virtual machine with XFCE desktop.  The icons are the expected size.

https://i.postimg.cc/HVMjNxW6/gparted-forum-thread-17736-pic-1-ubuntu1604-gtk3.png

Edit 2:
Also where do the following icon files exist and what package is providing them.
(Currently on a CentOS desktop away from my development box with above Ubuntu virtual machine).

$ locate gtk-harddisk.png
/usr/share/icons/gnome/16x16/devices/gtk-harddisk.png
/usr/share/icons/gnome/22x22/devices/gtk-harddisk.png
/usr/share/icons/gnome/24x24/devices/gtk-harddisk.png
/usr/share/icons/gnome/256x256/devices/gtk-harddisk.png
/usr/share/icons/gnome/32x32/devices/gtk-harddisk.png
/usr/share/icons/gnome/48x48/devices/gtk-harddisk.png
$ locate gtk-dialog-authentication.png
/usr/share/icons/gnome/16x16/status/gtk-dialog-authentication.png
/usr/share/icons/gnome/22x22/status/gtk-dialog-authentication.png
/usr/share/icons/gnome/24x24/status/gtk-dialog-authentication.png
/usr/share/icons/gnome/256x256/status/gtk-dialog-authentication.png
/usr/share/icons/gnome/32x32/status/gtk-dialog-authentication.png
/usr/share/icons/gnome/48x48/status/gtk-dialog-authentication.png
$ rpm -qf /usr/share/icons/gnome/16x16/devices/gtk-harddisk.png
gnome-icon-theme-legacy-3.12.0-1.el7.noarch

9

Re: GParted Gtk3, working experimental branch

New Issue 39 - After GTK3 port icons are too big on KDE created to track this problem.