]> git.eshelyaron.com Git - emacs.git/commitdiff
Add and use function horizontal-scroll-bars-available-p.
authorMartin Rudalics <rudalics@gmx.at>
Fri, 5 Sep 2014 10:29:34 +0000 (12:29 +0200)
committerMartin Rudalics <rudalics@gmx.at>
Fri, 5 Sep 2014 10:29:34 +0000 (12:29 +0200)
* scroll-bar.el (horizontal-scroll-bars-available-p): New
function.
(horizontal-scroll-bar-mode): Rewrite using
horizontal-scroll-bars-available-p.
* menu-bar.el (menu-bar-showhide-scroll-bar-menu): Rewrite using
horizontal-scroll-bars-available-p.

etc/NEWS
lisp/ChangeLog
lisp/menu-bar.el
lisp/scroll-bar.el

index bdda3ed0672a3b5c948b05654fff659ddfce236a..3b7516dd8194f87b2242d128c28ad875d025d728 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -240,6 +240,8 @@ optional repeat-count argument.
 ** Emacs can now draw horizontal scroll bars on some platforms that
 provide toolkit scroll bars, namely Gtk, Lucid, Motif and Windows.
 Horizontal scroll bars are turned off by default.
+*** New function `horizontal-scroll-bars-available-p' telling whether
+    horizontal scroll bars are available on the underlying system.
 *** New mode `horizontal-scroll-bar-mode' to toggle horizontal scroll
     bars on all existing and future frames.
 *** New frame parameters `horizontal-scroll-bars' and
index 2cc27412da445c8ed944bd222e324f6bf6ffe1d3..c6469006b813d5c39aa6a7c7d27ac233e44f8570 100644 (file)
@@ -1,3 +1,12 @@
+2014-09-05  Martin Rudalics  <rudalics@gmx.at>
+
+       * scroll-bar.el (horizontal-scroll-bars-available-p): New
+       function.
+       (horizontal-scroll-bar-mode): Rewrite using
+       horizontal-scroll-bars-available-p.
+       * menu-bar.el (menu-bar-showhide-scroll-bar-menu): Rewrite using
+       horizontal-scroll-bars-available-p.
+
 2014-09-05  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * subr.el (call-process-shell-command, process-file-shell-command):
index 57acbbe648e85acdc436b33070719944de1cefc6..9657c5924f90a05a096c4acadf5f07e021d97190 100644 (file)
@@ -903,19 +903,17 @@ by \"Save Options\" in Custom buffers.")
       '(menu-item "Horizontal"
                   menu-bar-horizontal-scroll-bar
                   :help "Horizontal scroll bar"
-                  :visible (display-graphic-p)
-                  :button (:radio . (eq (cdr (assq 'horizontal-scroll-bars
-                                                   (frame-parameters)))
-                                       t))))
+                  :visible (horizontal-scroll-bars-available-p)
+                  :button (:radio . (cdr (assq 'horizontal-scroll-bars
+                                              (frame-parameters))))))
 
     (bindings--define-key menu [none-horizontal]
       '(menu-item "None-horizontal"
                   menu-bar-no-horizontal-scroll-bar
                   :help "Turn off horizontal scroll bars"
-                  :visible (display-graphic-p)
-                  :button (:radio . (eq (cdr (assq 'horizontal-scroll-bars
-                                                   (frame-parameters)))
-                                       nil))))
+                  :visible (horizontal-scroll-bars-available-p)
+                  :button (:radio . (not (cdr (assq 'horizontal-scroll-bars
+                                                   (frame-parameters)))))))
 
     (bindings--define-key menu [right]
       '(menu-item "On the Right"
index 588ac3b0f8acd7a3076f07e4482d880156ac159a..63713c24a64644b53dcd8e7cddb27dd3edb96f75 100644 (file)
@@ -144,6 +144,13 @@ created in the future."
                            (if v (or previous-scroll-bar-mode
                                      default-frame-scroll-bars))))))
 
+(defun horizontal-scroll-bars-available-p ()
+  "Return non-nil when horizontal scroll bars are available on this system."
+  (and (display-graphic-p)
+       (boundp 'x-toolkit-scroll-bars)
+       x-toolkit-scroll-bars
+       (not (eq (window-system) 'ns))))
+
 (define-minor-mode horizontal-scroll-bar-mode
   "Toggle horizontal scroll bars on all frames (Horizontal Scroll Bar mode).
 With a prefix argument ARG, enable Horizontal Scroll Bar mode if
@@ -155,14 +162,19 @@ created in the future."
   :init-value nil
   :global t
   :group 'frames
-  (dolist (frame (frame-list))
-    (set-frame-parameter
-     frame 'horizontal-scroll-bars horizontal-scroll-bar-mode))
-  ;; Handle `default-frame-alist' entry.
-  (setq default-frame-alist
-       (cons (cons 'horizontal-scroll-bars horizontal-scroll-bar-mode)
-             (assq-delete-all 'horizontal-scroll-bars
-                              default-frame-alist))))
+  (if (and horizontal-scroll-bar-mode
+          (not (horizontal-scroll-bars-available-p)))
+      (progn
+       (setq horizontal-scroll-bar-mode nil)
+       (message "Horizontal scroll bars are not implemented on this system"))
+    (dolist (frame (frame-list))
+      (set-frame-parameter
+       frame 'horizontal-scroll-bars horizontal-scroll-bar-mode))
+    ;; Handle `default-frame-alist' entry.
+    (setq default-frame-alist
+         (cons (cons 'horizontal-scroll-bars horizontal-scroll-bar-mode)
+               (assq-delete-all 'horizontal-scroll-bars
+                                default-frame-alist)))))
 
 (defun toggle-scroll-bar (arg)
   "Toggle whether or not the selected frame has vertical scroll bars.