mirror of
https://codeberg.org/cage/tinmop/
synced 2025-03-12 11:20:05 +01:00
- [TUI] prevented a crash when an external program can not be found.
This commit is contained in:
parent
c9279d21ec
commit
ddc81fb2b0
@ -565,7 +565,7 @@
|
||||
(if (tree-dir-p node-data)
|
||||
(expand-treenode window node-path)
|
||||
(let ((downloaded-path (download-path window node-path)))
|
||||
(os-utils:open-resource-with-external-program downloaded-path nil)))))
|
||||
(ui:open-resource-with-external-program downloaded-path nil)))))
|
||||
|
||||
(defun edit-node (window path)
|
||||
(when-let* ((root-node (filesystem-root window))
|
||||
@ -576,7 +576,7 @@
|
||||
(expand-treenode window node-path)
|
||||
(let ((downloaded-path (download-path window node-path)))
|
||||
(croatoan:end-screen)
|
||||
(os-utils:open-resource-with-external-program downloaded-path nil :open-for-edit t)
|
||||
(ui:open-resource-with-external-program downloaded-path nil :open-for-edit t)
|
||||
(upload-path window
|
||||
downloaded-path
|
||||
node-path)))))
|
||||
|
@ -103,7 +103,7 @@
|
||||
(force-rendering-of-cached-file stream-object)
|
||||
(setf (stream-status stream-object) :completed))
|
||||
(t
|
||||
(os-utils:open-resource-with-external-program support-file t))))))
|
||||
(ui:open-resource-with-external-program support-file t))))))
|
||||
|
||||
(defclass gemini-stream ()
|
||||
((download-thread-lock
|
||||
@ -520,7 +520,7 @@
|
||||
:payload regex)))
|
||||
(program-events:push-event event))))
|
||||
(open-with-external-program
|
||||
(os-utils:open-resource-with-external-program support-file nil)))
|
||||
(ui:open-resource-with-external-program support-file nil)))
|
||||
;; (allow-downloading wrapper-object)
|
||||
(gemini-client:close-ssl-socket download-socket))))))))
|
||||
;; (fs:delete-file-if-exists support-file)))))
|
||||
@ -586,8 +586,8 @@
|
||||
(not wait-for-download)
|
||||
(opening-partial-contents-p (octet-count wrapper-object)))
|
||||
(setf partial-content-not-opened nil)
|
||||
(os-utils:open-resource-with-external-program support-file
|
||||
nil))
|
||||
(ui:open-resource-with-external-program support-file
|
||||
nil))
|
||||
(%fill-buffer))))))))
|
||||
(%fill-buffer)))))))
|
||||
|
||||
|
@ -277,7 +277,7 @@
|
||||
:collect-fn (lambda (buffer)
|
||||
(write-sequence buffer stream)))
|
||||
(finish-output stream)
|
||||
(os-utils:open-resource-with-external-program filesystem-utils:temp-file
|
||||
(ui:open-resource-with-external-program filesystem-utils:temp-file
|
||||
nil))))))))
|
||||
|
||||
(defun open-menu-link ()
|
||||
|
@ -17,26 +17,27 @@
|
||||
(in-package :client-os-utils)
|
||||
|
||||
(defun open-resource-with-external-program (main-window resource &key (open-for-edit nil))
|
||||
(flet ((edit (file)
|
||||
(croatoan:end-screen)
|
||||
(os-utils:open-with-editor file)))
|
||||
(alexandria::when-let* ((parsed-as-iri (iri:iri-parse resource :null-on-error t))
|
||||
(parsed-no-fragment (iri:remove-fragment parsed-as-iri)))
|
||||
(let ((program (if (iri:absolute-url-p resource)
|
||||
(swconf:link-regex->program-to-use (text-utils:to-s parsed-no-fragment))
|
||||
(swconf:link-regex->program-to-use resource))))
|
||||
(if program
|
||||
(cond
|
||||
((swconf:use-editor-as-external-program-p program)
|
||||
(edit resource))
|
||||
((swconf:use-tinmop-as-external-program-p program)
|
||||
(if open-for-edit
|
||||
(edit resource)
|
||||
(client-main-window:open-local-path resource
|
||||
main-window
|
||||
:force-rendering t)))
|
||||
(t
|
||||
(os-utils:open-link-with-program program resource :wait open-for-edit)))
|
||||
(if open-for-edit
|
||||
(error (_ "No program defined in configuration file to edit this kind of files"))
|
||||
(os-utils:xdg-open resource)))))))
|
||||
(gui-goodies:with-notify-errors
|
||||
(flet ((edit (file)
|
||||
(croatoan:end-screen)
|
||||
(os-utils:open-with-editor file)))
|
||||
(alexandria::when-let* ((parsed-as-iri (iri:iri-parse resource :null-on-error t))
|
||||
(parsed-no-fragment (iri:remove-fragment parsed-as-iri)))
|
||||
(let ((program (if (iri:absolute-url-p resource)
|
||||
(swconf:link-regex->program-to-use (text-utils:to-s parsed-no-fragment))
|
||||
(swconf:link-regex->program-to-use resource))))
|
||||
(if program
|
||||
(cond
|
||||
((swconf:use-editor-as-external-program-p program)
|
||||
(edit resource))
|
||||
((swconf:use-tinmop-as-external-program-p program)
|
||||
(if open-for-edit
|
||||
(edit resource)
|
||||
(client-main-window:open-local-path resource
|
||||
main-window
|
||||
:force-rendering t)))
|
||||
(t
|
||||
(os-utils:open-link-with-program program resource :wait open-for-edit)))
|
||||
(if open-for-edit
|
||||
(error (_ "No program defined in configuration file to edit this kind of files"))
|
||||
(os-utils:xdg-open resource))))))))
|
||||
|
@ -169,4 +169,4 @@
|
||||
(progn
|
||||
(db:cache-invalidate url)
|
||||
(open-attachment url))
|
||||
(os-utils:open-resource-with-external-program cached-file nil))))))))
|
||||
(ui:open-resource-with-external-program cached-file nil))))))))
|
||||
|
@ -162,7 +162,7 @@
|
||||
((fs:dirp decoded-path)
|
||||
(ui:open-file-explorer decoded-path))
|
||||
(t
|
||||
(os-utils:open-resource-with-external-program decoded-path nil))))))))
|
||||
(ui:open-resource-with-external-program decoded-path nil))))))))
|
||||
|
||||
(defclass open-links-window ()
|
||||
((links
|
||||
|
@ -3292,7 +3292,8 @@
|
||||
:search-fediverse
|
||||
:search-fediverse-local
|
||||
:localized-default-string
|
||||
:search-fediverse-with-query))
|
||||
:search-fediverse-with-query
|
||||
:open-resource-with-external-program))
|
||||
|
||||
(defpackage :scheduled-events
|
||||
(:use
|
||||
|
@ -3726,3 +3726,11 @@ gemini client certificates!)."
|
||||
(with-search-fediverse (query)
|
||||
(push-event (make-instance 'program-events:fediverse-local-query-event
|
||||
:payload query))))
|
||||
|
||||
|
||||
(defun open-resource-with-external-program (resource give-focus-to-message-window
|
||||
&key (open-for-edit nil))
|
||||
(with-notify-errors
|
||||
(os-utils:open-resource-with-external-program resource
|
||||
give-focus-to-message-window
|
||||
:open-for-edit open-for-edit)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user