1 // Gtk.RadioToolButton.cs - Gtk RadioToolButton class customizations
2 //
3 // Author: Mike Kestner <mkestner@novell.com>
4 //
5 // Copyright (c) 2006 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 RadioToolButton {
27 
28 		[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
gtk_radio_tool_button_new(IntPtr group)29 		static extern IntPtr gtk_radio_tool_button_new (IntPtr group);
30 
RadioToolButton(RadioToolButton[] group)31 		public RadioToolButton (RadioToolButton[] group) : base (IntPtr.Zero)
32 		{
33 			if (GetType () != typeof (RadioToolButton)) {
34 				CreateNativeObject (new string [0], new GLib.Value [0]);
35 				Group = group;
36 				return;
37 			}
38 			IntPtr native_group = IntPtr.Zero;
39 			if (group != null) {
40 				GLib.List list = new GLib.List(IntPtr.Zero);
41 				foreach (RadioToolButton item in group) {
42 					list.Append (item.Handle);
43 				}
44 				native_group = list.Handle;
45 			}
46 			Raw = gtk_radio_tool_button_new(native_group);
47 		}
48 
49 		[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
gtk_radio_tool_button_new_from_stock(IntPtr group, IntPtr stock_id)50 		static extern IntPtr gtk_radio_tool_button_new_from_stock (IntPtr group, IntPtr stock_id);
51 
RadioToolButton(RadioToolButton[] group, string stock_id)52 		public RadioToolButton (RadioToolButton[] group, string stock_id) : base (IntPtr.Zero)
53 		{
54 			if (GetType () != typeof (RadioToolButton)) {
55 				GLib.Value[] vals = new GLib.Value [1];
56 				string[] names = { "stock_id" };
57 				vals [0] = new GLib.Value (stock_id);
58 				CreateNativeObject (names, vals);
59 				Group = group;
60 				return;
61 			}
62 			IntPtr stock_id_as_native = GLib.Marshaller.StringToPtrGStrdup (stock_id);
63 			IntPtr native_group = IntPtr.Zero;
64 			if (group != null) {
65 				GLib.List list = new GLib.List(IntPtr.Zero);
66 				foreach (RadioToolButton item in group) {
67 					list.Append (item.Handle);
68 				}
69 				native_group = list.Handle;
70 			}
71 			Raw = gtk_radio_tool_button_new_from_stock(native_group, stock_id_as_native);
72 			GLib.Marshaller.Free (stock_id_as_native);
73 		}
74 
75 		[DllImport(Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
gtk_radio_tool_button_get_group(IntPtr raw)76 		static extern IntPtr gtk_radio_tool_button_get_group(IntPtr raw);
77 
78 		[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
gtk_radio_tool_button_set_group(IntPtr raw, IntPtr list)79 		static extern void gtk_radio_tool_button_set_group(IntPtr raw, IntPtr list);
80 
81 		[GLib.Property ("group")]
82 		public RadioToolButton[] Group {
83 			get  {
84 				IntPtr raw_ret = gtk_radio_tool_button_get_group(Handle);
85 				RadioToolButton[] ret = (RadioToolButton[]) GLib.Marshaller.ListPtrToArray (raw_ret, typeof(GLib.SList), false, false, typeof(RadioToolButton));
86 				return ret;
87 			}
88 			set {
89 				IntPtr native_group = IntPtr.Zero;
90 				if (value != null) {
91 					GLib.List list = new GLib.List(IntPtr.Zero);
92 					foreach (RadioToolButton item in value) {
93 						list.Append (item.Handle);
94 					}
95 					native_group = list.Handle;
96 				}
97 				gtk_radio_tool_button_set_group(Handle, native_group);
98 			}
99 		}
100 	}
101 }
102