Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Mac OS #6

Merged
merged 10 commits into from
Jun 18, 2021
Merged

Add support for Mac OS #6

merged 10 commits into from
Jun 18, 2021

Conversation

williamchange
Copy link
Contributor

I am able to get most of the features working on mac OS, with pasteboard being the only needed dependency for path data.

Everything else is handled with applescript (osascript) which is built-in on macs.

Tested on Mac OS Big Sur 11.4 on Macbook Pro 15" 2018, with Blender versions 2.83.16, 2.92, 2.93.0 (LTS), and 3.0 (current master).

What's working(so far):

  • Pasting one or more images from Finder
  • Pasting from screenshot (i.e. ctrl-cmd-shift-4)
  • Pasting from other apps(tested with Preview)
  • Pasting from websites (tested with Firefox 89, Chrome 91)
  • Copying image from Blender to clipboard

Pasting doesn't work when copied from Safari because clipboard stored website link instead of image data.

recording.mp4

@thanhph111
Copy link
Collaborator

Great job. I'm really looking forward to this PR. I'll review the code as soon as possible.

However, I'm going to restructure the repo to make it easier for future contributions, it is PR #7 and then I plan to split the code into separate modules. I hope we can make some changes before merging this PR to main. Tell me what you think.

By the way, may I ask why did you decide to use pasteboard? Is it good to use a set of more native commands like pbcopy and pbpaste? I'm not familiar with macOS so the questions might be a bit silly for you, please excuse me.

Finally, thanks a lot for your contributions.

@thanhph111 thanhph111 self-requested a review June 17, 2021 17:29
Copy link
Collaborator

@thanhph111 thanhph111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: I just finished my work. As you can see, we have a merge conflict. I think we can work together to make it mergeable.

By the way I have a few points to ask? Can you take time to have a look?

__init__.py Outdated Show resolved Hide resolved
mac.py Outdated Show resolved Hide resolved
mac.py Outdated Show resolved Hide resolved
@thanhph111
Copy link
Collaborator

I see a lot of improvements here. When you're satisfied with new changes, you could re-request me and I will come back asap. Take it easy, OK? 😄

@williamchange
Copy link
Contributor Author

By the way, may I ask why did you decide to use pasteboard? Is it good to use a set of more native commands like pbcopy and pbpaste? I'm not familiar with macOS so the questions might be a bit silly for you, please excuse me.

Finally, thanks a lot for your contributions.

Thanks.

The current implementation is mostly motivated from pillow 's grabclipboard function which uses applescript to access the clipboard.

I also looked into those commands, but they seemed to only handle text, and copying multiple images(from Finder) I was only able to grab the first filename using pbpaste. The same goes for applescript which only yields the first result(as file name or path) when multiple images are copied (see https://stackoverflow.com/a/3485101), though it worked well when dealing with copying/pasting image data.

so pasteboard is here to only deal with translating copied image files from Finder to absolute paths.

@thanhph111
Copy link
Collaborator

Thanks for the useful information. So for now, the only remaining problem is that it doesn't work with clipboard received from the Safari browser?

Both the Windows and Linux version I'm working on always have issues when handle transparent images. Have you test a transparent image with a gradient shadow like this (both copy to Blender and copy from Blender)?

__init__.py Outdated Show resolved Hide resolved
@williamchange
Copy link
Contributor Author

Thanks for the useful information. So for now, the only remaining problem is that it doesn't work with clipboard received from the Safari browser?

Yes, Safari was not working when I first opened this PR but I can confirm this works now:

safari.mp4

Both the Windows and Linux version I'm working on always have issues when handle transparent images. Have you test a transparent image with a gradient shadow like this (both copy to Blender and copy from Blender)?

Yeah transparency worked out fine for me both ways:

test.mp4

Hmm not sure what happened but I probably messed it up during fetch upstream from my editor.

Co-authored-by: Thanh Phan <thanhph111@gmail.com>
@thanhph111
Copy link
Collaborator

Great! I think it's perfect now.
Thank you for your effort and patience. Hope to see you in the next contributions.

@williamchange
Copy link
Contributor Author

All good! Thanks for your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants