+ return g_object_new (GTK_TYPE_BUTTON, NULL);
+}
+
+static gboolean
+show_image (GtkButton *button)
+{
+ GtkButtonPrivate *priv = button->priv;
+ gboolean show;
+
+ if (priv->label_text && !priv->always_show_image)
+ {
+ GtkSettings *settings;
+
+ settings = gtk_widget_get_settings (GTK_WIDGET (button));
+ g_object_get (settings, "gtk-button-images", &show, NULL);
+ }
+ else
+ show = TRUE;
+
+ return show;
+}
+
+
+static void
+gtk_button_construct_child (GtkButton *button)
+{
+ GtkButtonPrivate *priv = button->priv;
+ GtkStyleContext *context;
+ GtkStockItem item;
+ GtkWidget *child;
+ GtkWidget *label;
+ GtkWidget *box;
+ GtkWidget *align;
+ GtkWidget *image = NULL;
+ gchar *label_text = NULL;
+ gint image_spacing;
+
+ if (!priv->constructed)
+ return;
+
+ if (!priv->label_text && !priv->image)
+ return;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (button));
+
+ gtk_style_context_get_style (context,
+ "image-spacing", &image_spacing,
+ NULL);
+
+ if (priv->image && !priv->image_is_stock)
+ {
+ GtkWidget *parent;
+
+ image = g_object_ref (priv->image);
+
+ parent = gtk_widget_get_parent (image);
+ if (parent)
+ gtk_container_remove (GTK_CONTAINER (parent), image);
+ }
+
+ priv->image = NULL;
+
+ child = gtk_bin_get_child (GTK_BIN (button));
+ if (child)
+ gtk_container_remove (GTK_CONTAINER (button), child);
+
+ if (priv->use_stock &&
+ priv->label_text &&
+ gtk_stock_lookup (priv->label_text, &item))
+ {
+ if (!image)
+ image = g_object_ref (gtk_image_new_from_stock (priv->label_text, GTK_ICON_SIZE_BUTTON));
+
+ label_text = item.label;
+ }
+ else
+ label_text = priv->label_text;
+
+ if (image)
+ {
+ priv->image = image;
+ g_object_set (priv->image,
+ "visible", show_image (button),
+ "no-show-all", TRUE,
+ NULL);
+
+ if (priv->image_position == GTK_POS_LEFT ||
+ priv->image_position == GTK_POS_RIGHT)
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, image_spacing);
+ else
+ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, image_spacing);
+
+ if (priv->align_set)
+ align = gtk_alignment_new (priv->xalign, priv->yalign, 0.0, 0.0);
+ else
+ align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+
+ if (priv->image_position == GTK_POS_LEFT ||
+ priv->image_position == GTK_POS_TOP)
+ gtk_box_pack_start (GTK_BOX (box), priv->image, FALSE, FALSE, 0);
+ else
+ gtk_box_pack_end (GTK_BOX (box), priv->image, FALSE, FALSE, 0);
+
+ if (label_text)
+ {
+ if (priv->use_underline || priv->use_stock)
+ {
+ label = gtk_label_new_with_mnemonic (label_text);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label),
+ GTK_WIDGET (button));
+ }
+ else
+ label = gtk_label_new (label_text);
+
+ if (priv->image_position == GTK_POS_RIGHT ||
+ priv->image_position == GTK_POS_BOTTOM)
+ gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
+ else
+ gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0);
+ }
+
+ gtk_container_add (GTK_CONTAINER (button), align);
+ gtk_container_add (GTK_CONTAINER (align), box);
+ gtk_widget_show_all (align);
+
+ g_object_unref (image);
+
+ return;
+ }
+
+ if (priv->use_underline || priv->use_stock)
+ {
+ label = gtk_label_new_with_mnemonic (priv->label_text);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
+ }
+ else
+ label = gtk_label_new (priv->label_text);
+
+ if (priv->align_set)
+ gtk_misc_set_alignment (GTK_MISC (label), priv->xalign, priv->yalign);
+
+ gtk_widget_show (label);
+ gtk_container_add (GTK_CONTAINER (button), label);
+}
+
+
+/**
+ * gtk_button_new_with_label:
+ * @label: The text you want the #GtkLabel to hold.
+ *
+ * Creates a #GtkButton widget with a #GtkLabel child containing the given
+ * text.
+ *
+ * Returns: The newly created #GtkButton widget.
+ */
+GtkWidget*
+gtk_button_new_with_label (const gchar *label)
+{
+ return g_object_new (GTK_TYPE_BUTTON, "label", label, NULL);
+}
+
+/**
+ * gtk_button_new_from_stock:
+ * @stock_id: the name of the stock item
+ *
+ * Creates a new #GtkButton containing the image and text from a stock item.
+ * Some stock ids have preprocessor macros like #GTK_STOCK_OK and
+ * #GTK_STOCK_APPLY.
+ *
+ * If @stock_id is unknown, then it will be treated as a mnemonic
+ * label (as for gtk_button_new_with_mnemonic()).
+ *
+ * Returns: a new #GtkButton
+ **/
+GtkWidget*
+gtk_button_new_from_stock (const gchar *stock_id)
+{
+ return g_object_new (GTK_TYPE_BUTTON,
+ "label", stock_id,
+ "use-stock", TRUE,
+ "use-underline", TRUE,
+ NULL);