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
|
|
|
|
|
* style classes such as .toggle, .popup, .scale, .lock, .color, .font, .file
|
|
|
|
|
* 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"
|
2013-07-20 00:29:11 +00:00
|
|
|
|
#include "deprecated/gtkactivatable.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 "gtkcsscustomgadgetprivate.h"
|
|
|
|
|
#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,
|
2004-11-15 20:56:28 +00:00
|
|
|
|
PROP_IMAGE,
|
2001-08-27 01:05:07 +00:00
|
|
|
|
PROP_RELIEF,
|
|
|
|
|
PROP_USE_UNDERLINE,
|
2009-01-23 15:15:28 +00:00
|
|
|
|
PROP_IMAGE_POSITION,
|
2014-06-07 13:40:55 +00:00
|
|
|
|
PROP_ALWAYS_SHOW_IMAGE,
|
|
|
|
|
|
|
|
|
|
/* actionable properties */
|
2012-01-06 03:22:06 +00:00
|
|
|
|
PROP_ACTION_NAME,
|
|
|
|
|
PROP_ACTION_TARGET,
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
|
|
|
|
/* activatable properties */
|
|
|
|
|
PROP_ACTIVATABLE_RELATED_ACTION,
|
2014-06-07 13:40:55 +00:00
|
|
|
|
PROP_ACTIVATABLE_USE_ACTION_APPEARANCE,
|
|
|
|
|
LAST_PROP = PROP_ACTION_NAME
|
2003-12-15 00:00:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
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);
|
|
|
|
|
static void gtk_button_screen_changed (GtkWidget *widget,
|
|
|
|
|
GdkScreen *previous_screen);
|
2009-01-27 02:55:02 +00:00
|
|
|
|
static void gtk_button_realize (GtkWidget * widget);
|
|
|
|
|
static void gtk_button_unrealize (GtkWidget * widget);
|
|
|
|
|
static void gtk_button_map (GtkWidget * widget);
|
|
|
|
|
static void gtk_button_unmap (GtkWidget * widget);
|
|
|
|
|
static void gtk_button_size_allocate (GtkWidget * widget,
|
|
|
|
|
GtkAllocation * allocation);
|
2010-09-07 22:23:04 +00:00
|
|
|
|
static gint gtk_button_draw (GtkWidget * widget, cairo_t *cr);
|
2009-01-27 02:55:02 +00:00
|
|
|
|
static gint gtk_button_grab_broken (GtkWidget * widget,
|
|
|
|
|
GdkEventGrabBroken * event);
|
|
|
|
|
static gint gtk_button_key_release (GtkWidget * widget, GdkEventKey * event);
|
|
|
|
|
static gint gtk_button_enter_notify (GtkWidget * widget,
|
|
|
|
|
GdkEventCrossing * event);
|
|
|
|
|
static gint gtk_button_leave_notify (GtkWidget * widget,
|
|
|
|
|
GdkEventCrossing * 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
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void gtk_button_constructed (GObject *object);
|
2004-02-19 22:39:58 +00:00
|
|
|
|
static void gtk_button_construct_child (GtkButton *button);
|
2004-09-26 05:47:11 +00:00
|
|
|
|
static void gtk_button_state_changed (GtkWidget *widget,
|
|
|
|
|
GtkStateType previous_state);
|
|
|
|
|
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);
|
2010-04-07 00:48:41 +00:00
|
|
|
|
static void gtk_button_activatable_interface_init(GtkActivatableIface *iface);
|
2009-02-22 05:20:14 +00:00
|
|
|
|
static void gtk_button_update (GtkActivatable *activatable,
|
|
|
|
|
GtkAction *action,
|
|
|
|
|
const gchar *property_name);
|
|
|
|
|
static void gtk_button_sync_action_properties (GtkActivatable *activatable,
|
|
|
|
|
GtkAction *action);
|
|
|
|
|
static void gtk_button_set_related_action (GtkButton *button,
|
|
|
|
|
GtkAction *action);
|
|
|
|
|
static void gtk_button_set_use_action_appearance (GtkButton *button,
|
|
|
|
|
gboolean use_appearance);
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
2013-04-22 21:37:18 +00:00
|
|
|
|
static void gtk_button_get_preferred_width (GtkWidget *widget,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size);
|
|
|
|
|
static void gtk_button_get_preferred_height (GtkWidget *widget,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size);
|
|
|
|
|
static void gtk_button_get_preferred_width_for_height (GtkWidget *widget,
|
|
|
|
|
gint for_size,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size);
|
|
|
|
|
static void gtk_button_get_preferred_height_for_width (GtkWidget *widget,
|
|
|
|
|
gint for_size,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size);
|
2013-03-07 12:53:16 +00:00
|
|
|
|
static void gtk_button_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
|
|
|
|
|
gint width,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size,
|
|
|
|
|
gint *minimum_baseline,
|
|
|
|
|
gint *natural_baseline);
|
2015-12-04 02:56:25 +00:00
|
|
|
|
|
|
|
|
|
static void gtk_button_measure (GtkCssGadget *gadget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum_size,
|
|
|
|
|
int *natural_size,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline,
|
|
|
|
|
gpointer data);
|
|
|
|
|
static void gtk_button_allocate (GtkCssGadget *gadget,
|
|
|
|
|
const GtkAllocation *allocation,
|
|
|
|
|
int baseline,
|
|
|
|
|
GtkAllocation *out_clip,
|
|
|
|
|
gpointer data);
|
|
|
|
|
static gboolean gtk_button_render (GtkCssGadget *gadget,
|
|
|
|
|
cairo_t *cr,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
gpointer data);
|
|
|
|
|
|
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
|
|
|
|
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
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)
|
2012-01-06 03:22:06 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIONABLE, gtk_button_actionable_iface_init)
|
2009-01-23 15:15:28 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
|
2010-09-21 14:35:17 +00:00
|
|
|
|
gtk_button_activatable_interface_init))
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
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;
|
|
|
|
|
GtkContainerClass *container_class;
|
|
|
|
|
|
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;
|
|
|
|
|
container_class = (GtkContainerClass*) klass;
|
2001-03-09 13:28:26 +00:00
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
gobject_class->constructed = gtk_button_constructed;
|
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
|
|
|
|
|
2013-04-22 21:37:18 +00:00
|
|
|
|
widget_class->get_preferred_width = gtk_button_get_preferred_width;
|
2010-09-21 14:35:17 +00:00
|
|
|
|
widget_class->get_preferred_height = gtk_button_get_preferred_height;
|
2013-04-22 21:37:18 +00:00
|
|
|
|
widget_class->get_preferred_width_for_height = gtk_button_get_preferred_width_for_height;
|
|
|
|
|
widget_class->get_preferred_height_for_width = gtk_button_get_preferred_height_for_width;
|
2013-03-07 12:53:16 +00:00
|
|
|
|
widget_class->get_preferred_height_and_baseline_for_width = gtk_button_get_preferred_height_and_baseline_for_width;
|
2004-02-19 22:39:58 +00:00
|
|
|
|
widget_class->screen_changed = gtk_button_screen_changed;
|
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
|
|
|
|
widget_class->realize = gtk_button_realize;
|
2001-03-06 15:51:10 +00:00
|
|
|
|
widget_class->unrealize = gtk_button_unrealize;
|
2001-11-15 21:04:51 +00:00
|
|
|
|
widget_class->map = gtk_button_map;
|
|
|
|
|
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
|
|
|
|
widget_class->size_allocate = gtk_button_size_allocate;
|
2010-09-07 22:23:04 +00:00
|
|
|
|
widget_class->draw = gtk_button_draw;
|
2005-06-30 03:35:30 +00:00
|
|
|
|
widget_class->grab_broken_event = gtk_button_grab_broken;
|
2001-03-06 15:51:10 +00:00
|
|
|
|
widget_class->key_release_event = gtk_button_key_release;
|
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
|
|
|
|
widget_class->enter_notify_event = gtk_button_enter_notify;
|
|
|
|
|
widget_class->leave_notify_event = gtk_button_leave_notify;
|
2004-09-26 05:47:11 +00:00
|
|
|
|
widget_class->state_changed = gtk_button_state_changed;
|
|
|
|
|
widget_class->grab_notify = gtk_button_grab_notify;
|
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
|
|
|
|
|
2010-09-05 06:22:47 +00:00
|
|
|
|
gtk_container_class_handle_border_width (container_class);
|
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
|
|
|
|
|
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,
|
2014-06-07 14:48:49 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|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,
|
2014-06-07 14:48:49 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|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
|
|
|
|
|
2004-11-15 20:56:28 +00:00
|
|
|
|
/**
|
2011-01-18 09:12:38 +00:00
|
|
|
|
* GtkButton:image:
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*
|
2004-11-15 20:56:28 +00:00
|
|
|
|
* The child widget to appear next to the button text.
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*
|
2004-11-15 20:56:28 +00:00
|
|
|
|
* Since: 2.6
|
|
|
|
|
*/
|
2014-06-07 13:40:55 +00:00
|
|
|
|
props[PROP_IMAGE] =
|
|
|
|
|
g_param_spec_object ("image",
|
|
|
|
|
P_("Image widget"),
|
|
|
|
|
P_("Child widget to appear next to the button text"),
|
|
|
|
|
GTK_TYPE_WIDGET,
|
2014-06-07 14:48:49 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2004-11-15 20:56:28 +00:00
|
|
|
|
|
2006-05-31 00:22:19 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkButton:image-position:
|
|
|
|
|
*
|
2006-06-01 13:42:14 +00:00
|
|
|
|
* The position of the image relative to the text inside the button.
|
2010-05-01 17:17:51 +00:00
|
|
|
|
*
|
2006-05-31 00:22:19 +00:00
|
|
|
|
* Since: 2.10
|
|
|
|
|
*/
|
2014-06-07 13:40:55 +00:00
|
|
|
|
props[PROP_IMAGE_POSITION] =
|
|
|
|
|
g_param_spec_enum ("image-position",
|
|
|
|
|
P_("Image position"),
|
|
|
|
|
P_("The position of the image relative to the text"),
|
|
|
|
|
GTK_TYPE_POSITION_TYPE,
|
|
|
|
|
GTK_POS_LEFT,
|
2014-06-07 14:48:49 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2006-05-31 00:22:19 +00:00
|
|
|
|
|
2012-05-20 15:58:45 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkButton:always-show-image:
|
|
|
|
|
*
|
2013-10-25 00:35:55 +00:00
|
|
|
|
* If %TRUE, the button will ignore the #GtkSettings:gtk-button-images
|
|
|
|
|
* setting and always show the image, if available.
|
2012-05-20 15:58:45 +00:00
|
|
|
|
*
|
|
|
|
|
* Use this property if the button would be useless or hard to use
|
|
|
|
|
* without the image.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.6
|
|
|
|
|
*/
|
2014-06-07 13:40:55 +00:00
|
|
|
|
props[PROP_ALWAYS_SHOW_IMAGE] =
|
|
|
|
|
g_param_spec_boolean ("always-show-image",
|
|
|
|
|
P_("Always show image"),
|
|
|
|
|
P_("Whether the image will always be shown"),
|
|
|
|
|
FALSE,
|
2014-06-07 14:48:49 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|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");
|
|
|
|
|
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_RELATED_ACTION, "related-action");
|
|
|
|
|
g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_USE_ACTION_APPEARANCE, "use-action-appearance");
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
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);
|
2015-10-30 02:55:29 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, "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)
|
|
|
|
|
{
|
|
|
|
|
GtkButtonPrivate *priv;
|
|
|
|
|
gint width, height;
|
|
|
|
|
GdkEvent *event;
|
|
|
|
|
gdouble x, y;
|
|
|
|
|
|
|
|
|
|
priv = button->priv;
|
|
|
|
|
event = gtk_get_current_event ();
|
|
|
|
|
|
|
|
|
|
if (!event)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (event->type != GDK_TOUCH_END ||
|
|
|
|
|
event->touch.window != priv->event_window)
|
|
|
|
|
{
|
|
|
|
|
gdk_event_free (event);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdk_event_get_coords (event, &x, &y);
|
|
|
|
|
width = gdk_window_get_width (priv->event_window);
|
|
|
|
|
height = gdk_window_get_height (priv->event_window);
|
|
|
|
|
|
|
|
|
|
gdk_event_free (event);
|
|
|
|
|
|
|
|
|
|
if (x >= 0 && x <= width &&
|
|
|
|
|
y >= 0 && y <= height)
|
|
|
|
|
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;
|
|
|
|
|
GtkAllocation allocation;
|
|
|
|
|
gboolean in_button;
|
|
|
|
|
gdouble x, y;
|
|
|
|
|
|
|
|
|
|
if (sequence != gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_widget_get_allocation (GTK_WIDGET (button), &allocation);
|
|
|
|
|
gtk_gesture_get_point (gesture, sequence, &x, &y);
|
|
|
|
|
|
|
|
|
|
in_button = (x >= 0 && y >= 0 && x < allocation.width && y < allocation.height);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
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->label_text = NULL;
|
|
|
|
|
|
|
|
|
|
priv->constructed = FALSE;
|
|
|
|
|
priv->in_button = FALSE;
|
|
|
|
|
priv->button_down = FALSE;
|
|
|
|
|
priv->use_underline = FALSE;
|
2003-12-15 00:00:19 +00:00
|
|
|
|
|
2006-05-31 00:22:19 +00:00
|
|
|
|
priv->image_position = GTK_POS_LEFT;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
priv->use_action_appearance = TRUE;
|
2010-11-09 20:33:10 +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);
|
2014-05-27 10:38:49 +00:00
|
|
|
|
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->gesture), GTK_PHASE_BUBBLE);
|
2015-12-04 02:56:25 +00:00
|
|
|
|
|
|
|
|
|
priv->gadget = gtk_css_custom_gadget_new_for_node (gtk_widget_get_css_node (GTK_WIDGET (button)),
|
|
|
|
|
GTK_WIDGET (button),
|
|
|
|
|
gtk_button_measure,
|
|
|
|
|
gtk_button_allocate,
|
|
|
|
|
gtk_button_render,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
|
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-07-14 15:02:13 +00:00
|
|
|
|
g_clear_pointer (&priv->label_text, g_free);
|
2014-05-26 12:02:30 +00:00
|
|
|
|
g_clear_object (&priv->gesture);
|
2015-12-04 02:56:25 +00:00
|
|
|
|
g_clear_object (&priv->gadget);
|
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
|
|
|
|
}
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_constructed (GObject *object)
|
2001-08-27 01:05:07 +00:00
|
|
|
|
{
|
2014-06-26 22:22:42 +00:00
|
|
|
|
GtkButton *button = GTK_BUTTON (object);
|
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2001-08-27 01:05:07 +00:00
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_button_parent_class)->constructed (object);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
|
|
|
|
priv->constructed = TRUE;
|
2001-08-27 01:05:07 +00:00
|
|
|
|
|
2015-08-04 02:35:36 +00:00
|
|
|
|
if (priv->label_text != NULL || priv->image != NULL)
|
2001-08-27 01:05:07 +00:00
|
|
|
|
gtk_button_construct_child (button);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
if (priv->action)
|
|
|
|
|
{
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (button), NULL);
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
priv->action = NULL;
|
|
|
|
|
}
|
|
|
|
|
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-01-06 18:16:36 +00:00
|
|
|
|
g_return_if_fail (button->priv->action == NULL);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
|
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;
|
2004-11-15 20:56:28 +00:00
|
|
|
|
case PROP_IMAGE:
|
|
|
|
|
gtk_button_set_image (button, (GtkWidget *) g_value_get_object (value));
|
|
|
|
|
break;
|
2012-05-20 15:58:45 +00:00
|
|
|
|
case PROP_ALWAYS_SHOW_IMAGE:
|
|
|
|
|
gtk_button_set_always_show_image (button, g_value_get_boolean (value));
|
|
|
|
|
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;
|
2006-05-31 00:22:19 +00:00
|
|
|
|
case PROP_IMAGE_POSITION:
|
|
|
|
|
gtk_button_set_image_position (button, g_value_get_enum (value));
|
|
|
|
|
break;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
case PROP_ACTIVATABLE_RELATED_ACTION:
|
|
|
|
|
gtk_button_set_related_action (button, g_value_get_object (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
|
|
|
|
|
gtk_button_set_use_action_appearance (button, g_value_get_boolean (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);
|
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:
|
2010-10-18 17:39:19 +00:00
|
|
|
|
g_value_set_string (value, priv->label_text);
|
1998-06-16 05:20:05 +00:00
|
|
|
|
break;
|
2004-11-15 20:56:28 +00:00
|
|
|
|
case PROP_IMAGE:
|
|
|
|
|
g_value_set_object (value, (GObject *)priv->image);
|
|
|
|
|
break;
|
2012-05-20 15:58:45 +00:00
|
|
|
|
case PROP_ALWAYS_SHOW_IMAGE:
|
|
|
|
|
g_value_set_boolean (value, gtk_button_get_always_show_image (button));
|
|
|
|
|
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;
|
2006-05-31 00:22:19 +00:00
|
|
|
|
case PROP_IMAGE_POSITION:
|
|
|
|
|
g_value_set_enum (value, priv->image_position);
|
|
|
|
|
break;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
case PROP_ACTIVATABLE_RELATED_ACTION:
|
|
|
|
|
g_value_set_object (value, priv->action);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
|
|
|
|
|
g_value_set_boolean (value, priv->use_action_appearance);
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_activatable_interface_init (GtkActivatableIface *iface)
|
|
|
|
|
{
|
2009-02-22 05:20:14 +00:00
|
|
|
|
iface->update = gtk_button_update;
|
|
|
|
|
iface->sync_action_properties = gtk_button_sync_action_properties;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
activatable_update_short_label (GtkButton *button,
|
|
|
|
|
GtkAction *action)
|
|
|
|
|
{
|
2010-05-24 20:31:36 +00:00
|
|
|
|
GtkWidget *child;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
|
|
image = gtk_button_get_image (button);
|
|
|
|
|
|
|
|
|
|
/* Dont touch custom child... */
|
2010-05-24 20:31:36 +00:00
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (button));
|
2009-01-23 15:15:28 +00:00
|
|
|
|
if (GTK_IS_IMAGE (image) ||
|
2010-05-24 20:31:36 +00:00
|
|
|
|
child == NULL ||
|
|
|
|
|
GTK_IS_LABEL (child))
|
2009-01-23 15:15:28 +00:00
|
|
|
|
{
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
gtk_button_set_label (button, gtk_action_get_short_label (action));
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
gtk_button_set_use_underline (button, TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
activatable_update_icon_name (GtkButton *button,
|
|
|
|
|
GtkAction *action)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
|
|
image = gtk_button_get_image (button);
|
|
|
|
|
|
|
|
|
|
if (GTK_IS_IMAGE (image) &&
|
|
|
|
|
(gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_EMPTY ||
|
|
|
|
|
gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_ICON_NAME))
|
2013-06-28 15:27:19 +00:00
|
|
|
|
{
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
|
|
|
|
gtk_image_set_from_icon_name (GTK_IMAGE (image),
|
|
|
|
|
gtk_action_get_icon_name (action), GTK_ICON_SIZE_MENU);
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
|
|
|
|
}
|
2009-01-23 15:15:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
activatable_update_gicon (GtkButton *button,
|
|
|
|
|
GtkAction *action)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *image = gtk_button_get_image (button);
|
2013-06-28 15:27:19 +00:00
|
|
|
|
GIcon *icon;
|
|
|
|
|
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
|
|
|
|
icon = gtk_action_get_gicon (action);
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
if (GTK_IS_IMAGE (image) &&
|
|
|
|
|
(gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_EMPTY ||
|
|
|
|
|
gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_GICON))
|
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (image), icon, GTK_ICON_SIZE_BUTTON);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-02-22 05:20:14 +00:00
|
|
|
|
gtk_button_update (GtkActivatable *activatable,
|
|
|
|
|
GtkAction *action,
|
|
|
|
|
const gchar *property_name)
|
2009-01-23 15:15:28 +00:00
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButton *button = GTK_BUTTON (activatable);
|
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
|
|
|
|
if (strcmp (property_name, "visible") == 0)
|
|
|
|
|
{
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
if (gtk_action_is_visible (action))
|
|
|
|
|
gtk_widget_show (GTK_WIDGET (activatable));
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_hide (GTK_WIDGET (activatable));
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
}
|
|
|
|
|
else if (strcmp (property_name, "sensitive") == 0)
|
2013-06-28 15:27:19 +00:00
|
|
|
|
{
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
|
|
|
|
}
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
|
|
|
|
if (!priv->use_action_appearance)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-10-02 17:03:29 +00:00
|
|
|
|
if (strcmp (property_name, "gicon") == 0)
|
2009-01-23 15:15:28 +00:00
|
|
|
|
activatable_update_gicon (GTK_BUTTON (activatable), action);
|
|
|
|
|
else if (strcmp (property_name, "short-label") == 0)
|
|
|
|
|
activatable_update_short_label (GTK_BUTTON (activatable), action);
|
|
|
|
|
else if (strcmp (property_name, "icon-name") == 0)
|
|
|
|
|
activatable_update_icon_name (GTK_BUTTON (activatable), action);
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-22 05:20:14 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_sync_action_properties (GtkActivatable *activatable,
|
|
|
|
|
GtkAction *action)
|
2009-01-23 15:15:28 +00:00
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButton *button = GTK_BUTTON (activatable);
|
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2013-06-28 15:27:19 +00:00
|
|
|
|
gboolean always_show_image;
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
|
|
|
|
if (!action)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
if (gtk_action_is_visible (action))
|
|
|
|
|
gtk_widget_show (GTK_WIDGET (activatable));
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_hide (GTK_WIDGET (activatable));
|
2016-10-02 17:03:29 +00:00
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
|
2013-06-28 15:27:19 +00:00
|
|
|
|
always_show_image = gtk_action_get_always_show_image (action);
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
if (priv->use_action_appearance)
|
|
|
|
|
{
|
|
|
|
|
activatable_update_short_label (GTK_BUTTON (activatable), action);
|
|
|
|
|
activatable_update_gicon (GTK_BUTTON (activatable), action);
|
|
|
|
|
activatable_update_icon_name (GTK_BUTTON (activatable), action);
|
|
|
|
|
}
|
2012-05-20 15:58:45 +00:00
|
|
|
|
|
2013-06-28 15:27:19 +00:00
|
|
|
|
gtk_button_set_always_show_image (button, always_show_image);
|
2009-01-23 15:15:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-02-22 05:20:14 +00:00
|
|
|
|
gtk_button_set_related_action (GtkButton *button,
|
|
|
|
|
GtkAction *action)
|
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
|
|
|
|
g_return_if_fail (gtk_action_helper_get_action_name (button->priv->action_helper) == NULL);
|
2012-01-06 18:16:36 +00:00
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
if (priv->action == action)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-01-27 02:55:02 +00:00
|
|
|
|
/* This should be a default handler, but for compatibility reasons
|
|
|
|
|
* we need to support derived classes that don't chain up their
|
|
|
|
|
* clicked handler.
|
|
|
|
|
*/
|
|
|
|
|
g_signal_handlers_disconnect_by_func (button, gtk_real_button_clicked, NULL);
|
|
|
|
|
if (action)
|
2009-02-22 05:20:14 +00:00
|
|
|
|
g_signal_connect_after (button, "clicked",
|
2009-01-27 02:55:02 +00:00
|
|
|
|
G_CALLBACK (gtk_real_button_clicked), NULL);
|
|
|
|
|
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
2009-01-23 15:15:28 +00:00
|
|
|
|
gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (button), action);
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
2009-01-23 15:15:28 +00:00
|
|
|
|
|
|
|
|
|
priv->action = action;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-02-22 05:20:14 +00:00
|
|
|
|
gtk_button_set_use_action_appearance (GtkButton *button,
|
|
|
|
|
gboolean use_appearance)
|
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
|
|
|
|
|
|
|
|
|
if (priv->use_action_appearance != use_appearance)
|
|
|
|
|
{
|
|
|
|
|
priv->use_action_appearance = use_appearance;
|
2009-02-22 05:20:14 +00:00
|
|
|
|
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
2009-02-22 05:20:14 +00:00
|
|
|
|
gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (button), priv->action);
|
2013-06-28 15:27:19 +00:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2004-02-19 22:39:58 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
show_image (GtkButton *button)
|
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2004-02-19 22:39:58 +00:00
|
|
|
|
gboolean show;
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
2013-10-25 00:35:55 +00:00
|
|
|
|
if (priv->label_text && !priv->always_show_image)
|
|
|
|
|
{
|
|
|
|
|
GtkSettings *settings;
|
|
|
|
|
|
|
|
|
|
settings = gtk_widget_get_settings (GTK_WIDGET (button));
|
|
|
|
|
g_object_get (settings, "gtk-button-images", &show, NULL);
|
|
|
|
|
}
|
2013-06-26 12:24:44 +00:00
|
|
|
|
else
|
2013-10-25 00:35:55 +00:00
|
|
|
|
show = TRUE;
|
2004-02-19 22:39:58 +00:00
|
|
|
|
|
|
|
|
|
return show;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-20 15:58:45 +00:00
|
|
|
|
|
2001-08-27 01:05:07 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_construct_child (GtkButton *button)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2010-12-05 21:05:29 +00:00
|
|
|
|
GtkStyleContext *context;
|
2010-05-24 20:31:36 +00:00
|
|
|
|
GtkWidget *child;
|
2001-08-27 01:05:07 +00:00
|
|
|
|
GtkWidget *label;
|
2006-05-31 00:22:19 +00:00
|
|
|
|
GtkWidget *box;
|
2004-11-15 20:56:28 +00:00
|
|
|
|
GtkWidget *image = NULL;
|
2009-07-01 19:11:03 +00:00
|
|
|
|
|
2013-08-19 18:40:22 +00:00
|
|
|
|
context = gtk_widget_get_style_context (GTK_WIDGET (button));
|
|
|
|
|
gtk_style_context_remove_class (context, "image-button");
|
|
|
|
|
gtk_style_context_remove_class (context, "text-button");
|
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if (!priv->constructed)
|
2001-08-27 01:05:07 +00:00
|
|
|
|
return;
|
2009-07-01 19:11:03 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if (!priv->label_text && !priv->image)
|
2001-08-27 01:05:07 +00:00
|
|
|
|
return;
|
2009-07-01 19:11:03 +00:00
|
|
|
|
|
2016-10-02 17:03:29 +00:00
|
|
|
|
if (priv->image)
|
2006-03-06 03:47:06 +00:00
|
|
|
|
{
|
2010-08-11 21:17:29 +00:00
|
|
|
|
GtkWidget *parent;
|
|
|
|
|
|
2006-03-06 03:47:06 +00:00
|
|
|
|
image = g_object_ref (priv->image);
|
2010-08-11 21:17:29 +00:00
|
|
|
|
|
|
|
|
|
parent = gtk_widget_get_parent (image);
|
|
|
|
|
if (parent)
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (parent), image);
|
2004-03-05 21:36:03 +00:00
|
|
|
|
}
|
2009-07-01 19:11:03 +00:00
|
|
|
|
|
2007-07-03 17:09:42 +00:00
|
|
|
|
priv->image = NULL;
|
|
|
|
|
|
2010-05-24 20:31:36 +00:00
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (button));
|
|
|
|
|
if (child)
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (button), child);
|
2007-07-03 17:09:42 +00:00
|
|
|
|
|
2004-11-15 20:56:28 +00:00
|
|
|
|
if (image)
|
|
|
|
|
{
|
|
|
|
|
priv->image = image;
|
2009-07-01 19:11:03 +00:00
|
|
|
|
g_object_set (priv->image,
|
2004-02-19 22:39:58 +00:00
|
|
|
|
"visible", show_image (button),
|
2005-03-26 05:49:15 +00:00
|
|
|
|
"no-show-all", TRUE,
|
2004-02-19 22:39:58 +00:00
|
|
|
|
NULL);
|
2006-05-31 00:22:19 +00:00
|
|
|
|
|
|
|
|
|
if (priv->image_position == GTK_POS_LEFT ||
|
|
|
|
|
priv->image_position == GTK_POS_RIGHT)
|
2016-10-02 17:47:25 +00:00
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2006-05-31 00:22:19 +00:00
|
|
|
|
else
|
2016-10-02 17:47:25 +00:00
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
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-03-07 12:53:16 +00:00
|
|
|
|
gtk_widget_set_valign (image, GTK_ALIGN_BASELINE);
|
|
|
|
|
gtk_widget_set_valign (box, GTK_ALIGN_BASELINE);
|
|
|
|
|
|
2006-05-31 00:22:19 +00:00
|
|
|
|
if (priv->image_position == GTK_POS_LEFT ||
|
|
|
|
|
priv->image_position == GTK_POS_TOP)
|
2016-10-02 15:37:22 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), priv->image, FALSE, FALSE);
|
2006-05-31 00:22:19 +00:00
|
|
|
|
else
|
2016-10-02 15:37:22 +00:00
|
|
|
|
gtk_box_pack_end (GTK_BOX (box), priv->image, FALSE, FALSE);
|
2006-03-06 03:47:06 +00:00
|
|
|
|
|
2016-10-02 17:03:29 +00:00
|
|
|
|
if (priv->label_text)
|
2006-03-06 03:47:06 +00:00
|
|
|
|
{
|
2016-10-02 17:03:29 +00:00
|
|
|
|
if (priv->use_underline)
|
2009-06-19 02:08:31 +00:00
|
|
|
|
{
|
2016-10-02 17:03:29 +00:00
|
|
|
|
label = gtk_label_new_with_mnemonic (priv->label_text);
|
2009-06-19 02:08:31 +00:00
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label),
|
|
|
|
|
GTK_WIDGET (button));
|
|
|
|
|
}
|
|
|
|
|
else
|
2016-10-02 17:03:29 +00:00
|
|
|
|
label = gtk_label_new (priv->label_text);
|
2006-03-06 03:47:06 +00:00
|
|
|
|
|
2013-03-07 12:53:16 +00:00
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
|
|
|
|
|
|
2006-05-31 00:22:19 +00:00
|
|
|
|
if (priv->image_position == GTK_POS_RIGHT ||
|
|
|
|
|
priv->image_position == GTK_POS_BOTTOM)
|
2016-10-02 15:37:22 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE);
|
2006-05-31 00:22:19 +00:00
|
|
|
|
else
|
2016-10-02 15:37:22 +00:00
|
|
|
|
gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE);
|
2006-03-06 03:47:06 +00:00
|
|
|
|
}
|
2013-08-19 18:40:22 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gtk_style_context_add_class (context, "image-button");
|
|
|
|
|
}
|
2009-07-01 19:11:03 +00:00
|
|
|
|
|
2016-10-02 16:35:36 +00:00
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), box);
|
|
|
|
|
gtk_widget_show_all (box);
|
2001-08-27 01:05:07 +00:00
|
|
|
|
|
2004-11-15 20:56:28 +00:00
|
|
|
|
g_object_unref (image);
|
|
|
|
|
|
2001-08-27 01:05:07 +00:00
|
|
|
|
return;
|
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
|
|
|
|
}
|
2009-07-01 19:11:03 +00:00
|
|
|
|
|
2016-10-02 17:03:29 +00:00
|
|
|
|
if (priv->use_underline)
|
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-10-18 17:39:19 +00:00
|
|
|
|
label = gtk_label_new_with_mnemonic (priv->label_text);
|
2001-08-27 01:05:07 +00:00
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
|
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
|
|
|
|
}
|
2001-08-27 01:05:07 +00:00
|
|
|
|
else
|
2010-10-18 17:39:19 +00:00
|
|
|
|
label = gtk_label_new (priv->label_text);
|
2009-07-01 19:11:03 +00:00
|
|
|
|
|
2013-03-07 12:53:16 +00:00
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
|
|
|
|
|
|
2001-08-27 01:05:07 +00:00
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), label);
|
2013-08-19 18:40:22 +00:00
|
|
|
|
|
|
|
|
|
gtk_style_context_add_class (context, "text-button");
|
2001-08-27 01:05:07 +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:
|
|
|
|
|
* @icon_name: an icon name
|
2015-10-31 12:38:24 +00:00
|
|
|
|
* @size: (type int): an icon size (#GtkIconSize)
|
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
|
|
|
|
* This function is a convenience wrapper around gtk_button_new() and
|
|
|
|
|
* gtk_button_set_image().
|
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*
|
|
|
|
|
gtk_button_new_from_icon_name (const gchar *icon_name,
|
|
|
|
|
GtkIconSize size)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *button;
|
|
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
|
|
image = gtk_image_new_from_icon_name (icon_name, size);
|
|
|
|
|
button = g_object_new (GTK_TYPE_BUTTON,
|
|
|
|
|
"image", image,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
* The deprecated value %GTK_RELIEF_HALF behaves the same as
|
|
|
|
|
* %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
|
|
|
|
}
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_realize (GtkWidget *widget)
|
|
|
|
|
{
|
2010-08-11 21:17:29 +00:00
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2010-08-11 21:17:29 +00:00
|
|
|
|
GtkAllocation allocation;
|
|
|
|
|
GdkWindow *window;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
GdkWindowAttr attributes;
|
|
|
|
|
gint attributes_mask;
|
|
|
|
|
|
2010-08-11 21:17:29 +00:00
|
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
|
|
|
|
|
2010-03-06 10:51:33 +00:00
|
|
|
|
gtk_widget_set_realized (widget, TRUE);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
|
|
attributes.window_type = GDK_WINDOW_CHILD;
|
2010-09-05 06:22:47 +00:00
|
|
|
|
attributes.x = allocation.x;
|
|
|
|
|
attributes.y = allocation.y;
|
|
|
|
|
attributes.width = allocation.width;
|
|
|
|
|
attributes.height = allocation.height;
|
2001-11-15 21:04:51 +00:00
|
|
|
|
attributes.wclass = GDK_INPUT_ONLY;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
attributes.event_mask = gtk_widget_get_events (widget);
|
2003-07-08 18:59:16 +00:00
|
|
|
|
attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
|
2012-01-04 23:35:04 +00:00
|
|
|
|
GDK_BUTTON_RELEASE_MASK |
|
|
|
|
|
GDK_TOUCH_MASK |
|
|
|
|
|
GDK_ENTER_NOTIFY_MASK |
|
|
|
|
|
GDK_LEAVE_NOTIFY_MASK);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2001-11-15 21:04:51 +00:00
|
|
|
|
attributes_mask = GDK_WA_X | GDK_WA_Y;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2010-08-11 21:17:29 +00:00
|
|
|
|
window = gtk_widget_get_parent_window (widget);
|
|
|
|
|
gtk_widget_set_window (widget, window);
|
|
|
|
|
g_object_ref (window);
|
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv->event_window = gdk_window_new (window,
|
|
|
|
|
&attributes, attributes_mask);
|
2013-02-05 08:36:49 +00:00
|
|
|
|
gtk_widget_register_window (widget, priv->event_window);
|
1997-11-24 22:37: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
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if (priv->event_window)
|
2001-11-15 21:04:51 +00:00
|
|
|
|
{
|
2013-02-05 08:36:49 +00:00
|
|
|
|
gtk_widget_unregister_window (widget, priv->event_window);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
gdk_window_destroy (priv->event_window);
|
|
|
|
|
priv->event_window = NULL;
|
2001-11-15 21:04:51 +00:00
|
|
|
|
}
|
2010-10-18 17:39:19 +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
|
|
|
|
}
|
|
|
|
|
|
2001-11-15 21:04:51 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_map (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_button_parent_class)->map (widget);
|
2001-11-21 23:49:17 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if (priv->event_window)
|
|
|
|
|
gdk_window_show (priv->event_window);
|
2001-11-15 21:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_unmap (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->event_window)
|
2012-05-26 20:32:07 +00:00
|
|
|
|
{
|
|
|
|
|
gdk_window_hide (priv->event_window);
|
|
|
|
|
priv->in_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)->unmap (widget);
|
2001-11-15 21:04:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-29 13:07:22 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_size_allocate (GtkWidget *widget,
|
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
2015-12-04 02:56:25 +00:00
|
|
|
|
GtkAllocation clip;
|
2010-12-05 21:05:29 +00:00
|
|
|
|
|
2010-08-11 21:17:29 +00:00
|
|
|
|
gtk_widget_set_allocation (widget, allocation);
|
2015-12-04 02:56:25 +00:00
|
|
|
|
gtk_css_gadget_allocate (priv->gadget,
|
|
|
|
|
allocation,
|
|
|
|
|
gtk_widget_get_allocated_baseline (widget),
|
|
|
|
|
&clip);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
gtk_widget_set_clip (widget, &clip);
|
|
|
|
|
}
|
2004-05-07 15:26:35 +00:00
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_allocate (GtkCssGadget *gadget,
|
|
|
|
|
const GtkAllocation *allocation,
|
|
|
|
|
int baseline,
|
|
|
|
|
GtkAllocation *out_clip,
|
|
|
|
|
gpointer unused)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
GtkWidget *child;
|
2013-03-07 12:53:16 +00:00
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
widget = gtk_css_gadget_get_owner (gadget);
|
2010-08-07 21:41:29 +00:00
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (widget));
|
|
|
|
|
if (child && gtk_widget_get_visible (child))
|
|
|
|
|
gtk_widget_size_allocate_with_baseline (child, (GtkAllocation *)allocation, baseline);
|
2014-05-23 14:01:45 +00:00
|
|
|
|
|
2016-01-12 19:18:08 +00:00
|
|
|
|
if (gtk_widget_get_realized (widget))
|
|
|
|
|
{
|
|
|
|
|
GtkAllocation border_allocation;
|
|
|
|
|
gtk_css_gadget_get_border_allocation (gadget, &border_allocation, NULL);
|
|
|
|
|
gdk_window_move_resize (GTK_BUTTON (widget)->priv->event_window,
|
|
|
|
|
border_allocation.x,
|
|
|
|
|
border_allocation.y,
|
|
|
|
|
border_allocation.width,
|
|
|
|
|
border_allocation.height);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
gtk_container_get_children_clip (GTK_CONTAINER (widget), out_clip);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-04-11 13:02:56 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_button_draw (GtkWidget *widget,
|
|
|
|
|
cairo_t *cr)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2015-12-04 02:56:25 +00:00
|
|
|
|
gtk_css_gadget_draw (GTK_BUTTON (widget)->priv->gadget, cr);
|
2010-11-09 20:33:10 +00:00
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2010-11-09 20:33:10 +00:00
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_button_render (GtkCssGadget *gadget,
|
|
|
|
|
cairo_t *cr,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget;
|
2004-09-20 14:43:18 +00:00
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
widget = gtk_css_gadget_get_owner (gadget);
|
2011-01-10 01:26:28 +00:00
|
|
|
|
|
2010-09-07 22:23:04 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_button_parent_class)->draw (widget, cr);
|
2008-08-12 09:06:34 +00:00
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
return gtk_widget_has_visible_focus (widget);
|
1997-11-24 22:37:52 +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
|
2005-06-30 21:18:34 +00:00
|
|
|
|
gtk_button_grab_broken (GtkWidget *widget,
|
|
|
|
|
GdkEventGrabBroken *event)
|
2005-06-30 03:35:30 +00:00
|
|
|
|
{
|
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
|
|
|
|
|
2013-12-02 20:24:30 +00:00
|
|
|
|
gtk_button_do_release (button, FALSE);
|
2005-06-30 03:35:30 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2001-03-16 20:12:40 +00:00
|
|
|
|
static gboolean
|
1997-11-24 22:37:52 +00:00
|
|
|
|
gtk_button_enter_notify (GtkWidget *widget,
|
|
|
|
|
GdkEventCrossing *event)
|
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if ((event->window == button->priv->event_window) &&
|
1997-11-24 22:37:52 +00:00
|
|
|
|
(event->detail != GDK_NOTIFY_INFERIOR))
|
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv->in_button = TRUE;
|
2016-10-02 17:46:52 +00:00
|
|
|
|
gtk_button_update_state (button);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2001-03-16 20:12:40 +00:00
|
|
|
|
static gboolean
|
1997-11-24 22:37:52 +00:00
|
|
|
|
gtk_button_leave_notify (GtkWidget *widget,
|
|
|
|
|
GdkEventCrossing *event)
|
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButton *button = GTK_BUTTON (widget);
|
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
if ((event->window == button->priv->event_window) &&
|
2013-12-07 00:29:56 +00:00
|
|
|
|
(event->detail != GDK_NOTIFY_INFERIOR))
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv->in_button = FALSE;
|
2016-10-02 17:46:52 +00:00
|
|
|
|
gtk_button_update_state (button);
|
2012-01-04 23:35:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
2012-01-06 03:22:06 +00:00
|
|
|
|
|
2009-01-23 15:15:28 +00:00
|
|
|
|
if (priv->action)
|
|
|
|
|
gtk_action_activate (priv->action);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
guint32 time;
|
|
|
|
|
|
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
|
|
|
|
{
|
2005-06-27 20:04:33 +00:00
|
|
|
|
time = gtk_get_current_event_time ();
|
2010-05-25 22:38:44 +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)
|
|
|
|
|
{
|
2015-11-26 18:54:01 +00:00
|
|
|
|
if (gdk_seat_grab (gdk_device_get_seat (device), priv->event_window,
|
|
|
|
|
GDK_SEAT_CAPABILITY_KEYBOARD, TRUE,
|
|
|
|
|
NULL, NULL, NULL, NULL) == GDK_GRAB_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
gtk_device_grab_add (widget, device, TRUE);
|
|
|
|
|
priv->grab_keyboard = device;
|
|
|
|
|
priv->grab_time = time;
|
2011-01-21 19:36:27 +00:00
|
|
|
|
}
|
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
|
2015-12-04 02:56:25 +00:00
|
|
|
|
gtk_button_measure (GtkCssGadget *gadget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget;
|
2010-04-07 00:48:41 +00:00
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
widget = gtk_css_gadget_get_owner (gadget);
|
|
|
|
|
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
|
|
|
|
{
|
2015-12-04 02:56:25 +00:00
|
|
|
|
_gtk_widget_get_preferred_size_for_size (child,
|
|
|
|
|
orientation,
|
|
|
|
|
for_size,
|
|
|
|
|
minimum, natural,
|
|
|
|
|
minimum_baseline, natural_baseline);
|
2010-04-07 00:48:41 +00:00
|
|
|
|
}
|
2010-04-13 02:21:46 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2015-12-04 02:56:25 +00:00
|
|
|
|
*minimum = 0;
|
|
|
|
|
*natural = 0;
|
|
|
|
|
if (minimum_baseline)
|
|
|
|
|
*minimum_baseline = 0;
|
|
|
|
|
if (natural_baseline)
|
|
|
|
|
*natural_baseline = 0;
|
2013-03-07 12:53:16 +00:00
|
|
|
|
}
|
2010-04-07 00:48:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
static void
|
2010-09-21 14:35:17 +00:00
|
|
|
|
gtk_button_get_preferred_width (GtkWidget *widget,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size)
|
2010-04-13 02:21:46 +00:00
|
|
|
|
{
|
2015-12-04 02:56:25 +00:00
|
|
|
|
gtk_css_gadget_get_preferred_size (GTK_BUTTON (widget)->priv->gadget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL,
|
|
|
|
|
-1,
|
|
|
|
|
minimum_size, natural_size,
|
|
|
|
|
NULL, NULL);
|
2010-04-13 02:21:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
static void
|
2010-09-21 14:35:17 +00:00
|
|
|
|
gtk_button_get_preferred_height (GtkWidget *widget,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size)
|
2010-04-13 02:21:46 +00:00
|
|
|
|
{
|
2015-12-04 02:56:25 +00:00
|
|
|
|
gtk_css_gadget_get_preferred_size (GTK_BUTTON (widget)->priv->gadget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL,
|
|
|
|
|
-1,
|
|
|
|
|
minimum_size, natural_size,
|
|
|
|
|
NULL, NULL);
|
2013-04-22 21:37:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
static void
|
2013-04-22 21:37:18 +00:00
|
|
|
|
gtk_button_get_preferred_width_for_height (GtkWidget *widget,
|
|
|
|
|
gint for_size,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size)
|
|
|
|
|
{
|
2015-12-04 02:56:25 +00:00
|
|
|
|
gtk_css_gadget_get_preferred_size (GTK_BUTTON (widget)->priv->gadget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL,
|
|
|
|
|
for_size,
|
|
|
|
|
minimum_size, natural_size,
|
|
|
|
|
NULL, NULL);
|
2013-04-22 21:37:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 02:56:25 +00:00
|
|
|
|
static void
|
2013-04-22 21:37:18 +00:00
|
|
|
|
gtk_button_get_preferred_height_for_width (GtkWidget *widget,
|
|
|
|
|
gint for_size,
|
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size)
|
|
|
|
|
{
|
2015-12-04 02:56:25 +00:00
|
|
|
|
gtk_css_gadget_get_preferred_size (GTK_BUTTON (widget)->priv->gadget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL,
|
|
|
|
|
for_size,
|
|
|
|
|
minimum_size, natural_size,
|
|
|
|
|
NULL, NULL);
|
2013-03-07 12:53:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
|
2015-12-04 02:56:25 +00:00
|
|
|
|
gint for_size,
|
2013-03-07 12:53:16 +00:00
|
|
|
|
gint *minimum_size,
|
|
|
|
|
gint *natural_size,
|
|
|
|
|
gint *minimum_baseline,
|
|
|
|
|
gint *natural_baseline)
|
|
|
|
|
{
|
2015-12-04 02:56:25 +00:00
|
|
|
|
gtk_css_gadget_get_preferred_size (GTK_BUTTON (widget)->priv->gadget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL,
|
|
|
|
|
for_size,
|
|
|
|
|
minimum_size, natural_size,
|
|
|
|
|
minimum_baseline, natural_baseline);
|
2010-04-13 02:21:46 +00:00
|
|
|
|
}
|
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-02 17:03:29 +00:00
|
|
|
|
* Sets the text of the label of the button to @str.
|
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,
|
|
|
|
|
const gchar *label)
|
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv;
|
2003-11-07 21:57:20 +00:00
|
|
|
|
gchar *new_label;
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
2003-11-07 21:57:20 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv = button->priv;
|
|
|
|
|
|
2003-11-07 21:57:20 +00:00
|
|
|
|
new_label = g_strdup (label);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
g_free (priv->label_text);
|
|
|
|
|
priv->label_text = new_label;
|
|
|
|
|
|
2001-08-27 01:05:07 +00:00
|
|
|
|
gtk_button_construct_child (button);
|
|
|
|
|
|
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
|
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
|
|
|
|
* gtk_button_set_label(). If the label text has not
|
|
|
|
|
* been set the return value will be %NULL. This will be the
|
2001-11-14 22:36:23 +00:00
|
|
|
|
* case if you create an empty button with gtk_button_new() to
|
|
|
|
|
* use as a container.
|
2001-08-27 01:05:07 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: 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)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
|
2010-10-18 17:39:19 +00:00
|
|
|
|
|
|
|
|
|
return button->priv->label_text;
|
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
|
|
|
|
{
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv->use_underline = use_underline;
|
|
|
|
|
|
2001-08-27 01:05:07 +00:00
|
|
|
|
gtk_button_construct_child (button);
|
|
|
|
|
|
2014-06-07 13:40:55 +00:00
|
|
|
|
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
|
|
|
|
|
* mnemonic. See gtk_button_set_use_underline ().
|
|
|
|
|
*
|
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
|
|
|
|
|
2011-01-23 17:04:41 +00:00
|
|
|
|
new_state = gtk_widget_get_state_flags (GTK_WIDGET (button)) &
|
|
|
|
|
~(GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE);
|
|
|
|
|
|
2010-10-31 13:38:26 +00:00
|
|
|
|
if (priv->in_button)
|
|
|
|
|
new_state |= GTK_STATE_FLAG_PRELIGHT;
|
|
|
|
|
|
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
|
|
|
|
|
2013-10-25 00:35:55 +00:00
|
|
|
|
static void
|
|
|
|
|
show_image_change_notify (GtkButton *button)
|
|
|
|
|
{
|
|
|
|
|
GtkButtonPrivate *priv = button->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->image)
|
|
|
|
|
{
|
|
|
|
|
if (show_image (button))
|
|
|
|
|
gtk_widget_show (priv->image);
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_hide (priv->image);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
traverse_container (GtkWidget *widget,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
if (GTK_IS_BUTTON (widget))
|
|
|
|
|
show_image_change_notify (GTK_BUTTON (widget));
|
|
|
|
|
else if (GTK_IS_CONTAINER (widget))
|
|
|
|
|
gtk_container_forall (GTK_CONTAINER (widget), traverse_container, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_setting_changed (GtkSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
GList *list, *l;
|
|
|
|
|
|
|
|
|
|
list = gtk_window_list_toplevels ();
|
|
|
|
|
|
|
|
|
|
for (l = list; l; l = l->next)
|
|
|
|
|
gtk_container_forall (GTK_CONTAINER (l->data),
|
|
|
|
|
traverse_container, NULL);
|
|
|
|
|
|
|
|
|
|
g_list_free (list);
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-19 22:39:58 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_button_screen_changed (GtkWidget *widget,
|
|
|
|
|
GdkScreen *previous_screen)
|
|
|
|
|
{
|
2009-12-11 16:17:38 +00:00
|
|
|
|
GtkButton *button;
|
2010-10-18 17:39:19 +00:00
|
|
|
|
GtkButtonPrivate *priv;
|
2013-10-25 00:35:55 +00:00
|
|
|
|
GtkSettings *settings;
|
|
|
|
|
gulong show_image_connection;
|
2004-02-19 22:39:58 +00:00
|
|
|
|
|
2004-11-15 18:07:22 +00:00
|
|
|
|
if (!gtk_widget_has_screen (widget))
|
2004-02-19 22:39:58 +00:00
|
|
|
|
return;
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
/* If the button is being pressed while the screen changes the
|
|
|
|
|
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);
|
|
|
|
|
}
|
2013-10-25 00:35:55 +00:00
|
|
|
|
|
|
|
|
|
settings = gtk_widget_get_settings (widget);
|
|
|
|
|
|
|
|
|
|
show_image_connection =
|
|
|
|
|
g_signal_handler_find (settings, G_SIGNAL_MATCH_FUNC, 0, 0,
|
|
|
|
|
NULL, gtk_button_setting_changed, NULL);
|
|
|
|
|
|
|
|
|
|
if (show_image_connection)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
g_signal_connect (settings, "notify::gtk-button-images",
|
|
|
|
|
G_CALLBACK (gtk_button_setting_changed), NULL);
|
|
|
|
|
|
|
|
|
|
show_image_change_notify (button);
|
2004-02-19 22:39:58 +00:00
|
|
|
|
}
|
2004-09-26 05:47:11 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_state_changed (GtkWidget *widget,
|
|
|
|
|
GtkStateType previous_state)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_button_set_image:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
* @image: a widget to set as the image for the button
|
|
|
|
|
*
|
2013-06-26 12:24:44 +00:00
|
|
|
|
* Set the image of @button to the given widget. The image will be
|
|
|
|
|
* displayed if the label text is %NULL or if
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* #GtkButton:always-show-image is %TRUE. You don’t have to call
|
2005-06-16 12:51:00 +00:00
|
|
|
|
* gtk_widget_show() on @image yourself.
|
2004-11-15 20:56:28 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
2013-06-26 12:24:44 +00:00
|
|
|
|
*/
|
2004-11-15 20:56:28 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_button_set_image (GtkButton *button,
|
|
|
|
|
GtkWidget *image)
|
|
|
|
|
{
|
2005-09-29 13:42:21 +00:00
|
|
|
|
GtkButtonPrivate *priv;
|
2010-08-11 21:17:29 +00:00
|
|
|
|
GtkWidget *parent;
|
2005-09-29 13:42:21 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
g_return_if_fail (image == NULL || GTK_IS_WIDGET (image));
|
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv = button->priv;
|
2004-11-15 20:56:28 +00:00
|
|
|
|
|
2010-08-11 21:17:29 +00:00
|
|
|
|
if (priv->image)
|
|
|
|
|
{
|
|
|
|
|
parent = gtk_widget_get_parent (priv->image);
|
|
|
|
|
if (parent)
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (parent), priv->image);
|
|
|
|
|
}
|
2007-05-10 20:19:38 +00:00
|
|
|
|
|
2004-11-15 20:56:28 +00:00
|
|
|
|
priv->image = image;
|
|
|
|
|
|
|
|
|
|
gtk_button_construct_child (button);
|
|
|
|
|
|
2014-06-07 13:40:55 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_IMAGE]);
|
2004-11-15 20:56:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_button_get_image:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
*
|
|
|
|
|
* Gets the widget that is currenty set as the image of @button.
|
|
|
|
|
*
|
2015-12-28 20:14:08 +00:00
|
|
|
|
* Returns: (nullable) (transfer none): a #GtkWidget or %NULL in case
|
|
|
|
|
* there is no image
|
2005-03-31 17:04:25 +00:00
|
|
|
|
*
|
2004-11-15 20:56:28 +00:00
|
|
|
|
* Since: 2.6
|
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_button_get_image (GtkButton *button)
|
|
|
|
|
{
|
2004-11-17 01:21:16 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
|
2004-11-15 20:56:28 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
return button->priv->image;
|
2004-11-15 20:56:28 +00:00
|
|
|
|
}
|
2006-05-31 00:22:19 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_button_set_image_position:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
* @position: the position
|
|
|
|
|
*
|
2006-06-01 13:42:14 +00:00
|
|
|
|
* Sets the position of the image relative to the text
|
|
|
|
|
* inside the button.
|
2006-05-31 00:22:19 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_button_set_image_position (GtkButton *button,
|
|
|
|
|
GtkPositionType position)
|
|
|
|
|
{
|
|
|
|
|
GtkButtonPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
g_return_if_fail (position >= GTK_POS_LEFT && position <= GTK_POS_BOTTOM);
|
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
priv = button->priv;
|
2006-05-31 00:22:19 +00:00
|
|
|
|
|
|
|
|
|
if (priv->image_position != position)
|
|
|
|
|
{
|
|
|
|
|
priv->image_position = position;
|
|
|
|
|
|
|
|
|
|
gtk_button_construct_child (button);
|
|
|
|
|
|
2014-06-07 13:40:55 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_IMAGE_POSITION]);
|
2006-05-31 00:22:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_button_get_image_position:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
*
|
2006-06-01 13:42:14 +00:00
|
|
|
|
* Gets the position of the image relative to the text
|
|
|
|
|
* inside the button.
|
2006-05-31 00:22:19 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the position
|
2006-05-31 00:22:19 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.10
|
|
|
|
|
*/
|
|
|
|
|
GtkPositionType
|
|
|
|
|
gtk_button_get_image_position (GtkButton *button)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), GTK_POS_LEFT);
|
2004-11-15 20:56:28 +00:00
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
return button->priv->image_position;
|
2006-05-31 00:22:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-05-20 15:58:45 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_button_set_always_show_image:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
* @always_show: %TRUE if the menuitem should always show the image
|
|
|
|
|
*
|
2013-10-25 00:35:55 +00:00
|
|
|
|
* If %TRUE, the button will ignore the #GtkSettings:gtk-button-images
|
|
|
|
|
* setting and always show the image, if available.
|
2012-05-20 15:58:45 +00:00
|
|
|
|
*
|
|
|
|
|
* Use this property if the button would be useless or hard to use
|
|
|
|
|
* without the image.
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.6
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_button_set_always_show_image (GtkButton *button,
|
|
|
|
|
gboolean always_show)
|
|
|
|
|
{
|
|
|
|
|
GtkButtonPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON (button));
|
|
|
|
|
|
|
|
|
|
priv = button->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->always_show_image != always_show)
|
|
|
|
|
{
|
|
|
|
|
priv->always_show_image = always_show;
|
|
|
|
|
|
|
|
|
|
if (priv->image)
|
|
|
|
|
{
|
|
|
|
|
if (show_image (button))
|
|
|
|
|
gtk_widget_show (priv->image);
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_hide (priv->image);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-07 13:40:55 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_ALWAYS_SHOW_IMAGE]);
|
2012-05-20 15:58:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_button_get_always_show_image:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
*
|
2013-10-25 00:35:55 +00:00
|
|
|
|
* Returns whether the button will ignore the #GtkSettings:gtk-button-images
|
|
|
|
|
* setting and always show the image, if available.
|
2012-05-20 15:58:45 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the button will always show the image
|
|
|
|
|
*
|
|
|
|
|
* Since: 3.6
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_button_get_always_show_image (GtkButton *button)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), FALSE);
|
|
|
|
|
|
|
|
|
|
return button->priv->always_show_image;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-27 01:22:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_button_get_event_window:
|
|
|
|
|
* @button: a #GtkButton
|
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Returns the button’s event window if it is realized, %NULL otherwise.
|
2010-06-27 01:22:02 +00:00
|
|
|
|
* This function should be rarely needed.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (transfer none): @button’s event window.
|
2010-06-27 01:22:02 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.22
|
|
|
|
|
*/
|
|
|
|
|
GdkWindow*
|
|
|
|
|
gtk_button_get_event_window (GtkButton *button)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
|
|
|
|
|
|
2010-10-18 17:39:19 +00:00
|
|
|
|
return button->priv->event_window;
|
2010-06-27 01:22:02 +00:00
|
|
|
|
}
|