+ GtkPixmapMenuItem *pmenu_item;
+
+ pmenu_item = GTK_PIXMAP_MENU_ITEM(widget);
+
+ if (pmenu_item->pixmap && GTK_WIDGET_VISIBLE(pmenu_item))
+ {
+ GtkAllocation child_allocation;
+ int border_width;
+
+ border_width = GTK_CONTAINER (widget)->border_width;
+
+ child_allocation.width = pmenu_item->pixmap->requisition.width;
+ child_allocation.height = pmenu_item->pixmap->requisition.height;
+ child_allocation.x = border_width + BORDER_SPACING;
+ child_allocation.y = (border_width + BORDER_SPACING
+ + (((allocation->height - child_allocation.height) - child_allocation.x)
+ / 2)); /* center pixmaps vertically */
+ gtk_widget_size_allocate (pmenu_item->pixmap, &child_allocation);
+ }
+
+ if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
+ GTK_WIDGET_CLASS(parent_class)->size_allocate (widget, allocation);
+}
+
+static void
+gtk_pixmap_menu_item_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
+{
+ GtkPixmapMenuItem *menu_item;
+
+ g_return_if_fail (container != NULL);
+ g_return_if_fail (GTK_IS_PIXMAP_MENU_ITEM (container));
+ g_return_if_fail (callback != NULL);
+
+ menu_item = GTK_PIXMAP_MENU_ITEM (container);
+
+ if (menu_item->pixmap)
+ (* callback) (menu_item->pixmap, callback_data);
+
+ GTK_CONTAINER_CLASS(parent_class)->forall(container,include_internals,
+ callback,callback_data);
+}
+
+static void
+gtk_pixmap_menu_item_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ GtkPixmapMenuItem *menu_item;
+ GtkRequisition req = {0, 0};
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_MENU_ITEM (widget));
+ g_return_if_fail (requisition != NULL);
+
+ GTK_WIDGET_CLASS(parent_class)->size_request(widget,requisition);
+
+ menu_item = GTK_PIXMAP_MENU_ITEM (widget);
+
+ if (menu_item->pixmap)
+ gtk_widget_size_request(menu_item->pixmap, &req);
+
+ requisition->height = MAX(req.height + GTK_CONTAINER(widget)->border_width + BORDER_SPACING, (unsigned int) requisition->height);
+ requisition->width += (req.width + GTK_CONTAINER(widget)->border_width + BORDER_SPACING);
+}
+
+static void
+gtk_pixmap_menu_item_remove (GtkContainer *container,
+ GtkWidget *child)
+{
+ GtkBin *bin;
+ gboolean widget_was_visible;
+
+ g_return_if_fail (container != NULL);
+ g_return_if_fail (GTK_IS_PIXMAP_MENU_ITEM (container));
+ g_return_if_fail (child != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ bin = GTK_BIN (container);
+ g_return_if_fail ((bin->child == child ||
+ (GTK_PIXMAP_MENU_ITEM(container)->pixmap == child)));
+
+ widget_was_visible = GTK_WIDGET_VISIBLE (child);
+
+ gtk_widget_unparent (child);
+ if (bin->child == child)
+ bin->child = NULL;
+ else {
+ GTK_PIXMAP_MENU_ITEM(container)->pixmap = NULL;
+ changed_have_pixmap_status(GTK_PIXMAP_MENU_ITEM(container));
+ }
+
+ if (widget_was_visible)
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+}
+
+
+/* important to only call this if there was actually a _change_ in pixmap == NULL */
+static void
+changed_have_pixmap_status (GtkPixmapMenuItem *menu_item)
+{
+ if (menu_item->pixmap != NULL) {
+ GTK_PIXMAP_MENU_ITEM_GET_CLASS(menu_item)->have_pixmap_count += 1;
+
+ if (GTK_PIXMAP_MENU_ITEM_GET_CLASS(menu_item)->have_pixmap_count == 1) {
+ /* Install pixmap toggle size */
+ GTK_MENU_ITEM_GET_CLASS(menu_item)->toggle_size = MAX(GTK_PIXMAP_MENU_ITEM_GET_CLASS(menu_item)->orig_toggle_size, PMAP_WIDTH);
+ }
+ } else {
+ GTK_PIXMAP_MENU_ITEM_GET_CLASS(menu_item)->have_pixmap_count -= 1;
+
+ if (GTK_PIXMAP_MENU_ITEM_GET_CLASS(menu_item)->have_pixmap_count == 0) {
+ /* Install normal toggle size */
+ GTK_MENU_ITEM_GET_CLASS(menu_item)->toggle_size = GTK_PIXMAP_MENU_ITEM_GET_CLASS(menu_item)->orig_toggle_size;
+ }
+ }
+
+ /* Note that we actually need to do this for _all_ GtkPixmapMenuItem
+ whenever the klass->toggle_size changes; but by doing it anytime
+ this function is called, we get the same effect, just because of
+ how the preferences option to show pixmaps works. Bogus, broken.
+ */
+ if (GTK_WIDGET_VISIBLE(GTK_WIDGET(menu_item)))
+ gtk_widget_queue_resize(GTK_WIDGET(menu_item));