mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 06:33:57 -06:00
macos better wrapper
This commit is contained in:
parent
c37128ad63
commit
a259058845
4 changed files with 87 additions and 66 deletions
|
@ -10,8 +10,7 @@
|
|||
{
|
||||
self = [super init];
|
||||
if(self)
|
||||
{
|
||||
[self add_unmount_observer];
|
||||
{
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -25,48 +24,49 @@
|
|||
NSLog(@"add unmount observer");
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidUnmountNotification object:nil];
|
||||
}
|
||||
-(void) list_dev
|
||||
-(NSArray*) list_dev
|
||||
{
|
||||
NSLog(@"---");
|
||||
NSArray* devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
|
||||
for (NSString* volumePath in devices)
|
||||
{
|
||||
NSLog(@"@", volumePath);
|
||||
}
|
||||
NSLog(@"--");
|
||||
//removable here means CD not USB :/
|
||||
NSArray* listOfMedia = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths];
|
||||
NSLog(@"%@", listOfMedia);
|
||||
NSLog(@"%@", volumePath);
|
||||
}
|
||||
return devices;
|
||||
|
||||
for (NSString* volumePath in listOfMedia)
|
||||
{
|
||||
BOOL isRemovable = NO;
|
||||
BOOL isWritable = NO;
|
||||
BOOL isUnmountable = NO;
|
||||
NSString* description = [NSString string];
|
||||
NSString* type = [NSString string];
|
||||
|
||||
BOOL result = [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath:volumePath
|
||||
isRemovable:&isRemovable
|
||||
isWritable:&isWritable
|
||||
isUnmountable:&isUnmountable
|
||||
description:&description
|
||||
type:&type];
|
||||
NSLog(@"Result:%i Volume: %@, Removable:%i, W:%i, Unmountable:%i, Desc:%@, type:%@", result, volumePath, isRemovable, isWritable, isUnmountable, description, type);
|
||||
}
|
||||
}
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
void RemovableDriveManager::register_window()
|
||||
{
|
||||
m_rdmmm = nullptr;
|
||||
m_rdmmm = [[RemovableDriveManagerMM alloc] init];
|
||||
struct RemovableDriveManagerMMImpl{
|
||||
RemovableDriveManagerMM * wrap;
|
||||
}
|
||||
void RemovableDriveManager::list_devices()
|
||||
RemovableDriveManagerMM():impl(new RemovableDriveManagerMMImpl){
|
||||
impl->wrap = [[RemovableDriveManagerMM alloc] init];
|
||||
}
|
||||
RemovableDriveManagerMM::~RemovableDriveManagerMM()
|
||||
{
|
||||
if(m_rdmmm == nullptr)
|
||||
return;
|
||||
[m_rdmmm list_dev];
|
||||
if(impl)
|
||||
{
|
||||
[impl->wrap release];
|
||||
}
|
||||
}
|
||||
void RDMMMWrapper::register_window()
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}}//namespace Slicer::GUI
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue