From 30f758d98422a65e02dbe075c9faad6038035914 Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Sun, 4 May 2014 17:30:26 +0200 Subject: [PATCH] gdk: Fix dll name and use a const for all DllImports in custom code In Windows builds of GTK+ 3.x, the dll filename for GDK is libgdk-3-0.dll. We use this opportunity to use a common const in the DllImport for all custom code. --- gdk/Color.cs | 2 +- gdk/Device.cs | 4 ++-- gdk/Display.cs | 6 +++--- gdk/DisplayManager.cs | 2 +- gdk/Event.cs | 2 +- gdk/Global.cs | 12 +++++++----- gdk/Keymap.cs | 4 ++-- gdk/Property.cs | 4 ++-- gdk/Rectangle.cs | 6 +++--- gdk/Screen.cs | 8 ++++---- gdk/TextProperty.cs | 2 +- gdk/Window.cs | 18 +++++++++--------- gdk/gdk-api.raw | 2 +- gdk/gdk-sharp.dll.config.in | 2 +- gtkdotnet/Graphics.cs | 12 +++++++----- gtkdotnet/gtk-dotnet.dll.config.in | 2 +- sources/sources.xml | 2 +- 17 files changed, 47 insertions(+), 43 deletions(-) diff --git a/gdk/Color.cs b/gdk/Color.cs index f4f7d166e..a57dbc04e 100644 --- a/gdk/Color.cs +++ b/gdk/Color.cs @@ -35,7 +35,7 @@ namespace Gdk { Pixel = 0; } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern uint gdk_color_hash(ref Gdk.Color raw); public override int GetHashCode() { diff --git a/gdk/Device.cs b/gdk/Device.cs index c46e9eaa9..16137ccfe 100644 --- a/gdk/Device.cs +++ b/gdk/Device.cs @@ -25,10 +25,10 @@ namespace Gdk { public partial class Device { - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_device_free_history(IntPtr events, int n_events); - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern bool gdk_device_get_history(IntPtr device, IntPtr window, uint start, uint stop, out IntPtr events, out int n_events); public TimeCoord[] GetHistory (Gdk.Window window, uint start, uint stop) diff --git a/gdk/Display.cs b/gdk/Display.cs index 02def9f86..871397281 100644 --- a/gdk/Display.cs +++ b/gdk/Display.cs @@ -26,7 +26,7 @@ namespace Gdk { public partial class Display { - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_display_get_pointer(IntPtr raw, IntPtr screen, out int x, out int y, out int mask); [Obsolete] @@ -36,7 +36,7 @@ namespace Gdk { mask = (Gdk.ModifierType) mask_as_int; } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_display_get_pointer(IntPtr raw, out IntPtr screen, out int x, out int y, out int mask); public void GetPointer(out Gdk.Screen screen, out int x, out int y, out Gdk.ModifierType mask) { @@ -66,7 +66,7 @@ namespace Gdk { GetPointer (out screen, out x, out y, out mod); } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gdk_display_list_devices (IntPtr raw); public Device[] ListDevices () diff --git a/gdk/DisplayManager.cs b/gdk/DisplayManager.cs index 3af24f519..a79a1ee33 100644 --- a/gdk/DisplayManager.cs +++ b/gdk/DisplayManager.cs @@ -25,7 +25,7 @@ namespace Gdk { public partial class DisplayManager { - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gdk_display_manager_list_displays (IntPtr raw); public Display[] ListDisplays () diff --git a/gdk/Event.cs b/gdk/Event.cs index 9b9561135..99d26cd1b 100644 --- a/gdk/Event.cs +++ b/gdk/Event.cs @@ -39,7 +39,7 @@ namespace Gdk { get { return raw; } } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gdk_event_get_type (); public static GLib.GType GType { diff --git a/gdk/Global.cs b/gdk/Global.cs index 37255aff8..357c799c3 100644 --- a/gdk/Global.cs +++ b/gdk/Global.cs @@ -26,7 +26,9 @@ namespace Gdk { public partial class Global { - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + internal const string GdkNativeDll = "libgdk-3-0.dll"; + + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gdk_list_visuals (); public static Visual[] ListVisuals () @@ -105,7 +107,7 @@ namespace Gdk { } } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern bool gdk_init_check(ref int argc, ref IntPtr argv); public static bool InitCheck (ref string[] argv) @@ -119,7 +121,7 @@ namespace Gdk { return result; } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_parse_args(ref int argc, ref IntPtr argv); public static void ParseArgs (ref string[] argv) @@ -132,7 +134,7 @@ namespace Gdk { argv = a.GetArgs (argc); } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_query_depths (out IntPtr depths, out int n_depths); public static int[] QueryDepths () @@ -144,7 +146,7 @@ namespace Gdk { Marshal.Copy (ptr, result, 0, count); return result; } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_query_visual_types (out IntPtr types, out int n_types); public static VisualType[] QueryVisualTypes () diff --git a/gdk/Keymap.cs b/gdk/Keymap.cs index d8b316c65..a87ebd677 100644 --- a/gdk/Keymap.cs +++ b/gdk/Keymap.cs @@ -26,7 +26,7 @@ namespace Gdk { public partial class Keymap { - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern bool gdk_keymap_get_entries_for_keycode(IntPtr raw, uint hardware_keycode, out IntPtr keys, out IntPtr keyvals, out int n_entries); public void GetEntriesForKeycode(uint hardware_keycode, out Gdk.KeymapKey[] keys, out uint[] keyvals) @@ -51,7 +51,7 @@ namespace Gdk { } } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern bool gdk_keymap_get_entries_for_keyval(IntPtr raw, uint keyval, out IntPtr keys, out int n_keys); public KeymapKey[] GetEntriesForKeyval (uint keyval) diff --git a/gdk/Property.cs b/gdk/Property.cs index 5c8c04781..5e901d6e1 100644 --- a/gdk/Property.cs +++ b/gdk/Property.cs @@ -26,7 +26,7 @@ namespace Gdk { public partial class Property { - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_property_change(IntPtr window, IntPtr property, IntPtr type, int format, int mode, out byte data, int nelements); [Obsolete ("Replaced by corrected overload with data parameter")] @@ -36,7 +36,7 @@ namespace Gdk { return data; } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern bool gdk_property_get(IntPtr window, IntPtr property, IntPtr type, UIntPtr offset, UIntPtr length, bool pdelete, out IntPtr actual_property_type, out int actual_format, out int actual_length, out IntPtr data); public static bool Get(Gdk.Window window, Gdk.Atom property, Gdk.Atom type, ulong offset, ulong length, int pdelete, out Gdk.Atom actual_property_type, out int actual_format, out int actual_length, out byte[] data) { diff --git a/gdk/Rectangle.cs b/gdk/Rectangle.cs index deebb6852..debc1693a 100644 --- a/gdk/Rectangle.cs +++ b/gdk/Rectangle.cs @@ -219,7 +219,7 @@ namespace Gdk { return Offset (rect, dr.X, dr.Y); } - [DllImport("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gdk_rectangle_get_type(); public static GLib.GType GType { @@ -230,7 +230,7 @@ namespace Gdk { } } - [DllImport("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_rectangle_union (ref Rectangle src1, ref Rectangle src2, out Rectangle dest); public Gdk.Rectangle Union (Gdk.Rectangle src) @@ -240,7 +240,7 @@ namespace Gdk { return dest; } - [DllImport("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern bool gdk_rectangle_intersect (ref Rectangle src1, ref Rectangle src2, out Rectangle dest); public bool Intersect (Gdk.Rectangle src, out Gdk.Rectangle dest) diff --git a/gdk/Screen.cs b/gdk/Screen.cs index c6c59262a..84412644b 100644 --- a/gdk/Screen.cs +++ b/gdk/Screen.cs @@ -25,7 +25,7 @@ namespace Gdk { public partial class Screen { - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gdk_screen_get_toplevel_windows (IntPtr raw); public Window[] ToplevelWindows @@ -42,7 +42,7 @@ namespace Gdk { } } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gdk_screen_list_visuals (IntPtr raw); public Visual[] ListVisuals () @@ -57,10 +57,10 @@ namespace Gdk { return result; } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gdk_screen_get_font_options(IntPtr raw); - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_screen_set_font_options(IntPtr raw, IntPtr options); [GLib.Property ("font-options")] diff --git a/gdk/TextProperty.cs b/gdk/TextProperty.cs index 578502bfb..ccfc8cbeb 100644 --- a/gdk/TextProperty.cs +++ b/gdk/TextProperty.cs @@ -26,7 +26,7 @@ namespace Gdk { public class TextProperty { - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern int gdk_text_property_to_utf8_list_for_display(IntPtr display, IntPtr encoding, int format, byte[] text, int length, out IntPtr list); public static string[] ToStringListForDisplay (Gdk.Display display, Gdk.Atom encoding, int format, byte[] text, int length) diff --git a/gdk/Window.cs b/gdk/Window.cs index 7f3f017f3..22898d52a 100644 --- a/gdk/Window.cs +++ b/gdk/Window.cs @@ -32,10 +32,10 @@ namespace Gdk { public Window (Gdk.Window parent, Gdk.WindowAttr attributes, Gdk.WindowAttributesType attributes_mask) : this (parent, attributes, (int)attributes_mask) {} - [DllImport("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gdk_window_get_background_pattern(IntPtr raw); - [DllImport("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_window_set_background_pattern(IntPtr raw, IntPtr pattern); public Cairo.Pattern BackgroundPattern { @@ -49,7 +49,7 @@ namespace Gdk { } } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gdk_window_get_children(IntPtr raw); public Window[] Children { @@ -65,7 +65,7 @@ namespace Gdk { } } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_window_set_icon_list(IntPtr raw, IntPtr pixbufs); public Pixbuf[] IconList { @@ -80,7 +80,7 @@ namespace Gdk { [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr g_object_ref (IntPtr raw); - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_window_destroy(IntPtr raw); public void Destroy () @@ -97,10 +97,10 @@ namespace Gdk { gdk_window_move_resize (Handle, rect.X, rect.Y, rect.Width, rect.Height); } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_window_get_user_data (IntPtr raw, out IntPtr data); - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_window_set_user_data(IntPtr raw, IntPtr user_data); public IntPtr UserData { get { @@ -113,10 +113,10 @@ namespace Gdk { } } - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_window_add_filter (IntPtr handle, GdkSharp.FilterFuncNative wrapper, IntPtr data); - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (Global.GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] static extern void gdk_window_remove_filter (IntPtr handle, GdkSharp.FilterFuncNative wrapper, IntPtr data); static IDictionary filter_all_hash; diff --git a/gdk/gdk-api.raw b/gdk/gdk-api.raw index b675b8c3f..0dc3efc34 100644 --- a/gdk/gdk-api.raw +++ b/gdk/gdk-api.raw @@ -6,7 +6,7 @@ Please DO NOT MODIFY THIS FILE, modify .metadata files instead. --> - + diff --git a/gdk/gdk-sharp.dll.config.in b/gdk/gdk-sharp.dll.config.in index 32aa98f67..5f44e8143 100644 --- a/gdk/gdk-sharp.dll.config.in +++ b/gdk/gdk-sharp.dll.config.in @@ -2,6 +2,6 @@ - + diff --git a/gtkdotnet/Graphics.cs b/gtkdotnet/Graphics.cs index 933138120..6199b219c 100644 --- a/gtkdotnet/Graphics.cs +++ b/gtkdotnet/Graphics.cs @@ -30,22 +30,24 @@ using System.Runtime.InteropServices; namespace Gtk.DotNet { public class Graphics { + + private const string GdkNativeDll = "libgdk-3-0.dll"; private Graphics () {} - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr gdk_win32_drawable_get_handle(IntPtr raw); - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr gdk_win32_hdc_get(IntPtr drawable, IntPtr gc, int usage); - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] internal static extern void gdk_win32_hdc_release(IntPtr drawable,IntPtr gc,int usage); - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr gdk_x11_drawable_get_xdisplay (IntPtr raw); - [DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport (GdkNativeDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr gdk_x11_drawable_get_xid (IntPtr raw); public static System.Drawing.Graphics FromDrawable (Gdk.Window drawable) diff --git a/gtkdotnet/gtk-dotnet.dll.config.in b/gtkdotnet/gtk-dotnet.dll.config.in index f4c0c10cc..175abae20 100644 --- a/gtkdotnet/gtk-dotnet.dll.config.in +++ b/gtkdotnet/gtk-dotnet.dll.config.in @@ -1,3 +1,3 @@ - + diff --git a/sources/sources.xml b/sources/sources.xml index 9cae2a09b..67d3151c6 100644 --- a/sources/sources.xml +++ b/sources/sources.xml @@ -89,7 +89,7 @@ - + gdkalias.h