コード例 #1
0
        public static Gtk.Clipboard Get(Gdk.Atom selection)
        {
            IntPtr raw_ret = gtk_clipboard_get(selection == null ? IntPtr.Zero : selection.Handle);

            Gtk.Clipboard ret = GLib.Object.GetObject(raw_ret) as Gtk.Clipboard;
            return(ret);
        }
コード例 #2
0
        public static Gtk.Clipboard GetDefault(Gdk.Display display)
        {
            IntPtr raw_ret = gtk_clipboard_get_default(display == null ? IntPtr.Zero : display.Handle);

            Gtk.Clipboard ret = GLib.Object.GetObject(raw_ret) as Gtk.Clipboard;
            return(ret);
        }
コード例 #3
0
        private void Activated(object sender, EventArgs e)
        {
            NewImageDialog dialog = new NewImageDialog();

            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable())
            {
                Gdk.Pixbuf image = cb.WaitForImage();
                dialog.NewImageWidth  = image.Width;
                dialog.NewImageHeight = image.Height;
            }
            else
            {
                dialog.NewImageWidth  = PintaCore.Settings.GetSetting <int> ("new-image-width", 800);
                dialog.NewImageHeight = PintaCore.Settings.GetSetting <int> ("new-image-height", 600);
            }

            dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;

            int response = dialog.Run();

            if (response == (int)Gtk.ResponseType.Ok)
            {
                PintaCore.Workspace.NewDocument(new Gdk.Size(dialog.NewImageWidth, dialog.NewImageHeight), false);

                PintaCore.Settings.PutSetting("new-image-width", dialog.NewImageWidth);
                PintaCore.Settings.PutSetting("new-image-height", dialog.NewImageHeight);
                PintaCore.Settings.SaveSettings();
            }

            dialog.Destroy();
        }
コード例 #4
0
ファイル: TextEngine.cs プロジェクト: casey0102/Pinta
        public void PerformPaste(Gtk.Clipboard clipboard)
        {
            string txt = string.Empty;

            txt = clipboard.WaitForText();
            if (String.IsNullOrEmpty(txt))
            {
                return;
            }
            string[] ins_lines = txt.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.None);
            string   endline   = lines [linePos].Substring(textPos);

            lines [linePos] = lines [linePos].Substring(0, textPos);
            bool first = true;

            foreach (string ins_txt in ins_lines)
            {
                if (!first)
                {
                    linePos++;
                    lines.Insert(linePos, ins_txt);
                    textPos = ins_txt.Length;
                }
                else
                {
                    first           = false;
                    lines[linePos] += ins_txt;
                    textPos        += ins_txt.Length;
                }
            }
            lines [linePos] += endline;

            Recalculate();
        }
コード例 #5
0
        public static Gtk.Clipboard GetForDisplay(Gdk.Display display, Gdk.Atom selection)
        {
            IntPtr raw_ret = gtk_clipboard_get_for_display(display == null ? IntPtr.Zero : display.Handle, selection == null ? IntPtr.Zero : selection.Handle);

            Gtk.Clipboard ret = GLib.Object.GetObject(raw_ret) as Gtk.Clipboard;
            return(ret);
        }
コード例 #6
0
        void InvokeNative(Gtk.Clipboard clipboard, string text)
        {
            IntPtr native_text = GLib.Marshaller.StringToPtrGStrdup(text);

            native_cb(clipboard == null ? IntPtr.Zero : clipboard.Handle, native_text, __data);
            GLib.Marshaller.Free(native_text);
        }
コード例 #7
0
ファイル: TextEngine.cs プロジェクト: Pinta-NET/Pinta-NET
        public void PerformCopy(Gtk.Clipboard clipboard)
        {
            if (HasSelection())
            {
                StringBuilder strbld = new StringBuilder();

                TextPosition start = TextPosition.Min(currentPos, selectionStart);
                TextPosition end   = TextPosition.Max(currentPos, selectionStart);
                ForeachLine(start, end, (currentLinePos, strpos, endpos) => {
                    if (endpos - strpos > 0)
                    {
                        strbld.AppendLine(lines[currentLinePos].Substring(strpos, endpos - strpos));
                    }
                    else if (endpos == strpos)
                    {
                        strbld.AppendLine();
                    }
                });
                strbld.Remove(strbld.Length - Environment.NewLine.Length, Environment.NewLine.Length);

                clipboard.Text = strbld.ToString();
            }
            else
            {
                clipboard.Clear();
            }
        }
