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

Using an MacOS and Chrome (Gmail) doesn't attach the file #19

Open
farzadmf opened this issue Jul 25, 2023 · 13 comments
Open

Using an MacOS and Chrome (Gmail) doesn't attach the file #19

farzadmf opened this issue Jul 25, 2023 · 13 comments
Labels

Comments

@farzadmf
Copy link

Hi there,

This project is really what I needed on my Mac, and I was super excited about it, and I installed it immediately.

Tried to test it to attach a file in browser's Gmail (using Chrome), and when I drag the file, it basically pastes the path to the file, instead of attaching it to the email.

If I do the same using Finder (MacOS's file manager), it properly attaches the file.

I was wondering if this is something that is a known issue/can be fixed.

Thank you

@nik012003
Copy link
Owner

Yes, I am aware of this. Unfortunately, I confirmed that this is an issue with gtk4 iteself in both MacOS and Windows systems. As soon as the gtk fixes it, it should work automatically on ripdrag.

@farzadmf
Copy link
Author

Ah, that's too bad. Do you know if it's on their roadmap? Any issue I can track?

@nik012003
Copy link
Owner

I didn't see one open unfortunately, plese open one here https://gitlab.gnome.org/GNOME/gtk/-/issues if you feel like it.
I will try to fill the issue up with more information once I'll go back to macos... In the meanwhile I pushed some of the tests I was doing with on the macos-tests branch

@xxyxxyxyx1
Copy link

Is there an open issue GTK4 issue to follow?
I do not know what the problem is with GTK4, so I do not know what to search on their issue tracker.

@nik012003
Copy link
Owner

Is there an open issue GTK4 issue to follow? I do not know what the problem is with GTK4, so I do not know what to search on their issue tracker.

I don't think there is one. I don't have a working macos install to reproduce, but you should be able to repro and report the bug by compiling gtk4 demos and testing drag and drop there.

@ilyagr
Copy link

ilyagr commented Jun 26, 2024

I ended up using https://eternalstorms.at/yoink/mac/ for now. It's a little too elaborate for my liking, is not open-source, and has a nag screen until you pay, but works. See "Tip number 5" in https://eternalstorms.at/yoink/mac/tips/.

@Mellbourn
Copy link

@ilyagr that "Tip number 5", i.e. copying a file to clipboard in the terminal, can be achieved with a free script, e.g.

copy(){ osascript -e{'on run{a}','set the clipboard to posix file a',end} "$(greadlink -f -- "$1")";}

(source: https://apple.stackexchange.com/a/15484/12219)

@ilyagr
Copy link

ilyagr commented Oct 2, 2024

Actually, I think I've seen the light. You don't need any app on a Mac to have basic ripdrag-like functionality. You don't even need a script.

All you need is:

open -e anyfile  # Or, equivalently, `open -a TextEdit anyfile`.

Update: The -e shortcut was discovered by @xxyxxyxyx1 below, I was previously suggesting -a TextEdit. Browsing through the help, open -R anyfile can also be useful; it opens Finder with the file highlighted. open -t might be useful for people who set up an alternative default Mac text editor.

Then, you can use the proxy icon at the top of the screen to drag the file. By default, you need to click on the filename in the title for the icon to show up (but see below!).

image

I know it works since this is how the image above was attached to this issue :)

Hopefully unnecessary safety tip: don't save the file. If you make any edits, don't try to undo or fix them, just quit without saving.

Obviously, TextEdit is not the only app that can do this, many sufficiently Apple-y apps support proxy icons. It has two good properties: it's always installed and, unlike many Apple apps, it seems to be willing to open any file. TextEdit's one downside is that it requires the safety tip above; it'd be cool if there was an equally effective read-only app (e.g. if there was a way to open Finder's "Get Info" view from the command-line) or if there was a way to tell TextEdit to treat the file as read-only.


You can ask MacOS to show the proxy icons without requiring a click on the title by using the "Show window title icons" setting in the Settings app.

image

This is on Mac OS Sonoma 14.7.

@ilyagr
Copy link

ilyagr commented Oct 2, 2024

@ilyagr that "Tip number 5", i.e. copying a file to clipboard in the terminal, can be achieved with a free script, e.g.

copy(){ osascript -e{'on run{a}','set the clipboard to posix file a',end} "$(greadlink -f -- "$1")";}

(source: https://apple.stackexchange.com/a/15484/12219)

Thanks, this does a slightly different thing (of course, pasting does not fully replace drag-n-drop in every application), but works for me so far as well. For example, I checked and copying a JPG file with this script and pasting into a GitHub issue in Firefox works.

By the way, on recent versions of Mac OS (I'm on Sonoma, but I think this has been the case for some time), /usr/bin/readlink supports the -f option, so there is probably no need for greadlink. Just replace it with readlink.

#!/bin/sh
osascript -e{'on run{a}','set the clipboard to posix file a',end} "$(readlink -f -- "$1")"

(I put it into a separate file, but a shell function works too)

@xxyxxyxyx1
Copy link

@ilyagr, thank you very much for the window title icon idea! At first, I could not get it to work, but I think I have figured out the trick:
you must click and hold the mouse stationary on the icon for some small amount of time before moving the mouse. Even if the window bar has already been clicked, clicking the icon and immediately dragging just moves the window instead.

Two more notes:

  • according to the manpage, open -e will open the file in TextEdit. Slightly shorter than open -a TextEdit ;)
  • it would be nice if this could be achieved while opening the file in read-only-mode, like vim -m, to prevent accidental editing. I couldn't figure it out, though.

@ilyagr
Copy link

ilyagr commented Oct 2, 2024

according to the manpage, open -e will open the file in TextEdit. Slightly shorter than open -a TextEdit ;)

Nice! I updated my original comment with this suggestion.

it would be nice if this could be achieved while opening the file in read-only-mode, like vim -m, to prevent accidental editing. I couldn't figure it out, though.

Nice idea! For Vim fans, you can install https://github.com/macvim-dev/macvim, set up the mvim shortcut in your PATH1, and then use mvim -M (which seems slightly better than -m you suggested, which also works). Note that there's currently a minor bug, macvim-dev/macvim#1503, that makes the proxy icon invisible sometimes. It's still there, though.

Footnotes

  1. If installing via Homebrew, this is done automatically, but you can only have one of Homebrew's vim and macvim packages installed. gvim also works the same as mvim.

@xxyxxyxyx1
Copy link

I have encountered a situation where opening with the TextEdit does not work: zip archives.
However, your new suggestion of mvim -M does work. Thanks yet again.

@xxyxxyxyx1
Copy link

xxyxxyxyx1 commented Oct 3, 2024

Do you have a suggestion for doing this with many files? For example, if I have many zip archives to drag onto a webpage, might it be possible to have fewer than one drag per file?

macvim does not actually open multiple files when given multiple command line filename arguments, although "2 files to edit" is printed to terminal. I use this bash function now:

function odf() {
  for arg in "$@"
  do
    mvim -M --clean $arg
  done
}

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

No branches or pull requests

5 participants