Closed Viza74 closed 5 years ago
Note: file association for Mac: https://github.com/mjmlio/mjml-app/commit/4391f517b6de83038513b1667c9b7d5e595ae7cf
Postponing to a later milestone, need to give this some more thought. This means Petmate 0.4 is READY!
May I ask what needs more thought? I don't want to nag you or anything :) and definitely don't delay 0.4 just for this, but to me this seemed a somewhat easy feature add, and I'm curious what potential difficulties poped up?
It needs another code path for Windows, so I’d need to do some extra work for that platform. Also my code for mac didn’t quite work robustly. I want to finish the ”new window” part on macOS first before doing this so I can do this cleaner and robustly.
It’s not a lot of code but I don’t want this to be a source of bugs. So planning to release 0.4 first and add this in the next minor release.
It’s definitely coming, just want the next release out.
Uhh, I don't understand any of that :)
In my mind drag and drop open should be like a couple of lines of code... accept drop event, exctract filename, send to file open function.
File association - I don't know how programs "self register" for a specific file extension (I guess that platform specific), but if the user associates the file type with the program, then open with double click support is basically just supporting a file command line parameter like petmate myfile.petmate At least that owrked like a decade ago :)
The recent files menu seems to be more work, but mostly "straightforward" work - saving the states, doing the menus.
Again, please don't take this as nagging, I just interested in the technical details, so I would know if this pops up somewhere else next time. :)
On Windows the file association and double click on a .petmate file is not an Electron event but it opens a new instance of the app and sends to filename as a command line argument. On Mac Electron, it's an event, not a command line argument. Not too hard to implement, but needs testing nevertheless and I don't always have access to a Windows box as I mainly work on macOS. I maintain the Windows port as a first class citizen too, so I don't want to release an untested Windows version.
The second potential source of problems is the "open-file" event that Electron sends to my app when dragging a .petmate file into the window or double clicking a .petmate file. There's an ordering issue in how the app is initialized. I get the event "too early", before my app has had a chance to bootstrap. If this event comes too early, before my app is up, it will just crash. While it's possible to of course deal with this correctly, I haven't written the code yet let alone tested it. So I decided against shipping a half-assed implementation and rather spend enough time on it to know that it works robustly when a new Petmate ships with this feature.
File association (at least on Mac) is relatively easy. I do have code that installs Petmate as the handler for .petmate files. So there's no need for the user to associate manually.
This stuff is IMO pretty poorly documented in Electron and there seems to have been a lot of bugs related to it. So I'm just erring on caution. And also there's other stuff to do for 0.4 like update the docs, make a new 0.4 showcase video, etc.
I will of course be happy to review and accept PRs if you're feeling adventurous to implement it yourself for tonight's release. :)
Ahh, I see, thanks for technical info
Hey, progress being made: https://www.youtube.com/watch?v=ER5gZJdl21Q
This is just the drag to open. It flashes the editor window to a darkened version when something a file is being dragged on top of the window to indicate that drag&drop actually does something.
Will take a look at the "double click .petmate to open" at some later point.. probably want that in the next release too.
Looking very good! That will be so much better!
Not that important, just some "quality of life" enchantments: