Ejemplo n.º 1
0
 protected override void OnDragDataDelete(Gdk.DragContext context)
 {
     // This method is override to avoid the default implementation
     // being called. The default implementation deletes the
     // row being dragged, and we don't want that
     backend.DoDragaDataDelete();
 }
Ejemplo n.º 2
0
        protected override bool OnDragDrop(Gdk.DragContext context, int x, int y, uint time)
        {
            TreePath             path;
            TreeViewDropPosition pos;

            if (GetDestRowAtPos(x, y, out path, out pos))
            {
                TreeIter destIter;

                Project.EventTypes.Remove(draggedEventType);
                Project.EventTypes.Insert(path.Indices [0], draggedEventType);

                Model.GetIter(out destIter, path);
                if (dropPos == TreeViewDropPosition.After)
                {
                    Model.MoveAfter(srcIter, destIter);
                }
                else
                {
                    Model.MoveBefore(srcIter, destIter);
                }
                Refilter();
            }
            Gtk.Drag.Finish(context, true, false, time);
            return(true);
        }
Ejemplo n.º 3
0
 protected override void OnDragBegin(Gdk.DragContext context)
 {
     if (ServiceManager.SourceManager.ActiveSource.SupportedMergeTypes != SourceMergeType.None)
     {
         base.OnDragBegin(context);
     }
 }
Ejemplo n.º 4
0
        protected override void OnDragDataReceived(Gdk.DragContext context, int x, int y, SelectionData selectionData, uint info, uint time)
        {
            List <IViewModel> draggedElements = App.Current.DragContext.SourceData as List <IViewModel>;
            bool success = HandleDragReceived(draggedElements, x, y, Gtk.Drag.GetSourceWidget(context) == this);

            Gtk.Drag.Finish(context, success, false, time);
        }
Ejemplo n.º 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();
            }
        }
 protected override void OnDragBegin(Gdk.DragContext ctx)
 {
     Gtk.Widget ob = CreateItemWidget();
     if (ob != null)
     {
         DND.Drag(this, ctx, ob);
     }
 }
Ejemplo n.º 7
0
        protected override void OnDragBegin(Gdk.DragContext context)
        {
            base.OnDragBegin(context);
            TreePath [] paths = Selection.GetSelectedRows();
            TreeIter    iter;

            Model.GetIter(out iter, paths [0]);
            object firstDraggedElement = Model.GetValue(iter, COL_DATA);

            App.Current.DragContext.SourceDataType = firstDraggedElement.GetType();
        }
Ejemplo n.º 8
0
 void DisableDragInto(TreePath path, Gdk.DragContext context, uint time, TreeViewDropPosition pos)
 {
     if (pos == TreeViewDropPosition.IntoOrAfter)
     {
         pos = TreeViewDropPosition.After;
     }
     else if (pos == TreeViewDropPosition.IntoOrBefore)
     {
         pos = TreeViewDropPosition.Before;
     }
     SetDragDestRow(path, pos);
     Gdk.Drag.Status(context, context.SuggestedAction, time);
 }
Ejemplo n.º 9
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.Targets[0]);
                break;

            default:
                return;
            }

            base.OnDragDataGet(context, selectionData, info, time);
        }
Ejemplo n.º 10
0
        protected override bool OnDragMotion(Gdk.DragContext context, int x, int y, uint time)
        {
            TreePath             path;
            TreeViewDropPosition pos;
            Source active_source = ServiceManager.SourceManager.ActiveSource;

            if (active_source.SupportedMergeTypes == SourceMergeType.None)
            {
                Gdk.Drag.Status(context, 0, time);
                return(false);
            }
            else if (!GetDestRowAtPos(x, y, out path, out pos))
            {
                Gdk.Drag.Status(context, 0, time);
                return(false);
            }

            Source drop_source   = store.GetSource(path);
            Source parent_source = (drop_source as LibrarySource) ?? (drop_source.Parent as LibrarySource);

            // Scroll if within 20 pixels of the top or bottom
            if (y < 20)
            {
                Vadjustment.Value -= 30;
            }
            else if ((Allocation.Height - y) < 20)
            {
                Vadjustment.Value += 30;
            }

            ShowNewPlaylistUnder(parent_source, active_source);

            if (!drop_source.AcceptsUserInputFromSource(active_source))
            {
                Gdk.Drag.Status(context, 0, time);
                return(true);
            }

            SetDragDestRow(path, TreeViewDropPosition.IntoOrAfter);

            bool move = (active_source is LibrarySource) && (drop_source is LibrarySource);

            Gdk.Drag.Status(context, move ? Gdk.DragAction.Move : Gdk.DragAction.Copy, time);

            return(true);
        }
