From 7552545b46f8e1e364d99d0f68008a4e1abe10a1 Mon Sep 17 00:00:00 2001 From: Christian Hoff Date: Sun, 30 Aug 2009 19:14:00 +0000 Subject: [PATCH] 2009-08-30 Christian Hoff * gtk/StatusIcon.custom: Use managed code to pass the address of gtk_status_icon_position_menu to gtk_menu_popup. svn path=/trunk/gtk-sharp/; revision=140939 --- ChangeLog | 5 +++++ gtk/StatusIcon.custom | 15 ++++++++++++--- gtk/glue/Makefile.am | 1 - gtk/glue/statusicon.c | 37 ------------------------------------- 4 files changed, 17 insertions(+), 41 deletions(-) delete mode 100644 gtk/glue/statusicon.c diff --git a/ChangeLog b/ChangeLog index 65051f53a..710b01d36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-30 Christian Hoff + + * gtk/StatusIcon.custom: Use managed code to pass the address of + gtk_status_icon_position_menu to gtk_menu_popup. + 2009-08-19 Christian Hoff * generator/*.cs: Add the "partial" keyword to each generated class, diff --git a/gtk/StatusIcon.custom b/gtk/StatusIcon.custom index 5ad48a1c6..0caf32f8e 100644 --- a/gtk/StatusIcon.custom +++ b/gtk/StatusIcon.custom @@ -26,12 +26,21 @@ return GetGeometry (out junk, out area, out orientation); } - [DllImport("gtksharpglue-2")] - static extern void gtksharp_gtk_status_icon_present_menu (IntPtr raw, IntPtr menu, uint button, uint activate_time); + [UnmanagedFunctionPointer (CallingConvention.Cdecl)] + delegate void MenuPositionFuncNative (IntPtr menu, out int x, out int y, out bool push_in, IntPtr user_data); + + static MenuPositionFuncNative StatusIconPositionMenuFunc = null; + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_menu_popup (IntPtr menu, IntPtr parent_menu_shell, IntPtr parent_menu_item, MenuPositionFuncNative func, IntPtr data, uint button, uint activate_time); public void PresentMenu (Menu menu, uint button, uint activate_time) { - gtksharp_gtk_status_icon_present_menu (Handle, menu == null ? IntPtr.Zero : menu.Handle, button, activate_time); + if (StatusIconPositionMenuFunc == null) + // gtk_status_icon_position_menu already defined by autogenerated code + StatusIconPositionMenuFunc = new MenuPositionFuncNative (gtk_status_icon_position_menu); + + gtk_menu_popup (menu == null ? IntPtr.Zero : menu.Handle, IntPtr.Zero, IntPtr.Zero, StatusIconPositionMenuFunc, Handle, button, activate_time); } [Obsolete ("use the File property instead")] diff --git a/gtk/glue/Makefile.am b/gtk/glue/Makefile.am index 6441e42b6..b7f77e486 100644 --- a/gtk/glue/Makefile.am +++ b/gtk/glue/Makefile.am @@ -4,7 +4,6 @@ libgtksharpglue_2_la_SOURCES = \ cellrenderer.c \ container.c \ object.c \ - statusicon.c \ style.c \ vmglueheaders.h \ widget.c diff --git a/gtk/glue/statusicon.c b/gtk/glue/statusicon.c deleted file mode 100644 index df5a891e5..000000000 --- a/gtk/glue/statusicon.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * statusicon.c - Glue methods for GtkStatusIcon - * - * Authors: - * Mike Kestner -#include - -/* Forward declarations */ -void gtksharp_gtk_status_icon_present_menu (GtkStatusIcon *icon, GtkMenu* menu, guint button, guint32 activate_time); - -/* */ - -void -gtksharp_gtk_status_icon_present_menu (GtkStatusIcon *icon, GtkMenu* menu, guint button, guint32 activate_time) -{ - gtk_menu_popup (menu, NULL, NULL, gtk_status_icon_position_menu, icon, button, activate_time); -} -