def mount(path, callback): print("mount(%s)" % path) drives = gnomevfs.VolumeMonitor().get_connected_drives() for drive in drives: if drive.get_activation_uri() == path: drive.mount(callback) time.sleep(2)
def get_drive_icon(path): icon_theme = gtk.icon_theme_get_default() volume = gnomevfs.VolumeMonitor().get_volume_for_path(path) icon = None if volume: icon = icon_theme.load_icon(volume.get_icon(), 24, 0) return icon
def __init__(self, drive = None, uri = None): assert drive or uri, "Invalid arguments passed to DriveItem.__init__" if not drive and uri: for drive in gnomevfs.VolumeMonitor().get_connected_drives(): if drive.get_activation_uri() == uri: break else: raise ValueError, "Cannot find drive to match URI '%s'" % uri uri = drive.get_activation_uri() if not uri: for volume in drive.get_mounted_volumes(): if volume.is_user_visible(): # FIXME: Using the first volume URI for a device is # broken. There could be multiple, though I don't # know under what circumstances this would happen. uri = volume.get_activation_uri() break else: raise ValueError, "Cannot find URI to open for drive '%s'" % \ drive.get_display_name() Item.__init__(self, uri=uri, timestamp=0, mimetype="x-gimmie/drive", icon=drive.get_icon()) self.drive = drive
def __init__(self): ItemSource.__init__(self, name=_("Devices & Media"), icon="gnome-dev-removable-usb", uri="source://Devices", filter_by_date=False) self.add_bluetooth = Item(name=_("Add Bluetooth..."), comment=_("Access a wireless device"), icon="stock_bluetooth", special=True) self.add_bluetooth.do_open = lambda: self._add_bluetooth() self.cd_burner = Item(name=_("Create CD/DVD..."), comment=_("Burn files onto a CD or DVD disk"), icon="gnome-dev-cdrom", special=True) self.cd_burner.do_open = \ lambda: launcher.launch_command("nautilus --no-desktop burn:///") self.vol_monitor = gnomevfs.VolumeMonitor() self.vol_monitor.connect("drive_connected", lambda v, d: self.emit("reload")) self.vol_monitor.connect("drive_disconnected", lambda v, d: self.emit("reload")) self.vol_monitor.connect("volume_mounted", lambda v, d: self.emit("reload")) self.vol_monitor.connect("volume_unmounted", lambda v, d: self.emit("reload"))
def eject(path): print("EJECT: " + path) drives = gnomevfs.VolumeMonitor().get_connected_drives() for drive in drives: if drive.get_activation_uri() == path: return drive.eject(callback_eject) # Callback dont work volumes = drive.get_mounted_volumes() for volume in volumes: if volume.get_activation_uri() == path: drive.eject(callback_eject)
def __init__(self): gobject.GObject.__init__(self) self.volume_monitor = gnomevfs.VolumeMonitor() self.trash_dirs = {} # volume_uri : TrashDirectory self.notify_id = None self.volume_monitor.connect("volume_mounted", lambda m, v: self.add_volume(v)) self.volume_monitor.connect("volume_pre_unmount", lambda m, v: self.remove_volume(v)) self.recheck_trash_dirs()
def __init__(self): ItemSource.__init__(self, name=_("Nearby Computers"), icon=gtk.STOCK_NETWORK, uri="source://Network", filter_by_date=False) self.connect_to = Item(name=_("Connect to..."), comment=_("Access a computer on the network"), icon=gtk.STOCK_CONNECT, special=True) self.connect_to.do_open = lambda: self._connect_to() self.smb = Item(name=_("Windows Network"), comment=_("Browse nearby Windows computers"), icon=gtk.STOCK_NETWORK, special=True) self.smb.do_open = lambda: launcher.launch_command("nautilus smb://") self.vol_monitor = gnomevfs.VolumeMonitor() self.vol_monitor.connect("volume_mounted", lambda v, d: self.emit("reload")) self.vol_monitor.connect("volume_unmounted", lambda v, d: self.emit("reload"))
def get_gnome_drive(self, udi): monitor = gnomevfs.VolumeMonitor() for drive in monitor.get_connected_drives(): if drive.get_hal_udi() == udi: return drive
def __init__(self): gobject.GObject.__init__(self) self.vm = gnomevfs.VolumeMonitor() self.vm.connect("volume-mounted", self.mount_added) self.vm.connect("volume-unmounted", self.mount_removed)
def is_mounted(path): drives = gnomevfs.VolumeMonitor().get_connected_drives() for drive in drives: if drive.get_activation_uri() == path and drive.is_mounted(): return True return False
def get_label(path): drive = gnomevfs.VolumeMonitor().get_volume_for_path(path) if drive: print("label:", drive.get_display_name()) return drive.get_display_name()
def mount(path, callback): print("mount(%s)" % path) drives = gnomevfs.VolumeMonitor().get_connected_drives() for drive in drives: if drive.get_activation_uri() == path: drive.mount(callback) time.sleep(2) if __name__ == "__main__": # path = "/media/cdrom0" path = "/home/michal/Pictures/2014/" icon = get_drive_icon(path) if icon: icon.save('/home/jose/Escritorio/tmp_gnomecatalog_icon.png', 'png') drives = gnomevfs.VolumeMonitor().get_connected_drives() print("drives=%s" % drives) volume = gnomevfs.VolumeMonitor().get_volume_for_path(path) if volume: print("volume(%s)=>%s" % (path, drives)) print("volume is mounted = %s" % volume.is_mounted()) print(dir(volume)) for drive in drives: print(dir(drive)) print(drive.get_activation_uri()) if drive.get_activation_uri() == path: print(path) # drive.mount(mounted)