aboutsummaryrefslogtreecommitdiffstats
path: root/src/gtkutil.c
diff options
context:
space:
mode:
authorKaroly Lorentey2007-01-01 17:38:32 +0000
committerKaroly Lorentey2007-01-01 17:38:32 +0000
commit65e86587ab836aaa86b12ce30b219bcb4fcbaa06 (patch)
tree7e13feee7387635f52df3613cf1bba4414781aab /src/gtkutil.c
parent8c778e28bcf16b4baef6400a124ec2403941e940 (diff)
parent1fc8c92b50100da709c94a0faa47deed5603634f (diff)
downloademacs-65e86587ab836aaa86b12ce30b219bcb4fcbaa06.tar.gz
emacs-65e86587ab836aaa86b12ce30b219bcb4fcbaa06.zip
Merged from emacs@sv.gnu.org.
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-536 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-537 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-538 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-539 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-540 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-541 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-542 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-543 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-544 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-545 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-546 Update from erc--emacs--22 * emacs@sv.gnu.org/emacs--devo--0--patch-547 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-548 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-549 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-550 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-551 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-552 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-553 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-554 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-555 erc-iswitchb: Temporarily enable iswitchb mode * emacs@sv.gnu.org/emacs--devo--0--patch-556 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-557 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-558 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-559 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-560 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-561 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-562 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-563 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-564 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-565 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-566 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-567 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-568 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-569 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-570 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-571 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-572 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-573 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-574 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-575 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-576 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-577 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-578 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-579 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-580 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-581 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-582 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-583 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-584 Fix admin/quick-install-emacs to work with recent versions of autoconf * emacs@sv.gnu.org/gnus--rel--5.10--patch-171 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-172 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-173 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-174 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-175 Update from CVS: lisp/legacy-gnus-agent.el: Add Copyright notice. * emacs@sv.gnu.org/gnus--rel--5.10--patch-176 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-177 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-178 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-179 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-180 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-181 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-182 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-183 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-184 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-185 Merge from emacs--devo--0 git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-590
Diffstat (limited to 'src/gtkutil.c')
-rw-r--r--src/gtkutil.c210
1 files changed, 151 insertions, 59 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 17bf2d20a4c..d136dbe0fce 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -3350,11 +3350,8 @@ xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
3350 get them. */ 3350 get them. */
3351#define XG_TOOL_BAR_LAST_MODIFIER "emacs-tool-bar-modifier" 3351#define XG_TOOL_BAR_LAST_MODIFIER "emacs-tool-bar-modifier"
3352 3352
3353 3353/* The key for storing the button widget in its proxy menu item. */
3354/* Callback function invoked when a tool bar item is pressed. 3354#define XG_TOOL_BAR_PROXY_BUTTON "emacs-tool-bar-proxy-button"
3355 W is the button widget in the tool bar that got pressed,
3356 CLIENT_DATA is an integer that is the index of the button in the
3357 tool bar. 0 is the first button. */
3358 3355
3359static gboolean 3356static gboolean
3360xg_tool_bar_button_cb (widget, event, user_data) 3357xg_tool_bar_button_cb (widget, event, user_data)
@@ -3364,11 +3361,16 @@ xg_tool_bar_button_cb (widget, event, user_data)
3364{ 3361{
3365 /* Casts to avoid warnings when gpointer is 64 bits and int is 32 bits */ 3362 /* Casts to avoid warnings when gpointer is 64 bits and int is 32 bits */
3366 gpointer ptr = (gpointer) (EMACS_INT) event->state; 3363 gpointer ptr = (gpointer) (EMACS_INT) event->state;
3367 g_object_set_data (G_OBJECT (user_data), XG_TOOL_BAR_LAST_MODIFIER, ptr); 3364 g_object_set_data (G_OBJECT (widget), XG_TOOL_BAR_LAST_MODIFIER, ptr);
3368 return FALSE; 3365 return FALSE;
3369} 3366}
3370 3367
3371 3368
3369/* Callback function invoked when a tool bar item is pressed.
3370 W is the button widget in the tool bar that got pressed,
3371 CLIENT_DATA is an integer that is the index of the button in the
3372 tool bar. 0 is the first button. */
3373
3372static void 3374static void
3373xg_tool_bar_callback (w, client_data) 3375xg_tool_bar_callback (w, client_data)
3374 GtkWidget *w; 3376 GtkWidget *w;
@@ -3406,6 +3408,92 @@ xg_tool_bar_callback (w, client_data)
3406 kbd_buffer_store_event (&event); 3408 kbd_buffer_store_event (&event);
3407} 3409}
3408 3410
3411/* Callback function invoked when a tool bar item is pressed in a detached
3412 tool bar or the overflow drop down menu.
3413 We just call xg_tool_bar_callback.
3414 W is the menu item widget that got pressed,
3415 CLIENT_DATA is an integer that is the index of the button in the
3416 tool bar. 0 is the first button. */
3417
3418static void
3419xg_tool_bar_proxy_callback (w, client_data)
3420 GtkWidget *w;
3421 gpointer client_data;
3422{
3423 GtkWidget *wbutton = GTK_WIDGET (g_object_get_data (G_OBJECT (w),
3424 XG_TOOL_BAR_PROXY_BUTTON));
3425 xg_tool_bar_callback (wbutton, client_data);
3426}
3427
3428/* This callback is called when a tool item should create a proxy item,
3429 such as for the overflow menu. Also called when the tool bar is detached.
3430 If we don't create a proxy menu item, the detached tool bar will be
3431 blank. */
3432
3433static gboolean
3434xg_tool_bar_menu_proxy (toolitem, user_data)
3435 GtkToolItem *toolitem;
3436 gpointer user_data;
3437{
3438 GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (toolitem));
3439 GtkButton *wbutton = GTK_BUTTON (gtk_bin_get_child (GTK_BIN (weventbox)));
3440 GtkWidget *wmenuitem = gtk_image_menu_item_new ();
3441 GtkWidget *wmenuimage;
3442
3443 if (gtk_button_get_use_stock (wbutton))
3444 wmenuimage = gtk_image_new_from_stock (gtk_button_get_label (wbutton),
3445 GTK_ICON_SIZE_MENU);
3446 else
3447 {
3448 GtkImage *wimage = GTK_IMAGE (gtk_bin_get_child (GTK_BIN (wbutton)));
3449 GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (wbutton));
3450 GtkImageType store_type = gtk_image_get_storage_type (wimage);
3451 if (store_type == GTK_IMAGE_STOCK)
3452 {
3453 gchar *stock_id;
3454 gtk_image_get_stock (wimage, &stock_id, NULL);
3455 wmenuimage = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
3456 }
3457 else if (store_type == GTK_IMAGE_ICON_SET)
3458 {
3459 GtkIconSet *icon_set;
3460 gtk_image_get_icon_set (wimage, &icon_set, NULL);
3461 wmenuimage = gtk_image_new_from_icon_set (icon_set,
3462 GTK_ICON_SIZE_MENU);
3463 }
3464 else if (store_type == GTK_IMAGE_PIXBUF)
3465 {
3466 gint width, height;
3467
3468 if (settings &&
3469 gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
3470 &width, &height))
3471 {
3472 GdkPixbuf *src_pixbuf, *dest_pixbuf;
3473
3474 src_pixbuf = gtk_image_get_pixbuf (wimage);
3475 dest_pixbuf = gdk_pixbuf_scale_simple (src_pixbuf, width, height,
3476 GDK_INTERP_BILINEAR);
3477
3478 wmenuimage = gtk_image_new_from_pixbuf (dest_pixbuf);
3479 }
3480 }
3481 }
3482 if (wmenuimage)
3483 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (wmenuitem), wmenuimage);
3484
3485 g_signal_connect (G_OBJECT (wmenuitem),
3486 "activate",
3487 GTK_SIGNAL_FUNC (xg_tool_bar_proxy_callback),
3488 user_data);
3489
3490 g_object_set_data (G_OBJECT (wmenuitem), XG_TOOL_BAR_PROXY_BUTTON,
3491 (gpointer) wbutton);
3492 gtk_tool_item_set_proxy_menu_item (toolitem, "Emacs toolbar item", wmenuitem);
3493
3494 return TRUE;
3495}
3496
3409/* This callback is called when a tool bar is detached. We must set 3497/* This callback is called when a tool bar is detached. We must set
3410 the height of the tool bar to zero when this happens so frame sizes 3498 the height of the tool bar to zero when this happens so frame sizes
3411 are correctly calculated. 3499 are correctly calculated.
@@ -3491,9 +3579,6 @@ xg_tool_bar_help_callback (w, event, client_data)
3491 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA); 3579 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA);
3492 Lisp_Object help, frame; 3580 Lisp_Object help, frame;
3493 3581
3494 if (! GTK_IS_BUTTON (w))
3495 return FALSE;
3496
3497 if (! f || ! f->n_tool_bar_items || NILP (f->tool_bar_items)) 3582 if (! f || ! f->n_tool_bar_items || NILP (f->tool_bar_items))
3498 return FALSE; 3583 return FALSE;
3499 3584
@@ -3631,10 +3716,9 @@ update_frame_tool_bar (f)
3631{ 3716{
3632 int i; 3717 int i;
3633 GtkRequisition old_req, new_req; 3718 GtkRequisition old_req, new_req;
3634 GList *icon_list;
3635 GList *iter;
3636 struct x_output *x = f->output_data.x; 3719 struct x_output *x = f->output_data.x;
3637 int hmargin, vmargin; 3720 int hmargin, vmargin;
3721 GtkToolItem *ti;
3638 3722
3639 if (! FRAME_GTK_WIDGET (f)) 3723 if (! FRAME_GTK_WIDGET (f))
3640 return; 3724 return;
@@ -3670,9 +3754,6 @@ update_frame_tool_bar (f)
3670 3754
3671 gtk_widget_size_request (x->toolbar_widget, &old_req); 3755 gtk_widget_size_request (x->toolbar_widget, &old_req);
3672 3756
3673 icon_list = gtk_container_get_children (GTK_CONTAINER (x->toolbar_widget));
3674 iter = icon_list;
3675
3676 for (i = 0; i < f->n_tool_bar_items; ++i) 3757 for (i = 0; i < f->n_tool_bar_items; ++i)
3677 { 3758 {
3678#define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) 3759#define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX))
@@ -3683,9 +3764,16 @@ update_frame_tool_bar (f)
3683 int img_id; 3764 int img_id;
3684 struct image *img; 3765 struct image *img;
3685 Lisp_Object image; 3766 Lisp_Object image;
3686 GtkWidget *wicon = iter ? GTK_WIDGET (iter->data) : 0; 3767 GtkWidget *wbutton;
3768 GtkWidget *weventbox;
3687 3769
3688 if (iter) iter = g_list_next (iter); 3770 ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i);
3771
3772 if (ti)
3773 {
3774 weventbox = gtk_bin_get_child (GTK_BIN (ti));
3775 wbutton = gtk_bin_get_child (GTK_BIN (weventbox));
3776 }
3689 3777
3690 /* If image is a vector, choose the image according to the 3778 /* If image is a vector, choose the image according to the
3691 button state. */ 3779 button state. */
@@ -3710,7 +3798,7 @@ update_frame_tool_bar (f)
3710 /* Ignore invalid image specifications. */ 3798 /* Ignore invalid image specifications. */
3711 if (!valid_image_p (image)) 3799 if (!valid_image_p (image))
3712 { 3800 {
3713 if (wicon) gtk_widget_hide (wicon); 3801 if (ti) gtk_widget_hide_all (GTK_WIDGET (ti));
3714 continue; 3802 continue;
3715 } 3803 }
3716 3804
@@ -3720,39 +3808,55 @@ update_frame_tool_bar (f)
3720 3808
3721 if (img->load_failed_p || img->pixmap == None) 3809 if (img->load_failed_p || img->pixmap == None)
3722 { 3810 {
3723 if (wicon) 3811 if (ti)
3724 gtk_widget_hide (wicon); 3812 gtk_widget_hide_all (GTK_WIDGET (ti));
3725 else 3813 else
3726 gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), 3814 {
3727 gtk_tool_button_new (NULL, ""), 3815 /* Insert an empty (non-image) button */
3728 i); 3816 weventbox = gtk_event_box_new ();
3817 wbutton = gtk_button_new ();
3818 gtk_button_set_focus_on_click (GTK_BUTTON (wbutton), FALSE);
3819 gtk_button_set_relief (GTK_BUTTON (wbutton), GTK_RELIEF_NONE);
3820 gtk_container_add (GTK_CONTAINER (weventbox), wbutton);
3821 ti = gtk_tool_item_new ();
3822 gtk_container_add (GTK_CONTAINER (ti), weventbox);
3823 gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), ti, i);
3824 }
3729 continue; 3825 continue;
3730 } 3826 }
3731 3827
3732 if (! wicon) 3828 if (ti == NULL)
3733 { 3829 {
3734 GtkWidget *w = xg_get_image_for_pixmap (f, img, x->widget, NULL); 3830 GtkWidget *w = xg_get_image_for_pixmap (f, img, x->widget, NULL);
3735 GtkToolItem *ti = gtk_tool_button_new (w, "");
3736
3737 gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin); 3831 gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin);
3832 wbutton = gtk_button_new ();
3833 gtk_button_set_focus_on_click (GTK_BUTTON (wbutton), FALSE);
3834 gtk_button_set_relief (GTK_BUTTON (wbutton), GTK_RELIEF_NONE);
3835 gtk_container_add (GTK_CONTAINER (wbutton), w);
3836 weventbox = gtk_event_box_new ();
3837 gtk_container_add (GTK_CONTAINER (weventbox), wbutton);
3838 ti = gtk_tool_item_new ();
3839 gtk_container_add (GTK_CONTAINER (ti), weventbox);
3840 gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), ti, i);
3841
3738 3842
3739 gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget),
3740 ti,
3741 i);
3742 /* The EMACS_INT cast avoids a warning. */ 3843 /* The EMACS_INT cast avoids a warning. */
3743 g_signal_connect (GTK_WIDGET (ti), "clicked", 3844 g_signal_connect (G_OBJECT (ti), "create-menu-proxy",
3845 GTK_SIGNAL_FUNC (xg_tool_bar_menu_proxy),
3846 (gpointer) (EMACS_INT) i);
3847
3848 g_signal_connect (G_OBJECT (wbutton), "clicked",
3744 GTK_SIGNAL_FUNC (xg_tool_bar_callback), 3849 GTK_SIGNAL_FUNC (xg_tool_bar_callback),
3745 (gpointer) (EMACS_INT) i); 3850 (gpointer) (EMACS_INT) i);
3746 3851
3747 gtk_widget_show (GTK_WIDGET (ti)); 3852 gtk_widget_show_all (GTK_WIDGET (ti));
3748 gtk_widget_show (GTK_WIDGET (w));
3749 3853
3750 /* Save the image so we can see if an update is needed when 3854 /* Save the image so we can see if an update is needed when
3751 this function is called again. */ 3855 this function is called again. */
3752 g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA, 3856 g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA,
3753 (gpointer)img->pixmap); 3857 (gpointer)img->pixmap);
3754 3858
3755 g_object_set_data (G_OBJECT (ti), XG_FRAME_DATA, (gpointer)f); 3859 g_object_set_data (G_OBJECT (weventbox), XG_FRAME_DATA, (gpointer)f);
3756 3860
3757 /* Catch expose events to overcome an annoying redraw bug, see 3861 /* Catch expose events to overcome an annoying redraw bug, see
3758 comment for xg_tool_bar_item_expose_callback. */ 3862 comment for xg_tool_bar_item_expose_callback. */
@@ -3761,46 +3865,37 @@ update_frame_tool_bar (f)
3761 G_CALLBACK (xg_tool_bar_item_expose_callback), 3865 G_CALLBACK (xg_tool_bar_item_expose_callback),
3762 0); 3866 0);
3763 3867
3764 gtk_widget_set_sensitive (GTK_WIDGET (ti), enabled_p); 3868 gtk_widget_set_sensitive (wbutton, enabled_p);
3765 gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (ti), FALSE); 3869 gtk_tool_item_set_homogeneous (ti, FALSE);
3766 3870
3767 while (! GTK_IS_BUTTON (w))
3768 w = gtk_widget_get_parent (w);
3769
3770 /* Callback to save modifyer mask (Shift/Control, etc). GTK makes 3871 /* Callback to save modifyer mask (Shift/Control, etc). GTK makes
3771 no distinction based on modifiers in the activate callback, 3872 no distinction based on modifiers in the activate callback,
3772 so we have to do it ourselves. */ 3873 so we have to do it ourselves. */
3773 g_signal_connect (w, "button-release-event", 3874 g_signal_connect (wbutton, "button-release-event",
3774 GTK_SIGNAL_FUNC (xg_tool_bar_button_cb), 3875 GTK_SIGNAL_FUNC (xg_tool_bar_button_cb),
3775 ti); 3876 NULL);
3776 3877
3777 g_object_set_data (G_OBJECT (w), XG_FRAME_DATA, (gpointer)f); 3878 g_object_set_data (G_OBJECT (wbutton), XG_FRAME_DATA, (gpointer)f);
3778 3879
3779 /* Use enter/leave notify to show help. We use the events 3880 /* Use enter/leave notify to show help. We use the events
3780 rather than the GtkButton specific signals "enter" and 3881 rather than the GtkButton specific signals "enter" and
3781 "leave", so we can have only one callback. The event 3882 "leave", so we can have only one callback. The event
3782 will tell us what kind of event it is. */ 3883 will tell us what kind of event it is. */
3783 /* The EMACS_INT cast avoids a warning. */ 3884 /* The EMACS_INT cast avoids a warning. */
3784 g_signal_connect (G_OBJECT (w), 3885 g_signal_connect (G_OBJECT (weventbox),
3785 "enter-notify-event", 3886 "enter-notify-event",
3786 G_CALLBACK (xg_tool_bar_help_callback), 3887 G_CALLBACK (xg_tool_bar_help_callback),
3787 (gpointer) (EMACS_INT) i); 3888 (gpointer) (EMACS_INT) i);
3788 g_signal_connect (G_OBJECT (w), 3889 g_signal_connect (G_OBJECT (weventbox),
3789 "leave-notify-event", 3890 "leave-notify-event",
3790 G_CALLBACK (xg_tool_bar_help_callback), 3891 G_CALLBACK (xg_tool_bar_help_callback),
3791 (gpointer) (EMACS_INT) i); 3892 (gpointer) (EMACS_INT) i);
3792 } 3893 }
3793 else 3894 else
3794 { 3895 {
3795 /* The child of the tool bar is a button. Inside that button 3896 GtkWidget *wimage = gtk_bin_get_child (GTK_BIN (wbutton));
3796 is a vbox. Inside that vbox is the GtkImage. */
3797 GtkWidget *wvbox = gtk_bin_get_child (GTK_BIN (wicon));
3798 GList *chlist = gtk_container_get_children (GTK_CONTAINER (wvbox));
3799 GtkImage *wimage = GTK_IMAGE (chlist->data);
3800 Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage), 3897 Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage),
3801 XG_TOOL_BAR_IMAGE_DATA); 3898 XG_TOOL_BAR_IMAGE_DATA);
3802 g_list_free (chlist);
3803
3804 gtk_misc_set_padding (GTK_MISC (wimage), hmargin, vmargin); 3899 gtk_misc_set_padding (GTK_MISC (wimage), hmargin, vmargin);
3805 3900
3806 if (old_img != img->pixmap) 3901 if (old_img != img->pixmap)
@@ -3809,21 +3904,20 @@ update_frame_tool_bar (f)
3809 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, 3904 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA,
3810 (gpointer)img->pixmap); 3905 (gpointer)img->pixmap);
3811 3906
3812 gtk_widget_set_sensitive (wicon, enabled_p); 3907 gtk_widget_set_sensitive (wbutton, enabled_p);
3813 gtk_widget_show (wicon); 3908 gtk_widget_show_all (GTK_WIDGET (ti));
3814 } 3909 }
3815 3910
3816#undef PROP 3911#undef PROP
3817 } 3912 }
3818 3913
3819 /* Remove buttons not longer needed. We just hide them so they 3914 /* Remove buttons not longer needed. We just hide them so they
3820 can be reused later on. */ 3915 can be reused later on. */
3821 while (iter) 3916 do
3822 { 3917 {
3823 GtkWidget *w = GTK_WIDGET (iter->data); 3918 ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i++);
3824 gtk_widget_hide (w); 3919 if (ti) gtk_widget_hide_all (GTK_WIDGET (ti));
3825 iter = g_list_next (iter); 3920 } while (ti != NULL);
3826 }
3827 3921
3828 gtk_widget_size_request (x->toolbar_widget, &new_req); 3922 gtk_widget_size_request (x->toolbar_widget, &new_req);
3829 if (old_req.height != new_req.height 3923 if (old_req.height != new_req.height
@@ -3833,8 +3927,6 @@ update_frame_tool_bar (f)
3833 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); 3927 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f));
3834 } 3928 }
3835 3929
3836 if (icon_list) g_list_free (icon_list);
3837
3838 UNBLOCK_INPUT; 3930 UNBLOCK_INPUT;
3839} 3931}
3840 3932