Skip to content

Commit

Permalink
Remove the Gdk.Key enum now that the constants from gir.core can be used
Browse files Browse the repository at this point in the history
Gdk.Key is now just a wrapper type around the uint key value for better type safety
  • Loading branch information
cameronwhite committed Dec 26, 2024
1 parent ae7631c commit a767c4a
Show file tree
Hide file tree
Showing 28 changed files with 95 additions and 1,438 deletions.
5 changes: 3 additions & 2 deletions Pinta.Core/Classes/BaseTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ public virtual IEnumerable<IToolHandle> Handles
=> Enumerable.Empty<IToolHandle> ();

/// <summary>
/// The shortcut key used to activate this tool in the toolbox. Return 0 for no shortcut key.
/// The shortcut key used to activate this tool in the toolbox.
/// Return Gdk.Key.Invalid for no shortcut key.
/// </summary>
public virtual Gdk.Key ShortcutKey
=> 0;
=> Gdk.Key.Invalid;

/// <summary>
/// Affects the order of the tool in the toolbox. Lower numbers will appear first.
Expand Down
19 changes: 0 additions & 19 deletions Pinta.Core/Extensions/GdkExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ public static bool IsLeftMousePressed (this Gdk.ModifierType m)
public static bool IsRightMousePressed (this Gdk.ModifierType m)
=> m.HasFlag (Gdk.ModifierType.Button3Mask);

/// <summary>
/// Returns whether this key is a Ctrl key (or the Cmd key on macOS).
/// </summary>
public static bool IsControlKey (this Gdk.Key key)
{
if (PintaCore.System.OperatingSystem == OS.Mac)
return key == Gdk.Key.Meta_L || key == Gdk.Key.Meta_R;
else
return key == Gdk.Key.Control_L || key == Gdk.Key.Control_R;
}

/// <summary>
/// Returns whether any of the Ctrl/Cmd/Shift/Alt modifiers are active.
/// This prevents Caps Lock, Num Lock, etc from appearing as active modifier keys.
Expand Down Expand Up @@ -185,14 +174,6 @@ public static Gdk.Texture CreateIconWithShape (
return Gdk.Texture.NewForPixbuf (i.ToPixbuf ());
}

public static Gdk.Key ToUpper (this Gdk.Key k1)
{
if (Enum.TryParse (k1.ToString ().ToUpperInvariant (), out Gdk.Key result))
return result;
else
return k1;
}

// TODO-GTK4 (bindings, unsubmitted) - need gir.core async bindings for Gdk.Clipboard
public static Task<Gdk.Texture?> ReadTextureAsync (this Gdk.Clipboard clipboard)
{
Expand Down
Loading

0 comments on commit a767c4a

Please sign in to comment.