[Users] Open Attachments

Milan Obuch claws-mail-users at dino.sk
Tue Sep 28 21:46:03 CEST 2021


On Sat, 25 Sep 2021 23:39:12 +0200 I wrote:

> On Sun, 26 Sep 2021 10:27:12 +1300, Brian Bates <buzz at ksys.co.nz>
> wrote:
> 
> > On Fri, 24 Sep 2021 08:25:57 +0200
> > Milan Obuch <claws-mail-users at dino.sk> wrote:
> > 
> > > > Sorry for being vague.
> > > > What I am trying to achieve:
> > > > 1. Open new compose window.
> > > > 2. Press Ctrl+M and attach a pdf file.
> > > > 3. Go to the "Attachments" tab in the compose window.
> > > > 
> > > > This is where I am stumped so far.
> > > > 
> > > > This will now be showing the attached file details in what I
> > > > think may be a list box, under the headings "Mime type" "Size"
> > > > "Name". It should be showing the following line:
> > > > "application/pdf 20.11KB mypdf.pdf"
> > > > 
> > > > If I double click this line it shows a properties dialog. Right
> > > > click give the options to remove it, add another file or show
> > > > the properties dialog.
> > > > 
> > > > I would like to add the ability to open the file in the
> > > > appropriate external program. In this case my choice of pdf
> > > > viewer. 

[ snip ]

> I am currently testing simple solution for this task. I need a bit
> more time to make it working well, but some skeleton is already done.
> So you'll get some answer from me, hopefully soon.
>

[ Follow-up to my mail ]

Not yet done perfectly well, but basically it is working now, using Lua
plugin. It requires two small scripts, first one in hook/compose_created
to install an additional item into popup menu:

--- 8< ----------------------------------------------------------------

local compose_window = ...
local xmenu = '<ui>' ..
               '<menubar name="Popup">' ..
                '<menu name="Compose" action="Compose">' ..
                 '<separator name="Separator2" action="Compose/---"/>' ..
                 '<menuitem name="Test" action="Tools/LuaScripts/OpenWith..."/>' ..
                '</menu>' ..
               '</menubar>' ..
              '</ui>'
local mid = compose_window.ui_manager:add_ui(xmenu)

--- 8< ----------------------------------------------------------------

and second one to be executed in compose/OpenWith... (file name is used
as menu item label, thus the name):

--- 8< ----------------------------------------------------------------

local compose = ...
local attachments = compose.attachments
[[ extract necessary file name from table get above just get into fname ]]
os.execute("xpdf " .. fname)

--- 8< ----------------------------------------------------------------

Exact binding for compose.attachments is not yet done, but I am able to
get both attachment table and selected items list for compose window,
just those pieces needs to be put somehow together (or I'd like to do
it this way).

So if you'd like to test it, I can send you necessary sources to build
Lua plugin (it is not yet in official repository, but it is easy to use
if you are able to build from source).

Regards,
Milan


More information about the Users mailing list