comparison src/gtkutil.c @ 74376:42ad3938ee1a

(update_frame_tool_bar): Handle modifying a toolbar item without an image.
author Jan Djärv <jan.h.d@swipnet.se>
date Sun, 03 Dec 2006 11:44:33 +0000
parents 7c60775b5a52
children de706755c4d7 f1d13e615070
comparison
equal deleted inserted replaced
74375:dd30954df7e1 74376:42ad3938ee1a
3682 int idx; 3682 int idx;
3683 int img_id; 3683 int img_id;
3684 struct image *img; 3684 struct image *img;
3685 Lisp_Object image; 3685 Lisp_Object image;
3686 GtkWidget *wicon = iter ? GTK_WIDGET (iter->data) : 0; 3686 GtkWidget *wicon = iter ? GTK_WIDGET (iter->data) : 0;
3687 GtkToolItem *ti = NULL;
3688 GtkWidget *wvbox;
3689 GList *chlist;
3687 3690
3688 if (iter) iter = g_list_next (iter); 3691 if (iter) iter = g_list_next (iter);
3689 3692
3690 /* If image is a vector, choose the image according to the 3693 /* If image is a vector, choose the image according to the
3691 button state. */ 3694 button state. */
3721 if (img->load_failed_p || img->pixmap == None) 3724 if (img->load_failed_p || img->pixmap == None)
3722 { 3725 {
3723 if (wicon) 3726 if (wicon)
3724 gtk_widget_hide (wicon); 3727 gtk_widget_hide (wicon);
3725 else 3728 else
3729 /* Insert an empty (non-image) button */
3726 gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), 3730 gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget),
3727 gtk_tool_button_new (NULL, ""), 3731 gtk_tool_button_new (NULL, ""),
3728 i); 3732 i);
3729 continue; 3733 continue;
3730 } 3734 }
3731 3735
3732 if (! wicon) 3736 if (wicon)
3737 {
3738 /* The child of the tool bar is a button. Inside that button
3739 is a vbox. Inside that vbox is the GtkImage. */
3740 wvbox = gtk_bin_get_child (GTK_BIN (wicon));
3741 chlist = gtk_container_get_children (GTK_CONTAINER (wvbox));
3742 if (chlist == NULL)
3743 /* In this case, we inserted an empty button (above) with no image */
3744 ti = GTK_TOOL_ITEM (wicon);
3745 }
3746
3747 if (! wicon || ti != NULL)
3733 { 3748 {
3734 GtkWidget *w = xg_get_image_for_pixmap (f, img, x->widget, NULL); 3749 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); 3750 gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin);
3738 3751
3739 gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), 3752
3740 ti, 3753 if (ti == NULL)
3741 i); 3754 {
3755 ti = gtk_tool_button_new (w, "");
3756
3757 gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), ti, i);
3758 }
3759 else
3760 gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (ti), w);
3761
3762
3742 /* The EMACS_INT cast avoids a warning. */ 3763 /* The EMACS_INT cast avoids a warning. */
3743 g_signal_connect (GTK_WIDGET (ti), "clicked", 3764 g_signal_connect (GTK_WIDGET (ti), "clicked",
3744 GTK_SIGNAL_FUNC (xg_tool_bar_callback), 3765 GTK_SIGNAL_FUNC (xg_tool_bar_callback),
3745 (gpointer) (EMACS_INT) i); 3766 (gpointer) (EMACS_INT) i);
3746 3767