2008-07-01 22:57:50 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
2004-09-27 18:37:33 +00:00
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2003 Ricardo Fernandez Pascual
|
|
|
|
|
* Copyright (C) 2004 Paolo Borelli
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2004-09-27 18:37:33 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2008-06-17 14:11:26 +00:00
|
|
|
|
|
2004-09-27 18:37:33 +00:00
|
|
|
|
#include "gtkmenutoolbutton.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
|
2004-09-27 18:37:33 +00:00
|
|
|
|
#include "gtktogglebutton.h"
|
2012-05-30 16:45:39 +00:00
|
|
|
|
#include "gtkmenubutton.h"
|
|
|
|
|
#include "gtkmenubuttonprivate.h"
|
2011-08-28 05:40:10 +00:00
|
|
|
|
#include "gtkbox.h"
|
2004-09-27 18:37:33 +00:00
|
|
|
|
#include "gtkmenu.h"
|
|
|
|
|
#include "gtkmain.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
#include "gtksizerequest.h"
|
2011-01-09 04:10:40 +00:00
|
|
|
|
#include "gtkbuildable.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
|
2005-03-22 02:14:55 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2008-06-17 14:11:26 +00:00
|
|
|
|
#include "gtkintl.h"
|
2004-09-27 18:37:33 +00:00
|
|
|
|
|
|
|
|
|
|
2011-04-14 23:08:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkmenutoolbutton
|
|
|
|
|
* @Short_description: A GtkToolItem containing a button with an additional dropdown menu
|
|
|
|
|
* @Title: GtkMenuToolButton
|
|
|
|
|
* @See_also: #GtkToolbar, #GtkToolButton
|
|
|
|
|
*
|
|
|
|
|
* A #GtkMenuToolButton is a #GtkToolItem that contains a button and
|
|
|
|
|
* a small additional button with an arrow. When clicked, the arrow
|
|
|
|
|
* button pops up a dropdown menu.
|
|
|
|
|
*
|
|
|
|
|
* Use gtk_menu_tool_button_new() to create a new
|
2013-06-25 03:47:52 +00:00
|
|
|
|
* #GtkMenuToolButton.
|
2011-04-14 23:08:33 +00:00
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # GtkMenuToolButton as GtkBuildable
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2011-04-14 23:08:33 +00:00
|
|
|
|
* The GtkMenuToolButton implementation of the GtkBuildable interface
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* supports adding a menu by specifying “menu” as the “type” attribute
|
|
|
|
|
* of a <child> element.
|
2011-04-14 23:08:33 +00:00
|
|
|
|
*
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* An example for a UI definition fragment with menus:
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* |[
|
2011-04-14 23:08:33 +00:00
|
|
|
|
* <object class="GtkMenuToolButton">
|
|
|
|
|
* <child type="menu">
|
|
|
|
|
* <object class="GtkMenu"/>
|
|
|
|
|
* </child>
|
|
|
|
|
* </object>
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2011-04-14 23:08:33 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2004-09-27 18:37:33 +00:00
|
|
|
|
struct _GtkMenuToolButtonPrivate
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *button;
|
|
|
|
|
GtkWidget *arrow_button;
|
|
|
|
|
GtkWidget *box;
|
|
|
|
|
};
|
|
|
|
|
|
2011-01-09 04:10:40 +00:00
|
|
|
|
static void gtk_menu_tool_button_buildable_interface_init (GtkBuildableIface *iface);
|
|
|
|
|
static void gtk_menu_tool_button_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const gchar *type);
|
|
|
|
|
|
2004-09-27 18:37:33 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
2004-10-05 14:19:54 +00:00
|
|
|
|
SHOW_MENU,
|
2004-09-27 18:37:33 +00:00
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
2008-05-19 14:15:34 +00:00
|
|
|
|
PROP_MENU
|
2004-09-27 18:37:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static gint signals[LAST_SIGNAL];
|
|
|
|
|
|
2011-01-09 04:10:40 +00:00
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkMenuToolButton, gtk_menu_tool_button, GTK_TYPE_TOOL_BUTTON,
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_ADD_PRIVATE (GtkMenuToolButton)
|
2011-01-09 04:10:40 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
|
gtk_menu_tool_button_buildable_interface_init))
|
2004-09-27 18:37:33 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_menu_tool_button_construct_contents (GtkMenuToolButton *button)
|
|
|
|
|
{
|
2005-08-08 18:14:26 +00:00
|
|
|
|
GtkMenuToolButtonPrivate *priv = button->priv;
|
2004-09-27 18:37:33 +00:00
|
|
|
|
GtkWidget *box;
|
2010-08-11 21:07:35 +00:00
|
|
|
|
GtkWidget *parent;
|
2004-09-27 18:37:33 +00:00
|
|
|
|
GtkOrientation orientation;
|
|
|
|
|
|
|
|
|
|
orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button));
|
|
|
|
|
|
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
|
{
|
2010-10-31 17:07:20 +00:00
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2012-05-30 16:45:39 +00:00
|
|
|
|
gtk_menu_button_set_direction (GTK_MENU_BUTTON (priv->arrow_button), GTK_ARROW_DOWN);
|
2004-09-27 18:37:33 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-05-30 16:45:39 +00:00
|
|
|
|
GtkTextDirection direction;
|
|
|
|
|
GtkArrowType type;
|
|
|
|
|
|
2010-10-31 17:07:20 +00:00
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2012-05-30 16:45:39 +00:00
|
|
|
|
direction = gtk_widget_get_direction (GTK_WIDGET (button));
|
|
|
|
|
type = (direction == GTK_TEXT_DIR_LTR ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT);
|
|
|
|
|
gtk_menu_button_set_direction (GTK_MENU_BUTTON (priv->arrow_button), type);
|
2004-09-27 18:37:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-11 21:07:35 +00:00
|
|
|
|
parent = gtk_widget_get_parent (priv->button);
|
|
|
|
|
if (priv->button && parent)
|
2004-09-27 18:37:33 +00:00
|
|
|
|
{
|
|
|
|
|
g_object_ref (priv->button);
|
2010-08-11 21:07:35 +00:00
|
|
|
|
gtk_container_remove (GTK_CONTAINER (parent),
|
2004-09-27 18:37:33 +00:00
|
|
|
|
priv->button);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (box), priv->button);
|
|
|
|
|
g_object_unref (priv->button);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-11 21:07:35 +00:00
|
|
|
|
parent = gtk_widget_get_parent (priv->arrow_button);
|
|
|
|
|
if (priv->arrow_button && parent)
|
2004-09-27 18:37:33 +00:00
|
|
|
|
{
|
|
|
|
|
g_object_ref (priv->arrow_button);
|
2010-08-11 21:07:35 +00:00
|
|
|
|
gtk_container_remove (GTK_CONTAINER (parent),
|
2004-09-27 18:37:33 +00:00
|
|
|
|
priv->arrow_button);
|
|
|
|
|
gtk_box_pack_end (GTK_BOX (box), priv->arrow_button,
|
2016-10-02 15:37:22 +00:00
|
|
|
|
FALSE, FALSE);
|
2004-09-27 18:37:33 +00:00
|
|
|
|
g_object_unref (priv->arrow_button);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->box)
|
|
|
|
|
{
|
2007-09-10 12:46:23 +00:00
|
|
|
|
gchar *tmp;
|
|
|
|
|
|
|
|
|
|
/* Transfer a possible tooltip to the new box */
|
|
|
|
|
g_object_get (priv->box, "tooltip-markup", &tmp, NULL);
|
|
|
|
|
|
|
|
|
|
if (tmp)
|
|
|
|
|
{
|
|
|
|
|
g_object_set (box, "tooltip-markup", tmp, NULL);
|
|
|
|
|
g_free (tmp);
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-27 18:37:33 +00:00
|
|
|
|
/* Note: we are not destroying the button and the arrow_button
|
|
|
|
|
* here because they were removed from their container above
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_destroy (priv->box);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->box = box;
|
|
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), priv->box);
|
|
|
|
|
gtk_widget_show_all (priv->box);
|
|
|
|
|
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (button));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_menu_tool_button_toolbar_reconfigured (GtkToolItem *toolitem)
|
|
|
|
|
{
|
|
|
|
|
gtk_menu_tool_button_construct_contents (GTK_MENU_TOOL_BUTTON (toolitem));
|
|
|
|
|
|
|
|
|
|
/* chain up */
|
2006-05-02 23:56:43 +00:00
|
|
|
|
GTK_TOOL_ITEM_CLASS (gtk_menu_tool_button_parent_class)->toolbar_reconfigured (toolitem);
|
2004-09-27 18:37:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_menu_tool_button_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuToolButton *button = GTK_MENU_TOOL_BUTTON (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_MENU:
|
|
|
|
|
gtk_menu_tool_button_set_menu (button, g_value_get_object (value));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_menu_tool_button_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuToolButton *button = GTK_MENU_TOOL_BUTTON (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_MENU:
|
2012-08-20 21:03:15 +00:00
|
|
|
|
g_value_set_object (value, gtk_menu_button_get_popup (GTK_MENU_BUTTON (button->priv->arrow_button)));
|
2004-09-27 18:37:33 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_menu_tool_button_class_init (GtkMenuToolButtonClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
GtkToolItemClass *toolitem_class;
|
|
|
|
|
|
|
|
|
|
object_class = (GObjectClass *)klass;
|
|
|
|
|
toolitem_class = (GtkToolItemClass *)klass;
|
|
|
|
|
|
|
|
|
|
object_class->set_property = gtk_menu_tool_button_set_property;
|
|
|
|
|
object_class->get_property = gtk_menu_tool_button_get_property;
|
2010-09-18 23:55:42 +00:00
|
|
|
|
|
2004-09-27 18:37:33 +00:00
|
|
|
|
toolitem_class->toolbar_reconfigured = gtk_menu_tool_button_toolbar_reconfigured;
|
|
|
|
|
|
2008-12-30 05:49:05 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkMenuToolButton::show-menu:
|
|
|
|
|
* @button: the object on which the signal is emitted
|
|
|
|
|
*
|
|
|
|
|
* The ::show-menu signal is emitted before the menu is shown.
|
|
|
|
|
*
|
2013-09-05 00:59:56 +00:00
|
|
|
|
* It can be used to populate the menu on demand, using
|
2012-05-29 18:06:40 +00:00
|
|
|
|
* gtk_menu_tool_button_set_menu().
|
2008-12-30 05:49:05 +00:00
|
|
|
|
|
2013-09-05 00:59:56 +00:00
|
|
|
|
* Note that even if you populate the menu dynamically in this way,
|
2008-12-30 05:49:05 +00:00
|
|
|
|
* you must set an empty menu on the #GtkMenuToolButton beforehand,
|
|
|
|
|
* since the arrow is made insensitive if the menu is not set.
|
|
|
|
|
*/
|
2004-10-05 14:19:54 +00:00
|
|
|
|
signals[SHOW_MENU] =
|
2005-09-01 05:11:46 +00:00
|
|
|
|
g_signal_new (I_("show-menu"),
|
2004-09-27 18:37:33 +00:00
|
|
|
|
G_OBJECT_CLASS_TYPE (klass),
|
2004-10-05 14:19:54 +00:00
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkMenuToolButtonClass, show_menu),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
2004-09-27 18:37:33 +00:00
|
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
PROP_MENU,
|
|
|
|
|
g_param_spec_object ("menu",
|
|
|
|
|
P_("Menu"),
|
|
|
|
|
P_("The dropdown menu"),
|
|
|
|
|
GTK_TYPE_MENU,
|
2005-03-22 02:14:55 +00:00
|
|
|
|
GTK_PARAM_READWRITE));
|
2004-09-27 18:37:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_menu_tool_button_init (GtkMenuToolButton *button)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *box;
|
|
|
|
|
GtkWidget *arrow_button;
|
|
|
|
|
GtkWidget *real_button;
|
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
|
button->priv = gtk_menu_tool_button_get_instance_private (button);
|
2004-09-27 18:37:33 +00:00
|
|
|
|
|
|
|
|
|
gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (button), FALSE);
|
|
|
|
|
|
2010-10-31 17:07:20 +00:00
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2004-09-27 18:37:33 +00:00
|
|
|
|
|
2010-05-24 20:31:36 +00:00
|
|
|
|
real_button = gtk_bin_get_child (GTK_BIN (button));
|
2004-09-27 18:37:33 +00:00
|
|
|
|
g_object_ref (real_button);
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (button), real_button);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (box), real_button);
|
|
|
|
|
g_object_unref (real_button);
|
|
|
|
|
|
2012-05-30 16:45:39 +00:00
|
|
|
|
arrow_button = gtk_menu_button_new ();
|
2004-09-27 18:37:33 +00:00
|
|
|
|
gtk_box_pack_end (GTK_BOX (box), arrow_button,
|
2016-10-02 15:37:22 +00:00
|
|
|
|
FALSE, FALSE);
|
2004-09-27 18:37:33 +00:00
|
|
|
|
|
|
|
|
|
/* the arrow button is insentive until we set a menu */
|
|
|
|
|
gtk_widget_set_sensitive (arrow_button, FALSE);
|
|
|
|
|
|
|
|
|
|
gtk_widget_show_all (box);
|
|
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), box);
|
2012-05-30 16:45:39 +00:00
|
|
|
|
gtk_menu_button_set_align_widget (GTK_MENU_BUTTON (arrow_button),
|
|
|
|
|
GTK_WIDGET (button));
|
2004-09-27 18:37:33 +00:00
|
|
|
|
|
|
|
|
|
button->priv->button = real_button;
|
|
|
|
|
button->priv->arrow_button = arrow_button;
|
|
|
|
|
button->priv->box = box;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-09 04:10:40 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_tool_button_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const gchar *type)
|
|
|
|
|
{
|
|
|
|
|
if (type && strcmp (type, "menu") == 0)
|
|
|
|
|
gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (buildable),
|
|
|
|
|
GTK_WIDGET (child));
|
|
|
|
|
else
|
|
|
|
|
parent_buildable_iface->add_child (buildable, builder, child, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_menu_tool_button_buildable_interface_init (GtkBuildableIface *iface)
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
iface->add_child = gtk_menu_tool_button_buildable_add_child;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-27 18:37:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_tool_button_new:
|
2010-02-19 16:53:17 +00:00
|
|
|
|
* @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
|
2004-09-27 18:37:33 +00:00
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkMenuToolButton using @icon_widget as icon and
|
|
|
|
|
* @label as label.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the new #GtkMenuToolButton
|
2004-09-27 18:37:33 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
|
|
|
|
**/
|
|
|
|
|
GtkToolItem *
|
|
|
|
|
gtk_menu_tool_button_new (GtkWidget *icon_widget,
|
|
|
|
|
const gchar *label)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuToolButton *button;
|
|
|
|
|
|
|
|
|
|
button = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON, NULL);
|
|
|
|
|
|
|
|
|
|
if (label)
|
|
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (button), label);
|
|
|
|
|
|
|
|
|
|
if (icon_widget)
|
|
|
|
|
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (button), icon_widget);
|
|
|
|
|
|
|
|
|
|
return GTK_TOOL_ITEM (button);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_tool_button_new_from_stock:
|
|
|
|
|
* @stock_id: the name of a stock item
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkMenuToolButton.
|
|
|
|
|
* The new #GtkMenuToolButton will contain an icon and label from
|
|
|
|
|
* the stock item indicated by @stock_id.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the new #GtkMenuToolButton
|
2004-09-27 18:37:33 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
2013-06-25 03:47:52 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 3.10: Use gtk_menu_tool_button_new() instead.
|
2004-09-27 18:37:33 +00:00
|
|
|
|
**/
|
|
|
|
|
GtkToolItem *
|
|
|
|
|
gtk_menu_tool_button_new_from_stock (const gchar *stock_id)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuToolButton *button;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (stock_id != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
button = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON,
|
2005-03-26 05:49:15 +00:00
|
|
|
|
"stock-id", stock_id,
|
2004-09-27 18:37:33 +00:00
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
return GTK_TOOL_ITEM (button);
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-04 11:25:19 +00:00
|
|
|
|
static void
|
2012-05-30 16:45:39 +00:00
|
|
|
|
_show_menu_emit (gpointer user_data)
|
2006-01-04 11:25:19 +00:00
|
|
|
|
{
|
2012-05-30 16:45:39 +00:00
|
|
|
|
GtkMenuToolButton *button = (GtkMenuToolButton *) user_data;
|
|
|
|
|
g_signal_emit (button, signals[SHOW_MENU], 0);
|
2006-01-04 11:25:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-09-27 18:37:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_tool_button_set_menu:
|
|
|
|
|
* @button: a #GtkMenuToolButton
|
|
|
|
|
* @menu: the #GtkMenu associated with #GtkMenuToolButton
|
|
|
|
|
*
|
|
|
|
|
* Sets the #GtkMenu that is popped up when the user clicks on the arrow.
|
|
|
|
|
* If @menu is NULL, the arrow button becomes insensitive.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
gtk_menu_tool_button_set_menu (GtkMenuToolButton *button,
|
|
|
|
|
GtkWidget *menu)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuToolButtonPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_MENU_TOOL_BUTTON (button));
|
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu) || menu == NULL);
|
|
|
|
|
|
|
|
|
|
priv = button->priv;
|
|
|
|
|
|
2012-08-20 21:03:15 +00:00
|
|
|
|
_gtk_menu_button_set_popup_with_func (GTK_MENU_BUTTON (priv->arrow_button),
|
|
|
|
|
menu,
|
|
|
|
|
_show_menu_emit,
|
|
|
|
|
button);
|
2004-09-27 18:37:33 +00:00
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (button), "menu");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_tool_button_get_menu:
|
|
|
|
|
* @button: a #GtkMenuToolButton
|
|
|
|
|
*
|
|
|
|
|
* Gets the #GtkMenu associated with #GtkMenuToolButton.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (transfer none): the #GtkMenu associated
|
2010-09-21 04:18:11 +00:00
|
|
|
|
* with #GtkMenuToolButton
|
2004-09-27 18:37:33 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
|
|
|
|
**/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_menu_tool_button_get_menu (GtkMenuToolButton *button)
|
|
|
|
|
{
|
2012-05-30 16:45:39 +00:00
|
|
|
|
GtkMenu *ret;
|
|
|
|
|
|
2004-09-27 18:37:33 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_MENU_TOOL_BUTTON (button), NULL);
|
|
|
|
|
|
2012-08-20 21:03:15 +00:00
|
|
|
|
ret = gtk_menu_button_get_popup (GTK_MENU_BUTTON (button->priv->arrow_button));
|
2012-05-30 16:45:39 +00:00
|
|
|
|
if (!ret)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return GTK_WIDGET (ret);
|
2004-09-27 18:37:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
Replace non-deprecated API using old tooltips API, deprecate old tooltips
2007-07-09 Kristian Rietveld <kris@imendio.com>
Replace non-deprecated API using old tooltips API, deprecate
old tooltips API for real. (#451575).
* gtk/gtk.symbols: updated.
* gtk/gtkwidget.c (gtk_widget_real_show_help): don't call
_gtk_tooltips_toggle_keyboard_mode() anymore.
* gtk/gtkmenutoolbutton.[ch] (gtk_menu_tool_button_set_arrow_tooltip):
deprecated,
(gtk_menu_tool_button_set_arrow_tooltip_{text,markup}): replacements.
* gtk/gtktoolitem.[ch] (gtk_tool_item_real_set_tooltip): use
new API,
(gtk_tool_item_set_tooltip): deprecated,
(gtk_tool_item_set_tooltip_{text,markup): replacements.
(GtkToolItemClass:set_tooltip): deprecated.
* gtk/gtktooltips.[ch]: strip out all unused parts, made
gtk_tooltips_set_tip() call gtk_widget_set_tooltip_text(),
deprecate all of gtk_tooltips_*.
* gtk/gtktoolbar.[ch] (gtk_toolbar_get_tooltips): always return
TRUE,
(GtkToolbar:tooltips): deprecated, renamed.
* gtk/gtkaction.c (gtk_action_sync_tooltip): use new API to
set the tooltip text.
* tests/autotestfilechooser.c: #undef GTK_DISABLE_DEPRECATED for now,
will be removed GtkFileChooserDefault has been converted.
svn path=/trunk/; revision=18418
2007-07-09 19:23:18 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_tool_button_set_arrow_tooltip_text:
|
|
|
|
|
* @button: a #GtkMenuToolButton
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* @text: text to be used as tooltip text for button’s arrow button
|
Replace non-deprecated API using old tooltips API, deprecate old tooltips
2007-07-09 Kristian Rietveld <kris@imendio.com>
Replace non-deprecated API using old tooltips API, deprecate
old tooltips API for real. (#451575).
* gtk/gtk.symbols: updated.
* gtk/gtkwidget.c (gtk_widget_real_show_help): don't call
_gtk_tooltips_toggle_keyboard_mode() anymore.
* gtk/gtkmenutoolbutton.[ch] (gtk_menu_tool_button_set_arrow_tooltip):
deprecated,
(gtk_menu_tool_button_set_arrow_tooltip_{text,markup}): replacements.
* gtk/gtktoolitem.[ch] (gtk_tool_item_real_set_tooltip): use
new API,
(gtk_tool_item_set_tooltip): deprecated,
(gtk_tool_item_set_tooltip_{text,markup): replacements.
(GtkToolItemClass:set_tooltip): deprecated.
* gtk/gtktooltips.[ch]: strip out all unused parts, made
gtk_tooltips_set_tip() call gtk_widget_set_tooltip_text(),
deprecate all of gtk_tooltips_*.
* gtk/gtktoolbar.[ch] (gtk_toolbar_get_tooltips): always return
TRUE,
(GtkToolbar:tooltips): deprecated, renamed.
* gtk/gtkaction.c (gtk_action_sync_tooltip): use new API to
set the tooltip text.
* tests/autotestfilechooser.c: #undef GTK_DISABLE_DEPRECATED for now,
will be removed GtkFileChooserDefault has been converted.
svn path=/trunk/; revision=18418
2007-07-09 19:23:18 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the tooltip text to be used as tooltip for the arrow button which
|
2009-12-07 21:42:08 +00:00
|
|
|
|
* pops up the menu. See gtk_tool_item_set_tooltip_text() for setting a tooltip
|
Replace non-deprecated API using old tooltips API, deprecate old tooltips
2007-07-09 Kristian Rietveld <kris@imendio.com>
Replace non-deprecated API using old tooltips API, deprecate
old tooltips API for real. (#451575).
* gtk/gtk.symbols: updated.
* gtk/gtkwidget.c (gtk_widget_real_show_help): don't call
_gtk_tooltips_toggle_keyboard_mode() anymore.
* gtk/gtkmenutoolbutton.[ch] (gtk_menu_tool_button_set_arrow_tooltip):
deprecated,
(gtk_menu_tool_button_set_arrow_tooltip_{text,markup}): replacements.
* gtk/gtktoolitem.[ch] (gtk_tool_item_real_set_tooltip): use
new API,
(gtk_tool_item_set_tooltip): deprecated,
(gtk_tool_item_set_tooltip_{text,markup): replacements.
(GtkToolItemClass:set_tooltip): deprecated.
* gtk/gtktooltips.[ch]: strip out all unused parts, made
gtk_tooltips_set_tip() call gtk_widget_set_tooltip_text(),
deprecate all of gtk_tooltips_*.
* gtk/gtktoolbar.[ch] (gtk_toolbar_get_tooltips): always return
TRUE,
(GtkToolbar:tooltips): deprecated, renamed.
* gtk/gtkaction.c (gtk_action_sync_tooltip): use new API to
set the tooltip text.
* tests/autotestfilechooser.c: #undef GTK_DISABLE_DEPRECATED for now,
will be removed GtkFileChooserDefault has been converted.
svn path=/trunk/; revision=18418
2007-07-09 19:23:18 +00:00
|
|
|
|
* on the whole #GtkMenuToolButton.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.12
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
gtk_menu_tool_button_set_arrow_tooltip_text (GtkMenuToolButton *button,
|
|
|
|
|
const gchar *text)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_MENU_TOOL_BUTTON (button));
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_tooltip_text (button->priv->arrow_button, text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_tool_button_set_arrow_tooltip_markup:
|
|
|
|
|
* @button: a #GtkMenuToolButton
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* @markup: markup text to be used as tooltip text for button’s arrow button
|
Replace non-deprecated API using old tooltips API, deprecate old tooltips
2007-07-09 Kristian Rietveld <kris@imendio.com>
Replace non-deprecated API using old tooltips API, deprecate
old tooltips API for real. (#451575).
* gtk/gtk.symbols: updated.
* gtk/gtkwidget.c (gtk_widget_real_show_help): don't call
_gtk_tooltips_toggle_keyboard_mode() anymore.
* gtk/gtkmenutoolbutton.[ch] (gtk_menu_tool_button_set_arrow_tooltip):
deprecated,
(gtk_menu_tool_button_set_arrow_tooltip_{text,markup}): replacements.
* gtk/gtktoolitem.[ch] (gtk_tool_item_real_set_tooltip): use
new API,
(gtk_tool_item_set_tooltip): deprecated,
(gtk_tool_item_set_tooltip_{text,markup): replacements.
(GtkToolItemClass:set_tooltip): deprecated.
* gtk/gtktooltips.[ch]: strip out all unused parts, made
gtk_tooltips_set_tip() call gtk_widget_set_tooltip_text(),
deprecate all of gtk_tooltips_*.
* gtk/gtktoolbar.[ch] (gtk_toolbar_get_tooltips): always return
TRUE,
(GtkToolbar:tooltips): deprecated, renamed.
* gtk/gtkaction.c (gtk_action_sync_tooltip): use new API to
set the tooltip text.
* tests/autotestfilechooser.c: #undef GTK_DISABLE_DEPRECATED for now,
will be removed GtkFileChooserDefault has been converted.
svn path=/trunk/; revision=18418
2007-07-09 19:23:18 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the tooltip markup text to be used as tooltip for the arrow button
|
2013-09-05 00:59:56 +00:00
|
|
|
|
* which pops up the menu. See gtk_tool_item_set_tooltip_text() for setting
|
|
|
|
|
* a tooltip on the whole #GtkMenuToolButton.
|
Replace non-deprecated API using old tooltips API, deprecate old tooltips
2007-07-09 Kristian Rietveld <kris@imendio.com>
Replace non-deprecated API using old tooltips API, deprecate
old tooltips API for real. (#451575).
* gtk/gtk.symbols: updated.
* gtk/gtkwidget.c (gtk_widget_real_show_help): don't call
_gtk_tooltips_toggle_keyboard_mode() anymore.
* gtk/gtkmenutoolbutton.[ch] (gtk_menu_tool_button_set_arrow_tooltip):
deprecated,
(gtk_menu_tool_button_set_arrow_tooltip_{text,markup}): replacements.
* gtk/gtktoolitem.[ch] (gtk_tool_item_real_set_tooltip): use
new API,
(gtk_tool_item_set_tooltip): deprecated,
(gtk_tool_item_set_tooltip_{text,markup): replacements.
(GtkToolItemClass:set_tooltip): deprecated.
* gtk/gtktooltips.[ch]: strip out all unused parts, made
gtk_tooltips_set_tip() call gtk_widget_set_tooltip_text(),
deprecate all of gtk_tooltips_*.
* gtk/gtktoolbar.[ch] (gtk_toolbar_get_tooltips): always return
TRUE,
(GtkToolbar:tooltips): deprecated, renamed.
* gtk/gtkaction.c (gtk_action_sync_tooltip): use new API to
set the tooltip text.
* tests/autotestfilechooser.c: #undef GTK_DISABLE_DEPRECATED for now,
will be removed GtkFileChooserDefault has been converted.
svn path=/trunk/; revision=18418
2007-07-09 19:23:18 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.12
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
gtk_menu_tool_button_set_arrow_tooltip_markup (GtkMenuToolButton *button,
|
|
|
|
|
const gchar *markup)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_MENU_TOOL_BUTTON (button));
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_tooltip_markup (button->priv->arrow_button, markup);
|
|
|
|
|
}
|