lizgoban icon indicating copy to clipboard operation
lizgoban copied to clipboard

Request: Ability to default "open with" .sgf files with LizGoban

Open JamesMowery opened this issue 3 years ago • 9 comments

It would be great if, when you set .sgf files on your computer to open by default with LizGoban, if that actually worked as would be expected. When setting LizGoban to open .sgf files by default currently, nothing really happens after LizGoban opens up. It doesn't automatically load the .sgf file.

Thanks! Really loving the program so far! Happy it's updated to KataGo 1.9!

JamesMowery avatar Jul 05 '21 02:07 JamesMowery

happy to hear you enjoy my program :)

Before examining how we can realize it, I'd like to confirm this: Are you using LizGoban 0.*.*.exe on Windows? If "no", please let me know your environment and how you launch lizgoban.

kaorahi avatar Jul 05 '21 11:07 kaorahi

No worries! I'm using LizGoban 0.6.2 with updated version of Windows 10, and just tried it this morning! Tried with both the prior version and new version of LizGoban.

This is what I see when I try to explicitly "open with" LizGoban...

https://drive.google.com/uc?id=1IWFjrzBlvI7hsgldZtIVryWsMXdBVp2F

As you can see, nothing has happened. It just opened the program as it normally would. I'd still need to go to File > Open SGF or drag the file in for it to actually open it.

Would just be very handy because the only reason I download .sgf files is to open them in LizGoban. So being able to set LizGoban as the default app and immediately open it up with the file loaded would save some time.

JamesMowery avatar Jul 05 '21 16:07 JamesMowery

Ah, sorry. I just intended to confirm...

  1. Are you using Windows? (not Mac, Linux, etc.)
  2. Are you using *.exe? (not npm start, lizgoban_windows.vbs, etc.)

I'll study how to implement this feature.

kaorahi avatar Jul 06 '21 11:07 kaorahi

1.) Yes! Sorry for not showing the window chrome. Latest updated version of Windows 10 being used. 2.) Yup! Using the LizGoban 0.6.2.exe for the "Open With" command.

If it's helpful, it looks like Sabaki is also written with Electron. So perhaps the author of the program might be willing to help provide code to easily drop this in to implement the open with functionality.

Thanks so much!

JamesMowery avatar Jul 06 '21 19:07 JamesMowery

Not so easy...

"Open with" itself seems to work for lizgoban. I get into trouble if I use "open with" when lizgoban is already running. There are two strategies in this case.

  • (A) Open another lizgoban instance.
  • (B) Reuse the existing lizgoban instance.

I prefer (B) strongly. But the standard way of (B) in Electron (requestSingleInstanceLock and second-instance) does not work well in my case. It goes like this:

  1. The second instance starts.
  2. The second instance checks "I am not first" and quits.
  3. As a side effect of Step 2, the first instance receives an event on this attempt.
  4. The first instance reacts to the attempt.

As Lizgoban*.exe is a compressed archive actually, Step 1 takes unbearably long time for extraction before its start.

kaorahi avatar Jul 07 '21 14:07 kaorahi

Why not add Recent files menu item. It's easy to view and open recent opened files?

function get_recent_files() {
        const files = store.get('recent_files') || [];
        const item = files.map(file => ({
            label: file,
            click() { load_sgf_etc(file) }
        }))
        return item;
    }
    const file_menu = menu('File', [
        menu('Recent Files', get_recent_files()),
截屏2023-11-30 14 36 10

qcgm1978 avatar Nov 30 '23 06:11 qcgm1978

Hmm, the 'recent files' feature seems unrelated to this issue for me. Am I missing something?

kaorahi avatar Nov 30 '23 14:11 kaorahi

I only want to know whether there's such feature in the project. I think they're the similar problems to me. Of course they are different features to others.

qcgm1978 avatar Nov 30 '23 16:11 qcgm1978

I see. Then let's move to the new issue #101.

kaorahi avatar Dec 01 '23 12:12 kaorahi