G_TYPE_NONE, 0);
widget_class->activate_signal = button_signals[ACTIVATE];
+ /**
+ * GtkButton:default-border:
+ *
+ * The "default-border" style property defines the extra space to add
+ * around a button that can become the default widget of its window.
+ * For more information about default widgets, see gtk_widget_grab_default().
+ */
+
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boxed ("default-border",
P_("Default Spacing"),
- P_("Extra space to add for CAN_DEFAULT buttons"),
+ P_("Extra space to add for GTK_CAN_DEFAULT buttons"),
GTK_TYPE_BORDER,
GTK_PARAM_READABLE));
+ /**
+ * GtkButton:default-outside-border:
+ *
+ * The "default-outside-border" style property defines the extra outside
+ * space to add around a button that can become the default widget of its
+ * window. Extra outside space is always drawn outside the button border.
+ * For more information about default widgets, see gtk_widget_grab_default().
+ */
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boxed ("default-outside-border",
P_("Default Outside Spacing"),
- P_("Extra space to add for CAN_DEFAULT buttons that is always drawn outside the border"),
+ P_("Extra space to add for GTK_CAN_DEFAULT buttons that is always drawn outside the border"),
GTK_TYPE_BORDER,
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
GtkWidget *image = NULL;
gchar *label_text = NULL;
gint image_spacing;
-
+
if (!button->constructed)
return;
-
+
if (!button->label_text && !priv->image)
return;
-
- gtk_widget_style_get (GTK_WIDGET (button),
- "image-spacing", &image_spacing,
+
+ gtk_widget_style_get (GTK_WIDGET (button),
+ "image-spacing", &image_spacing,
NULL);
if (priv->image && !priv->image_is_stock)
if (image->parent)
gtk_container_remove (GTK_CONTAINER (image->parent), image);
}
-
+
priv->image = NULL;
if (GTK_BIN (button)->child)
if (image)
{
priv->image = image;
- g_object_set (priv->image,
+ g_object_set (priv->image,
"visible", show_image (button),
"no-show-all", TRUE,
NULL);
if (label_text)
{
- if (button->use_underline)
+ if (button->use_underline || button->use_stock)
{
label = gtk_label_new_with_mnemonic (label_text);
gtk_label_set_mnemonic_widget (GTK_LABEL (label),
else
gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0);
}
-
+
gtk_container_add (GTK_CONTAINER (button), align);
gtk_container_add (GTK_CONTAINER (align), box);
gtk_widget_show_all (align);
return;
}
-
- if (button->use_underline)
+
+ if (button->use_underline || button->use_stock)
{
label = gtk_label_new_with_mnemonic (button->label_text);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
}
else
label = gtk_label_new (button->label_text);
-
+
if (priv->align_set)
gtk_misc_set_alignment (GTK_MISC (label), priv->xalign, priv->yalign);
-
+
gtk_widget_show (label);
gtk_container_add (GTK_CONTAINER (button), label);
}
GTK_WIDGET (widget)->style->ythickness) * 2 +
inner_border.top + inner_border.bottom);
- if (GTK_WIDGET_CAN_DEFAULT (widget))
+ if (gtk_widget_get_can_default (widget))
{
requisition->width += default_border.left + default_border.right;
requisition->height += default_border.top + default_border.bottom;
}
- if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
+ if (GTK_BIN (button)->child && gtk_widget_get_visible (GTK_BIN (button)->child))
{
GtkRequisition child_requisition;
widget->allocation.width - border_width * 2,
widget->allocation.height - border_width * 2);
- if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
+ if (GTK_BIN (button)->child && gtk_widget_get_visible (GTK_BIN (button)->child))
{
child_allocation.x = widget->allocation.x + border_width + inner_border.left + xthickness;
child_allocation.y = widget->allocation.y + border_width + inner_border.top + ythickness;
inner_border.bottom -
border_width * 2);
- if (GTK_WIDGET_CAN_DEFAULT (button))
+ if (gtk_widget_get_can_default (GTK_WIDGET (button)))
{
child_allocation.x += default_border.left;
child_allocation.y += default_border.top;
child_allocation.height = MAX (1, child_allocation.height - default_border.top - default_border.bottom);
}
- if (GTK_WIDGET_CAN_FOCUS (button))
+ if (gtk_widget_get_can_focus (GTK_WIDGET (button)))
{
child_allocation.x += focus_width + focus_pad;
child_allocation.y += focus_width + focus_pad;
gboolean interior_focus;
gint focus_width;
gint focus_pad;
-
- if (GTK_WIDGET_DRAWABLE (button))
+
+ widget = GTK_WIDGET (button);
+
+ if (gtk_widget_is_drawable (widget))
{
- widget = GTK_WIDGET (button);
border_width = GTK_CONTAINER (widget)->border_width;
gtk_button_get_props (button, &default_border, &default_outside_border, NULL, &interior_focus);
- gtk_widget_style_get (GTK_WIDGET (widget),
+ gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
width = widget->allocation.width - border_width * 2;
height = widget->allocation.height - border_width * 2;
- if (GTK_WIDGET_HAS_DEFAULT (widget) &&
+ if (gtk_widget_has_default (widget) &&
GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL)
{
gtk_paint_box (widget->style, widget->window,
width -= default_border.left + default_border.right;
height -= default_border.top + default_border.bottom;
}
- else if (GTK_WIDGET_CAN_DEFAULT (widget))
+ else if (gtk_widget_get_can_default (widget))
{
x += default_outside_border.left;
y += default_outside_border.top;
height -= default_outside_border.top + default_outside_border.bottom;
}
- if (!interior_focus && GTK_WIDGET_HAS_FOCUS (widget))
+ if (!interior_focus && gtk_widget_has_focus (widget))
{
x += focus_width + focus_pad;
y += focus_width + focus_pad;
shadow_type, area, widget, "button",
x, y, width, height);
- if (GTK_WIDGET_HAS_FOCUS (widget))
+ if (gtk_widget_has_focus (widget))
{
gint child_displacement_x;
gint child_displacement_y;
gboolean displace_focus;
- gtk_widget_style_get (GTK_WIDGET (widget),
+ gtk_widget_style_get (widget,
"child-displacement-y", &child_displacement_y,
"child-displacement-x", &child_displacement_x,
"displace-focus", &displace_focus,
gtk_button_expose (GtkWidget *widget,
GdkEventExpose *event)
{
- if (GTK_WIDGET_DRAWABLE (widget))
+ if (gtk_widget_is_drawable (widget))
{
GtkButton *button = GTK_BUTTON (widget);
{
button = GTK_BUTTON (widget);
- if (button->focus_on_click && !GTK_WIDGET_HAS_FOCUS (widget))
+ if (button->focus_on_click && !gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
if (event->button == 1)
if ((event_widget == widget) &&
(event->detail != GDK_NOTIFY_INFERIOR) &&
- (GTK_WIDGET_SENSITIVE (event_widget)))
+ (gtk_widget_get_sensitive (event_widget)))
{
button->in_button = FALSE;
gtk_button_leave (button);
gtk_button_screen_changed (GtkWidget *widget,
GdkScreen *previous_screen)
{
+ GtkButton *button;
GtkSettings *settings;
guint show_image_connection;
if (!gtk_widget_has_screen (widget))
return;
+ button = GTK_BUTTON (widget);
+
+ /* If the button is being pressed while the screen changes the
+ release might never occur, so we reset the state. */
+ if (button->button_down)
+ {
+ button->button_down = FALSE;
+ gtk_button_update_state (button);
+ }
+
settings = gtk_widget_get_settings (widget);
show_image_connection =
I_("gtk-button-connection"),
GUINT_TO_POINTER (show_image_connection));
- show_image_change_notify (GTK_BUTTON (widget));
+ show_image_change_notify (button);
}
static void
{
GtkButton *button = GTK_BUTTON (widget);
- if (!GTK_WIDGET_IS_SENSITIVE (widget))
+ if (!gtk_widget_is_sensitive (widget))
{
button->in_button = FALSE;
gtk_real_button_released (button);