-/**
- * gtk_toolbar_append_item:
- * @toolbar: a #GtkToolbar.
- * @text: give your toolbar button a label.
- * @tooltip_text: a string that appears when the user holds the mouse over this item.
- * @tooltip_private_text: use with #GtkTipsQuery.
- * @icon: a #GtkWidget that should be used as the button's icon.
- * @callback: the function to be executed when the button is pressed.
- * @user_data: a pointer to any data you wish to be passed to the callback.
- *
- * Inserts a new item into the toolbar. You must specify the position
- * in the toolbar where it will be inserted.
- *
- * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use G_CALLBACK() to cast the function to #GCallback.
- *
- * Return value: the new toolbar item as a #GtkWidget.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-GtkWidget *
-gtk_toolbar_append_item (GtkToolbar *toolbar,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GCallback callback,
- gpointer user_data)
-{
- return gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON,
- NULL, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data,
- toolbar->num_children);
-}
-
-/**
- * gtk_toolbar_prepend_item:
- * @toolbar: a #GtkToolbar.
- * @text: give your toolbar button a label.
- * @tooltip_text: a string that appears when the user holds the mouse over this item.
- * @tooltip_private_text: use with #GtkTipsQuery.
- * @icon: a #GtkWidget that should be used as the button's icon.
- * @callback: the function to be executed when the button is pressed.
- * @user_data: a pointer to any data you wish to be passed to the callback.
- *
- * Adds a new button to the beginning (top or left edges) of the given toolbar.
- *
- * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use G_CALLBACK() to cast the function to #GCallback.
- *
- * Return value: the new toolbar item as a #GtkWidget.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-GtkWidget *
-gtk_toolbar_prepend_item (GtkToolbar *toolbar,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GCallback callback,
- gpointer user_data)
-{
- return gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON,
- NULL, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data,
- 0);
-}
-
-/**
- * gtk_toolbar_insert_item:
- * @toolbar: a #GtkToolbar.
- * @text: give your toolbar button a label.
- * @tooltip_text: a string that appears when the user holds the mouse over this item.
- * @tooltip_private_text: use with #GtkTipsQuery.
- * @icon: a #GtkWidget that should be used as the button's icon.
- * @callback: the function to be executed when the button is pressed.
- * @user_data: a pointer to any data you wish to be passed to the callback.
- * @position: the number of widgets to insert this item after.
- *
- * Inserts a new item into the toolbar. You must specify the position in the
- * toolbar where it will be inserted.
- *
- * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use G_CALLBACK() to cast the function to #GCallback.
- *
- * Return value: the new toolbar item as a #GtkWidget.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-GtkWidget *
-gtk_toolbar_insert_item (GtkToolbar *toolbar,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GCallback callback,
- gpointer user_data,
- gint position)
-{
- return gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON,
- NULL, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data,
- position);
-}
-
-/**
- * gtk_toolbar_insert_stock:
- * @toolbar: A #GtkToolbar
- * @stock_id: The id of the stock item you want to insert
- * @tooltip_text: The text in the tooltip of the toolbar button
- * @tooltip_private_text: The private text of the tooltip
- * @callback: The callback called when the toolbar button is clicked.
- * @user_data: user data passed to callback
- * @position: The position the button shall be inserted at.
- * -1 means at the end.
- *
- * Inserts a stock item at the specified position of the toolbar. If
- * @stock_id is not a known stock item ID, it's inserted verbatim,
- * except that underscores used to mark mnemonics are removed.
- *
- * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use G_CALLBACK() to cast the function to #GCallback.
- *
- * Returns: the inserted widget
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- */
-GtkWidget*
-gtk_toolbar_insert_stock (GtkToolbar *toolbar,
- const gchar *stock_id,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GCallback callback,
- gpointer user_data,
- gint position)
-{
- return internal_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON,
- NULL, stock_id,
- tooltip_text, tooltip_private_text,
- NULL, callback, user_data,
- position, TRUE);
-}
-
-/**
- * gtk_toolbar_append_space:
- * @toolbar: a #GtkToolbar.
- *
- * Adds a new space to the end of the toolbar.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-void
-gtk_toolbar_append_space (GtkToolbar *toolbar)
-{
- gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_SPACE,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL, NULL,
- toolbar->num_children);
-}
-
-/**
- * gtk_toolbar_prepend_space:
- * @toolbar: a #GtkToolbar.
- *
- * Adds a new space to the beginning of the toolbar.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-void
-gtk_toolbar_prepend_space (GtkToolbar *toolbar)
-{
- gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_SPACE,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL, NULL,
- 0);
-}
-
-/**
- * gtk_toolbar_insert_space:
- * @toolbar: a #GtkToolbar
- * @position: the number of widgets after which a space should be inserted.
- *
- * Inserts a new space in the toolbar at the specified position.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-void
-gtk_toolbar_insert_space (GtkToolbar *toolbar,
- gint position)
-{
- gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_SPACE,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL, NULL,
- position);
-}
-
-/**
- * gtk_toolbar_remove_space:
- * @toolbar: a #GtkToolbar.
- * @position: the index of the space to remove.
- *
- * Removes a space from the specified position.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-void
-gtk_toolbar_remove_space (GtkToolbar *toolbar,
- gint position)
-{
- GtkToolbarPrivate *priv;
- ToolbarContent *content;
-
- g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
-
- if (!gtk_toolbar_check_old_api (toolbar))
- return;
-
- priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-
- content = g_list_nth_data (priv->content, position);
-
- if (!content)
- {
- g_warning ("Toolbar position %d doesn't exist", position);
- return;
- }
-
- if (!toolbar_content_is_separator (content))
- {
- g_warning ("Toolbar position %d is not a space", position);
- return;
- }
-
- toolbar_content_remove (content, toolbar);
- toolbar_content_free (content);
-}
-
-/**
- * gtk_toolbar_append_widget:
- * @toolbar: a #GtkToolbar.
- * @widget: a #GtkWidget to add to the toolbar.
- * @tooltip_text: (allow-none): the element's tooltip.
- * @tooltip_private_text: (allow-none): used for context-sensitive help about this toolbar element.
- *
- * Adds a widget to the end of the given toolbar.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-void
-gtk_toolbar_append_widget (GtkToolbar *toolbar,
- GtkWidget *widget,
- const gchar *tooltip_text,
- const gchar *tooltip_private_text)
-{
- gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_WIDGET,
- widget, NULL,
- tooltip_text, tooltip_private_text,
- NULL, NULL, NULL,
- toolbar->num_children);
-}
-
-/**
- * gtk_toolbar_prepend_widget:
- * @toolbar: a #GtkToolbar.
- * @widget: a #GtkWidget to add to the toolbar.
- * @tooltip_text: (allow-none): the element's tooltip.
- * @tooltip_private_text: (allow-none): used for context-sensitive help about this toolbar element.
- *
- * Adds a widget to the beginning of the given toolbar.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-void
-gtk_toolbar_prepend_widget (GtkToolbar *toolbar,
- GtkWidget *widget,
- const gchar *tooltip_text,
- const gchar *tooltip_private_text)
-{
- gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_WIDGET,
- widget, NULL,
- tooltip_text, tooltip_private_text,
- NULL, NULL, NULL,
- 0);
-}
-
-/**
- * gtk_toolbar_insert_widget:
- * @toolbar: a #GtkToolbar.
- * @widget: a #GtkWidget to add to the toolbar.
- * @tooltip_text: (allow-none): the element's tooltip.
- * @tooltip_private_text: (allow-none): used for context-sensitive help about this toolbar element.
- * @position: the number of widgets to insert this widget after.
- *
- * Inserts a widget in the toolbar at the given position.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-void
-gtk_toolbar_insert_widget (GtkToolbar *toolbar,
- GtkWidget *widget,
- const char *tooltip_text,
- const char *tooltip_private_text,
- gint position)
-{
- gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_WIDGET,
- widget, NULL,
- tooltip_text, tooltip_private_text,
- NULL, NULL, NULL,
- position);
-}
-
-/**
- * gtk_toolbar_append_element:
- * @toolbar: a #GtkToolbar.
- * @type: a value of type #GtkToolbarChildType that determines what @widget will be.
- * @widget: (allow-none): a #GtkWidget, or %NULL.
- * @text: the element's label.
- * @tooltip_text: the element's tooltip.
- * @tooltip_private_text: used for context-sensitive help about this toolbar element.
- * @icon: a #GtkWidget that provides pictorial representation of the element's function.
- * @callback: the function to be executed when the button is pressed.
- * @user_data: any data you wish to pass to the callback.
- *
- * Adds a new element to the end of a toolbar.
- *
- * If @type == %GTK_TOOLBAR_CHILD_WIDGET, @widget is used as the new element.
- * If @type == %GTK_TOOLBAR_CHILD_RADIOBUTTON, @widget is used to determine
- * the radio group for the new element. In all other cases, @widget must
- * be %NULL.
- *
- * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use G_CALLBACK() to cast the function to #GCallback.
- *
- * Return value: the new toolbar element as a #GtkWidget.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-GtkWidget*
-gtk_toolbar_append_element (GtkToolbar *toolbar,
- GtkToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GCallback callback,
- gpointer user_data)
-{
- return gtk_toolbar_insert_element (toolbar, type, widget, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data,
- toolbar->num_children);
-}
-
-/**
- * gtk_toolbar_prepend_element:
- * @toolbar: a #GtkToolbar.
- * @type: a value of type #GtkToolbarChildType that determines what @widget will be.
- * @widget: (allow-none): a #GtkWidget, or %NULL
- * @text: the element's label.
- * @tooltip_text: the element's tooltip.
- * @tooltip_private_text: used for context-sensitive help about this toolbar element.
- * @icon: a #GtkWidget that provides pictorial representation of the element's function.
- * @callback: the function to be executed when the button is pressed.
- * @user_data: any data you wish to pass to the callback.
- *
- * Adds a new element to the beginning of a toolbar.
- *
- * If @type == %GTK_TOOLBAR_CHILD_WIDGET, @widget is used as the new element.
- * If @type == %GTK_TOOLBAR_CHILD_RADIOBUTTON, @widget is used to determine
- * the radio group for the new element. In all other cases, @widget must
- * be %NULL.
- *
- * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use G_CALLBACK() to cast the function to #GCallback.
- *
- * Return value: the new toolbar element as a #GtkWidget.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-GtkWidget *
-gtk_toolbar_prepend_element (GtkToolbar *toolbar,
- GtkToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GCallback callback,
- gpointer user_data)
-{
- return gtk_toolbar_insert_element (toolbar, type, widget, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data, 0);
-}
-
-/**
- * gtk_toolbar_insert_element:
- * @toolbar: a #GtkToolbar.
- * @type: a value of type #GtkToolbarChildType that determines what @widget
- * will be.
- * @widget: (allow-none): a #GtkWidget, or %NULL.
- * @text: the element's label.
- * @tooltip_text: the element's tooltip.
- * @tooltip_private_text: used for context-sensitive help about this toolbar element.
- * @icon: a #GtkWidget that provides pictorial representation of the element's function.
- * @callback: the function to be executed when the button is pressed.
- * @user_data: any data you wish to pass to the callback.
- * @position: the number of widgets to insert this element after.
- *
- * Inserts a new element in the toolbar at the given position.
- *
- * If @type == %GTK_TOOLBAR_CHILD_WIDGET, @widget is used as the new element.
- * If @type == %GTK_TOOLBAR_CHILD_RADIOBUTTON, @widget is used to determine
- * the radio group for the new element. In all other cases, @widget must
- * be %NULL.
- *
- * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use G_CALLBACK() to cast the function to #GCallback.
- *
- * Return value: the new toolbar element as a #GtkWidget.
- *
- * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
- **/
-GtkWidget *
-gtk_toolbar_insert_element (GtkToolbar *toolbar,
- GtkToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GCallback callback,
- gpointer user_data,
- gint position)
-{
- return internal_insert_element (toolbar, type, widget, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data, position, FALSE);
-}
-
-static void
-set_child_packing_and_visibility(GtkToolbar *toolbar,
- GtkToolbarChild *child)
-{
- GtkWidget *box;
- gboolean expand;
-
- box = gtk_bin_get_child (GTK_BIN (child->widget));
-
- g_return_if_fail (GTK_IS_BOX (box));
-
- if (child->label)
- {
- expand = (toolbar->style != GTK_TOOLBAR_BOTH);
-
- gtk_box_set_child_packing (GTK_BOX (box), child->label,
- expand, expand, 0, GTK_PACK_END);
-
- if (toolbar->style != GTK_TOOLBAR_ICONS)
- gtk_widget_show (child->label);
- else
- gtk_widget_hide (child->label);
- }
-
- if (child->icon)
- {
- expand = (toolbar->style != GTK_TOOLBAR_BOTH_HORIZ);
-
- gtk_box_set_child_packing (GTK_BOX (box), child->icon,
- expand, expand, 0, GTK_PACK_END);
-
- if (toolbar->style != GTK_TOOLBAR_TEXT)
- gtk_widget_show (child->icon);
- else
- gtk_widget_hide (child->icon);
- }
-}
-
-static GtkWidget *
-internal_insert_element (GtkToolbar *toolbar,
- GtkToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GCallback callback,
- gpointer user_data,
- gint position,
- gboolean use_stock)
-{
- GtkWidget *box;
- ToolbarContent *content;
- char *free_me = NULL;
-
- GtkWidget *child_widget;
- GtkWidget *child_label;
- GtkWidget *child_icon;
-
- g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), NULL);
- if (type == GTK_TOOLBAR_CHILD_WIDGET)
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- else if (type != GTK_TOOLBAR_CHILD_RADIOBUTTON)
- g_return_val_if_fail (widget == NULL, NULL);
- if (GTK_IS_TOOL_ITEM (widget))
- g_warning (MIXED_API_WARNING);
-
- if (!gtk_toolbar_check_old_api (toolbar))
- return NULL;
-
- child_widget = NULL;
- child_label = NULL;
- child_icon = NULL;
-
- switch (type)
- {
- case GTK_TOOLBAR_CHILD_SPACE:
- break;
-
- case GTK_TOOLBAR_CHILD_WIDGET:
- child_widget = widget;
- break;
-
- case GTK_TOOLBAR_CHILD_BUTTON:
- case GTK_TOOLBAR_CHILD_TOGGLEBUTTON:
- case GTK_TOOLBAR_CHILD_RADIOBUTTON:
- if (type == GTK_TOOLBAR_CHILD_BUTTON)
- {
- child_widget = gtk_button_new ();
- }
- else if (type == GTK_TOOLBAR_CHILD_TOGGLEBUTTON)
- {
- child_widget = gtk_toggle_button_new ();
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (child_widget), FALSE);
- }
- else /* type == GTK_TOOLBAR_CHILD_RADIOBUTTON */
- {
- GSList *group = NULL;
-
- if (widget)
- group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
-
- child_widget = gtk_radio_button_new (group);
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (child_widget), FALSE);
- }
-
- gtk_button_set_relief (GTK_BUTTON (child_widget), get_button_relief (toolbar));
- gtk_button_set_focus_on_click (GTK_BUTTON (child_widget), FALSE);
-
- if (callback)
- {
- g_signal_connect (child_widget, "clicked",
- callback, user_data);
- }
-
- if (toolbar->style == GTK_TOOLBAR_BOTH_HORIZ)
- box = gtk_hbox_new (FALSE, 0);
- else
- box = gtk_vbox_new (FALSE, 0);
-
- gtk_container_add (GTK_CONTAINER (child_widget), box);
- gtk_widget_show (box);
-
- if (text && use_stock)
- {
- GtkStockItem stock_item;
- if (gtk_stock_lookup (text, &stock_item))
- {
- if (!icon)
- icon = gtk_image_new_from_stock (text, toolbar->icon_size);
-
- text = free_me = _gtk_toolbar_elide_underscores (stock_item.label);
- }
- }
-
- if (text)
- {
- child_label = gtk_label_new (text);
-
- gtk_container_add (GTK_CONTAINER (box), child_label);
- }
-
- if (icon)
- {
- child_icon = GTK_WIDGET (icon);
- gtk_container_add (GTK_CONTAINER (box), child_icon);
- }
-
- gtk_widget_show (child_widget);
- break;
-
- default:
- g_assert_not_reached ();
- break;
- }
-
- if ((type != GTK_TOOLBAR_CHILD_SPACE) && tooltip_text)
- {
- gtk_tooltips_set_tip (toolbar->tooltips, child_widget,
- tooltip_text, tooltip_private_text);