1 // Gtk.UiManager.cs - Gtk UiManager class customizations
2 //
3 // Author: John Luke  <john.luke@gmail.com>
4 //
5 // Copyright (C) 2004 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 UIManager {
27 
AddUiFromResource(string resource)28 		public uint AddUiFromResource (string resource)
29 		{
30 			if (resource == null)
31 				throw new ArgumentNullException ("resource");
32 
33 			System.IO.Stream s = System.Reflection.Assembly.GetCallingAssembly ().GetManifestResourceStream (resource);
34 			if (s == null)
35 				throw new ArgumentException ("resource must be a valid resource name of 'assembly'.");
36 
37 			return AddUiFromString (new System.IO.StreamReader (s).ReadToEnd ());
38 		}
39 
40 		[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
gtk_ui_manager_new_merge_id(IntPtr raw)41 		static extern uint gtk_ui_manager_new_merge_id (IntPtr raw);
42 
NewMergeId()43 		public uint NewMergeId ()
44 		{
45 			return gtk_ui_manager_new_merge_id (Handle);
46 		}
47 
48 		[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
gtk_ui_manager_get_toplevels(IntPtr raw, int types)49 		static extern IntPtr gtk_ui_manager_get_toplevels (IntPtr raw, int types);
50 
GetToplevels(Gtk.UIManagerItemType types)51 		public Widget[] GetToplevels (Gtk.UIManagerItemType types) {
52 			IntPtr raw_ret = gtk_ui_manager_get_toplevels (Handle, (int) types);
53 			GLib.SList list = new GLib.SList (raw_ret);
54  			Widget[] result = new Widget [list.Count];
55 			for (int i = 0; i < list.Count; i++)
56 				result [i] = list [i] as Widget;
57 
58 			return result;
59 		}
60 
61 		[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
gtk_ui_manager_get_action_groups(IntPtr raw)62 		static extern IntPtr gtk_ui_manager_get_action_groups (IntPtr raw);
63 
64 		public ActionGroup[] ActionGroups {
65 			get {
66 				IntPtr raw_ret = gtk_ui_manager_get_action_groups (Handle);
67 				GLib.List list = new GLib.List(raw_ret);
68  				ActionGroup[] result = new ActionGroup [list.Count];
69 				for (int i = 0; i < list.Count; i++)
70 					result [i] = list [i] as ActionGroup;
71 
72 				return result;
73 			}
74 		}
75 	}
76 }
77