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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* Copyright (C) 2007 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gio/gio.h>
#include <glibmm/interface.h>
#include <giomm/asyncresult.h>
#include <giomm/cancellable.h>
#include <giomm/icon.h>
#include <giomm/mountoperation.h>
_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/interface_p.h)
namespace Gio
{
/** Virtual File System drive management.
*
* This represent a piece of hardware connected to the machine. It's generally only created for removable hardware or hardware with removable media.
* Gio::Drive is a container class for Gio::Volume objects that stem from the same piece of media. As such, Gio::Drive abstracts a drive with
* (or without) removable media and provides operations for querying whether media is available, determing whether media change is automatically
* detected and ejecting the media.
*
* If the Gio::Drive reports that media isn't automatically detected, one can poll for media; typically one should not do this periodically as a
* poll for media operation is potententially expensive and may spin up the drive, creating noise.
*/
class Drive : public Glib::Interface
{
_CLASS_INTERFACE(Drive, GDrive, G_DRIVE, GDriveIface)
public:
_WRAP_METHOD(Glib::ustring get_name() const, g_drive_get_name)
_WRAP_METHOD(Glib::RefPtr<Icon> get_icon(),
g_drive_get_icon,
refreturn)
_WRAP_METHOD(Glib::RefPtr<const Icon> get_icon() const,
g_drive_get_icon,
refreturn, constversion)
_WRAP_METHOD(bool has_volumes() const, g_drive_has_volumes)
// TODO: get_volumes, returns a list of GVolumes, we shouldn't take copy
// as these are owned by the volume monitor
_WRAP_METHOD(bool is_media_removable() const, g_drive_is_media_removable)
_WRAP_METHOD(bool has_media() const, g_drive_has_media)
_WRAP_METHOD(bool is_media_check_automatic(),
g_drive_is_media_check_automatic)
_WRAP_METHOD(bool can_poll_for_media() const, g_drive_can_poll_for_media)
_WRAP_METHOD(bool can_eject(), g_drive_can_eject)
//TODO: Use MountUnmountFlags instead of GMountUnmountFlags - we need to wrap some more stuff to see where this should best be declared.
/** Ejects the drive.
* @param flags Flags affecting the unmount if required for eject.
* @param cancellable A cancellable object which can be used to cancel the eject.
* @param slot A callback which will be called when the eject is completed or canceled.
*/
void eject(GMountUnmountFlags flags, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot);
/** Ejects the drive.
* @param flags Flags affecting the unmount if required for eject.
* @param slot A callback which will be called when the eject is completed.
*/
void eject(GMountUnmountFlags flags, const SlotAsyncReady& slot);
_IGNORE(g_drive_eject)
_WRAP_METHOD(bool eject_finish(const Glib::RefPtr<AsyncResult>& result),
g_drive_eject_finish,
errthrow)
_IGNORE(g_drive_poll_for_media)
void poll_for_media(const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot);
void poll_for_media(const SlotAsyncReady& slot);
_WRAP_METHOD(bool poll_for_media_finish(const Glib::RefPtr<AsyncResult>& result),
g_drive_poll_for_media_finish,
errthrow)
/* vfuncs */
_WRAP_VFUNC(Glib::ustring get_name() const, "get_name")
// TODO: get_icon (when we wrap GIcon)
_WRAP_VFUNC(bool has_volumes() const, "has_volumes")
//TODO: finish
};
} // namespace Gio
|