-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port to GTK4 #484
base: test
Are you sure you want to change the base?
Port to GTK4 #484
Conversation
MostlyKIGuess
commented
Feb 11, 2025
- The messy branch with so many commits, I wanted to see the overall changes being made, and probably needed some suggestions on faster testing.
Signed-off-by: Chihurumnaya Ibiam <[email protected]>
Use of python3-six is now redundant per https://wiki.debian.org/Python3-six-removal
Signed-off-by: Chihurumnaya Ibiam <[email protected]>
…0 on Debian/Ubuntu
- Replace deprecated Gtk.Popover methods with GTK4 equivalents - Update window positioning and menu handling for GTK4 - Add Gtk.EventControllerMotion for mouse event handling - Update add_item method to use append instead of pack_start - Remove deprecated transient_for handling
- Replace deprecated Gtk.VBox and Gtk.HBox with Gtk.Box - Update widget packing methods from pack_start to append - Use set_visible(True) instead of show() - Update event handling methods to use set_state_flags and unset_state_flags - Maintain existing comments and documentation
- Replace deprecated Gtk.VBox, Gtk.HBox, Gtk.Alignment, Gtk.HSeparator, and Gtk.HButtonBox with Gtk.Box and Gtk.Separator - Update widget packing methods from pack_start to append - Use set_visible(True) instead of show() - Update event handling methods to use set_state_flags and unset_state_flags - Update set_child for Gtk.Button instead of set_image - Maintain existing comments and documentation
- Replace deprecated Gtk.MenuItem with Gtk.ListBox and Gtk.ListBoxRow - Replace deprecated Gtk.EventBox with Gtk.Box - Replace deprecated Gtk.VBox and Gtk.HBox with Gtk.Box - Update widget packing methods from pack_start to append - Use set_visible(True) instead of show() - Update event handling methods to use set_state_flags and unset_state_flags
- Replace deprecated Gtk.ToolButton with Gtk.Button - Update methods to use Gtk.Button APIs
…oolbarbox classes
- Replaced deprecated `Gtk.HBox` and `Gtk.HButtonBox` with `Gtk.Box` with appropriate orientation. - Updated widget packing methods to use `append`. - Used `set_visible(True)` instead of `show()`. - Updated event handling methods to use `set_state_flags` and `unset_state_flags` for state changes.
…tton, and ToolComboBox
- Replaced deprecated `Gtk.Toolbar` with `Gtk.Box` and updated orientation. - Replaced deprecated `Gtk.ToolItem` with `Gtk.Box` and updated orientation. - Replaced deprecated `Gtk.SeparatorToolItem` with `Gtk.Separator`. - Updated widget packing methods to use `append`. - Used `set_visible(True)` instead of `show()`. - Updated screen dimension handling for GTK4.
refactor: Replace deprecated Gtk.AccelGroup with Gtk.ShortcutController and update monitor geometry handling
## Activity & Window Updates: - Removed deprecated GTK3 methods such as `Gtk.main_quit` and `get_window()` from `activity.py`. - Updated `activity.py` to use `GLib.MainLoop` for running and quitting the main loop. - Adjusted `window.py` to follow GTK4 API patterns and layout changes. ## Widget & Signal Refactoring: - Modified `widgets.py` and `graphics` modules (`radiopalette.py`, `radiotoolbutton.py`) to remove reliance on deprecated signals such as “hierarchy-changed”. - Replaced GTK3 container iteration (e.g. `get_children()`) with GTK4-compatible approaches (using `get_first_child()/get_next_sibling()` or iterating directly). ## Accelerator Implementation: - In `toolbutton.py`, removed the legacy `Gtk.AccelGroup` API and replaced it with a new GTK4-based accelerator implementation. - Added `_add_accelerator_gtk4()` that leverages `Gtk.ShortcutTrigger`, `Gtk.CallbackAction`, and `Gtk.ShortcutController` to set up accelerators. - Updated accelerator property notifications to re-apply controllers as needed. ## Palette & PaletteMenu Adjustments: - Updated `palette.py`, `palettemenu.py`, and `palettewindow.py` to reflect GTK4 widget parenting and container APIs. - Touched `menuitem.py` to ensure GTK4 layout and actions function as intended. ## ToolbarBox and Others: - In `toolbarbox.py`, ensured that all toolbar components are arranged as per the GTK4 style guidelines. ## Additional Fixes: - Addressed GDK cursor warnings related to GTK4 theme sizes. - Handled session manager warnings by ensuring that components expect the absence of `SESSION_MANAGER`.
- GTK4 Update remains
1. Event Handling & Window System - Replaced deprecated GdkWindow APIs with new GdkSurface APIs in GTK4 - Updated event handling code to use GTK4's new event model - Added conditional compilation (#if GTK_CHECK_VERSION(4,0,0)) blocks to handle API differences - Replaced direct event field access with accessor functions (e.g., gdk_event_get_position) - Updated X11-specific code to use the new gdk/x11/gdkx.h header path 2. Cursor Tracking - Modernized cursor visibility tracking for GTK4 - Updated surface/window management code to work with both GTK3 and GTK4 - Replaced deprecated gdk_threads_* functions with their GTK4 equivalents - Added proper cleanup and resource management for surfaces 3. Event Controllers - Updated touch and gesture event handling for GTK4's new event model - Implemented proper event propagation and handling - Added support for GTK4's new event controller system - Maintained backwards compatibility with GTK3's event system 4. Clipboard Handling - Created compatibility layer for clipboard operations between GTK3 and GTK4 - Added stub implementation for GTK4 clipboard API - Defined compatibility types and functions for smooth transition 5. Window Management - Updated window positioning code to work with GTK4's new coordinate system - Fixed window property handling for both GTK versions - Improved error handling and reporting 6. Build System - Updated configure.ac to properly detect and use GTK4 - Added version-specific compiler flags and dependencies - Updated pkg-config requirements 7. Code Structure - Improved code organization with better separation of GTK3/GTK4 specific code - Added extensive documentation for version-specific implementations - Cleaned up header includes and dependencies 8. Documentation - Added comments explaining version-specific code paths - Updated function documentation to reflect API changes - Added migration notes for downstream applications Technical Details: Event Handling: - Replaced event->type direct access with gdk_event_get_event_type() - Updated event coordinate handling for GTK4's new coordinate system - Added proper null checking and error handling for event access Window Management: - Implemented proper surface lifecycle management - Updated window positioning code to use GTK4's new APIs - Added proper cleanup for window resources Event Controllers: - Updated controller attachment and management - Improved event propagation handling - Added proper cleanup for controllers The changes maintain backwards compatibility where possible while providing a clear upgrade path to GTK4. Version-specific code is clearly marked and documented to aid in future maintenance. Testing: - Tested on both GTK3 and GTK4 environments - Verified window management functionality - Confirmed event handling works correctly - Validated cursor tracking behavior - Checked clipboard operations Note: Some GTK4 features (particularly advanced clipboard operations) are currently stubbed out and will need further implementation in future updates.
@quozl could you perhaps make this in a system where you can test it ( the current error on hello-world is very weird)?
as well as SugarExt is not discovered ( i am not sure why this happens as well) but to fix that I update the path:
Info about the Error:
activity_button = ActivityToolbarButton(self)
|
I'm sure you'll think of something. What is the stack trace of the segmentation fault? Have you made sure not to install anything except the toolkit and dependencies on your test system? |
Yes, the debian system only has installation things from portinggt4 md file. I will get back to you on the trace |
Here's the full log from the start of application:
|
…acks - In sugar3/graphics/alert.py, update the label wrapping call by replacing the deprecated set_line_wrap() with set_wrap(). - In sugar3/graphics/palettewindow.py, change the connection for the 'clicked' signal in WidgetInvoker so that it now uses __clicked_cb (for non‐event driven activations) instead of __click_event_cb. This ensures the intended callback is invoked for user interactions