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] add initial Gtk3 support #332

Merged
merged 23 commits into from Aug 3, 2014
Merged

[GTK] add initial Gtk3 support #332

merged 23 commits into from Aug 3, 2014

Conversation

sevoku
Copy link
Member

@sevoku sevoku commented May 15, 2014

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:

I 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.

@slluis
Copy link
Member

slluis commented May 24, 2014

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
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh... sure!

@sevoku
Copy link
Member Author

sevoku commented May 24, 2014

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.

@sevoku
Copy link
Member Author

sevoku commented May 30, 2014

Ok, now the last problem: completely different implementations!

Use "partial" keyword or create some base classes (for WidgetBackend, TextEntryBackend, LabelBackend,...)?

@slluis
Copy link
Member

slluis commented May 30, 2014

For which case is this?

@sevoku
Copy link
Member Author

sevoku commented May 30, 2014

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.

@sevoku
Copy link
Member Author

sevoku commented May 30, 2014

Some examples with WidgetBackend and GetPreferredSize:

  1. partial class: https://gist.github.com/sevoku/bd4a4e7b94ddf51acb3c
  2. rename WidgetBackend and subclass: https://gist.github.com/sevoku/93092e085c74bcc05a88
  3. WidgetBackend -> WidgetBackendGtk (toolkit specific) -> WidgetBackendBase: https://gist.github.com/sevoku/6751f676dd6041277bd6

@slluis
Copy link
Member

slluis commented Jun 1, 2014

Let's use a partial class.

@sevoku
Copy link
Member Author

sevoku commented Jun 1, 2014

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
@sevoku
Copy link
Member Author

sevoku commented Jun 8, 2014

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.

@slluis
Copy link
Member

slluis commented Jun 21, 2014

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.

@sevoku
Copy link
Member Author

sevoku commented Jun 21, 2014

Thanks! As I have written before, I'll maintain this part. No Problem!

@sevoku
Copy link
Member Author

sevoku commented Jul 16, 2014

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.

@Therzok
Copy link
Contributor

Therzok commented Jul 17, 2014

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
@slluis slluis merged commit 8e6a86a into mono:master Aug 3, 2014
@slluis
Copy link
Member

slluis commented Aug 3, 2014

Merged. Thanks!

@sevoku
Copy link
Member Author

sevoku commented Aug 4, 2014

Thanks! I'll keep an eye on it!

@sevoku sevoku deleted the gtk3 branch September 5, 2014 19:59
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.

None yet

3 participants