コード例 #8
0
ファイル: TextEngine.cs プロジェクト: ywscr/Pinta
		/// <summary>
		/// Pastes text from the clipboard.
		/// </summary>
		/// <returns>
		/// <c>true</c>, if the paste was successfully performed, <c>false</c> otherwise.
		/// </returns>
		public bool PerformPaste (Gtk.Clipboard clipboard)
		{
			string txt = string.Empty;
			txt = clipboard.WaitForText ();
			if (String.IsNullOrEmpty (txt))
				return false;

            if (HasSelection ())
                DeleteSelection ();

			string[] ins_lines = txt.Split (Environment.NewLine.ToCharArray (), StringSplitOptions.RemoveEmptyEntries);
			string endline = lines [currentPos.Line].Substring (currentPos.Offset);
			lines [currentPos.Line] = lines [currentPos.Line].Substring (0, currentPos.Offset);
			bool first = true;
			foreach (string ins_txt in ins_lines) {
				if (!first) {
					currentPos.Line++;
					lines.Insert (currentPos.Line, ins_txt);
					currentPos.Offset = ins_txt.Length;
				} else {
					first = false;
					lines[currentPos.Line] += ins_txt;
					currentPos.Offset += ins_txt.Length;
				}
			}
			lines [currentPos.Line] += endline;

            selectionStart = currentPos;
			State = TextMode.Uncommitted;

			OnModified ();
			return true;
		}
コード例 #9
0
ファイル: MessageTextView.cs プロジェクト: licnep/smuxi
        protected virtual void OnPopulatePopup(object sender, Gtk.PopulatePopupArgs e)
        {
            Trace.Call(sender, e);

            if (!_AtLinkTag)
            {
                return;
            }

            Gtk.Menu popup = e.Menu;
            // remove all items
            foreach (Gtk.Widget children in popup.Children)
            {
                popup.Remove(children);
            }

            Gtk.ImageMenuItem open_item = new Gtk.ImageMenuItem(Gtk.Stock.Open, null);
            open_item.Activated += delegate {
                if (_ActiveLink != null)
                {
                    OpenLink(_ActiveLink);
                }
            };
            popup.Append(open_item);

            Gtk.ImageMenuItem copy_item = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null);
            copy_item.Activated += delegate {
                Gdk.Atom      clipboardAtom = Gdk.Atom.Intern("CLIPBOARD", false);
                Gtk.Clipboard clipboard     = Gtk.Clipboard.Get(clipboardAtom);
                clipboard.Text = _ActiveLink.ToString();
            };
            popup.Append(copy_item);

            popup.ShowAll();
        }
コード例 #10
0
 protected override void Run()
 {
     if (IdeApp.Workbench.RootWindow.HasToplevelFocus)
     {
         Gtk.Editable editable = IdeApp.Workbench.RootWindow.Focus as Gtk.Editable;
         if (editable != null)
         {
             editable.PasteClipboard();
             return;
         }
         Gtk.TextView tv = IdeApp.Workbench.RootWindow.Focus as Gtk.TextView;
         if (tv != null)
         {
             Gtk.Clipboard clipboard = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
             tv.Buffer.PasteClipboard(clipboard);
             return;
         }
                         #if MAC
         var mactv = AppKit.NSApplication.SharedApplication.KeyWindow.FirstResponder as AppKit.NSText;
         if (mactv != null)
         {
             mactv.Paste(mactv);
             return;
         }
                         #endif
     }
 }
