public void Clear() { Control.Clear(); targets = new Gtk.TargetList(); clipboard.Clear(); Update(); }
public Gtk.TargetList GetTargets() { var targets = new Gtk.TargetList(); targets.AddTable(Control.Values.Select(r => r.Target).ToArray()); return(targets); }
public static Gtk.TargetList BuildTargetTable(TransferDataType[] types) { var tl = new Gtk.TargetList (); foreach (var tt in types) tl.AddTable (CreateTargetEntries (tt)); return tl; }
public static Gtk.TargetList SourceGetTargetList(Gtk.Widget widget) { IntPtr raw_ret = gtk_drag_source_get_target_list(widget == null ? IntPtr.Zero : widget.Handle); Gtk.TargetList ret = raw_ret == IntPtr.Zero ? null : (Gtk.TargetList)GLib.Opaque.GetOpaque(raw_ret, typeof(Gtk.TargetList), false); return(ret); }
public static Gdk.DragContext BeginWithCoordinates(Gtk.Widget widget, Gtk.TargetList targets, Gdk.DragAction actions, int button, Gdk.Event evnt, int x, int y) { IntPtr raw_ret = gtk_drag_begin_with_coordinates(widget == null ? IntPtr.Zero : widget.Handle, targets == null ? IntPtr.Zero : targets.Handle, (int)actions, button, evnt == null ? IntPtr.Zero : evnt.Handle, x, y); Gdk.DragContext ret = GLib.Object.GetObject(raw_ret) as Gdk.DragContext; return(ret); }
static Gtk.TargetEntry[] CreateTargetEntries(string type) { lock (dragTargets) { Gtk.TargetEntry[] entries; if (dragTargets.TryGetValue(type, out entries)) { return(entries); } uint id = targetIdCounter++; switch (type) { case TransferDataType.Uri: { Gtk.TargetList list = new Gtk.TargetList(); list.AddUriTargets(id); entries = (Gtk.TargetEntry[])list; break; } case TransferDataType.Text: { Gtk.TargetList list = new Gtk.TargetList(); list.AddTextTargets(id); //HACK: work around gtk_selection_data_set_text causing crashes on Mac w/ QuickSilver, Clipbard History etc. if (Platform.IsMac) { list.Remove("COMPOUND_TEXT"); list.Remove("TEXT"); list.Remove("STRING"); } entries = (Gtk.TargetEntry[])list; break; } case TransferDataType.Rtf: { Gdk.Atom atom; if (Platform.IsMac) { atom = Gdk.Atom.Intern("NSRTFPboardType", false); //TODO: use public.rtf when dep on MacOS 10.6 } else { atom = Gdk.Atom.Intern("text/rtf", false); } entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry(atom, 0, id) }; break; } default: entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry(Gdk.Atom.Intern("application/" + type, false), 0, id) }; break; } foreach (var a in entries.Select(e => e.Target)) { atomToType [a] = type; } return(dragTargets [type] = entries); } }
protected override void Initialize(IPadWindow container) { base.Initialize(container); #if MAC toolbox = new Toolbox.MacToolbox(DesignerSupport.Service.ToolboxService, container); widget = GtkMacInterop.NSViewToGtkWidget(toolbox); widget.CanFocus = true; widget.Sensitive = true; widget.KeyPressEvent += toolbox.OnKeyPressed; widget.KeyReleaseEvent += toolbox.KeyReleased; widget.DragBegin += (o, args) => { if (!isDragging) { DesignerSupport.Service.ToolboxService.DragSelectedItem(widget, args.Context); isDragging = true; } }; widget.DragEnd += (o, args) => { isDragging = false; }; widget.Focused += (s, e) => { toolbox.FocusSelectedView(); }; toolbox.ContentFocused += (s, e) => { if (!widget.HasFocus) { widget.HasFocus = true; toolbox.FocusSelectedView(); } }; toolbox.DragSourceSet += (s, e) => { targets = new Gtk.TargetList(); targets.AddTable(e); }; toolbox.DragBegin += (object sender, EventArgs e) => { if (!isDragging) { Gtk.Drag.SourceUnset(widget); // Gtk.Application.CurrentEvent and other copied gdk_events seem to have a problem // when used as they use gdk_event_copy which seems to crash on de-allocating the private slice. IntPtr currentEvent = GtkWorkarounds.GetCurrentEventHandle(); Gtk.Drag.Begin(widget, targets, Gdk.DragAction.Copy | Gdk.DragAction.Move, 1, new Gdk.Event(currentEvent)); // gtk_drag_begin does not store the event, so we're okay GtkWorkarounds.FreeEvent(currentEvent); } }; widget.ShowAll(); #else widget = new Toolbox.Toolbox(DesignerSupport.Service.ToolboxService, container); #endif }
public static Gtk.TargetList BuildTargetTable(string[] types) { var tl = new Gtk.TargetList(); foreach (var tt in types) { tl.AddTable(CreateTargetEntries(tt)); } return(tl); }
static DND() { widgetIcon = Gdk.Pixbuf.LoadFromResource ("widget.png"); steticWidgetType = Gdk.Atom.Intern ("application/x-stetic-widget", false); targets = new Gtk.TargetEntry[2]; targets[0] = new Gtk.TargetEntry ("application/x-stetic-widget", 0, SteticType); targets[1] = new Gtk.TargetEntry ((string)GladeUtils.ApplicationXGladeAtom, 0, GladeType); targetList = new Gtk.TargetList (); targetList.Add (steticWidgetType, 0, 0); targetList.Add (GladeUtils.ApplicationXGladeAtom, 0, 1); }
static DND() { widgetIcon = Gdk.Pixbuf.LoadFromResource("widget.png"); steticWidgetType = Gdk.Atom.Intern("application/x-stetic-widget", false); targets = new Gtk.TargetEntry[2]; targets[0] = new Gtk.TargetEntry("application/x-stetic-widget", 0, SteticType); targets[1] = new Gtk.TargetEntry((string)GladeUtils.ApplicationXGladeAtom, 0, GladeType); targetList = new Gtk.TargetList(); targetList.Add(steticWidgetType, 0, 0); targetList.Add(GladeUtils.ApplicationXGladeAtom, 0, 1); }
public static Gtk.TargetEntry[] TableNewFromList(Gtk.TargetList list) { int n_targets; IntPtr array_ptr = gtk_target_table_new_from_list(list.Handle, out n_targets); Gtk.TargetEntry[] ret = new Gtk.TargetEntry [n_targets]; int unmanaged_struct_size = Marshal.SizeOf(typeof(Gtk.TargetEntry)); for (int i = 0; i < n_targets; i++) { ret [i] = Gtk.TargetEntry.New(new IntPtr(array_ptr.ToInt64() + i * unmanaged_struct_size)); } return(ret); }
static DND() { try { widgetIcon = Gdk.Pixbuf.LoadFromResource("widget.png"); } catch (Exception e) { Console.WriteLine("Error while loading pixbuf 'widget.png': " + e); } steticWidgetType = Gdk.Atom.Intern("application/x-stetic-widget", false); targets = new Gtk.TargetEntry[2]; targets[0] = new Gtk.TargetEntry(steticWidgetType, 0, SteticType); targets[1] = new Gtk.TargetEntry((string)GladeUtils.ApplicationXGladeAtom, 0, GladeType); targetList = new Gtk.TargetList(targets); targets = (Gtk.TargetEntry[])targetList; }
static DND () { try { widgetIcon = Gdk.Pixbuf.LoadFromResource ("widget.png"); } catch (Exception e) { Console.WriteLine ("Error while loading pixbuf 'widget.png': " + e); } steticWidgetType = Gdk.Atom.Intern ("application/x-stetic-widget", false); targets = new Gtk.TargetEntry[2]; targets[0] = new Gtk.TargetEntry (steticWidgetType, 0, SteticType); targets[1] = new Gtk.TargetEntry ((string) GladeUtils.ApplicationXGladeAtom, 0, GladeType); targetList = new Gtk.TargetList (targets); targets = (Gtk.TargetEntry[]) targetList; }
public NoteEditor(Gtk.TextBuffer buffer) : base(buffer) { WrapMode = Gtk.WrapMode.Word; LeftMargin = DefaultMargin; RightMargin = DefaultMargin; CanDefault = true; //Set up the GConf client to watch the default document font Preferences.Client.AddNotify(DESKTOP_GNOME_INTERFACE_PATH, OnFontSettingChanged); // Make sure the cursor position is visible ScrollMarkOnscreen(buffer.InsertMark); // Set Font from GConf preference if ((bool)Preferences.Get(Preferences.ENABLE_CUSTOM_FONT)) { string font_string = (string) Preferences.Get(Preferences.CUSTOM_FONT_FACE); ModifyFont(Pango.FontDescription.FromString(font_string)); } else { ModifyFont(GetGnomeDocumentFontDescription()); } // Update search match color UpdateSearchMatchColor(); Preferences.SettingChanged += OnFontSettingChanged; Preferences.SettingChanged += OnSearchMatchColorSettingChanged; // Set extra editor drag targets supported (in addition // to the default TextView's various text formats)... Gtk.TargetList list = Gtk.Drag.DestGetTargetList(this); list.Add(Gdk.Atom.Intern("text/uri-list", false), 0, 1); list.Add(Gdk.Atom.Intern("_NETSCAPE_URL", false), 0, 1); KeyPressEvent += KeyPressed; ButtonPressEvent += ButtonPressed; }
public static void SourceSetTargetList(Gtk.Widget widget, Gtk.TargetList target_list) { gtk_drag_source_set_target_list(widget == null ? IntPtr.Zero : widget.Handle, target_list == null ? IntPtr.Zero : target_list.Handle); }
public static Gdk.Atom DestFindTarget(Gtk.Widget widget, Gdk.DragContext context, Gtk.TargetList target_list) { IntPtr raw_ret = gtk_drag_dest_find_target(widget == null ? IntPtr.Zero : widget.Handle, context == null ? IntPtr.Zero : context.Handle, target_list == null ? IntPtr.Zero : target_list.Handle); Gdk.Atom ret = raw_ret == IntPtr.Zero ? null : (Gdk.Atom)GLib.Opaque.GetOpaque(raw_ret, typeof(Gdk.Atom), false); return(ret); }
static Gtk.TargetEntry[] CreateTargetEntries(TransferDataType type) { lock (dragTargets) { Gtk.TargetEntry[] entries; if (dragTargets.TryGetValue (type, out entries)) return entries; uint id = targetIdCounter++; if (type == TransferDataType.Uri) { Gtk.TargetList list = new Gtk.TargetList (); list.AddUriTargets (id); entries = (Gtk.TargetEntry[])list; } else if (type == TransferDataType.Text) { Gtk.TargetList list = new Gtk.TargetList (); list.AddTextTargets (id); //HACK: work around gtk_selection_data_set_text causing crashes on Mac w/ QuickSilver, Clipbard History etc. if (Platform.IsMac) { list.Remove ("COMPOUND_TEXT"); list.Remove ("TEXT"); list.Remove ("STRING"); } entries = (Gtk.TargetEntry[])list; } else if (type == TransferDataType.Rtf) { Gdk.Atom atom; if (Platform.IsMac) atom = Gdk.Atom.Intern ("NSRTFPboardType", false); //TODO: use public.rtf when dep on MacOS 10.6 else atom = Gdk.Atom.Intern ("text/rtf", false); entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry (atom, 0, id) }; } else { entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry (Gdk.Atom.Intern ("application/" + type.Id, false), 0, id) }; } foreach (var a in entries.Select (e => e.Target)) atomToType [a] = type; return dragTargets [type] = entries; } }
protected override void Initialize(IPadWindow window) { this.window = window; dragPad = new FigmaDragAndDropContent(); window.PadContentHidden += Container_PadHidden; window.PadContentShown += Container_PadShown; widget = GtkMacInterop.NSViewToGtkWidget(dragPad); widget.CanFocus = true; widget.Sensitive = true; widget.DragBegin += (o, args) => { //if (!isDragging) //{ // var processedNode = dragPad.GetProcessedNode(dragPad.SelectedNode); // selected = new TemplateToolboxNode(new Ide.CodeTemplates.CodeTemplate() { Code = processedNode.Code }); // CurrentConsumer.DragItem(selected, widget, args.Context); // //DesignerSupport.Service.ToolboxService.DragSelectedItem(widget, args.Context); // isDragging = true; //} }; widget.DragEnd += (o, args) => { isDragging = false; }; widget.Focused += (s, e) => { // toolbox }; dragPad.SelectCode += (sender, e) => { if (!string.IsNullOrEmpty(e)) { try { var editor = IdeApp.Workbench.ActiveDocument.GetContent <ITextView>(); var position = editor.Caret.Position.BufferPosition.Position; editor.TextBuffer.Insert(position, e); } catch (Exception ex) { Console.WriteLine(ex); } } }; dragPad.DragSourceSet += (s, e) => { targets = new Gtk.TargetList(); targets.AddTable(e); }; dragPad.DragBegin += (object sender, EventArgs e) => { if (!isDragging) { Gtk.Drag.SourceUnset(widget); // Gtk.Application.CurrentEvent and other copied gdk_events seem to have a problem // when used as they use gdk_event_copy which seems to crash on de-allocating the private slice. IntPtr currentEvent = Components.GtkWorkarounds.GetCurrentEventHandle(); Gtk.Drag.Begin(widget, targets, Gdk.DragAction.Copy | Gdk.DragAction.Move, 1, new Gdk.Event(currentEvent)); // gtk_drag_begin does not store the event, so we're okay //Components.GtkWorkarounds.FreeEvent(currentEvent); } }; widget.ShowAll(); if (IdeApp.Workbench != null) { //IdeApp.Workbench.ActiveDocumentChanged += Workbench_ActiveDocumentChanged; IdeApp.Workbench.ActiveDocumentChanged += onActiveDocChanged; // += new EventHandler(onActiveDocChanged); onActiveDocChanged(null, null); } }
static Gtk.TargetEntry[] CreateTargetEntries(TransferDataType type) { lock (dragTargets) { Gtk.TargetEntry[] entries; if (dragTargets.TryGetValue(type, out entries)) { return(entries); } uint id = targetIdCounter++; if (type == TransferDataType.Uri) { Gtk.TargetList list = new Gtk.TargetList(); list.AddUriTargets(id); entries = (Gtk.TargetEntry[])list; } else if (type == TransferDataType.Text) { Gtk.TargetList list = new Gtk.TargetList(); list.AddTextTargets(id); //HACK: work around gtk_selection_data_set_text causing crashes on Mac w/ QuickSilver, Clipbard History etc. if (Platform.IsMac) { list.Remove("COMPOUND_TEXT"); list.Remove("TEXT"); list.Remove("STRING"); } entries = (Gtk.TargetEntry[])list; } else if (type == TransferDataType.Rtf) { Gdk.Atom atom; if (Platform.IsMac) { atom = Gdk.Atom.Intern("NSRTFPboardType", false); //TODO: use public.rtf when dep on MacOS 10.6 } else if (Platform.IsWindows) { atom = Gdk.Atom.Intern("Rich Text Format", false); } else { atom = Gdk.Atom.Intern("text/rtf", false); } entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry(atom, 0, id) }; } else if (type == TransferDataType.Html) { Gdk.Atom atom; if (Platform.IsMac) { atom = Gdk.Atom.Intern("Apple HTML pasteboard type", false); //TODO: use public.rtf when dep on MacOS 10.6 } else if (Platform.IsWindows) { atom = Gdk.Atom.Intern("HTML Format", false); } else { atom = Gdk.Atom.Intern("text/html", false); } entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry(atom, 0, id) }; } else if (type == TransferDataType.Image) { Gtk.TargetList list = new Gtk.TargetList(); list.AddImageTargets(id, true); entries = (Gtk.TargetEntry[])list; } else { entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry(Gdk.Atom.Intern("application/" + type.Id, false), 0, id) }; } foreach (var a in entries.Select(e => e.Target)) { atomToType [a] = type; } return(dragTargets [type] = entries); } }