Skip to content

Commit

Permalink
Update to the latest GtkSharp version
Browse files Browse the repository at this point in the history
This fixes the crashes with Gdk.DefaultSeat and lets us move away from the deprecated API for accessing the mouse position.
  • Loading branch information
cameronwhite committed Mar 8, 2021
1 parent c515977 commit e7fc021
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 38 deletions.
12 changes: 12 additions & 0 deletions Pinta.Core/Extensions/GdkExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,5 +269,17 @@ public static Key ToUpper (this Key k1)

return k1;
}

public static void GetWidgetPointer (Gtk.Widget widget, out int x, out int y, out Gdk.ModifierType mask)
{
var pointer = widget.Display.DefaultSeat.Pointer;
widget.Window.GetDevicePosition (pointer, out x, out y, out mask);
}

public static void GetWindowPointer (Gdk.Window window, out int x, out int y, out Gdk.ModifierType mask)
{
var pointer = window.Display.DefaultSeat.Pointer;
window.GetDevicePosition (pointer, out x, out y, out mask);
}
}
}
7 changes: 0 additions & 7 deletions Pinta.Core/Extensions/ObsoleteExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ public static void AddToIconFactory (IconFactory factory, string stock_id, IconS
public static void AddDefaultToIconFactory (IconFactory factory)
=> factory.AddDefault ();

// https://github.com/GtkSharp/GtkSharp/issues/131
public static Gdk.Window GetWindowPointer (Gdk.Window window, out int x, out int y, out ModifierType mask)
=> window.GetPointer (out x, out y, out mask);

public static void GetWidgetPointer (Widget widget, out int x, out int y)
=> widget.GetPointer (out x, out y);

public static FontDescription GetStyleContextFont (StyleContext context, StateFlags flags)
=> context.GetFont (flags);
}
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Core/Pinta.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Product />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.22.25.128" />
<PackageReference Include="GtkSharp" Version="3.24.24.4" />
<PackageReference Include="NGettext" Version="0.6.6" />
<PackageReference Include="SharpZipLib" Version="1.3.1" />
<PackageReference Include="ParagonClipper" Version="6.4.2" />
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Docking/Pinta.Docking.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<Product />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.22.25.128" />
<PackageReference Include="GtkSharp" Version="3.24.24.4" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions Pinta.Effects/Dialogs/Effects.CurvesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void HandleDrawingMotionNotifyEvent (object o, Gtk.MotionNotifyEventArgs
{
int x, y;
Gdk.ModifierType mask;
ObsoleteExtensions.GetWindowPointer (drawing.Window, out x, out y, out mask);
GdkExtensions.GetWindowPointer (drawing.Window, out x, out y, out mask);

if (x < 0 || x >= size || y < 0 || y >=size)
return;
Expand All @@ -224,7 +224,7 @@ private void HandleDrawingButtonPressEvent (object o, Gtk.ButtonPressEventArgs a
{
int x, y;
Gdk.ModifierType mask;
ObsoleteExtensions.GetWindowPointer (drawing.Window, out x, out y, out mask);
GdkExtensions.GetWindowPointer (drawing.Window, out x, out y, out mask);

if (args.Event.Button == 1) {
AddControlPoint (x, y);
Expand Down Expand Up @@ -265,7 +265,7 @@ private void DrawPointerCross (Context g)
{
int x, y;
Gdk.ModifierType mask;
ObsoleteExtensions.GetWindowPointer (drawing.Window, out x, out y, out mask);
GdkExtensions.GetWindowPointer (drawing.Window, out x, out y, out mask);

if (x >= 0 && x < size && y >= 0 && y < size) {
g.LineWidth = 0.5;
Expand Down Expand Up @@ -330,7 +330,7 @@ private void DrawControlPoints (Context g)
{
int x, y;
Gdk.ModifierType mask;
ObsoleteExtensions.GetWindowPointer (drawing.Window, out x, out y, out mask);
GdkExtensions.GetWindowPointer (drawing.Window, out x, out y, out mask);

var infos = GetDrawingInfos ();

Expand Down
2 changes: 1 addition & 1 deletion Pinta.Effects/Pinta.Effects.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Product />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.22.25.128" />
<PackageReference Include="GtkSharp" Version="3.24.24.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Pinta.Core\Pinta.Core.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Gui.Widgets/Pinta.Gui.Widgets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Product />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.22.25.128" />
<PackageReference Include="GtkSharp" Version="3.24.24.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Pinta.Core\Pinta.Core.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Gui.Widgets/Widgets/Canvas/CanvasWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public bool IsMouseOnCanvas {
get {
// Get the position of the mouse pointer relative
// to canvas scrolled window top-left corner
ObsoleteExtensions.GetWidgetPointer (scrolled_window, out var x, out var y);
GdkExtensions.GetWidgetPointer (scrolled_window, out int x, out int y, out var mask);

// Check if the pointer is on the canvas
return (x > 0) && (x < scrolled_window.Allocation.Width) &&
Expand Down
6 changes: 3 additions & 3 deletions Pinta.Gui.Widgets/Widgets/ColorGradientWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private int FindValueIndex (int y)

private void HandleMotionNotifyEvent (object o, MotionNotifyEventArgs args)
{
ObsoleteExtensions.GetWindowPointer (Window, out var px, out var py, out var mask);
GdkExtensions.GetWindowPointer (Window, out var px, out var py, out var mask);

var index = FindValueIndex (py);
py = (int) NormalizeY (index, py);
Expand Down Expand Up @@ -199,7 +199,7 @@ private void HandleLeaveNotifyEvent (object o, LeaveNotifyEventArgs args)

private void HandleButtonPressEvent (object o, ButtonPressEventArgs args)
{
ObsoleteExtensions.GetWindowPointer (Window, out var px, out var py, out var mask);
GdkExtensions.GetWindowPointer (Window, out var px, out var py, out var mask);

var index = FindValueIndex ((int) py);

Expand Down Expand Up @@ -227,7 +227,7 @@ private void DrawGradient (Context g)

private void DrawTriangles (Context g)
{
ObsoleteExtensions.GetWindowPointer (Window, out var px, out var py, out var mask);
GdkExtensions.GetWindowPointer (Window, out var px, out var py, out var mask);

var rect = GradientRectangle;
var all = Allocation.ToCairoRectangle ();
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Resources/Pinta.Resources.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.22.25.128" />
<PackageReference Include="GtkSharp" Version="3.24.24.4" />
</ItemGroup>
<ItemGroup>
<Content Include="icons/hicolor/16x16/*/*">
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Tools/Pinta.Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Product />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.22.25.128" />
<PackageReference Include="GtkSharp" Version="3.24.24.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Pinta.Core\Pinta.Core.csproj" />
Expand Down
20 changes: 6 additions & 14 deletions Pinta/Pinta.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

</PropertyGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.22.25.128" />
<PackageReference Include="GtkSharp" Version="3.24.24.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Pinta.Core\Pinta.Core.csproj" />
Expand All @@ -35,24 +35,16 @@

<!-- Run msgfmt on our translation (po) files -->
<ItemGroup>
<Translation Include="../po/*.po"/>
<Translation Include="../po/*.po" />
</ItemGroup>
<Target Name="CompileTranslations"
BeforeTargets="Build"
Condition="'$(BuildTranslations)' == 'true'"
Inputs="@(Translation)"
Outputs="$(OutputPath)/locale/%(Translation.Filename)/LC_MESSAGES/pinta.mo">
<Target Name="CompileTranslations" BeforeTargets="Build" Condition="'$(BuildTranslations)' == 'true'" Inputs="@(Translation)" Outputs="$(OutputPath)/locale/%(Translation.Filename)/LC_MESSAGES/pinta.mo">

<MakeDir Directories="$(OutputPath)/locale/%(Translation.Filename)/LC_MESSAGES" />
<Exec Command='msgfmt "%(Translation.FullPath)" -o "$(OutputPath)/locale/%(Translation.Filename)/LC_MESSAGES/pinta.mo"' />
<Exec Command="msgfmt &quot;%(Translation.FullPath)&quot; -o &quot;$(OutputPath)/locale/%(Translation.Filename)/LC_MESSAGES/pinta.mo&quot;" />
</Target>

<!-- Include the compiled translation files when publishing. -->
<Target Name="PublishTranslations"
AfterTargets="Publish"
Condition="'$(BuildTranslations)' == 'true'">
<Copy
SourceFiles="$(OutputPath)/locale/%(Translation.Filename)/LC_MESSAGES/pinta.mo"
DestinationFiles="$(PublishDir)/locale/%(Translation.Filename)/LC_MESSAGES/pinta.mo" />
<Target Name="PublishTranslations" AfterTargets="Publish" Condition="'$(BuildTranslations)' == 'true'">
<Copy SourceFiles="$(OutputPath)/locale/%(Translation.Filename)/LC_MESSAGES/pinta.mo" DestinationFiles="$(PublishDir)/locale/%(Translation.Filename)/LC_MESSAGES/pinta.mo" />
</Target>
</Project>
6 changes: 3 additions & 3 deletions tests/Pinta.Core.Tests/Pinta.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.22.25.128" />
<PackageReference Include="NUnit" Version="3.13.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="GtkSharp" Version="3.24.24.4" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
</ItemGroup>

Expand Down

0 comments on commit e7fc021

Please sign in to comment.