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] add initial Gtk3 support #332
Conversation
Thanks for the contribution, awesome work! My main concern about the PR is the excessive use of #if to special case gtk3. It makes the code harder to read and to maintain. I'll add some comments with ideas for reducing those. Also, if I merge this PR I can't make any guarantee that the gtk3 won't break when doing changes for gtk2. I don't have an environment for testing on gtk3, so you'll have to keep an eye on this. |
TreeModel treeModel; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You only need one #if in the whole file if you do this:
#if XWT_GTK3
using TreeModel = ITreeModel
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... sure!
Oh wow! Many comments! Thanks! I'll comment everything asap! Keeping an eye on this will be no problem, if you merge this. I'm working on a bigger project and we'll prefer gtk3 on Linux and maybe take a look on gtk3 support for windows. |
…ic implementations
…gtk2/3) specific implementations CustomViewPort must be sealed because of the new adjustment properties for Gtk3
…2/3) specific implementations
Ok, now the last problem: completely different implementations! Use "partial" keyword or create some base classes (for WidgetBackend, TextEntryBackend, LabelBackend,...)? |
For which case is this? |
WidgetBackend: GetPreferredSize has a completely different implementation for Gtk3 and Gtk3 does not need/have HandleWidgetSizeRequested. TextEntryBackend/PasswordEntryBackend: completely different PlaceholderText implementations LabelBackend: Gtk3 handles wrapping and alignment correctly without the need to connect the expose and sizing events. |
Some examples with WidgetBackend and GetPreferredSize:
|
Let's use a partial class. |
Ok, here we go! The pattern is pretty simple. The shared code remains in original files and the toolkit specific code has been moved to new *Gtk[2|3].cs files. I've tried to minimize the changes to the original files by splitting some methods, too. |
Conflicts: TestApps/Samples/Samples/TextEntries.cs Xwt.Gtk/Xwt.GtkBackend/CanvasBackend.cs
Hi! I've merged recent changes from xwt/master to make it easier to merge the PR. Additionally I've added some BackgroundColor fixes and extended the Samples. |
The code looks ok to me now. I'm going to test my apps with this change to make sure it doesn't break anything and then I'll merge. Beware that you'll be responsible for the maintenance of the gtk3 port. I can't guarantee to keep the gtk3 project buildable while doing changes in the gtk2 support. |
Thanks! As I have written before, I'll maintain this part. No Problem! |
…e for canvas drawing
This PR needs some manual merging now. Please let me know, if I should merge master into this branch and/or if I should wait for you to merge some other PRs conflicting this one. |
This needs a rebase to be able to be merged. |
Conflicts: Xwt.Gtk/Xwt.Gtk.csproj Xwt.Gtk/Xwt.GtkBackend/GtkInterop.cs Xwt.Gtk/Xwt.GtkBackend/GtkWorkarounds.cs
Conflicts: Xwt.Gtk/Xwt.GtkBackend/Conversion.cs
Merged. Thanks! |
Thanks! I'll keep an eye on it! |
This pull request adds initial Gtk3 support and a Gtk3 test app (Gtk3Test).
(It is a follow up of #322, but with a separate branch in my repository)
To use the Gtk3 backend compile the Xwt.Gtk3 project and initialize Xwt with ToolkitType.Gtk3.
The new Xwt.Gtk3 project reuses all Xwt.Gtk sources, which have been modified for Gtk3 support (using conditional compiling by the XWT_GTK3 symbol set in Xwt.Gtk3).
The most important changes from Gtk2 to Gtk3 are based on the new sizing model (height-by-width, widh-by-height) eliminating the SizeRequested handlers/overrides.
In the Gtk3Test app almost everything is working like with Gtk2 except of:
PopoverBackend (TODO!): done in sevoku/xwt@9b586dfComboBoxes with icon (samples app): fixed by sevoku/xwt@78f999fI have tested everything on my development system with Ubuntu 14.04 with following versions:
Mono: 3.2.8+dfsg-4ubuntu1
Gtk3: 3.12.0-0ubuntu1-trusty0 (Gnome staging PPA)
gtk-sharp: 2.99.2-2ubuntu1
but it should work with all Gtk3 versions on Linux. TODO: Windows and Mac.