示例#1
0
    void CbGetFunc(Gtk.Clipboard cb, ref Gtk.SelectionData sd, uint info, object o)
    {
        if (info == 0)
        {
            // string
            // so we want to return filenames

            StringBuilder sb = new StringBuilder();
            foreach (string iid in cb_currently_selected)
            {
                sb.Append(repo.GetImage(iid).FullFilename);
                sb.Append(" ");
            }

            sd.Text = sb.ToString();
        }
        else if (info == 1)
        {
            // mphoto_imageid_list
            StringBuilder sb = new StringBuilder();
            foreach (string iid in cb_currently_selected)
            {
                sb.Append(iid);
                Console.WriteLine(" cb append: " + iid);
                sb.Append(";");
            }
            // we cheat here and tell it to just set it as a string
            sd.Text = sb.ToString();
        }
    }
    private void ReceivedFunc(Gtk.Clipboard clipboard, Gtk.SelectionData selection)
    {
        var temp = _encoding.GetString(selection.Data);

        if (temp == null)
        {
            return;
        }

        var items = temp.Split();

        for (int i = 1; i < items.Length; i++)
        {
            var fileFrom = items[i].Substring("file://".Length);
            var fileTo   = System.IO.Path.Combine(_destination, System.IO.Path.GetFileName(fileFrom));
            if (items[0] == "copy")
            {
                File.Copy(fileFrom, fileTo);
            }
            else if (items[1] == "cut")
            {
                File.Move(fileFrom, fileTo);
            }
        }
    }
示例#3
0
        public bool DragDataGet(Gtk.TreePath path, Gtk.SelectionData selection_data)
        {
            bool raw_ret = gtk_tree_drag_source_drag_data_get(Handle, path.Handle, selection_data.Handle);
            bool ret     = raw_ret;

            return(ret);
        }
示例#4
0
        public bool DragDataReceived(Gtk.TreePath dest, Gtk.SelectionData selection_data)
        {
            bool raw_ret = gtk_tree_drag_dest_drag_data_received(Handle, dest.Handle, selection_data.Handle);
            bool ret     = raw_ret;

            return(ret);
        }
示例#5
0
        protected override void OnDragDataReceived(Gdk.DragContext context, int x, int y,
                                                   Gtk.SelectionData data, uint info, uint time)
        {
            try {
                if (final_drag_start_time != context.StartTime || final_drag_source == null)
                {
                    Gtk.Drag.Finish(context, false, false, time);
                    return;
                }

                Source drop_source = final_drag_source;

                if (final_drag_source == NewPlaylistSource)
                {
                    PlaylistSource playlist = new PlaylistSource(Catalog.GetString("New Playlist"),
                                                                 (new_playlist_parent as PrimarySource));
                    playlist.Save();
                    playlist.PrimarySource.AddChildSource(playlist);
                    drop_source = playlist;
                }

                if (data.Target.Name == Banshee.Gui.DragDrop.DragDropTarget.Source.Target)
                {
                    DragDropList <Source> sources = data;
                    if (sources.Count > 0)
                    {
                        drop_source.MergeSourceInput(sources[0], SourceMergeType.Source);
                    }
                }
                else if (data.Target.Name == Banshee.Gui.DragDrop.DragDropTarget.UriList.Target)
                {
                    foreach (string uri in DragDropUtilities.SplitSelectionData(data))
                    {
                        // TODO if we dropped onto a playlist, add ourselves
                        // to it after importing (or if already imported, find
                        // and add to playlist)
                        ServiceManager.Get <Banshee.Library.LibraryImportManager> ().Enqueue(uri);
                    }
                }
                else if (data.Target.Name == Hyena.Data.Gui.ListViewDragDropTarget.ModelSelection.Target)
                {
                    // If the drag source is not the track list, it's a filter list, and instead of
                    // only merging the track model's selected tracks, we should merge all the tracks
                    // currently matching the active filters.
                    bool from_filter = !(Gtk.Drag.GetSourceWidget(context) is Banshee.Collection.Gui.BaseTrackListView);
                    drop_source.MergeSourceInput(
                        ServiceManager.SourceManager.ActiveSource,
                        from_filter ? SourceMergeType.Source : SourceMergeType.ModelSelection
                        );
                }
                else
                {
                    Hyena.Log.DebugFormat("SourceView got unknown drag target type: {0}", data.Target.Name);
                }

                Gtk.Drag.Finish(context, true, false, time);
            } finally {
                HideNewPlaylistRow();
            }
        }
