mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 22:10:08 +00:00
button: Stop implementing GtkActivatable
This commit is contained in:
parent
05211d200f
commit
7e16396cc5
@ -892,7 +892,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="visible">1</property>
|
||||
<property name="can_focus">1</property>
|
||||
<property name="receives_default">1</property>
|
||||
<property name="use_action_appearance">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="fill">0</property>
|
||||
@ -905,7 +904,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="sensitive">0</property>
|
||||
<property name="can_focus">1</property>
|
||||
<property name="receives_default">1</property>
|
||||
<property name="use_action_appearance">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="fill">0</property>
|
||||
@ -918,7 +916,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="visible">1</property>
|
||||
<property name="can_focus">1</property>
|
||||
<property name="receives_default">1</property>
|
||||
<property name="use_action_appearance">0</property>
|
||||
<property name="active">1</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -933,7 +930,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="sensitive">0</property>
|
||||
<property name="can_focus">1</property>
|
||||
<property name="receives_default">1</property>
|
||||
<property name="use_action_appearance">0</property>
|
||||
<property name="active">1</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -980,7 +976,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="visible">1</property>
|
||||
<property name="can_focus">1</property>
|
||||
<property name="receives_default">1</property>
|
||||
<property name="use_action_appearance">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="fill">0</property>
|
||||
@ -992,7 +987,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="visible">1</property>
|
||||
<property name="can_focus">1</property>
|
||||
<property name="receives_default">1</property>
|
||||
<property name="use_action_appearance">0</property>
|
||||
<property name="rgba">#31316867a09f</property>
|
||||
<property name="use_alpha">1</property>
|
||||
</object>
|
||||
@ -1016,7 +1010,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="can_focus">1</property>
|
||||
<property name="receives_default">1</property>
|
||||
<property name="has_tooltip">1</property>
|
||||
<property name="use_action_appearance">0</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="uri">http://www.gtk.org</property>
|
||||
</object>
|
||||
|
226
gtk/gtkbutton.c
226
gtk/gtkbutton.c
@ -62,7 +62,6 @@
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtkbox.h"
|
||||
#include "deprecated/gtkactivatable.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
@ -100,10 +99,6 @@ enum {
|
||||
/* actionable properties */
|
||||
PROP_ACTION_NAME,
|
||||
PROP_ACTION_TARGET,
|
||||
|
||||
/* activatable properties */
|
||||
PROP_ACTIVATABLE_RELATED_ACTION,
|
||||
PROP_ACTIVATABLE_USE_ACTION_APPEARANCE,
|
||||
LAST_PROP = PROP_ACTION_NAME
|
||||
};
|
||||
|
||||
@ -150,16 +145,6 @@ static void gtk_button_do_release (GtkButton *button,
|
||||
gboolean emit_clicked);
|
||||
|
||||
static void gtk_button_actionable_iface_init (GtkActionableInterface *iface);
|
||||
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 void gtk_button_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum_size,
|
||||
@ -206,13 +191,9 @@ static gboolean gtk_button_render (GtkCssGadget *gadget,
|
||||
static GParamSpec *props[LAST_PROP] = { NULL, };
|
||||
static guint button_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkButton, gtk_button, GTK_TYPE_BIN,
|
||||
G_ADD_PRIVATE (GtkButton)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIONABLE, gtk_button_actionable_iface_init)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
|
||||
gtk_button_activatable_interface_init))
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIONABLE, gtk_button_actionable_iface_init))
|
||||
|
||||
static void
|
||||
gtk_button_class_init (GtkButtonClass *klass)
|
||||
@ -325,11 +306,6 @@ gtk_button_class_init (GtkButtonClass *klass)
|
||||
g_object_class_override_property (gobject_class, PROP_ACTION_NAME, "action-name");
|
||||
g_object_class_override_property (gobject_class, PROP_ACTION_TARGET, "action-target");
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
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");
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
/**
|
||||
* GtkButton::clicked:
|
||||
* @button: the object that received the signal
|
||||
@ -560,13 +536,6 @@ gtk_button_dispose (GObject *object)
|
||||
|
||||
g_clear_object (&priv->action_helper);
|
||||
|
||||
if (priv->action)
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (button), NULL);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
priv->action = NULL;
|
||||
}
|
||||
G_OBJECT_CLASS (gtk_button_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
@ -576,8 +545,6 @@ gtk_button_set_action_name (GtkActionable *actionable,
|
||||
{
|
||||
GtkButton *button = GTK_BUTTON (actionable);
|
||||
|
||||
g_return_if_fail (button->priv->action == NULL);
|
||||
|
||||
if (!button->priv->action_helper)
|
||||
button->priv->action_helper = gtk_action_helper_new (actionable);
|
||||
|
||||
@ -628,12 +595,6 @@ gtk_button_set_property (GObject *object,
|
||||
case PROP_IMAGE_POSITION:
|
||||
gtk_button_set_image_position (button, g_value_get_enum (value));
|
||||
break;
|
||||
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;
|
||||
case PROP_ACTION_NAME:
|
||||
gtk_button_set_action_name (GTK_ACTIONABLE (button), g_value_get_string (value));
|
||||
break;
|
||||
@ -675,12 +636,6 @@ gtk_button_get_property (GObject *object,
|
||||
case PROP_IMAGE_POSITION:
|
||||
g_value_set_enum (value, priv->image_position);
|
||||
break;
|
||||
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;
|
||||
case PROP_ACTION_NAME:
|
||||
g_value_set_string (value, gtk_action_helper_get_action_name (priv->action_helper));
|
||||
break;
|
||||
@ -718,182 +673,6 @@ gtk_button_actionable_iface_init (GtkActionableInterface *iface)
|
||||
iface->set_action_target_value = gtk_button_set_action_target_value;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_activatable_interface_init (GtkActivatableIface *iface)
|
||||
{
|
||||
iface->update = gtk_button_update;
|
||||
iface->sync_action_properties = gtk_button_sync_action_properties;
|
||||
}
|
||||
|
||||
static void
|
||||
activatable_update_short_label (GtkButton *button,
|
||||
GtkAction *action)
|
||||
{
|
||||
GtkWidget *child;
|
||||
GtkWidget *image;
|
||||
|
||||
image = gtk_button_get_image (button);
|
||||
|
||||
/* Dont touch custom child... */
|
||||
child = gtk_bin_get_child (GTK_BIN (button));
|
||||
if (GTK_IS_IMAGE (image) ||
|
||||
child == NULL ||
|
||||
GTK_IS_LABEL (child))
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
gtk_button_set_label (button, gtk_action_get_short_label (action));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
activatable_update_gicon (GtkButton *button,
|
||||
GtkAction *action)
|
||||
{
|
||||
GtkWidget *image = gtk_button_get_image (button);
|
||||
GIcon *icon;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
icon = gtk_action_get_gicon (action);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
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
|
||||
gtk_button_update (GtkActivatable *activatable,
|
||||
GtkAction *action,
|
||||
const gchar *property_name)
|
||||
{
|
||||
GtkButton *button = GTK_BUTTON (activatable);
|
||||
GtkButtonPrivate *priv = button->priv;
|
||||
|
||||
if (strcmp (property_name, "visible") == 0)
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
if (gtk_action_is_visible (action))
|
||||
gtk_widget_show (GTK_WIDGET (activatable));
|
||||
else
|
||||
gtk_widget_hide (GTK_WIDGET (activatable));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
}
|
||||
else if (strcmp (property_name, "sensitive") == 0)
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
}
|
||||
|
||||
if (!priv->use_action_appearance)
|
||||
return;
|
||||
|
||||
if (strcmp (property_name, "gicon") == 0)
|
||||
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);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_sync_action_properties (GtkActivatable *activatable,
|
||||
GtkAction *action)
|
||||
{
|
||||
GtkButton *button = GTK_BUTTON (activatable);
|
||||
GtkButtonPrivate *priv = button->priv;
|
||||
gboolean always_show_image;
|
||||
|
||||
if (!action)
|
||||
return;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
if (gtk_action_is_visible (action))
|
||||
gtk_widget_show (GTK_WIDGET (activatable));
|
||||
else
|
||||
gtk_widget_hide (GTK_WIDGET (activatable));
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
|
||||
always_show_image = gtk_action_get_always_show_image (action);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
gtk_button_set_always_show_image (button, always_show_image);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_set_related_action (GtkButton *button,
|
||||
GtkAction *action)
|
||||
{
|
||||
GtkButtonPrivate *priv = button->priv;
|
||||
|
||||
g_return_if_fail (gtk_action_helper_get_action_name (button->priv->action_helper) == NULL);
|
||||
|
||||
if (priv->action == action)
|
||||
return;
|
||||
|
||||
/* 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)
|
||||
g_signal_connect_after (button, "clicked",
|
||||
G_CALLBACK (gtk_real_button_clicked), NULL);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (button), action);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
priv->action = action;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_set_use_action_appearance (GtkButton *button,
|
||||
gboolean use_appearance)
|
||||
{
|
||||
GtkButtonPrivate *priv = button->priv;
|
||||
|
||||
if (priv->use_action_appearance != use_appearance)
|
||||
{
|
||||
priv->use_action_appearance = use_appearance;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (button), priv->action);
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_button_new:
|
||||
*
|
||||
@ -1391,9 +1170,6 @@ gtk_real_button_clicked (GtkButton *button)
|
||||
|
||||
if (priv->action_helper)
|
||||
gtk_action_helper_activate (priv->action_helper);
|
||||
|
||||
if (priv->action)
|
||||
gtk_action_activate (priv->action);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "gtkactionhelper.h"
|
||||
#include "gtkgesturesingle.h"
|
||||
#include "deprecated/gtkaction.h"
|
||||
#include "gtkcssgadgetprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -29,7 +28,6 @@ G_BEGIN_DECLS
|
||||
|
||||
struct _GtkButtonPrivate
|
||||
{
|
||||
GtkAction *action;
|
||||
GtkWidget *image;
|
||||
GtkActionHelper *action_helper;
|
||||
GtkCssGadget *gadget;
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "deprecated/gtktoggleaction.h"
|
||||
#include "deprecated/gtkactivatable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "a11y/gtktogglebuttonaccessible.h"
|
||||
@ -143,22 +142,10 @@ static void gtk_toggle_button_get_property (GObject *object,
|
||||
GParamSpec *pspec);
|
||||
|
||||
|
||||
static void gtk_toggle_button_activatable_interface_init (GtkActivatableIface *iface);
|
||||
static void gtk_toggle_button_update (GtkActivatable *activatable,
|
||||
GtkAction *action,
|
||||
const gchar *property_name);
|
||||
static void gtk_toggle_button_sync_action_properties (GtkActivatable *activatable,
|
||||
GtkAction *action);
|
||||
|
||||
static GtkActivatableIface *parent_activatable_iface;
|
||||
static guint toggle_button_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkToggleButton, gtk_toggle_button, GTK_TYPE_BUTTON,
|
||||
G_ADD_PRIVATE (GtkToggleButton)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
|
||||
gtk_toggle_button_activatable_interface_init))
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
G_ADD_PRIVATE (GtkToggleButton))
|
||||
|
||||
static void
|
||||
gtk_toggle_button_class_init (GtkToggleButtonClass *class)
|
||||
@ -236,60 +223,6 @@ gtk_toggle_button_init (GtkToggleButton *toggle_button)
|
||||
gtk_style_context_add_class (context, "toggle");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toggle_button_activatable_interface_init (GtkActivatableIface *iface)
|
||||
{
|
||||
parent_activatable_iface = g_type_interface_peek_parent (iface);
|
||||
iface->update = gtk_toggle_button_update;
|
||||
iface->sync_action_properties = gtk_toggle_button_sync_action_properties;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toggle_button_update (GtkActivatable *activatable,
|
||||
GtkAction *action,
|
||||
const gchar *property_name)
|
||||
{
|
||||
GtkToggleButton *button;
|
||||
|
||||
parent_activatable_iface->update (activatable, action, property_name);
|
||||
|
||||
button = GTK_TOGGLE_BUTTON (activatable);
|
||||
|
||||
if (strcmp (property_name, "active") == 0)
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
gtk_action_block_activate (action);
|
||||
gtk_toggle_button_set_active (button, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
|
||||
gtk_action_unblock_activate (action);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toggle_button_sync_action_properties (GtkActivatable *activatable,
|
||||
GtkAction *action)
|
||||
{
|
||||
GtkToggleButton *button;
|
||||
gboolean is_toggle_action;
|
||||
|
||||
parent_activatable_iface->sync_action_properties (activatable, action);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
is_toggle_action = GTK_IS_TOGGLE_ACTION (action);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
if (!is_toggle_action)
|
||||
return;
|
||||
|
||||
button = GTK_TOGGLE_BUTTON (activatable);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
gtk_action_block_activate (action);
|
||||
gtk_toggle_button_set_active (button, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
|
||||
gtk_action_unblock_activate (action);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_toggle_button_new:
|
||||
|
Loading…
Reference in New Issue
Block a user