Skip to content

Commit

Permalink
SSL と ACTIVE/INACTIVE の状態をモードラインアイコンに表示するようにした。
Browse files Browse the repository at this point in the history
* twittering-mode.el : SSL と ACTIVE/INACTIVE の状態をモードライン
アイコンに表示するようにした。-nw 時は文字列を表示する。
(twittering-update-mode-line): mode-line-buffer-identification の設
定を追加。INACTIVE と ssl の mode-name への設定を削除した。
(twittering-display-image-p): 新規マクロ
(twittering-init-active-inactive-icons): 新規関数
(twittering-mode-init-global):
twittering-init-active-inactive-icons を呼ぶように修正。

* icons/ssl.xpm: 上記に伴い Mew から拝借。

* offline.patch: 上記に伴い削除。元々私がブログに公開したものを
Hayamizu 氏が拾って下さったもの。
  • Loading branch information
masutaka authored and cvmat committed Apr 21, 2010
1 parent 15759bc commit 7021ed5
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 123 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
@@ -1,3 +1,19 @@
2010-04-19 Takashi Masuda <masutaka@nifty.com>

* twittering-mode.el : SSL と ACTIVE/INACTIVE の状態をモードライン
アイコンに表示するようにした。-nw 時は文字列を表示する。
(twittering-update-mode-line): mode-line-buffer-identification の設
定を追加。INACTIVE と ssl の mode-name への設定を削除した。
(twittering-display-image-p): 新規マクロ
(twittering-init-active-inactive-icons): 新規関数
(twittering-mode-init-global):
twittering-init-active-inactive-icons を呼ぶように修正。

* icons/ssl.xpm: 上記に伴い Mew から拝借。

* offline.patch: 上記に伴い削除。元々私がブログに公開したものを
Hayamizu 氏が拾って下さったもの。

2010-04-19 Tadashi MATSUO <tad@mymail.twin.jp>

* twittering-mode.el (twittering-get-buffer-from-spec): return nil
Expand Down
30 changes: 30 additions & 0 deletions icons/ssl.xpm
@@ -0,0 +1,30 @@
/* XPM */
/*
* Copyright (C) 2003 Yuuichi Teranishi <teranisi@gohome.org>
* Copyright (C) 2003 Kazu Yamamoto <kazu@Mew.org>
* Copyright (C) 2004 Yoshifumi Nishida <nishida@csl.sony.co.jp>
* Copyright notice is the same as Mew's one.
*/
static char * yellow3_xpm[] = {
"14 14 7 1",
" c None",
". c #B07403",
"+ c #EFEE38",
"@ c #603300",
"# c #D0A607",
"$ c #FAFC90",
"% c #241100",
" .++++@ ",
" .+@...+@ ",
" .+@ .+@ ",
" .+@ .+@ ",
" .+@ .+@ ",
"++########@@@@",
"+$$++++++++#@@",
"+$++++%@+++#@@",
"+$+++%%%@++#@@",
"+$+++%%%@++#@@",
"+$++++%@+++#@@",
"+$++++%@+++#@@",
"+$+++++++++#@@",
"++@@@@@@@@@@@@"};
119 changes: 0 additions & 119 deletions offline.patch

This file was deleted.

79 changes: 75 additions & 4 deletions twittering-mode.el
Expand Up @@ -485,14 +485,16 @@ and its contents (BUFFER)"

(defun twittering-update-mode-line ()
"Update mode line."
(setq mode-line-buffer-identification
`((twittering-use-ssl twittering-modeline-ssl "")
(twittering-active-mode twittering-modeline-active twittering-modeline-inactive)
,(default-value 'mode-line-buffer-identification)))
(let ((enabled-options
`(,@(unless (twittering-buffer-active-p) '("INACTIVE"))
,@(when twittering-jojo-mode '("jojo"))
`(,@(when twittering-jojo-mode '("jojo"))
,@(when twittering-icon-mode '("icon"))
,@(when twittering-reverse-mode '("reverse"))
,@(when twittering-scroll-mode '("scroll"))
,@(when twittering-proxy-use '("proxy"))
,@(when twittering-use-ssl '("ssl")))))
,@(when twittering-proxy-use '("proxy")))))
(setq mode-name
(concat twittering-mode-string
(if twittering-display-remaining
Expand Down Expand Up @@ -1592,6 +1594,74 @@ means the number of statuses retrieved after the last visiting of the buffer.")
(remove '(:eval (twittering-make-unread-status-notifier-string))
global-mode-string)))

;;;
;;; mode-line icon
;;;

;;; SSL
(defvar twittering-ssl-image nil)
(defvar twittering-ssl-indicator "[ssl]")
(defvar twittering-modeline-ssl twittering-ssl-indicator)
(put 'twittering-modeline-ssl 'risky-local-variable t)

;;; ACTIVE/INACTIVE
(defvar twittering-active-image nil)
(defvar twittering-inactive-image nil)
(defvar twittering-active-indicator "[ACTIVE] ")
(defvar twittering-inactive-indicator "[INACTIVE] ")
(defvar twittering-modeline-active twittering-active-indicator)
(defvar twittering-modeline-inactive twittering-inactive-indicator)
(put 'twittering-modeline-active 'risky-local-variable t)
(put 'twittering-modeline-inactive 'risky-local-variable t)

(defvar twittering-icon-directory
(expand-file-name
"icons"
(file-name-directory (locate-library "twittering-mode")))
"*Icon directory")

;; filename relative to twittering-icon-directory
(defvar twittering-ssl-icon "ssl.xpm"
"*Icon file for ssl state.")
(defvar twittering-active-icon "plugged.xpm"
"*Icon file for active state.")
(defvar twittering-inactive-icon "unplugged.xpm"
"*Icon file for inactive state.")

(defmacro twittering-display-image-p ()
'(and (display-images-p)
(image-type-available-p 'xpm)))

(defun twittering-init-active-inactive-icons ()
(when (twittering-display-image-p)
(let ((load-path (cons twittering-icon-directory load-path)))
(setq twittering-ssl-image (find-image
`((:type xpm
:file ,twittering-ssl-icon
:ascent center))))
(setq twittering-active-image (find-image
`((:type xpm
:file ,twittering-active-icon
:ascent center))))
(setq twittering-inactive-image (find-image
`((:type xpm
:file ,twittering-inactive-icon
:ascent center)))))
(setq twittering-modeline-ssl
(apply 'propertize twittering-ssl-indicator
`(display ,twittering-ssl-image)))
(let ((props
(when (display-mouse-p)
(list 'local-map (purecopy (make-mode-line-mouse-map
'mouse-2 #'twittering-toggle-activate-buffer))
'help-echo "mouse-2 toggles activate buffer"))))
(setq twittering-modeline-active
(apply 'propertize twittering-active-indicator
`(display ,twittering-active-image ,@props)))
(setq twittering-modeline-inactive
(apply 'propertize twittering-inactive-indicator
`(display ,twittering-inactive-image ,@props))))))

;;;
;;; Debug mode
;;;
Expand Down Expand Up @@ -1735,6 +1805,7 @@ means the number of statuses retrieved after the last visiting of the buffer.")
(if (null (search-forward-regexp "\\(Image\\|Graphics\\)Magick" nil t))
(setq twittering-use-convert nil)))))
(twittering-setup-proxy)
(twittering-init-active-inactive-icons)
)

(defvar twittering-mode-hook nil
Expand Down

0 comments on commit 7021ed5

Please sign in to comment.