Efficient way to manage interaction events across hundreds of GTK3 widgets

Hello,

I’m developing a GTK3 application on Linux for rich, interactive business software.

Our goal is to track almost every interaction a user performs on our UI elements(widgets). From my current understanding, this means registering signals using g_signal_connect().

Here’s my concern:

The UI contains many elements (top bar menus, headers, side menu, bottom bar, main content area, etc.).

For each widget, we may want to capture all possible interactions.

For example, with a GtkButton, we might connect to signals like:
clicked, pressed, released, activate, enter-notify-event, leave-notify-event, button-press-event, button-release-event, motion-notify-event, key-press-event, key-release-event, focus-in-event, focus-out-event, etc.

If the app has ~500 buttons, and I want to register ~15–20 signals per button, that means making 7,500–10,000 g_signal_connect() calls.

My question:

  • Is this really the expected/normal way to handle events at scale in GTK (connecting signals individually per widget and per event)?
  • Or is there a more centralized or efficient mechanism for handling interaction events across many widgets?

Thanks.

Hi,

At this point, you may better fork gtk to add your capture logic directly inside the widgets implementation, and ship your app with that custom gtk build.

If you’re doing this, then you’re not using a GtkButton: you’re writing a custom widget. At that point, might as well subclass GtkWidget and write your own implementation of every event-related virtual function.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.