示例#6
0
        public bool RowDropPossible(Gtk.TreePath dest_path, Gtk.SelectionData selection_data)
        {
            bool raw_ret = gtk_tree_drag_dest_row_drop_possible(Handle, dest_path.Handle, selection_data.Handle);
            bool ret     = raw_ret;

            return(ret);
        }
 public new bool DragDataReceived(TreePath path, SelectionData data)
 {
     logger.Debug("DragDataReceived dstPath={0}", path);
     TreeModel srcModel;
     TreePath srcPath;
     TreeIter srcIter, dstIter, newIter, ParentIter;
     if(Tree.GetRowDragData(data, out srcModel, out srcPath))
     {
         logger.Debug("DragDataReceived srcPath={0}", srcPath);
         bool Last = false;
         if(!this.GetIter(out dstIter, path))
         {
             path.Prev();
             Last = true;
             this.GetIter(out dstIter, path);
         }
         this.GetIter(out srcIter, srcPath);
         this.IterParent(out ParentIter, dstIter);
         if(Last)
             newIter = this.InsertNodeAfter(ParentIter, dstIter);
         else
             newIter = this.InsertNodeBefore(ParentIter, dstIter);
         CopyValues(srcIter, newIter);
         return true;
     }
     return false;
 }
示例#8
0
			public void SetData (SelectionData selection_data, uint info)
			{
				if (selection_data == null)
					return;
				switch (info) {
				case TextType:
					// Windows specific hack to work around bug: Bug 661973 - copy operation in TextEditor braks text lines with duplicate line endings when the file has CRLF
					// Remove when https://bugzilla.gnome.org/show_bug.cgi?id=640439 is fixed.
					if (Platform.IsWindows) {
						selection_data.Text = copiedDocument.Text.Replace ("\r\n", "\n");
					} else {
						selection_data.Text = copiedDocument.Text;
					}
					break;
				case RichTextType:
					selection_data.Set (RTF_ATOM, UTF8_FORMAT, System.Text.Encoding.UTF8.GetBytes (RtfWriter.GenerateRtf (copiedDocument, mode, docStyle, options)));
					break;
				case HTMLTextType:
					selection_data.Set (HTML_ATOM, UTF8_FORMAT, System.Text.Encoding.UTF8.GetBytes (HtmlWriter.GenerateHtml (copiedDocument, mode, docStyle, options)));
					break;
				case MonoTextType:
					byte[] rawText = System.Text.Encoding.UTF8.GetBytes (monoDocument.Text);
					byte[] data = new byte [rawText.Length + 1];
					rawText.CopyTo (data, 1);
					data [0] = 0;
					if (isBlockMode)
						data [0] |= 1;
					if (isLineSelectionMode)
						data [0] |= 2;
					selection_data.Set (MD_ATOM, UTF8_FORMAT, data);
					break;
				}
			}
示例#9
0
 protected override void OnDragDataGet(Gdk.DragContext context, Gtk.SelectionData selection_data, uint info, uint time_)
 {
     if (info == DragDropTargets.UriQueryEntry.Info ||
         info == (uint)DragDropTargets.TargetType.UriList ||
         info == (uint)DragDropTargets.TargetType.PlainText)
     {
         selection_data.SetUriListData(SelectedUris, context.Targets[0]);
         return;
     }
 }
 public void ClipboardGetFunc(Clipboard clipboard, SelectionData selection_data, uint info)
 {
     if (selection_data == null)
         return;
     switch (info) {
         case TextType:
             selection_data.Text = Utils.ToNormalString (lyrics_text);
             break;
     }
 }
示例#11
0
        public static TreePath [] SelectionDataToTreePaths(Gtk.SelectionData data)
        {
            string rawData = String.Empty;

            try {
                rawData = SelectionDataToString(data);
                return(SelectionDataToTreePaths(rawData));
            } catch (Exception) {
                return(null);
            }
        }
示例#12
0
        public static string SelectionDataToString(Gtk.SelectionData data)
        {
            if (data.Length <= 0)
            {
                return(String.Empty);
            }

            try {
                return(System.Text.Encoding.UTF8.GetString(data.Data));
            } catch {
                return(String.Empty);
            }
        }
