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,
|
|
|
|
|
* #GtkLockButton, #GtkColorButton, #GtkFontButton or #GtkFileChooserButton use
|
2017-05-04 07:36:22 +00:00
|
|
|
|
* style classes such as .toggle, .popup, .scale, .lock, .color, .file
|
2015-11-02 17:51:00 +00:00
|
|
|
|
* to differentiate themselves from a plain GtkButton.
|
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 "gtkbutton.h"
|
|
|
|
|
#include "gtkbuttonprivate.h"
|
|
|
|
|
|
1998-01-03 05:46:58 +00:00
|
|
|
|
#include <string.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"
|
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
|
|
|
|
#include "gtkimage.h"
|
2011-08-28 05:40:10 +00:00
|
|
|
|
#include "gtkbox.h"
|
2010-06-18 04:11:26 +00:00
|
|
|
|
#include "gtksizerequest.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtktypebuiltins.h"
|
2013-04-27 21:24:41 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2005-03-22 02:14:55 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2001-03-23 23:39:24 +00:00
|
|
|
|
#include "gtkintl.h"
|
2011-07-02 01:25:53 +00:00
|
|
|
|
#include "a11y/gtkbuttonaccessible.h"
|
2012-01-06 03:22:06 +00:00
|
|
|
|
#include "gtkapplicationprivate.h"
|
2012-08-17 22:27:21 +00:00
|
|
|
|
#include "gtkactionhelper.h"
|
2015-12-04 02:56:25 +00:00
|
|
|
|
#include "gtkcontainerprivate.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
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
enum {
|
|
|
|
|
CLICKED,
|
|
|
|
|
ENTER,
|
|
|
|
|
LEAVE,
|
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,
|
2001-08-27 01:05:07 +00:00
|
|
|
|
PROP_RELIEF,
|
|
|
|
|
PROP_USE_UNDERLINE,
|
2016-10-14 14:01:56 +00:00
|
|
|
|
PROP_ICON_NAME,
|
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
|
|
|
|
|
2016-06-05 23:33:21 +00:00
|
|
|
|
static void gtk_button_finalize (GObject *object);
|
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);
|
2017-10-30 21:19:02 +00:00
|
|
|
|
static void gtk_button_display_changed (GtkWidget *widget,
|
|
|
|
|
GdkDisplay *previous_display);
|
2009-01-27 02:55:02 +00:00
|
|
|
|
static void gtk_button_unrealize (GtkWidget * widget);
|
2018-01-02 22:00:39 +00:00
|
|
|
|
static gboolean gtk_button_event (GtkWidget *widget,
|
|
|
|
|
GdkEvent *event);
|
2009-01-27 02:55:02 +00:00
|
|
|
|
static gint gtk_button_key_release (GtkWidget * widget, GdkEventKey * event);
|
|
|
|
|
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_update_state (GtkButton *button);
|
|
|
|
|
static void gtk_button_finish_activate (GtkButton *button,
|
|
|
|
|
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);
|
2004-09-26 05:47:11 +00:00
|
|
|
|
static void gtk_button_grab_notify (GtkWidget *widget,
|
|
|
|
|
gboolean was_grabbed);
|
2015-02-25 19:29:22 +00:00
|
|
|
|
static void gtk_button_do_release (GtkButton *button,
|
|
|
|
|
gboolean emit_clicked);
|
2001-08-27 01:05:07 +00:00
|
|
|
|
|
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
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
static void gtk_button_measure_ (GtkWidget *widget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline);
|
2016-10-20 15:58:03 +00:00
|
|
|
|
static void gtk_button_set_child_type (GtkButton *button, guint child_type);
|
2015-12-04 02:56:25 +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
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkButton, gtk_button, GTK_TYPE_BIN,
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_ADD_PRIVATE (GtkButton)
|
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
|
|
|
|
|
gtk_button_add (GtkContainer *container, GtkWidget *child)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (container);
|
|
|
|
|
|
|
|
|
|
if (button->priv->child_type != WIDGET_CHILD)
|
|
|
|
|
gtk_container_remove (container, gtk_bin_get_child (GTK_BIN (button)));
|
|
|
|
|
|
|
|
|
|
gtk_button_set_child_type (button, WIDGET_CHILD);
|
|
|
|
|
|
|
|
|
|
GTK_CONTAINER_CLASS (gtk_button_parent_class)->add (container, child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_remove (GtkContainer *container, GtkWidget *child)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (container);
|
|
|
|
|
|
|
|
|
|
gtk_button_set_child_type (button, WIDGET_CHILD);
|
|
|
|
|
|
|
|
|
|
GTK_CONTAINER_CLASS (gtk_button_parent_class)->remove (container, child);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-02 18:45:23 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_unmap (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GTK_BUTTON (widget)->priv->in_button = FALSE;
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_button_parent_class)->unmap (widget);
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_class_init (GtkButtonClass *klass)
|
|
|
|
|
{
|
2002-10-11 22:57:11 +00:00
|
|
|
|
GObjectClass *gobject_class;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
GtkWidgetClass *widget_class;
|
2016-10-20 15:58:03 +00:00
|
|
|
|
GtkContainerClass *container_class;
|
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
|
|
|
|
container_class = GTK_CONTAINER_CLASS (klass);
|
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
gobject_class->dispose = gtk_button_dispose;
|
2016-06-05 23:33:21 +00:00
|
|
|
|
gobject_class->finalize = gtk_button_finalize;
|
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
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
widget_class->measure = gtk_button_measure_;
|
2017-10-30 21:19:02 +00:00
|
|
|
|
widget_class->display_changed = gtk_button_display_changed;
|
2001-03-06 15:51:10 +00:00
|
|
|
|
widget_class->unrealize = gtk_button_unrealize;
|
2018-01-02 22:00:39 +00:00
|
|
|
|
widget_class->event = gtk_button_event;
|
2001-03-06 15:51:10 +00:00
|
|
|
|
widget_class->key_release_event = gtk_button_key_release;
|
2016-11-01 19:28:28 +00:00
|
|
|
|
widget_class->state_flags_changed = gtk_button_state_flags_changed;
|
2004-09-26 05:47:11 +00:00
|
|
|
|
widget_class->grab_notify = gtk_button_grab_notify;
|
2017-07-02 18:45:23 +00:00
|
|
|
|
widget_class->unmap = gtk_button_unmap;
|
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
|
|
|
|
|
2016-10-20 15:58:03 +00:00
|
|
|
|
container_class->add = gtk_button_add;
|
|
|
|
|
container_class->remove = gtk_button_remove;
|
|
|
|
|
|
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
|
|
|
|
|
2014-06-07 13:40:55 +00:00
|
|
|
|
props[PROP_RELIEF] =
|
|
|
|
|
g_param_spec_enum ("relief",
|
|
|
|
|
P_("Border relief"),
|
|
|
|
|
P_("The border relief style"),
|
|
|
|
|
GTK_TYPE_RELIEF_STYLE,
|
|
|
|
|
GTK_RELIEF_NORMAL,
|
2014-06-07 14:48:49 +00:00
|
|
|
|
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
|
|
|
|
|
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"),
|
2010-09-18 23:55:42 +00:00
|
|
|
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
2002-10-11 22:57:11 +00:00
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_STRUCT_OFFSET (GtkButtonClass, clicked),
|
|
|
|
|
NULL, NULL,
|
2016-08-29 14:00:17 +00:00
|
|
|
|
NULL,
|
2002-10-11 22:57:11 +00:00
|
|
|
|
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"),
|
2010-09-18 23:55:42 +00:00
|
|
|
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
2002-10-11 22:57:11 +00:00
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_STRUCT_OFFSET (GtkButtonClass, activate),
|
|
|
|
|
NULL, NULL,
|
2016-08-29 14:00:17 +00:00
|
|
|
|
NULL,
|
2002-10-11 22:57:11 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
2001-03-06 15:51:10 +00:00
|
|
|
|
widget_class->activate_signal = button_signals[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
|
|
|
|
|
2011-07-02 01:25:53 +00:00
|
|
|
|
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_BUTTON_ACCESSIBLE);
|
2017-11-18 03:49:57 +00:00
|
|
|
|
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
|
2014-05-12 17:12:27 +00:00
|
|
|
|
multipress_pressed_cb (GtkGestureMultiPress *gesture,
|
|
|
|
|
guint n_press,
|
|
|
|
|
gdouble x,
|
|
|
|
|
gdouble y,
|
|
|
|
|
GtkWidget *widget)
|
2014-05-02 00:15:40 +00:00
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
|
|
|
|
|
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
|
|
|
|
|
2014-08-20 18:12:35 +00:00
|
|
|
|
priv->in_button = TRUE;
|
2016-10-02 17:46:52 +00:00
|
|
|
|
|
|
|
|
|
if (!priv->activate_timeout)
|
|
|
|
|
{
|
|
|
|
|
priv->button_down = TRUE;
|
|
|
|
|
gtk_button_update_state (button);
|
|
|
|
|
}
|
2014-05-27 15:35:36 +00:00
|
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
2014-05-02 00:15:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 17:46:52 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
touch_release_in_button (GtkButton *button)
|
|
|
|
|
{
|
|
|
|
|
GdkEvent *event;
|
|
|
|
|
gdouble x, y;
|
|
|
|
|
|
|
|
|
|
event = gtk_get_current_event ();
|
|
|
|
|
|
|
|
|
|
if (!event)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2017-08-25 14:43:09 +00:00
|
|
|
|
if (gdk_event_get_event_type (event) != GDK_TOUCH_END)
|
2016-10-02 17:46:52 +00:00
|
|
|
|
{
|
2017-10-31 12:45:41 +00:00
|
|
|
|
g_object_unref (event);
|
2016-10-02 17:46:52 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdk_event_get_coords (event, &x, &y);
|
|
|
|
|
|
2017-10-31 12:45:41 +00:00
|
|
|
|
g_object_unref (event);
|
2016-10-02 17:46:52 +00:00
|
|
|
|
|
2017-11-01 19:50:33 +00:00
|
|
|
|
if (gtk_widget_contains (GTK_WIDGET (button), x, y))
|
2016-10-02 17:46:52 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 00:15:40 +00:00
|
|
|
|
static void
|
2014-05-12 17:12:27 +00:00
|
|
|
|
multipress_released_cb (GtkGestureMultiPress *gesture,
|
|
|
|
|
guint n_press,
|
|
|
|
|
gdouble x,
|
|
|
|
|
gdouble y,
|
|
|
|
|
GtkWidget *widget)
|
2014-05-02 00:15:40 +00:00
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
2014-08-20 18:12:35 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
|
|
|
|
GdkEventSequence *sequence;
|
2014-09-25 13:24:46 +00:00
|
|
|
|
|
2016-10-02 17:46:52 +00:00
|
|
|
|
gtk_button_do_release (button,
|
|
|
|
|
gtk_widget_is_sensitive (GTK_WIDGET (button)) &&
|
|
|
|
|
(button->priv->in_button ||
|
|
|
|
|
touch_release_in_button (button)));
|
2014-08-20 18:12:35 +00:00
|
|
|
|
|
|
|
|
|
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
2014-09-25 13:24:46 +00:00
|
|
|
|
|
|
|
|
|
if (sequence)
|
2014-09-08 01:24:01 +00:00
|
|
|
|
{
|
2014-09-25 13:24:46 +00:00
|
|
|
|
priv->in_button = FALSE;
|
|
|
|
|
gtk_button_update_state (button);
|
2014-09-08 01:24:01 +00:00
|
|
|
|
}
|
2014-05-02 00:15:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-20 18:12:35 +00:00
|
|
|
|
static void
|
|
|
|
|
multipress_gesture_update_cb (GtkGesture *gesture,
|
|
|
|
|
GdkEventSequence *sequence,
|
|
|
|
|
GtkButton *button)
|
|
|
|
|
{
|
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
|
|
|
|
gboolean in_button;
|
|
|
|
|
gdouble x, y;
|
|
|
|
|
|
|
|
|
|
if (sequence != gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_gesture_get_point (gesture, sequence, &x, &y);
|
|
|
|
|
|
2017-11-01 19:09:06 +00:00
|
|
|
|
in_button = gtk_widget_contains (GTK_WIDGET (button), x, y);
|
2014-08-20 18:12:35 +00:00
|
|
|
|
|
|
|
|
|
if (priv->in_button != in_button)
|
|
|
|
|
{
|
|
|
|
|
priv->in_button = in_button;
|
|
|
|
|
gtk_button_update_state (button);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-25 19:29:22 +00:00
|
|
|
|
static void
|
|
|
|
|
multipress_gesture_cancel_cb (GtkGesture *gesture,
|
|
|
|
|
GdkEventSequence *sequence,
|
|
|
|
|
GtkButton *button)
|
|
|
|
|
{
|
|
|
|
|
gtk_button_do_release (button, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv;
|
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
|
button->priv = gtk_button_get_instance_private (button);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv = button->priv;
|
2003-12-15 00:00:19 +00:00
|
|
|
|
|
2010-03-02 03:40:38 +00:00
|
|
|
|
gtk_widget_set_can_focus (GTK_WIDGET (button), TRUE);
|
2010-03-01 16:41:37 +00:00
|
|
|
|
gtk_widget_set_receives_default (GTK_WIDGET (button), TRUE);
|
2010-03-06 10:29:31 +00:00
|
|
|
|
gtk_widget_set_has_window (GTK_WIDGET (button), FALSE);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv->in_button = FALSE;
|
|
|
|
|
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
|
|
|
|
|
2014-05-12 17:12:27 +00:00
|
|
|
|
priv->gesture = gtk_gesture_multi_press_new (GTK_WIDGET (button));
|
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);
|
2014-05-12 17:12:27 +00:00
|
|
|
|
g_signal_connect (priv->gesture, "pressed", G_CALLBACK (multipress_pressed_cb), button);
|
|
|
|
|
g_signal_connect (priv->gesture, "released", G_CALLBACK (multipress_released_cb), button);
|
2014-08-20 18:12:35 +00:00
|
|
|
|
g_signal_connect (priv->gesture, "update", G_CALLBACK (multipress_gesture_update_cb), button);
|
2015-02-25 19:29:22 +00:00
|
|
|
|
g_signal_connect (priv->gesture, "cancel", G_CALLBACK (multipress_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);
|
2015-12-04 02:56:25 +00:00
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-25 22:19:22 +00:00
|
|
|
|
static void
|
2016-06-05 23:33:21 +00:00
|
|
|
|
gtk_button_finalize (GObject *object)
|
2001-11-25 22:19:22 +00:00
|
|
|
|
{
|
2016-06-05 23:33:21 +00:00
|
|
|
|
GtkButton *button = GTK_BUTTON (object);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2010-09-18 23:55:42 +00:00
|
|
|
|
|
2014-05-26 12:02:30 +00:00
|
|
|
|
g_clear_object (&priv->gesture);
|
2014-05-02 00:58:13 +00:00
|
|
|
|
|
2016-06-05 23:33:21 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_button_parent_class)->finalize (object);
|
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);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
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,
|
|
|
|
|
const gchar *action_name)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (actionable);
|
|
|
|
|
|
2012-08-17 22:27:21 +00:00
|
|
|
|
if (!button->priv->action_helper)
|
|
|
|
|
button->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
|
|
|
|
|
2012-08-17 22:27:21 +00:00
|
|
|
|
gtk_action_helper_set_action_name (button->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);
|
|
|
|
|
|
2012-08-17 22:27:21 +00:00
|
|
|
|
if (!button->priv->action_helper)
|
|
|
|
|
button->priv->action_helper = gtk_action_helper_new (actionable);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
|
2012-08-17 22:27:21 +00:00
|
|
|
|
gtk_action_helper_set_action_target_value (button->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;
|
2001-03-23 23:39:24 +00:00
|
|
|
|
case PROP_RELIEF:
|
|
|
|
|
gtk_button_set_relief (button, g_value_get_enum (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;
|
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);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
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;
|
2001-03-23 23:39:24 +00:00
|
|
|
|
case PROP_RELIEF:
|
2014-06-27 01:59:06 +00:00
|
|
|
|
g_value_set_enum (value, gtk_button_get_relief (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;
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-06 03:22:06 +00:00
|
|
|
|
static const gchar *
|
|
|
|
|
gtk_button_get_action_name (GtkActionable *actionable)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (actionable);
|
|
|
|
|
|
2012-08-17 22:27:21 +00:00
|
|
|
|
return gtk_action_helper_get_action_name (button->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);
|
|
|
|
|
|
2012-08-17 22:27:21 +00:00
|
|
|
|
return gtk_action_helper_get_action_target_value (button->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;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-01 17:17:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_button_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkButton widget. To add a child widget to the button,
|
|
|
|
|
* use gtk_container_add().
|
|
|
|
|
*
|
|
|
|
|
* 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*
|
|
|
|
|
gtk_button_new_with_label (const gchar *label)
|
|
|
|
|
{
|
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
|
2013-08-19 18:40:22 +00:00
|
|
|
|
*
|
2013-08-14 07:41:42 +00:00
|
|
|
|
* Since: 3.10
|
2016-06-09 20:37:53 +00:00
|
|
|
|
*/
|
2013-08-14 07:41:42 +00:00
|
|
|
|
GtkWidget*
|
2017-01-20 07:02:48 +00:00
|
|
|
|
gtk_button_new_from_icon_name (const gchar *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*
|
2001-03-21 18:58:28 +00:00
|
|
|
|
gtk_button_new_with_mnemonic (const gchar *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
|
|
|
|
/**
|
|
|
|
|
* gtk_button_clicked:
|
|
|
|
|
* @button: The #GtkButton you want to send the signal to.
|
|
|
|
|
*
|
|
|
|
|
* Emits a #GtkButton::clicked signal to the given #GtkButton.
|
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_button_clicked (GtkButton *button)
|
|
|
|
|
{
|
1998-12-13 00:13:39 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
|
2002-10-11 22:57:11 +00:00
|
|
|
|
g_signal_emit (button, button_signals[CLICKED], 0);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-01 17:17:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_button_set_relief:
|
2014-06-27 01:59:06 +00:00
|
|
|
|
* @button: The #GtkButton you want to set relief styles of
|
|
|
|
|
* @relief: The GtkReliefStyle as described above
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the relief style of the edges of the given #GtkButton widget.
|
2014-06-27 01:59:06 +00:00
|
|
|
|
* Two styles exist, %GTK_RELIEF_NORMAL and %GTK_RELIEF_NONE.
|
|
|
|
|
* The default style is, as one can guess, %GTK_RELIEF_NORMAL.
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*/
|
1998-05-12 21:30:52 +00:00
|
|
|
|
void
|
2014-06-27 01:59:06 +00:00
|
|
|
|
gtk_button_set_relief (GtkButton *button,
|
|
|
|
|
GtkReliefStyle relief)
|
1998-05-12 21:30:52 +00:00
|
|
|
|
{
|
2014-06-27 01:59:06 +00:00
|
|
|
|
GtkStyleContext *context;
|
|
|
|
|
GtkReliefStyle old_relief;
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
1998-05-12 21:30:52 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
|
2014-06-27 01:59:06 +00:00
|
|
|
|
old_relief = gtk_button_get_relief (button);
|
|
|
|
|
if (old_relief != relief)
|
2002-01-28 18:52:49 +00:00
|
|
|
|
{
|
2014-06-27 01:59:06 +00:00
|
|
|
|
context = gtk_widget_get_style_context (GTK_WIDGET (button));
|
|
|
|
|
if (relief == GTK_RELIEF_NONE)
|
|
|
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_FLAT);
|
|
|
|
|
else
|
|
|
|
|
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FLAT);
|
|
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_RELIEF]);
|
2002-01-28 18:52:49 +00:00
|
|
|
|
}
|
1998-05-12 21:30:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-01 17:17:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_button_get_relief:
|
|
|
|
|
* @button: The #GtkButton you want the #GtkReliefStyle from.
|
|
|
|
|
*
|
|
|
|
|
* Returns the current relief style of the given #GtkButton.
|
|
|
|
|
*
|
|
|
|
|
* Returns: The current #GtkReliefStyle
|
|
|
|
|
*/
|
1998-05-12 21:30:52 +00:00
|
|
|
|
GtkReliefStyle
|
1998-07-08 14:12:27 +00:00
|
|
|
|
gtk_button_get_relief (GtkButton *button)
|
1998-05-12 21:30:52 +00:00
|
|
|
|
{
|
2014-06-27 01:59:06 +00:00
|
|
|
|
GtkStyleContext *context;
|
|
|
|
|
|
1998-05-12 21:30:52 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), GTK_RELIEF_NORMAL);
|
|
|
|
|
|
2014-06-27 01:59:06 +00:00
|
|
|
|
context = gtk_widget_get_style_context (GTK_WIDGET (button));
|
|
|
|
|
if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_FLAT))
|
|
|
|
|
return GTK_RELIEF_NONE;
|
|
|
|
|
else
|
|
|
|
|
return GTK_RELIEF_NORMAL;
|
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);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
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)
|
|
|
|
|
{
|
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->button_down)
|
|
|
|
|
{
|
|
|
|
|
priv->button_down = FALSE;
|
|
|
|
|
|
|
|
|
|
if (priv->activate_timeout)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (emit_clicked)
|
|
|
|
|
gtk_button_clicked (button);
|
|
|
|
|
|
|
|
|
|
gtk_button_update_state (button);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-30 03:35:30 +00:00
|
|
|
|
static gboolean
|
2018-01-02 22:00:39 +00:00
|
|
|
|
gtk_button_event (GtkWidget *widget,
|
|
|
|
|
GdkEvent *event)
|
2005-06-30 03:35:30 +00:00
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
|
|
|
|
|
2018-01-02 22:00:39 +00:00
|
|
|
|
if (gdk_event_get_event_type (event) == GDK_GRAB_BROKEN)
|
|
|
|
|
{
|
|
|
|
|
gtk_button_do_release (button, FALSE);
|
|
|
|
|
return GDK_EVENT_STOP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return GDK_EVENT_PROPAGATE;
|
2005-06-30 03:35:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-03-06 15:51:10 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_button_key_release (GtkWidget *widget,
|
|
|
|
|
GdkEventKey *event)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
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, TRUE);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2006-05-02 23:56:43 +00:00
|
|
|
|
else if (GTK_WIDGET_CLASS (gtk_button_parent_class)->key_release_event)
|
|
|
|
|
return GTK_WIDGET_CLASS (gtk_button_parent_class)->key_release_event (widget, event);
|
2001-03-06 15:51:10 +00:00
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
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);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkDevice *device;
|
2005-06-27 20:04:33 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
device = gtk_get_current_event_device ();
|
|
|
|
|
|
2010-11-23 19:25:13 +00:00
|
|
|
|
if (device && gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
|
2010-08-17 13:43:08 +00:00
|
|
|
|
device = gdk_device_get_associated_device (device);
|
|
|
|
|
|
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
|
|
|
|
{
|
2011-01-21 19:36:27 +00:00
|
|
|
|
/* bgo#626336 - Only grab if we have a device (from an event), not if we
|
|
|
|
|
* were activated programmatically when no event is available.
|
|
|
|
|
*/
|
|
|
|
|
if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
|
|
|
|
{
|
2017-03-31 17:11:03 +00:00
|
|
|
|
gtk_device_grab_add (widget, device, TRUE);
|
|
|
|
|
priv->grab_keyboard = device;
|
2001-03-06 15:51:10 +00:00
|
|
|
|
}
|
2005-06-27 20:04:33 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv->activate_timeout = gdk_threads_add_timeout (ACTIVATE_TIMEOUT,
|
2005-06-27 20:04:33 +00:00
|
|
|
|
button_activate_timeout,
|
|
|
|
|
button);
|
2013-10-22 13:43:43 +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;
|
2005-06-27 20:04:33 +00:00
|
|
|
|
gtk_button_update_state (button);
|
2001-03-06 15:51:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_finish_activate (GtkButton *button,
|
|
|
|
|
gboolean do_it)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (button);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
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-05-25 22:38:44 +00:00
|
|
|
|
if (priv->grab_keyboard)
|
2005-06-27 20:04:33 +00:00
|
|
|
|
{
|
2015-11-26 18:54:01 +00:00
|
|
|
|
gdk_seat_ungrab (gdk_device_get_seat (priv->grab_keyboard));
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gtk_device_grab_remove (widget, priv->grab_keyboard);
|
|
|
|
|
priv->grab_keyboard = NULL;
|
2005-06-27 20:04:33 +00:00
|
|
|
|
}
|
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-08-25 23:11:46 +00:00
|
|
|
|
gtk_button_update_state (button);
|
2001-03-06 15:51:10 +00:00
|
|
|
|
|
|
|
|
|
if (do_it)
|
|
|
|
|
gtk_button_clicked (button);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-07 00:48:41 +00:00
|
|
|
|
static void
|
2017-05-04 07:36:49 +00:00
|
|
|
|
gtk_button_measure_ (GtkWidget *widget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline)
|
2015-12-04 02:56:25 +00:00
|
|
|
|
{
|
2017-05-04 07:36:49 +00:00
|
|
|
|
GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
|
2013-03-07 12:53:16 +00:00
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
if (child && gtk_widget_get_visible (child))
|
2010-04-07 00:48:41 +00:00
|
|
|
|
{
|
2016-10-22 14:06:14 +00:00
|
|
|
|
gtk_widget_measure (child,
|
|
|
|
|
orientation,
|
|
|
|
|
for_size,
|
|
|
|
|
minimum, natural,
|
|
|
|
|
minimum_baseline, natural_baseline);
|
2010-04-07 00:48:41 +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,
|
2016-10-14 14:01:56 +00:00
|
|
|
|
const gchar *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;
|
|
|
|
|
GtkStyleContext *context;
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
2003-11-07 21:57:20 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
|
2016-10-14 14:01:56 +00:00
|
|
|
|
context = gtk_widget_get_style_context (GTK_WIDGET (button));
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
2016-10-14 14:01:56 +00:00
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (button));
|
|
|
|
|
|
2016-10-20 15:58:03 +00:00
|
|
|
|
if (priv->child_type != LABEL_CHILD || child == NULL)
|
2016-10-14 14:01:56 +00:00
|
|
|
|
{
|
2016-10-20 15:58:03 +00:00
|
|
|
|
if (child != NULL)
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (button), child);
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (child), 0.0);
|
|
|
|
|
}
|
2016-10-14 14:01:56 +00:00
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), child);
|
2016-10-20 15:58:03 +00:00
|
|
|
|
gtk_style_context_remove_class (context, "image-button");
|
|
|
|
|
gtk_style_context_add_class (context, "text-button");
|
2016-10-14 14:01:56 +00:00
|
|
|
|
}
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
2016-10-20 15:58:03 +00:00
|
|
|
|
gtk_label_set_label (GTK_LABEL (child), label);
|
|
|
|
|
gtk_button_set_child_type (button, LABEL_CHILD);
|
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
|
|
|
|
*/
|
2011-06-06 18:13:44 +00:00
|
|
|
|
const gchar *
|
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)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *child = gtk_bin_get_child (GTK_BIN (button));
|
|
|
|
|
return gtk_label_get_label (GTK_LABEL (child));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
gboolean use_underline)
|
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv;
|
|
|
|
|
|
2001-08-27 01:05:07 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv = button->priv;
|
|
|
|
|
|
2001-08-27 01:05:07 +00:00
|
|
|
|
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
|
|
|
|
{
|
2016-10-20 15:58:03 +00:00
|
|
|
|
GtkWidget *child;
|
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (button));
|
|
|
|
|
|
2016-10-14 14:01:56 +00:00
|
|
|
|
gtk_label_set_use_underline (GTK_LABEL (child), use_underline);
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (child), GTK_WIDGET (button));
|
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), FALSE);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
|
|
|
|
return button->priv->use_underline;
|
2001-08-27 01:05:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-24 17:21:05 +00:00
|
|
|
|
static void
|
2001-08-25 23:11:46 +00:00
|
|
|
|
gtk_button_update_state (GtkButton *button)
|
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2011-01-23 17:04:41 +00:00
|
|
|
|
GtkStateFlags new_state;
|
2010-10-18 17:39:19 +00:00
|
|
|
|
gboolean depressed;
|
2001-08-25 23:11:46 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if (priv->activate_timeout)
|
2014-08-14 13:44:35 +00:00
|
|
|
|
depressed = TRUE;
|
2002-02-22 13:34:28 +00:00
|
|
|
|
else
|
2010-10-18 17:39:19 +00:00
|
|
|
|
depressed = priv->in_button && priv->button_down;
|
2001-09-03 06:45:17 +00:00
|
|
|
|
|
2017-08-01 16:16:40 +00:00
|
|
|
|
new_state = gtk_widget_get_state_flags (GTK_WIDGET (button)) & ~(GTK_STATE_FLAG_ACTIVE);
|
2010-10-31 13:38:26 +00:00
|
|
|
|
|
2012-01-17 22:14:23 +00:00
|
|
|
|
if (depressed)
|
2010-10-31 13:38:26 +00:00
|
|
|
|
new_state |= GTK_STATE_FLAG_ACTIVE;
|
2001-08-25 23:11:46 +00:00
|
|
|
|
|
2010-10-31 13:38:26 +00:00
|
|
|
|
gtk_widget_set_state_flags (GTK_WIDGET (button), new_state, TRUE);
|
2001-08-25 23:11:46 +00:00
|
|
|
|
}
|
2004-02-19 22:39:58 +00:00
|
|
|
|
|
|
|
|
|
static void
|
2017-10-30 21:19:02 +00:00
|
|
|
|
gtk_button_display_changed (GtkWidget *widget,
|
|
|
|
|
GdkDisplay *previous_display)
|
2004-02-19 22:39:58 +00:00
|
|
|
|
{
|
2009-12-11 16:17:38 +00:00
|
|
|
|
GtkButton *button;
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv;
|
2004-02-19 22:39:58 +00:00
|
|
|
|
|
2009-12-11 16:17:38 +00:00
|
|
|
|
button = GTK_BUTTON (widget);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv = button->priv;
|
2009-12-11 16:17:38 +00:00
|
|
|
|
|
2017-10-30 21:19:02 +00:00
|
|
|
|
/* If the button is being pressed while the display changes the
|
2009-12-11 16:17:38 +00:00
|
|
|
|
release might never occur, so we reset the state. */
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if (priv->button_down)
|
2009-12-11 16:17:38 +00:00
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv->button_down = FALSE;
|
2009-12-11 16:17:38 +00:00
|
|
|
|
gtk_button_update_state (button);
|
|
|
|
|
}
|
2004-02-19 22:39:58 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_grab_notify (GtkWidget *widget,
|
|
|
|
|
gboolean was_grabbed)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2004-09-26 05:47:11 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if (priv->activate_timeout &&
|
2010-05-25 22:38:44 +00:00
|
|
|
|
priv->grab_keyboard &&
|
|
|
|
|
gtk_widget_device_is_shadowed (widget, priv->grab_keyboard))
|
|
|
|
|
gtk_button_finish_activate (button, FALSE);
|
|
|
|
|
|
2004-09-26 05:47:11 +00:00
|
|
|
|
if (!was_grabbed)
|
2013-12-02 20:24:30 +00:00
|
|
|
|
gtk_button_do_release (button, FALSE);
|
2004-09-26 05:47:11 +00:00
|
|
|
|
}
|
2004-11-15 20:56:28 +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
|
|
|
|
|
* @icon_name: A icon name
|
2012-05-20 15:58:45 +00:00
|
|
|
|
*
|
2016-10-20 15:58:03 +00:00
|
|
|
|
* Adds a #GtkImage with the given icon name as a child. The icon will be
|
|
|
|
|
* of size %GTK_ICON_SIZE_BUTTON. If @button already contains a child widget,
|
|
|
|
|
* that child widget will be removed and replaced with the image.
|
2016-10-22 19:02:34 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 3.90
|
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);
|
|
|
|
|
GtkWidget *child;
|
|
|
|
|
GtkStyleContext *context;
|
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
|
|
|
|
|
2016-10-14 14:01:56 +00:00
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (button));
|
|
|
|
|
context = gtk_widget_get_style_context (GTK_WIDGET (button));
|
2012-05-20 15:58:45 +00:00
|
|
|
|
|
2016-10-20 15:58:03 +00:00
|
|
|
|
if (priv->child_type != ICON_CHILD || child == NULL)
|
2012-05-20 15:58:45 +00:00
|
|
|
|
{
|
2016-10-20 15:58:03 +00:00
|
|
|
|
if (child != NULL)
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (button), child);
|
2012-05-20 15:58:45 +00:00
|
|
|
|
|
2017-11-15 00:43:13 +00:00
|
|
|
|
child = gtk_image_new_from_icon_name (icon_name);
|
2016-10-20 15:58:03 +00:00
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), child);
|
|
|
|
|
gtk_style_context_remove_class (context, "text-button");
|
|
|
|
|
gtk_style_context_add_class (context, "image-button");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-11-15 00:43:13 +00:00
|
|
|
|
gtk_image_set_from_icon_name (GTK_IMAGE (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()
|
2016-10-22 19:02:34 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 3.90
|
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)
|
2016-10-14 14:01:56 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *child = gtk_bin_get_child (GTK_BIN (button));
|
|
|
|
|
|
2017-01-22 21:58:45 +00:00
|
|
|
|
return gtk_image_get_icon_name (GTK_IMAGE (child));
|
2016-10-14 14:01:56 +00:00
|
|
|
|
}
|
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;
|
|
|
|
|
}
|