public EditorBox(Widget child) { Child = child; VisibleWindow = false; ButtonPressEvent += (o, a) => { if (a.Event.Button == 3 && IsBoxSensitive((int)a.Event.X, (int)a.Event.Y)) { var menu = new Menu(); var choose = new MenuItem(Catalog.GetString("Choose New Cover Art...")); choose.Activated += delegate { try { var track = GetTrack(); if (track != null) { var dialog = new Banshee.Gui.Dialogs.ImageFileChooserDialog(); var resp = dialog.Run(); string filename = dialog.Filename; dialog.Destroy(); if (resp == (int)Gtk.ResponseType.Ok) { SetCoverArt(track, filename); } } } catch (Exception e) { Log.Error(e); } }; var delete = new MenuItem(Catalog.GetString("Delete This Cover Art")); delete.Activated += delegate { try { var track = GetTrack(); if (track != null) { DeleteCoverArt(track); NotifyUpdated(track); } } catch (Exception e) { Log.Error(e); } }; var uri = GetCoverArtPath(GetTrack()); choose.Sensitive = uri != null; if (uri == null || !Banshee.IO.File.Exists(uri)) { delete.Sensitive = false; } menu.Append(choose); menu.Append(delete); menu.ShowAll(); menu.Popup(); } }; Gtk.Drag.SourceSet(this, Gdk.ModifierType.Button1Mask, new TargetEntry [] { DragDropTarget.UriList }, Gdk.DragAction.Copy | Gdk.DragAction.Move); DragDataGet += (o, a) => { try { var uri = GetCoverArtPath(GetTrack()); if (uri != null) { if (Banshee.IO.File.Exists(uri)) { a.SelectionData.Set( Gdk.Atom.Intern(DragDropTarget.UriList.Target, false), 8, Encoding.UTF8.GetBytes(uri.AbsoluteUri) ); } } } catch (Exception e) { Log.Error(e); } }; Gtk.Drag.DestSet(this, Gtk.DestDefaults.All, new TargetEntry [] { DragDropTarget.UriList }, Gdk.DragAction.Copy); DragDataReceived += (o, a) => { try { SetCoverArt(GetTrack(), Encoding.UTF8.GetString(a.SelectionData.Data)); } catch (Exception e) { Log.Error(e); } }; }
public EditorBox (Widget child) { Child = child; VisibleWindow = false; ButtonPressEvent += (o, a) => { if (a.Event.Button == 3 && IsSensitive ((int)a.Event.X, (int)a.Event.Y)) { var menu = new Menu (); var choose = new MenuItem (Catalog.GetString ("Choose New Cover Art...")); choose.Activated += delegate { try { var track = GetTrack (); if (track != null) { var dialog = new Banshee.Gui.Dialogs.ImageFileChooserDialog (); var resp = dialog.Run (); string filename = dialog.Filename; dialog.Destroy (); if (resp == (int)Gtk.ResponseType.Ok) { SetCoverArt (track, filename); } } } catch (Exception e) { Log.Exception (e); } }; var delete = new MenuItem (Catalog.GetString ("Delete This Cover Art")); delete.Activated += delegate { try { var track = GetTrack (); if (track != null) { DeleteCoverArt (track); NotifyUpdated (track); } } catch (Exception e) { Log.Exception (e); } }; var uri = GetCoverArtPath (GetTrack ()); choose.Sensitive = uri != null; if (uri == null || !Banshee.IO.File.Exists (uri)) { delete.Sensitive = false; } menu.Append (choose); menu.Append (delete); menu.ShowAll (); menu.Popup (); } }; Gtk.Drag.SourceSet (this, Gdk.ModifierType.Button1Mask, new TargetEntry [] { DragDropTarget.UriList }, Gdk.DragAction.Copy | Gdk.DragAction.Move); DragDataGet += (o, a) => { try { var uri = GetCoverArtPath (GetTrack ()); if (uri != null) { if (Banshee.IO.File.Exists (uri)) { a.SelectionData.Set ( Gdk.Atom.Intern (DragDropTarget.UriList.Target, false), 8, Encoding.UTF8.GetBytes (uri.AbsoluteUri) ); } } } catch (Exception e) { Log.Exception (e); } }; Gtk.Drag.DestSet (this, Gtk.DestDefaults.All, new TargetEntry [] { DragDropTarget.UriList }, Gdk.DragAction.Copy); DragDataReceived += (o, a) => { try { SetCoverArt (GetTrack (), Encoding.UTF8.GetString (a.SelectionData.Data)); } catch (Exception e) { Log.Exception (e); } }; }