示例#13
0
        protected override void OnDragDataGet(Gdk.DragContext context, SelectionData selectionData,
            uint info, uint time)
        {
            switch ((DragDropTargetType)info) {
                case DragDropTargetType.Source:
                    new DragDropList<Source> (ServiceManager.SourceManager.ActiveSource,
                        selectionData, context.ListTargets ()[0]);
                    break;
                default:
                    return;
            }

            base.OnDragDataGet (context, selectionData, info, time);
        }
		private void ReceivedFunc(Clipboard clipboard, SelectionData selection) {
			string temp = Encoding.ASCII.GetString(selection.Data);
			if (temp==null) return;
			
			string[] items = temp.Split('\n', '\r');
			List<Uri> paths = new List<Uri>(items.Length);
			for(int i = 1; i < items.Length; ++i) {
				if(items[i] == string.Empty) continue;
				Uri fileFrom = new Uri(items[i]);
				paths.Add(fileFrom);
			}
			
			inData = new ClipboardData(paths, items[0] == "cut" ? ClipboardOperationType.Cut : ClipboardOperationType.Copy);
			evt(null, null);
		}
示例#15
0
        static void ClipboardGet(Gtk.Clipboard clipboard, Gtk.SelectionData seldata, uint info)
        {
            if (selection == null)
            {
                return;
            }

            if (info == TextType)
            {
                seldata.Text = selection.OuterXml;
            }
            else
            {
                seldata.Set(WidgetUtils.ApplicationXSteticAtom, 8, System.Text.Encoding.UTF8.GetBytes(selection.OuterXml));
            }
        }
示例#16
0
        static void ClipboardPaste(Gtk.Clipboard clipboard, Gtk.SelectionData seldata)
        {
            Stetic.Wrapper.Container parent = Stetic.Wrapper.Container.LookupParent(target);
            if (parent == null)
            {
                return;
            }

            Stetic.Wrapper.Widget wrapper = WidgetUtils.Paste(parent.Project, seldata);
            if (wrapper == null)
            {
                return;
            }

            parent.PasteChild(target, wrapper.Wrapped);
            target = null;
        }
示例#17
0
			public void SetData (SelectionData selection_data, uint info)
			{
				if (selection_data == null)
					return;
				switch (info) {
				case TextType:
					// Windows specific hack to work around bug: Bug 661973 - copy operation in TextEditor braks text lines with duplicate line endings when the file has CRLF
					// Remove when https://bugzilla.gnome.org/show_bug.cgi?id=640439 is fixed.
					if (Platform.IsWindows) {
						selection_data.Text = copiedDocument.Text.Replace ("\r\n", "\n");
					} else {
						selection_data.Text = copiedDocument.Text;
					}
					break;
				case RichTextType:
					var rtf = RtfWriter.GenerateRtf (copiedDocument, mode, docStyle, options);
//					Console.WriteLine ("rtf:" + rtf);
					selection_data.Set (RTF_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes (rtf));
					break;
				case HTMLTextType:
					var html = HtmlWriter.GenerateHtml (copiedDocument, mode, docStyle, options);
//					Console.WriteLine ("html:" + html);
					selection_data.Set (HTML_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes (html));
					break;
				case MonoTextType:
					byte[] rawText = Encoding.UTF8.GetBytes (monoDocument.Text);
					var copyDataLength = (byte)(copyData != null ? copyData.Length : 0);
					var dataOffset = 1 + 1 + copyDataLength;
					byte[] data = new byte [rawText.Length + dataOffset];
					data [1] = copyDataLength;
					if (copyDataLength > 0)
						copyData.CopyTo (data, 2);
					rawText.CopyTo (data, dataOffset);
					data [0] = 0;
					if (isBlockMode)
						data [0] |= 1;
					if (isLineSelectionMode)
						data [0] |= 2;
					selection_data.Set (MD_ATOM, UTF8_FORMAT, data);
					break;
				}
			}
        public bool DragDataReceived(TreePath path, SelectionData data)
        {
            Console.WriteLine("DragDataReceived dstPath={0}", path);
            TreeModel srcModel;
            TreePath srcPath;
            if(Tree.GetRowDragData(data, out srcModel, out srcPath))
            {
                Console.WriteLine("DragDataReceived srcPath={0}", srcPath);
                object row = NodeAtPath (srcPath);
                SourceList.RemoveAt (srcPath.Indices[0]);
                if (srcPath.Indices [0] < path.Indices [0])
                    path.Prev ();

                if (path.Indices [0] == SourceList.Count)
                    SourceList.Add (row);
                else
                    SourceList.Insert (path.Indices [0], row);
                return true;
            }
            return false;
        }
示例#19
0
    public void DoEditPaste()
    {
        Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("PRIMARY", false));

        Gtk.SelectionData sd = cb.WaitForContents(Gdk.Atom.Intern("MPHOTO_IMAGEID_LIST", false));

        string s = sd.Text;

        Console.WriteLine("PASTE: '" + s + "'");
        string[] imageids = s.Split(';');

        collection.FreezeUpdates();
        foreach (string iid in imageids)
        {
            if (iid.Length == 0)
            {
                continue;
            }
            collection.AddItem(iid);
        }
        collection.ThawUpdates();
    }
