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

Sample.Gtk: build SourceGen separately #21

Open
wants to merge 36 commits into
base: master
Choose a base branch
from

Conversation

parhamsaremi
Copy link
Collaborator

@parhamsaremi parhamsaremi commented Apr 26, 2023

Build Controls.SourceGen.csproj before building Microsoft.Maui.Gtk.slnf. We have to do this since sometimes when building the Sample.Gtk project, the error below is shown. It's a random error that happens when building the Microsoft.Maui.Gtk.slnf but it doesn't happen in each build attempt.

CSC : error CS0006: Metadata file '/home/runner/work/maui/maui/.nuspec/Microsoft.Maui.Controls.SourceGen.dll' could not be found [/home/runner/work/maui/maui/src/Controls/samples/Controls.Sample.Gtk/Controls.Sample.Gtk.csproj]
    0 Warning(s)
    1 Error(s)

aarani and others added 30 commits March 8, 2023 23:14
We changed the dotnet version to 6.0.300 to ultimately use
GtkSharp pre-built packages instead of cloning the repo.

Co-authored-by: webwarrior-ws <reg@webwarrior.ws>
Co-authored-by: Parham Saremi <parhaamsaremi@gmail.com>
Error:
/home/runner/work/maui/maui/src/Controls/samples/Controls.Sample.Gtk/SimpleSampleApp/SimpleSampleGtkApplication.cs(28,5):
error CS0117: 'Box' does not contain a definition for 'Fill'
It was throwing some error in our PRs CI, and this
seems Microsoft-specific.
FontNamedSizeService is needed when using `Fontsize=Large` or
`Fontsize=Small` in Xaml files. Without this service, we get
runtime errors when trying to parse Xaml files that have
Fontsize attribute in them.
These changes are necessary for having access to MainWindow
in MauiGtkApplication. Initially, this field was always null
and was never set. We needed access to MainWindow to do
manual operations like resize on it because the applications
might want to specify custom size of the window.

Co-authored-by: webwarrior-ws <reg@webwarrior.ws>
When TRACE_ALLOCATION constant is defined, some debug borders
with width and heights is shown for layouts. By disabling them,
the debug values are removed from the final output.
Made label widget in Gtk respect LineBreakMode and MaxLines
properties, the way it does on other platforms. By doing this
labels won't crop text with dashes in any part of the word and
they keep the words complete.
These properties were added to ILabel interface, as it is in
MAUI main branch.
Layout size is messed up after window looses or gains focus.
Which is fixed by not returning the cached value.

Co-authored-by: webwarrior-ws <reg@webwarrior.ws>
Implement Connectivity for Gtk platform by porting code from
nblockchain/DotNetEssentials.
Implemented NavigationViewHandler for Gtk.
Made changes so that NavigationViewHandler is used for
NavigationPage in Gtk, instead of generic Page handler.
It is incomplete at the moment. Processing of navigation
events works, but toolbar is not implemented.

Co-authored-by: Parham <parhaamsaremi@gmail.com>
In order to have this new CI fragment pass we've had to
update many C# files.
Implement AlertManager for Gtk.
Implementation is not complete; alert dialogs and action sheets
are implemented, progress bar prompts are not. Also title bar
is not shown.
Layouts in Gtk now react to change in Visibility property.
This way we know exactly all the projects that are being
compiled.
Made date picker work, ported from [1].

But it gives errors in console and can crash[2] if opened/closed
many times.

[1] https://github.com/xamarin/Xamarin.Forms/blob/5.0.0/Xamarin.Forms.Platform.GTK/Controls/DatePicker.cs
[2] (TODO: file a bug in GtkSharp repo):

```
(GWallet.Frontend.Maui:110296): GLib-GObject-CRITICAL **: 12:14:36.625: g_object_remove_toggle_ref: assertion 'G_IS_OBJECT (object)' failed

(GWallet.Frontend.Maui:110296): GLib-GObject-CRITICAL **: 12:14:36.627: g_object_remove_toggle_ref: assertion 'G_IS_OBJECT (object)' failed
Marshaling button-press-event signal
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
GLib.MissingIntPtrCtorException: Unable to construct instance of type Microsoft.Maui.Platform.DatePickerWindow from native object handle. Instance of managed subclass may have been prematurely disposed.
   at GLib.ObjectManager.CreateObject(IntPtr raw)
   at GLib.Object.GetObject(IntPtr o, Boolean owned_ref)
   at GLib.Value.get_Val()
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
   at GLib.ExceptionManager.RaiseUnhandledException(Exception e, Boolean is_terminal)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
   at GLib.Application.Run(String program_name, String[] args)
   at GLib.Application.Run()
   at Microsoft.Maui.MauiGtkApplication.Launch(EventArgs args) in /home/ubuntu/geewallet-build/geewallet/dependencies/maui/src/Core/src/Platform/Gtk/MauiGtkApplication.cs:line 127
   at Microsoft.Maui.MauiGtkApplication.Run(String[] args) in /home/ubuntu/geewallet-build/geewallet/dependencies/maui/src/Core/src/Platform/Gtk/MauiGtkApplication.cs:line 40
   at GWallet.Frontend.Maui.Program.main(String[] _args) in /home/ubuntu/geewallet-build/geewallet/src/GWallet.Frontend.Maui/Platforms/Gtk/Program.fs:line 14
```

Co-authored-by: Parham <parhaamsaremi@gmail.com>
Fix potential exception if DatePicker is used
many times quickly:

