aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2010-12-20 08:17:26 +0800
committerChong Yidong2010-12-20 08:17:26 +0800
commit949752705efd6a4b7478623d41b3552f93e9596c (patch)
tree3f41f09628f8c7ac17c1c771c69cdb2916cc5fb8
parentef1b0ba7e5a82308514b8427cd84994805e61a4f (diff)
downloademacs-949752705efd6a4b7478623d41b3552f93e9596c.tar.gz
emacs-949752705efd6a4b7478623d41b3552f93e9596c.zip
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.
-rw-r--r--etc/ChangeLog4
-rw-r--r--etc/NEWS4
-rw-r--r--etc/images/separator.xpm8
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/info.el3
-rw-r--r--lisp/tool-bar.el70
-rw-r--r--src/ChangeLog9
-rw-r--r--src/keyboard.c21
-rw-r--r--src/xdisp.c8
9 files changed, 87 insertions, 54 deletions
diff --git a/etc/ChangeLog b/etc/ChangeLog
index 87236dc4eb2..ebd613ddfe8 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
12010-12-18 Chong Yidong <cyd@stupidchicken.com>
2
3 * images/separator.xpm: Tweak colors.
4
12010-12-14 Michael Albinus <michael.albinus@gmx.de> 52010-12-14 Michael Albinus <michael.albinus@gmx.de>
2 6
3 * NEWS: Mention new Tramp method "ksu". 7 * NEWS: Mention new Tramp method "ksu".
diff --git a/etc/NEWS b/etc/NEWS
index 1ec8325c2a3..89d6139dc0e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -692,9 +692,7 @@ input.
692 692
693** Tool-bars can display separators. 693** Tool-bars can display separators.
694Tool-bar separators are handled like menu separators in menu-bar maps, 694Tool-bar separators are handled like menu separators in menu-bar maps,
695i.e. with entries of the form `(menu-item "--")'. 695i.e. via menu entries of the form `(menu-item "--")'.
696
697Currently, tool-bar separators are only displayed on GTK.
698 696
699** Image API 697** Image API
700 698
diff --git a/etc/images/separator.xpm b/etc/images/separator.xpm
index 0c518fa7599..b728316a8f8 100644
--- a/etc/images/separator.xpm
+++ b/etc/images/separator.xpm
@@ -2,11 +2,12 @@
2static char * separator_xpm[] = { 2static char * separator_xpm[] = {
3"2 24 3 1", 3"2 24 3 1",
4" c None", 4" c None",
5". c #DBD3CB", 5". c #888888",
6"+ c #FCFBFA", 6"+ c #FFFFFF",
7" ",
8" ", 7" ",
9" ", 8" ",
9".+ ",
10".+",
10".+", 11".+",
11".+", 12".+",
12".+", 13".+",
@@ -25,6 +26,5 @@ static char * separator_xpm[] = {
25".+", 26".+",
26".+", 27".+",
27".+", 28".+",
28" ",
29" ", 29" ",
30" "}; 30" "};
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4ed1a75cda2..0c363ab7a03 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
12010-12-20 Chong Yidong <cyd@stupidchicken.com>
2
3 * vc/diff.el (diff-better-file-name): Function deleted;
4 abbreviating file name creates problems with shell-quote-argument.
5 (diff-no-select): Just use expand-file-name.
6
7 * tool-bar.el (tool-bar--image-expression): New function.
8 (tool-bar-local-item, tool-bar--image-exp): Use it.
9 (tool-bar-setup): Initialize tool-bar-separator-image-expression.
10 Use :enable instead of :visible to avoid changing the tool-bar
11 configuration unnecessarily.
12
13 * info.el (info-tool-bar-map): Add separators.
14
12010-12-17 Ken Brown <kbrown@cornell.edu> 152010-12-17 Ken Brown <kbrown@cornell.edu>
2 16
3 * loadup.el: Use version numbers in Cygwin build. 17 * loadup.el: Use version numbers in Cygwin build.
diff --git a/lisp/info.el b/lisp/info.el
index 7c0333f6b8e..ad92914a54d 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -3769,14 +3769,17 @@ If FORK is non-nil, it is passed to `Info-goto-node'."
3769 :rtl "left-arrow" 3769 :rtl "left-arrow"
3770 :label "Forward" 3770 :label "Forward"
3771 :vert-only t) 3771 :vert-only t)
3772 (define-key-after map [separator-1] menu-bar-separator)
3772 (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map 3773 (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map
3773 :rtl "next-node") 3774 :rtl "next-node")
3774 (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map 3775 (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map
3775 :rtl "prev-node") 3776 :rtl "prev-node")
3776 (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map 3777 (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map
3777 :vert-only t) 3778 :vert-only t)
3779 (define-key-after map [separator-2] menu-bar-separator)
3778 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map) 3780 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
3779 (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map) 3781 (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map)
3782 (define-key-after map [separator-3] menu-bar-separator)
3780 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map 3783 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map
3781 :label "Index Search") 3784 :label "Index Search")
3782 (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map) 3785 (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
diff --git a/lisp/tool-bar.el b/lisp/tool-bar.el
index 7c7216ed7d3..e819cbe99a8 100644
--- a/lisp/tool-bar.el
+++ b/lisp/tool-bar.el
@@ -139,6 +139,26 @@ Use this function only to make bindings in the global value of `tool-bar-map'.
139To define items in any other map, use `tool-bar-local-item'." 139To define items in any other map, use `tool-bar-local-item'."
140 (apply 'tool-bar-local-item icon def key tool-bar-map props)) 140 (apply 'tool-bar-local-item icon def key tool-bar-map props))
141 141
142(defun tool-bar--image-expression (icon)
143 "Return an expression that evaluates to an image spec for ICON."
144 (let* ((fg (face-attribute 'tool-bar :foreground))
145 (bg (face-attribute 'tool-bar :background))
146 (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
147 (if (eq bg 'unspecified) nil (list :background bg))))
148 (xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
149 (xpm-lo-spec (list :type 'xpm :file
150 (concat "low-color/" icon ".xpm")))
151 (pbm-spec (append (list :type 'pbm :file
152 (concat icon ".pbm")) colors))
153 (xbm-spec (append (list :type 'xbm :file
154 (concat icon ".xbm")) colors)))
155 `(find-image (cond ((not (display-color-p))
156 ',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
157 ((< (display-color-cells) 256)
158 ',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec))
159 (t
160 ',(list xpm-spec pbm-spec xbm-spec))))))
161
142;;;###autoload 162;;;###autoload
143(defun tool-bar-local-item (icon def key map &rest props) 163(defun tool-bar-local-item (icon def key map &rest props)
144 "Add an item to the tool bar in map MAP. 164 "Add an item to the tool bar in map MAP.
@@ -151,24 +171,7 @@ ICON is the base name of a file containing the image to use. The
151function will first try to use low-color/ICON.xpm if `display-color-cells' 171function will first try to use low-color/ICON.xpm if `display-color-cells'
152is less or equal to 256, then ICON.xpm, then ICON.pbm, and finally 172is less or equal to 256, then ICON.xpm, then ICON.pbm, and finally
153ICON.xbm, using `find-image'." 173ICON.xbm, using `find-image'."
154 (let* ((fg (face-attribute 'tool-bar :foreground)) 174 (let* ((image-exp (tool-bar--image-expression icon)))
155 (bg (face-attribute 'tool-bar :background))
156 (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
157 (if (eq bg 'unspecified) nil (list :background bg))))
158 (xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
159 (xpm-lo-spec (list :type 'xpm :file
160 (concat "low-color/" icon ".xpm")))
161 (pbm-spec (append (list :type 'pbm :file
162 (concat icon ".pbm")) colors))
163 (xbm-spec (append (list :type 'xbm :file
164 (concat icon ".xbm")) colors))
165 (image-exp `(find-image
166 (cond ((not (display-color-p))
167 ',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
168 ((< (display-color-cells) 256)
169 ',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec))
170 (t
171 ',(list xpm-spec pbm-spec xbm-spec))))))
172 (define-key-after map (vector key) 175 (define-key-after map (vector key)
173 `(menu-item ,(symbol-name key) ,def :image ,image-exp ,@props)))) 176 `(menu-item ,(symbol-name key) ,def :image ,image-exp ,@props))))
174 177
@@ -203,24 +206,7 @@ holds a keymap."
203 (setq from-map global-map)) 206 (setq from-map global-map))
204 (let* ((menu-bar-map (lookup-key from-map [menu-bar])) 207 (let* ((menu-bar-map (lookup-key from-map [menu-bar]))
205 (keys (where-is-internal command menu-bar-map)) 208 (keys (where-is-internal command menu-bar-map))
206 (fg (face-attribute 'tool-bar :foreground)) 209 (image-exp (tool-bar--image-expression icon))
207 (bg (face-attribute 'tool-bar :background))
208 (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
209 (if (eq bg 'unspecified) nil (list :background bg))))
210 (xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
211 (xpm-lo-spec (list :type 'xpm :file
212 (concat "low-color/" icon ".xpm")))
213 (pbm-spec (append (list :type 'pbm :file
214 (concat icon ".pbm")) colors))
215 (xbm-spec (append (list :type 'xbm :file
216 (concat icon ".xbm")) colors))
217 (image-exp `(find-image
218 (cond ((not (display-color-p))
219 ',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
220 ((< (display-color-cells) 256)
221 ',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec))
222 (t
223 ',(list xpm-spec pbm-spec xbm-spec)))))
224 submap key) 210 submap key)
225 ;; We'll pick up the last valid entry in the list of keys if 211 ;; We'll pick up the last valid entry in the list of keys if
226 ;; there's more than one. 212 ;; there's more than one.
@@ -257,32 +243,34 @@ holds a keymap."
257;;; Set up some global items. Additions/deletions up for grabs. 243;;; Set up some global items. Additions/deletions up for grabs.
258 244
259(defun tool-bar-setup () 245(defun tool-bar-setup ()
246 (setq tool-bar-separator-image-expression
247 (tool-bar--image-expression "separator"))
260 (tool-bar-add-item-from-menu 'find-file "new" nil :label "New File" 248 (tool-bar-add-item-from-menu 'find-file "new" nil :label "New File"
261 :vert-only t) 249 :vert-only t)
262 (tool-bar-add-item-from-menu 'menu-find-file-existing "open" nil 250 (tool-bar-add-item-from-menu 'menu-find-file-existing "open" nil
263 :label "Open" :vert-only t) 251 :label "Open" :vert-only t)
264 (tool-bar-add-item-from-menu 'dired "diropen" nil :vert-only t) 252 (tool-bar-add-item-from-menu 'dired "diropen" nil :vert-only t)
265 (tool-bar-add-item-from-menu 'kill-this-buffer "close" nil :vert-only t) 253 (tool-bar-add-item-from-menu 'kill-this-buffer "close" nil :vert-only t)
266 (tool-bar-add-item-from-menu 'save-buffer "save" nil :vert-only t 254 (tool-bar-add-item-from-menu 'save-buffer "save" nil
267 :label "Save" 255 :label "Save"
268 :visible '(or buffer-file-name 256 :enable '(or buffer-file-name
269 (not (eq 'special 257 (not (eq 'special
270 (get major-mode 258 (get major-mode
271 'mode-class))))) 259 'mode-class)))))
272 (define-key-after (default-value 'tool-bar-map) [separator-1] menu-bar-separator) 260 (define-key-after (default-value 'tool-bar-map) [separator-1] menu-bar-separator)
273 (tool-bar-add-item-from-menu 'undo "undo" nil :vert-only t 261 (tool-bar-add-item-from-menu 'undo "undo" nil :vert-only t
274 :visible '(not (eq 'special (get major-mode 262 :enable '(not (eq 'special (get major-mode
275 'mode-class)))) 263 'mode-class))))
276 (define-key-after (default-value 'tool-bar-map) [separator-2] menu-bar-separator) 264 (define-key-after (default-value 'tool-bar-map) [separator-2] menu-bar-separator)
277 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut]) 265 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut])
278 "cut" nil :vert-only t 266 "cut" nil :vert-only t
279 :visible '(not (eq 'special (get major-mode 267 :enable '(not (eq 'special (get major-mode
280 'mode-class)))) 268 'mode-class))))
281 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy]) 269 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy])
282 "copy" nil :vert-only t) 270 "copy" nil :vert-only t)
283 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste]) 271 (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste])
284 "paste" nil :vert-only t 272 "paste" nil :vert-only t
285 :visible '(not (eq 'special (get major-mode 273 :enable '(not (eq 'special (get major-mode
286 'mode-class)))) 274 'mode-class))))
287 (define-key-after (default-value 'tool-bar-map) [separator-3] menu-bar-separator) 275 (define-key-after (default-value 'tool-bar-map) [separator-3] menu-bar-separator)
288 (tool-bar-add-item-from-menu 'nonincremental-search-forward "search" 276 (tool-bar-add-item-from-menu 'nonincremental-search-forward "search"
diff --git a/src/ChangeLog b/src/ChangeLog
index 4313c68f593..a6ee107422c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12010-12-20 Chong Yidong <cyd@stupidchicken.com>
2
3 * keyboard.c (Vtool_bar_separator_image_expression): New variable.
4 (parse_tool_bar_item): Use it to obtain image separators for
5 displays not using native tool-bar separators.
6
7 * xdisp.c (build_desired_tool_bar_string): Don't handle separators
8 specially, since this is now done in parse_tool_bar_item.
9
12010-12-19 Stefan Monnier <monnier@iro.umontreal.ca> 102010-12-19 Stefan Monnier <monnier@iro.umontreal.ca>
2 11
3 Minor clean up to silence some gcc warnings. 12 Minor clean up to silence some gcc warnings.
diff --git a/src/keyboard.c b/src/keyboard.c
index 959c57a81e3..27c311d72e2 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -212,6 +212,12 @@ Lisp_Object Vprefix_help_command;
212/* List of items that should move to the end of the menu bar. */ 212/* List of items that should move to the end of the menu bar. */
213Lisp_Object Vmenu_bar_final_items; 213Lisp_Object Vmenu_bar_final_items;
214 214
215/* Expression to evaluate for the tool bar separator image.
216 This is used for build_desired_tool_bar_string only. For GTK, we
217 use GTK tool bar seperators. */
218
219Lisp_Object Vtool_bar_separator_image_expression;
220
215/* Non-nil means show the equivalent key-binding for 221/* Non-nil means show the equivalent key-binding for
216 any M-x command that has one. 222 any M-x command that has one.
217 The value can be a length of time to show the message for. 223 The value can be a length of time to show the message for.
@@ -8294,6 +8300,15 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
8294 if (menu_separator_name_p (SDATA (caption))) 8300 if (menu_separator_name_p (SDATA (caption)))
8295 { 8301 {
8296 PROP (TOOL_BAR_ITEM_TYPE) = Qt; 8302 PROP (TOOL_BAR_ITEM_TYPE) = Qt;
8303#if !defined (USE_GTK) && !defined (HAVE_NS)
8304 /* If we use build_desired_tool_bar_string to render the
8305 tool bar, the separator is rendered as an image. */
8306 PROP (TOOL_BAR_ITEM_IMAGES)
8307 = menu_item_eval_property (Vtool_bar_separator_image_expression);
8308 PROP (TOOL_BAR_ITEM_ENABLED_P) = Qnil;
8309 PROP (TOOL_BAR_ITEM_SELECTED_P) = Qnil;
8310 PROP (TOOL_BAR_ITEM_CAPTION) = Qnil;
8311#endif
8297 return 1; 8312 return 1;
8298 } 8313 }
8299 return 0; 8314 return 0;
@@ -12151,6 +12166,12 @@ might happen repeatedly and make Emacs nonfunctional. */);
12151The elements of the list are event types that may have menu bar bindings. */); 12166The elements of the list are event types that may have menu bar bindings. */);
12152 Vmenu_bar_final_items = Qnil; 12167 Vmenu_bar_final_items = Qnil;
12153 12168
12169 DEFVAR_LISP ("tool-bar-separator-image-expression", &Vtool_bar_separator_image_expression,
12170 doc: /* Expression evaluating to the image spec for a tool-bar separator.
12171This is used internally by graphical displays that do not render
12172tool-bar separators natively. Otherwise it is unused (e.g. on GTK). */);
12173 Vtool_bar_separator_image_expression = Qnil;
12174
12154 DEFVAR_KBOARD ("overriding-terminal-local-map", 12175 DEFVAR_KBOARD ("overriding-terminal-local-map",
12155 Voverriding_terminal_local_map, 12176 Voverriding_terminal_local_map,
12156 doc: /* Per-terminal keymap that overrides all other local keymaps. 12177 doc: /* Per-terminal keymap that overrides all other local keymaps.
diff --git a/src/xdisp.c b/src/xdisp.c
index 41204e0a5b4..7a299055185 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10317,10 +10317,6 @@ build_desired_tool_bar_string (struct frame *f)
10317 int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); 10317 int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
10318 int hmargin, vmargin, relief, idx, end; 10318 int hmargin, vmargin, relief, idx, end;
10319 10319
10320 /* Ignore separator items. */
10321 if (EQ (PROP (TOOL_BAR_ITEM_TYPE), Qt))
10322 continue;
10323
10324 /* If image is a vector, choose the image according to the 10320 /* If image is a vector, choose the image according to the
10325 button state. */ 10321 button state. */
10326 image = PROP (TOOL_BAR_ITEM_IMAGES); 10322 image = PROP (TOOL_BAR_ITEM_IMAGES);
@@ -10495,7 +10491,7 @@ display_tool_bar_line (struct it *it, int height)
10495 row->used[TEXT_AREA] = n_glyphs_before; 10491 row->used[TEXT_AREA] = n_glyphs_before;
10496 *it = it_before; 10492 *it = it_before;
10497 /* If this is the only glyph on this line, it will never fit on the 10493 /* If this is the only glyph on this line, it will never fit on the
10498 toolbar, so skip it. But ensure there is at least one glyph, 10494 tool-bar, so skip it. But ensure there is at least one glyph,
10499 so we don't accidentally disable the tool-bar. */ 10495 so we don't accidentally disable the tool-bar. */
10500 if (n_glyphs_before == 0 10496 if (n_glyphs_before == 0
10501 && (it->vpos > 0 || IT_STRING_CHARPOS (*it) < it->end_charpos-1)) 10497 && (it->vpos > 0 || IT_STRING_CHARPOS (*it) < it->end_charpos-1))
@@ -26885,7 +26881,7 @@ vertical margin. */);
26885 tool_bar_button_relief = DEFAULT_TOOL_BAR_BUTTON_RELIEF; 26881 tool_bar_button_relief = DEFAULT_TOOL_BAR_BUTTON_RELIEF;
26886 26882
26887 DEFVAR_LISP ("tool-bar-style", &Vtool_bar_style, 26883 DEFVAR_LISP ("tool-bar-style", &Vtool_bar_style,
26888 doc: /* *Tool bar style to use. 26884 doc: /* Tool bar style to use.
26889It can be one of 26885It can be one of
26890 image - show images only 26886 image - show images only
26891 text - show text only 26887 text - show text only