示例#20
0
			public void SetData (SelectionData selection_data, uint info)
			{
				if (selection_data == null)
					return;
				switch (info) {
				case TextType:
					selection_data.Text = copiedDocument.Text;
					break;
				case RichTextType:
					selection_data.Set (RTF_ATOM, UTF8_FORMAT, System.Text.Encoding.UTF8.GetBytes (GenerateRtf (copiedDocument, mode, docStyle, options)));
					break;
				case MonoTextType:
					byte[] rawText = System.Text.Encoding.UTF8.GetBytes (monoDocument.Text);
					byte[] data    = new byte [rawText.Length + 1];
					rawText.CopyTo (data, 1);
					data[0] = 0;
					if (isBlockMode)
						data[0] |= 1;
					if (isLineSelectionMode)
						data[0] |= 2;
					selection_data.Set (MD_ATOM, UTF8_FORMAT, data);
					break;
				}
			}
示例#21
0
			public void ClipboardGetFunc (Clipboard clipboard, SelectionData selection_data, uint info)
			{
				SetData (selection_data, info);
			}
示例#22
0
        protected override void OnDragDataReceived(Gdk.DragContext context, int x, int y, Gtk.SelectionData selection_data, uint info, uint time_)
        {
            base.OnDragDataReceived(context, x, y, selection_data, info, time_);

            SetFolders(selection_data.GetUriListData());
            query.RequestReload();
        }
		public bool DragDataReceived(TreePath path, SelectionData selectionData)
		{
			return true;
		}
示例#24
0
 // Methods
 // Methods :: Public
 // Methods :: Public :: SelectionDataToString
 /// <summary>
 ///	Converts <see cref="Gtk.SelectionData" /> to a
 ///     <see cref="String" />.
 /// </summary>
 /// <remarks>
 ///	Data in <see cref="Gtk.SelectionData" /> is held as an
 ///     array of <see cref="Byte">bytes</see>. This function
 ///	just calls <see cref="System.Text.Encoding.UTF8.GetString" />
 ///	on that array.
 /// </remarks>
 /// <param name="data">
 ///	A <see cref="Gtk.SelectionData" /> object.
 /// </param>
 public static string SelectionDataToString(Gtk.SelectionData data)
 {
     return(System.Text.Encoding.UTF8.GetString(data.Data));
 }
示例#25
0
		public bool RowDropPossible(TreePath path, SelectionData data){
			return LocationsModel.RowDropPossible(path,data);
		}
示例#26
0
文件: Item.cs 项目: quequotion/glippy
        /// <summary>
        /// Gets complex data from item and sets as content when requested.
        /// </summary>
        /// <param name="clipboard">Clipboard.</param>
        /// <param name="selectionData">Selection data.</param>
        /// <param name="info">Target index.</param>
        internal void GetDataFunc(Gtk.Clipboard clipboard, SelectionData selectionData, uint info)
        {
            switch (info)
            {
                case 0:
                    selectionData.Set(this.Target, 8, this.Data);
                    break;

                case 1:
                default:
                    selectionData.Set(Targets.Atoms[Targets.UtfString], 8, this.DataText);
                    break;
            }
        }
