* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
-#include <string.h>
+#include "gtktoolitem.h"
-#undef GTK_DISABLE_DEPRECATED /* GtkTooltips */
+#include <string.h>
-#include "gtktoolitem.h"
#include "gtkmarshalers.h"
#include "gtktoolshell.h"
#include "gtkseparatormenuitem.h"
+#include "gtksizerequest.h"
#include "gtkactivatable.h"
#include "gtkintl.h"
-#include "gtkmain.h"
#include "gtkprivate.h"
-#include "gtkalias.h"
+
/**
* SECTION:gtktoolitem
* @short_description: The base class of widgets that can be added to GtkToolShell
+ * @Title: GtkToolItem
+ * @see_also: <variablelist>
+ * <varlistentry>
+ * <term>#GtkToolbar</term>
+ * <listitem><para>The toolbar widget</para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>#GtkToolButton</term>
+ * <listitem><para>A subclass of #GtkToolItem that displays buttons on
+ * the toolbar</para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>#GtkSeparatorToolItem</term>
+ * <listitem><para>A subclass of #GtkToolItem that separates groups of
+ * items on a toolbar</para></listitem>
+ * </varlistentry>
+ * </variablelist>
*
* #GtkToolItem<!-- -->s are widgets that can appear on a toolbar. To
* create a toolbar item that contain something else than a button, use
enum {
CREATE_MENU_PROXY,
TOOLBAR_RECONFIGURED,
- SET_TOOLTIP,
LAST_SIGNAL
};
PROP_ACTIVATABLE_USE_ACTION_APPEARANCE
};
-#define GTK_TOOL_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_TOOL_ITEM, GtkToolItemPrivate))
struct _GtkToolItemPrivate
{
gchar *tip_text;
gchar *tip_private;
- guint visible_horizontal : 1;
- guint visible_vertical : 1;
- guint homogeneous : 1;
- guint expand : 1;
- guint use_drag_window : 1;
- guint is_important : 1;
+ guint visible_horizontal : 1;
+ guint visible_vertical : 1;
+ guint homogeneous : 1;
+ guint expand : 1;
+ guint use_drag_window : 1;
+ guint is_important : 1;
+ guint use_action_appearance : 1;
GdkWindow *drag_window;
-
gchar *menu_item_id;
GtkWidget *menu_item;
GtkAction *action;
- gboolean use_action_appearance;
};
-
+
static void gtk_tool_item_finalize (GObject *object);
static void gtk_tool_item_dispose (GObject *object);
static void gtk_tool_item_parent_set (GtkWidget *toolitem,
static void gtk_tool_item_unrealize (GtkWidget *widget);
static void gtk_tool_item_map (GtkWidget *widget);
static void gtk_tool_item_unmap (GtkWidget *widget);
-static void gtk_tool_item_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+static void gtk_tool_item_get_preferred_width
+ (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+static void gtk_tool_item_get_preferred_height
+ (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
static void gtk_tool_item_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-static gboolean gtk_tool_item_real_set_tooltip (GtkToolItem *tool_item,
- GtkTooltips *tooltips,
- const gchar *tip_text,
- const gchar *tip_private);
-
-static gboolean gtk_tool_item_create_menu_proxy (GtkToolItem *item);
static void gtk_tool_item_activatable_interface_init (GtkActivatableIface *iface);
-static void gtk_tool_item_activatable_update (GtkActivatable *activatable,
+static void gtk_tool_item_update (GtkActivatable *activatable,
GtkAction *action,
const gchar *property_name);
-static void gtk_tool_item_activatable_reset (GtkActivatable *activatable,
+static void gtk_tool_item_sync_action_properties (GtkActivatable *activatable,
GtkAction *action);
static void gtk_tool_item_set_related_action (GtkToolItem *item,
GtkAction *action);
object_class = (GObjectClass *)klass;
widget_class = (GtkWidgetClass *)klass;
-
+
object_class->set_property = gtk_tool_item_set_property;
object_class->get_property = gtk_tool_item_get_property;
object_class->finalize = gtk_tool_item_finalize;
widget_class->unrealize = gtk_tool_item_unrealize;
widget_class->map = gtk_tool_item_map;
widget_class->unmap = gtk_tool_item_unmap;
- widget_class->size_request = gtk_tool_item_size_request;
+ widget_class->get_preferred_width = gtk_tool_item_get_preferred_width;
+ widget_class->get_preferred_height = gtk_tool_item_get_preferred_height;
widget_class->size_allocate = gtk_tool_item_size_allocate;
widget_class->parent_set = gtk_tool_item_parent_set;
- klass->create_menu_proxy = gtk_tool_item_create_menu_proxy;
- klass->set_tooltip = gtk_tool_item_real_set_tooltip;
+ gtk_container_class_handle_border_width (GTK_CONTAINER_CLASS (klass));
+
+ klass->create_menu_proxy = _gtk_tool_item_create_menu_proxy;
g_object_class_install_property (object_class,
PROP_VISIBLE_HORIZONTAL,
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
-/**
- * GtkToolItem::set-tooltip:
- * @tool_item: the object the signal was emitted on
- * @tooltips: the #GtkTooltips
- * @tip_text: the tooltip text
- * @tip_private: the tooltip private text
- *
- * This signal is emitted when the toolitem's tooltip changes.
- * Application developers can use gtk_tool_item_set_tooltip() to
- * set the item's tooltip.
- *
- * Return value: %TRUE if the signal was handled, %FALSE if not
- *
- * Deprecated: 2.12: With the new tooltip API, there is no
- * need to use this signal anymore.
- **/
- toolitem_signals[SET_TOOLTIP] =
- g_signal_new (I_("set-tooltip"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtkToolItemClass, set_tooltip),
- _gtk_boolean_handled_accumulator, NULL,
- _gtk_marshal_BOOLEAN__OBJECT_STRING_STRING,
- G_TYPE_BOOLEAN, 3,
- GTK_TYPE_TOOLTIPS,
- G_TYPE_STRING,
- G_TYPE_STRING);
g_type_class_add_private (object_class, sizeof (GtkToolItemPrivate));
}
static void
gtk_tool_item_init (GtkToolItem *toolitem)
{
- GTK_WIDGET_UNSET_FLAGS (toolitem, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus (GTK_WIDGET (toolitem), FALSE);
- toolitem->priv = GTK_TOOL_ITEM_GET_PRIVATE (toolitem);
+ toolitem->priv = G_TYPE_INSTANCE_GET_PRIVATE (toolitem,
+ GTK_TYPE_TOOL_ITEM,
+ GtkToolItemPrivate);
toolitem->priv->visible_horizontal = TRUE;
toolitem->priv->visible_vertical = TRUE;
gtk_tool_item_parent_set (GtkWidget *toolitem,
GtkWidget *prev_parent)
{
- if (GTK_WIDGET (toolitem)->parent != NULL)
+ if (gtk_widget_get_parent (GTK_WIDGET (toolitem)) != NULL)
gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM (toolitem));
}
if (tool_item->priv->menu_item && strcmp (pspec->name, "sensitive") == 0)
gtk_widget_set_sensitive (tool_item->priv->menu_item,
- GTK_WIDGET_SENSITIVE (tool_item));
+ gtk_widget_get_sensitive (GTK_WIDGET (tool_item)));
+
+ if (G_OBJECT_CLASS (gtk_tool_item_parent_class)->notify)
+ G_OBJECT_CLASS (gtk_tool_item_parent_class)->notify (object, pspec);
}
static void
create_drag_window (GtkToolItem *toolitem)
{
+ GtkAllocation allocation;
GtkWidget *widget;
GdkWindowAttr attributes;
- gint attributes_mask, border_width;
+ gint attributes_mask;
g_return_if_fail (toolitem->priv->use_drag_window == TRUE);
widget = GTK_WIDGET (toolitem);
- border_width = GTK_CONTAINER (toolitem)->border_width;
+
+ gtk_widget_get_allocation (widget, &allocation);
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - border_width * 2;
- attributes.height = widget->allocation.height - border_width * 2;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
toolitem->priv->drag_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
- gdk_window_set_user_data (toolitem->priv->drag_window, toolitem);
+ gtk_widget_register_window (widget, toolitem->priv->drag_window);
}
static void
gtk_tool_item_realize (GtkWidget *widget)
{
GtkToolItem *toolitem;
+ GdkWindow *window;
toolitem = GTK_TOOL_ITEM (widget);
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ gtk_widget_set_realized (widget, TRUE);
- widget->window = gtk_widget_get_parent_window (widget);
- g_object_ref (widget->window);
+ window = gtk_widget_get_parent_window (widget);
+ gtk_widget_set_window (widget, window);
+ g_object_ref (window);
if (toolitem->priv->use_drag_window)
create_drag_window(toolitem);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
}
static void
{
if (toolitem->priv->drag_window)
{
- gdk_window_set_user_data (toolitem->priv->drag_window, NULL);
+ gtk_widget_unregister_window (GTK_WIDGET (toolitem), toolitem->priv->drag_window);
gdk_window_destroy (toolitem->priv->drag_window);
toolitem->priv->drag_window = NULL;
}
}
static void
-gtk_tool_item_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+gtk_tool_item_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
{
- GtkWidget *child = GTK_BIN (widget)->child;
+ GtkWidget *child;
- if (child && GTK_WIDGET_VISIBLE (child))
- {
- gtk_widget_size_request (child, requisition);
- }
- else
- {
- requisition->height = 0;
- requisition->width = 0;
- }
-
- requisition->width += (GTK_CONTAINER (widget)->border_width) * 2;
- requisition->height += (GTK_CONTAINER (widget)->border_width) * 2;
+ *minimum = *natural = 0;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child && gtk_widget_get_visible (child))
+ gtk_widget_get_preferred_width (child, minimum, natural);
+}
+
+static void
+gtk_tool_item_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ GtkWidget *child;
+
+ *minimum = *natural = 0;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child && gtk_widget_get_visible (child))
+ gtk_widget_get_preferred_height (child, minimum, natural);
}
static void
{
GtkToolItem *toolitem = GTK_TOOL_ITEM (widget);
GtkAllocation child_allocation;
- gint border_width;
- GtkWidget *child = GTK_BIN (widget)->child;
+ GtkWidget *child;
- widget->allocation = *allocation;
- border_width = GTK_CONTAINER (widget)->border_width;
+ gtk_widget_set_allocation (widget, allocation);
if (toolitem->priv->drag_window)
gdk_window_move_resize (toolitem->priv->drag_window,
- widget->allocation.x + border_width,
- widget->allocation.y + border_width,
- widget->allocation.width - border_width * 2,
- widget->allocation.height - border_width * 2);
-
- if (child && GTK_WIDGET_VISIBLE (child))
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child && gtk_widget_get_visible (child))
{
- child_allocation.x = allocation->x + border_width;
- child_allocation.y = allocation->y + border_width;
- child_allocation.width = allocation->width - 2 * border_width;
- child_allocation.height = allocation->height - 2 * border_width;
+ child_allocation.x = allocation->x;
+ child_allocation.y = allocation->y;
+ child_allocation.width = allocation->width;
+ child_allocation.height = allocation->height;
gtk_widget_size_allocate (child, &child_allocation);
}
}
-static gboolean
-gtk_tool_item_create_menu_proxy (GtkToolItem *item)
+gboolean
+_gtk_tool_item_create_menu_proxy (GtkToolItem *item)
{
GtkWidget *menu_item;
gboolean visible_overflown;
}
else
gtk_tool_item_set_proxy_menu_item (item, "gtk-action-menu-item", NULL);
+
+ return TRUE;
}
return FALSE;
}
-static void
-gtk_tool_item_activatable_interface_init (GtkActivatableIface *iface)
+static void
+gtk_tool_item_activatable_interface_init (GtkActivatableIface *iface)
{
- iface->update = gtk_tool_item_activatable_update;
- iface->reset = gtk_tool_item_activatable_reset;
+ iface->update = gtk_tool_item_update;
+ iface->sync_action_properties = gtk_tool_item_sync_action_properties;
}
-static void
-gtk_tool_item_activatable_update (GtkActivatable *activatable,
- GtkAction *action,
- const gchar *property_name)
+static void
+gtk_tool_item_update (GtkActivatable *activatable,
+ GtkAction *action,
+ const gchar *property_name)
{
if (strcmp (property_name, "visible") == 0)
{
gtk_action_get_is_important (action));
}
-static void
-gtk_tool_item_activatable_reset (GtkActivatable *activatable,
- GtkAction *action)
+static void
+gtk_tool_item_sync_action_properties (GtkActivatable *activatable,
+ GtkAction *action)
{
if (!action)
return;
}
static void
-gtk_tool_item_set_use_action_appearance (GtkToolItem *item,
+gtk_tool_item_set_use_action_appearance (GtkToolItem *item,
gboolean use_appearance)
{
if (item->priv->use_action_appearance != use_appearance)
{
item->priv->use_action_appearance = use_appearance;
-
- gtk_activatable_reset (GTK_ACTIVATABLE (item), item->priv->action);
+
+ gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (item), item->priv->action);
}
}
return item;
}
+/**
+ * gtk_tool_item_get_ellipsize_mode:
+ * @tool_item: a #GtkToolItem
+ *
+ * Returns the ellipsize mode used for @tool_item. Custom subclasses of
+ * #GtkToolItem should call this function to find out how text should
+ * be ellipsized.
+ *
+ * Return value: a #PangoEllipsizeMode indicating how text in @tool_item
+ * should be ellipsized.
+ *
+ * Since: 2.20
+ **/
+PangoEllipsizeMode
+gtk_tool_item_get_ellipsize_mode (GtkToolItem *tool_item)
+{
+ GtkWidget *parent;
+
+ g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
+
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
+ if (!parent || !GTK_IS_TOOL_SHELL (parent))
+ return PANGO_ELLIPSIZE_NONE;
+
+ return gtk_tool_shell_get_ellipsize_mode (GTK_TOOL_SHELL (parent));
+}
+
/**
* gtk_tool_item_get_icon_size:
* @tool_item: a #GtkToolItem
* #GtkToolItem should call this function to find out what size icons
* they should use.
*
- * Return value: a #GtkIconSize indicating the icon size used for @tool_item
+ * Return value: (type int): a #GtkIconSize indicating the icon size
+ * used for @tool_item
*
* Since: 2.4
**/
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ICON_SIZE_LARGE_TOOLBAR);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_ICON_SIZE_LARGE_TOOLBAR;
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_ORIENTATION_HORIZONTAL;
* <listitem> GTK_TOOLBAR_TEXT, meaning the tool item should only
* show text</listitem>
* <listitem> GTK_TOOLBAR_BOTH_HORIZ, meaning the tool item should show
- * both an icon and a label, arranged horizontally (however, note the
- * #GtkToolButton::has_text_horizontally that makes tool buttons not
- * show labels when the toolbar style is GTK_TOOLBAR_BOTH_HORIZ.
- * </listitem>
+ * both an icon and a label, arranged horizontally</listitem>
* </itemizedlist>
*
* Return value: A #GtkToolbarStyle indicating the toolbar style used
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_TOOLBAR_ICONS);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_TOOLBAR_ICONS;
* gtk_tool_item_get_relief_style:
* @tool_item: a #GtkToolItem
*
- * Returns the relief style of @tool_item. See gtk_button_set_relief_style().
+ * Returns the relief style of @tool_item. See gtk_button_set_relief().
* Custom subclasses of #GtkToolItem should call this function in the handler
* of the #GtkToolItem::toolbar_reconfigured signal to find out the
* relief style of buttons.
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_RELIEF_NONE);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_RELIEF_NONE;
return gtk_tool_shell_get_relief_style (GTK_TOOL_SHELL (parent));
}
+/**
+ * gtk_tool_item_get_text_alignment:
+ * @tool_item: a #GtkToolItem:
+ *
+ * Returns the text alignment used for @tool_item. Custom subclasses of
+ * #GtkToolItem should call this function to find out how text should
+ * be aligned.
+ *
+ * Return value: a #gfloat indicating the horizontal text alignment
+ * used for @tool_item
+ *
+ * Since: 2.20
+ **/
+gfloat
+gtk_tool_item_get_text_alignment (GtkToolItem *tool_item)
+{
+ GtkWidget *parent;
+
+ g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
+
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
+ if (!parent || !GTK_IS_TOOL_SHELL (parent))
+ return 0.5;
+
+ return gtk_tool_shell_get_text_alignment (GTK_TOOL_SHELL (parent));
+}
+
+/**
+ * gtk_tool_item_get_text_orientation:
+ * @tool_item: a #GtkToolItem
+ *
+ * Returns the text orientation used for @tool_item. Custom subclasses of
+ * #GtkToolItem should call this function to find out how text should
+ * be orientated.
+ *
+ * Return value: a #GtkOrientation indicating the text orientation
+ * used for @tool_item
+ *
+ * Since: 2.20
+ */
+GtkOrientation
+gtk_tool_item_get_text_orientation (GtkToolItem *tool_item)
+{
+ GtkWidget *parent;
+
+ g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
+
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
+ if (!parent || !GTK_IS_TOOL_SHELL (parent))
+ return GTK_ORIENTATION_HORIZONTAL;
+
+ return gtk_tool_shell_get_text_orientation (GTK_TOOL_SHELL (parent));
+}
+
+/**
+ * gtk_tool_item_get_text_size_group:
+ * @tool_item: a #GtkToolItem
+ *
+ * Returns the size group used for labels in @tool_item.
+ * Custom subclasses of #GtkToolItem should call this function
+ * and use the size group for labels.
+ *
+ * Return value: (transfer none): a #GtkSizeGroup
+ *
+ * Since: 2.20
+ */
+GtkSizeGroup *
+gtk_tool_item_get_text_size_group (GtkToolItem *tool_item)
+{
+ GtkWidget *parent;
+
+ g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
+
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
+ if (!parent || !GTK_IS_TOOL_SHELL (parent))
+ return NULL;
+
+ return gtk_tool_shell_get_text_size_group (GTK_TOOL_SHELL (parent));
+}
+
/**
* gtk_tool_item_set_expand:
- * @tool_item: a #GtkToolItem
+ * @tool_item: a #GtkToolItem
* @expand: Whether @tool_item is allocated extra space
- *
+ *
* Sets whether @tool_item is allocated extra space when there
* is more room on the toolbar then needed for the items. The
* effect is that the item gets bigger when the toolbar gets bigger
* and smaller when the toolbar gets smaller.
- *
+ *
* Since: 2.4
- **/
+ */
void
gtk_tool_item_set_expand (GtkToolItem *tool_item,
gboolean expand)
}
}
-static gboolean
-gtk_tool_item_real_set_tooltip (GtkToolItem *tool_item,
- GtkTooltips *tooltips,
- const gchar *tip_text,
- const gchar *tip_private)
-{
- GtkWidget *child = GTK_BIN (tool_item)->child;
-
- if (!child)
- return FALSE;
-
- gtk_widget_set_tooltip_text (child, tip_text);
-
- return TRUE;
-}
-
-/**
- * gtk_tool_item_set_tooltip:
- * @tool_item: a #GtkToolItem
- * @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 @tool_item, the
- * text to be displayed as tooltip on the item and the private text
- * to be used. See gtk_tooltips_set_tip().
- *
- * Since: 2.4
- *
- * Deprecated: 2.12: Use gtk_tool_item_set_tooltip_text() instead.
- **/
-void
-gtk_tool_item_set_tooltip (GtkToolItem *tool_item,
- GtkTooltips *tooltips,
- const gchar *tip_text,
- const gchar *tip_private)
-{
- gboolean retval;
-
- g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
-
- g_signal_emit (tool_item, toolitem_signals[SET_TOOLTIP], 0,
- tooltips, tip_text, tip_private, &retval);
-}
-
/**
* gtk_tool_item_set_tooltip_text:
* @tool_item: a #GtkToolItem
g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
- child = GTK_BIN (tool_item)->child;
-
+ child = gtk_bin_get_child (GTK_BIN (tool_item));
if (child)
gtk_widget_set_tooltip_text (child, text);
}
g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
- child = GTK_BIN (tool_item)->child;
-
+ child = gtk_bin_get_child (GTK_BIN (tool_item));
if (child)
gtk_widget_set_tooltip_markup (child, markup);
}
if (use_drag_window)
{
- if (!toolitem->priv->drag_window && GTK_WIDGET_REALIZED (toolitem))
+ if (!toolitem->priv->drag_window &&
+ gtk_widget_get_realized (GTK_WIDGET (toolitem)))
{
create_drag_window(toolitem);
- if (GTK_WIDGET_MAPPED (toolitem))
+ if (gtk_widget_get_mapped (GTK_WIDGET (toolitem)))
gdk_window_show (toolitem->priv->drag_window);
}
}
* Returns the #GtkMenuItem that was last set by
* gtk_tool_item_set_proxy_menu_item(), ie. the #GtkMenuItem
* that is going to appear in the overflow menu.
- *
- * Return value: The #GtkMenuItem that is going to appear in the
+ *
+ * Return value: (transfer none): The #GtkMenuItem that is going to appear in the
* overflow menu for @tool_item.
- *
+ *
* Since: 2.4
**/
GtkWidget *
/**
* gtk_tool_item_get_proxy_menu_item:
- * @tool_item: a #GtkToolItem
+ * @tool_item: a #GtkToolItem
* @menu_item_id: a string used to identify the menu item
- *
+ *
* If @menu_item_id matches the string passed to
* gtk_tool_item_set_proxy_menu_item() return the corresponding #GtkMenuItem.
*
- * Custom subclasses of #GtkToolItem should use this function to update
- * their menu item when the #GtkToolItem changes. That the
- * @menu_item_id<!-- -->s must match ensures that a #GtkToolItem will not
- * inadvertently change a menu item that they did not create.
- *
- * Return value: The #GtkMenuItem passed to
- * gtk_tool_item_set_proxy_menu_item(), if the @menu_item_id<!-- -->s match.
- *
+ * Custom subclasses of #GtkToolItem should use this function to
+ * update their menu item when the #GtkToolItem changes. That the
+ * @menu_item_id<!-- -->s must match ensures that a #GtkToolItem
+ * will not inadvertently change a menu item that they did not create.
+ *
+ * Return value: (transfer none): The #GtkMenuItem passed to
+ * gtk_tool_item_set_proxy_menu_item(), if the @menu_item_id<!-- -->s
+ * match.
+ *
* Since: 2.4
**/
GtkWidget *
}
/**
- * gtk_tool_item_rebuild_menu()
+ * gtk_tool_item_rebuild_menu:
* @tool_item: a #GtkToolItem
- *
+ *
* Calling this function signals to the toolbar that the
* overflow menu item for @tool_item has changed. If the
* overflow menu is visible when this function it called,
* the menu will be rebuilt.
*
- * The function must be called when the tool item
- * changes what it will do in response to the "create_menu_proxy"
- * signal.
- *
+ * The function must be called when the tool item changes what it
+ * will do in response to the #GtkToolItem::create-menu-proxy signal.
+ *
* Since: 2.6
- **/
+ */
void
gtk_tool_item_rebuild_menu (GtkToolItem *tool_item)
{
+ GtkWidget *parent;
GtkWidget *widget;
-
+
g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
widget = GTK_WIDGET (tool_item);
- if (GTK_IS_TOOL_SHELL (widget->parent))
- gtk_tool_shell_rebuild_menu (GTK_TOOL_SHELL (widget->parent));
+ parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_TOOL_SHELL (parent))
+ gtk_tool_shell_rebuild_menu (GTK_TOOL_SHELL (parent));
}
/**
g_object_ref_sink (menu_item);
gtk_widget_set_sensitive (menu_item,
- GTK_WIDGET_SENSITIVE (tool_item));
+ gtk_widget_get_sensitive (GTK_WIDGET (tool_item)));
}
tool_item->priv->menu_item = menu_item;
/* The slightely inaccurate name "gtk_tool_item_toolbar_reconfigured" was
* choosen over "gtk_tool_item_tool_shell_reconfigured", since the function
* emits the "toolbar-reconfigured" signal, not "tool-shell-reconfigured".
- * Its not possible to rename the signal, and emitting another name than
+ * It's not possible to rename the signal, and emitting another name than
* indicated by the function name would be quite confusing. That's the
* price of providing stable APIs.
*/
gtk_widget_queue_resize (GTK_WIDGET (tool_item));
}
-
-#define __GTK_TOOL_ITEM_C__
-#include "gtkaliasdef.c"