Commit f904c0f9 authored by Jan Djärv's avatar Jan Djärv

Gtk tool bars can be text, icons with text or just icons.

* xsettings.c: Qmonospace_font_name, Qtool_bar_style and
current_tool_bar_style are new.
(store_config_changed_event): Rename from store_font_changed_event.
(XSETTINGS_TOOL_BAR_STYLE): New define.
(SEEN_FONT, SEEN_TB_STYLE): New enum values.
(struct xsettings): Add font and tb_style, set xft stuff inside #ifdef
HAVE_XFT.
(something_changedCB): store_font_changed_event is now
store_config_changed_event
(parse_settings): Rename from parse_xft_settings.  Read
non-xft xsettings outside #ifdef HAVE_XFT.
(read_settings): Renamed from read_xft_settings.
(apply_xft_settings): Take current settings as parameter.  Do not
call read_(xft)_settings.
(read_and_apply_settings): New function.
(xft_settings_event): Do non-xft stuff out of HAVE_XFT.  Call
read_and_apply_settings if there are settings to be read.
(init_xsettings): Renamed from init_xfd_settings.
Call read_and_apply_settings unconditionally.
(xsettings_initialize): Call init_xsettings.
(Ftool_bar_get_system_style): New function.
(syms_of_xsettings): Define Qmonospace_font_name and
Qtool_bar_style.  Initialize current_tool_bar_style to nil.
defsubr Stool_bar_get_system_style. Fprovide on
dynamic-setting.

* xsettings.h (Ftool_bar_get_system_style): Declare.

* xdisp.c: Vtool_bar_style, tool_bar_max_label_size,
Qtext, Qboth, Qboth_horiz are new.
(syms_of_xdisp): Intern Qtext, Qboth, Qboth_horiz, DEFVAR
Vtool_bar_style, tool_bar_max_label_size.

* lisp.h: Extern declare Qtext, Qboth, Qboth_horiz.

* keyboard.c: QClabel is new.
(parse_tool_bar_item): Take out QClabel from tool bar items.
Try to construct a label if ther is no QClabel.
(syms_of_keyboard): Intern :label as QClabel.

* dispextern.h (tool_bar_item_idx): TOOL_BAR_ITEM_LABEL is new.
(Vtool_bar_style, tool_bar_max_label_size, DEFAULT_TOOL_BAR_LABEL_SIZE):
New.

* Makefile.in (SOME_MACHINE_LISP): font-setting.el renamed to
dynamic-setting.el.

* gtkutil.c (xg_tool_bar_menu_proxy): Handle label in tool bar item.
(xg_make_tool_item, xg_show_toolbar_item): New function.
(update_frame_tool_bar): Take label from TOOL_BAR_ITEM_LABEL.
Call xg_make_tool_item to make a tool bar item.
Call xg_show_toolbar_item.  Use wtoolbar instead of x->toolbar_widget.

* xterm.c (x_draw_image_relief): Take Vtool_bar_button_margin
into account for toolbars.

* vc-dir.el (vc-dir-tool-bar-map): Add :label on some tool bar items.

* tool-bar.el (tool-bar-setup): Add :label on some tool bar items.

* loadup.el: Load dynamic-setting.el if feature dynamic-setting
is present.

* info.el (info-tool-bar-map): Add labels.

* cus-start.el (all): Add tool-bar-style and tool-bar-max-label-size.

* cus-edit.el (custom-commands): Add labels for tool bar.
(custom-buffer-create-internal, Custom-mode): Adjust for
labels in custom-commands.