示例#27
0
        /// <summary>
        /// Handles more complicated content from keyboard clipboard.
        /// </summary>
        /// <param name="clipboard">Clipboard.</param>
        /// <param name="selectionData">Data.</param>
        private void OnKeyboardContentReceived(Gtk.Clipboard clipboard, SelectionData selectionData)
        {
            Item item = this.Items.FirstOrDefault(i => i.IsData && i.Target.Name == selectionData.Target.Name && i.Data.SequenceEqual(selectionData.Data));

            if (item != null)
            {
                this.Items.MoveTop(item);
            }
            else
            {
                Gtk.SelectionData sub_data = this.keyboardClipboard.WaitForContents(Targets.Atoms[Targets.UtfString]);

                if (sub_data == null)
                    sub_data = this.keyboardClipboard.WaitForContents(Targets.Atoms[Targets.String]);

                if (Settings.Instance[Settings.Keys.Core.SupportedFilesAsImages].AsBoolean() && selectionData.Target.Name == Targets.File && sub_data != null && sub_data.Text != null && sub_data.Text.Length > 1)
                {
                    string ext = System.IO.Path.GetExtension(sub_data.Text);

                    if (ext.Length > 1)
                    {
                        ext = ext.Substring(1, ext.Length - 1).ToLower();
                        PixbufFormat format = this.pixbufFormats.FirstOrDefault(f => f.Extensions.Contains(ext));

                        if (format != null)
                        {
                            try
                            {
                                this.OnKeyboardImageReceived(clipboard, new Pixbuf(sub_data.Text));
                                return;
                            }
                            catch (Exception ex)
                            {
                                Tools.PrintInfo(ex, this.GetType());
                            }
                        }
                    }
                }

                string sub_text = sub_data != null ? sub_data.Text : System.Text.Encoding.UTF8.GetString(selectionData.Data);

                item = new Item(selectionData.Target ,selectionData.Data, sub_text);

                string label = item.Label;
                int c = 1;

                while (this.Items.Any(i => i.Label == item.Label))
                {
                    item.Label = label + c.ToString();
                    c++;
                }

                this.Items.Insert(0, item);
            }

            Item text_item = this.Items.FirstOrDefault(i => !i.IsData && i.Text == item.Text);

            if (text_item != null)
            {
                this.Items.Remove(text_item);

                if (this.MouseItem == text_item)
                {
                    this.SetAsMouseContent(item);
                 	MouseItem = item;
                }
            }

            ClipboardChangedArgs args = new ClipboardChangedArgs(Gdk.Selection.Clipboard, this.KeyboardItem, item);

            this.KeyboardItem = item;

            if (Settings.Instance[Settings.Keys.Core.SynchronizeClipboards].AsBoolean() && Settings.Instance[Settings.Keys.Core.MouseClipboard].AsBoolean() && item.Target.Name == Targets.Html)
            {
                synchronizing = true;
                this.SetAsMouseContent(item);
            }
            else
            {
                if (this.ClipboardChanged != null)
                    this.ClipboardChanged(this, args);
            }
        }
		/// <summary>
		/// Fills selection with data
		/// </summary>
		/// <param name="aData">
		/// Data <see cref="SelectionData"/>
		/// </param>
		/// <param name="aInfo">
		/// Type <see cref="System.UInt32"/>
		/// </param>
		private void FillSelectionData (SelectionData aData, uint aInfo) 
		{
			aData.Set (aData.Target, 8, System.Text.Encoding.UTF8.GetBytes (TargetUrl),
			           System.Text.Encoding.UTF8.GetBytes (TargetUrl).Length);
		}
