[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r102689: Implement tool-bar separator
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r102689: Implement tool-bar separators for non-GTK tool-bars. |
Date: |
Mon, 20 Dec 2010 08:17:26 +0800 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 102689
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Mon 2010-12-20 08:17:26 +0800
message:
Implement tool-bar separators for non-GTK tool-bars.
* lisp/tool-bar.el (tool-bar--image-expression): New function.
(tool-bar-local-item, tool-bar--image-exp): Use it.
(tool-bar-setup): Initialize tool-bar-separator-image-expression.
Use :enable instead of :visible to avoid changing the tool-bar
configuration unnecessarily.
* src/keyboard.c (Vtool_bar_separator_image_expression): New variable.
(parse_tool_bar_item): Use it to obtain image separators for
displays not using native tool-bar separators.
* src/xdisp.c (build_desired_tool_bar_string): Don't handle separators
specially, since this is now done in parse_tool_bar_item.
* lisp/info.el (info-tool-bar-map): Add separators.
modified:
etc/ChangeLog
etc/NEWS
etc/images/separator.xpm
lisp/ChangeLog
lisp/info.el
lisp/tool-bar.el
src/ChangeLog
src/keyboard.c
src/xdisp.c
=== modified file 'etc/ChangeLog'
--- a/etc/ChangeLog 2010-12-14 20:42:57 +0000
+++ b/etc/ChangeLog 2010-12-20 00:17:26 +0000
@@ -1,3 +1,7 @@
+2010-12-18 Chong Yidong <address@hidden>
+
+ * images/separator.xpm: Tweak colors.
+
2010-12-14 Michael Albinus <address@hidden>
* NEWS: Mention new Tramp method "ksu".
=== modified file 'etc/NEWS'
--- a/etc/NEWS 2010-12-17 04:04:06 +0000
+++ b/etc/NEWS 2010-12-20 00:17:26 +0000
@@ -692,9 +692,7 @@
** Tool-bars can display separators.
Tool-bar separators are handled like menu separators in menu-bar maps,
-i.e. with entries of the form `(menu-item "--")'.
-
-Currently, tool-bar separators are only displayed on GTK.
+i.e. via menu entries of the form `(menu-item "--")'.
** Image API
=== modified file 'etc/images/separator.xpm'
--- a/etc/images/separator.xpm 2006-03-28 19:15:30 +0000
+++ b/etc/images/separator.xpm 2010-12-20 00:17:26 +0000
@@ -2,29 +2,29 @@
static char * separator_xpm[] = {
"2 24 3 1",
" c None",
-". c #DBD3CB",
-"+ c #FCFBFA",
-" ",
-" ",
-" ",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-".+",
-" ",
+". c #888888",
+"+ c #FFFFFF",
+" ",
+" ",
+".+ ",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
+".+",
" ",
" "};
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2010-12-18 20:39:05 +0000
+++ b/lisp/ChangeLog 2010-12-20 00:17:26 +0000
@@ -1,3 +1,17 @@
+2010-12-20 Chong Yidong <address@hidden>
+
+ * vc/diff.el (diff-better-file-name): Function deleted;
+ abbreviating file name creates problems with shell-quote-argument.
+ (diff-no-select): Just use expand-file-name.
+
+ * tool-bar.el (tool-bar--image-expression): New function.
+ (tool-bar-local-item, tool-bar--image-exp): Use it.
+ (tool-bar-setup): Initialize tool-bar-separator-image-expression.
+ Use :enable instead of :visible to avoid changing the tool-bar
+ configuration unnecessarily.
+
+ * info.el (info-tool-bar-map): Add separators.
+
2010-12-17 Ken Brown <address@hidden>
* loadup.el: Use version numbers in Cygwin build.
=== modified file 'lisp/info.el'
--- a/lisp/info.el 2010-11-20 14:51:25 +0000
+++ b/lisp/info.el 2010-12-20 00:17:26 +0000
@@ -3769,14 +3769,17 @@
:rtl "left-arrow"
:label "Forward"
:vert-only t)
+ (define-key-after map [separator-1] menu-bar-separator)
(tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map
:rtl "next-node")
(tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map
:rtl "prev-node")
(tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map
:vert-only t)
+ (define-key-after map [separator-2] menu-bar-separator)
(tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
(tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map)
+ (define-key-after map [separator-3] menu-bar-separator)
(tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map
:label "Index Search")
(tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
=== modified file 'lisp/tool-bar.el'
--- a/lisp/tool-bar.el 2010-12-17 04:04:06 +0000
+++ b/lisp/tool-bar.el 2010-12-20 00:17:26 +0000
@@ -139,6 +139,26 @@
To define items in any other map, use `tool-bar-local-item'."
(apply 'tool-bar-local-item icon def key tool-bar-map props))
+(defun tool-bar--image-expression (icon)
+ "Return an expression that evaluates to an image spec for ICON."
+ (let* ((fg (face-attribute 'tool-bar :foreground))
+ (bg (face-attribute 'tool-bar :background))
+ (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
+ (if (eq bg 'unspecified) nil (list :background bg))))
+ (xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
+ (xpm-lo-spec (list :type 'xpm :file
+ (concat "low-color/" icon ".xpm")))
+ (pbm-spec (append (list :type 'pbm :file
+ (concat icon ".pbm")) colors))
+ (xbm-spec (append (list :type 'xbm :file
+ (concat icon ".xbm")) colors)))
+ `(find-image (cond ((not (display-color-p))
+ ',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
+ ((< (display-color-cells) 256)
+ ',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec))
+ (t
+ ',(list xpm-spec pbm-spec xbm-spec))))))
+
;;;###autoload
(defun tool-bar-local-item (icon def key map &rest props)
"Add an item to the tool bar in map MAP.
@@ -151,24 +171,7 @@
function will first try to use low-color/ICON.xpm if `display-color-cells'
is less or equal to 256, then ICON.xpm, then ICON.pbm, and finally
ICON.xbm, using `find-image'."
- (let* ((fg (face-attribute 'tool-bar :foreground))
- (bg (face-attribute 'tool-bar :background))
- (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
- (if (eq bg 'unspecified) nil (list :background bg))))
- (xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
- (xpm-lo-spec (list :type 'xpm :file
- (concat "low-color/" icon ".xpm")))
- (pbm-spec (append (list :type 'pbm :file
- (concat icon ".pbm")) colors))
- (xbm-spec (append (list :type 'xbm :file
- (concat icon ".xbm")) colors))
- (image-exp `(find-image
- (cond ((not (display-color-p))
- ',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
- ((< (display-color-cells) 256)
- ',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec))
- (t
- ',(list xpm-spec pbm-spec xbm-spec))))))
+ (let* ((image-exp (tool-bar--image-expression icon)))
(define-key-after map (vector key)
`(menu-item ,(symbol-name key) ,def :image ,image-exp ,@props))))
@@ -203,24 +206,7 @@
(setq from-map global-map))
(let* ((menu-bar-map (lookup-key from-map [menu-bar]))
(keys (where-is-internal command menu-bar-map))
- (fg (face-attribute 'tool-bar :foreground))
- (bg (face-attribute 'tool-bar :background))
- (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
- (if (eq bg 'unspecified) nil (list :background bg))))
- (xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
- (xpm-lo-spec (list :type 'xpm :file
- (concat "low-color/" icon ".xpm")))
- (pbm-spec (append (list :type 'pbm :file
- (concat icon ".pbm")) colors))
- (xbm-spec (append (list :type 'xbm :file
- (concat icon ".xbm")) colors))
- (image-exp `(find-image
- (cond ((not (display-color-p))
- ',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
- ((< (display-color-cells) 256)
- ',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec))
- (t
- ',(list xpm-spec pbm-spec xbm-spec)))))
+ (image-exp (tool-bar--image-expression icon))
submap key)
;; We'll pick up the last valid entry in the list of keys if
;; there's more than one.
@@ -257,32 +243,34 @@
;;; Set up some global items. Additions/deletions up for grabs.
(defun tool-bar-setup ()
+ (setq tool-bar-separator-image-expression
+ (tool-bar--image-expression "separator"))
(tool-bar-add-item-from-menu 'find-file "new" nil :label "New File"
:vert-only t)
(tool-bar-add-item-from-menu 'menu-find-file-existing "open" nil
:label "Open" :vert-only t)
(tool-bar-add-item-from-menu 'dired "diropen" nil :vert-only t)
(tool-bar-add-item-from-menu 'kill-this-buffer "close" nil :vert-only t)
- (tool-bar-add-item-from-menu 'save-buffer "save" nil :vert-only t
+ (tool-bar-add-item-from-menu 'save-buffer "save" nil
:label "Save"
- :visible '(or buffer-file-name
+ :enable '(or buffer-file-name
(not (eq 'special
(get major-mode
'mode-class)))))
(define-key-after (default-value 'tool-bar-map) [separator-1]
menu-bar-separator)
(tool-bar-add-item-from-menu 'undo "undo" nil :vert-only t
- :visible '(not (eq 'special (get major-mode
+ :enable '(not (eq 'special (get major-mode
'mode-class))))
(define-key-after (default-value 'tool-bar-map) [separator-2]
menu-bar-separator)
(tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut])
"cut" nil :vert-only t
- :visible '(not (eq 'special (get major-mode
+ :enable '(not (eq 'special (get major-mode
'mode-class))))
(tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy])
"copy" nil :vert-only t)
(tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste])
"paste" nil :vert-only t
- :visible '(not (eq 'special (get major-mode
+ :enable '(not (eq 'special (get major-mode
'mode-class))))
(define-key-after (default-value 'tool-bar-map) [separator-3]
menu-bar-separator)
(tool-bar-add-item-from-menu 'nonincremental-search-forward "search"
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2010-12-19 05:43:42 +0000
+++ b/src/ChangeLog 2010-12-20 00:17:26 +0000
@@ -1,3 +1,12 @@
+2010-12-20 Chong Yidong <address@hidden>
+
+ * keyboard.c (Vtool_bar_separator_image_expression): New variable.
+ (parse_tool_bar_item): Use it to obtain image separators for
+ displays not using native tool-bar separators.
+
+ * xdisp.c (build_desired_tool_bar_string): Don't handle separators
+ specially, since this is now done in parse_tool_bar_item.
+
2010-12-19 Stefan Monnier <address@hidden>
Minor clean up to silence some gcc warnings.
=== modified file 'src/keyboard.c'
--- a/src/keyboard.c 2010-12-17 04:04:06 +0000
+++ b/src/keyboard.c 2010-12-20 00:17:26 +0000
@@ -212,6 +212,12 @@
/* List of items that should move to the end of the menu bar. */
Lisp_Object Vmenu_bar_final_items;
+/* Expression to evaluate for the tool bar separator image.
+ This is used for build_desired_tool_bar_string only. For GTK, we
+ use GTK tool bar seperators. */
+
+Lisp_Object Vtool_bar_separator_image_expression;
+
/* Non-nil means show the equivalent key-binding for
any M-x command that has one.
The value can be a length of time to show the message for.
@@ -8294,6 +8300,15 @@
if (menu_separator_name_p (SDATA (caption)))
{
PROP (TOOL_BAR_ITEM_TYPE) = Qt;
+#if !defined (USE_GTK) && !defined (HAVE_NS)
+ /* If we use build_desired_tool_bar_string to render the
+ tool bar, the separator is rendered as an image. */
+ PROP (TOOL_BAR_ITEM_IMAGES)
+ = menu_item_eval_property (Vtool_bar_separator_image_expression);
+ PROP (TOOL_BAR_ITEM_ENABLED_P) = Qnil;
+ PROP (TOOL_BAR_ITEM_SELECTED_P) = Qnil;
+ PROP (TOOL_BAR_ITEM_CAPTION) = Qnil;
+#endif
return 1;
}
return 0;
@@ -12151,6 +12166,12 @@
The elements of the list are event types that may have menu bar bindings. */);
Vmenu_bar_final_items = Qnil;
+ DEFVAR_LISP ("tool-bar-separator-image-expression",
&Vtool_bar_separator_image_expression,
+ doc: /* Expression evaluating to the image spec for a tool-bar separator.
+This is used internally by graphical displays that do not render
+tool-bar separators natively. Otherwise it is unused (e.g. on GTK). */);
+ Vtool_bar_separator_image_expression = Qnil;
+
DEFVAR_KBOARD ("overriding-terminal-local-map",
Voverriding_terminal_local_map,
doc: /* Per-terminal keymap that overrides all other local
keymaps.
=== modified file 'src/xdisp.c'
--- a/src/xdisp.c 2010-12-17 04:04:06 +0000
+++ b/src/xdisp.c 2010-12-20 00:17:26 +0000
@@ -10317,10 +10317,6 @@
int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
int hmargin, vmargin, relief, idx, end;
- /* Ignore separator items. */
- if (EQ (PROP (TOOL_BAR_ITEM_TYPE), Qt))
- continue;
-
/* If image is a vector, choose the image according to the
button state. */
image = PROP (TOOL_BAR_ITEM_IMAGES);
@@ -10495,7 +10491,7 @@
row->used[TEXT_AREA] = n_glyphs_before;
*it = it_before;
/* If this is the only glyph on this line, it will never fit on
the
- toolbar, so skip it. But ensure there is at least one glyph,
+ tool-bar, so skip it. But ensure there is at least one glyph,
so we don't accidentally disable the tool-bar. */
if (n_glyphs_before == 0
&& (it->vpos > 0 || IT_STRING_CHARPOS (*it) <
it->end_charpos-1))
@@ -26885,7 +26881,7 @@
tool_bar_button_relief = DEFAULT_TOOL_BAR_BUTTON_RELIEF;
DEFVAR_LISP ("tool-bar-style", &Vtool_bar_style,
- doc: /* *Tool bar style to use.
+ doc: /* Tool bar style to use.
It can be one of
image - show images only
text - show text only
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r102689: Implement tool-bar separators for non-GTK tool-bars.,
Chong Yidong <=