* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
+#include "config.h"
+
#include "gtkmenutoolbutton.h"
-#include "gtkintl.h"
#include "gtktogglebutton.h"
#include "gtkarrow.h"
#include "gtkhbox.h"
#include "gtkmenu.h"
#include "gtkmain.h"
#include "gtkprivate.h"
-#include "gtkalias.h"
-
+#include "gtkintl.h"
-#define GTK_MENU_TOOL_BUTTON_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GTK_TYPE_MENU_TOOL_BUTTON, GtkMenuToolButtonPrivate))
struct _GtkMenuToolButtonPrivate
{
GtkMenuToolButton *button = GTK_MENU_TOOL_BUTTON (widget);
GtkMenuToolButtonPrivate *priv = button->priv;
- if (!GTK_WIDGET_IS_SENSITIVE (widget) && priv->menu)
+ if (!gtk_widget_is_sensitive (widget) && priv->menu)
{
gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->menu));
}
widget_class->state_changed = gtk_menu_tool_button_state_changed;
toolitem_class->toolbar_reconfigured = gtk_menu_tool_button_toolbar_reconfigured;
+ /**
+ * GtkMenuToolButton::show-menu:
+ * @button: the object on which the signal is emitted
+ *
+ * The ::show-menu signal is emitted before the menu is shown.
+ *
+ * It can be used to populate the menu on demand, using
+ * gtk_menu_tool_button_get_menu().
+
+ * Note that even if you populate the menu dynamically in this way,
+ * you must set an empty menu on the #GtkMenuToolButton beforehand,
+ * since the arrow is made insensitive if the menu is not set.
+ */
signals[SHOW_MENU] =
g_signal_new (I_("show-menu"),
G_OBJECT_CLASS_TYPE (klass),
return;
if (gtk_toggle_button_get_active (togglebutton) &&
- !GTK_WIDGET_VISIBLE (priv->menu))
+ !gtk_widget_get_visible (GTK_WIDGET (priv->menu)))
{
/* we get here only when the menu is activated by a key
* press, so that we can select the first menu item */
GtkWidget *arrow_button;
GtkWidget *real_button;
- button->priv = GTK_MENU_TOOL_BUTTON_GET_PRIVATE (button);
+ button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button,
+ GTK_TYPE_MENU_TOOL_BUTTON,
+ GtkMenuToolButtonPrivate);
gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (button), FALSE);
box = gtk_hbox_new (FALSE, 0);
- real_button = GTK_BIN (button)->child;
+ real_button = gtk_bin_get_child (GTK_BIN (button));
g_object_ref (real_button);
gtk_container_remove (GTK_CONTAINER (button), real_button);
gtk_container_add (GTK_CONTAINER (box), real_button);
g_signal_connect (arrow_button, "toggled",
G_CALLBACK (arrow_button_toggled_cb), button);
- g_signal_connect (arrow_button, "button_press_event",
+ g_signal_connect (arrow_button, "button-press-event",
G_CALLBACK (arrow_button_button_press_event_cb), button);
}
arrow_button_button_press_event_cb,
button);
}
-
- if (GTK_OBJECT_CLASS (gtk_menu_tool_button_parent_class)->destroy)
- (*GTK_OBJECT_CLASS (gtk_menu_tool_button_parent_class)->destroy) (object);
+
+ GTK_OBJECT_CLASS (gtk_menu_tool_button_parent_class)->destroy (object);
}
/**
* gtk_menu_tool_button_new:
- * @icon_widget: a widget that will be used as icon widget, or %NULL
- * @label: a string that will be used as label, or %NULL
+ * @icon_widget: (allow-none): a widget that will be used as icon widget, or %NULL
+ * @label: (allow-none): a string that will be used as label, or %NULL
*
* Creates a new #GtkMenuToolButton using @icon_widget as icon and
* @label as label.
if (priv->menu != GTK_MENU (menu))
{
- if (priv->menu && GTK_WIDGET_VISIBLE (priv->menu))
+ if (priv->menu && gtk_widget_get_visible (GTK_WIDGET (priv->menu)))
gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->menu));
if (priv->menu)
return GTK_WIDGET (button->priv->menu);
}
-/**
- * gtk_menu_tool_button_set_arrow_tooltip:
- * @button: a #GtkMenuToolButton
- * @tooltips: the #GtkTooltips object to be used
- * @tip_text: text to be used as tooltip text for tool_item
- * @tip_private: text to be used as private tooltip text
- *
- * Sets the #GtkTooltips object to be used for arrow button which
- * pops up the menu. See gtk_tool_item_set_tooltip() for setting
- * a tooltip on the whole #GtkMenuToolButton.
- *
- * Since: 2.6
- *
- * Deprecated: 2.12: Use gtk_menu_tool_button_set_arrow_tooltip_text()
- * instead.
- **/
-void
-gtk_menu_tool_button_set_arrow_tooltip (GtkMenuToolButton *button,
- GtkTooltips *tooltips,
- const gchar *tip_text,
- const gchar *tip_private)
-{
- g_return_if_fail (GTK_IS_MENU_TOOL_BUTTON (button));
-
- gtk_tooltips_set_tip (tooltips, button->priv->arrow_button, tip_text, tip_private);
-}
-
/**
* gtk_menu_tool_button_set_arrow_tooltip_text:
* @button: a #GtkMenuToolButton
* @text: text to be used as tooltip text for button's arrow button
*
* Sets the tooltip text to be used as tooltip for the arrow button which
- * pops up the menu. See gtk_tool_item_set_tooltip() for setting a tooltip
+ * pops up the menu. See gtk_tool_item_set_tooltip_text() for setting a tooltip
* on the whole #GtkMenuToolButton.
*
* Since: 2.12
* @markup: markup text to be used as tooltip text for button's arrow button
*
* Sets the tooltip markup text to be used as tooltip for the arrow button
- * which pops up the menu. See gtk_tool_item_set_tooltip() for setting a
+ * which pops up the menu. See gtk_tool_item_set_tooltip_text() for setting a
* tooltip on the whole #GtkMenuToolButton.
*
* Since: 2.12
gtk_widget_set_tooltip_markup (button->priv->arrow_button, markup);
}
-
-#define __GTK_MENU_TOOL_BUTTON_C__
-#include "gtkaliasdef.c"