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>
* 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."
(defvar custom-commands
'(("Set for current session" Custom-set t
"Apply all settings in this buffer to the current session"
"index")
"index"
"Apply")
("Save for future sessions" Custom-save
(or custom-file user-init-file)
"Apply all settings in this buffer and save them for future Emacs sessions."
"save")
"save"
"Save")
("Undo edits" Custom-reset-current t
"Restore all settings in this buffer to reflect their current values."
"refresh")
"refresh"
"Undo")
("Reset to saved" Custom-reset-saved t
"Restore all settings in this buffer to their saved values (if any)."
"undo")
"undo"
"Reset")
("Erase customizations" Custom-reset-standard
(or custom-file user-init-file)
"Un-customize all settings in this buffer and save them with standard values."
"delete")
"delete"
"Uncustomize")
("Help for Customize" Custom-help t
"Get help for using Customize."
"help")
("Exit" Custom-buffer-done t "Exit Customize." "exit")))
"help"
"Help")
("Exit" Custom-buffer-done t "Exit Customize." "exit" "Exit")))
(defun Custom-help ()
"Read the node on Easy Customization in the Emacs manual."
......@@ -1616,7 +1622,7 @@ Otherwise use brackets."
(if custom-buffer-verbose-help
(widget-insert "
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 " ")
(if (eval active)
(widget-create 'push-button :tag tag
......@@ -4680,7 +4686,8 @@ if that value is non-nil."
(mapc
(lambda (arg)
(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)
(setq custom-tool-bar-map map))))
(make-local-variable 'custom-options)
......
......@@ -339,6 +339,15 @@ since it could result in memory overflow and make Emacs crash."
(const :tag "Off (nil)" :value nil)
(const :tag "Immediate" :value t)
(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
(scalable-fonts-allowed display boolean "22.1")
;; xfns.c
......
;;; font-setting.el --- Support dynamic font changes
;;; dynamic-setting.el --- Support dynamic changes
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
;; Author: Jan Djärv <jan.h.d@swipnet.se>
;; Maintainer: FSF
;; Keywords: font, system-font
;; Keywords: font, system-font, tool-bar-style
;; This file is part of GNU Emacs.
......@@ -81,21 +81,25 @@ current form for the frame (i.e. hinting or somesuch changed)."
(custom-push-theme 'theme-face 'default 'user 'set spec)
(put 'default 'face-modified nil))))))
(defun font-setting-handle-config-changed-event (event)
"Handle config-changed-event to change fonts on the display in EVENT.
If `font-use-system-font' is nil, the font is not changed."
(defun dynamic-setting-handle-config-changed-event (event)
"Handle config-changed-event on the display in EVENT.
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")
(let ((type (nth 1 event)) ;; font-name or font-render
(let ((type (nth 1 event))
(display-name (nth 2 event)))
(if (or (not (eq type 'font-name))
font-use-system-font)
(font-setting-change-default-font display-name
(eq type 'font-name)))))
(cond ((and (eq type 'monospace-font-name) font-use-system-font)
(font-setting-change-default-font display-name t))
(if (or (featurep 'system-font-setting) (featurep 'font-render-setting))
(define-key special-event-map [config-changed-event]
'font-setting-handle-config-changed-event))
((eq type 'font-render)
(font-setting-change-default-font display-name nil))
(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
......@@ -3736,9 +3736,11 @@ If FORK is non-nil, it is passed to `Info-goto-node'."
(defvar info-tool-bar-map
(let ((map (make-sparse-keymap)))
(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
:rtl "left-arrow")
:rtl "left-arrow"
:label "Forward")
(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
......@@ -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-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)
(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-exit "exit" map Info-mode-map)
map))
......
......@@ -203,8 +203,8 @@
(load "dnd")
(load "tool-bar")))
(if (or (featurep 'system-font-setting) (featurep 'font-render-setting))
(load "font-setting"))
(if (featurep 'dynamic-setting)
(load "dynamic-setting"))
(if (featurep 'x)
(progn
......
......@@ -267,7 +267,7 @@ holds a keymap."
;; 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")
(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")
......@@ -294,14 +294,15 @@ holds a keymap."
"paste" nil
:visible '(not (eq 'special (get major-mode
'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")
;; There's no icon appropriate for News and we need a command rather
;; than a lambda for Read Mail.
;;(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
;; (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,
map vc-dir-mode-map)
(tool-bar-local-item "bookmark_add"
'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"
map vc-dir-mode-map
:rtl "right-arrow")
......@@ -313,11 +314,14 @@ If BODY uses EVENT, it should be a variable,
(tool-bar-local-item-from-menu 'revert-buffer "refresh"
map vc-dir-mode-map)
(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
"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"
map vc-dir-mode-map)
map vc-dir-mode-map
:label "Cancel")
(tool-bar-local-item-from-menu 'quit-window "exit"
map vc-dir-mode-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>
* data.c (make_blv): Declarations before code (Bug#5993).
......
......@@ -566,7 +566,7 @@ otherobj= $(termcapobj) lastfile.o $(mallocobj) $(widgetobj) $(LIBOBJS)
${lispsource}international/fontset.elc ${lispsource}dnd.elc \
${lispsource}tool-bar.elc ${lispsource}mwheel.elc ${lispsource}x-dnd.elc \
${lispsource}term/common-win.elc ${lispsource}term/x-win.elc \
${lispsource}font-setting.elc
${lispsource}dynamic-setting.elc
#else
#define WINDOW_SUPPORT ${lispsource}fringe.elc ${lispsource}image.elc \
${lispsource}international/fontset.elc ${lispsource}dnd.elc \
......@@ -801,7 +801,7 @@ SOME_MACHINE_LISP = ../lisp/mouse.elc \
../lisp/tooltip.elc ../lisp/image.elc \
../lisp/fringe.elc ../lisp/dnd.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/fontset.elc \
../lisp/mouse.elc \
......
......@@ -2793,6 +2793,9 @@ enum tool_bar_item_idx
/* Icon file name of right to left image when an RTL locale is used. */
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
tool-bar item. */
TOOL_BAR_ITEM_NSLOTS
......@@ -2814,6 +2817,15 @@ enum tool_bar_item_image
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. */
extern EMACS_INT tool_bar_button_relief;
......
......@@ -3522,7 +3522,16 @@ xg_tool_bar_menu_proxy (toolitem, user_data)
{
GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (toolitem));
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;
if (gtk_button_get_use_stock (wbutton))
......@@ -3530,7 +3539,6 @@ xg_tool_bar_menu_proxy (toolitem, user_data)
GTK_ICON_SIZE_MENU);
else
{
GtkImage *wimage = GTK_IMAGE (gtk_bin_get_child (GTK_BIN (wbutton)));
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (wbutton));
GtkImageType store_type = gtk_image_get_storage_type (wimage);
......@@ -3834,6 +3842,132 @@ find_rtl_image (f, image, rtl)
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. */
extern Lisp_Object Qx_gtk_map_stock;
......@@ -3885,8 +4019,8 @@ update_frame_tool_bar (f)
wtoolbar = GTK_TOOLBAR (x->toolbar_widget);
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)
{
int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P));
......@@ -3904,8 +4038,10 @@ update_frame_tool_bar (f)
GtkWidget *wbutton = NULL;
GtkWidget *weventbox;
Lisp_Object specified_file;
ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i);
Lisp_Object lbl = PROP (TOOL_BAR_ITEM_LABEL);
char *label = SSDATA (PROP (TOOL_BAR_ITEM_LABEL));
ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (wtoolbar), i);
if (ti)
{
......@@ -3913,6 +4049,7 @@ update_frame_tool_bar (f)
wbutton = gtk_bin_get_child (GTK_BIN (weventbox));
}
image = PROP (TOOL_BAR_ITEM_IMAGES);
/* Ignore invalid image specifications. */
......@@ -3944,7 +4081,7 @@ update_frame_tool_bar (f)
icon_size = gtk_toolbar_get_icon_size (wtoolbar);
}
else if (gtk_stock_lookup (SSDATA (stock), &stock_item))
icon_size = gtk_toolbar_get_icon_size (wtoolbar);
icon_size = gtk_toolbar_get_icon_size (wtoolbar);
else
{
stock = Qnil;
......@@ -3988,22 +4125,15 @@ update_frame_tool_bar (f)
if (img->load_failed_p || img->pixmap == None)
{
if (ti)
gtk_widget_hide_all (GTK_WIDGET (ti));
else
if (ti)
gtk_widget_hide_all (GTK_WIDGET (ti));
else
{
/* Insert an empty (non-image) button */
weventbox = gtk_event_box_new ();
wbutton = gtk_button_new ();
gtk_button_set_focus_on_click (GTK_BUTTON (wbutton), FALSE);
gtk_button_set_relief (GTK_BUTTON (wbutton),
GTK_RELIEF_NONE);
gtk_container_add (GTK_CONTAINER (weventbox), wbutton);
ti = gtk_tool_item_new ();
gtk_container_add (GTK_CONTAINER (ti), weventbox);
gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), ti, -1);
/* Insert an empty (non-image) button */
ti = xg_make_tool_item (f, NULL, NULL, "", i);
gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, -1);
}
continue;
continue;
}
}
......@@ -4034,73 +4164,27 @@ update_frame_tool_bar (f)
}
gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin);
wbutton = gtk_button_new ();
gtk_button_set_focus_on_click (GTK_BUTTON (wbutton), FALSE);
gtk_button_set_relief (GTK_BUTTON (wbutton), GTK_RELIEF_NONE);
gtk_container_add (GTK_CONTAINER (wbutton), w);
weventbox = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (weventbox), wbutton);
ti = gtk_tool_item_new ();
gtk_container_add (GTK_CONTAINER (ti), weventbox);
gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), ti, -1);
/* 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 (wbutton), "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);
ti = xg_make_tool_item (f, w, &wbutton, label, i);
gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, -1);
gtk_widget_set_sensitive (wbutton, enabled_p);
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 (wbutton, "button-release-event",
G_CALLBACK (xg_tool_bar_button_cb),
NULL);
g_object_set_data (G_OBJECT (wbutton), 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);
}
else
{
GtkWidget *wimage = gtk_bin_get_child (GTK_BIN (wbutton));
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;
Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage),