summaryrefslogtreecommitdiff
path: root/daemon/trashlib/trashitem.h
blob: ad782028704ef9cbf0173cf4a72ec8e825626a9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * Copyright © 2008 Ryan Lortie
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of version 3 of the GNU General Public License as
 * published by the Free Software Foundation.   
 */

#ifndef _trashitem_h_
#define _trashitem_h_

#include <gio/gio.h>

typedef struct  OPAQUE_TYPE__TrashRoot        TrashRoot;
typedef struct  OPAQUE_TYPE__TrashItem        TrashItem;

typedef void  (*trash_item_notify)           (TrashItem          *item,
                                              gpointer            user_data);
typedef void  (*trash_size_change)           (gpointer            user_data);

/* trash root -- the set of all toplevel trash items */
TrashRoot      *trash_root_new               (trash_item_notify   create,
                                              trash_item_notify   delete,
                                              trash_size_change   size_change,
                                              gpointer            user_data);
void            trash_root_free              (TrashRoot          *root);

/* add/remove trash items (safe only from one thread) */
void            trash_root_add_item          (TrashRoot          *root,
                                              GFile              *file,
                                              gboolean            in_homedir);
void            trash_root_remove_item       (TrashRoot          *root,
                                              GFile              *file,
                                              gboolean            in_homedir);
void            trash_root_thaw              (TrashRoot          *root);

/* query trash items, holding references (safe from any thread) */
int             trash_root_get_n_items       (TrashRoot          *root);
GList          *trash_root_get_items         (TrashRoot          *root);
TrashItem      *trash_root_lookup_item       (TrashRoot          *root,
                                              const char         *escaped);

void            trash_item_list_free         (GList              *list);
void            trash_item_unref             (TrashItem          *item);

/* query a trash item (safe while holding a reference to it) */
const char     *trash_item_get_escaped_name  (TrashItem          *item);
const char     *trash_item_get_delete_date   (TrashItem          *item);
GFile          *trash_item_get_original      (TrashItem          *item);
GFile          *trash_item_get_file          (TrashItem          *item);

/* delete a trash item (safe while holding a reference to it) */
gboolean        trash_item_delete            (TrashItem          *item,
                                              GError            **error);
gboolean        trash_item_restore           (TrashItem          *item,
                                              GFile              *dest,
					      GFileCopyFlags      flags,
                                              GError            **error);

#endif /* _trashitem_h_ */