Skip to content
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

GTK 4 support #221

Merged
merged 9 commits into from
Feb 27, 2021
Merged

GTK 4 support #221

merged 9 commits into from
Feb 27, 2021

Conversation

amolenaar
Copy link
Member

@amolenaar amolenaar commented Feb 24, 2021

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes

The change

Gaphas works for GTK+ 3. This PR adds support for GTK 4 -- without breaking backwards compatibility.

Where there are incompatibilities between the GTK 3 and 4 api, a check for Gtk.get_major_version() == 3 is done.

Tests can be executed with GTK 4 by running TEST_GTK_VERSION=4.0 pytest.

Issue Number: gaphor/gaphor#618

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

In GTK 4, the canvas is a lot more responsive, on macOS at least.

Copy link
Member

@danyeaw danyeaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good!

I am getting a few warnings while running the demo:
Gtk-CRITICAL **: 21:27:25.049: gtk_event_controller_get_propagation_phase: assertion 'GTK_IS_EVENT_CONTROLLER (controller)' failed

I am not sure if it is a setup issue on my side, but the demo loads ok besides that.

Should we wait until a pygobject version with support is released?

@amolenaar
Copy link
Member Author

I haven't seen that warning.

Should we wait until a pygobject version with support is released?

Although it works fine for both GTK+ 3 and GTK 4, I think we do not want to depend on a master branch of PyGObject. We'd better wait for an official release.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 26, 2021

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 1.37%.

Quality metrics Before After Change
Complexity 3.11 ⭐ 3.58 ⭐ 0.47 👎
Method Length 36.57 ⭐ 38.29 ⭐ 1.72 👎
Working memory 7.18 🙂 7.48 🙂 0.30 👎
Quality 77.39% 76.02% -1.37% 👎
Other metrics Before After Change
Lines 1768 1869 101
Changed files Quality Before Quality After Quality Change
examples/simple-box.py 78.08% ⭐ 78.08% ⭐ 0.00%
gaphas/segment.py 67.45% 🙂 67.27% 🙂 -0.18% 👎
gaphas/aspect/handlemove.py 79.22% ⭐ 77.28% ⭐ -1.94% 👎
gaphas/tool/hover.py 93.75% ⭐ 90.61% ⭐ -3.14% 👎
gaphas/tool/itemtool.py 66.11% 🙂 65.55% 🙂 -0.56% 👎
gaphas/tool/placement.py 80.75% ⭐ 79.12% ⭐ -1.63% 👎
gaphas/tool/rubberband.py 79.95% ⭐ 78.85% ⭐ -1.10% 👎
gaphas/tool/scroll.py 88.48% ⭐ 84.95% ⭐ -3.53% 👎
gaphas/tool/viewfocus.py 96.59% ⭐ 92.75% ⭐ -3.84% 👎
gaphas/tool/zoom.py 78.11% ⭐ 76.48% ⭐ -1.63% 👎
gaphas/view/gtkview.py 74.21% 🙂 71.50% 🙂 -2.71% 👎
gaphas/view/scrolling.py 65.98% 🙂 66.51% 🙂 0.53% 👍
tests/init.py 96.51% ⭐ 92.38% ⭐ -4.13% 👎
tests/conftest.py 95.64% ⭐ 92.73% ⭐ -2.91% 👎
tests/test_tool_hover.py 91.54% ⭐ 91.05% ⭐ -0.49% 👎
tests/test_tool_item.py 88.09% ⭐ 88.46% ⭐ 0.37% 👍
tests/test_tool_placement.py 94.41% ⭐ 93.72% ⭐ -0.69% 👎
tests/test_tool_scroll.py 93.10% ⭐ 92.33% ⭐ -0.77% 👎
tests/test_tool_zoom.py 92.12% ⭐ 91.52% ⭐ -0.60% 👎
tests/test_view.py 88.91% ⭐ 82.57% ⭐ -6.34% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
gaphas/view/gtkview.py GtkView.update_back_buffer 28 😞 265 ⛔ 11 😞 29.80% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
gaphas/tool/itemtool.py handle_at_point 18 🙂 151 😞 10 😞 46.38% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/tool/itemtool.py on_drag_begin 9 🙂 144 😞 15 😞 46.90% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/view/gtkview.py GtkView.__init__ 4 ⭐ 167 😞 15 😞 49.36% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/segment.py LineSegment.split_segment 6 ⭐ 205 ⛔ 11 😞 50.20% 🙂 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

@amolenaar
Copy link
Member Author

@danyeaw I changed the default PyGObject version back to stable. I added a separate job to test with GTK 4. It's using Fedora, since it already ships GTK 4. I think now it's safe to merge.

@danyeaw danyeaw merged commit 12052d0 into master Feb 27, 2021
@danyeaw danyeaw deleted the gtk4 branch February 27, 2021 13:56
@danyeaw
Copy link
Member

danyeaw commented Feb 27, 2021

Nice one @amolenaar 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants