Skip to content

Add GTK4 + libadwaita interface (GTK_BUILD_TYPE=GTK4) - #1318

Merged
LocutusOfBorg merged 1 commit into
masterfrom
gtk4-migration
Sep 3, 2026
Merged

LocutusOfBorg merged 1 commit into
masterfrom
gtk4-migration

Conversation

@eaescob

@eaescob eaescob commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a GTK4 + libadwaita port of the GTK GUI, selectable with
-DGTK_BUILD_TYPE=GTK4. GTK3 stays the default and is left completely
unchanged — the GTK4 interface is a parallel tree under
src/interfaces/gtk4/, so this change is purely additive.

Why now

GTK3 is in maintenance-only mode upstream, and recent GTK / glycin changes
have started to break the GTK3 interface in the field — see #1310, where
ettercap -G crashes after idle once glycin restarts its image loaders across
the privilege drop. This gives ettercap a modern, actively-supported toolkit
to move to. The move off GtkTreeView to GtkColumnView may also help with
long-standing rendering glitches some users hit on certain setups (#1231),
though that still needs confirmation from affected users on the new interface.

What's in it

A full modernization, not a mechanical port:

  • Asynchronous dialogs everywhere. GTK4 removed gtk_dialog_run(); every
    dialog is now build → present → respond, with shared helpers in
    ec_gtk4_dialogs.c (AdwAlertDialog, GtkFileDialog, AdwToast).
  • List views move from GtkTreeView/GtkListStore to GtkColumnView
    over a GListModel with a typed GObject item per view. This drops the
    hidden pointer column and the fragile GtkTreeIter-based deferred name
    resolution.
  • libadwaita widgets: AdwApplicationWindow, AdwToolbarView /
    AdwHeaderBar, AdwTabView for the MDI pages, AdwAboutDialog,
    AdwToast, and AdwShortcutsDialog (with a plain AdwDialog fallback for
    libadwaita < 1.8).
  • The keyboard-shortcuts window is generated from the accelerator table
    instead of the ~1370-line hand-written ec_gtk3_shortcuts.c.

Build wiring: a pkg-config-based FindGTK4.cmake, GTK_BUILD_TYPE=GTK4 in
EttercapLibCheck.cmake, HAVE_GTK4, and a 24.04-only entry in the CI matrix.

Requirements (for packagers)

  • GTK ≥ 4.12 and libadwaita ≥ 1.5 (the latter is what provides
    AdwDialog/AdwAlertDialog). This gates the GTK4 build to Ubuntu ≥
    24.04 / Debian ≥ 13 / Fedora ≥ 39
    ; older releases keep the GTK3 build.
  • README.md and INSTALL document the dependencies and -DGTK_BUILD_TYPE=.

Validation

Built and driven in an Ubuntu 24.04 cloud sandbox via the included harness
(tests/gtk4/, see its README) — 5/5 checks pass: startup, the async
dialogs, the generated shortcuts window, the about dialog, and the sniffing UI
with its GtkColumnView list views populated from a fixture pcap, all with no
GTK criticals logged.

Screenshots from that run are attached below (setup screen, sniffing UI, the
connections and profiles GtkColumnViews with data, the generated shortcuts
window, and the AdwAboutDialog).
01-setup-screen
02-sniffing-ui
03-connections-columnview
04-profiles-columnview
05-keyboard-shortcuts
06-about-dialog

Notes for reviewers

  • The GTK3 interface is untouched; nothing here changes existing behaviour.
  • It also fixes a few latent GTK3 bugs picked up during the port: the
    tab-page accelerators that never fired (the GTK3 FIXME doesn't work yet),
    a duplicate <Primary>p binding, and a mislabelled OS in the profile
    detail view.
  • This is a large diff. Happy to split it into smaller reviewable chunks
    (build wiring / dialog layer / individual views) if that's easier to land.

Related: #1310, #1231


🤖 Generated with Claude Code

Introduce a GTK4/libadwaita port of the GTK GUI alongside the existing
GTK2/GTK3 interfaces, selectable with -DGTK_BUILD_TYPE=GTK4. GTK3 remains the
default and is left untouched, so this change is purely additive.

The new interface lives in src/interfaces/gtk4/ and is a full modernization,
not a mechanical port:

- Asynchronous dialogs throughout. GTK4 removed gtk_dialog_run(); every dialog
  is now build -> present -> respond, with shared helpers in
  ec_gtk4_dialogs.c (AdwAlertDialog, GtkFileDialog, AdwToast).
- List views move from GtkTreeView/GtkListStore to GtkColumnView over a
  GListModel with a typed GObject item per view. This removes the hidden
  pointer column and the fragile GtkTreeIter-based deferred name resolution.
- libadwaita widgets: AdwApplicationWindow, AdwToolbarView/AdwHeaderBar,
  AdwTabView (MDI pages), AdwAboutDialog, AdwToast, AdwShortcutsDialog (with a
  plain AdwDialog fallback for libadwaita < 1.8).
- The keyboard-shortcuts window is generated from the accelerator table
  rather than the ~1370-line hand-written ec_gtk3_shortcuts.c.

Build wiring: pkg-config-based FindGTK4.cmake, GTK_BUILD_TYPE=GTK4 in
EttercapLibCheck.cmake (requires GTK >= 4.12 and libadwaita >= 1.5), a HAVE_GTK4
define, the source list in src/interfaces/CMakeLists.txt, and a 24.04-only
entry in the CI matrix (older releases ship libadwaita < 1.5).

A Cua-based test harness (tests/gtk4/) builds and drives the interface in an
Ubuntu 24.04 cloud sandbox; its provision.sh doubles as the standalone build
recipe and is shared with CI. README.md and INSTALL document the new
dependencies and the GTK_BUILD_TYPE selection for packagers.

Along the way this fixes some latent GTK3 bugs carried over during the port:
the tab-page accelerators that never worked (the GTK3 "FIXME doesn't work
yet"), a duplicate <Primary>p binding, and a mislabelled OS in the profile
detail view.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019BH79eFmKHXYo6dYnQLcep
@LocutusOfBorg

Copy link
Copy Markdown
Contributor

thank you! I tested and looks like working properly, but I have a question, on startup I can't see the "select interfaces", I don't know how to pass the interface properly, is it a bug?

@eaescob

eaescob commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

It's actually a bug. I'll be opening a PR to fix it.

@eaescob

eaescob commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up (c4a8026): restored the network-interface picker on the setup
screen, which the initial port had dropped — there was no way to choose the
capture interface. It's rebuilt with libadwaita (an AdwPreferencesGroup
with AdwComboRow interface dropdowns and AdwSwitchRow toggles for "sniff
at startup" and "bridged sniffing"), plus the setup "Options" submenu
(Unoffensive / Promisc / Set Netmask) that GTK3 also exposed there.

I also diffed the GTK4 interface against GTK3 to make sure nothing else was
left behind: all 48 registered actions and all 38 sniffing-menu items match.
Still 5/5 on the sandbox harness. Updated setup-screen screenshot to follow.

@koeppea

koeppea commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

This is huge. But its good that you left GTK3 the default graphical UI variant.

When building, I get the following warnings:

[ 14%] Building C object src/interfaces/CMakeFiles/ec_interfaces.dir/gtk4/ec_gtk4_dialogs.c.o
/home/koeppea/dev/ettercap/src/interfaces/gtk4/ec_gtk4_dialogs.c:51:19: warning: redundant redeclaration of ‘toastoverlay’ [-Wredundant-decls]
   51 | extern GtkWidget *toastoverlay;
      |                   ^~~~~~~~~~~~
In file included from /home/koeppea/dev/ettercap/src/interfaces/gtk4/ec_gtk4_dialogs.c:48:
/home/koeppea/dev/ettercap/src/interfaces/gtk4/ec_gtk4.h:113:19: note: previous declaration of ‘toastoverlay’ with type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’}
  113 | extern GtkWidget *toastoverlay;     /* AdwToastOverlay, replaces the infobar */
      |  

Has GTK4 also dropped the application menu, with Save, Open, Quit?
The Spider doesn't appear in the setup screen but a editable section below the selections (big white section and hovered cursor changes to text-marker).
image

When setup is finished and I try to open a list, the background picture isn't replaced:
image

When scanning (progress dialog), following messages appear on the terminal:

(ettercap:35975): Gtk-WARNING **: 15:26:01.017: Trying to measure GtkLabel 0x55e2518003a0 for width of 510, but it needs at least 756

(ettercap:35975): Gtk-WARNING **: 15:26:01.022: Trying to measure GtkLabel 0x55e2518003a0 for width of 510, but it needs at least 756

These are the main findings yet.

@eaescob

eaescob commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, @koeppea — all four are real. The interface
picker that the merge was missing landed in #1320; these four fixes are in
#1329 (they were meant to ride along with #1320 but landed just after it was
merged).

  • Redundant toastoverlay redeclaration — removed; it's only declared in
    ec_gtk4.h now, so the -Wredundant-decls warning is gone.

  • Application menu (Open/Save/Quit) — not dropped. GTK4 removed
    gtk_application_set_app_menu(), so instead of the old GNOME app-menu slot
    it now lives in the primary "hamburger" menu (the ☰ button in the header
    bar), together with an Options submenu (Unoffensive / Promisc / Set Netmask)
    that the setup screen also exposed. Agreed it's less obvious there than the
    old app menu — open to moving individual items into the header if you'd
    prefer.

  • Spider / editable white section on the setup screen — that white area
    was the message-log GtkTextView, which I had wrongly put on the setup
    screen; GTK3 shows the logo there and keeps the message log on the
    sniffing screen only. Fixed to match: the setup screen now shows the logo
    under the setup form, and the message log is created only on the sniffing
    screen.

  • Background picture not replaced when opening a list — the logo was a
    sibling stacked above the tab view, so it never got replaced. It's now an
    overlay on the tab view, shown only while the view has no pages, so opening
    a list hides it.

  • Trying to measure GtkLabel ... needs at least N during scan — the
    progress dialog set the title as both the AdwAlertDialog heading and a
    separate label; the duplicate, unwrapped label caused those warnings. The
    body is now just the progress bar and the heading carries the title.

All verified in the Cua sandbox harness (tests/gtk4/). A full GTK3-vs-GTK4
parity audit (menu actions, context menus, header buttons, accelerators) is on
#1320.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants