Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: added support for gifs #327

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

Merged
merged 3 commits into from
Sep 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ To update the banner or banner title
;; 'official which displays the official emacs logo
;; 'logo which displays an alternative emacs logo
;; 1, 2 or 3 which displays one of the text banners
;; "path/to/your/image.png" or "path/to/your/text.txt" which displays whatever image/text you would prefer
;; "path/to/your/image.gif", "path/to/your/image.png" or "path/to/your/text.txt" which displays whatever gif/image/text you would prefer

;; Content is not centered by default. To center, set
(setq dashboard-center-content t)
Expand Down Expand Up @@ -282,3 +282,4 @@ make install
** Prerequisites

* [[https://github.com/cask/cask][Cask]]

22 changes: 16 additions & 6 deletions dashboard-widgets.el
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,12 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer."
(put-text-property 0 (length ascii-banner) 'face 'dashboard-text-banner ascii-banner)
(insert ascii-banner)))

(defun dashboard--type-is-gif-p (image-path)
"Return if image is a gif.
String -> bool.
Argument IMAGE-PATH path to the image."
(eq 'gif (image-type image-path)))

(defun dashboard-insert-image-banner (banner)
"Display an image BANNER."
(when (file-exists-p banner)
Expand All @@ -494,12 +500,15 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer."
(when (> dashboard-image-banner-max-height 0)
(list :max-height dashboard-image-banner-max-height))))
(spec
(if (image-type-available-p 'imagemagick)
(apply 'create-image banner 'imagemagick nil size-props)
(apply 'create-image banner nil nil
(when (and (fboundp 'image-transforms-p)
(memq 'scale (funcall 'image-transforms-p)))
size-props))))
(cond ((dashboard--type-is-gif-p banner)
(create-image banner))
((image-type-available-p 'imagemagick)
(apply 'create-image banner 'imagemagick nil size-props))
(t
(apply 'create-image banner nil nil
(when (and (fboundp 'image-transforms-p)
(memq 'scale (funcall 'image-transforms-p)))
size-props)))))
;; TODO: For some reason, `elisp-lint' is reporting error void
;; function `image-size'.
(size (when (fboundp 'image-size) (image-size spec)))
Expand All @@ -509,6 +518,7 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer."
(insert "\n")
(insert (make-string left-margin ?\ ))
(insert-image spec)
(when (dashboard--type-is-gif-p banner) (image-animate spec 0 t))
(insert "\n\n")
(when title
(dashboard-center-line title)
Expand Down