public Gtk.TreeRowReference Copy() { IntPtr raw_ret = gtk_tree_row_reference_copy(Handle); Gtk.TreeRowReference ret = raw_ret == IntPtr.Zero ? null : (Gtk.TreeRowReference)GLib.Opaque.GetOpaque(raw_ret, typeof(Gtk.TreeRowReference), true); return(ret); }
void SelectImageRowRef(Gtk.TreeRowReference rowRef) { // select image in thumb list this.ImageThumbView.SetCursor(rowRef.Path, null, false); this.ImageThumbView.SelectPath(rowRef.Path); this.ImageThumbView.ScrollToPath(rowRef.Path); }
/// <summary> /// Gets the image for a given row reference. /// </summary> /// <returns>The image.</returns> /// <param name="rowRef">Row reference.</param> public Image GetImage(Gtk.TreeRowReference rowRef) { if (rowRef == null) { throw new ArgumentNullException(); } if (rowRef.Model != this) { throw new InvalidOperationException(); } Gtk.TreeIter iter; if (!this.GetIter(out iter, rowRef.Path)) { return(null); } return(GetImage(iter)); }
bool IsAnySelectedMarkedForDelete() { foreach (var path in this.ImageThumbView.SelectedItems) { var rowRef = new Gtk.TreeRowReference(this.store, path); var image = this.store.GetImage(rowRef); if (image == null) { continue; } if (image.Tags == null) { continue; } if (image.Tags.Contains("deleteme")) { return(true); } } return(false); }
void on_DeleteButton_clicked(object sender, EventArgs args) { Queue <Gtk.TreeRowReference> rowRefs = new Queue <Gtk.TreeRowReference> (); List <Image> images = new List <Image> (); foreach (var path in this.ImageThumbView.SelectedItems) { var rowRef = new Gtk.TreeRowReference(this.store, path); rowRefs.Enqueue(rowRef); var image = this.store.GetImage(rowRef); images.Add(image); } this.ImageThumbView.UnselectAll(); while (rowRefs.Count > 0) { Gtk.TreePath path = rowRefs.Dequeue().Path; Gtk.TreeIter iter; if (this.store.GetIter(out iter, path)) { this.store.Remove(ref iter); } this.foundImageCount--; } var dbConfig = BooruApp.BooruApplication.Database.Config; bool moveImages = dbConfig.GetBool("deletemove.enable"); var targetPath = moveImages ? dbConfig.GetString("deletemove.path") : ""; foreach (var image in images) { BooruApp.BooruApplication.TaskRunner.StartTaskAsync("Delete marked images", () => { var paths = BooruApp.BooruApplication.Database.GetImagePaths(image.Details.MD5); foreach (string source in paths) { try { string target = targetPath + "/" + System.IO.Path.GetFileName(source); if (System.IO.File.Exists(source)) { if (moveImages && !System.IO.File.Exists(target)) { System.IO.File.Move(source, target); BooruApp.BooruApplication.Log.Log(BooruLog.Category.Files, BooruLog.Severity.Info, "Moved file " + source + " to " + targetPath); } else { System.IO.File.Delete(source); BooruApp.BooruApplication.Log.Log(BooruLog.Category.Files, BooruLog.Severity.Info, "Deleted file " + source); } } } catch (Exception ex) { BooruApp.BooruApplication.Log.Log(BooruLog.Category.Files, ex, "Caught exception trying to delete file " + source); } } BooruApp.BooruApplication.Database.RemoveImage(image.Details.MD5); }); } this.UpdateButtons(); }