Ejemplo n.º 11
0
        protected override bool OnDragMotion(Gdk.DragContext context, int x, int y, uint time_)
        {
            // Scroll if within 20 pixels of the top or bottom
            var    parent = Parent.Parent as Gtk.ScrolledWindow;
            double rel_y  = y - parent.Vadjustment.Value;

            if (rel_y < 20)
            {
                parent.Vadjustment.Value -= 30;
            }
            else if ((parent.Allocation.Height - rel_y) < 20)
            {
                parent.Vadjustment.Value = Math.Min(parent.Vadjustment.Upper - parent.Allocation.Height, parent.Vadjustment.Value + 30);
            }

            var targets = context.Targets.Select(t => (string)t);

            if (targets.Contains(move_internal_target.Target) || targets.Contains(move_external_target.Target))
            {
                bool ret = base.OnDragMotion(context, x, y, time_);
                SetDestInfo(x, y);
                return(ret);
            }
            else if (targets.Contains(uri_dest_target.Target))
            {
                // TODO could do this (from Gtk+ docs) to make sure the uris are all .pdfs (or mime-sniffed as pdfs):

                /* If the decision whether the drop will be accepted or rejected can't be made based solely on the
                 * cursor position and the type of the data, the handler may inspect the dragged data by calling gtk_drag_get_data() and
                 * defer the gdk_drag_status() call to the "drag-data-received" handler. Note that you cannot not pass GTK_DEST_DEFAULT_DROP,
                 * GTK_DEST_DEFAULT_MOTION or GTK_DEST_DEFAULT_ALL to gtk_drag_dest_set() when using the drag-motion signal that way. */
                Gdk.Drag.Status(context, DragAction.Copy, time_);
                if (!highlighted)
                {
                    Gtk.Drag.Highlight(this);
                    highlighted = true;
                }

                SetDestInfo(x, y);

                return(true);
            }

            Gdk.Drag.Abort(context, time_);
            return(false);
        }
Ejemplo n.º 12
0
        protected override void OnDragDataGet(Gdk.DragContext context, SelectionData selectionData, uint info, uint time)
        {
            List <IViewModel> draggedViewModels = new List <IViewModel> ();
            var paths = Selection.GetSelectedRows();

            foreach (var path in paths)
            {
                TreeIter iter;
                Model.GetIter(out iter, path);
                var vm = (IViewModel)Model.GetValue(iter, COL_DATA);
                if (vm != null)
                {
                    draggedViewModels.Add(vm);
                }
            }
            App.Current.DragContext.SourceData = draggedViewModels;
        }
Ejemplo n.º 13
0
 void IToolboxConsumer.DragItem(ItemToolboxNode item, Gtk.Widget source, Gdk.DragContext ctx)
 {
     if (designer != null)
     {
         ComponentToolboxNode node = item as ComponentToolboxNode;
         if (node != null)
         {
             if (node.Reference == null)
             {
                 designer.BeginComponentDrag(node.ComponentType, source, ctx);
             }
             else
             {
                 designer.BeginComponentDrag(node.Name, node.ClassName, source, ctx, delegate { CheckReference(node); });
             }
         }
     }
 }
Ejemplo n.º 14
0
        protected override bool OnDragDrop(Gdk.DragContext context, int x, int y, uint time)
        {
            Wrapper.ActionPaletteItem dropped = DND.Drop(context, null, time) as Wrapper.ActionPaletteItem;
            if (dropped == null)
            {
                return(false);
            }

            if (dropped.Node.Action.ActionGroup != group)
            {
                using (dropped.Node.Action.UndoManager.AtomicChange) {
                    dropped.Node.Action.ActionGroup.Actions.Remove(dropped.Node.Action);
                    group.Actions.Add(dropped.Node.Action);
                }
            }

            return(base.OnDragDrop(context, x, y, time));
        }
