SignalDescriptor GetSignalDescriptor(Gtk.TreeIter iter) { Gtk.TreeIter group_iter; if (!(bool)store.GetValue(iter, ColIsSignal) || !store.IterParent(out group_iter, iter)) { return(null); } string name = (string)store.GetValue(iter, ColSignal); string group_name = (string)store.GetValue(group_iter, ColSignal); foreach (ItemGroup igroup in selection.ClassDescriptor.SignalGroups) { if (igroup.Label != group_name) { continue; } SignalDescriptor desc = (SignalDescriptor)igroup [name]; if (desc != null) { return(desc); } } return(null); }
public static void ReadSignal(ClassDescriptor klass, ObjectWrapper ob, XmlElement elem) { string name = elem.GetAttribute("name"); SignalDescriptor signal = klass.SignalGroups.GetItem(name) as SignalDescriptor; if (signal != null) { string handler = elem.GetAttribute("handler"); bool after = elem.GetAttribute("after") == "yes"; ob.Signals.Add(new Signal(signal, handler, after)); } }
void SetEmptySingalRow(Gtk.TreeIter signalIter, SignalDescriptor sd, bool showName) { if (showName) { store.SetValue(signalIter, ColSignal, sd.Name); } store.SetValue(signalIter, ColHandler, "<i><span foreground=\"grey\">" + EmptyHandlerText + "</span></i>"); store.SetValue(signalIter, ColHasHandler, false); store.SetValue(signalIter, ColIsSignal, true); store.SetValue(signalIter, ColDescriptorObject, sd); store.SetValue(signalIter, ColSignalTextWeight, (int)Pango.Weight.Normal); }
internal static void BindSignalHandlers(CodeExpression targetObjectVar, ObjectWrapper wrapper, Stetic.WidgetMap map, CodeStatementCollection statements, GenerationOptions options) { foreach (Signal signal in wrapper.Signals) { SignalDescriptor descriptor = signal.SignalDescriptor; CodeExpression createDelegate = new CodeDelegateCreateExpression( new CodeTypeReference(descriptor.HandlerTypeName, CodeTypeReferenceOptions.GlobalReference), new CodeThisReferenceExpression(), signal.Handler); CodeAttachEventStatement cevent = new CodeAttachEventStatement( new CodeEventReferenceExpression( map.GetWidgetExp(wrapper), descriptor.Name), createDelegate); statements.Add(cevent); } Wrapper.Widget widget = wrapper as Wrapper.Widget; if (widget != null && widget.IsTopLevel) { // Bind local action signals foreach (Wrapper.ActionGroup grp in widget.LocalActionGroups) { foreach (Wrapper.Action ac in grp.Actions) { BindSignalHandlers(targetObjectVar, ac, map, statements, options); } } } Gtk.Container cont = wrapper.Wrapped as Gtk.Container; if (cont != null) { foreach (Gtk.Widget child in cont.AllChildren) { Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup(child); if (ww != null) { BindSignalHandlers(targetObjectVar, ww, map, statements, options); } } } }
void OnRowActivated(object sender, Gtk.RowActivatedArgs args) { Gtk.TreeIter iter; if (!store.GetIter(out iter, args.Path)) { return; } SignalDescriptor sd = GetSignalDescriptor(iter); if (sd != null) { if (GetSignal(iter) == null) { AddHandler(iter, GetHandlerName(sd.Name)); } frontend.NotifySignalActivated(); } }
void AddHandler(Gtk.TreeIter iter, string name) { internalChange = true; Gtk.TreeIter piter = iter; while (store.IterDepth(piter) != 0) { store.IterParent(out piter, piter); } Signal signal = GetSignal(iter); if (signal == null) { if (name != "") { SignalDescriptor sd = (SignalDescriptor)store.GetValue(iter, ColDescriptorObject); signal = new Signal(sd); signal.Handler = name; selection.Signals.Add(signal); SetSignalData(iter, signal); store.SetValue(iter, ColSignalTextWeight, (int)Pango.Weight.Bold); if (store.IterDepth(iter) == 1) { SetEmptySingalRow(store.AppendNode(iter), signal.SignalDescriptor, false); } else { store.IterParent(out iter, iter); SetEmptySingalRow(store.AppendNode(iter), signal.SignalDescriptor, false); } } } else { if (name != "") { signal.Handler = name; store.SetValue(iter, ColHandler, signal.Handler); } else { selection.Signals.Remove(signal); if (store.IterDepth(iter) == 1) { if (store.IterNChildren(iter) == 1) { SetEmptySingalRow(iter, signal.SignalDescriptor, true); // Remove the empty row store.IterChildren(out iter, iter); store.Remove(ref iter); } else { Gtk.TreeIter citer; store.IterChildren(out citer, iter); Signal csignal = GetSignal(citer); store.Remove(ref citer); SetSignalData(iter, csignal); if (store.IterNChildren(iter) == 1) { tree.CollapseRow(store.GetPath(iter)); } } } else { store.Remove(ref iter); } } } UpdateGroupStatus(piter); internalChange = false; }
public Signal(SignalDescriptor descriptor, string handlerName, bool after) { this.descriptor = descriptor; this.handlerName = handlerName; this.after = after; }
public Signal(SignalDescriptor descriptor) : this(descriptor, null, false) { }
public Signal (SignalDescriptor descriptor, string handlerName, bool after) { this.descriptor = descriptor; this.handlerName = handlerName; this.after = after; }
public Signal (SignalDescriptor descriptor): this (descriptor, null, false) { }
void SetEmptySingalRow(Gtk.TreeIter signalIter, SignalDescriptor sd, bool showName) { if (showName) store.SetValue (signalIter, ColSignal, sd.Name); store.SetValue (signalIter, ColHandler, "<i><span foreground=\"grey\">" + EmptyHandlerText + "</span></i>"); store.SetValue (signalIter, ColHasHandler, false); store.SetValue (signalIter, ColIsSignal, true); store.SetValue (signalIter, ColDescriptorObject, sd); store.SetValue (signalIter, ColSignalTextWeight, (int) Pango.Weight.Normal); }
internal static void BindSignalHandlers(CodeExpression targetObjectVar, ObjectWrapper wrapper, Stetic.WidgetMap map, CodeStatementCollection statements, GenerationOptions options) { foreach (Signal signal in wrapper.Signals) { SignalDescriptor descriptor = signal.SignalDescriptor; CodeExpression createDelegate; if (options.UsePartialClasses) { var rgx = new Regex(@"`\d+"); createDelegate = new CodeDelegateCreateExpression( new CodeTypeReference(rgx.Replace(descriptor.HandlerTypeName, ""), CodeTypeReferenceOptions.GlobalReference), new CodeThisReferenceExpression(), signal.Handler); } else { createDelegate = new CodeMethodInvokeExpression( new CodeTypeReferenceExpression(new CodeTypeReference(typeof(Delegate), CodeTypeReferenceOptions.GlobalReference)), "CreateDelegate", new CodeTypeOfExpression(descriptor.HandlerTypeName), targetObjectVar, new CodePrimitiveExpression(signal.Handler)); createDelegate = new CodeCastExpression(descriptor.HandlerTypeName.ToGlobalTypeRef(), createDelegate); } CodeAttachEventStatement cevent = new CodeAttachEventStatement( new CodeEventReferenceExpression( map.GetWidgetExp(wrapper), descriptor.Name), createDelegate); statements.Add(cevent); } Wrapper.Widget widget = wrapper as Wrapper.Widget; if (widget != null && widget.IsTopLevel) { // Bind local action signals foreach (Wrapper.ActionGroup grp in widget.LocalActionGroups) { foreach (Wrapper.Action ac in grp.Actions) { BindSignalHandlers(targetObjectVar, ac, map, statements, options); } } } Gtk.Container cont = wrapper.Wrapped as Gtk.Container; if (cont != null) { foreach (Gtk.Widget child in cont.AllChildren) { Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup(child); if (ww != null) { BindSignalHandlers(targetObjectVar, ww, map, statements, options); } } } }