2019-12-09 14:33:10 +00:00
|
|
|
#import "RemovableDriveManager.hpp"
|
2019-12-10 10:17:12 +00:00
|
|
|
#import "RemovableDriveManagerMM.h"
|
2019-12-10 09:08:57 +00:00
|
|
|
#import <AppKit/AppKit.h>
|
|
|
|
|
|
|
|
@implementation RemovableDriveManagerMM
|
2019-12-09 14:33:10 +00:00
|
|
|
|
2019-12-10 10:17:12 +00:00
|
|
|
|
2019-12-09 14:33:10 +00:00
|
|
|
|
2019-12-10 09:08:57 +00:00
|
|
|
-(instancetype) init
|
2019-12-09 14:33:10 +00:00
|
|
|
{
|
2019-12-10 09:08:57 +00:00
|
|
|
self = [super init];
|
|
|
|
if(self)
|
2019-12-10 13:10:47 +00:00
|
|
|
{
|
2019-12-10 09:08:57 +00:00
|
|
|
}
|
|
|
|
return self;
|
2019-12-09 14:33:10 +00:00
|
|
|
}
|
|
|
|
-(void) on_device_unmount: (NSNotification*) notification
|
|
|
|
{
|
|
|
|
NSLog(@"on device change");
|
2019-12-10 10:17:12 +00:00
|
|
|
Slic3r::GUI::RemovableDriveManager::get_instance().update();
|
2019-12-09 14:33:10 +00:00
|
|
|
}
|
2019-12-10 09:08:57 +00:00
|
|
|
-(void) add_unmount_observer
|
|
|
|
{
|
2019-12-10 10:17:12 +00:00
|
|
|
NSLog(@"add unmount observer");
|
2019-12-10 09:08:57 +00:00
|
|
|
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidUnmountNotification object:nil];
|
|
|
|
}
|
2019-12-10 13:10:47 +00:00
|
|
|
-(NSArray*) list_dev
|
2019-12-10 10:35:39 +00:00
|
|
|
{
|
|
|
|
NSArray* devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
|
|
|
|
for (NSString* volumePath in devices)
|
|
|
|
{
|
2019-12-10 13:10:47 +00:00
|
|
|
NSLog(@"%@", volumePath);
|
|
|
|
}
|
|
|
|
return devices;
|
2019-12-10 10:35:39 +00:00
|
|
|
|
|
|
|
}
|
2019-12-10 10:17:12 +00:00
|
|
|
namespace Slic3r {
|
|
|
|
namespace GUI {
|
2019-12-10 13:10:47 +00:00
|
|
|
struct RemovableDriveManagerMMImpl{
|
|
|
|
RemovableDriveManagerMM * wrap;
|
|
|
|
}
|
|
|
|
RemovableDriveManagerMM():impl(new RemovableDriveManagerMMImpl){
|
|
|
|
impl->wrap = [[RemovableDriveManagerMM alloc] init];
|
|
|
|
}
|
|
|
|
RemovableDriveManagerMM::~RemovableDriveManagerMM()
|
2019-12-10 09:08:57 +00:00
|
|
|
{
|
2019-12-10 13:10:47 +00:00
|
|
|
if(impl)
|
|
|
|
{
|
|
|
|
[impl->wrap release];
|
|
|
|
}
|
2019-12-10 09:08:57 +00:00
|
|
|
}
|
2019-12-10 13:10:47 +00:00
|
|
|
void RDMMMWrapper::register_window()
|
2019-12-10 10:35:39 +00:00
|
|
|
{
|
2019-12-10 13:10:47 +00:00
|
|
|
if(impl->wrap)
|
|
|
|
{
|
|
|
|
[impl->wrap add_unmount_observer];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void RDMMMWrapper::list_devices()
|
|
|
|
{
|
|
|
|
if(impl->wrap)
|
|
|
|
{
|
|
|
|
NSArray* devices = [impl->wrap list_dev];
|
|
|
|
for (NSString* volumePath in devices)
|
|
|
|
{
|
|
|
|
NSLog(@"%@", volumePath);
|
|
|
|
Slic3r::GUI::RemovableDriveManager::get_instance().inspect_file(std::string([volumePath UTF8String]), "/Volumes");
|
|
|
|
}
|
|
|
|
}
|
2019-12-10 10:35:39 +00:00
|
|
|
}
|
2019-12-10 10:17:12 +00:00
|
|
|
}}//namespace Slicer::GUI
|
2019-12-10 09:08:57 +00:00
|
|
|
|
|
|
|
/*
|
2019-12-09 14:33:10 +00:00
|
|
|
|
2019-12-10 09:08:57 +00:00
|
|
|
*/
|
2019-12-10 10:17:12 +00:00
|
|
|
|
|
|
|
@end
|