15
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
using System.Collections.Generic;
20
using System.Collections.ObjectModel;
31
27
using Docky.Services;
28
using Docky.Services.Prefs;
35
32
public class TrashDockItem : IconDockItem
35
IPreferences trashPrefs = DockServices.Preferences.Get ("/apps/nautilus/preferences");
36
bool ConfirmTrashDelete {
38
return trashPrefs.Get<bool> ("confirm_trash", true);
37
42
uint ItemsInTrash {
39
44
return OwnedFile.QueryInfo<uint> ("trash::item-count");
161
166
// intentionally dont inherit
162
167
MenuList list = new MenuList ();
163
list[MenuListContainer.Actions].Add (
169
list.SetContainerTitle (MenuListContainer.CustomOne, Catalog.GetString ("Restore Files"));
171
FileEnumerator enumerator = OwnedFile.EnumerateChildren ("standard::type,standard::name", FileQueryInfoFlags.NofollowSymlinks, null);
172
List<File> files = new List<File> ();
174
if (enumerator != null) {
177
while ((info = enumerator.NextFile ()) != null) {
178
files.Add (OwnedFile.GetChild (info.Name));
184
enumerator.Close (null);
185
enumerator.Dispose ();
189
- this code should work, but GetFiles() currently uses .net IO instead of GIO
190
when this starts working, the enumeration block above can go away too
191
foreach (File _f in OwnedFile.GetFiles ().OrderByDescending (f => f.QueryInfo<string> ("trash::deletion-date")).Take (5)) {
193
foreach (File _f in files.OrderByDescending (f => f.QueryInfo<string> ("trash::deletion-date")).Take (5)) {
195
MenuItem item = new IconMenuItem (f.Basename, f.Icon (), (o, a) => RestoreFile (f));
196
item.Mnemonic = null;
197
list[MenuListContainer.CustomOne].Add (item);
200
list[MenuListContainer.CustomTwo].Add (
164
201
new MenuItem (Catalog.GetString ("_Open Trash"), Icon, (o, a) => OpenTrash ()));
165
list[MenuListContainer.Actions].Add (
202
list[MenuListContainer.CustomTwo].Add (
166
203
new MenuItem (Catalog.GetString ("Empty _Trash"), "gtk-clear", (o, a) => EmptyTrash (), !TrashFull));
208
void RestoreFile (File f)
210
File destFile = FileFactory.NewForPath (f.QueryInfo<string> ("trash::orig-path"));
211
f.Move (destFile, FileCopyFlags.NofollowSymlinks | FileCopyFlags.AllMetadata | FileCopyFlags.NoFallbackForMove, null, null);
170
214
void OpenTrash ()
172
216
DockServices.System.Open (OwnedFile);
192
230
"can also delete them separately.");
193
231
md.Modal = false;
195
Gtk.Button cancel_button = new Gtk.Button();
196
cancel_button.CanFocus = true;
197
cancel_button.Name = "cancel_button";
198
cancel_button.UseStock = true;
199
cancel_button.UseUnderline = true;
200
cancel_button.Label = "gtk-cancel";
201
cancel_button.Show ();
202
md.AddActionWidget (cancel_button, Gtk.ResponseType.Cancel);
233
md.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
203
234
md.AddButton (Catalog.GetString ("Empty _Trash"), Gtk.ResponseType.Ok);
204
235
md.DefaultResponse = Gtk.ResponseType.Ok;