示例#29
0
        /// <summary>
        /// Handles more complicated content from keyboard clipboard.
        /// </summary>
        /// <param name="clipboard">Clipboard.</param>
        /// <param name="selectionData">Data.</param>
        private void OnKeyboardContentReceived(Gtk.Clipboard clipboard, SelectionData selectionData)
        {
            Item item = this.Items.FirstOrDefault(i => i.IsData && i.Target.Name == selectionData.Target.Name && i.Data.SequenceEqual(selectionData.Data));

            if (item != null)
            {
                this.Items.MoveTop(item);
            }
            else
            {
                Gtk.SelectionData sub_data = this.keyboardClipboard.WaitForContents(Targets.Atoms[Targets.UtfString]);

                if (sub_data == null)
                {
                    sub_data = this.keyboardClipboard.WaitForContents(Targets.Atoms[Targets.String]);
                }

                if (Settings.Instance[Settings.Keys.Core.SupportedFilesAsImages].AsBoolean() && selectionData.Target.Name == Targets.File && sub_data != null && sub_data.Text != null && sub_data.Text.Length > 1)
                {
                    string ext = System.IO.Path.GetExtension(sub_data.Text);

                    if (ext.Length > 1)
                    {
                        ext = ext.Substring(1, ext.Length - 1).ToLower();
                        PixbufFormat format = this.pixbufFormats.FirstOrDefault(f => f.Extensions.Contains(ext));

                        if (format != null)
                        {
                            try
                            {
                                this.OnKeyboardImageReceived(clipboard, new Pixbuf(sub_data.Text));
                                return;
                            }
                            catch (Exception ex)
                            {
                                Tools.PrintInfo(ex, this.GetType());
                            }
                        }
                    }
                }

                string sub_text = sub_data != null ? sub_data.Text : System.Text.Encoding.UTF8.GetString(selectionData.Data);

                item = new Item(selectionData.Target, selectionData.Data, sub_text);

                string label = item.Label;
                int    c     = 1;

                while (this.Items.Any(i => i.Label == item.Label))
                {
                    item.Label = label + c.ToString();
                    c++;
                }

                this.Items.Insert(0, item);
            }

            Item text_item = this.Items.FirstOrDefault(i => !i.IsData && i.Text == item.Text);

            if (text_item != null)
            {
                this.Items.Remove(text_item);

                if (this.MouseItem == text_item)
                {
                    this.SetAsMouseContent(item);
                    MouseItem = item;
                }
            }

            ClipboardChangedArgs args = new ClipboardChangedArgs(Gdk.Selection.Clipboard, this.KeyboardItem, item);

            this.KeyboardItem = item;

            if (Settings.Instance[Settings.Keys.Core.SynchronizeClipboards].AsBoolean() && Settings.Instance[Settings.Keys.Core.MouseClipboard].AsBoolean() && item.Target.Name == Targets.Html)
            {
                synchronizing = true;
                this.SetAsMouseContent(item);
            }
            else
            {
                if (this.ClipboardChanged != null)
                {
                    this.ClipboardChanged(this, args);
                }
            }
        }
		void FillSelectionData (SelectionData aData, uint aInfo) 
		{
			if (aInfo < (int) TransferDataType.X_Special)
				aData.Set (aData.Target, 8, System.Text.Encoding.UTF8.GetBytes (GetTimeAsString (copyBuffer)),
				           System.Text.Encoding.UTF8.GetBytes (GetTimeAsString(copyBuffer)).Length);
			else {
				byte[] num = BitConverter.GetBytes (copyBuffer.Hour);
				byte[] data = new byte[num.Length*4];
				num.CopyTo (data, 0);
				num = BitConverter.GetBytes (copyBuffer.Minute);
				num.CopyTo (data, num.Length);
				num = BitConverter.GetBytes (copyBuffer.Second);
				num.CopyTo (data, num.Length*2);
				num = BitConverter.GetBytes (copyBuffer.Millisecond);
				num.CopyTo (data, num.Length*3);
				aData.Set (aData.Target, 8, data, data.Length);
			}
		}
		protected void HandleDataReceived (uint aType, Gtk.Widget aSource, SelectionData aData)
		{
			if (Editable == false)
				return;
			ResetEditing();
			string text = "";
			switch (aType) {
			case (int) TransferDataType.Default:
				text = System.Text.Encoding.UTF8.GetString (aData.Data);
				break;
			case (int) TransferDataType.X_Special:
				int intsize = (BitConverter.GetBytes((int) 1).Length);
				int h = BitConverter.ToInt32 (aData.Data, 0);
				int m = BitConverter.ToInt32 (aData.Data, intsize);
				int s = BitConverter.ToInt32 (aData.Data, intsize * 2);					
				int ms = BitConverter.ToInt32 (aData.Data, intsize * 2);					
				SetTime (h, m, s, ms);
				return;
			}		
			if (text != "")
				try {
					DateTime dt = DateTime.Parse (text);
					SetTime (dt.Hour, dt.Minute, dt.Second, dt.Millisecond);
				}
				catch {}
			text = "";
		}
示例#32
0
 public new bool DragDataGet(TreePath path, SelectionData sel)
 {
     Console.WriteLine (path);
     Console.WriteLine (path.Depth);
     return true;
 }
 public DragDropList(T o, Gtk.SelectionData selectionData, Gdk.Atom target) : base()
 {
     Add(o);
     AssignToSelection(selectionData, target);
 }
示例#34
0
		protected override void OnDragDataGet (Gdk.DragContext ctx, Gtk.SelectionData data, uint info, uint time)
		{
			byte[] uri = System.Text.Encoding.UTF8.GetBytes (Hit.EscapedUri + "\r\n");
			data.Set (data.Target, 8, uri);
		}
示例#35
0
			public void SetData (SelectionData selection_data, uint info)
			{
				if (selection_data == null)
					return;
				switch (info) {
				case TextType:
					selection_data.Text = GetCopiedPlainText ();
					break;
				case RichTextType:
					var rtf = RtfWriter.GenerateRtf (copiedColoredChunks, docStyle, options);
					selection_data.Set (RTF_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes (rtf));
					break;
				case HTMLTextType:
					var html = HtmlWriter.GenerateHtml (copiedColoredChunks, docStyle, options);
//					Console.WriteLine ("html:" + html);
					selection_data.Set (HTML_ATOM, UTF8_FORMAT, Encoding.UTF8.GetBytes (html));
					break;
				case MonoTextType:
					byte[] rawText = Encoding.UTF8.GetBytes (GetCopiedPlainText ());
					var copyDataLength = (byte)(copyData != null ? copyData.Length : 0);
					var dataOffset = 1 + 1 + copyDataLength;
					byte[] data = new byte [rawText.Length + dataOffset];
					data [1] = copyDataLength;
					if (copyDataLength > 0)
						copyData.CopyTo (data, 2);
					rawText.CopyTo (data, dataOffset);
					data [0] = 0;
					if (isBlockMode)
						data [0] |= 1;
					if (isLineSelectionMode)
						data [0] |= 2;
					selection_data.Set (MD_ATOM, UTF8_FORMAT, data);
					break;
				}
			}
