diff options
| author | Jan Djärv | 2010-07-29 18:49:59 +0200 |
|---|---|---|
| committer | Jan Djärv | 2010-07-29 18:49:59 +0200 |
| commit | bfeabdc3d7568d08491eb3eab7249bc6c2c24af3 (patch) | |
| tree | 8d91481669f60b8507911afe7182975c057d53fd /src/gtkutil.c | |
| parent | 063e52940d4d97fe372f226c895d6d0f9d87f5d4 (diff) | |
| download | emacs-bfeabdc3d7568d08491eb3eab7249bc6c2c24af3.tar.gz emacs-bfeabdc3d7568d08491eb3eab7249bc6c2c24af3.zip | |
Add ability to put Gtk+ tool bar on the left/right/bottom or top. Default top.
* lisp/menu-bar.el (menu-bar-showhide-tool-bar-menu-customize-enable-left)
(menu-bar-showhide-tool-bar-menu-customize-disable)
(menu-bar-showhide-tool-bar-menu-customize-enable-right)
(menu-bar-showhide-tool-bar-menu-customize-enable-top)
(menu-bar-showhide-tool-bar-menu-customize-enable-bottom): New functions
(menu-bar-showhide-tool-bar-menu): If tool bar is moveable,
make a menu for Options => toolbar that can move it.
* src/frame.c (Qtool_bar_position): New variable.
(make_frame): Set tool_bar_position to Qtop.
(frame_parms): Add tool-bar-position.
(x_report_frame_params): Store tool_bar_position.
(x_set_fringe_width): Reset wm size hint after fringe changes.
* src/frame.h (struct frame): Add tool_bar_position.
(Qbottom): Declare.
* src/gtkutil.c (FRAME_TOTAL_PIXEL_WIDTH): New macro.
(xg_frame_set_char_size): Add FRAME_TOOLBAR_WIDTH to pixelwidth.
(xg_height_or_width_changed): Use FRAME_TOTAL_PIXEL_WIDTH.
(xg_create_frame_widgets): Create a hobox for placing widgets
vertically. Use gtk_box_pack_start.
(xg_height_or_width_changed): Renamed from xg_height_changed.
(x_wm_set_size_hint): Add FRAME_TOOLBAR_WIDTH to base_width.
(xg_update_frame_menubar, free_frame_menubar): Change to
xg_height_or_width_changed.
(xg_tool_bar_detach_callback): Update left/right/top/bottom tool bar
size correctly. Remove hardcoded 4, instead use handlebox size -
toolbar size.
(xg_tool_bar_attach_callback): Update left/right/top/bottom tool bar
size correctly. Use handlebox size + toolbar size as additional
size.
(xg_pack_tool_bar): POS is a new parameter.
Set orientation of tool bar based on pos.
Only make handlebox_widget if NULL.
Check if tool bar goes to vbox or hbox depending on pos.
(xg_update_tool_bar_sizes): New function.
(update_frame_tool_bar): Remove old_req, new_req. Do not get tool bar
height, call xg_update_tool_bar_sizes instead.
(free_frame_tool_bar): Remove from hbox or vbox depending on
toolbar_in_hbox, Set all FRAME_TOOLBAR_*_(WIDTH|HEIGHT) to zero.
(xg_change_toolbar_position): New function.
* src/gtkutil.h (xg_change_toolbar_position): Declare.
* src/window.c (calc_absolute_offset): Check for FRAME_TOOLBAR_TOP_HEIGHT
and FRAME_TOOLBAR_LEFT_WIDTH.
* src/xfns.c (x_set_tool_bar_position): New function.
(xic_set_statusarea): Use FRAME_TOOLBAR_TOP_HEIGHT.
(x_frame_parm_handlers): Add x_set_tool_bar_position.
(syms_of_xfns): if USE_GTK, provide move-toolbar.
* src/xterm.c (x_set_window_size_1): Add FRAME_TOOLBAR_WIDTH to pixelwidth.
* src/xterm.h (struct x_output): Add toolbar_top_height,
toolbar_bottom_height, toolbar_left_width, toolbar_right_width. Remove
toolbar_height.
if USE_GTK: Add hbox_widget and toolbar_in_hbox.
(FRAME_TOOLBAR_TOP_HEIGHT, FRAME_TOOLBAR_BOTTOM_HEIGHT)
(FRAME_TOOLBAR_LEFT_WIDTH, FRAME_TOOLBAR_RIGHT_WIDTH): New macros.
(FRAME_TOOLBAR_HEIGHT): Is now TOP_HEIGHT + BOTTOM_HEIGHT.
Diffstat (limited to 'src/gtkutil.c')
| -rw-r--r-- | src/gtkutil.c | 248 |
1 files changed, 184 insertions, 64 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index 3fb05ba1348..b31eb2d21f2 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -44,6 +44,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 44 | #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ | 44 | #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ |
| 45 | (FRAME_PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f)) | 45 | (FRAME_PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f)) |
| 46 | 46 | ||
| 47 | #define FRAME_TOTAL_PIXEL_WIDTH(f) \ | ||
| 48 | (FRAME_PIXEL_WIDTH (f) + FRAME_TOOLBAR_WIDTH (f)) | ||
| 49 | |||
| 47 | /* Avoid "differ in sign" warnings */ | 50 | /* Avoid "differ in sign" warnings */ |
| 48 | #define SSDATA(x) ((char *) SDATA (x)) | 51 | #define SSDATA(x) ((char *) SDATA (x)) |
| 49 | 52 | ||
| @@ -640,7 +643,8 @@ xg_frame_set_char_size (FRAME_PTR f, int cols, int rows) | |||
| 640 | 643 | ||
| 641 | /* FRAME_TEXT_COLS_TO_PIXEL_WIDTH uses scroll_bar_actual_width, so call it | 644 | /* FRAME_TEXT_COLS_TO_PIXEL_WIDTH uses scroll_bar_actual_width, so call it |
| 642 | after calculating that value. */ | 645 | after calculating that value. */ |
| 643 | pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); | 646 | pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols) |
| 647 | + FRAME_TOOLBAR_WIDTH (f); | ||
| 644 | 648 | ||
| 645 | 649 | ||
| 646 | /* Do this before resize, as we don't know yet if we will be resized. */ | 650 | /* Do this before resize, as we don't know yet if we will be resized. */ |
| @@ -677,14 +681,15 @@ xg_frame_set_char_size (FRAME_PTR f, int cols, int rows) | |||
| 677 | } | 681 | } |
| 678 | } | 682 | } |
| 679 | 683 | ||
| 680 | /* Handle height changes (i.e. add/remove menu/toolbar). | 684 | /* Handle height/width changes (i.e. add/remove/move menu/toolbar). |
| 681 | The policy is to keep the number of editable lines. */ | 685 | The policy is to keep the number of editable lines. */ |
| 682 | 686 | ||
| 683 | static void | 687 | static void |
| 684 | xg_height_changed (FRAME_PTR f) | 688 | xg_height_or_width_changed (FRAME_PTR f) |
| 685 | { | 689 | { |
| 686 | gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | 690 | gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), |
| 687 | FRAME_PIXEL_WIDTH (f), FRAME_TOTAL_PIXEL_HEIGHT (f)); | 691 | FRAME_TOTAL_PIXEL_WIDTH (f), |
| 692 | FRAME_TOTAL_PIXEL_HEIGHT (f)); | ||
| 688 | f->output_data.x->hint_flags = 0; | 693 | f->output_data.x->hint_flags = 0; |
| 689 | x_wm_set_size_hint (f, 0, 0); | 694 | x_wm_set_size_hint (f, 0, 0); |
| 690 | } | 695 | } |
| @@ -733,7 +738,7 @@ int | |||
| 733 | xg_create_frame_widgets (FRAME_PTR f) | 738 | xg_create_frame_widgets (FRAME_PTR f) |
| 734 | { | 739 | { |
| 735 | GtkWidget *wtop; | 740 | GtkWidget *wtop; |
| 736 | GtkWidget *wvbox; | 741 | GtkWidget *wvbox, *whbox; |
| 737 | GtkWidget *wfixed; | 742 | GtkWidget *wfixed; |
| 738 | GdkColor bg; | 743 | GdkColor bg; |
| 739 | GtkRcStyle *style; | 744 | GtkRcStyle *style; |
| @@ -749,12 +754,14 @@ xg_create_frame_widgets (FRAME_PTR f) | |||
| 749 | xg_set_screen (wtop, f); | 754 | xg_set_screen (wtop, f); |
| 750 | 755 | ||
| 751 | wvbox = gtk_vbox_new (FALSE, 0); | 756 | wvbox = gtk_vbox_new (FALSE, 0); |
| 757 | whbox = gtk_hbox_new (FALSE, 0); | ||
| 752 | wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */ | 758 | wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */ |
| 753 | 759 | ||
| 754 | if (! wtop || ! wvbox || ! wfixed) | 760 | if (! wtop || ! wvbox || ! whbox || ! wfixed) |
| 755 | { | 761 | { |
| 756 | if (wtop) gtk_widget_destroy (wtop); | 762 | if (wtop) gtk_widget_destroy (wtop); |
| 757 | if (wvbox) gtk_widget_destroy (wvbox); | 763 | if (wvbox) gtk_widget_destroy (wvbox); |
| 764 | if (whbox) gtk_widget_destroy (whbox); | ||
| 758 | if (wfixed) gtk_widget_destroy (wfixed); | 765 | if (wfixed) gtk_widget_destroy (wfixed); |
| 759 | 766 | ||
| 760 | UNBLOCK_INPUT; | 767 | UNBLOCK_INPUT; |
| @@ -775,11 +782,13 @@ xg_create_frame_widgets (FRAME_PTR f) | |||
| 775 | FRAME_GTK_OUTER_WIDGET (f) = wtop; | 782 | FRAME_GTK_OUTER_WIDGET (f) = wtop; |
| 776 | FRAME_GTK_WIDGET (f) = wfixed; | 783 | FRAME_GTK_WIDGET (f) = wfixed; |
| 777 | f->output_data.x->vbox_widget = wvbox; | 784 | f->output_data.x->vbox_widget = wvbox; |
| 785 | f->output_data.x->hbox_widget = whbox; | ||
| 778 | 786 | ||
| 779 | gtk_widget_set_has_window (wfixed, TRUE); | 787 | gtk_widget_set_has_window (wfixed, TRUE); |
| 780 | 788 | ||
| 781 | gtk_container_add (GTK_CONTAINER (wtop), wvbox); | 789 | gtk_container_add (GTK_CONTAINER (wtop), wvbox); |
| 782 | gtk_box_pack_end (GTK_BOX (wvbox), wfixed, TRUE, TRUE, 0); | 790 | gtk_box_pack_start (GTK_BOX (wvbox), whbox, TRUE, TRUE, 0); |
| 791 | gtk_box_pack_start (GTK_BOX (whbox), wfixed, TRUE, TRUE, 0); | ||
| 783 | 792 | ||
| 784 | if (FRAME_EXTERNAL_TOOL_BAR (f)) | 793 | if (FRAME_EXTERNAL_TOOL_BAR (f)) |
| 785 | update_frame_tool_bar (f); | 794 | update_frame_tool_bar (f); |
| @@ -889,7 +898,7 @@ x_wm_set_size_hint (FRAME_PTR f, long int flags, int user_position) | |||
| 889 | size_hints.height_inc = FRAME_LINE_HEIGHT (f); | 898 | size_hints.height_inc = FRAME_LINE_HEIGHT (f); |
| 890 | 899 | ||
| 891 | hint_flags |= GDK_HINT_BASE_SIZE; | 900 | hint_flags |= GDK_HINT_BASE_SIZE; |
| 892 | base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0); | 901 | base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0) + FRAME_TOOLBAR_WIDTH (f); |
| 893 | base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0) | 902 | base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0) |
| 894 | + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); | 903 | + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); |
| 895 | 904 | ||
| @@ -2828,7 +2837,7 @@ xg_update_frame_menubar (FRAME_PTR f) | |||
| 2828 | gtk_widget_show_all (x->menubar_widget); | 2837 | gtk_widget_show_all (x->menubar_widget); |
| 2829 | gtk_widget_size_request (x->menubar_widget, &req); | 2838 | gtk_widget_size_request (x->menubar_widget, &req); |
| 2830 | FRAME_MENUBAR_HEIGHT (f) = req.height; | 2839 | FRAME_MENUBAR_HEIGHT (f) = req.height; |
| 2831 | xg_height_changed (f); | 2840 | xg_height_or_width_changed (f); |
| 2832 | UNBLOCK_INPUT; | 2841 | UNBLOCK_INPUT; |
| 2833 | 2842 | ||
| 2834 | return 1; | 2843 | return 1; |
| @@ -2851,7 +2860,7 @@ free_frame_menubar (FRAME_PTR f) | |||
| 2851 | the container. */ | 2860 | the container. */ |
| 2852 | x->menubar_widget = 0; | 2861 | x->menubar_widget = 0; |
| 2853 | FRAME_MENUBAR_HEIGHT (f) = 0; | 2862 | FRAME_MENUBAR_HEIGHT (f) = 0; |
| 2854 | xg_height_changed (f); | 2863 | xg_height_or_width_changed (f); |
| 2855 | UNBLOCK_INPUT; | 2864 | UNBLOCK_INPUT; |
| 2856 | } | 2865 | } |
| 2857 | } | 2866 | } |
| @@ -3548,13 +3557,21 @@ xg_tool_bar_detach_callback (GtkHandleBox *wbox, | |||
| 3548 | 3557 | ||
| 3549 | if (f) | 3558 | if (f) |
| 3550 | { | 3559 | { |
| 3560 | GtkRequisition req, req2; | ||
| 3551 | FRAME_X_OUTPUT (f)->toolbar_detached = 1; | 3561 | FRAME_X_OUTPUT (f)->toolbar_detached = 1; |
| 3552 | 3562 | gtk_widget_size_request (GTK_WIDGET (wbox), &req); | |
| 3553 | /* When detaching a tool bar, not everything dissapear. There are | 3563 | gtk_widget_size_request (w, &req2); |
| 3554 | a few pixels left that are used to drop the tool bar back into | 3564 | req.width -= req2.width; |
| 3555 | place. */ | 3565 | req.height -= req2.height; |
| 3556 | FRAME_TOOLBAR_HEIGHT (f) = 4; | 3566 | if (FRAME_TOOLBAR_TOP_HEIGHT (f) != 0) |
| 3557 | xg_height_changed (f); | 3567 | FRAME_TOOLBAR_TOP_HEIGHT (f) = req.height; |
| 3568 | else if (FRAME_TOOLBAR_BOTTOM_HEIGHT (f) != 0) | ||
| 3569 | FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = req.height; | ||
| 3570 | else if (FRAME_TOOLBAR_RIGHT_WIDTH (f) != 0) | ||
| 3571 | FRAME_TOOLBAR_RIGHT_WIDTH (f) = req.width; | ||
| 3572 | else if (FRAME_TOOLBAR_LEFT_WIDTH (f) != 0) | ||
| 3573 | FRAME_TOOLBAR_LEFT_WIDTH (f) = req.width; | ||
| 3574 | xg_height_or_width_changed (f); | ||
| 3558 | } | 3575 | } |
| 3559 | } | 3576 | } |
| 3560 | 3577 | ||
| @@ -3575,13 +3592,21 @@ xg_tool_bar_attach_callback (GtkHandleBox *wbox, | |||
| 3575 | 3592 | ||
| 3576 | if (f) | 3593 | if (f) |
| 3577 | { | 3594 | { |
| 3578 | GtkRequisition req; | 3595 | GtkRequisition req, req2; |
| 3579 | |||
| 3580 | FRAME_X_OUTPUT (f)->toolbar_detached = 0; | 3596 | FRAME_X_OUTPUT (f)->toolbar_detached = 0; |
| 3581 | 3597 | gtk_widget_size_request (GTK_WIDGET (wbox), &req); | |
| 3582 | gtk_widget_size_request (w, &req); | 3598 | gtk_widget_size_request (w, &req2); |
| 3583 | FRAME_TOOLBAR_HEIGHT (f) = req.height; | 3599 | req.width += req2.width; |
| 3584 | xg_height_changed (f); | 3600 | req.height += req2.height; |
| 3601 | if (FRAME_TOOLBAR_TOP_HEIGHT (f) != 0) | ||
| 3602 | FRAME_TOOLBAR_TOP_HEIGHT (f) = req.height; | ||
| 3603 | else if (FRAME_TOOLBAR_BOTTOM_HEIGHT (f) != 0) | ||
| 3604 | FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = req.height; | ||
| 3605 | else if (FRAME_TOOLBAR_RIGHT_WIDTH (f) != 0) | ||
| 3606 | FRAME_TOOLBAR_RIGHT_WIDTH (f) = req.width; | ||
| 3607 | else if (FRAME_TOOLBAR_LEFT_WIDTH (f) != 0) | ||
| 3608 | FRAME_TOOLBAR_LEFT_WIDTH (f) = req.width; | ||
| 3609 | xg_height_or_width_changed (f); | ||
| 3585 | } | 3610 | } |
| 3586 | } | 3611 | } |
| 3587 | 3612 | ||
| @@ -3656,41 +3681,63 @@ xg_tool_bar_item_expose_callback (GtkWidget *w, | |||
| 3656 | return FALSE; | 3681 | return FALSE; |
| 3657 | } | 3682 | } |
| 3658 | 3683 | ||
| 3684 | #ifdef HAVE_GTK_ORIENTABLE_SET_ORIENTATION | ||
| 3685 | #define toolbar_set_orientation(w, o) \ | ||
| 3686 | gtk_orientable_set_orientation (GTK_ORIENTABLE (w), o) | ||
| 3687 | #else | ||
| 3688 | #define toolbar_set_orientation(w, o) \ | ||
| 3689 | gtk_toolbar_set_orientation (GTK_TOOLBAR (w), o) | ||
| 3690 | #endif | ||
| 3691 | |||
| 3659 | /* Attach a tool bar to frame F. */ | 3692 | /* Attach a tool bar to frame F. */ |
| 3660 | 3693 | ||
| 3661 | static void | 3694 | static void |
| 3662 | xg_pack_tool_bar (FRAME_PTR f) | 3695 | xg_pack_tool_bar (FRAME_PTR f, Lisp_Object pos) |
| 3663 | { | 3696 | { |
| 3664 | struct x_output *x = f->output_data.x; | 3697 | struct x_output *x = f->output_data.x; |
| 3665 | int vbox_pos = x->menubar_widget ? 1 : 0; | 3698 | int into_hbox = EQ (pos, Qleft) || EQ (pos, Qright); |
| 3666 | |||
| 3667 | x->handlebox_widget = gtk_handle_box_new (); | ||
| 3668 | g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", | ||
| 3669 | G_CALLBACK (xg_tool_bar_detach_callback), f); | ||
| 3670 | g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", | ||
| 3671 | G_CALLBACK (xg_tool_bar_attach_callback), f); | ||
| 3672 | |||
| 3673 | gtk_container_add (GTK_CONTAINER (x->handlebox_widget), | ||
| 3674 | x->toolbar_widget); | ||
| 3675 | |||
| 3676 | gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget, | ||
| 3677 | FALSE, FALSE, 0); | ||
| 3678 | 3699 | ||
| 3679 | gtk_box_reorder_child (GTK_BOX (x->vbox_widget), x->handlebox_widget, | 3700 | toolbar_set_orientation (x->toolbar_widget, |
| 3680 | vbox_pos); | 3701 | into_hbox |
| 3702 | ? GTK_ORIENTATION_VERTICAL | ||
| 3703 | : GTK_ORIENTATION_HORIZONTAL); | ||
| 3704 | if (!x->handlebox_widget) | ||
| 3705 | { | ||
| 3706 | x->handlebox_widget = gtk_handle_box_new (); | ||
| 3707 | g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", | ||
| 3708 | G_CALLBACK (xg_tool_bar_detach_callback), f); | ||
| 3709 | g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", | ||
| 3710 | G_CALLBACK (xg_tool_bar_attach_callback), f); | ||
| 3711 | gtk_container_add (GTK_CONTAINER (x->handlebox_widget), | ||
| 3712 | x->toolbar_widget); | ||
| 3713 | } | ||
| 3681 | 3714 | ||
| 3682 | gtk_widget_show (x->toolbar_widget); | 3715 | if (into_hbox) |
| 3683 | gtk_widget_show (x->handlebox_widget); | 3716 | { |
| 3717 | gtk_box_pack_start (GTK_BOX (x->hbox_widget), x->handlebox_widget, | ||
| 3718 | FALSE, FALSE, 0); | ||
| 3719 | |||
| 3720 | if (EQ (pos, Qleft)) | ||
| 3721 | gtk_box_reorder_child (GTK_BOX (x->hbox_widget), | ||
| 3722 | x->handlebox_widget, | ||
| 3723 | 0); | ||
| 3724 | x->toolbar_in_hbox = 1; | ||
| 3725 | } | ||
| 3726 | else | ||
| 3727 | { | ||
| 3728 | int vbox_pos = x->menubar_widget ? 1 : 0; | ||
| 3729 | gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget, | ||
| 3730 | FALSE, FALSE, 0); | ||
| 3731 | |||
| 3732 | if (EQ (pos, Qtop)) | ||
| 3733 | gtk_box_reorder_child (GTK_BOX (x->vbox_widget), | ||
| 3734 | x->handlebox_widget, | ||
| 3735 | vbox_pos); | ||
| 3736 | x->toolbar_in_hbox = 0; | ||
| 3737 | } | ||
| 3684 | } | 3738 | } |
| 3685 | 3739 | ||
| 3686 | /* Create a tool bar for frame F. */ | 3740 | /* Create a tool bar for frame F. */ |
| 3687 | #ifdef HAVE_GTK_ORIENTABLE_SET_ORIENTATION | ||
| 3688 | #define toolbar_set_orientation(w, o) \ | ||
| 3689 | gtk_orientable_set_orientation (GTK_ORIENTABLE (w), o) | ||
| 3690 | #else | ||
| 3691 | #define toolbar_set_orientation(w, o) \ | ||
| 3692 | gtk_toolbar_set_orientation (GTK_TOOLBAR (w), o) | ||
| 3693 | #endif | ||
| 3694 | 3741 | ||
| 3695 | static void | 3742 | static void |
| 3696 | xg_create_tool_bar (FRAME_PTR f) | 3743 | xg_create_tool_bar (FRAME_PTR f) |
| @@ -3875,6 +3922,50 @@ xg_show_toolbar_item (GtkToolItem *ti) | |||
| 3875 | gtk_widget_show (GTK_WIDGET (ti)); | 3922 | gtk_widget_show (GTK_WIDGET (ti)); |
| 3876 | } | 3923 | } |
| 3877 | 3924 | ||
| 3925 | static int | ||
| 3926 | xg_update_tool_bar_sizes (FRAME_PTR f) | ||
| 3927 | { | ||
| 3928 | struct x_output *x = f->output_data.x; | ||
| 3929 | GtkRequisition req; | ||
| 3930 | int nl = 0, nr = 0, nt = 0, nb = 0; | ||
| 3931 | |||
| 3932 | gtk_widget_size_request (GTK_WIDGET (x->handlebox_widget), &req); | ||
| 3933 | if (x->toolbar_in_hbox) | ||
| 3934 | { | ||
| 3935 | int pos; | ||
| 3936 | gtk_container_child_get (GTK_CONTAINER (x->hbox_widget), | ||
| 3937 | x->handlebox_widget, | ||
| 3938 | "position", &pos, NULL); | ||
| 3939 | if (pos == 0) nl = req.width; | ||
| 3940 | else nr = req.width; | ||
| 3941 | } | ||
| 3942 | else | ||
| 3943 | { | ||
| 3944 | int pos; | ||
| 3945 | gtk_container_child_get (GTK_CONTAINER (x->vbox_widget), | ||
| 3946 | x->handlebox_widget, | ||
| 3947 | "position", &pos, NULL); | ||
| 3948 | if (pos == 0 || (pos == 1 && x->menubar_widget)) nt = req.height; | ||
| 3949 | else nb = req.height; | ||
| 3950 | } | ||
| 3951 | |||
| 3952 | if (nl != FRAME_TOOLBAR_LEFT_WIDTH (f) | ||
| 3953 | || nr != FRAME_TOOLBAR_RIGHT_WIDTH (f) | ||
| 3954 | || nt != FRAME_TOOLBAR_TOP_HEIGHT (f) | ||
| 3955 | || nb != FRAME_TOOLBAR_BOTTOM_HEIGHT (f)) | ||
| 3956 | { | ||
| 3957 | FRAME_TOOLBAR_RIGHT_WIDTH (f) = FRAME_TOOLBAR_LEFT_WIDTH (f) | ||
| 3958 | = FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0; | ||
| 3959 | FRAME_TOOLBAR_LEFT_WIDTH (f) = nl; | ||
| 3960 | FRAME_TOOLBAR_RIGHT_WIDTH (f) = nr; | ||
| 3961 | FRAME_TOOLBAR_TOP_HEIGHT (f) = nt; | ||
| 3962 | FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = nb; | ||
| 3963 | return 1; | ||
| 3964 | } | ||
| 3965 | |||
| 3966 | return 0; | ||
| 3967 | } | ||
| 3968 | |||
| 3878 | 3969 | ||
| 3879 | /* Update the tool bar for frame F. Add new buttons and remove old. */ | 3970 | /* Update the tool bar for frame F. Add new buttons and remove old. */ |
| 3880 | 3971 | ||
| @@ -3884,7 +3975,6 @@ void | |||
| 3884 | update_frame_tool_bar (FRAME_PTR f) | 3975 | update_frame_tool_bar (FRAME_PTR f) |
| 3885 | { | 3976 | { |
| 3886 | int i; | 3977 | int i; |
| 3887 | GtkRequisition old_req, new_req; | ||
| 3888 | struct x_output *x = f->output_data.x; | 3978 | struct x_output *x = f->output_data.x; |
| 3889 | int hmargin = 0, vmargin = 0; | 3979 | int hmargin = 0, vmargin = 0; |
| 3890 | GtkToolbar *wtoolbar; | 3980 | GtkToolbar *wtoolbar; |
| @@ -3925,7 +4015,6 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 3925 | xg_create_tool_bar (f); | 4015 | xg_create_tool_bar (f); |
| 3926 | 4016 | ||
| 3927 | wtoolbar = GTK_TOOLBAR (x->toolbar_widget); | 4017 | wtoolbar = GTK_TOOLBAR (x->toolbar_widget); |
| 3928 | gtk_widget_size_request (GTK_WIDGET (wtoolbar), &old_req); | ||
| 3929 | dir = gtk_widget_get_direction (GTK_WIDGET (wtoolbar)); | 4018 | dir = gtk_widget_get_direction (GTK_WIDGET (wtoolbar)); |
| 3930 | 4019 | ||
| 3931 | for (i = 0; i < f->n_tool_bar_items; ++i) | 4020 | for (i = 0; i < f->n_tool_bar_items; ++i) |
| @@ -4143,18 +4232,16 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 4143 | if (ti) gtk_widget_hide_all (GTK_WIDGET (ti)); | 4232 | if (ti) gtk_widget_hide_all (GTK_WIDGET (ti)); |
| 4144 | } while (ti != NULL); | 4233 | } while (ti != NULL); |
| 4145 | 4234 | ||
| 4146 | new_req.height = 0; | 4235 | if (f->n_tool_bar_items != 0) |
| 4147 | if (pack_tool_bar && f->n_tool_bar_items != 0) | ||
| 4148 | xg_pack_tool_bar (f); | ||
| 4149 | |||
| 4150 | |||
| 4151 | gtk_widget_size_request (GTK_WIDGET (wtoolbar), &new_req); | ||
| 4152 | if (old_req.height != new_req.height | ||
| 4153 | && ! FRAME_X_OUTPUT (f)->toolbar_detached) | ||
| 4154 | { | 4236 | { |
| 4155 | FRAME_TOOLBAR_HEIGHT (f) = new_req.height; | 4237 | if (pack_tool_bar) |
| 4156 | xg_height_changed (f); | 4238 | xg_pack_tool_bar (f, f->tool_bar_position); |
| 4239 | gtk_widget_show (x->toolbar_widget); | ||
| 4240 | gtk_widget_show (x->handlebox_widget); | ||
| 4241 | if (xg_update_tool_bar_sizes (f)) | ||
| 4242 | xg_height_or_width_changed (f); | ||
| 4157 | } | 4243 | } |
| 4244 | |||
| 4158 | UNBLOCK_INPUT; | 4245 | UNBLOCK_INPUT; |
| 4159 | } | 4246 | } |
| 4160 | 4247 | ||
| @@ -4172,21 +4259,54 @@ free_frame_tool_bar (FRAME_PTR f) | |||
| 4172 | BLOCK_INPUT; | 4259 | BLOCK_INPUT; |
| 4173 | /* We may have created the toolbar_widget in xg_create_tool_bar, but | 4260 | /* We may have created the toolbar_widget in xg_create_tool_bar, but |
| 4174 | not the x->handlebox_widget which is created in xg_pack_tool_bar. */ | 4261 | not the x->handlebox_widget which is created in xg_pack_tool_bar. */ |
| 4175 | if (is_packed) | 4262 | if (is_packed) |
| 4176 | gtk_container_remove (GTK_CONTAINER (x->vbox_widget), | 4263 | { |
| 4177 | x->handlebox_widget); | 4264 | if (x->toolbar_in_hbox) |
| 4265 | gtk_container_remove (GTK_CONTAINER (x->hbox_widget), | ||
| 4266 | x->handlebox_widget); | ||
| 4267 | else | ||
| 4268 | gtk_container_remove (GTK_CONTAINER (x->vbox_widget), | ||
| 4269 | x->handlebox_widget); | ||
| 4270 | } | ||
| 4178 | else | 4271 | else |
| 4179 | gtk_widget_destroy (x->toolbar_widget); | 4272 | gtk_widget_destroy (x->toolbar_widget); |
| 4180 | 4273 | ||
| 4181 | x->toolbar_widget = 0; | 4274 | x->toolbar_widget = 0; |
| 4182 | x->handlebox_widget = 0; | 4275 | x->handlebox_widget = 0; |
| 4183 | FRAME_TOOLBAR_HEIGHT (f) = 0; | 4276 | FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0; |
| 4184 | xg_height_changed (f); | 4277 | FRAME_TOOLBAR_LEFT_WIDTH (f) = FRAME_TOOLBAR_RIGHT_WIDTH (f) = 0; |
| 4278 | |||
| 4279 | xg_height_or_width_changed (f); | ||
| 4185 | 4280 | ||
| 4186 | UNBLOCK_INPUT; | 4281 | UNBLOCK_INPUT; |
| 4187 | } | 4282 | } |
| 4188 | } | 4283 | } |
| 4189 | 4284 | ||
| 4285 | int | ||
| 4286 | xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos) | ||
| 4287 | { | ||
| 4288 | struct x_output *x = f->output_data.x; | ||
| 4289 | |||
| 4290 | if (! x->toolbar_widget || ! x->handlebox_widget) | ||
| 4291 | return 1; | ||
| 4292 | |||
| 4293 | BLOCK_INPUT; | ||
| 4294 | g_object_ref (x->handlebox_widget); | ||
| 4295 | if (x->toolbar_in_hbox) | ||
| 4296 | gtk_container_remove (GTK_CONTAINER (x->hbox_widget), | ||
| 4297 | x->handlebox_widget); | ||
| 4298 | else | ||
| 4299 | gtk_container_remove (GTK_CONTAINER (x->vbox_widget), | ||
| 4300 | x->handlebox_widget); | ||
| 4301 | xg_pack_tool_bar (f, pos); | ||
| 4302 | g_object_unref (x->handlebox_widget); | ||
| 4303 | if (xg_update_tool_bar_sizes (f)) | ||
| 4304 | xg_height_or_width_changed (f); | ||
| 4305 | |||
| 4306 | UNBLOCK_INPUT; | ||
| 4307 | return 1; | ||
| 4308 | } | ||
| 4309 | |||
| 4190 | 4310 | ||
| 4191 | 4311 | ||
| 4192 | /*********************************************************************** | 4312 | /*********************************************************************** |