From e0a12342da33ea2e79b06777c5579294094353ed Mon Sep 17 00:00:00 2001
From: David Kocik <kocikdav@gmail.com>
Date: Tue, 10 Dec 2019 10:08:57 +0100
Subject: [PATCH] macos mm files

---
 src/slic3r/CMakeLists.txt                     |  3 +-
 src/slic3r/GUI/RemovableDriveManager.hpp      |  3 +-
 src/slic3r/GUI/RemovableDriveManagerMM.h      |  9 ++++++
 ...eManager.mm => RemovableDriveManagerMM.mm} | 29 +++++++++++++++----
 4 files changed, 36 insertions(+), 8 deletions(-)
 create mode 100644 src/slic3r/GUI/RemovableDriveManagerMM.h
 rename src/slic3r/GUI/{RemovableDriveManager.mm => RemovableDriveManagerMM.mm} (86%)

diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt
index 246f1365b..a06a8cf1d 100644
--- a/src/slic3r/CMakeLists.txt
+++ b/src/slic3r/CMakeLists.txt
@@ -169,7 +169,8 @@ if (APPLE)
     list(APPEND SLIC3R_GUI_SOURCES
             Utils/RetinaHelperImpl.mm
             Utils/MacDarkMode.mm
-            GUI/RemovableDriveManager.mm
+            GUI/RemovableDriveManagerMM.mm
+            GUI/RemovableDriveManagerMM.h
         )
 endif ()
 
diff --git a/src/slic3r/GUI/RemovableDriveManager.hpp b/src/slic3r/GUI/RemovableDriveManager.hpp
index 501c16b71..04bbe48b5 100644
--- a/src/slic3r/GUI/RemovableDriveManager.hpp
+++ b/src/slic3r/GUI/RemovableDriveManager.hpp
@@ -52,8 +52,9 @@ private:
 	void register_window();
 	//INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
 #elif __APPLE__
+	void *m_rdmmm;
 	void register_window();
-	void list_devices();
+	//void list_devices();
 #else
 	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);
diff --git a/src/slic3r/GUI/RemovableDriveManagerMM.h b/src/slic3r/GUI/RemovableDriveManagerMM.h
new file mode 100644
index 000000000..8f783c2d2
--- /dev/null
+++ b/src/slic3r/GUI/RemovableDriveManagerMM.h
@@ -0,0 +1,9 @@
+#import <Cocoa/Cocoa.h>
+
+@interface RemovableDriveManagerMM : NSObject
+
+-(instancetype) init;
+-(void) add_unmount_observer;
+-(void) on_device_unmount: (NSNotification*) notification;
+
+@end
\ No newline at end of file
diff --git a/src/slic3r/GUI/RemovableDriveManager.mm b/src/slic3r/GUI/RemovableDriveManagerMM.mm
similarity index 86%
rename from src/slic3r/GUI/RemovableDriveManager.mm
rename to src/slic3r/GUI/RemovableDriveManagerMM.mm
index a1358625f..e4e324654 100644
--- a/src/slic3r/GUI/RemovableDriveManager.mm
+++ b/src/slic3r/GUI/RemovableDriveManagerMM.mm
@@ -1,22 +1,39 @@
 #import "RemovableDriveManager.hpp"
 
-@implementation RemovableDriveManager
+#import <AppKit/AppKit.h> 
+
+@implementation RemovableDriveManagerMM
 
 namespace Slic3r {
 namespace GUI {
 
-void RemovableDriveManager::register_window()
+-(instancetype) init
 {
-	//[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(volumesChanged:) name:NSWorkspaceDidMountNotification object: nil];
-    [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidUnmountNotification object:nil];
+	self = [super init];
+	if(self)
+	{
+		[self add_unmount_observer]
+	}
+	return self;
 }
-
 -(void) on_device_unmount: (NSNotification*) notification
 {
     NSLog(@"on device change");
     RemovableDriveManager::get_instance().update();
 }
+-(void) add_unmount_observer
+{
+    [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidUnmountNotification object:nil];
+}
 
+void RemovableDriveManager::register_window()
+{
+	m_rdmmm = nullptr;
+	m_rdmmm = [[RemovableDriveManagerMM alloc] init];
+}
+
+
+/*
 -(void) RemovableDriveManager::list_devices()
 {
 	NSLog(@"---");
@@ -47,5 +64,5 @@ void RemovableDriveManager::register_window()
 	    NSLog(@"Result:%i Volume: %@, Removable:%i, W:%i, Unmountable:%i, Desc:%@, type:%@", result, volumePath, isRemovable, isWritable, isUnmountable, description, type);
 	}
 }
-
+*/
 }}//namespace Slicer::GUI
\ No newline at end of file