示例#36
0
 public new bool RowDropPossible(TreePath path, SelectionData sel)
 {
     return path.Depth == 2;
 }
示例#37
0
文件: UriList.cs 项目: tcausby/giver
 public UriList(Gtk.SelectionData selection)
 {
     // FIXME this should check the atom etc.
     LoadFromString(System.Text.Encoding.UTF8.GetString(selection.Data));
 }
    private void ClearGet(Gtk.Clipboard clipboard, Gtk.SelectionData selection, uint info)
    {
        var temp = _action + "\n" + _source;

        selection.Set(selection.Target, 8, _encoding.GetBytes(temp));
    }
示例#39
0
		public bool DragDataReceived(TreePath path, SelectionData data){
			return LocationsModel.DragDataReceived(path,data);
		}
示例#40
0
 public static string [] SplitSelectionData(Gtk.SelectionData data)
 {
     return(SplitSelectionData(SelectionDataToString(data)));
 }
示例#41
0
        // Methods :: Public :: SplitSelectionData
        /// <summary>
        ///	Split <see cref="Gtk.SelectionData" /> data into an
        ///     array of <see cref="String">strings</see>.
        /// </summary>
        /// <remarks>
        ///	Data is separated by "\r\n" pairs.
        /// </remarks>
        /// <param name="data">
        ///	A <see cref="Gtk.SelectionData" /> object.
        /// </param>
        public static string [] SplitSelectionData(Gtk.SelectionData data)
        {
            string s = SelectionDataToString(data);

            return(SplitSelectionData(s));
        }
示例#42
0
        protected override void OnDragDataReceived(DragContext context, int x, int y, SelectionData selection, uint info, uint time)
        {
            TreeIter iter;
            TreePath path;
            TreeViewDropPosition pos;
            Playlist destPlaylist;
            IPlaylistElement destElement;
            TreeStore store = Model as TreeStore;

            if (GetDestRowAtPos (x, y, out path, out pos)) {
                store.GetIter (out iter, path);
                FillElementAndPlaylist (iter, out destPlaylist, out destElement);

                /* Moving playlists */
                if (dragSourceElement == null) {
                    project.Playlists.Remove (dragSourcePlaylist);
                    project.Playlists.Insert (path.Indices [0], dragSourcePlaylist);
                } else {
                    IPlaylistElement srcCurrent, dstCurrent;
                    int destIndex;

                    if (pos == TreeViewDropPosition.Before ||
                        pos == TreeViewDropPosition.IntoOrBefore) {
                        destIndex = store.GetPath (iter).Indices [1];
                    } else {
                        destIndex = store.GetPath (iter).Indices [1] + 1;
                    }

                    if (dragSourcePlaylist == destPlaylist) {
                        // If the element is dragged to bigger index, when it's removed from the playlist
                        // the new index needs to be decremented by one because there is one element less in the
                        // playlist now
                        if (dragSourcePlaylist.Elements.IndexOf (dragSourceElement) <= destIndex) {
                            destIndex--;
                        }
                    }

                    srcCurrent = dragSourcePlaylist.Selected;
                    dstCurrent = destPlaylist.Selected;

                    dragSourcePlaylist.Elements.Remove (dragSourceElement);
                    destPlaylist.Elements.Insert (destIndex, dragSourceElement);

                    if (dragSourcePlaylist != destPlaylist) {
                        dragSourcePlaylist.SetActive (srcCurrent);
                    }
                    destPlaylist.SetActive (dstCurrent);
                }
            }
            Gtk.Drag.Finish (context, true, false, time);
        }
 public bool DragDataGet(TreePath path, SelectionData sel)
 {
     Console.WriteLine("DragDataGet path={0}", path);
     return Tree.SetRowDragData(sel, Adapter, path);
 }