コード例 #11
0
        public static void RequestTargets(Gtk.Clipboard clipboard, ClipboardTargetsReceivedFunc cb)
        {
            var cb_wrapper = new ClipboardTargetsReceivedFuncWrapper(cb);

            cb_wrapper.PersistUntilCalled();
            gtk_clipboard_request_targets(clipboard.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
        }
コード例 #12
0
        protected void OnBtnCopyCountClicked(object sender, EventArgs e)
        {
            String msg = _voteCount.GetPostableVoteCount();

            Gtk.Clipboard clip = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            clip.Text = msg;
        }
コード例 #13
0
 public DataRequest(Gtk.Clipboard clipboard, AsyncCallback callback, object state, TransferDataType type, Gdk.Atom[] atoms)
 {
     this.callback  = callback;
     this.type      = type;
     AsyncState     = state;
     this.atoms     = atoms;
     this.clipboard = clipboard;
     RequestData();
 }
コード例 #14
0
ファイル: TextEdit.cs プロジェクト: anthrax3/ide-1
        public void CopyClipboard()
        {
            if (String.IsNullOrEmpty(this.SelectedText))
            {
                return;
            }

            Gtk.Clipboard clipboard = this.GetClipboard(Gdk.Selection.Clipboard);
            clipboard.Text = this.SelectedText;
        }
コード例 #15
0
ファイル: Controller.cs プロジェクト: codecopy/core-1
        void OnPasteEvent(EventKey evnt)
        {
            Gtk.Clipboard clip = Gtk.Clipboard.Get(Selection.Clipboard);
            if (!clip.WaitIsTextAvailable())
            {
                return;
            }
            string str = clip.WaitForText();

            SearchController.SetString(SearchController.Query + str);
        }
コード例 #16
0
ファイル: Watchers.cs プロジェクト: shubhtr/tomboy-1
        void CopyLinkActivate(object sender, EventArgs args)
        {
            Gtk.TextIter click_iter = Buffer.GetIterAtMark(click_mark);

            Gtk.TextIter start, end;
            Note.TagTable.UrlTag.GetExtents(click_iter, out start, out end);

            string url = GetUrl(start, end);

            Gtk.Clipboard clip = Window.Editor.GetClipboard(Gdk.Selection.Clipboard);
            clip.Text = url;
        }
コード例 #17
0
 public void ClipboardTargetsReceivedFunc(Gtk.Clipboard clipboard, Gdk.Atom [] atoms, int n_atoms)
 {
     Trace.WriteLine($"{nameof (clipboard)}-{nameof (IsTypeAvailable)}:");
     foreach (var f in atoms)
     {
         Trace.WriteLine($"\t{f.Name}");
     }
     if (atoms.Any(f => f == "text/x-moz-url-priv"))
     {
         var data = this.GetData(Xwt.TransferDataType.FromId("text/x-moz-url-priv"));
         Trace.WriteLine($"\t{data}");
     }
 }
コード例 #18
0
ファイル: EditAction.cs プロジェクト: anthrax3/ide-1
        public void CopyText(object obj, EventArgs args)
        {
            if (this.editor == null)
            {
                return;
            }
            if (String.IsNullOrEmpty(this.editor.SelectedText))
            {
                return;
            }

            Gtk.Clipboard clipboard = this.editor.GetClipboard(Gdk.Selection.Clipboard);
            clipboard.Text = this.editor.SelectedText;            // RequestText (new Gtk.ClipboardTextReceivedFunc (PasteReceived));
        }
コード例 #19
0
        protected void OnRepositoryUrlEntryClipboardPasted(object sender, EventArgs e)
        {
            Gtk.Clipboard clip = GetClipboard(Gdk.Atom.Intern("CLIPBOARD", false));
            clip.RequestText(delegate(Gtk.Clipboard clp, string text) {
                if (String.IsNullOrEmpty(text))
                {
                    return;
                }

                Uri url;
                if (Uri.TryCreate(text, UriKind.Absolute, out url))
                {
                    repositoryUrlEntry.Text = text;
                }
            });
        }
コード例 #20
0
 public void PerformCopy(Gtk.Clipboard clipboard)
 {
     if (selectionRelativeIndex > 0)
     {
         clipboard.Text = GetText(linePos, textPos, selectionRelativeIndex);
     }
     else if (selectionRelativeIndex < 0)
     {
         Position p = IndexToPosition(PositionToIndex(new Position(linePos, textPos)) + selectionRelativeIndex);
         clipboard.Text = GetText(p.Line, p.Offset, -selectionRelativeIndex);
     }
     else
     {
         clipboard.Clear();
     }
 }
コード例 #21
0
ファイル: Clipboard.cs プロジェクト: glib-sharp/gtk-sharp
 void RichTextReceivedCallback(IntPtr clipboard_ptr, IntPtr format_ptr, IntPtr text_ptr, UIntPtr length, IntPtr data)
 {
     try {
         Gtk.Clipboard clipboard = GLib.Object.GetObject(clipboard_ptr) as Gtk.Clipboard;
         Gdk.Atom      format    = format_ptr == IntPtr.Zero ? null : (Gdk.Atom)GLib.Opaque.GetOpaque(format_ptr, typeof(Gdk.Atom), false);
         int           sz        = (int)(uint)length;
         byte[]        text      = new byte [sz];
         Marshal.Copy(text, 0, text_ptr, sz);
         GCHandle             gch = (GCHandle)data;
         RichTextReceivedFunc cb  = gch.Target as RichTextReceivedFunc;
         cb(clipboard, format, text);
         gch.Free();
     } catch (Exception e) {
         GLib.ExceptionManager.RaiseUnhandledException(e, false);
     }
 }
コード例 #22
0
        public ReceiveDialog()
        {
            this.Build();

            entry1.Text = App.Instance.Wallet.GetUnusedKey().Address.ToString();

            Gtk.Clipboard clipboard = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));

            buttonCopy.Clicked += delegate {
                clipboard.Text = entry1.Text;
            };

            buttonClose.Clicked += delegate {
                CloseDialog();
            };
        }