```
    (GWallet.Frontend.Maui:110296): GLib-GObject-CRITICAL **: 12:14:36.625: g_object_remove_toggle_ref: assertion 'G_IS_OBJECT (object)' failed

    (GWallet.Frontend.Maui:110296): GLib-GObject-CRITICAL **: 12:14:36.627: g_object_remove_toggle_ref: assertion 'G_IS_OBJECT (object)' failed
    Marshaling button-press-event signal
    Exception in Gtk# callback delegate
      Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
    GLib.MissingIntPtrCtorException: Unable to construct instance of type Microsoft.Maui.Platform.DatePickerWindow from native object handle. Instance of managed subclass may have been prematurely disposed.
       at GLib.ObjectManager.CreateObject(IntPtr raw)
       at GLib.Object.GetObject(IntPtr o, Boolean owned_ref)
       at GLib.Value.get_Val()
       at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
       at GLib.ExceptionManager.RaiseUnhandledException(Exception e, Boolean is_terminal)
       at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
       at GLib.Application.Run(String program_name, String[] args)
       at GLib.Application.Run()
       at Microsoft.Maui.MauiGtkApplication.Launch(EventArgs args) in /home/ubuntu/geewallet-build/geewallet/dependencies/maui/src/Core/src/Platform/Gtk/MauiGtkApplication.cs:line 127
       at Microsoft.Maui.MauiGtkApplication.Run(String[] args) in /home/ubuntu/geewallet-build/geewallet/dependencies/maui/src/Core/src/Platform/Gtk/MauiGtkApplication.cs:line 40
       at GWallet.Frontend.Maui.Program.main(String[] _args) in /home/ubuntu/geewallet-build/geewallet/src/GWallet.Frontend.Maui/Platforms/Gtk/Program.fs:line 14
```

By using Hide instead of Destroy.
Fix position of calendar pop-up when opened more than one time.
Avoid excessive firing of OnDateTimeChanged events when
creating DatePickerWindow.
Update calendar properties SelectedDate, MinimumDate,
MaximumDate when opening calendar popup when it is already
created but hidden.
DatePicker window location was wrong when we didn't use
x11 GdkBackend. This problem was fixed by setting the
TransientFor property.

Co-authored-by: webwarrior-ws <reg@webwarrior.ws>
Replace deprecated methods.
Used Entry icon instead of defining a new button for datepicker
arrow.

Co-authored-by: webwarrior-ws <reg@webwarrior.ws>
Core(Gtk): implement date picker
Fix setting of style in widgets in certain cases (when widget's CSS path
contains spaces).
Add mappers for BorderColor and CornerRadius for Frame elements
so they can now have borders.
Fix fill in solid shapes like Ellipse or Rectangle.
Path elements are now being drawn.
Previously, Image class didn't work in maui code and after
setting the image nothing would appear.
When visibility for image or label (or other views) was set to
false, they stayed visible in the application.
webwarrior-ws and others added 5 commits April 3, 2023 19:35
Ported Launcher code from DotNetEssentials.
Implement tap/click gestures for Gtk.
Note that due to the way Gtk works only certain widgets can
respond to click events.
I changed ContentView to inherit from EventBox, so many
elements have this capability, including all layouts.
Still many widgets such as label for which adding tap gesture
recognizer will have no effect.
See
https://discourse.gnome.org/t/gtk-widget-mouse-down-event-does-not-seem-to-work/1699.
Implement WidthRequest and HeightRequest mappings for Image.
@parhamsaremi
Copy link
Collaborator Author

please review @aarani @knocte

@aarani
Copy link

aarani commented Apr 26, 2023

I get the goal but not sure I agree with the way you are trying to achieve it.

@parhamsaremi
Copy link
Collaborator Author

I get the goal but not sure I agree with the way you are trying to achieve it.

I agree with you that this is not ideal. Maybe we can consider this a workaround? I searched a lot and this was the best thing I could come up with. Do you have any other suggestions?

@aarani
Copy link

aarani commented Apr 26, 2023

I get the goal but not sure I agree with the way you are trying to achieve it.

I agree with you that this is not ideal. Maybe we can consider this a workaround? I searched a lot and this was the best thing I could come up with. Do you have any other suggestions?

Add a line in CI that builds this project.

@parhamsaremi
Copy link
Collaborator Author

Add a line in CI that builds this project.

Ok sure, I'll give it a try.

@knocte
Copy link
Member

knocte commented Apr 27, 2023

Below was the error:

What error? You don't explain what this error is, is it a runtime error?, compile time error?, how did you get it? I mean, what did you do to get it? how often do you get it (if not 100% of the time), etc

@parhamsaremi parhamsaremi force-pushed the check-ci-squashed-2 branch 2 times, most recently from 9eea9dd to d69270f Compare April 27, 2023 10:04
@parhamsaremi
Copy link
Collaborator Author

Below was the error:

What error? You don't explain what this error is, is it a runtime error?, compile time error?, how did you get it? I mean, what did you do to get it? how often do you get it (if not 100% of the time), etc

I improved the commit message and I believe it should be complete now. I also tested the latest state and it's all ok now.

Build Controls.SourceGen.csproj before building
Microsoft.Maui.Gtk.slnf. We have to do this since
sometimes when building the Sample.Gtk project, the error
below is shown. It's a random error that happens when
building the Microsoft.Maui.Gtk.slnf but it doesn't happen
in each build attempt.

```
CSC : error CS0006: Metadata file '/home/runner/work/maui/maui/.nuspec/Microsoft.Maui.Controls.SourceGen.dll' could not be found [/home/runner/work/maui/maui/src/Controls/samples/Controls.Sample.Gtk/Controls.Sample.Gtk.csproj]
    0 Warning(s)
    1 Error(s)
```
@parhamsaremi parhamsaremi changed the title Sample.Gtk: add SourceGen as ProjectReference Sample.Gtk: build SourceGen separately Apr 27, 2023
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

4 participants