Beispiel #1
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();
            }
        }
Beispiel #2
0
        private void OnPresetTreeFolderDragOver(object sender, DragEventArgs e)
        {
            try
            {
                Point currentPosition = e.GetPosition(this.presetTreeView);

                if (DragDropUtilities.IsMovementBigEnough(this.lastPresetTreeViewMouseDown, currentPosition))
                {
                    // Verify that this is a valid drop and then store the drop target
                    this.DecideDropTarget(e);

                    if (this.dropTarget != null)
                    {
                        this.ShowFolderMoveAdorner(this.dropTarget);
                    }
                    else
                    {
                        this.RemoveFolderMoveAdorner();
                    }
                }

                e.Handled = true;
            }
            catch (Exception)
            {
            }
        }
Beispiel #3
0
        private void OnPresetTreeItemMouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                Point currentPosition = e.GetPosition(this.presetTreeView);

                if (DragDropUtilities.IsMovementBigEnough(this.lastPresetTreeViewMouseDown, currentPosition))
                {
                    this.draggedPreset = this.presetTreeView.SelectedItem as PresetViewModel;

                    if (this.draggedPreset != null)
                    {
                        var windowManager = StaticResolver.Resolve <IWindowManager>();

                        windowManager.SuspendDropOnWindows();
                        DragDrop.DoDragDrop((DependencyObject)sender, this.presetTreeView.SelectedItem, DragDropEffects.Move);
                        windowManager.ResumeDropOnWindows();
                    }
                }
            }
        }