コード例 #23
0
        protected override void Run()
        {
                        #if WIN32
            var wintv = System.Windows.Input.Keyboard.FocusedElement;
            var cmd   = System.Windows.Input.ApplicationCommands.Cut;
            if (wintv != null && cmd.CanExecute(null, wintv))
            {
                cmd.Execute(null, wintv);
                return;
            }
                        #endif

            if (IdeApp.Workbench.RootWindow.HasToplevelFocus)
            {
                Gtk.Editable editable = IdeApp.Workbench.RootWindow.Focus as Gtk.Editable;
                if (editable != null)
                {
                    editable.CutClipboard();
                    return;
                }
                Gtk.TextView tv = IdeApp.Workbench.RootWindow.Focus as Gtk.TextView;
                if (tv != null)
                {
                    Gtk.Clipboard clipboard = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
                    tv.Buffer.CutClipboard(clipboard, true);
                    return;
                }
            }

                        #if MAC
            var keyWindow = AppKit.NSApplication.SharedApplication.KeyWindow;
            var focusView = keyWindow?.FirstResponder;
            if (focusView != null)
            {
                var mactv = focusView as AppKit.NSText;
                if (mactv != null)
                {
                    mactv.Cut(mactv);
                }
                else
                {
                    AppKit.NSApplication.SharedApplication.SendAction(cutSelector, focusView, keyWindow);
                }
                return;
            }
                        #endif
        }
コード例 #24
0
ファイル: UploadDialog.cs プロジェクト: gifuser/Gifuser
        void Uploader_Completed(object sender, UploadCompletedEventArgs e)
        {
            Gtk.Application.Invoke(delegate
            {
                _uploadFinished = true;

                if (!e.Canceled)
                {
                    string newLine = Environment.NewLine;

                    Gtk.MessageDialog dialog;
                    if (e.HasError)
                    {
                        string txt = string.Format("An error occurred in the upload.{0}{0}You will need to upload your file manually:{0}{0}{1}", newLine, _fileName);
                        dialog     = new Gtk.MessageDialog(
                            this,
                            Gtk.DialogFlags.Modal,
                            Gtk.MessageType.Info,
                            Gtk.ButtonsType.Ok,
                            txt
                            );
                    }
                    else
                    {
                        using (Gtk.Clipboard clipboard = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false)))
                        {
                            clipboard.Text = e.Link;
                        }

                        string txt = string.Format("Done!{0}{0}{1}{0}{0}The link is already on your clipboard.", newLine, e.Link);
                        dialog     = new Gtk.MessageDialog(
                            this,
                            Gtk.DialogFlags.Modal,
                            Gtk.MessageType.Info,
                            Gtk.ButtonsType.Ok,
                            txt
                            );
                    }

                    dialog.Run();
                    dialog.Destroy();
                }

                Destroy();
            });
        }
コード例 #25
0
 protected override void Run()
 {
     if (IdeApp.Workbench.RootWindow.HasToplevelFocus)
     {
         Gtk.Editable editable = IdeApp.Workbench.RootWindow.Focus as Gtk.Editable;
         if (editable != null)
         {
             editable.PasteClipboard();
             return;
         }
         Gtk.TextView tv = IdeApp.Workbench.RootWindow.Focus as Gtk.TextView;
         if (tv != null)
         {
             Gtk.Clipboard clipboard = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
             tv.Buffer.PasteClipboard(clipboard);
             return;
         }
     }
 }
コード例 #26
0
ファイル: EditAction.cs プロジェクト: anthrax3/ide-1
        void PasteReceived(Gtk.Clipboard clipboard, string text)
        {
            ISegment sg = this.editor.SelectionRange;

            if ((sg != null) && sg.Length > 0)
            {
                this.editor.Replace(sg.Offset, sg.Length, text);
                int newPositionCaret = sg.Offset + text.Length;

                DocumentLocation dl = this.editor.Document.OffsetToLocation(newPositionCaret);

                Caret caret = this.editor.Caret;
                caret.Location = dl;
            }
            else
            {
                this.editor.InsertAtCaret(text);
            };
        }
