macos implementation
This commit is contained in:
parent
e0a12342da
commit
c3653589f6
3 changed files with 18 additions and 12 deletions
|
@ -218,11 +218,11 @@ INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
||||||
#else
|
#else
|
||||||
void RemovableDriveManager::search_for_drives()
|
void RemovableDriveManager::search_for_drives()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
list_devices();
|
list_devices();
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
m_current_drives.clear();
|
m_current_drives.clear();
|
||||||
m_current_drives.reserve(26);
|
m_current_drives.reserve(26);
|
||||||
|
|
||||||
|
@ -389,6 +389,8 @@ void RemovableDriveManager::init()
|
||||||
add_callback([](void) { RemovableDriveManager::get_instance().print(); });
|
add_callback([](void) { RemovableDriveManager::get_instance().print(); });
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
register_window();
|
register_window();
|
||||||
|
#elif __APPLE__
|
||||||
|
register_window();
|
||||||
#endif
|
#endif
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -493,4 +495,4 @@ void RemovableDriveManager::print()
|
||||||
//std::cout << "Removed Device: "<<(int)is_last_drive_removed()<<"\n";
|
//std::cout << "Removed Device: "<<(int)is_last_drive_removed()<<"\n";
|
||||||
std::cout << "notified\n";
|
std::cout << "notified\n";
|
||||||
}
|
}
|
||||||
}}//namespace Slicer::Gui::
|
}}//namespace Slicer::Gui::
|
||||||
|
|
|
@ -55,10 +55,12 @@ private:
|
||||||
void *m_rdmmm;
|
void *m_rdmmm;
|
||||||
void register_window();
|
void register_window();
|
||||||
//void list_devices();
|
//void list_devices();
|
||||||
|
void search_path(const std::string &path, const std::string &parent_path);
|
||||||
|
bool compare_filesystem_id(const std::string &path_a, const std::string &path_b);
|
||||||
#else
|
#else
|
||||||
void search_path(const std::string &path, const std::string &parent_path);
|
void search_path(const std::string &path, const std::string &parent_path);
|
||||||
bool compare_filesystem_id(const std::string &path_a, const std::string &path_b);
|
bool compare_filesystem_id(const std::string &path_a, const std::string &path_b);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,37 +1,38 @@
|
||||||
#import "RemovableDriveManager.hpp"
|
#import "RemovableDriveManager.hpp"
|
||||||
|
#import "RemovableDriveManagerMM.h"
|
||||||
#import <AppKit/AppKit.h>
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
@implementation RemovableDriveManagerMM
|
@implementation RemovableDriveManagerMM
|
||||||
|
|
||||||
namespace Slic3r {
|
|
||||||
namespace GUI {
|
|
||||||
|
|
||||||
-(instancetype) init
|
-(instancetype) init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if(self)
|
if(self)
|
||||||
{
|
{
|
||||||
[self add_unmount_observer]
|
[self add_unmount_observer];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
-(void) on_device_unmount: (NSNotification*) notification
|
-(void) on_device_unmount: (NSNotification*) notification
|
||||||
{
|
{
|
||||||
NSLog(@"on device change");
|
NSLog(@"on device change");
|
||||||
RemovableDriveManager::get_instance().update();
|
Slic3r::GUI::RemovableDriveManager::get_instance().update();
|
||||||
}
|
}
|
||||||
-(void) add_unmount_observer
|
-(void) add_unmount_observer
|
||||||
{
|
{
|
||||||
|
NSLog(@"add unmount observer");
|
||||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidUnmountNotification object:nil];
|
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidUnmountNotification object:nil];
|
||||||
}
|
}
|
||||||
|
namespace Slic3r {
|
||||||
|
namespace GUI {
|
||||||
void RemovableDriveManager::register_window()
|
void RemovableDriveManager::register_window()
|
||||||
{
|
{
|
||||||
m_rdmmm = nullptr;
|
m_rdmmm = nullptr;
|
||||||
m_rdmmm = [[RemovableDriveManagerMM alloc] init];
|
m_rdmmm = [[RemovableDriveManagerMM alloc] init];
|
||||||
}
|
}
|
||||||
|
}}//namespace Slicer::GUI
|
||||||
|
|
||||||
/*
|
/*
|
||||||
-(void) RemovableDriveManager::list_devices()
|
-(void) RemovableDriveManager::list_devices()
|
||||||
|
@ -65,4 +66,5 @@ void RemovableDriveManager::register_window()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}}//namespace Slicer::GUI
|
|
||||||
|
@end
|
||||||
|
|
Loading…
Reference in a new issue