* dynamic-setting.el: Renamed from font-setting.el.
parent c632dfda
2010-04-21 Jan Djärv <jan.h.d@swipnet.se>
* vc-dir.el (vc-dir-tool-bar-map): Add :label on some tool bar items.
* tool-bar.el (tool-bar-setup): Add :label on some tool bar items.
* loadup.el: Load dynamic-setting.el if feature dynamic-setting
is present.
* info.el (info-tool-bar-map): Add labels.
* cus-start.el (all): Add tool-bar-style and tool-bar-max-label-size.
* cus-edit.el (custom-commands): Add labels for tool bar.
(custom-buffer-create-internal, Custom-mode): Adjust for
labels in custom-commands.
* dynamic-setting.el: Renamed from font-setting.el.
2010-04-21 John Wiegley <jwiegley@gmail.com> 2010-04-21 John Wiegley <jwiegley@gmail.com>
* ido.el (ido-init-completion-maps): For ido-switch-buffer, C-o * ido.el (ido-init-completion-maps): For ido-switch-buffer, C-o
......
...@@ -739,25 +739,31 @@ groups after non-groups, if nil do not order groups at all." ...@@ -739,25 +739,31 @@ groups after non-groups, if nil do not order groups at all."
(defvar custom-commands (defvar custom-commands
'(("Set for current session" Custom-set t '(("Set for current session" Custom-set t
"Apply all settings in this buffer to the current session" "Apply all settings in this buffer to the current session"
"index") "index"
"Apply")
("Save for future sessions" Custom-save ("Save for future sessions" Custom-save
(or custom-file user-init-file) (or custom-file user-init-file)
"Apply all settings in this buffer and save them for future Emacs sessions." "Apply all settings in this buffer and save them for future Emacs sessions."
"save") "save"
"Save")
("Undo edits" Custom-reset-current t ("Undo edits" Custom-reset-current t
"Restore all settings in this buffer to reflect their current values." "Restore all settings in this buffer to reflect their current values."
"refresh") "refresh"
"Undo")
("Reset to saved" Custom-reset-saved t ("Reset to saved" Custom-reset-saved t
"Restore all settings in this buffer to their saved values (if any)." "Restore all settings in this buffer to their saved values (if any)."
"undo") "undo"
"Reset")
("Erase customizations" Custom-reset-standard ("Erase customizations" Custom-reset-standard
(or custom-file user-init-file) (or custom-file user-init-file)
"Un-customize all settings in this buffer and save them with standard values." "Un-customize all settings in this buffer and save them with standard values."
"delete") "delete"
"Uncustomize")
("Help for Customize" Custom-help t ("Help for Customize" Custom-help t
"Get help for using Customize." "Get help for using Customize."
"help") "help"
("Exit" Custom-buffer-done t "Exit Customize." "exit"))) "Help")
("Exit" Custom-buffer-done t "Exit Customize." "exit" "Exit")))
(defun Custom-help () (defun Custom-help ()
"Read the node on Easy Customization in the Emacs manual." "Read the node on Easy Customization in the Emacs manual."
...@@ -1616,7 +1622,7 @@ Otherwise use brackets." ...@@ -1616,7 +1622,7 @@ Otherwise use brackets."
(if custom-buffer-verbose-help (if custom-buffer-verbose-help
(widget-insert " (widget-insert "
Operate on all settings in this buffer:\n")) Operate on all settings in this buffer:\n"))
(let ((button (lambda (tag action active help icon) (let ((button (lambda (tag action active help icon label)
(widget-insert " ") (widget-insert " ")
(if (eval active) (if (eval active)
(widget-create 'push-button :tag tag (widget-create 'push-button :tag tag
...@@ -4680,7 +4686,8 @@ if that value is non-nil." ...@@ -4680,7 +4686,8 @@ if that value is non-nil."
(mapc (mapc
(lambda (arg) (lambda (arg)
(tool-bar-local-item-from-menu (tool-bar-local-item-from-menu
(nth 1 arg) (nth 4 arg) map custom-mode-map)) (nth 1 arg) (nth 4 arg) map custom-mode-map
:label (nth 5 arg)))
custom-commands) custom-commands)
(setq custom-tool-bar-map map)))) (setq custom-tool-bar-map map))))
(make-local-variable 'custom-options) (make-local-variable 'custom-options)
......
...@@ -339,6 +339,15 @@ since it could result in memory overflow and make Emacs crash." ...@@ -339,6 +339,15 @@ since it could result in memory overflow and make Emacs crash."
(const :tag "Off (nil)" :value nil) (const :tag "Off (nil)" :value nil)
(const :tag "Immediate" :value t) (const :tag "Immediate" :value t)
(number :tag "Delay by secs" :value 0.5)) "22.1") (number :tag "Delay by secs" :value 0.5)) "22.1")
(tool-bar-style
frames (choice
(const :tag "Images" :value image)
(const :tag "Text" :value text)
(const :tag "Both" :value both)
(const :tag "Both-horiz" :value both-horiz)
(const :tag "System default" :value nil)) "23.3")
(tool-bar-max-label-size frames integer "23.3")
;; xfaces.c ;; xfaces.c
(scalable-fonts-allowed display boolean "22.1") (scalable-fonts-allowed display boolean "22.1")
;; xfns.c ;; xfns.c
......
;;; font-setting.el --- Support dynamic font changes ;;; dynamic-setting.el --- Support dynamic changes
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
;; Author: Jan Djärv <jan.h.d@swipnet.se> ;; Author: Jan Djärv <jan.h.d@swipnet.se>
;; Maintainer: FSF ;; Maintainer: FSF
;; Keywords: font, system-font ;; Keywords: font, system-font, tool-bar-style
;; This file is part of GNU Emacs. ;; This file is part of GNU Emacs.
...@@ -81,21 +81,25 @@ current form for the frame (i.e. hinting or somesuch changed)." ...@@ -81,21 +81,25 @@ current form for the frame (i.e. hinting or somesuch changed)."
(custom-push-theme 'theme-face 'default 'user 'set spec) (custom-push-theme 'theme-face 'default 'user 'set spec)
(put 'default 'face-modified nil)))))) (put 'default 'face-modified nil))))))
(defun font-setting-handle-config-changed-event (event) (defun dynamic-setting-handle-config-changed-event (event)
"Handle config-changed-event to change fonts on the display in EVENT. "Handle config-changed-event on the display in EVENT.
If `font-use-system-font' is nil, the font is not changed." Changes can be
The monospace font. If `font-use-system-font' is nil, the font
is not changed.
Xft parameters, like DPI and hinting.
The tool bar style."
(interactive "e") (interactive "e")
(let ((type (nth 1 event)) ;; font-name or font-render (let ((type (nth 1 event))
(display-name (nth 2 event))) (display-name (nth 2 event)))
(if (or (not (eq type 'font-name)) (cond ((and (eq type 'monospace-font-name) font-use-system-font)
font-use-system-font) (font-setting-change-default-font display-name t))
(font-setting-change-default-font display-name
(eq type 'font-name)))))
(if (or (featurep 'system-font-setting) (featurep 'font-render-setting)) ((eq type 'font-render)
(define-key special-event-map [config-changed-event] (font-setting-change-default-font display-name nil))
'font-setting-handle-config-changed-event))
(provide 'font-setting) ((eq type 'tool-bar-style) (force-mode-line-update t)))))
(define-key special-event-map [config-changed-event]
'dynamic-setting-handle-config-changed-event)
;; arch-tag: 3a57e78f-1cd6-48b6-ab75-98f160dcc017 ;; arch-tag: 3a57e78f-1cd6-48b6-ab75-98f160dcc017
...@@ -3736,9 +3736,11 @@ If FORK is non-nil, it is passed to `Info-goto-node'." ...@@ -3736,9 +3736,11 @@ If FORK is non-nil, it is passed to `Info-goto-node'."
(defvar info-tool-bar-map (defvar info-tool-bar-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map (tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map
:rtl "right-arrow") :rtl "right-arrow"
:label "Back")
(tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map (tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map
:rtl "left-arrow") :rtl "left-arrow"
:label "Forward")
(tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map
:rtl "next-node") :rtl "next-node")
(tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map
...@@ -3746,7 +3748,8 @@ If FORK is non-nil, it is passed to `Info-goto-node'." ...@@ -3746,7 +3748,8 @@ If FORK is non-nil, it is passed to `Info-goto-node'."
(tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map) (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map)
(tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map) (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) (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map)
(tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map) (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) (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
(tool-bar-local-item-from-menu 'Info-exit "exit" map Info-mode-map) (tool-bar-local-item-from-menu 'Info-exit "exit" map Info-mode-map)
map)) map))
......
...@@ -203,8 +203,8 @@ ...@@ -203,8 +203,8 @@
(load "dnd") (load "dnd")
(load "tool-bar"))) (load "tool-bar")))
(if (or (featurep 'system-font-setting) (featurep 'font-render-setting)) (if (featurep 'dynamic-setting)
(load "font-setting")) (load "dynamic-setting"))
(if (featurep 'x) (if (featurep 'x)
(progn (progn
......
...@@ -267,7 +267,7 @@ holds a keymap." ...@@ -267,7 +267,7 @@ holds a keymap."
;; People say it's bad to have EXIT on the tool bar, since users ;; People say it's bad to have EXIT on the tool bar, since users
;; might inadvertently click that button. ;; might inadvertently click that button.
;;(tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit") ;;(tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit")
(tool-bar-add-item-from-menu 'find-file "new") (tool-bar-add-item-from-menu 'find-file "new" nil :label "New File")
(tool-bar-add-item-from-menu 'menu-find-file-existing "open") (tool-bar-add-item-from-menu 'menu-find-file-existing "open")
(tool-bar-add-item-from-menu 'dired "diropen") (tool-bar-add-item-from-menu 'dired "diropen")
(tool-bar-add-item-from-menu 'kill-this-buffer "close") (tool-bar-add-item-from-menu 'kill-this-buffer "close")
...@@ -294,14 +294,15 @@ holds a keymap." ...@@ -294,14 +294,15 @@ holds a keymap."
"paste" nil "paste" nil
:visible '(not (eq 'special (get major-mode :visible '(not (eq 'special (get major-mode
'mode-class)))) 'mode-class))))
(tool-bar-add-item-from-menu 'nonincremental-search-forward "search") (tool-bar-add-item-from-menu 'nonincremental-search-forward "search"
nil :label "Search")
;;(tool-bar-add-item-from-menu 'ispell-buffer "spell") ;;(tool-bar-add-item-from-menu 'ispell-buffer "spell")
;; There's no icon appropriate for News and we need a command rather ;; There's no icon appropriate for News and we need a command rather
;; than a lambda for Read Mail. ;; than a lambda for Read Mail.
;;(tool-bar-add-item-from-menu 'compose-mail "mail/compose") ;;(tool-bar-add-item-from-menu 'compose-mail "mail/compose")
(tool-bar-add-item-from-menu 'print-buffer "print") (tool-bar-add-item-from-menu 'print-buffer "print" nil :label "Print")
;; tool-bar-add-item-from-menu itself operates on ;; tool-bar-add-item-from-menu itself operates on
;; (default-value 'tool-bar-map), but when we don't use that function, ;; (default-value 'tool-bar-map), but when we don't use that function,
......
...@@ -301,7 +301,8 @@ If BODY uses EVENT, it should be a variable, ...@@ -301,7 +301,8 @@ If BODY uses EVENT, it should be a variable,
map vc-dir-mode-map) map vc-dir-mode-map)
(tool-bar-local-item "bookmark_add" (tool-bar-local-item "bookmark_add"
'vc-dir-toggle-mark 'vc-dir-toggle-mark map 'vc-dir-toggle-mark 'vc-dir-toggle-mark map
:help "Toggle mark on current item") :help "Toggle mark on current item"
:label "Toggle Mark")
(tool-bar-local-item-from-menu 'vc-dir-previous-line "left-arrow" (tool-bar-local-item-from-menu 'vc-dir-previous-line "left-arrow"
map vc-dir-mode-map map vc-dir-mode-map
:rtl "right-arrow") :rtl "right-arrow")
...@@ -313,11 +314,14 @@ If BODY uses EVENT, it should be a variable, ...@@ -313,11 +314,14 @@ If BODY uses EVENT, it should be a variable,
(tool-bar-local-item-from-menu 'revert-buffer "refresh" (tool-bar-local-item-from-menu 'revert-buffer "refresh"
map vc-dir-mode-map) map vc-dir-mode-map)
(tool-bar-local-item-from-menu 'nonincremental-search-forward (tool-bar-local-item-from-menu 'nonincremental-search-forward
"search" map) "search" map nil
:label "Search")
(tool-bar-local-item-from-menu 'vc-dir-query-replace-regexp (tool-bar-local-item-from-menu 'vc-dir-query-replace-regexp
"search-replace" map vc-dir-mode-map) "search-replace" map vc-dir-mode-map
:label "Replace")
(tool-bar-local-item-from-menu 'vc-dir-kill-dir-status-process "cancel" (tool-bar-local-item-from-menu 'vc-dir-kill-dir-status-process "cancel"
map vc-dir-mode-map) map vc-dir-mode-map
:label "Cancel")
(tool-bar-local-item-from-menu 'quit-window "exit" (tool-bar-local-item-from-menu 'quit-window "exit"
map vc-dir-mode-map) map vc-dir-mode-map)
map)) map))
......
2010-04-21 Jan Djärv <jan.h.d@swipnet.se>
* xsettings.c: Qmonospace_font_name, Qtool_bar_style and
current_tool_bar_style are new.
(store_config_changed_event): Rename from store_font_changed_event.
(XSETTINGS_TOOL_BAR_STYLE): New define.
(SEEN_FONT, SEEN_TB_STYLE): New enum values.
(struct xsettings): Add font and tb_style, set xft stuff inside #ifdef
HAVE_XFT.
(something_changedCB): store_font_changed_event is now
store_config_changed_event
(parse_settings): Rename from parse_xft_settings. Read
non-xft xsettings outside #ifdef HAVE_XFT.
(read_settings): Renamed from read_xft_settings.
(apply_xft_settings): Take current settings as parameter. Do not
call read_(xft)_settings.
(read_and_apply_settings): New function.
(xft_settings_event): Do non-xft stuff out of HAVE_XFT. Call
read_and_apply_settings if there are settings to be read.
(init_xsettings): Renamed from init_xfd_settings.
Call read_and_apply_settings unconditionally.
(xsettings_initialize): Call init_xsettings.
(Ftool_bar_get_system_style): New function.
(syms_of_xsettings): Define Qmonospace_font_name and
Qtool_bar_style. Initialize current_tool_bar_style to nil.
defsubr Stool_bar_get_system_style. Fprovide on
dynamic-setting.
* xsettings.h (Ftool_bar_get_system_style): Declare.
* xdisp.c: Vtool_bar_style, tool_bar_max_label_size,
Qtext, Qboth, Qboth_horiz are new.
(syms_of_xdisp): Intern Qtext, Qboth, Qboth_horiz, DEFVAR
Vtool_bar_style, tool_bar_max_label_size.
* lisp.h: Extern declare Qtext, Qboth, Qboth_horiz.
* keyboard.c: QClabel is new.
(parse_tool_bar_item): Take out QClabel from tool bar items.
Try to construct a label if ther is no QClabel.
(syms_of_keyboard): Intern :label as QClabel.
* dispextern.h (tool_bar_item_idx): TOOL_BAR_ITEM_LABEL is new.
(Vtool_bar_style, tool_bar_max_label_size, DEFAULT_TOOL_BAR_LABEL_SIZE):
New.
* Makefile.in (SOME_MACHINE_LISP): font-setting.el renamed to
dynamic-setting.el.
* gtkutil.c (xg_tool_bar_menu_proxy): Handle label in tool bar item.
(xg_make_tool_item, xg_show_toolbar_item): New function.
(update_frame_tool_bar): Take label from TOOL_BAR_ITEM_LABEL.
Call xg_make_tool_item to make a tool bar item.
Call xg_show_toolbar_item. Use wtoolbar instead of x->toolbar_widget.
* xterm.c (x_draw_image_relief): Take Vtool_bar_button_margin
into account for toolbars.
2010-04-21 Jan Djärv <jan.h.d@swipnet.se> 2010-04-21 Jan Djärv <jan.h.d@swipnet.se>
* data.c (make_blv): Declarations before code (Bug#5993). * data.c (make_blv): Declarations before code (Bug#5993).
......
...@@ -566,7 +566,7 @@ otherobj= $(termcapobj) lastfile.o $(mallocobj) $(widgetobj) $(LIBOBJS) ...@@ -566,7 +566,7 @@ otherobj= $(termcapobj) lastfile.o $(mallocobj) $(widgetobj) $(LIBOBJS)
${lispsource}international/fontset.elc ${lispsource}dnd.elc \ ${lispsource}international/fontset.elc ${lispsource}dnd.elc \
${lispsource}tool-bar.elc ${lispsource}mwheel.elc ${lispsource}x-dnd.elc \ ${lispsource}tool-bar.elc ${lispsource}mwheel.elc ${lispsource}x-dnd.elc \
${lispsource}term/common-win.elc ${lispsource}term/x-win.elc \ ${lispsource}term/common-win.elc ${lispsource}term/x-win.elc \
${lispsource}font-setting.elc ${lispsource}dynamic-setting.elc
#else #else
#define WINDOW_SUPPORT ${lispsource}fringe.elc ${lispsource}image.elc \ #define WINDOW_SUPPORT ${lispsource}fringe.elc ${lispsource}image.elc \
${lispsource}international/fontset.elc ${lispsource}dnd.elc \ ${lispsource}international/fontset.elc ${lispsource}dnd.elc \
...@@ -801,7 +801,7 @@ SOME_MACHINE_LISP = ../lisp/mouse.elc \ ...@@ -801,7 +801,7 @@ SOME_MACHINE_LISP = ../lisp/mouse.elc \
../lisp/tooltip.elc ../lisp/image.elc \ ../lisp/tooltip.elc ../lisp/image.elc \
../lisp/fringe.elc ../lisp/dnd.elc \ ../lisp/fringe.elc ../lisp/dnd.elc \
../lisp/mwheel.elc ../lisp/tool-bar.elc \ ../lisp/mwheel.elc ../lisp/tool-bar.elc \
../lisp/x-dnd.elc ../lisp/font-setting.elc \ ../lisp/x-dnd.elc ../lisp/dynamic-setting.elc \
../lisp/international/ccl.elc \ ../lisp/international/ccl.elc \
../lisp/international/fontset.elc \ ../lisp/international/fontset.elc \
../lisp/mouse.elc \ ../lisp/mouse.elc \
......
...@@ -2793,6 +2793,9 @@ enum tool_bar_item_idx ...@@ -2793,6 +2793,9 @@ enum tool_bar_item_idx
/* Icon file name of right to left image when an RTL locale is used. */ /* Icon file name of right to left image when an RTL locale is used. */
TOOL_BAR_ITEM_RTL_IMAGE, TOOL_BAR_ITEM_RTL_IMAGE,
/* Label to show when text labels are enabled. */
TOOL_BAR_ITEM_LABEL,
/* Sentinel = number of slots in tool_bar_items occupied by one /* Sentinel = number of slots in tool_bar_items occupied by one
tool-bar item. */ tool-bar item. */
TOOL_BAR_ITEM_NSLOTS TOOL_BAR_ITEM_NSLOTS
...@@ -2814,6 +2817,15 @@ enum tool_bar_item_image ...@@ -2814,6 +2817,15 @@ enum tool_bar_item_image
extern Lisp_Object Vtool_bar_button_margin; extern Lisp_Object Vtool_bar_button_margin;
/* Tool bar style */
extern Lisp_Object Vtool_bar_style;
/* Maximum number of characters a label can have to be shown. */
extern EMACS_INT tool_bar_max_label_size;
#define DEFAULT_TOOL_BAR_LABEL_SIZE 14
/* Thickness of relief to draw around tool-bar buttons. */ /* Thickness of relief to draw around tool-bar buttons. */
extern EMACS_INT tool_bar_button_relief; extern EMACS_INT tool_bar_button_relief;
......
...@@ -3522,7 +3522,16 @@ xg_tool_bar_menu_proxy (toolitem, user_data) ...@@ -3522,7 +3522,16 @@ xg_tool_bar_menu_proxy (toolitem, user_data)
{ {
GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (toolitem)); GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (toolitem));
GtkButton *wbutton = GTK_BUTTON (gtk_bin_get_child (GTK_BIN (weventbox))); GtkButton *wbutton = GTK_BUTTON (gtk_bin_get_child (GTK_BIN (weventbox)));
GtkWidget *wmenuitem = gtk_image_menu_item_new_with_label (""); GtkBox *vb = GTK_BOX (gtk_bin_get_child (GTK_BIN (wbutton)));
GtkBoxChild *c1 = (GtkBoxChild *) vb->children->data;
GtkBoxChild *c2 = (GtkBoxChild *) vb->children->next->data;
GtkImage *wimage = GTK_IS_IMAGE (c1->widget)
? GTK_IMAGE (c1->widget) : GTK_IMAGE (c2->widget);
GtkLabel *wlbl = GTK_IS_LABEL (c1->widget)
? GTK_LABEL (c1->widget) : GTK_LABEL (c2->widget);
GtkWidget *wmenuitem = gtk_image_menu_item_new_with_label
(gtk_label_get_text (wlbl));
GtkWidget *wmenuimage; GtkWidget *wmenuimage;
if (gtk_button_get_use_stock (wbutton)) if (gtk_button_get_use_stock (wbutton))
...@@ -3530,7 +3539,6 @@ xg_tool_bar_menu_proxy (toolitem, user_data) ...@@ -3530,7 +3539,6 @@ xg_tool_bar_menu_proxy (toolitem, user_data)
GTK_ICON_SIZE_MENU); GTK_ICON_SIZE_MENU);
else else
{ {
GtkImage *wimage = GTK_IMAGE (gtk_bin_get_child (GTK_BIN (wbutton)));
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (wbutton)); GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (wbutton));
GtkImageType store_type = gtk_image_get_storage_type (wimage); GtkImageType store_type = gtk_image_get_storage_type (wimage);
...@@ -3834,6 +3842,132 @@ find_rtl_image (f, image, rtl) ...@@ -3834,6 +3842,132 @@ find_rtl_image (f, image, rtl)
return image; return image;
} }
static GtkToolItem *
xg_make_tool_item (FRAME_PTR f,
GtkWidget *wimage,
GtkWidget **wbutton,
char *label,
int i)
{
GtkToolItem *ti = gtk_tool_item_new ();
GtkWidget *vb = EQ (Vtool_bar_style, Qboth_horiz)
? gtk_hbox_new (FALSE, 0) : gtk_vbox_new (FALSE, 0);
GtkWidget *wb = gtk_button_new ();
GtkWidget *weventbox = gtk_event_box_new ();
if (wimage)
gtk_box_pack_start_defaults (GTK_BOX (vb), wimage);
gtk_box_pack_start_defaults (GTK_BOX (vb), gtk_label_new (label));
gtk_button_set_focus_on_click (GTK_BUTTON (wb), FALSE);
gtk_button_set_relief (GTK_BUTTON (wb), GTK_RELIEF_NONE);
gtk_container_add (GTK_CONTAINER (wb), vb);
gtk_container_add (GTK_CONTAINER (weventbox), wb);
gtk_container_add (GTK_CONTAINER (ti), weventbox);
if (wimage)
{
/* The EMACS_INT cast avoids a warning. */
g_signal_connect (G_OBJECT (ti), "create-menu-proxy",
G_CALLBACK (xg_tool_bar_menu_proxy),
(gpointer) (EMACS_INT) i);
g_signal_connect (G_OBJECT (wb), "clicked",
G_CALLBACK (xg_tool_bar_callback),
(gpointer) (EMACS_INT) i);
gtk_widget_show_all (GTK_WIDGET (ti));
g_object_set_data (G_OBJECT (weventbox), XG_FRAME_DATA, (gpointer)f);
/* Catch expose events to overcome an annoying redraw bug, see
comment for xg_tool_bar_item_expose_callback. */
g_signal_connect (G_OBJECT (ti),
"expose-event",
G_CALLBACK (xg_tool_bar_item_expose_callback),
0);
gtk_tool_item_set_homogeneous (ti, FALSE);
/* Callback to save modifyer mask (Shift/Control, etc). GTK makes
no distinction based on modifiers in the activate callback,
so we have to do it ourselves. */
g_signal_connect (wb, "button-release-event",
G_CALLBACK (xg_tool_bar_button_cb),
NULL);
g_object_set_data (G_OBJECT (wb), XG_FRAME_DATA, (gpointer)f);
/* Use enter/leave notify to show help. We use the events
rather than the GtkButton specific signals "enter" and
"leave", so we can have only one callback. The event
will tell us what kind of event it is. */
/* The EMACS_INT cast avoids a warning. */
g_signal_connect (G_OBJECT (weventbox),
"enter-notify-event",
G_CALLBACK (xg_tool_bar_help_callback),
(gpointer) (EMACS_INT) i);
g_signal_connect (G_OBJECT (weventbox),
"leave-notify-event",
G_CALLBACK (xg_tool_bar_help_callback),
(gpointer) (EMACS_INT) i);
}
if (wbutton) *wbutton = wb;
return ti;
}
static void
xg_show_toolbar_item (GtkToolItem *ti)
{
Lisp_Object style = Ftool_bar_get_system_style ();
int show_label = EQ (style, Qboth)
|| EQ (style, Qboth_horiz) || EQ (style, Qtext);
int show_image = ! EQ (style, Qtext);
int horiz = EQ (style, Qboth_horiz);
GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (ti));
GtkWidget *wbutton = gtk_bin_get_child (GTK_BIN (weventbox));
GtkBox *vb = GTK_BOX (gtk_bin_get_child (GTK_BIN (wbutton)));
GtkBoxChild *c1 = (GtkBoxChild *) vb->children->data;
GtkBoxChild *c2 = (GtkBoxChild *) vb->children->next->data;
GtkWidget *wimage = GTK_IS_IMAGE (c1->widget)
? c1->widget : c2->widget;
GtkWidget *wlbl = GTK_IS_LABEL (c1->widget)
? c1->widget : c2->widget;
GtkWidget *new_box = NULL;
if (GTK_IS_VBOX (vb) && horiz)
new_box = gtk_hbox_new (FALSE, 0);
else if (GTK_IS_HBOX (vb) && !horiz && show_label && show_image)
new_box = gtk_vbox_new (FALSE, 0);
if (new_box)
{
gtk_widget_ref (wimage);
gtk_widget_ref (wlbl);
gtk_container_remove (GTK_CONTAINER (vb), wimage);
gtk_container_remove (GTK_CONTAINER (vb), wlbl);
gtk_widget_destroy (GTK_WIDGET (vb));
gtk_box_pack_start_defaults (GTK_BOX (new_box), wimage);
gtk_box_pack_start_defaults (GTK_BOX (new_box), wlbl);
gtk_container_add (GTK_CONTAINER (wbutton), new_box);
gtk_widget_unref (wimage);
gtk_widget_unref (wlbl);
vb = GTK_BOX (new_box);
}
if (show_label) gtk_widget_show (wlbl);
else gtk_widget_hide (wlbl);
if (show_image) gtk_widget_show (wimage);
else gtk_widget_hide (wimage);
gtk_widget_show (GTK_WIDGET (vb));
gtk_widget_show (GTK_WIDGET (wbutton));
gtk_widget_show (GTK_WIDGET (ti));
}
/* Update the tool bar for frame F. Add new buttons and remove old. */ /* Update the tool bar for frame F. Add new buttons and remove old. */
extern Lisp_Object Qx_gtk_map_stock; extern Lisp_Object Qx_gtk_map_stock;
...@@ -3885,8 +4019,8 @@ update_frame_tool_bar (f) ...@@ -3885,8 +4019,8 @@ update_frame_tool_bar (f)
wtoolbar = GTK_TOOLBAR (x->toolbar_widget); wtoolbar = GTK_TOOLBAR (x->toolbar_widget);
gtk_widget_size_request (GTK_WIDGET (wtoolbar), &old_req); gtk_widget_size_request (GTK_WIDGET (wtoolbar), &old_req);
dir = gtk_widget_get_direction (x->toolbar_widget); dir = gtk_widget_get_direction (GTK_WIDGET (wtoolbar));
for (i = 0; i < f->n_tool_bar_items; ++i) for (i = 0; i < f->n_tool_bar_items; ++i)
{ {
int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)); int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P));
...@@ -3904,8 +4038,10 @@ update_frame_tool_bar (f) ...@@ -3904,8 +4038,10 @@ update_frame_tool_bar (f)
GtkWidget *wbutton = NULL; GtkWidget *wbutton = NULL;
GtkWidget *weventbox; GtkWidget *weventbox;
Lisp_Object specified_file; Lisp_Object specified_file;
Lisp_Object lbl = PROP (TOOL_BAR_ITEM_LABEL);
ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i); char *label = SSDATA (PROP (TOOL_BAR_ITEM_LABEL));
ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (wtoolbar), i);
if (ti) if (ti)
{ {
...@@ -3913,6 +4049,7 @@ update_frame_tool_bar (f) ...@@ -3913,6 +4049,7 @@ update_frame_tool_bar (f)
wbutton = gtk_bin_get_child (GTK_BIN (weventbox)); wbutton = gtk_bin_get_child (GTK_BIN (weventbox));
} }
image = PROP (TOOL_BAR_ITEM_IMAGES); image = PROP (TOOL_BAR_ITEM_IMAGES);
/* Ignore invalid image specifications. */ /* Ignore invalid image specifications. */
...@@ -3944,7 +4081,7 @@ update_frame_tool_bar (f) ...@@ -3944,7 +4081,7 @@ update_frame_tool_bar (f)
icon_size = gtk_toolbar_get_icon_size (wtoolbar); icon_size = gtk_toolbar_get_icon_size (wtoolbar);
} }
else if (gtk_stock_lookup (SSDATA (stock), &stock_item)) else if (gtk_stock_lookup (SSDATA (stock), &stock_item))
icon_size = gtk_toolbar_get_icon_size (wtoolbar);