コード例 #27
0
        public void ClipboardTargetsReceivedFuncWorkaround(Gtk.Clipboard clipboard, Gdk.Atom atoms, int n_atoms)
        {
            if (atoms == null)
            {
                return;
            }

            // solution from:
            var hint = nameof(Gtk.TextBuffer.SerializeFormats);
            //

            var list_ptr = atoms.Handle;
            var result   = new Gdk.Atom [n_atoms];

            for (var i = 0; i < n_atoms; i++)
            {
                var format = Marshal.ReadIntPtr(list_ptr, i * IntPtr.Size);
                result [i] = format == IntPtr.Zero ? null : (Gdk.Atom)GLib.Opaque.GetOpaque(format, typeof(Gdk.Atom), false);
            }
        }
コード例 #28
0
        /// <summary>
        /// Sets the dialog to use the clipboard image's dimensions, if possible.
        /// </summary>
        /// <returns>True if an image was on the clipboard, false otherwise.</returns>
        private static bool TryUseClipboardImageSize(NewImageDialog dialog)
        {
            bool clipboardUsed = false;

            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable())
            {
                Gdk.Pixbuf image = cb.WaitForImage();
                if (image != null)
                {
                    clipboardUsed         = true;
                    dialog.NewImageWidth  = image.Width;
                    dialog.NewImageHeight = image.Height;
                    image.Dispose();
                }
            }

            cb.Dispose();

            return(clipboardUsed);
        }
コード例 #29
0
        void DataReceived(Gtk.Clipboard cb, Gtk.SelectionData data)
        {
            TransferDataStore store = new TransferDataStore();

            if (Util.GetSelectionData(data, store))
            {
                Result = ((ITransferData)store).GetValue(type);
                SetComplete();
            }
            else
            {
                if (++index < atoms.Length)
                {
                    RequestData();
                }
                else
                {
                    SetComplete();
                }
            }
        }
コード例 #30
0
        /// <summary>
        /// Gets the width and height of an image on the clipboard,
        /// if available.
        /// </summary>
        /// <param name="width">Destination for the image width.</param>
        /// <param name="height">Destination for the image height.</param>
        /// <returns>True if dimensions were available, false otherwise.</returns>
        private static bool GetClipboardImageSize(out int width, out int height)
        {
            bool clipboardUsed = false;

            width = height = 0;

            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable())
            {
                Gdk.Pixbuf image = cb.WaitForImage();
                if (image != null)
                {
                    clipboardUsed = true;
                    width         = image.Width;
                    height        = image.Height;
                    image.Dispose();
                }
            }

            cb.Dispose();

            return(clipboardUsed);
        }
コード例 #31
0
 public TextAreaClipboardHandler(TextArea textArea)
 {
     this.textArea = textArea;
     clipboard = Gtk.Clipboard.Get (Gdk.Atom.Intern("CLIPBOARD", false));
     textArea.SelectionManager.SelectionChanged += new EventHandler(DocumentSelectionChanged);
 }
コード例 #32
0
ファイル: ClipboardManager.cs プロジェクト: izadi/GtkEdit
 public ClipboardManager(Gtk.Clipboard clipboard)
 {
     this.clipboard = clipboard;
 }
コード例 #33
0
ファイル: ClipboardBackend.cs プロジェクト: StEvUgnIn/xwt
		public DataRequest (ApplicationContext context, Gtk.Clipboard clipboard, AsyncCallback callback, object state, TransferDataType type, Gdk.Atom[] atoms)
		{
			this.context = context;
			this.callback = callback;
			this.type = type;
			AsyncState = state;
			this.atoms = atoms;
			this.clipboard = clipboard;
			RequestData ();
		}
コード例 #34
0
ファイル: ClipboardBackend.cs プロジェクト: pixelmeister/xwt
 public DataRequest(Gtk.Clipboard clipboard, AsyncCallback callback, object state, string type, Gdk.Atom[] atoms)
 {
     this.callback = callback;
     this.type = type;
     AsyncState = state;
     this.atoms = atoms;
     this.clipboard = clipboard;
     RequestData ();
 }
コード例 #35
0
ファイル: ClipboardBackend.cs プロジェクト: StEvUgnIn/xwt
		public GtkClipboardBackend ()
		{
			clipboard = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
//			primaryClipboard = Gtk.Clipboard.Get (Gdk.Atom.Intern ("PRIMARY", false));
		}