public void SetGValue(ref GLib.Value val) { GLib.Value min = new GLib.Value(Min); GLib.Value max = new GLib.Value(Max); gst_value_set_fraction_range(ref val, ref min, ref max); min.Dispose(); max.Dispose(); }
public void SetGValue(ref GLib.Value val) { foreach (object o in content) { GLib.Value v = new GLib.Value(o); gst_value_array_append_value(ref val, ref v); v.Dispose(); } }
bool RowSeparatorFunc(Gtk.TreeModel model, Gtk.TreeIter iter) { GLib.Value val = new GLib.Value(); model.GetValue(iter, 0, ref val); bool sep = ((string)val) == ""; val.Dispose(); return(sep); }
public PropertyInfo(IntPtr pspec_ptr) { GParamSpec pspec = (GParamSpec)Marshal.PtrToStructure(pspec_ptr, typeof(GParamSpec)); IntPtr name = g_param_spec_get_name(pspec_ptr); IntPtr nick = g_param_spec_get_nick(pspec_ptr); IntPtr blurb = g_param_spec_get_blurb(pspec_ptr); this.name = GLib.Marshaller.Utf8PtrToString(name); this.nick = GLib.Marshaller.Utf8PtrToString(nick); this.blurb = GLib.Marshaller.Utf8PtrToString(blurb); this.readable = ((pspec.Flags & (1 << 0)) != 0); this.writeable = ((pspec.Flags & (1 << 1)) != 0); this.controllable = ((pspec.Flags & (1 << 9)) != 0); /* TODO: Add more flags later, like the mutable flags */ this.gtype = new GLib.GType(pspec.ValueType); this.type = (System.Type) this.gtype; this.dflt = this.min = this.max = null; try { GLib.Value v = new GLib.Value(new GLib.GType(pspec.ValueType)); g_param_value_set_default(pspec_ptr, ref v); this.dflt = v.Val; v.Dispose(); if (EnumInfo.IsEnumType(this.gtype)) { EnumInfo ei = new EnumInfo(this.gtype); this.min = ei.Min; this.max = ei.Max; } else { GLib.Value min = new GLib.Value(new GLib.GType(pspec.ValueType)); GLib.Value max = new GLib.Value(new GLib.GType(pspec.ValueType)); if (gstsharp_g_param_spec_get_range(pspec_ptr, ref min, ref max)) { this.min = (object)min.Val; this.max = (object)max.Val; } min.Dispose(); max.Dispose(); } } catch (Exception) {} }
public bool MoveNext() { IntPtr raw_ret; bool retry = false; if (iterator.Handle == IntPtr.Zero) { return(false); } do { GLib.Value value = new GLib.Value(GLib.GType.Boolean); value.Dispose(); IteratorResult ret = iterator.Next(ref value); switch (ret) { case IteratorResult.Done: return(false); case IteratorResult.Ok: if (seen.Contains(value)) { retry = true; break; } seen.Add(value, null); current = value.Val; return(true); case IteratorResult.Resync: iterator.Resync(); retry = true; break; default: case IteratorResult.Error: throw new Exception("Error while iterating"); } } while (retry); return(false); }
public PropertyInfo(IntPtr pspec_ptr) { GParamSpec pspec = (GParamSpec) Marshal.PtrToStructure (pspec_ptr, typeof (GParamSpec)); IntPtr name = g_param_spec_get_name (pspec_ptr); IntPtr nick = g_param_spec_get_nick (pspec_ptr); IntPtr blurb = g_param_spec_get_blurb (pspec_ptr); this.name = GLib.Marshaller.Utf8PtrToString (name); this.nick = GLib.Marshaller.Utf8PtrToString (nick); this.blurb = GLib.Marshaller.Utf8PtrToString (blurb); this.readable = ( (pspec.Flags & (1 << 0)) != 0); this.writeable = ( (pspec.Flags & (1 << 1)) != 0); this.controllable = ( (pspec.Flags & (1 << 9)) != 0); /* TODO: Add more flags later, like the mutable flags */ this.gtype = new GLib.GType (pspec.ValueType); this.type = (System.Type) this.gtype; this.dflt = this.min = this.max = null; try { GLib.Value v = new GLib.Value (new GLib.GType (pspec.ValueType)); g_param_value_set_default (pspec_ptr, ref v); this.dflt = v.Val; v.Dispose (); if (EnumInfo.IsEnumType (this.gtype)) { EnumInfo ei = new EnumInfo (this.gtype); this.min = ei.Min; this.max = ei.Max; } else { GLib.Value min = new GLib.Value (new GLib.GType (pspec.ValueType)); GLib.Value max = new GLib.Value (new GLib.GType (pspec.ValueType)); if (gstsharp_g_param_spec_get_range (pspec_ptr, ref min, ref max)) { this.min = (object) min.Val; this.max = (object) max.Val; } min.Dispose (); max.Dispose (); } } catch (Exception) {} }
void OnTreeViewSelectionChanged(object sender, EventArgs e) { Gtk.TreeSelection selection = sender as Gtk.TreeSelection; string data; Gtk.TreeModel model; Gtk.TreeIter iter; if (selection.GetSelected(out model, out iter)) { int depth = model.GetPath(iter).ToString().Split(':').Length; if (depth == 1) //Category { int column = (int)Column.Id; GLib.Value val = GLib.Value.Empty; model.GetValue(iter, column, ref val); data = (string)val.Val; documentSelectedInTreeView = registry.Get(categorySelectedInComboBox.Direction, categorySelectedInComboBox.Group).Get(int.Parse(data)); val.Dispose(); } } }
public void SetGValue(ref GLib.Value val) { foreach (object o in content) { GLib.Value v = new GLib.Value (o); gst_value_list_append_value (ref val, ref v); v.Dispose (); } }
public void SetGValue(ref GLib.Value val) { GLib.Value min = new GLib.Value (Min); GLib.Value max = new GLib.Value (Max); gst_value_set_fraction_range (ref val, ref min, ref max); min.Dispose (); max.Dispose (); }
protected virtual bool OnNewWindowPolicyDecisionRequested (WebFrame frame, NetworkRequest request, WebNavigationAction action, WebPolicyDecision decision) { var val = new Value (GType.Int); var valueArray = new ValueArray (5u); var array = new Value[5]; array [0] = new Value (this); valueArray.Append (array [0]); array [1] = new Value (frame); valueArray.Append (array [1]); array [2] = new Value (request); valueArray.Append (array [2]); array [3] = new Value (action); valueArray.Append (array [3]); array [4] = new Value (decision); valueArray.Append (array [4]); GLib.Object.g_signal_chain_from_overridden (valueArray.ArrayPtr, ref val); var array2 = array; for (int i = 0; i < array2.Length; i++) { var value = array2 [i]; value.Dispose (); } bool result = (bool)val; val.Dispose (); return result; }
public static object Emit(GLib.Object o, string name, params object[] parameters) { SignalQuery query; IntPtr type = gstsharp_g_type_from_instance(o.Handle); GType gtype = new GType(type); string signal_name, signal_detail; uint signal_detail_quark = 0; int colon; colon = name.LastIndexOf("::"); if (colon == -1) { signal_name = name; signal_detail = String.Empty; } else { signal_name = name.Substring(0, colon); signal_detail = name.Substring(colon + 2); } GTypeSignalKey key = new GTypeSignalKey(gtype, signal_name); if (SignalEmitInfo[key] == null) { IntPtr native_string = GLib.Marshaller.StringToPtrGStrdup(signal_name); uint signal_id = g_signal_lookup(native_string, type); GLib.Marshaller.Free(native_string); if (signal_id == 0) { throw new NotSupportedException(String.Format("{0} has no signal of name {1}", o, name)); } GSignalQuery q = new GSignalQuery(); g_signal_query(signal_id, ref q); if (q.signal_id == 0) { throw new NotSupportedException(String.Format("{0} couldn't be queried for signal with name {1}", o, name)); } query = new SignalQuery(); query.signal_id = signal_id; query.signal_name = GLib.Marshaller.Utf8PtrToString(q.signal_name); query.itype = new GType(q.itype); query.signal_flags = q.signal_flags; query.return_type = new GType(q.return_type); query.n_params = q.n_params; query.param_types = new Type[q.n_params]; for (int i = 0; i < query.n_params; i++) { IntPtr t = Marshal.ReadIntPtr(q.param_types, i); GType g = new GType(t); query.param_types[i] = (Type)g; } SignalEmitInfo.Add(key, query); } query = (SignalQuery)SignalEmitInfo[key]; GLib.Value[] signal_parameters = new GLib.Value[query.n_params + 1]; signal_parameters[0] = new GLib.Value(o); if (parameters.Length != query.n_params) { throw new ApplicationException(String.Format("Invalid number of parameters: expected {0}, got {1}", query.n_params, parameters.Length)); } for (int i = 0; i < query.n_params; i++) { Type expected_type = (Type)query.param_types[i]; Type given_type = parameters[i].GetType(); if (expected_type != given_type && !given_type.IsSubclassOf(given_type)) { throw new ApplicationException(String.Format("Invalid parameter type: expected {0}, got {1}", expected_type, given_type)); } signal_parameters[i + 1] = new GLib.Value(parameters[i]); } GLib.Value return_value = new GLib.Value(); if (query.return_type != GType.Invalid && query.return_type != GType.None) { return_value.Init(query.return_type); } if (signal_detail != String.Empty) { IntPtr native_string = GLib.Marshaller.StringToPtrGStrdup(signal_detail); signal_detail_quark = g_quark_from_string(native_string); GLib.Marshaller.Free(native_string); } g_signal_emitv(signal_parameters, query.signal_id, signal_detail_quark, ref return_value); foreach (GLib.Value v in signal_parameters) { v.Dispose(); } object ret = (query.return_type != GType.Invalid && query.return_type != GType.None) ? return_value.Val : null; if (ret != null) { return_value.Dispose(); } return(ret); }
public bool MoveNext() { IntPtr raw_ret; bool retry = false; if (iterator.Handle == IntPtr.Zero) return false; do { GLib.Value value = new GLib.Value (GLib.GType.Boolean); value.Dispose (); IteratorResult ret = iterator.Next (ref value); switch (ret) { case IteratorResult.Done: return false; case IteratorResult.Ok: if (seen.Contains (value)) { retry = true; break; } seen.Add (value , null); current = value.Val; return true; case IteratorResult.Resync: iterator.Resync (); retry = true; break; default: case IteratorResult.Error: throw new Exception ("Error while iterating"); } } while (retry); return false; }
public static object Emit(GLib.Object o, string name, params object[] parameters) { SignalQuery query; IntPtr type = gstsharp_g_type_from_instance (o.Handle); GType gtype = new GType (type); string signal_name, signal_detail; uint signal_detail_quark = 0; int colon; colon = name.LastIndexOf ("::"); if (colon == -1) { signal_name = name; signal_detail = String.Empty; } else { signal_name = name.Substring (0, colon); signal_detail = name.Substring (colon + 2); } GTypeSignalKey key = new GTypeSignalKey (gtype, signal_name); if (SignalEmitInfo[key] == null) { IntPtr native_string = GLib.Marshaller.StringToPtrGStrdup (signal_name); uint signal_id = g_signal_lookup (native_string, type); GLib.Marshaller.Free (native_string); if (signal_id == 0) throw new NotSupportedException (String.Format ("{0} has no signal of name {1}", o, name)); GSignalQuery q = new GSignalQuery (); g_signal_query (signal_id, ref q); if (q.signal_id == 0) throw new NotSupportedException (String.Format ("{0} couldn't be queried for signal with name {1}", o, name)); query = new SignalQuery (); query.signal_id = signal_id; query.signal_name = GLib.Marshaller.Utf8PtrToString (q.signal_name); query.itype = new GType (q.itype); query.signal_flags = q.signal_flags; query.return_type = new GType (q.return_type); query.n_params = q.n_params; query.param_types = new Type[q.n_params]; for (int i = 0; i < query.n_params; i++) { IntPtr t = Marshal.ReadIntPtr (q.param_types, i); GType g = new GType (t); query.param_types[i] = (Type) g; } SignalEmitInfo.Add (key, query); } query = (SignalQuery) SignalEmitInfo[key]; GLib.Value[] signal_parameters = new GLib.Value[query.n_params + 1]; signal_parameters[0] = new GLib.Value (o); if (parameters.Length != query.n_params) throw new ApplicationException (String.Format ("Invalid number of parameters: expected {0}, got {1}", query.n_params, parameters.Length)); for (int i = 0; i < query.n_params; i++) { Type expected_type = (Type) query.param_types[i]; Type given_type = parameters[i].GetType (); if (expected_type != given_type && ! given_type.IsSubclassOf (given_type)) throw new ApplicationException (String.Format ("Invalid parameter type: expected {0}, got {1}", expected_type, given_type)); signal_parameters[i + 1] = new GLib.Value (parameters[i]); } GLib.Value return_value = new GLib.Value (); if (query.return_type != GType.Invalid && query.return_type != GType.None) return_value.Init (query.return_type); if (signal_detail != String.Empty) { IntPtr native_string = GLib.Marshaller.StringToPtrGStrdup (signal_detail); signal_detail_quark = g_quark_from_string (native_string); GLib.Marshaller.Free (native_string); } g_signal_emitv (signal_parameters, query.signal_id, signal_detail_quark, ref return_value); foreach (GLib.Value v in signal_parameters) v.Dispose (); object ret = (query.return_type != GType.Invalid && query.return_type != GType.None) ? return_value.Val : null; if (ret != null) return_value.Dispose (); return ret; }
bool RowSeparatorFunc (Gtk.TreeModel model, Gtk.TreeIter iter) { GLib.Value val = new GLib.Value (); model.GetValue (iter, 0, ref val); bool sep = ((string)val) == ""; val.Dispose (); return sep; }