Mercurial > emacs
changeset 111650:8fd0d7bcdf7d
Add keyword :vert-only for tool bar items with labels not shown horizontally.
* lisp/info.el (info-tool-bar-map): Add some :vert-only keywords.
* lisp/tool-bar.el (tool-bar-setup): Add some :vert-only keywords.
* src/dispextern.h (tool_bar_item_idx): Add TOOL_BAR_ITEM_VERT_ONLY.
* src/gtkutil.c (xg_make_tool_item): Take vert_only as argument.
Set important to ! vert_only.
(xg_show_toolbar_item): Don't show label horizontally if
tool item isn't important.
(update_frame_tool_bar): Get TOOL_BAR_ITEM_VERT_ONLY and pass it to
xg_make_tool_item, or update important on existing tool item.
* src/keyboard.c (QCvert_only): New variable.
(parse_tool_bar_item): Check for QCvert_only.
(syms_of_keyboard): Initialize QCvert_only.
author | Jan D. <jan.h.d@swipnet.se> |
---|---|
date | Sat, 20 Nov 2010 15:51:25 +0100 |
parents | 342ca5475c01 |
children | dbffbd2b89b9 |
files | lisp/ChangeLog lisp/info.el lisp/tool-bar.el src/ChangeLog src/dispextern.h src/gtkutil.c src/keyboard.c |
diffstat | 7 files changed, 63 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Sat Nov 20 16:35:45 2010 +0200 +++ b/lisp/ChangeLog Sat Nov 20 15:51:25 2010 +0100 @@ -1,3 +1,9 @@ +2010-11-20 Jan Djärv <jan.h.d@swipnet.se> + + * tool-bar.el (tool-bar-setup): Add some :vert-only keywords. + + * info.el (info-tool-bar-map): Add some :vert-only keywords. + 2010-11-20 Eli Zaretskii <eliz@gnu.org> * international/characters.el (glyphless-char-display-control):
--- a/lisp/info.el Sat Nov 20 16:35:45 2010 +0200 +++ b/lisp/info.el Sat Nov 20 15:51:25 2010 +0100 @@ -3763,15 +3763,18 @@ (let ((map (make-sparse-keymap))) (tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map :rtl "right-arrow" - :label "Back") + :label "Back" + :vert-only t) (tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map :rtl "left-arrow" - :label "Forward") + :label "Forward" + :vert-only t) (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) + (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map + :vert-only t) (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-index "index" map Info-mode-map
--- a/lisp/tool-bar.el Sat Nov 20 16:35:45 2010 +0200 +++ b/lisp/tool-bar.el Sat Nov 20 15:51:25 2010 +0100 @@ -260,31 +260,33 @@ ;; People say it's bad to have EXIT on the tool bar, since users ;; might inadvertently click that button. ;;(tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit") - (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 'dired "diropen") - (tool-bar-add-item-from-menu 'kill-this-buffer "close") - (tool-bar-add-item-from-menu 'save-buffer "save" nil + (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 + :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 :visible '(or buffer-file-name (not (eq 'special (get major-mode 'mode-class))))) - (tool-bar-add-item-from-menu 'write-file "saveas" nil + (tool-bar-add-item-from-menu 'write-file "saveas" nil :vert-only t :visible '(or buffer-file-name (not (eq 'special (get major-mode 'mode-class))))) - (tool-bar-add-item-from-menu 'undo "undo" nil + (tool-bar-add-item-from-menu 'undo "undo" nil :vert-only t :visible '(not (eq 'special (get major-mode 'mode-class)))) (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut]) - "cut" nil + "cut" nil :vert-only t :visible '(not (eq 'special (get major-mode 'mode-class)))) (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy]) - "copy") + "copy" nil :vert-only t) (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste]) - "paste" nil + "paste" nil :vert-only t :visible '(not (eq 'special (get major-mode 'mode-class)))) (tool-bar-add-item-from-menu 'nonincremental-search-forward "search"
--- a/src/ChangeLog Sat Nov 20 16:35:45 2010 +0200 +++ b/src/ChangeLog Sat Nov 20 15:51:25 2010 +0100 @@ -1,3 +1,18 @@ +2010-11-20 Jan Djärv <jan.h.d@swipnet.se> + + * gtkutil.c (xg_make_tool_item): Take vert_only as argument. + Set important to ! vert_only. + (xg_show_toolbar_item): Don't show label horizontally if + tool item isn't important. + (update_frame_tool_bar): Get TOOL_BAR_ITEM_VERT_ONLY and pass it to + xg_make_tool_item, or update important on existing tool item. + + * keyboard.c (QCvert_only): New variable. + (parse_tool_bar_item): Check for QCvert_only. + (syms_of_keyboard): Initialize QCvert_only. + + * dispextern.h (tool_bar_item_idx): Add TOOL_BAR_ITEM_VERT_ONLY. + 2010-11-20 Eli Zaretskii <eliz@gnu.org> * msdos.c (dos_rawgetc): Use gen_help_event, instead of doing the
--- a/src/dispextern.h Sat Nov 20 16:35:45 2010 +0200 +++ b/src/dispextern.h Sat Nov 20 15:51:25 2010 +0100 @@ -2887,6 +2887,9 @@ /* Label to show when text labels are enabled. */ TOOL_BAR_ITEM_LABEL, + /* If we shall show the label only below the icon and not beside it. */ + TOOL_BAR_ITEM_VERT_ONLY, + /* Sentinel = number of slots in tool_bar_items occupied by one tool-bar item. */ TOOL_BAR_ITEM_NSLOTS
--- a/src/gtkutil.c Sat Nov 20 16:35:45 2010 +0200 +++ b/src/gtkutil.c Sat Nov 20 15:51:25 2010 +0100 @@ -4059,7 +4059,8 @@ GtkWidget *wimage, GtkWidget **wbutton, const char *label, - int i) + int i, + int vert_only) { GtkToolItem *ti = gtk_tool_item_new (); Lisp_Object style = Ftool_bar_get_system_style (); @@ -4071,6 +4072,10 @@ GtkWidget *wb = gtk_button_new (); GtkWidget *weventbox = gtk_event_box_new (); + /* We are not letting Gtk+ alter display on this, we only keep it here + so we can get it later in xg_show_toolbar_item. */ + gtk_tool_item_set_is_important (ti, !vert_only); + if (wimage && ! text_image) gtk_box_pack_start (GTK_BOX (vb), wimage, TRUE, TRUE, 0); @@ -4144,7 +4149,8 @@ int text_image = EQ (style, Qtext_image_horiz); int horiz = both_horiz || text_image; - int show_label = ! EQ (style, Qimage); + int vert_only = ! gtk_tool_item_get_is_important (ti); + int show_label = ! EQ (style, Qimage) && ! (vert_only && horiz); int show_image = ! EQ (style, Qtext); GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (ti)); @@ -4301,7 +4307,8 @@ Lisp_Object specified_file; const char *label = (STRINGP (PROP (TOOL_BAR_ITEM_LABEL)) ? SSDATA (PROP (TOOL_BAR_ITEM_LABEL)) : ""); - + int vert_only = ! NILP (PROP (TOOL_BAR_ITEM_VERT_ONLY)); + ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (wtoolbar), i); if (ti) @@ -4391,7 +4398,7 @@ else { /* Insert an empty (non-image) button */ - ti = xg_make_tool_item (f, NULL, NULL, "", i); + ti = xg_make_tool_item (f, NULL, NULL, "", i, 0); gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, -1); } continue; @@ -4425,7 +4432,7 @@ } gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin); - ti = xg_make_tool_item (f, w, &wbutton, label, i); + ti = xg_make_tool_item (f, w, &wbutton, label, i, vert_only); gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, -1); gtk_widget_set_sensitive (wbutton, enabled_p); } @@ -4442,6 +4449,7 @@ gpointer old_icon_name = g_object_get_data (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME); gtk_label_set_text (GTK_LABEL (wlbl), label); + gtk_tool_item_set_is_important (ti, !vert_only); if (stock_name && (! old_stock_name || strcmp (old_stock_name, stock_name) != 0)) {
--- a/src/keyboard.c Sat Nov 20 16:35:45 2010 +0200 +++ b/src/keyboard.c Sat Nov 20 15:51:25 2010 +0100 @@ -489,10 +489,10 @@ Lisp_Object Qevent_kind; Lisp_Object Qevent_symbol_elements; -/* menu item parts */ +/* menu and tool bar item parts */ Lisp_Object Qmenu_enable; Lisp_Object QCenable, QCvisible, QChelp, QCfilter, QCkeys, QCkey_sequence; -Lisp_Object QCbutton, QCtoggle, QCradio, QClabel; +Lisp_Object QCbutton, QCtoggle, QCradio, QClabel, QCvert_only; /* An event header symbol HEAD may have a property named Qevent_symbol_element_mask, which is of the form (BASE MODIFIERS); @@ -8269,9 +8269,12 @@ if (NILP (menu_item_eval_property (value))) return 0; } - else if (EQ (key, QChelp)) + else if (EQ (key, QChelp)) /* `:help HELP-STRING'. */ PROP (TOOL_BAR_ITEM_HELP) = value; + else if (EQ (key, QCvert_only)) + /* `:vert-only t/nil'. */ + PROP (TOOL_BAR_ITEM_VERT_ONLY) = value; else if (EQ (key, QClabel)) { const char *bad_label = "!!?GARBLED ITEM?!!"; @@ -11629,6 +11632,8 @@ staticpro (&QCradio); QClabel = intern_c_string (":label"); staticpro (&QClabel); + QCvert_only = intern_c_string (":vert-only"); + staticpro (&QCvert_only); Qmode_line = intern_c_string ("mode-line"); staticpro (&Qmode_line);