1 // Accel.cs - customizations to Gtk.Accel 2 // 3 // Authors: Mike Kestner <mkestner@ximian.com> 4 // 5 // Copyright (c) 2004-2005 Novell, Inc. 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of version 2 of the Lesser GNU General 9 // Public License as published by the Free Software Foundation. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 // Lesser General Public License for more details. 15 // 16 // You should have received a copy of the GNU Lesser General Public 17 // License along with this program; if not, write to the 18 // Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 // Boston, MA 02111-1307, USA. 20 21 namespace Gtk { 22 23 using System; 24 using System.Runtime.InteropServices; 25 26 public partial class Accel { 27 28 [DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)] gtk_accel_map_save(IntPtr file_name)29 static extern void gtk_accel_map_save(IntPtr file_name); 30 31 [Obsolete("Moved to AccelMap class. Use AccelMap.Save instead")] MapSave(string file_name)32 public static void MapSave(string file_name) { 33 IntPtr native = GLib.Marshaller.StringToPtrGStrdup (file_name); 34 gtk_accel_map_save (native); 35 GLib.Marshaller.Free (native); 36 } 37 38 [DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)] gtk_accel_map_add_filter(IntPtr filter_pattern)39 static extern void gtk_accel_map_add_filter(IntPtr filter_pattern); 40 41 [Obsolete("Moved to AccelMap class. Use AccelMap.AddFilter instead")] MapAddFilter(string filter_pattern)42 public static void MapAddFilter(string filter_pattern) { 43 IntPtr native = GLib.Marshaller.StringToPtrGStrdup (filter_pattern); 44 gtk_accel_map_add_filter (native); 45 GLib.Marshaller.Free (native); 46 } 47 48 [DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)] gtk_accel_map_foreach_unfiltered(IntPtr data, GtkSharp.AccelMapForeachNative foreach_func)49 static extern void gtk_accel_map_foreach_unfiltered(IntPtr data, GtkSharp.AccelMapForeachNative foreach_func); 50 51 [Obsolete("Moved to AccelMap class. Use AccelMap.ForeachUnfiltered instead")] MapForeachUnfiltered(IntPtr data, Gtk.AccelMapForeach foreach_func)52 public static void MapForeachUnfiltered(IntPtr data, Gtk.AccelMapForeach foreach_func) { 53 GtkSharp.AccelMapForeachWrapper foreach_func_wrapper = new GtkSharp.AccelMapForeachWrapper (foreach_func); 54 gtk_accel_map_foreach_unfiltered(data, foreach_func_wrapper.NativeDelegate); 55 } 56 57 [DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)] gtk_accel_map_save_fd(int fd)58 static extern void gtk_accel_map_save_fd(int fd); 59 60 [Obsolete("Moved to AccelMap class. Use AccelMap.SaveFd instead")] MapSaveFd(int fd)61 public static void MapSaveFd(int fd) { 62 gtk_accel_map_save_fd(fd); 63 } 64 65 [DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)] gtk_accel_map_add_entry(IntPtr accel_path, uint accel_key, int accel_mods)66 static extern void gtk_accel_map_add_entry(IntPtr accel_path, uint accel_key, int accel_mods); 67 68 [Obsolete("Moved to AccelMap class. Use AccelMap.AddEntry instead")] MapAddEntry(string accel_path, uint accel_key, Gdk.ModifierType accel_mods)69 public static void MapAddEntry(string accel_path, uint accel_key, Gdk.ModifierType accel_mods) { 70 IntPtr native = GLib.Marshaller.StringToPtrGStrdup (accel_path); 71 gtk_accel_map_add_entry(native, accel_key, (int) accel_mods); 72 GLib.Marshaller.Free (native); 73 } 74 75 [DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)] gtk_accel_map_load_fd(int fd)76 static extern void gtk_accel_map_load_fd(int fd); 77 78 [Obsolete("Moved to AccelMap class. Use AccelMap.LoadFd instead")] MapLoadFd(int fd)79 public static void MapLoadFd(int fd) { 80 gtk_accel_map_load_fd(fd); 81 } 82 83 [DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)] gtk_accel_map_lookup_entry(IntPtr accel_path, ref Gtk.AccelKey key)84 static extern bool gtk_accel_map_lookup_entry(IntPtr accel_path, ref Gtk.AccelKey key); 85 86 [Obsolete("Moved to AccelMap class. Use AccelMap.LookupEntry instead")] MapLookupEntry(string accel_path, Gtk.AccelKey key)87 public static bool MapLookupEntry(string accel_path, Gtk.AccelKey key) { 88 IntPtr native = GLib.Marshaller.StringToPtrGStrdup (accel_path); 89 bool ret = gtk_accel_map_lookup_entry(native, ref key); 90 GLib.Marshaller.Free (native); 91 return ret; 92 } 93 94 [DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)] gtk_accel_map_change_entry(IntPtr accel_path, uint accel_key, int accel_mods, bool replace)95 static extern bool gtk_accel_map_change_entry(IntPtr accel_path, uint accel_key, int accel_mods, bool replace); 96 97 [Obsolete("Moved to AccelMap class. Use AccelMap.ChangeEntry instead")] MapChangeEntry(string accel_path, uint accel_key, Gdk.ModifierType accel_mods, bool replace)98 public static bool MapChangeEntry (string accel_path, uint accel_key, Gdk.ModifierType accel_mods, bool replace) { 99 IntPtr native = GLib.Marshaller.StringToPtrGStrdup (accel_path); 100 bool ret = gtk_accel_map_change_entry (native, accel_key, (int) accel_mods, replace); 101 GLib.Marshaller.Free (native); 102 return ret; 103 } 104 105 [DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)] gtk_accel_map_load(IntPtr file_name)106 static extern void gtk_accel_map_load (IntPtr file_name); 107 108 [Obsolete("Moved to AccelMap class. Use AccelMap.Load instead")] MapLoad(string file_name)109 public static void MapLoad (string file_name) { 110 IntPtr native = GLib.Marshaller.StringToPtrGStrdup (file_name); 111 gtk_accel_map_load (native); 112 GLib.Marshaller.Free (native); 113 } 114 115 [DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)] gtk_accel_map_foreach(IntPtr data, GtkSharp.AccelMapForeachNative foreach_func)116 static extern void gtk_accel_map_foreach(IntPtr data, GtkSharp.AccelMapForeachNative foreach_func); 117 118 [Obsolete("Moved to AccelMap class. Use AccelMap.Foreach instead")] MapForeach(IntPtr data, Gtk.AccelMapForeach foreach_func)119 public static void MapForeach(IntPtr data, Gtk.AccelMapForeach foreach_func) { 120 GtkSharp.AccelMapForeachWrapper foreach_func_wrapper = new GtkSharp.AccelMapForeachWrapper (foreach_func); 121 gtk_accel_map_foreach(data, foreach_func_wrapper.NativeDelegate); 122 } 123 124 [DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)] gtk_accel_groups_from_object(IntPtr obj)125 static extern IntPtr gtk_accel_groups_from_object (IntPtr obj); 126 GroupsFromObject(GLib.Object obj)127 public static AccelGroup[] GroupsFromObject (GLib.Object obj) 128 { 129 IntPtr raw_ret = gtk_accel_groups_from_object(obj.Handle); 130 if (raw_ret == IntPtr.Zero) 131 return new AccelGroup [0]; 132 GLib.SList list = new GLib.SList(raw_ret); 133 AccelGroup[] result = new AccelGroup [list.Count]; 134 for (int i = 0; i < list.Count; i++) 135 result [i] = list [i] as AccelGroup; 136 return result; 137 } 138 } 139 } 140