示例#44
0
        protected override void OnDragDataReceived(DragContext context, int x, int y, SelectionData selection, uint info, uint time)
        {
            TreeIter iter;
            TreePath path;
            TreeViewDropPosition pos;
            Playlist destPlaylist;
            IPlaylistElement destElement;
            TreeStore store = Model as TreeStore;

            if (GetDestRowAtPos (x, y, out path, out pos)) {
                store.GetIter (out iter, path);
                FillElementAndPlaylist (iter, out destPlaylist, out destElement);

                /* Moving playlists */
                if (dragSourceElement == null) {
                    project.Playlists.Remove (dragSourcePlaylist);
                    project.Playlists.Insert (path.Indices [0], dragSourcePlaylist);
                    if (pos == TreeViewDropPosition.Before ||
                        pos == TreeViewDropPosition.IntoOrBefore) {
                        store.MoveBefore (selectedIter, iter);
                    } else {
                        store.MoveAfter (selectedIter, iter);
                    }
                } else {
                    /* For elements moves can happen between 2 playlists and Move{Before|After}
                     * requires iter to have the same parent */
                    TreeIter newIter;
                    IPlaylistElement srcCurrent, dstCurrent;

                    if (pos == TreeViewDropPosition.Before ||
                        pos == TreeViewDropPosition.IntoOrBefore) {
                        newIter = (Model as TreeStore).InsertNodeBefore (iter);
                    } else {
                        newIter = (Model as TreeStore).InsertNodeAfter (iter);
                    }
                    store.SetValue (newIter, 0, dragSourceElement);
                    store.Remove (ref selectedIter);

                    srcCurrent = dragSourcePlaylist.Selected;
                    dstCurrent = destPlaylist.Selected;

                    dragSourcePlaylist.Elements.Remove (dragSourceElement);
                    destPlaylist.Elements.Insert (store.GetPath (newIter).Indices [1], dragSourceElement);

                    if (dragSourcePlaylist != destPlaylist) {
                        dragSourcePlaylist.SetActive (srcCurrent);
                    }
                    destPlaylist.SetActive (dstCurrent);
                }

            }
            Gtk.Drag.Finish (context, true, false, time);
        }
		public bool RowDropPossible(TreePath path, SelectionData selectionData)
		{
			return true;
		}
 public bool RowDropPossible(TreePath path, SelectionData sel)
 {
     Console.WriteLine("RowDropPossible path={0} depth= {1}", path, path.Depth);
     return path.Depth == 1;
 }
示例#47
0
		protected override void OnDragDataReceived (DragContext context, int x, int y, SelectionData selection_data, uint info, uint time_)
		{
			base.OnDragDataReceived (context, x, y, selection_data, info, time_);
			if (info == 100u) {
				string fullData = System.Text.Encoding.UTF8.GetString (selection_data.Data);
				
				foreach (string individualFile in fullData.Split ('\n')) {
					string file = individualFile.Trim ();
					if (file.StartsWith ("file://")) {
						file = new Uri(file).LocalPath;
						if (!CheckImage (file))
							return;
						if (project != null)
							file = project.GetRelativeChildPath (file);
						SelectedProjectFile = file;
						OnChanged (EventArgs.Empty);
					}
				}
				
			}
		}
示例#48
0
        protected override void OnDragDataReceived(Gdk.DragContext context, int x, int y, Gtk.SelectionData selection_data, uint info, uint time_)
        {
            if (selection_data.Target == null || selection_data.Target.Name != RowAtom.Name)
            {
                return;
            }

            if (torrentController.SelectedDownload == null)
            {
                return;
            }

            TreeIter             iter;
            TreePath             path;
            TreeViewDropPosition pos;

            if (!GetDestRowAtPos(x, y, out path, out pos))
            {
                return;
            }
            if (!Model.GetIter(out iter, path))
            {
                return;
            }

            Download download = (Download)Model.GetValue(iter, 0);

            if (download == torrentController.SelectedDownload)
            {
                return;
            }

            List <Download> downloads = new List <Download> (torrentController.Torrents);

            downloads.Sort(delegate(Download left, Download right) {
                return(left.Priority.CompareTo(right.Priority));
            });

            int index = download.Priority;

            if (pos != TreeViewDropPosition.After)
            {
                index--;
            }

            downloads.Remove(torrentController.SelectedDownload);
            downloads.Insert(Math.Min(index, downloads.Count), torrentController.SelectedDownload);

            for (int i = downloads.Count - 1; i >= 9; i--)
            {
                downloads [i].Priority = i * downloads.Count;
            }
            for (int i = 0; i < downloads.Count; i++)
            {
                downloads [i].Priority = i + 1;
            }
        }
示例#49
0
 public new bool DragDataGet(TreePath path, SelectionData sel)
 {
     logger.Debug("DragDataGet path={0}", path);
     return Tree.SetRowDragData(sel, this, path);
 }
 public void AssignToSelection(Gtk.SelectionData selectionData, Gdk.Atom target)
 {
     byte [] data = this;
     selectionData.Set(target, 8, data, data.Length);
 }