Skip to content

Fix GTK4 Port: Layout, Focus Management, and Arrow Navigation#81

Open
Inuth0603 wants to merge 1 commit intosugarlabs:masterfrom
Inuth0603:fix/gtk4-layout-port
Open

Fix GTK4 Port: Layout, Focus Management, and Arrow Navigation#81
Inuth0603 wants to merge 1 commit intosugarlabs:masterfrom
Inuth0603:fix/gtk4-layout-port

Conversation

@Inuth0603
Copy link
Copy Markdown

@Inuth0603 Inuth0603 commented Feb 4, 2026

This PR ports the Calculate activity UI from GTK3 to GTK4/Sugar4. The math engine and parser remain unchanged; only the UI layer and event handling were updated.

What changed

  • Replaced Gtk.Table and deprecated packing APIs with Gtk.Grid and Gtk.Box
  • Removed legacy styling calls (modify_bg, modify_font, modify_base) and switched to semantic CSS classes:
    calc-button, calc-numpad-btn, calc-operator-btn, and calc-action-btn
  • Retained per-user XoColor styling for equation history and variable views using sugar_style.apply_css_to_widget()
  • Reworked the toolbar to use Sugar4 ToolbarBox / ToolbarButton
  • Updated toolbars.py to use set_child() for text fallback when SVG icons are missing
  • Migrated key handling to Gtk.EventControllerKey
  • Updated clipboard handling to GTK4’s async clipboard API
  • Added main.py for standalone local testing

Notes on standalone testing

A couple of visual issues are expected when running via main.py outside Sugar:

  • Buttons use the default GTK4 look because sugar-artwork does not yet provide the full GTK4 theme styling
  • Some toolbar icons may be missing outside Sugar and fall back to text; on the dark toolbar, those fallbacks can appear faint or mostly empty

These are standalone-testing limitations and should not affect behavior inside the Sugar desktop.

Testing

Tested on Debian. Layout, toolbar switching, and expression evaluation all work correctly, and syntax errors are still handled properly.

Screen.Recording.2026-03-15.054616.mp4

@Inuth0603 Inuth0603 marked this pull request as draft February 17, 2026 22:39
@Inuth0603 Inuth0603 force-pushed the fix/gtk4-layout-port branch 2 times, most recently from 67ac97e to d1ad88f Compare February 21, 2026 07:14
@Inuth0603 Inuth0603 marked this pull request as ready for review February 21, 2026 07:38
@Inuth0603 Inuth0603 force-pushed the fix/gtk4-layout-port branch from 6f0dd4d to ce1ad7f Compare February 23, 2026 21:01
@quozl quozl mentioned this pull request Mar 14, 2026
@Inuth0603 Inuth0603 force-pushed the fix/gtk4-layout-port branch from ce1ad7f to 35b9332 Compare March 15, 2026 00:22
This commit fully ports the Calculate activity to GTK4 and Sugar4.

- Port 'shareable_activity.py' with updated DBus and Sugar4 base classes.
- Rework 'layout.py' to use GTK4 box packing ('append', 'set_child') instead of deprecated containers like 'Gtk.Table'.
- Replace legacy per-widget styling ('modify_bg', 'modify_font') with semantic CSS classes ('calc-button', 'calc-numpad-btn', 'calc-operator-btn', 'calc-action-btn') to be painted by sugar-artwork's GTK4 theme.
- Use 'sugar_style.apply_css_to_widget()' for dynamic per-user XoColor styling on equation history and variable text views.
- Replace StackSwitcher with proper Sugar4 ToolbarBox architecture using ToolbarButton with icon resolution (local SVG fallback).
- Add EventControllerKey on text_entry and calculator buttons.
- Refactor 'toolbars.py' to gracefully render GTK4 toolbar items and correctly update text fallbacks when SVG icons are invalid.
- Port 'calculate.py' to use 'Gtk.EventControllerKey' for keystrokes and update clipboard operations to use GTK4 async mechanisms.
- Include 'main.py' standalone bootstrapper for isolated GTK4 testing.
@Inuth0603 Inuth0603 force-pushed the fix/gtk4-layout-port branch from 35b9332 to 6ccfee3 Compare March 15, 2026 00:41
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.

1 participant