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-11 13:53:28 +00:00
|
|
|
Slic3r::GUI::RemovableDriveManager::get_instance().update(0,true);
|
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-16 14:46:25 +00:00
|
|
|
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidMountNotification object:nil];
|
2019-12-10 09:08:57 +00:00
|
|
|
}
|
2019-12-10 13:10:47 +00:00
|
|
|
-(NSArray*) list_dev
|
2019-12-10 10:35:39 +00:00
|
|
|
{
|
|
|
|
NSArray* devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
|
2019-12-10 13:10:47 +00:00
|
|
|
return devices;
|
2019-12-10 10:35:39 +00:00
|
|
|
|
|
|
|
}
|
2019-12-10 10:17:12 +00:00
|
|
|
namespace Slic3r {
|
|
|
|
namespace GUI {
|
2019-12-11 09:16:32 +00:00
|
|
|
RDMMMWrapper::RDMMMWrapper():m_imp(nullptr){
|
|
|
|
m_imp = [[RemovableDriveManagerMM alloc] init];
|
2019-12-10 13:10:47 +00:00
|
|
|
}
|
2019-12-11 09:16:32 +00:00
|
|
|
RDMMMWrapper::~RDMMMWrapper()
|
2019-12-10 09:08:57 +00:00
|
|
|
{
|
2019-12-11 09:16:32 +00:00
|
|
|
if(m_imp)
|
2019-12-10 13:10:47 +00:00
|
|
|
{
|
2019-12-11 09:16:32 +00:00
|
|
|
[m_imp release];
|
2019-12-10 13:10:47 +00:00
|
|
|
}
|
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-11 09:16:32 +00:00
|
|
|
if(m_imp)
|
2019-12-10 13:10:47 +00:00
|
|
|
{
|
2019-12-11 09:16:32 +00:00
|
|
|
[m_imp add_unmount_observer];
|
2019-12-10 13:10:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
void RDMMMWrapper::list_devices()
|
|
|
|
{
|
2019-12-11 09:16:32 +00:00
|
|
|
if(m_imp)
|
2019-12-10 13:10:47 +00:00
|
|
|
{
|
2019-12-11 09:16:32 +00:00
|
|
|
NSArray* devices = [m_imp list_dev];
|
2019-12-10 13:10:47 +00:00
|
|
|
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-11 15:59:26 +00:00
|
|
|
void RDMMMWrapper::log(const std::string &msg)
|
|
|
|
{
|
|
|
|
NSLog(@"%s", msg.c_str());
|
|
|
|
}
|
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
|