add idea of a custom tool-bar

This commit is contained in:
2025-06-25 16:21:35 +02:00
parent 6d4336a051
commit 65bd50b345
3 changed files with 129 additions and 1 deletions

117
lisp/my/my-tool-bar.el Normal file
View File

@@ -0,0 +1,117 @@
;;; my-tool-bar.el --- Tool bar -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(defun my-tool-bar-newline ()
"Newline."
"\n")
(defun my-tool-bar-function-save (event)
"Pop up the same menu as displayed by the menu bar.
Used by `tab-bar-format-menu-bar'."
(interactive "e")
(let ()
;;(message "%s" event)
(save-buffer)
;;(message "foo")
))
(defvar my-tool-bar-button-save "Save "
"Button for going back in tab history.")
(defun my-tool-bar-function-open (event)
"Pop up the same menu as displayed by the menu bar.
Used by `tab-bar-format-menu-bar'."
(interactive "e")
(let ()
;;(message "%s" event)
(if (featurep 'counsel)
(counsel-find-file)
(find-file))
;;(message "foo")
))
(defvar my-tool-bar-button-open "Open "
"Button for going back in tab history.")
;; (defun my-tool-bar-format-save ()
;; "Produce the Menu button for the tool bar that shows the menu bar."
;; `((menu-bar menu-item ,my-tool-bar-button-save
;; my-tool-bar-function-save :help "Save buffer")))
(defun my-tool-bar-format ()
"Produce tool-bar buttons for the tab bar.
These buttons will be shown when `my-tool-bar-mode' is enabled.
You can hide these buttons by customizing `tab-bar-format' and removing
`my-tool-bar-format' from it."
(when my-tool-bar-mode
`(;;(sep-history-back menu-item ,(tab-bar-separator) ignore)
(save
menu-item ,my-tool-bar-button-save my-tool-bar-function-save
:help "Save")
;;(sep-test menu-item "" ignore)
(open
menu-item ,my-tool-bar-button-open my-tool-bar-function-open
:help "Open File...")
(sep-tool-bar menu-item ,(my-tool-bar-newline) ignore)
)))
(defun my-tool-bar--load-buttons ()
"Load the icons for the tool bar buttons."
;; (emoji "<empji>") see e.g. https://emojipedia.org/hamburger
;; (symbol "<unicode>") see e.g. https://www.compart.com/en/unicode/U+2630
(require 'icons)
(unless (iconp 'my-tool-bar-icon-save)
(define-icon my-tool-bar-icon-save nil
`((image "save.xpm"
:height (1.5 . em)
:margin ,tab-bar-button-margin
:ascent center)
(emoji "💾")
(symbol "🖫")
(text "Save"
;; :face tab-bar-tab-inactive
))
"Icon for the menu bar."
:version "29.1"))
(setq my-tool-bar-button-save (icon-string 'my-tool-bar-icon-save))
(unless (iconp 'my-tool-bar-icon-open)
(define-icon my-tool-bar-icon-open nil
`((image "open.xpm"
:height (1.5 . em)
:margin ,tab-bar-button-margin
:ascent center)
(emoji "📂")
(symbol "🗁")
(text "Open"
;; :face tab-bar-tab-inactive
))
"Icon for the menu bar."
:version "29.1"))
(setq my-tool-bar-button-open (icon-string 'my-tool-bar-icon-open))
)
(define-minor-mode my-tool-bar-mode
"Toggle tab history mode for the tab bar.
Tab history mode remembers window configurations used in every tab,
and can restore them."
:global t :group 'tab-bar
(if my-tool-bar-mode
(progn
(my-tool-bar--load-buttons)
;;(add-hook 'pre-command-hook #'tab-bar--history-pre-change)
;;(add-hook 'window-configuration-change-hook #'tab-bar--history-change)
)
;;(remove-hook 'pre-command-hook #'tab-bar--history-pre-change)
;;(remove-hook 'window-configuration-change-hook #'tab-bar--history-change)
)
)
(provide 'my-tool-bar)
;;; my-tool-bar.el ends here

View File

@@ -846,5 +846,10 @@ Version 2016-07-13"
)
)
(use-package calendar
:defer t
:config
(setq calendar-week-start-day 1))
(provide 'general-settings)
;;; general-settings.el ends here

View File

@@ -113,7 +113,12 @@ DISPLAY-START: `integer', e.g. 3820"
("s-t" . tab-bar-new-tab)
("s-w" . tab-bar-close-tab))))
:config
(add-to-list 'tab-bar-format #'tab-bar-format-menu-bar)
(require 'my-tool-bar)
(add-to-list 'tab-bar-format #'my-tool-bar-format)
(tab-bar-rename-tab "Default")
(defun my-tab-view-elisp ()
(if (tab-bar--tab-index-by-name "ELisp IDE")
@@ -347,7 +352,8 @@ DISPLAY-START: `integer', e.g. 3820"
))
(use-package dashboard
:defer 0.1
:defer nil
;; :defer 0.1
:delight (dashboard-mode "Db") ;; "\u01F153
:after (all-the-icons)
:commands (dashboard-mode)