Ejemplo n.º 15
0
        protected override bool OnDragMotion(Gdk.DragContext context, int x, int y, uint time)
        {
            TreePath             path;
            TreeViewDropPosition pos;

            if (GetDestRowAtPos(x, y, out path, out pos))
            {
                EventType ev = GetValueFromPath(path) as EventType;
                if (ev != null)
                {
                    DisableDragInto(path, context, time, pos);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Ejemplo n.º 16
0
        protected override void OnDragLeave(Gdk.DragContext context, uint time)
        {
            TreePath             path;
            TreeViewDropPosition pos;

            GetDragDestRow(out path, out pos);

            if (path == null && !TreeIter.Zero.Equals(new_playlist_iter))
            {
                path = store.GetPath(new_playlist_iter);
            }

            if (path != null)
            {
                final_drag_source = store.GetSource(path);
            }

            HideNewPlaylistRow();
            SetDragDestRow(null, TreeViewDropPosition.Before);
        }
Ejemplo n.º 17
0
        protected override void OnDragBegin(Gdk.DragContext context)
        {
            TreePath       path;
            TreeViewColumn col;
            int            cellX, cellY;

            GetPathAtPos(startX, startY, out path, out col, out cellX, out cellY);
            draggedEventType = GetValueFromPath(path) as EventType;


            if (draggedEventType != null)
            {
                GetPathAtPos(startX, startY, out path, out col, out cellX, out cellY);
                Model.GetIter(out srcIter, path);
                Pixmap rowPix = CreateRowDragIcon(path);
                Gtk.Drag.SetIconPixmap(context, rowPix.Colormap, rowPix, null, startX + 1, cellY + 1);
            }
            else
            {
                Gtk.Drag.Finish(context, false, false, context.StartTime);
            }
        }
Ejemplo n.º 18
0
        protected override bool OnDragMotion(Gdk.DragContext context, int x, int y, uint time)
        {
            TreeIter             iter;
            TreePath             path;
            TreeViewDropPosition pos;

            if (GetDestRowAtPos(x, y, out path, out pos))
            {
                Model.GetIter(out iter, path);
                IViewModel element = Model.GetValue(iter, COL_DATA) as IViewModel;
                if (AllowDrop(element))
                {
                    DragAction action = DragAction.Copy;
                    if (Gtk.Drag.GetSourceWidget(context) == this)
                    {
                        action = DragAction.Move;
                    }
                    DisableDragInto(path, context, time, pos);
                    Gdk.Drag.Status(context, action, time);
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
0
 protected override void OnDragLeave(DragContext context, uint time_)
 {
     if (!draggingDivider)
         GdkWindow.Cursor = null;
     base.OnDragLeave (context, time_);
 }
Ejemplo n.º 21
0
 protected override void OnDragBegin(Gdk.DragContext context)
 {
     drag_started = true;
     base.OnDragBegin(context);
 }
Ejemplo n.º 22
0
 public static Gdk.Atom[] ListTargets(this Gdk.DragContext context)
 {
     return(context.Targets);
 }
Ejemplo n.º 23
0
 protected override bool OnDragFailed(Gdk.DragContext drag_context, DragResult drag_result)
 {
     App.Current.DragContext.SourceDataType = null;
     App.Current.DragContext.SourceData     = null;
     return(base.OnDragFailed(drag_context, drag_result));
 }
Ejemplo n.º 24
0
 protected override void OnDragEnd(Gdk.DragContext context)
 {
     base.OnDragEnd(context);
     SetDragDestRow(null, TreeViewDropPosition.Before);
 }
Ejemplo n.º 25
0
 void DisableDragInto(TreePath path, DragContext context, uint time, TreeViewDropPosition pos)
 {
     if (pos == TreeViewDropPosition.IntoOrAfter) {
         pos = TreeViewDropPosition.After;
     } else if (pos == TreeViewDropPosition.IntoOrBefore) {
         pos = TreeViewDropPosition.Before;
     }
     SetDragDestRow (path, pos);
     dropPos = pos;
     Gdk.Drag.Status (context, context.SuggestedAction, time);
 }
Ejemplo n.º 26
0
        protected override bool OnDragMotion(DragContext context, int x, int y, uint time)
        {
            TreePath path;
            TreeViewDropPosition pos;

            if (GetDestRowAtPos (x, y, out path, out pos)) {
                EventType ev = GetValueFromPath (path) as EventType;
                if (ev != null) {
                    DisableDragInto (path, context, time, pos);
                    return true;
                } else {
                    return false;
                }
            }
            return false;
        }
Ejemplo n.º 27
0
        protected override bool OnDragDrop(DragContext context, int x, int y, uint time)
        {
            TreePath path;
            TreeViewDropPosition pos;
            if (GetDestRowAtPos (x, y, out path, out pos)) {
                TreeIter destIter;

                Project.EventTypes.Remove (draggedEventType);
                Project.EventTypes.Insert (path.Indices [0], draggedEventType);

                Model.GetIter (out destIter, path);
                if (dropPos == TreeViewDropPosition.After) {
                    Model.MoveAfter (srcIter, destIter);
                } else {
                    Model.MoveBefore (srcIter, destIter);
                }
                Refilter ();
            }
            Gtk.Drag.Finish (context, true, false, time);
            return true;
        }
Ejemplo n.º 28
0
        protected override void OnDragBegin(DragContext context)
        {
            TreePath path;
            TreeViewColumn col;
            int cellX, cellY;

            GetPathAtPos (startX, startY, out path, out col, out cellX, out cellY);
            draggedEventType = GetValueFromPath (path) as EventType;

            if (draggedEventType != null) {
                GetPathAtPos (startX, startY, out path, out col, out cellX, out cellY);
                Model.GetIter (out srcIter, path);
                Pixmap rowPix = CreateRowDragIcon (path);
                Gtk.Drag.SetIconPixmap (context, rowPix.Colormap, rowPix, null, startX + 1, cellY + 1);
            } else {
                Gtk.Drag.Finish (context, false, false, context.StartTime);
            }
        }
Ejemplo n.º 29
0
        protected override bool OnDragMotion(DragContext context, int x, int y, uint time)
        {
            TreePath path;
            TreeViewDropPosition pos;
            TreeIter iter;
            IPlaylistElement element;
            Playlist playlist;

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

                FillElementAndPlaylist (iter, out playlist, out element);

                /* Drag a playlist*/
                if (dragSourceElement == null) {
                    if (element == null) {
                        DisableDragInto (path, context, time, pos);
                        return true;
                    } else {
                        return false;
                    }
                }
                /* Drag an element */
                else {
                    if (element != null) {
                        DisableDragInto (path, context, time, pos);
                        return true;
                    } else {
                        return false;
                    }
                }
            }
            return false;
        }
Ejemplo n.º 30
0
 public static Gdk.DragAction GetSelectedAction(this Gdk.DragContext context)
 {
     return(context.Action);
 }
Ejemplo n.º 31
0
 protected override void OnDragBegin(DragContext context)
 {
     Selection.GetSelected (out selectedIter);
     FillElementAndPlaylist (selectedIter, out dragSourcePlaylist,
         out dragSourceElement);
     dragStarted = true;
     base.OnDragBegin (context);
 }
 protected override bool OnDragMotion(DragContext context, int x, int y, uint time_)
 {
     return base.OnDragMotion (context, x, y, time_);
 }
 protected override bool OnDragDrop(Gdk.DragContext context, int x, int y, uint time_)
 {
     return(base.OnDragDrop(context, x, y, time_));
 }
Ejemplo n.º 34
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);
        }
Ejemplo n.º 35
0
 protected override void OnDragBegin(DragContext context)
 {
     pathIn = Selection.GetSelectedRows()[0];
     base.OnDragBegin (context);
 }
Ejemplo n.º 36
0
 protected override void OnDragEnd(Gdk.DragContext context)
 {
     App.Current.DragContext.SourceDataType = null;
     App.Current.DragContext.SourceData     = null;
     base.OnDragEnd(context);
 }
Ejemplo n.º 37
0
 protected override void OnDragEnd(DragContext context)
 {
     base.OnDragEnd (context);
     pathOut = Selection.GetSelectedRows()[0];
     playlist.Reorder(pathIn.Indices[0], pathOut.Indices[0]);
 }
Ejemplo n.º 38
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);
					}
				}
				
			}
		}
Ejemplo n.º 39
0
 protected override void OnDragEnd(DragContext context)
 {
     base.OnDragEnd (context);
     dragStarted = false;
 }