gboolean was_grabbed);
-static void gtk_button_activatable_interface_init (GtkActivatableIface *iface);
-static void gtk_button_activatable_update (GtkActivatable *activatable,
- GtkAction *action,
- const gchar *property_name);
-static void gtk_button_activatable_reset (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);
+static void gtk_button_activatable_interface_init (GtkActivatableIface *iface);
+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);
static guint button_signals[LAST_SIGNAL] = { 0 };
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,
static void
gtk_button_activatable_interface_init (GtkActivatableIface *iface)
{
- iface->update = gtk_button_activatable_update;
- iface->reset = gtk_button_activatable_reset;
+ iface->update = gtk_button_update;
+ iface->sync_action_properties = gtk_button_sync_action_properties;
}
static void
}
static void
-gtk_button_activatable_update (GtkActivatable *activatable,
- GtkAction *action,
- const gchar *property_name)
+gtk_button_update (GtkActivatable *activatable,
+ GtkAction *action,
+ const gchar *property_name)
{
GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (activatable);
activatable_update_icon_name (GTK_BUTTON (activatable), action);
}
-static void
-gtk_button_activatable_reset (GtkActivatable *activatable,
- GtkAction *action)
+static void
+gtk_button_sync_action_properties (GtkActivatable *activatable,
+ GtkAction *action)
{
GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (activatable);
}
static void
-gtk_button_set_related_action (GtkButton *button,
- GtkAction *action)
+gtk_button_set_related_action (GtkButton *button,
+ GtkAction *action)
{
GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (button);
*/
g_signal_handlers_disconnect_by_func (button, gtk_real_button_clicked, NULL);
if (action)
- g_signal_connect_after (button, "clicked",
+ g_signal_connect_after (button, "clicked",
G_CALLBACK (gtk_real_button_clicked), NULL);
gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (button), action);
}
static void
-gtk_button_set_use_action_appearance (GtkButton *button,
- gboolean use_appearance)
+gtk_button_set_use_action_appearance (GtkButton *button,
+ gboolean use_appearance)
{
GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (button);
if (priv->use_action_appearance != use_appearance)
{
priv->use_action_appearance = use_appearance;
-
- gtk_activatable_reset (GTK_ACTIVATABLE (button), priv->action);
+
+ gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (button), priv->action);
}
}
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)
{
- label = gtk_label_new_with_mnemonic (label_text);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label),
- GTK_WIDGET (button));
+ if (button->use_underline || button->use_stock)
+ {
+ label = gtk_label_new_with_mnemonic (label_text);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label),
+ GTK_WIDGET (button));
+ }
+ else
+ label = gtk_label_new (label_text);
if (priv->image_position == GTK_POS_RIGHT ||
priv->image_position == GTK_POS_BOTTOM)
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;
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;
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;
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