2008-07-01 22:57:50 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
1997-11-24 22:37:52 +00:00
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
|
* 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
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* 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/>.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2001-03-23 23:39:24 +00:00
|
|
|
|
* Modified by the GTK+ Team and others 1997-2001. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
|
*/
|
|
|
|
|
|
2010-05-01 17:17:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkbutton
|
2012-02-13 08:15:03 +00:00
|
|
|
|
* @Short_description: A widget that emits a signal when clicked on
|
2010-05-01 17:17:51 +00:00
|
|
|
|
* @Title: GtkButton
|
|
|
|
|
*
|
2012-02-13 08:15:03 +00:00
|
|
|
|
* The #GtkButton widget is generally used to trigger a callback function that is
|
2010-05-01 17:17:51 +00:00
|
|
|
|
* called when the button is pressed. The various signals and how to use them
|
|
|
|
|
* are outlined below.
|
|
|
|
|
*
|
2012-02-13 08:15:03 +00:00
|
|
|
|
* The #GtkButton widget can hold any valid child widget. That is, it can hold
|
|
|
|
|
* almost any other standard #GtkWidget. The most commonly used child is the
|
2010-05-01 17:17:51 +00:00
|
|
|
|
* #GtkLabel.
|
2015-10-30 02:55:29 +00:00
|
|
|
|
*
|
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
|
|
|
|
* GtkButton has a single CSS node with name button. The node will get the
|
|
|
|
|
* style classes .image-button or .text-button, if the content is just an
|
|
|
|
|
* image or label, respectively. It may also receive the .flat style class.
|
|
|
|
|
*
|
|
|
|
|
* Other style classes that are commonly used with GtkButton include
|
2016-03-03 00:10:59 +00:00
|
|
|
|
* .suggested-action and .destructive-action. In special cases, buttons
|
|
|
|
|
* can be made round by adding the .circular style class.
|
2015-11-02 17:51:00 +00:00
|
|
|
|
*
|
|
|
|
|
* Button-like widgets like #GtkToggleButton, #GtkMenuButton, #GtkVolumeButton,
|
2019-06-20 19:51:37 +00:00
|
|
|
|
* #GtkLockButton, #GtkColorButton or #GtkFontButton use style classes such as
|
|
|
|
|
* .toggle, .popup, .scale, .lock, .color on the button node
|
2015-11-02 17:51:00 +00:00
|
|
|
|
* to differentiate themselves from a plain GtkButton.
|
2020-07-27 14:46:52 +00:00
|
|
|
|
*
|
|
|
|
|
* # Accessibility
|
|
|
|
|
*
|
|
|
|
|
* GtkButton uses the #GTK_ACCESSIBLE_ROLE_BUTTON role.
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2010-10-19 00:01:31 +00:00
|
|
|
|
|
|
|
|
|
#include "gtkbuttonprivate.h"
|
|
|
|
|
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkactionhelperprivate.h"
|
2020-05-02 14:30:46 +00:00
|
|
|
|
#include "gtkbuildable.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkcheckbutton.h"
|
2019-05-29 17:10:46 +00:00
|
|
|
|
#include "gtkgestureclick.h"
|
2018-06-05 12:34:36 +00:00
|
|
|
|
#include "gtkeventcontrollerkey.h"
|
2020-05-02 14:30:46 +00:00
|
|
|
|
#include "gtkbinlayout.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkimage.h"
|
|
|
|
|
#include "gtkintl.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
|
#include "gtklabel.h"
|
|
|
|
|
#include "gtkmain.h"
|
2001-11-17 23:28:51 +00:00
|
|
|
|
#include "gtkmarshalers.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2019-03-16 03:48:26 +00:00
|
|
|
|
#include "gtkstylecontext.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtktypebuiltins.h"
|
2020-04-08 11:43:28 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2020-08-15 12:27:24 +00:00
|
|
|
|
#include "gtkshortcuttrigger.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
|
|
|
|
|
#include <string.h>
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2004-02-19 22:39:58 +00:00
|
|
|
|
/* Time out before giving up on getting a key release when animating
|
2001-03-06 15:51:10 +00:00
|
|
|
|
* the close button.
|
|
|
|
|
*/
|
|
|
|
|
#define ACTIVATE_TIMEOUT 250
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2018-02-25 10:29:33 +00:00
|
|
|
|
struct _GtkButtonPrivate
|
|
|
|
|
{
|
2020-05-02 14:30:46 +00:00
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkActionHelper *action_helper;
|
|
|
|
|
|
|
|
|
|
GtkGesture *gesture;
|
|
|
|
|
|
|
|
|
|
guint activate_timeout;
|
|
|
|
|
|
|
|
|
|
guint button_down : 1;
|
|
|
|
|
guint use_underline : 1;
|
|
|
|
|
guint child_type : 2;
|
|
|
|
|
};
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
enum {
|
|
|
|
|
CLICKED,
|
2001-03-06 15:51:10 +00:00
|
|
|
|
ACTIVATE,
|
1997-11-24 22:37:52 +00:00
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
Move more text widget headers into the private header list
2000-09-26 Havoc Pennington <hp@redhat.com>
* gtk/Makefile.am (gtk_private_h_sources): Move more text widget
headers into the private header list
* Makefile.am (pkgconfig_DATA): install pkg-config files
* configure.in: add pkg-config files
* gdk-2.0.pc.in, gdk-pixbuf.pc.in, gtk+-2.0.pc.in: pkg-config files
* gtk/gtkwindow.c (gtk_window_read_rcfiles): Invalidate
outstanding icon caches on theme change.
* gtk/gtkiconfactory.h, gtk/gtkiconfactory.c: New icon system. Three
important types:
(GtkIconSource): Specification for creating a pixbuf
appropriate for a direction/state/size triplet from
a source pixbuf or filename
(GtkIconSet): List of GtkIconSource objects that are used to
create the "same" icon (e.g. an OK button icon), and cache for
rendered icons
(GtkIconFactory): Hash from stock ID to GtkIconSet; used to look
up the icon set for a given stock ID. GTK maintains a stack of
GtkIconFactory to search, and applications or libraries can add
additional icon factories on top of the stack
* gtk/gtkrc.h, gtk/gtkrc.c: When loading an RcStyle, parse
the set of GtkIconSource specified for a given stock ID into
a GtkIconSet, and put the GtkIconSet into a GtkIconFactory for the
RcStyle, under the specified stock ID.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Add a virtual function
render_icon used to derive a GdkPixbuf from a GtkIconSource.
This allows people to theme how prelight, insensitive, etc. are
done.
(gtk_style_lookup_icon_set): Look up a stock ID in the list of
icon factories for a style, and return the resulting
icon set if any.
(gtk_style_render_icon): Render an icon using the render_icon
method in the GtkStyleClass.
* gtk/gtkwidget.h, gtk/gtkwidget.c (gtk_widget_render_icon):
Use the style for a given widget to look up a stock ID, get the
icon set, and render an icon using the render_icon method
of the style
* gtk/gtkstock.h, gtk/gtkstock.c: Header with the GtkStockItem type
(contains information about a stock item), the built-in stock item
IDs, and functions to add/lookup stock items.
* gtk/stock-icons/*: Stock icons that come with GTK
* gtk/gtkbutton.h, gtk/gtkbutton.c (gtk_button_new_stock): Returns
a button based on a GtkStockItem
(gtk_button_new_accel): Takes a uline string and accel group, and
installs the accelerator.
* gtk/gtkimage.h, gtk/gtkimage.c: Make this into a generic
image-display widget.
2000-09-26 20:22:17 +00:00
|
|
|
|
|
1998-01-16 00:49:51 +00:00
|
|
|
|
enum {
|
2001-03-23 23:39:24 +00:00
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_LABEL,
|
2020-04-17 04:20:09 +00:00
|
|
|
|
PROP_HAS_FRAME,
|
2001-08-27 01:05:07 +00:00
|
|
|
|
PROP_USE_UNDERLINE,
|
2016-10-14 14:01:56 +00:00
|
|
|
|
PROP_ICON_NAME,
|
2020-05-02 06:45:09 +00:00
|
|
|
|
PROP_CHILD,
|
2014-06-07 13:40:55 +00:00
|
|
|
|
|
|
|
|
|
/* actionable properties */
|
2012-01-06 03:22:06 +00:00
|
|
|
|
PROP_ACTION_NAME,
|
|
|
|
|
PROP_ACTION_TARGET,
|
2014-06-07 13:40:55 +00:00
|
|
|
|
LAST_PROP = PROP_ACTION_NAME
|
2003-12-15 00:00:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
2016-10-20 15:58:03 +00:00
|
|
|
|
enum {
|
|
|
|
|
LABEL_CHILD,
|
|
|
|
|
ICON_CHILD,
|
|
|
|
|
WIDGET_CHILD
|
|
|
|
|
};
|
|
|
|
|
|
1998-05-03 22:41:32 +00:00
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
static void gtk_button_dispose (GObject *object);
|
2005-06-30 21:18:34 +00:00
|
|
|
|
static void gtk_button_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gtk_button_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2009-01-27 02:55:02 +00:00
|
|
|
|
static void gtk_button_unrealize (GtkWidget * widget);
|
|
|
|
|
static void gtk_real_button_clicked (GtkButton * button);
|
2005-06-30 21:18:34 +00:00
|
|
|
|
static void gtk_real_button_activate (GtkButton *button);
|
|
|
|
|
static void gtk_button_finish_activate (GtkButton *button,
|
2020-08-15 09:54:38 +00:00
|
|
|
|
gboolean do_it);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2016-11-01 19:28:28 +00:00
|
|
|
|
static void gtk_button_state_flags_changed (GtkWidget *widget,
|
|
|
|
|
GtkStateFlags previous_state);
|
2015-02-25 19:29:22 +00:00
|
|
|
|
static void gtk_button_do_release (GtkButton *button,
|
|
|
|
|
gboolean emit_clicked);
|
2020-05-02 14:30:46 +00:00
|
|
|
|
static void gtk_button_set_child_type (GtkButton *button, guint child_type);
|
2001-08-27 01:05:07 +00:00
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
static void gtk_button_buildable_iface_init (GtkBuildableIface *iface);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
static void gtk_button_actionable_iface_init (GtkActionableInterface *iface);
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
2014-06-07 13:40:55 +00:00
|
|
|
|
static GParamSpec *props[LAST_PROP] = { NULL, };
|
1998-03-09 15:16:28 +00:00
|
|
|
|
static guint button_signals[LAST_SIGNAL] = { 0 };
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkButton, gtk_button, GTK_TYPE_WIDGET,
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_ADD_PRIVATE (GtkButton)
|
2020-05-02 14:30:46 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_button_buildable_iface_init)
|
2016-10-12 20:06:44 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIONABLE, gtk_button_actionable_iface_init))
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2016-10-20 15:58:03 +00:00
|
|
|
|
static void
|
2020-05-02 14:30:46 +00:00
|
|
|
|
gtk_button_compute_expand (GtkWidget *widget,
|
|
|
|
|
gboolean *hexpand,
|
|
|
|
|
gboolean *vexpand)
|
2016-10-20 15:58:03 +00:00
|
|
|
|
{
|
2020-05-02 14:30:46 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (GTK_BUTTON (widget));
|
2016-10-20 15:58:03 +00:00
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
if (priv->child)
|
|
|
|
|
{
|
|
|
|
|
*hexpand = gtk_widget_compute_expand (priv->child, GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
|
*vexpand = gtk_widget_compute_expand (priv->child, GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*hexpand = FALSE;
|
|
|
|
|
*vexpand = FALSE;
|
|
|
|
|
}
|
2016-10-20 15:58:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
static GtkSizeRequestMode
|
|
|
|
|
gtk_button_get_request_mode (GtkWidget *widget)
|
2017-07-02 18:45:23 +00:00
|
|
|
|
{
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (GTK_BUTTON (widget));
|
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
if (priv->child)
|
|
|
|
|
return gtk_widget_get_request_mode (priv->child);
|
|
|
|
|
else
|
|
|
|
|
return GTK_SIZE_REQUEST_CONSTANT_SIZE;
|
2017-07-02 18:45:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_class_init (GtkButtonClass *klass)
|
|
|
|
|
{
|
2020-08-15 12:27:24 +00:00
|
|
|
|
const guint activate_keyvals[] = { GDK_KEY_space, GDK_KEY_KP_Space, GDK_KEY_Return,
|
|
|
|
|
GDK_KEY_ISO_Enter, GDK_KEY_KP_Enter };
|
2002-10-11 22:57:11 +00:00
|
|
|
|
GObjectClass *gobject_class;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
GtkWidgetClass *widget_class;
|
2020-08-15 12:27:24 +00:00
|
|
|
|
GtkShortcutAction *activate_action;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2002-10-11 22:57:11 +00:00
|
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
widget_class = (GtkWidgetClass*) klass;
|
2016-10-20 15:58:03 +00:00
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
gobject_class->dispose = gtk_button_dispose;
|
2002-10-11 22:57:11 +00:00
|
|
|
|
gobject_class->set_property = gtk_button_set_property;
|
|
|
|
|
gobject_class->get_property = gtk_button_get_property;
|
doh, this was broken beyond believe.
Tue Dec 12 23:46:44 2000 Tim Janik <timj@gtk.org>
* gtk/stock-icons/Makefile.am: doh, this was broken beyond believe.
* gtk/gtkbox.c: change property types from (u)long to (u)int for
::position and ::padding.
* gtk/gtkcontainer.c: make ::border_width an INT property.
* gtk/gtkpacker.c: make ::position an INT property.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed):
guard against NULL h/v scrollbars, since this is used at construction
time.
* gtk/gtkclist.[hc]: nuked gtk_clist_construct(), implemented
internal gtk_clist_constructor().
* gtk/gtkctree.[hc]: nuked gtk_ctree_construct(), implemented
gtk_ctree_constructor().
* gtk/gtkprogressbar.c (gtk_progress_bar_class_init): property
::pulse_step should use ARG_PULSE_STEP, not ARG_FRACTION.
* docs/reference/Makefile.am: fun stuff, disabled docs generation
again, gtk-scan.c needs to introspec paramspecs, not GtkAgs.
* gtk/gtkwidget.[hc]:
removed gtk_widget_setv(), gtk_widget_getv(), gtk_widget_newv()
and gtk_widget_get().
(gtk_widget_new): use g_object_new_valist().
(gtk_widget_set): use g_object_set_valist().
* gtk/gtkobject.[hc]:
removed gtk_object_arg_get_info(), gtk_object_getv(),
gtk_object_query_args(), gtk_object_newv(),
gtk_object_class_add_signals(),
gtk_object_class_user_signal_new(),
gtk_object_class_user_signal_newv(),
gtk_object_arg_set(), gtk_object_arg_get(),
gtk_object_args_collect(),
gtk_object_default_construct(),
gtk_object_constructed(),
GTK_CONSTRUCTED and GTK_OBJECT_CONSTRUCTED().
removed nsignals, signals and n_args members from GtkObjectClass.
(gtk_object_new): use g_object_new_valist().
(gtk_object_set): use g_object_set_valist().
(gtk_object_get): use g_object_get_valist().
* gtk/gtkcompat.h: define gtk_object_default_construct().
* gtk/gtktypeutils.c (gtk_type_new): create constructed objects via
g_object_new().
* gtk/*.c: removed gtk_object_class_add_signals() from class_init()
fucntions, cleaned up method assignments (make sure your structures
are setup properly before calling out). removed all GTK_CONSTRUCTED
hacks ;)
2000-12-13 01:34:41 +00:00
|
|
|
|
|
2001-03-06 15:51:10 +00:00
|
|
|
|
widget_class->unrealize = gtk_button_unrealize;
|
2016-11-01 19:28:28 +00:00
|
|
|
|
widget_class->state_flags_changed = gtk_button_state_flags_changed;
|
2020-05-02 14:30:46 +00:00
|
|
|
|
widget_class->compute_expand = gtk_button_compute_expand;
|
|
|
|
|
widget_class->get_request_mode = gtk_button_get_request_mode;
|
2016-10-20 15:58:03 +00:00
|
|
|
|
|
2009-01-27 02:55:02 +00:00
|
|
|
|
klass->clicked = NULL;
|
2001-03-06 15:51:10 +00:00
|
|
|
|
klass->activate = gtk_real_button_activate;
|
doh, this was broken beyond believe.
Tue Dec 12 23:46:44 2000 Tim Janik <timj@gtk.org>
* gtk/stock-icons/Makefile.am: doh, this was broken beyond believe.
* gtk/gtkbox.c: change property types from (u)long to (u)int for
::position and ::padding.
* gtk/gtkcontainer.c: make ::border_width an INT property.
* gtk/gtkpacker.c: make ::position an INT property.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed):
guard against NULL h/v scrollbars, since this is used at construction
time.
* gtk/gtkclist.[hc]: nuked gtk_clist_construct(), implemented
internal gtk_clist_constructor().
* gtk/gtkctree.[hc]: nuked gtk_ctree_construct(), implemented
gtk_ctree_constructor().
* gtk/gtkprogressbar.c (gtk_progress_bar_class_init): property
::pulse_step should use ARG_PULSE_STEP, not ARG_FRACTION.
* docs/reference/Makefile.am: fun stuff, disabled docs generation
again, gtk-scan.c needs to introspec paramspecs, not GtkAgs.
* gtk/gtkwidget.[hc]:
removed gtk_widget_setv(), gtk_widget_getv(), gtk_widget_newv()
and gtk_widget_get().
(gtk_widget_new): use g_object_new_valist().
(gtk_widget_set): use g_object_set_valist().
* gtk/gtkobject.[hc]:
removed gtk_object_arg_get_info(), gtk_object_getv(),
gtk_object_query_args(), gtk_object_newv(),
gtk_object_class_add_signals(),
gtk_object_class_user_signal_new(),
gtk_object_class_user_signal_newv(),
gtk_object_arg_set(), gtk_object_arg_get(),
gtk_object_args_collect(),
gtk_object_default_construct(),
gtk_object_constructed(),
GTK_CONSTRUCTED and GTK_OBJECT_CONSTRUCTED().
removed nsignals, signals and n_args members from GtkObjectClass.
(gtk_object_new): use g_object_new_valist().
(gtk_object_set): use g_object_set_valist().
(gtk_object_get): use g_object_get_valist().
* gtk/gtkcompat.h: define gtk_object_default_construct().
* gtk/gtktypeutils.c (gtk_type_new): create constructed objects via
g_object_new().
* gtk/*.c: removed gtk_object_class_add_signals() from class_init()
fucntions, cleaned up method assignments (make sure your structures
are setup properly before calling out). removed all GTK_CONSTRUCTED
hacks ;)
2000-12-13 01:34:41 +00:00
|
|
|
|
|
2014-06-07 13:40:55 +00:00
|
|
|
|
props[PROP_LABEL] =
|
|
|
|
|
g_param_spec_string ("label",
|
|
|
|
|
P_("Label"),
|
|
|
|
|
P_("Text of the label widget inside the button, if the button contains a label widget"),
|
|
|
|
|
NULL,
|
2016-10-14 14:01:56 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2016-10-02 17:03:29 +00:00
|
|
|
|
|
2014-06-07 13:40:55 +00:00
|
|
|
|
props[PROP_USE_UNDERLINE] =
|
|
|
|
|
g_param_spec_boolean ("use-underline",
|
|
|
|
|
P_("Use underline"),
|
|
|
|
|
P_("If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key"),
|
|
|
|
|
FALSE,
|
2016-10-14 14:01:56 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2016-10-02 17:03:29 +00:00
|
|
|
|
|
2020-04-17 04:20:09 +00:00
|
|
|
|
props[PROP_HAS_FRAME] =
|
|
|
|
|
g_param_spec_boolean ("has-frame",
|
|
|
|
|
P_("Has Frame"),
|
|
|
|
|
P_("Whether the button has a frame"),
|
|
|
|
|
TRUE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2016-10-14 14:01:56 +00:00
|
|
|
|
props[PROP_ICON_NAME] =
|
|
|
|
|
g_param_spec_string ("icon-name",
|
|
|
|
|
P_("Icon Name"),
|
|
|
|
|
P_("The name of the icon used to automatically populate the button"),
|
|
|
|
|
NULL,
|
2014-06-07 14:48:49 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2004-11-15 20:56:28 +00:00
|
|
|
|
|
2020-05-02 06:45:09 +00:00
|
|
|
|
props[PROP_CHILD] =
|
|
|
|
|
g_param_spec_object ("child",
|
|
|
|
|
P_("Child"),
|
|
|
|
|
P_("The child widget"),
|
|
|
|
|
GTK_TYPE_WIDGET,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2014-06-07 13:40:55 +00:00
|
|
|
|
|
|
|
|
|
g_object_class_install_properties (gobject_class, LAST_PROP, props);
|
2012-05-20 15:58:45 +00:00
|
|
|
|
|
2012-01-06 03:22:06 +00:00
|
|
|
|
g_object_class_override_property (gobject_class, PROP_ACTION_NAME, "action-name");
|
|
|
|
|
g_object_class_override_property (gobject_class, PROP_ACTION_TARGET, "action-target");
|
|
|
|
|
|
2005-06-17 18:42:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkButton::clicked:
|
|
|
|
|
* @button: the object that received the signal
|
|
|
|
|
*
|
|
|
|
|
* Emitted when the button has been activated (pressed and released).
|
2016-10-02 17:46:52 +00:00
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
button_signals[CLICKED] =
|
2005-09-01 05:11:46 +00:00
|
|
|
|
g_signal_new (I_("clicked"),
|
2020-08-15 09:54:38 +00:00
|
|
|
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_STRUCT_OFFSET (GtkButtonClass, clicked),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
G_TYPE_NONE, 0);
|
2005-06-17 18:42:49 +00:00
|
|
|
|
|
2003-12-18 00:39:17 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkButton::activate:
|
2004-04-15 14:31:02 +00:00
|
|
|
|
* @widget: the object which received the signal.
|
2003-12-18 00:39:17 +00:00
|
|
|
|
*
|
2007-05-26 06:59:36 +00:00
|
|
|
|
* The ::activate signal on GtkButton is an action signal and
|
2016-10-02 17:46:52 +00:00
|
|
|
|
* emitting it causes the button to animate press then release.
|
2003-12-18 00:39:17 +00:00
|
|
|
|
* Applications should never connect to this signal, but use the
|
2007-05-26 06:59:36 +00:00
|
|
|
|
* #GtkButton::clicked signal.
|
2003-12-18 00:39:17 +00:00
|
|
|
|
*/
|
2001-03-06 15:51:10 +00:00
|
|
|
|
button_signals[ACTIVATE] =
|
2005-09-01 05:11:46 +00:00
|
|
|
|
g_signal_new (I_("activate"),
|
2020-08-15 09:54:38 +00:00
|
|
|
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_STRUCT_OFFSET (GtkButtonClass, activate),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
G_TYPE_NONE, 0);
|
2001-03-06 15:51:10 +00:00
|
|
|
|
widget_class->activate_signal = button_signals[ACTIVATE];
|
2020-08-15 12:27:24 +00:00
|
|
|
|
activate_action = gtk_signal_action_new ("activate");
|
Fix G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 15:51:28 +00:00
|
|
|
|
|
2020-08-15 12:27:24 +00:00
|
|
|
|
for (guint i = 0; i < G_N_ELEMENTS (activate_keyvals); i++)
|
|
|
|
|
{
|
|
|
|
|
GtkShortcut *activate_shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (activate_keyvals[i], 0),
|
|
|
|
|
g_object_ref (activate_action));
|
2020-07-18 16:51:18 +00:00
|
|
|
|
|
2020-08-15 12:27:24 +00:00
|
|
|
|
gtk_widget_class_add_shortcut (widget_class, activate_shortcut);
|
|
|
|
|
g_object_unref (activate_shortcut);
|
|
|
|
|
}
|
|
|
|
|
g_object_unref (activate_action);
|
2020-07-13 15:03:27 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_BUTTON);
|
2020-08-15 12:27:24 +00:00
|
|
|
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
|
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("button"));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 00:15:40 +00:00
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
|
click_pressed_cb (GtkGestureClick *gesture,
|
|
|
|
|
guint n_press,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double x,
|
|
|
|
|
double y,
|
2019-05-29 17:10:46 +00:00
|
|
|
|
GtkWidget *widget)
|
2014-05-02 00:15:40 +00:00
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2020-08-10 02:58:22 +00:00
|
|
|
|
GdkEventSequence *sequence;
|
2014-05-02 00:15:40 +00:00
|
|
|
|
|
2015-10-23 16:39:01 +00:00
|
|
|
|
if (gtk_widget_get_focus_on_click (widget) && !gtk_widget_has_focus (widget))
|
2014-05-02 00:15:40 +00:00
|
|
|
|
gtk_widget_grab_focus (widget);
|
2014-05-12 17:12:27 +00:00
|
|
|
|
|
2020-08-10 02:58:22 +00:00
|
|
|
|
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
|
|
|
|
gtk_gesture_set_sequence_state (GTK_GESTURE (gesture), sequence, GTK_EVENT_SEQUENCE_CLAIMED);
|
|
|
|
|
|
2016-10-02 17:46:52 +00:00
|
|
|
|
if (!priv->activate_timeout)
|
2019-01-25 16:17:20 +00:00
|
|
|
|
priv->button_down = TRUE;
|
2014-05-02 00:15:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
|
click_released_cb (GtkGestureClick *gesture,
|
|
|
|
|
guint n_press,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double x,
|
|
|
|
|
double y,
|
2019-05-29 17:10:46 +00:00
|
|
|
|
GtkWidget *widget)
|
2014-05-02 00:15:40 +00:00
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
2014-09-25 13:24:46 +00:00
|
|
|
|
|
2020-08-05 20:56:05 +00:00
|
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
2016-10-02 17:46:52 +00:00
|
|
|
|
gtk_button_do_release (button,
|
|
|
|
|
gtk_widget_is_sensitive (GTK_WIDGET (button)) &&
|
2020-09-25 17:10:46 +00:00
|
|
|
|
gtk_widget_contains (widget, x, y));
|
2014-08-20 18:12:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-25 19:29:22 +00:00
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
|
click_gesture_cancel_cb (GtkGesture *gesture,
|
|
|
|
|
GdkEventSequence *sequence,
|
|
|
|
|
GtkButton *button)
|
2015-02-25 19:29:22 +00:00
|
|
|
|
{
|
2020-06-24 12:17:15 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
|
|
|
|
|
|
|
|
|
if (priv->activate_timeout)
|
|
|
|
|
gtk_button_finish_activate (button, FALSE);
|
|
|
|
|
|
2015-02-25 19:29:22 +00:00
|
|
|
|
gtk_button_do_release (button, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-05 12:34:36 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
key_controller_key_pressed_cb (GtkEventControllerKey *controller,
|
|
|
|
|
guint keyval,
|
|
|
|
|
guint keycode,
|
|
|
|
|
guint modifiers,
|
|
|
|
|
GtkButton *button)
|
|
|
|
|
{
|
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
|
|
|
|
|
|
|
|
|
return priv->activate_timeout != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
key_controller_key_released_cb (GtkEventControllerKey *controller,
|
|
|
|
|
guint keyval,
|
|
|
|
|
guint keycode,
|
|
|
|
|
guint modifiers,
|
|
|
|
|
GtkButton *button)
|
|
|
|
|
{
|
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
|
|
|
|
|
|
|
|
|
if (priv->activate_timeout)
|
|
|
|
|
gtk_button_finish_activate (button, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-20 15:58:03 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_set_child_type (GtkButton *button, guint child_type)
|
|
|
|
|
{
|
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
|
|
|
|
|
|
|
|
|
if (priv->child_type == child_type)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (child_type != LABEL_CHILD)
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_LABEL]);
|
|
|
|
|
else if (child_type != ICON_CHILD)
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_ICON_NAME]);
|
|
|
|
|
|
|
|
|
|
priv->child_type = child_type;
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_init (GtkButton *button)
|
|
|
|
|
{
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2018-09-23 15:59:37 +00:00
|
|
|
|
GtkEventController *key_controller;
|
2003-12-15 00:00:19 +00:00
|
|
|
|
|
2020-05-05 18:57:21 +00:00
|
|
|
|
gtk_widget_set_focusable (GTK_WIDGET (button), TRUE);
|
2010-03-01 16:41:37 +00:00
|
|
|
|
gtk_widget_set_receives_default (GTK_WIDGET (button), TRUE);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv->button_down = FALSE;
|
|
|
|
|
priv->use_underline = FALSE;
|
2016-10-20 15:58:03 +00:00
|
|
|
|
priv->child_type = WIDGET_CHILD;
|
2003-12-15 00:00:19 +00:00
|
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
|
priv->gesture = gtk_gesture_click_new ();
|
2014-05-02 00:15:40 +00:00
|
|
|
|
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->gesture), FALSE);
|
2014-05-12 17:52:35 +00:00
|
|
|
|
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (priv->gesture), TRUE);
|
2014-05-02 00:15:40 +00:00
|
|
|
|
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->gesture), GDK_BUTTON_PRIMARY);
|
2019-05-29 17:10:46 +00:00
|
|
|
|
g_signal_connect (priv->gesture, "pressed", G_CALLBACK (click_pressed_cb), button);
|
|
|
|
|
g_signal_connect (priv->gesture, "released", G_CALLBACK (click_released_cb), button);
|
|
|
|
|
g_signal_connect (priv->gesture, "cancel", G_CALLBACK (click_gesture_cancel_cb), button);
|
2017-03-31 15:59:43 +00:00
|
|
|
|
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->gesture), GTK_PHASE_CAPTURE);
|
2018-03-09 05:14:59 +00:00
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (priv->gesture));
|
2018-06-05 12:34:36 +00:00
|
|
|
|
|
2018-09-23 15:59:37 +00:00
|
|
|
|
key_controller = gtk_event_controller_key_new ();
|
|
|
|
|
g_signal_connect (key_controller, "key-pressed", G_CALLBACK (key_controller_key_pressed_cb), button);
|
|
|
|
|
g_signal_connect (key_controller, "key-released", G_CALLBACK (key_controller_key_released_cb), button);
|
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (button), key_controller);
|
2001-11-25 22:19:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
static void
|
2009-01-23 15:15:28 +00:00
|
|
|
|
gtk_button_dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (object);
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
g_clear_pointer (&priv->child, gtk_widget_unparent);
|
2012-08-17 22:27:21 +00:00
|
|
|
|
g_clear_object (&priv->action_helper);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_button_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-06 03:22:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_set_action_name (GtkActionable *actionable,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *action_name)
|
2012-01-06 03:22:06 +00:00
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (actionable);
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
|
2018-02-25 10:29:33 +00:00
|
|
|
|
if (!priv->action_helper)
|
|
|
|
|
priv->action_helper = gtk_action_helper_new (actionable);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
|
2012-08-17 22:27:21 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (button, gtk_real_button_clicked, NULL);
|
|
|
|
|
if (action_name)
|
|
|
|
|
g_signal_connect_after (button, "clicked", G_CALLBACK (gtk_real_button_clicked), NULL);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
|
2018-02-25 10:29:33 +00:00
|
|
|
|
gtk_action_helper_set_action_name (priv->action_helper, action_name);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_set_action_target_value (GtkActionable *actionable,
|
|
|
|
|
GVariant *action_target)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (actionable);
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
|
2018-02-25 10:29:33 +00:00
|
|
|
|
if (!priv->action_helper)
|
|
|
|
|
priv->action_helper = gtk_action_helper_new (actionable);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
|
2018-02-25 10:29:33 +00:00
|
|
|
|
gtk_action_helper_set_action_target_value (priv->action_helper, action_target);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void
|
2001-03-23 23:39:24 +00:00
|
|
|
|
gtk_button_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2003-12-15 00:00:19 +00:00
|
|
|
|
GtkButton *button = GTK_BUTTON (object);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2001-03-23 23:39:24 +00:00
|
|
|
|
switch (prop_id)
|
1998-01-16 00:49:51 +00:00
|
|
|
|
{
|
2001-03-23 23:39:24 +00:00
|
|
|
|
case PROP_LABEL:
|
2001-08-27 01:05:07 +00:00
|
|
|
|
gtk_button_set_label (button, g_value_get_string (value));
|
1998-01-16 00:49:51 +00:00
|
|
|
|
break;
|
2020-04-17 04:20:09 +00:00
|
|
|
|
case PROP_HAS_FRAME:
|
|
|
|
|
gtk_button_set_has_frame (button, g_value_get_boolean (value));
|
1998-07-08 14:12:27 +00:00
|
|
|
|
break;
|
2001-08-27 01:05:07 +00:00
|
|
|
|
case PROP_USE_UNDERLINE:
|
|
|
|
|
gtk_button_set_use_underline (button, g_value_get_boolean (value));
|
|
|
|
|
break;
|
2016-10-14 14:01:56 +00:00
|
|
|
|
case PROP_ICON_NAME:
|
|
|
|
|
gtk_button_set_icon_name (button, g_value_get_string (value));
|
2006-05-31 00:22:19 +00:00
|
|
|
|
break;
|
2020-05-02 06:45:09 +00:00
|
|
|
|
case PROP_CHILD:
|
|
|
|
|
gtk_button_set_child (button, g_value_get_object (value));
|
|
|
|
|
break;
|
2012-01-06 03:22:06 +00:00
|
|
|
|
case PROP_ACTION_NAME:
|
|
|
|
|
gtk_button_set_action_name (GTK_ACTIONABLE (button), g_value_get_string (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ACTION_TARGET:
|
|
|
|
|
gtk_button_set_action_target_value (GTK_ACTIONABLE (button), g_value_get_variant (value));
|
|
|
|
|
break;
|
1998-06-16 05:20:05 +00:00
|
|
|
|
default:
|
2001-03-23 23:39:24 +00:00
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
1998-06-16 05:20:05 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2001-03-23 23:39:24 +00:00
|
|
|
|
gtk_button_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
1998-06-16 05:20:05 +00:00
|
|
|
|
{
|
2003-12-15 00:00:19 +00:00
|
|
|
|
GtkButton *button = GTK_BUTTON (object);
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
1998-06-28 07:46:10 +00:00
|
|
|
|
|
2001-03-23 23:39:24 +00:00
|
|
|
|
switch (prop_id)
|
1998-06-16 05:20:05 +00:00
|
|
|
|
{
|
2001-03-23 23:39:24 +00:00
|
|
|
|
case PROP_LABEL:
|
2016-10-20 15:58:03 +00:00
|
|
|
|
g_value_set_string (value, gtk_button_get_label (button));
|
1998-06-16 05:20:05 +00:00
|
|
|
|
break;
|
2020-04-17 04:20:09 +00:00
|
|
|
|
case PROP_HAS_FRAME:
|
|
|
|
|
g_value_set_boolean (value, gtk_button_get_has_frame (button));
|
1998-07-08 14:12:27 +00:00
|
|
|
|
break;
|
2001-08-27 01:05:07 +00:00
|
|
|
|
case PROP_USE_UNDERLINE:
|
2010-10-18 17:39:19 +00:00
|
|
|
|
g_value_set_boolean (value, priv->use_underline);
|
2001-08-27 01:05:07 +00:00
|
|
|
|
break;
|
2016-10-14 14:01:56 +00:00
|
|
|
|
case PROP_ICON_NAME:
|
|
|
|
|
g_value_set_string (value, gtk_button_get_icon_name (button));
|
2006-05-31 00:22:19 +00:00
|
|
|
|
break;
|
2020-05-02 06:45:09 +00:00
|
|
|
|
case PROP_CHILD:
|
2020-05-02 14:30:46 +00:00
|
|
|
|
g_value_set_object (value, priv->child);
|
2020-05-02 06:45:09 +00:00
|
|
|
|
break;
|
2012-01-06 03:22:06 +00:00
|
|
|
|
case PROP_ACTION_NAME:
|
2012-08-17 22:27:21 +00:00
|
|
|
|
g_value_set_string (value, gtk_action_helper_get_action_name (priv->action_helper));
|
2012-01-06 03:22:06 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_ACTION_TARGET:
|
2012-08-17 22:27:21 +00:00
|
|
|
|
g_value_set_variant (value, gtk_action_helper_get_action_target_value (priv->action_helper));
|
2012-01-06 03:22:06 +00:00
|
|
|
|
break;
|
1998-01-21 23:03:11 +00:00
|
|
|
|
default:
|
2001-03-23 23:39:24 +00:00
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
1998-01-21 23:03:11 +00:00
|
|
|
|
break;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
|
static const char *
|
2012-01-06 03:22:06 +00:00
|
|
|
|
gtk_button_get_action_name (GtkActionable *actionable)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (actionable);
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
|
2018-02-25 10:29:33 +00:00
|
|
|
|
return gtk_action_helper_get_action_name (priv->action_helper);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GVariant *
|
|
|
|
|
gtk_button_get_action_target_value (GtkActionable *actionable)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (actionable);
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
|
2018-02-25 10:29:33 +00:00
|
|
|
|
return gtk_action_helper_get_action_target_value (priv->action_helper);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_actionable_iface_init (GtkActionableInterface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->get_action_name = gtk_button_get_action_name;
|
|
|
|
|
iface->set_action_name = gtk_button_set_action_name;
|
|
|
|
|
iface->get_action_target_value = gtk_button_get_action_target_value;
|
|
|
|
|
iface->set_action_target_value = gtk_button_set_action_target_value;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *type)
|
2020-05-02 14:30:46 +00:00
|
|
|
|
{
|
|
|
|
|
if (GTK_IS_WIDGET (child))
|
|
|
|
|
gtk_button_set_child (GTK_BUTTON (buildable), GTK_WIDGET (child));
|
|
|
|
|
else
|
|
|
|
|
parent_buildable_iface->add_child (buildable, builder, child, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_buildable_iface_init (GtkBuildableIface *iface)
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
|
|
|
|
|
iface->add_child = gtk_button_buildable_add_child;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-01 17:17:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_button_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkButton widget. To add a child widget to the button,
|
2020-08-01 13:34:59 +00:00
|
|
|
|
* use gtk_button_set_child().
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: The newly created #GtkButton widget.
|
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
GtkWidget*
|
1998-05-03 22:41:32 +00:00
|
|
|
|
gtk_button_new (void)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2002-10-11 22:57:11 +00:00
|
|
|
|
return g_object_new (GTK_TYPE_BUTTON, NULL);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-01 17:17:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2001-08-27 01:05:07 +00:00
|
|
|
|
GtkWidget*
|
2020-07-24 18:40:36 +00:00
|
|
|
|
gtk_button_new_with_label (const char *label)
|
2001-08-27 01:05:07 +00:00
|
|
|
|
{
|
2013-08-19 18:00:37 +00:00
|
|
|
|
return g_object_new (GTK_TYPE_BUTTON, "label", label, NULL);
|
2001-08-27 01:05:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-14 07:41:42 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_button_new_from_icon_name:
|
2017-02-16 11:22:33 +00:00
|
|
|
|
* @icon_name: (nullable): an icon name or %NULL
|
2013-08-14 07:41:42 +00:00
|
|
|
|
*
|
2013-08-19 18:40:22 +00:00
|
|
|
|
* Creates a new button containing an icon from the current icon theme.
|
|
|
|
|
*
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* If the icon name isn’t known, a “broken image” icon will be
|
2013-08-14 07:41:42 +00:00
|
|
|
|
* displayed instead. If the current icon theme is changed, the icon
|
|
|
|
|
* will be updated appropriately.
|
2013-08-19 18:40:22 +00:00
|
|
|
|
*
|
2013-08-14 07:41:42 +00:00
|
|
|
|
* Returns: a new #GtkButton displaying the themed icon
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2013-08-14 07:41:42 +00:00
|
|
|
|
GtkWidget*
|
2020-07-24 18:40:36 +00:00
|
|
|
|
gtk_button_new_from_icon_name (const char *icon_name)
|
2013-08-14 07:41:42 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
2017-01-20 07:02:48 +00:00
|
|
|
|
button = g_object_new (GTK_TYPE_BUTTON,
|
|
|
|
|
"icon-name", icon_name,
|
|
|
|
|
NULL);
|
2013-08-14 07:41:42 +00:00
|
|
|
|
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
2001-03-21 18:58:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_button_new_with_mnemonic:
|
|
|
|
|
* @label: The text of the button, with an underscore in front of the
|
|
|
|
|
* mnemonic character
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkButton containing a label.
|
More precise documentation about underscores and mnemonics. (#66380)
* gtk/gtklabel.c (gtk_label_new_with_mnemonic),
gtk/gtkbutton.c (gtk_button_new_with_mnemonic): More precise
documentation about underscores and mnemonics. (#66380)
* gtk/gtktextiter.c (gtk_text_iter_backward_word_starts): Fix
cyclic reference in docs.
* gtk/gtklabel.c (gtk_label_set_justify): Correct documentation
of default value. (#65402)
* gtk/gtkmain.c (gtk_set_locale, gtk_disable_set_locale):
Markup fixes.
* gdk-pixbuf-io.c, gdk-pixbuf-animation.c, gdk-pixbuf-data.c,
gdk-pixbuf-loader.c, gdk-pixbuf-scale.c, gdk-pixbuf-util.c,
gdk-pixdata.c: Markup fixes.
* gtk/text_widget.sgml: More precise wording. (#63388)
* gtk/tmpl/gtksignal.sgml (GTK_SIGNAL_OFFSET): Add docs.
* gtk/resources.sgml: Fix markup of mail URLs.
* gtk/tmpl/gtkpaned.sgml, gtk/tmpl/gtkobject.sgml: Markup fixes.
* gtk/tmpl/gtktoolbar.sgml (gtk_toolbar_{prepend,append}_element):
Expand documentation. (#60471)
* gtk/tmpl/gtkmain.sgml: Remove misleading information about
gtk_set_locale(). (#65758)
2001-12-20 23:09:29 +00:00
|
|
|
|
* If characters in @label are preceded by an underscore, they are underlined.
|
2014-02-07 19:03:49 +00:00
|
|
|
|
* If you need a literal underscore character in a label, use “__” (two
|
2011-09-26 00:58:59 +00:00
|
|
|
|
* underscores). The first underlined character represents a keyboard
|
More precise documentation about underscores and mnemonics. (#66380)
* gtk/gtklabel.c (gtk_label_new_with_mnemonic),
gtk/gtkbutton.c (gtk_button_new_with_mnemonic): More precise
documentation about underscores and mnemonics. (#66380)
* gtk/gtktextiter.c (gtk_text_iter_backward_word_starts): Fix
cyclic reference in docs.
* gtk/gtklabel.c (gtk_label_set_justify): Correct documentation
of default value. (#65402)
* gtk/gtkmain.c (gtk_set_locale, gtk_disable_set_locale):
Markup fixes.
* gdk-pixbuf-io.c, gdk-pixbuf-animation.c, gdk-pixbuf-data.c,
gdk-pixbuf-loader.c, gdk-pixbuf-scale.c, gdk-pixbuf-util.c,
gdk-pixdata.c: Markup fixes.
* gtk/text_widget.sgml: More precise wording. (#63388)
* gtk/tmpl/gtksignal.sgml (GTK_SIGNAL_OFFSET): Add docs.
* gtk/resources.sgml: Fix markup of mail URLs.
* gtk/tmpl/gtkpaned.sgml, gtk/tmpl/gtkobject.sgml: Markup fixes.
* gtk/tmpl/gtktoolbar.sgml (gtk_toolbar_{prepend,append}_element):
Expand documentation. (#60471)
* gtk/tmpl/gtkmain.sgml: Remove misleading information about
gtk_set_locale(). (#65758)
2001-12-20 23:09:29 +00:00
|
|
|
|
* accelerator called a mnemonic.
|
2001-03-21 18:58:28 +00:00
|
|
|
|
* Pressing Alt and that key activates the button.
|
2011-09-26 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: a new #GtkButton
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
Move more text widget headers into the private header list
2000-09-26 Havoc Pennington <hp@redhat.com>
* gtk/Makefile.am (gtk_private_h_sources): Move more text widget
headers into the private header list
* Makefile.am (pkgconfig_DATA): install pkg-config files
* configure.in: add pkg-config files
* gdk-2.0.pc.in, gdk-pixbuf.pc.in, gtk+-2.0.pc.in: pkg-config files
* gtk/gtkwindow.c (gtk_window_read_rcfiles): Invalidate
outstanding icon caches on theme change.
* gtk/gtkiconfactory.h, gtk/gtkiconfactory.c: New icon system. Three
important types:
(GtkIconSource): Specification for creating a pixbuf
appropriate for a direction/state/size triplet from
a source pixbuf or filename
(GtkIconSet): List of GtkIconSource objects that are used to
create the "same" icon (e.g. an OK button icon), and cache for
rendered icons
(GtkIconFactory): Hash from stock ID to GtkIconSet; used to look
up the icon set for a given stock ID. GTK maintains a stack of
GtkIconFactory to search, and applications or libraries can add
additional icon factories on top of the stack
* gtk/gtkrc.h, gtk/gtkrc.c: When loading an RcStyle, parse
the set of GtkIconSource specified for a given stock ID into
a GtkIconSet, and put the GtkIconSet into a GtkIconFactory for the
RcStyle, under the specified stock ID.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Add a virtual function
render_icon used to derive a GdkPixbuf from a GtkIconSource.
This allows people to theme how prelight, insensitive, etc. are
done.
(gtk_style_lookup_icon_set): Look up a stock ID in the list of
icon factories for a style, and return the resulting
icon set if any.
(gtk_style_render_icon): Render an icon using the render_icon
method in the GtkStyleClass.
* gtk/gtkwidget.h, gtk/gtkwidget.c (gtk_widget_render_icon):
Use the style for a given widget to look up a stock ID, get the
icon set, and render an icon using the render_icon method
of the style
* gtk/gtkstock.h, gtk/gtkstock.c: Header with the GtkStockItem type
(contains information about a stock item), the built-in stock item
IDs, and functions to add/lookup stock items.
* gtk/stock-icons/*: Stock icons that come with GTK
* gtk/gtkbutton.h, gtk/gtkbutton.c (gtk_button_new_stock): Returns
a button based on a GtkStockItem
(gtk_button_new_accel): Takes a uline string and accel group, and
installs the accelerator.
* gtk/gtkimage.h, gtk/gtkimage.c: Make this into a generic
image-display widget.
2000-09-26 20:22:17 +00:00
|
|
|
|
GtkWidget*
|
2020-07-24 18:40:36 +00:00
|
|
|
|
gtk_button_new_with_mnemonic (const char *label)
|
Move more text widget headers into the private header list
2000-09-26 Havoc Pennington <hp@redhat.com>
* gtk/Makefile.am (gtk_private_h_sources): Move more text widget
headers into the private header list
* Makefile.am (pkgconfig_DATA): install pkg-config files
* configure.in: add pkg-config files
* gdk-2.0.pc.in, gdk-pixbuf.pc.in, gtk+-2.0.pc.in: pkg-config files
* gtk/gtkwindow.c (gtk_window_read_rcfiles): Invalidate
outstanding icon caches on theme change.
* gtk/gtkiconfactory.h, gtk/gtkiconfactory.c: New icon system. Three
important types:
(GtkIconSource): Specification for creating a pixbuf
appropriate for a direction/state/size triplet from
a source pixbuf or filename
(GtkIconSet): List of GtkIconSource objects that are used to
create the "same" icon (e.g. an OK button icon), and cache for
rendered icons
(GtkIconFactory): Hash from stock ID to GtkIconSet; used to look
up the icon set for a given stock ID. GTK maintains a stack of
GtkIconFactory to search, and applications or libraries can add
additional icon factories on top of the stack
* gtk/gtkrc.h, gtk/gtkrc.c: When loading an RcStyle, parse
the set of GtkIconSource specified for a given stock ID into
a GtkIconSet, and put the GtkIconSet into a GtkIconFactory for the
RcStyle, under the specified stock ID.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Add a virtual function
render_icon used to derive a GdkPixbuf from a GtkIconSource.
This allows people to theme how prelight, insensitive, etc. are
done.
(gtk_style_lookup_icon_set): Look up a stock ID in the list of
icon factories for a style, and return the resulting
icon set if any.
(gtk_style_render_icon): Render an icon using the render_icon
method in the GtkStyleClass.
* gtk/gtkwidget.h, gtk/gtkwidget.c (gtk_widget_render_icon):
Use the style for a given widget to look up a stock ID, get the
icon set, and render an icon using the render_icon method
of the style
* gtk/gtkstock.h, gtk/gtkstock.c: Header with the GtkStockItem type
(contains information about a stock item), the built-in stock item
IDs, and functions to add/lookup stock items.
* gtk/stock-icons/*: Stock icons that come with GTK
* gtk/gtkbutton.h, gtk/gtkbutton.c (gtk_button_new_stock): Returns
a button based on a GtkStockItem
(gtk_button_new_accel): Takes a uline string and accel group, and
installs the accelerator.
* gtk/gtkimage.h, gtk/gtkimage.c: Make this into a generic
image-display widget.
2000-09-26 20:22:17 +00:00
|
|
|
|
{
|
2013-08-19 18:00:37 +00:00
|
|
|
|
return g_object_new (GTK_TYPE_BUTTON, "label", label, "use-underline", TRUE, NULL);
|
Move more text widget headers into the private header list
2000-09-26 Havoc Pennington <hp@redhat.com>
* gtk/Makefile.am (gtk_private_h_sources): Move more text widget
headers into the private header list
* Makefile.am (pkgconfig_DATA): install pkg-config files
* configure.in: add pkg-config files
* gdk-2.0.pc.in, gdk-pixbuf.pc.in, gtk+-2.0.pc.in: pkg-config files
* gtk/gtkwindow.c (gtk_window_read_rcfiles): Invalidate
outstanding icon caches on theme change.
* gtk/gtkiconfactory.h, gtk/gtkiconfactory.c: New icon system. Three
important types:
(GtkIconSource): Specification for creating a pixbuf
appropriate for a direction/state/size triplet from
a source pixbuf or filename
(GtkIconSet): List of GtkIconSource objects that are used to
create the "same" icon (e.g. an OK button icon), and cache for
rendered icons
(GtkIconFactory): Hash from stock ID to GtkIconSet; used to look
up the icon set for a given stock ID. GTK maintains a stack of
GtkIconFactory to search, and applications or libraries can add
additional icon factories on top of the stack
* gtk/gtkrc.h, gtk/gtkrc.c: When loading an RcStyle, parse
the set of GtkIconSource specified for a given stock ID into
a GtkIconSet, and put the GtkIconSet into a GtkIconFactory for the
RcStyle, under the specified stock ID.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Add a virtual function
render_icon used to derive a GdkPixbuf from a GtkIconSource.
This allows people to theme how prelight, insensitive, etc. are
done.
(gtk_style_lookup_icon_set): Look up a stock ID in the list of
icon factories for a style, and return the resulting
icon set if any.
(gtk_style_render_icon): Render an icon using the render_icon
method in the GtkStyleClass.
* gtk/gtkwidget.h, gtk/gtkwidget.c (gtk_widget_render_icon):
Use the style for a given widget to look up a stock ID, get the
icon set, and render an icon using the render_icon method
of the style
* gtk/gtkstock.h, gtk/gtkstock.c: Header with the GtkStockItem type
(contains information about a stock item), the built-in stock item
IDs, and functions to add/lookup stock items.
* gtk/stock-icons/*: Stock icons that come with GTK
* gtk/gtkbutton.h, gtk/gtkbutton.c (gtk_button_new_stock): Returns
a button based on a GtkStockItem
(gtk_button_new_accel): Takes a uline string and accel group, and
installs the accelerator.
* gtk/gtkimage.h, gtk/gtkimage.c: Make this into a generic
image-display widget.
2000-09-26 20:22:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-01 17:17:51 +00:00
|
|
|
|
/**
|
2020-04-20 02:50:35 +00:00
|
|
|
|
* gtk_button_set_has_frame:
|
2020-04-17 04:20:09 +00:00
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
* @has_frame: whether the button should have a visible frame
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*
|
2020-04-17 04:20:09 +00:00
|
|
|
|
* Sets the style of the button. Buttons can has a flat appearance
|
|
|
|
|
* or have a frame drawn around them.
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*/
|
1998-05-12 21:30:52 +00:00
|
|
|
|
void
|
2020-04-17 04:20:09 +00:00
|
|
|
|
gtk_button_set_has_frame (GtkButton *button,
|
|
|
|
|
gboolean has_frame)
|
1998-05-12 21:30:52 +00:00
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
1998-05-12 21:30:52 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
|
2020-04-17 04:20:09 +00:00
|
|
|
|
if (gtk_button_get_has_frame (button) == has_frame)
|
|
|
|
|
return;
|
2014-06-27 01:59:06 +00:00
|
|
|
|
|
2020-04-17 04:20:09 +00:00
|
|
|
|
if (has_frame)
|
2020-08-13 23:49:02 +00:00
|
|
|
|
gtk_widget_remove_css_class (GTK_WIDGET (button), "flat");
|
2020-04-17 04:20:09 +00:00
|
|
|
|
else
|
2020-08-13 23:49:02 +00:00
|
|
|
|
gtk_widget_add_css_class (GTK_WIDGET (button), "flat");
|
2020-04-17 04:20:09 +00:00
|
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_HAS_FRAME]);
|
1998-05-12 21:30:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-01 17:17:51 +00:00
|
|
|
|
/**
|
2020-04-17 04:20:09 +00:00
|
|
|
|
* gtk_button_get_has_frame:
|
|
|
|
|
* @button: a #GtkButton
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*
|
2020-04-17 04:20:09 +00:00
|
|
|
|
* Returns whether the button has a frame.
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*
|
2020-04-17 04:20:09 +00:00
|
|
|
|
* Returns: %TRUE if the button has a frame
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*/
|
2020-04-17 04:20:09 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_button_get_has_frame (GtkButton *button)
|
1998-05-12 21:30:52 +00:00
|
|
|
|
{
|
2020-04-17 04:20:09 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), TRUE);
|
1998-05-12 21:30:52 +00:00
|
|
|
|
|
2020-08-13 23:49:02 +00:00
|
|
|
|
return !gtk_widget_has_css_class (GTK_WIDGET (button), "flat");
|
1998-05-12 21:30:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-03-06 15:51:10 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_unrealize (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2001-03-06 15:51:10 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if (priv->activate_timeout)
|
2001-03-06 15:51:10 +00:00
|
|
|
|
gtk_button_finish_activate (button, FALSE);
|
2001-11-15 21:04:51 +00:00
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_button_parent_class)->unrealize (widget);
|
2001-03-06 15:51:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-02 12:41:15 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_do_release (GtkButton *button,
|
|
|
|
|
gboolean emit_clicked)
|
|
|
|
|
{
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2013-12-02 12:41:15 +00:00
|
|
|
|
|
|
|
|
|
if (priv->button_down)
|
|
|
|
|
{
|
|
|
|
|
priv->button_down = FALSE;
|
|
|
|
|
|
|
|
|
|
if (priv->activate_timeout)
|
2020-08-15 09:54:38 +00:00
|
|
|
|
return;
|
2013-12-02 12:41:15 +00:00
|
|
|
|
|
|
|
|
|
if (emit_clicked)
|
2019-05-18 18:15:54 +00:00
|
|
|
|
g_signal_emit (button, button_signals[CLICKED], 0);
|
2013-12-02 12:41:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void
|
2009-01-27 02:55:02 +00:00
|
|
|
|
gtk_real_button_clicked (GtkButton *button)
|
2009-01-23 15:15:28 +00:00
|
|
|
|
{
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
2012-08-17 22:27:21 +00:00
|
|
|
|
if (priv->action_helper)
|
|
|
|
|
gtk_action_helper_activate (priv->action_helper);
|
2009-01-23 15:15:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-03-06 15:51:10 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
button_activate_timeout (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
gtk_button_finish_activate (data, TRUE);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_real_button_activate (GtkButton *button)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (button);
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2010-08-17 13:43:08 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if (gtk_widget_get_realized (widget) && !priv->activate_timeout)
|
2001-03-06 15:51:10 +00:00
|
|
|
|
{
|
2018-02-02 14:51:47 +00:00
|
|
|
|
priv->activate_timeout = g_timeout_add (ACTIVATE_TIMEOUT, button_activate_timeout, button);
|
2019-02-05 10:26:20 +00:00
|
|
|
|
g_source_set_name_by_id (priv->activate_timeout, "[gtk] button_activate_timeout");
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv->button_down = TRUE;
|
2001-03-06 15:51:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_finish_activate (GtkButton *button,
|
2020-08-15 09:54:38 +00:00
|
|
|
|
gboolean do_it)
|
2001-03-06 15:51:10 +00:00
|
|
|
|
{
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2005-06-27 20:04:33 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
g_source_remove (priv->activate_timeout);
|
|
|
|
|
priv->activate_timeout = 0;
|
2001-03-06 15:51:10 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv->button_down = FALSE;
|
2001-09-03 06:45:17 +00:00
|
|
|
|
|
2001-03-06 15:51:10 +00:00
|
|
|
|
if (do_it)
|
2019-05-18 18:15:54 +00:00
|
|
|
|
g_signal_emit (button, button_signals[CLICKED], 0);
|
2001-03-06 15:51:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-08-27 01:05:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_button_set_label:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
* @label: a string
|
|
|
|
|
*
|
2016-10-14 14:01:56 +00:00
|
|
|
|
* Sets the text of the label of the button to @label.
|
2001-08-27 01:05:07 +00:00
|
|
|
|
*
|
|
|
|
|
* This will also clear any previously set labels.
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2001-08-27 01:05:07 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_button_set_label (GtkButton *button,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *label)
|
2001-08-27 01:05:07 +00:00
|
|
|
|
{
|
2016-10-14 14:01:56 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
|
|
|
|
GtkWidget *child;
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
2003-11-07 21:57:20 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
if (priv->child_type != LABEL_CHILD || priv->child == NULL)
|
2016-10-14 14:01:56 +00:00
|
|
|
|
{
|
2016-10-20 15:58:03 +00:00
|
|
|
|
child = gtk_label_new (NULL);
|
|
|
|
|
if (priv->use_underline)
|
2016-10-14 14:01:56 +00:00
|
|
|
|
{
|
2016-10-20 15:58:03 +00:00
|
|
|
|
gtk_label_set_use_underline (GTK_LABEL (child), priv->use_underline);
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (child), GTK_WIDGET (button));
|
2016-10-14 14:01:56 +00:00
|
|
|
|
}
|
2017-10-07 02:32:53 +00:00
|
|
|
|
if (GTK_IS_CHECK_BUTTON (button))
|
2020-05-02 14:30:46 +00:00
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (child), 0.0);
|
|
|
|
|
|
|
|
|
|
gtk_button_set_child (button, child);
|
2020-02-06 16:32:26 +00:00
|
|
|
|
gtk_widget_remove_css_class (GTK_WIDGET (button), "image-button");
|
|
|
|
|
gtk_widget_add_css_class (GTK_WIDGET (button), "text-button");
|
2016-10-14 14:01:56 +00:00
|
|
|
|
}
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
gtk_label_set_label (GTK_LABEL (priv->child), label);
|
2016-10-20 15:58:03 +00:00
|
|
|
|
gtk_button_set_child_type (button, LABEL_CHILD);
|
2020-04-23 19:08:18 +00:00
|
|
|
|
|
2020-07-13 16:04:38 +00:00
|
|
|
|
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_LABEL, label,
|
|
|
|
|
-1);
|
|
|
|
|
|
2014-06-07 13:40:55 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_LABEL]);
|
2001-08-27 01:05:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_button_get_label:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
*
|
|
|
|
|
* Fetches the text from the label of the button, as set by
|
2016-11-18 19:43:34 +00:00
|
|
|
|
* gtk_button_set_label(). If the label text has not
|
|
|
|
|
* been set the return value will be %NULL. This will be the
|
|
|
|
|
* case if you create an empty button with gtk_button_new() to
|
2001-11-14 22:36:23 +00:00
|
|
|
|
* use as a container.
|
2001-08-27 01:05:07 +00:00
|
|
|
|
*
|
2016-10-14 14:01:56 +00:00
|
|
|
|
* Returns: (nullable): The text of the label widget. This string is owned
|
Minor documentation fixes
2002-08-10 Soren Sandmann <sandmann@daimi.au.dk>
* docs/reference/gtk/tree_widget.sgml,
docs/reference/gtk/tmpl/gtkdialog.sgml,
docs/reference/gtk/tmpl/gtkentry.sgml,
docs/reference/gtk/tmpl/gtkfilesel.sgml,
docs/reference/gtk/tmpl/gtkfontsel.sgml,
docs/reference/gtk/tmpl/gtkfontseldlg.sgml,
docs/reference/gtk/tmpl/gtktreemodel.sgml,
docs/reference/gtk/tmpl/gtkwidget.sgml, gdk/x11/gdkdisplay-x11.c,
gtk/gtkbbox.c, gtk/gtkbox.c, gtk/gtkbutton.c, gtk/gtkcellrenderer.c,
gtk/gtkcellrendererpixbuf.c, gtk/gtkcellrenderertext.c,
gtk/gtkcheckmenuitem.c, gtk/gtkcontainer.c, gtk/gtkcurve.c,
gtk/gtkdialog.h, gtk/gtkentry.c, gtk/gtkfilesel.c, gtk/gtkfontsel.c,
gtk/gtkframe.c, gtk/gtkhandlebox.c, gtk/gtkiconfactory.c,
gtk/gtkimage.c, gtk/gtkinvisible.c, gtk/gtkitemfactory.c,
gtk/gtklabel.c, gtk/gtklayout.c, gtk/gtkmenu.c, gtk/gtkprogress.c,
gtk/gtkprogressbar.c, gtk/gtkscrolledwindow.c, gtk/gtksizegroup.c,
gtk/gtktable.c, gtk/gtktextiter.c, gtk/gtktexttag.c,
gtk/gtktexttag.h, gtk/gtktextview.c, gtk/gtktogglebutton.c,
gtk/gtktoolbar.c, gtk/gtktreemodel.c, gtk/gtktreeselection.c,
gtk/gtktreestore.c, gtk/gtktreeview.c, gtk/gtktreeviewcolumn.c,
gtk/gtkviewport.c, gtk/gtkwidget.c, gtk/gtkwidget.h,
gtk/gtkwindow.c:
Minor documentation fixes
(#89254, patch from Brett Nash;
#85809, patch from daten@dnetc.org;
#76391, patch from Ross Burton;
#74559, Manuel Clos;
#73569, #72005, Alexey A. Malyshev;
#70061, patch from Dennis Bj"orklund;
#64566, #63388, #58328, #57499, #81007, #77349, Vitaly Tishkov;
#78932, Vitaly Tishkov, patch from Ross Burton;
#73306)
2002-08-10 09:55:41 +00:00
|
|
|
|
* by the widget and must not be modified or freed.
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *
|
2001-08-27 01:05:07 +00:00
|
|
|
|
gtk_button_get_label (GtkButton *button)
|
|
|
|
|
{
|
2016-10-20 15:58:03 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
|
|
|
|
|
2001-08-27 01:05:07 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
2016-10-20 15:58:03 +00:00
|
|
|
|
if (priv->child_type == LABEL_CHILD)
|
2020-05-02 14:30:46 +00:00
|
|
|
|
return gtk_label_get_label (GTK_LABEL (priv->child));
|
2016-10-20 15:58:03 +00:00
|
|
|
|
|
|
|
|
|
return NULL;
|
2001-08-27 01:05:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_button_set_use_underline:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
* @use_underline: %TRUE if underlines in the text indicate mnemonics
|
|
|
|
|
*
|
|
|
|
|
* If true, an underline in the text of the button label indicates
|
|
|
|
|
* the next character should be used for the mnemonic accelerator key.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_button_set_use_underline (GtkButton *button,
|
2020-05-02 14:30:46 +00:00
|
|
|
|
gboolean use_underline)
|
2001-08-27 01:05:07 +00:00
|
|
|
|
{
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
2001-08-27 01:05:07 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
|
|
|
|
|
use_underline = use_underline != FALSE;
|
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if (use_underline != priv->use_underline)
|
2001-08-27 01:05:07 +00:00
|
|
|
|
{
|
2016-10-20 15:58:03 +00:00
|
|
|
|
if (priv->child_type == LABEL_CHILD)
|
2016-10-14 14:01:56 +00:00
|
|
|
|
{
|
2020-05-02 14:30:46 +00:00
|
|
|
|
gtk_label_set_use_underline (GTK_LABEL (priv->child), use_underline);
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (priv->child), GTK_WIDGET (button));
|
2016-10-14 14:01:56 +00:00
|
|
|
|
}
|
2016-10-20 15:58:03 +00:00
|
|
|
|
|
|
|
|
|
priv->use_underline = use_underline;
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_USE_UNDERLINE]);
|
2001-08-27 01:05:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_button_get_use_underline:
|
2001-10-26 15:44:20 +00:00
|
|
|
|
* @button: a #GtkButton
|
2001-08-27 01:05:07 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether an embedded underline in the button label indicates a
|
2016-11-18 19:43:34 +00:00
|
|
|
|
* mnemonic. See gtk_button_set_use_underline().
|
2001-08-27 01:05:07 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if an embedded underline in the button label
|
2001-08-27 01:05:07 +00:00
|
|
|
|
* indicates the mnemonic accelerator keys.
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2001-08-27 01:05:07 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_button_get_use_underline (GtkButton *button)
|
|
|
|
|
{
|
2018-02-25 10:29:33 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
|
|
|
|
|
2001-08-27 01:05:07 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), FALSE);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
2018-02-25 10:29:33 +00:00
|
|
|
|
return priv->use_underline;
|
2001-08-27 01:05:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-09-26 05:47:11 +00:00
|
|
|
|
static void
|
2016-11-01 19:28:28 +00:00
|
|
|
|
gtk_button_state_flags_changed (GtkWidget *widget,
|
|
|
|
|
GtkStateFlags previous_state)
|
2004-09-26 05:47:11 +00:00
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
|
|
|
|
|
2010-02-27 04:24:24 +00:00
|
|
|
|
if (!gtk_widget_is_sensitive (widget))
|
2013-12-07 00:29:56 +00:00
|
|
|
|
gtk_button_do_release (button, FALSE);
|
2004-09-26 05:47:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-05-20 15:58:45 +00:00
|
|
|
|
/**
|
2016-10-14 14:01:56 +00:00
|
|
|
|
* gtk_button_set_icon_name:
|
2016-10-20 15:58:03 +00:00
|
|
|
|
* @button: A #GtkButton
|
2019-08-25 12:52:24 +00:00
|
|
|
|
* @icon_name: An icon name
|
2012-05-20 15:58:45 +00:00
|
|
|
|
*
|
2018-06-20 07:07:51 +00:00
|
|
|
|
* Adds a #GtkImage with the given icon name as a child. If @button already
|
|
|
|
|
* contains a child widget, that child widget will be removed and replaced
|
|
|
|
|
* with the image.
|
2012-05-20 15:58:45 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2016-10-14 14:01:56 +00:00
|
|
|
|
gtk_button_set_icon_name (GtkButton *button,
|
|
|
|
|
const char *icon_name)
|
2012-05-20 15:58:45 +00:00
|
|
|
|
{
|
2016-10-14 14:01:56 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
2012-05-20 15:58:45 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
2016-10-14 14:01:56 +00:00
|
|
|
|
g_return_if_fail (icon_name != NULL);
|
2012-05-20 15:58:45 +00:00
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
if (priv->child_type != ICON_CHILD || priv->child == NULL)
|
2012-05-20 15:58:45 +00:00
|
|
|
|
{
|
2020-05-02 14:30:46 +00:00
|
|
|
|
GtkWidget *child = gtk_image_new_from_icon_name (icon_name);
|
2020-05-02 06:45:09 +00:00
|
|
|
|
gtk_button_set_child (GTK_BUTTON (button), child);
|
2020-06-15 16:23:32 +00:00
|
|
|
|
gtk_widget_set_valign (child, GTK_ALIGN_CENTER);
|
2020-02-06 16:32:26 +00:00
|
|
|
|
gtk_widget_remove_css_class (GTK_WIDGET (button), "text-button");
|
|
|
|
|
gtk_widget_add_css_class (GTK_WIDGET (button), "image-button");
|
2016-10-20 15:58:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-05-02 14:30:46 +00:00
|
|
|
|
gtk_image_set_from_icon_name (GTK_IMAGE (priv->child), icon_name);
|
2016-10-20 15:58:03 +00:00
|
|
|
|
}
|
2012-05-20 15:58:45 +00:00
|
|
|
|
|
2016-10-20 15:58:03 +00:00
|
|
|
|
gtk_button_set_child_type (button, ICON_CHILD);
|
2016-10-14 14:01:56 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_ICON_NAME]);
|
2012-05-20 15:58:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-27 01:22:02 +00:00
|
|
|
|
/**
|
2016-10-14 14:01:56 +00:00
|
|
|
|
* gtk_button_get_icon_name:
|
|
|
|
|
* @button: A #GtkButton
|
2010-06-27 01:22:02 +00:00
|
|
|
|
*
|
2016-11-18 19:43:34 +00:00
|
|
|
|
* Returns the icon name set via gtk_button_set_icon_name().
|
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable): The icon name set via gtk_button_set_icon_name()
|
2010-06-27 01:22:02 +00:00
|
|
|
|
*/
|
2016-10-14 14:01:56 +00:00
|
|
|
|
const char *
|
|
|
|
|
gtk_button_get_icon_name (GtkButton *button)
|
2010-06-27 01:22:02 +00:00
|
|
|
|
{
|
2016-10-20 15:58:03 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
|
|
|
|
|
2010-06-27 01:22:02 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
|
|
|
|
|
|
2016-10-20 15:58:03 +00:00
|
|
|
|
if (priv->child_type == ICON_CHILD)
|
2020-05-02 14:30:46 +00:00
|
|
|
|
return gtk_image_get_icon_name (GTK_IMAGE (priv->child));
|
2016-10-20 15:58:03 +00:00
|
|
|
|
|
2016-10-14 14:01:56 +00:00
|
|
|
|
return NULL;
|
2010-06-27 01:22:02 +00:00
|
|
|
|
}
|
2017-12-13 03:18:19 +00:00
|
|
|
|
|
|
|
|
|
GtkGesture *
|
|
|
|
|
gtk_button_get_gesture (GtkButton *button)
|
|
|
|
|
{
|
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
|
|
|
|
|
|
|
|
|
return priv->gesture;
|
|
|
|
|
}
|
2020-05-02 06:45:09 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_button_set_child:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
* @child: (allow-none): the child widget
|
|
|
|
|
*
|
|
|
|
|
* Sets the child widget of @button.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_button_set_child (GtkButton *button,
|
|
|
|
|
GtkWidget *child)
|
|
|
|
|
{
|
2020-05-02 14:30:46 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
|
|
|
|
|
2020-05-02 06:45:09 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
g_return_if_fail (child == NULL || GTK_IS_WIDGET (child));
|
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
g_clear_pointer (&priv->child, gtk_widget_unparent);
|
|
|
|
|
|
|
|
|
|
priv->child = child;
|
|
|
|
|
|
|
|
|
|
if (priv->child)
|
|
|
|
|
gtk_widget_set_parent (priv->child, GTK_WIDGET (button));
|
|
|
|
|
|
|
|
|
|
gtk_button_set_child_type (button, WIDGET_CHILD);
|
2020-08-01 13:34:07 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_CHILD]);
|
2020-05-02 06:45:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_button_get_child:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
*
|
|
|
|
|
* Gets the child widget of @button.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable) (transfer none): the child widget of @button
|
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_button_get_child (GtkButton *button)
|
|
|
|
|
{
|
2020-05-02 14:30:46 +00:00
|
|
|
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
|
|
|
|
|
2020-05-02 06:45:09 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
|
|
|
|
|
|
2020-05-02 14:30:46 +00:00
|
|
|
|
return priv->child;
|
2020-05-02 06:45:09 +00:00
|
|
|
|
}
|
|
|
|
|
|