#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkimage.h"
-#include "gtkhbox.h"
-#include "gtkvbox.h"
+#include "gtkbox.h"
#include "gtkstock.h"
#include "gtkiconfactory.h"
#include "gtkactivatable.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
#include "gtkintl.h"
+#include "a11y/gtkbuttonaccessible.h"
static const GtkBorder default_default_border = { 1, 1, 1, 1 };
* GtkButton:xalign:
*
* If the child of the button is a #GtkMisc or #GtkAlignment, this property
- * can be used to control it's horizontal alignment. 0.0 is left aligned,
+ * can be used to control its horizontal alignment. 0.0 is left aligned,
* 1.0 is right aligned.
*
* Since: 2.4
* GtkButton:yalign:
*
* If the child of the button is a #GtkMisc or #GtkAlignment, this property
- * can be used to control it's vertical alignment. 0.0 is top aligned,
+ * can be used to control its vertical alignment. 0.0 is top aligned,
* 1.0 is bottom aligned.
*
* Since: 2.4
GTK_PARAM_READABLE));
g_type_class_add_private (gobject_class, sizeof (GtkButtonPrivate));
+
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_BUTTON_ACCESSIBLE);
}
static void
GtkBorder *default_border,
GtkBorder *default_outside_border,
GtkBorder *inner_border,
+ GtkBorder *padding,
gboolean *interior_focus)
{
GtkStyleContext *context;
+ GtkStateFlags state;
GtkBorder *tmp_border;
context = gtk_widget_get_style_context (GTK_WIDGET (button));
+ state = gtk_style_context_get_state (context);
if (default_border)
{
"interior-focus", interior_focus,
NULL);
}
+
+ if (padding)
+ gtk_style_context_get_padding (context, state, padding);
}
static void
GtkButtonPrivate *priv = button->priv;
GtkAllocation child_allocation;
GtkStyleContext *context;
- GtkStateFlags state;
GtkWidget *child;
GtkBorder default_border;
GtkBorder inner_border;
- GtkBorder *border;
+ GtkBorder padding;
gint focus_width;
gint focus_pad;
context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
- gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL);
+ gtk_button_get_props (button, &default_border, NULL, &inner_border, &padding, NULL);
gtk_style_context_get_style (context,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
- gtk_style_context_get (context, state,
- "border-width", &border,
- NULL);
-
gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
child = gtk_bin_get_child (GTK_BIN (button));
if (child && gtk_widget_get_visible (child))
{
- child_allocation.x = allocation->x + inner_border.left + border->left;
- child_allocation.y = allocation->y + inner_border.top + border->top;
+ child_allocation.x = allocation->x + inner_border.left + padding.left;
+ child_allocation.y = allocation->y + inner_border.top + padding.top;
child_allocation.width =
allocation->width -
- (border->left + border->right) -
+ (padding.left + padding.right) -
inner_border.left -
inner_border.right;
child_allocation.height =
allocation->height -
- (border->top + border->bottom) -
+ (padding.top + padding.bottom) -
inner_border.top -
inner_border.bottom;
gtk_widget_size_allocate (child, &child_allocation);
}
-
- gtk_border_free (border);
}
void
gint focus_pad;
GtkAllocation allocation;
GtkStyleContext *context;
+ gboolean draw_focus;
widget = GTK_WIDGET (button);
context = gtk_widget_get_style_context (widget);
gtk_style_context_save (context);
gtk_style_context_set_state (context, state);
- gtk_button_get_props (button, &default_border, &default_outside_border, NULL, &interior_focus);
+ gtk_button_get_props (button, &default_border, &default_outside_border, NULL, NULL, &interior_focus);
gtk_style_context_get_style (context,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
width -= default_outside_border.left + default_outside_border.right;
height -= default_outside_border.top + default_outside_border.bottom;
}
-
- if (!interior_focus && gtk_widget_has_focus (widget))
+
+ draw_focus = gtk_widget_has_visible_focus (widget);
+
+
+ if (!interior_focus && draw_focus)
{
x += focus_width + focus_pad;
y += focus_width + focus_pad;
x, y, width, height);
}
- if (gtk_widget_has_focus (widget))
+ if (draw_focus)
{
gint child_displacement_x;
gint child_displacement_y;
gboolean displace_focus;
- GtkBorder *border;
+ GtkBorder border;
gtk_style_context_get_style (context,
"child-displacement-y", &child_displacement_y,
"child-displacement-x", &child_displacement_x,
"displace-focus", &displace_focus,
NULL);
-
- gtk_style_context_get (context, state,
- "border-width", &border,
- NULL);
+ gtk_style_context_get_border (context, state, &border);
if (interior_focus)
{
- x += border->left + focus_pad;
- y += border->top + focus_pad;
- width -= (2 * focus_pad) + border->left + border->right;
- height -= (2 * focus_pad) + border->top + border->bottom;
+ x += border.left + focus_pad;
+ y += border.top + focus_pad;
+ width -= (2 * focus_pad) + border.left + border.right;
+ height -= (2 * focus_pad) + border.top + border.bottom;
}
else
{
y += child_displacement_y;
}
- gtk_render_focus (context, cr,
- x, y, width, height);
-
- gtk_border_free (border);
+ gtk_render_focus (context, cr, x, y, width, height);
}
gtk_style_context_restore (context);
{
if (gdk_device_grab (device, priv->event_window,
GDK_OWNERSHIP_WINDOW, TRUE,
- GDK_KEY_PRESS | GDK_KEY_RELEASE,
+ GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
NULL, time) == GDK_GRAB_SUCCESS)
{
gtk_device_grab_add (widget, device, TRUE);
{
GtkButton *button = GTK_BUTTON (widget);
GtkStyleContext *context;
- GtkStateFlags state;
GtkWidget *child;
GtkBorder default_border;
GtkBorder inner_border;
- GtkBorder *border;
+ GtkBorder padding;
gint focus_width;
gint focus_pad;
gint minimum, natural;
context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
- gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL);
+ gtk_button_get_props (button, &default_border, NULL, &inner_border, &padding, NULL);
gtk_style_context_get_style (context,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
- gtk_style_context_get (context, state,
- "border-width", &border,
- NULL);
-
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- minimum = (border->left + border->right +
- inner_border.left + inner_border.right);
+ minimum = inner_border.left + inner_border.right + padding.left + padding.right;
if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
minimum += default_border.left + default_border.right;
}
else
{
- minimum = (border->top + border->bottom +
- inner_border.top + inner_border.bottom);
+ minimum = inner_border.top + inner_border.bottom + padding.top + padding.bottom;
if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
minimum += default_border.top + default_border.bottom;
if (natural_size)
*natural_size = natural;
-
- gtk_border_free (border);
}
static void
* Return value: The text of the label widget. This string is owned
* by the widget and must not be modified or freed.
**/
-G_CONST_RETURN gchar *
+const gchar *
gtk_button_get_label (GtkButton *button)
{
g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);