Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Preview.cs « Metacity « libsteticui « MonoDevelop.GtkCore « addins « src « main - github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b0bd5ba026b53a3c0e7f5ac61a2db9ef4e5d0633 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace Stetic.Metacity {

	using System;
	using System.Reflection;
	using System.Collections;
	using System.Runtime.InteropServices;

	internal class Preview : Gtk.Bin
	{
		const string LIBMETACITY = "libmetacity-private.so.0";
		static Theme theme;
		public static bool ThemeError = false;
			
		public static Metacity.Preview Create (TopLevelWindow window)
		{
			Metacity.Preview metacityPreview;

			try {
				Metacity.Preview.Init ();
				metacityPreview = new Metacity.Preview ();
			}
			catch {
				return null;
			}

			switch (window.TypeHint) {
				case Gdk.WindowTypeHint.Normal:
					metacityPreview.FrameType = Metacity.FrameType.Normal;
					break;
				case Gdk.WindowTypeHint.Dialog:
					metacityPreview.FrameType = window.Modal ? Metacity.FrameType.ModalDialog : Metacity.FrameType.Dialog;
					break;
				case Gdk.WindowTypeHint.Menu:
					metacityPreview.FrameType = Metacity.FrameType.Menu;
					break;
				case Gdk.WindowTypeHint.Splashscreen:
					metacityPreview.FrameType = Metacity.FrameType.Border;
					break;
				case Gdk.WindowTypeHint.Utility:
					metacityPreview.FrameType = Metacity.FrameType.Utility;
					break;
				default:
					metacityPreview.FrameType = Metacity.FrameType.Normal;
					break;
			}

			Metacity.FrameFlags flags =
				Metacity.FrameFlags.AllowsDelete |
				Metacity.FrameFlags.AllowsVerticalResize |
				Metacity.FrameFlags.AllowsHorizontalResize |
				Metacity.FrameFlags.AllowsMove |
				Metacity.FrameFlags.AllowsShade |
				Metacity.FrameFlags.HasFocus;

			if (window.Resizable)
				flags = flags | Metacity.FrameFlags.AllowsMaximize;

			metacityPreview.FrameFlags = flags;
			metacityPreview.ShowAll ();
			metacityPreview.AddWindow (window);

			metacityPreview.Theme = GetTheme ();

			return metacityPreview;
		}

		public void AddWindow (TopLevelWindow window)
		{
			base.Add (window);

			Title = window.Title ?? string.Empty;
			window.PropertyChanged += OnWindowPropChange;
			Destroyed += delegate {
				window.PropertyChanged -= OnWindowPropChange;
			};
		}

		void OnWindowPropChange (object ob, EventArgs e)
		{
			Title = ((TopLevelWindow)ob).Title ?? string.Empty;
		}

		static Theme GetTheme ()
		{
			if (theme == null) {
				try {
					Assembly assm = Assembly.LoadWithPartialName ("gconf-sharp");
					Type client_type = assm.GetType ("GConf.Client");
					MethodInfo method = client_type.GetMethod ("Get", BindingFlags.Instance | BindingFlags.Public);
					object client = Activator.CreateInstance (client_type, new object[] {
						
					});
					string themeName = (string)method.Invoke (client, new object[] { "/apps/metacity/general/theme" });
					theme = Metacity.Theme.Load (themeName);
				} catch {
					// Set theme error flag - in case of a theme error a solid background needs to be drawn.
					ThemeError = true;
					// Don't crash if metacity is not available
					return null;
				}
			}
			return theme;
		}

		/*		static void GConfNotify (object obj, GConf.NotifyEventArgs args)
				{
					if (args.Key == "/apps/metacity/general/theme") {
						theme = Metacity.Theme.Load ((string)args.Value);
						foreach (Metacity.Preview prev in wrappers.Values)
							prev.Theme = Theme;
					}
				}
		*/

		~Preview ( )
		{
			Dispose();
		}

		public Preview(IntPtr raw) : base(raw) {}

		[DllImport(LIBMETACITY)]
		static extern IntPtr meta_preview_new();

		public Preview () : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Preview)) {
				CreateNativeObject (new string [0], new GLib.Value[0]);
				return;
			}
			Raw = meta_preview_new();
		}

		[DllImport(LIBMETACITY)]
		static extern void meta_preview_set_title(IntPtr raw, IntPtr title);

		public string Title {
			set  {
				IntPtr title_as_native = GLib.Marshaller.StringToPtrGStrdup (value);
				meta_preview_set_title(Handle, title_as_native);
				GLib.Marshaller.Free (title_as_native);
			}
		}

		[DllImport(LIBMETACITY)]
		static extern void meta_preview_set_button_layout(IntPtr raw, ref Stetic.Metacity.ButtonLayout button_layout);

		public Stetic.Metacity.ButtonLayout ButtonLayout
		{
			set  {
				meta_preview_set_button_layout(Handle, ref value);
			}
		}

		[DllImport(LIBMETACITY)]
		static extern void meta_preview_set_theme(IntPtr raw, IntPtr theme);

		public Metacity.Theme Theme {
			set  {
				meta_preview_set_theme(Handle, (value == null ? IntPtr.Zero : value.Handle));
			}
		}

		[DllImport(LIBMETACITY)]
		static extern IntPtr meta_preview_get_mini_icon();

		public static Gdk.Pixbuf MiniIcon { 
			get {
				IntPtr raw_ret = meta_preview_get_mini_icon();
				Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
				return ret;
			}
		}

		[DllImport(LIBMETACITY)]
		static extern IntPtr meta_preview_get_icon();

		public static Gdk.Pixbuf Icon { 
			get {
				IntPtr raw_ret = meta_preview_get_icon();
				Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
				return ret;
			}
		}

		[DllImport(LIBMETACITY)]
		static extern void meta_preview_set_frame_type(IntPtr raw, int type);

		public Stetic.Metacity.FrameType FrameType
		{ 
			set {
				meta_preview_set_frame_type(Handle, (int) value);
			}
		}

		[DllImport(LIBMETACITY)]
		static extern IntPtr meta_preview_get_type();

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = meta_preview_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}

		[DllImport(LIBMETACITY)]
		static extern void meta_preview_set_frame_flags(IntPtr raw, int flags);

		public Stetic.Metacity.FrameFlags FrameFlags
		{ 
			set {
				meta_preview_set_frame_flags(Handle, (int) value);
			}
		}


		public static void Init()
		{
			GtkSharp.MetacitySharp.ObjectManager.Initialize ();
		}
	}
}