mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 14:00:09 +00:00
gtkarrow: Move public members to private structure
This commit is contained in:
parent
fa740ae012
commit
3862bf3208
@ -52,6 +52,12 @@
|
|||||||
|
|
||||||
#define MIN_ARROW_SIZE 15
|
#define MIN_ARROW_SIZE 15
|
||||||
|
|
||||||
|
struct _GtkArrowPriv
|
||||||
|
{
|
||||||
|
gint16 arrow_type;
|
||||||
|
gint16 shadow_type;
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_ARROW_TYPE,
|
PROP_ARROW_TYPE,
|
||||||
@ -112,6 +118,8 @@ gtk_arrow_class_init (GtkArrowClass *class)
|
|||||||
P_("Amount of space used up by arrow"),
|
P_("Amount of space used up by arrow"),
|
||||||
0.0, 1.0, 0.7,
|
0.0, 1.0, 0.7,
|
||||||
GTK_PARAM_READABLE));
|
GTK_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_type_class_add_private (class, sizeof (GtkArrowPriv));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -121,17 +129,18 @@ gtk_arrow_set_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
GtkArrow *arrow = GTK_ARROW (object);
|
GtkArrow *arrow = GTK_ARROW (object);
|
||||||
|
GtkArrowPriv *priv = arrow->priv;
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_ARROW_TYPE:
|
case PROP_ARROW_TYPE:
|
||||||
gtk_arrow_set (arrow,
|
gtk_arrow_set (arrow,
|
||||||
g_value_get_enum (value),
|
g_value_get_enum (value),
|
||||||
arrow->shadow_type);
|
priv->shadow_type);
|
||||||
break;
|
break;
|
||||||
case PROP_SHADOW_TYPE:
|
case PROP_SHADOW_TYPE:
|
||||||
gtk_arrow_set (arrow,
|
gtk_arrow_set (arrow,
|
||||||
arrow->arrow_type,
|
priv->arrow_type,
|
||||||
g_value_get_enum (value));
|
g_value_get_enum (value));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -147,14 +156,15 @@ gtk_arrow_get_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
GtkArrow *arrow = GTK_ARROW (object);
|
GtkArrow *arrow = GTK_ARROW (object);
|
||||||
|
GtkArrowPriv *priv = arrow->priv;
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_ARROW_TYPE:
|
case PROP_ARROW_TYPE:
|
||||||
g_value_set_enum (value, arrow->arrow_type);
|
g_value_set_enum (value, priv->arrow_type);
|
||||||
break;
|
break;
|
||||||
case PROP_SHADOW_TYPE:
|
case PROP_SHADOW_TYPE:
|
||||||
g_value_set_enum (value, arrow->shadow_type);
|
g_value_set_enum (value, priv->shadow_type);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -165,13 +175,20 @@ gtk_arrow_get_property (GObject *object,
|
|||||||
static void
|
static void
|
||||||
gtk_arrow_init (GtkArrow *arrow)
|
gtk_arrow_init (GtkArrow *arrow)
|
||||||
{
|
{
|
||||||
|
GtkArrowPriv *priv;
|
||||||
|
|
||||||
|
arrow->priv = G_TYPE_INSTANCE_GET_PRIVATE (arrow,
|
||||||
|
GTK_TYPE_ARROW,
|
||||||
|
GtkArrowPriv);
|
||||||
|
priv = arrow->priv;
|
||||||
|
|
||||||
gtk_widget_set_has_window (GTK_WIDGET (arrow), FALSE);
|
gtk_widget_set_has_window (GTK_WIDGET (arrow), FALSE);
|
||||||
|
|
||||||
GTK_WIDGET (arrow)->requisition.width = MIN_ARROW_SIZE + GTK_MISC (arrow)->xpad * 2;
|
GTK_WIDGET (arrow)->requisition.width = MIN_ARROW_SIZE + GTK_MISC (arrow)->xpad * 2;
|
||||||
GTK_WIDGET (arrow)->requisition.height = MIN_ARROW_SIZE + GTK_MISC (arrow)->ypad * 2;
|
GTK_WIDGET (arrow)->requisition.height = MIN_ARROW_SIZE + GTK_MISC (arrow)->ypad * 2;
|
||||||
|
|
||||||
arrow->arrow_type = GTK_ARROW_RIGHT;
|
priv->arrow_type = GTK_ARROW_RIGHT;
|
||||||
arrow->shadow_type = GTK_SHADOW_OUT;
|
priv->shadow_type = GTK_SHADOW_OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,12 +204,15 @@ GtkWidget*
|
|||||||
gtk_arrow_new (GtkArrowType arrow_type,
|
gtk_arrow_new (GtkArrowType arrow_type,
|
||||||
GtkShadowType shadow_type)
|
GtkShadowType shadow_type)
|
||||||
{
|
{
|
||||||
|
GtkArrowPriv *priv;
|
||||||
GtkArrow *arrow;
|
GtkArrow *arrow;
|
||||||
|
|
||||||
arrow = g_object_new (GTK_TYPE_ARROW, NULL);
|
arrow = g_object_new (GTK_TYPE_ARROW, NULL);
|
||||||
|
|
||||||
arrow->arrow_type = arrow_type;
|
priv = arrow->priv;
|
||||||
arrow->shadow_type = shadow_type;
|
|
||||||
|
priv->arrow_type = arrow_type;
|
||||||
|
priv->shadow_type = shadow_type;
|
||||||
|
|
||||||
return GTK_WIDGET (arrow);
|
return GTK_WIDGET (arrow);
|
||||||
}
|
}
|
||||||
@ -210,24 +230,27 @@ gtk_arrow_set (GtkArrow *arrow,
|
|||||||
GtkArrowType arrow_type,
|
GtkArrowType arrow_type,
|
||||||
GtkShadowType shadow_type)
|
GtkShadowType shadow_type)
|
||||||
{
|
{
|
||||||
|
GtkArrowPriv *priv;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_ARROW (arrow));
|
g_return_if_fail (GTK_IS_ARROW (arrow));
|
||||||
|
|
||||||
if ( ((GtkArrowType) arrow->arrow_type != arrow_type)
|
priv = arrow->priv;
|
||||||
|| ((GtkShadowType) arrow->shadow_type != shadow_type))
|
|
||||||
|
if (priv->arrow_type != arrow_type
|
||||||
|
|| priv->shadow_type != shadow_type)
|
||||||
{
|
{
|
||||||
g_object_freeze_notify (G_OBJECT (arrow));
|
g_object_freeze_notify (G_OBJECT (arrow));
|
||||||
|
|
||||||
if ((GtkArrowType) arrow->arrow_type != arrow_type)
|
if ((GtkArrowType) priv->arrow_type != arrow_type)
|
||||||
{
|
{
|
||||||
arrow->arrow_type = arrow_type;
|
priv->arrow_type = arrow_type;
|
||||||
g_object_notify (G_OBJECT (arrow), "arrow-type");
|
g_object_notify (G_OBJECT (arrow), "arrow-type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((GtkShadowType) arrow->shadow_type != shadow_type)
|
if (priv->shadow_type != shadow_type)
|
||||||
{
|
{
|
||||||
arrow->shadow_type = shadow_type;
|
priv->shadow_type = shadow_type;
|
||||||
g_object_notify (G_OBJECT (arrow), "shadow-type");
|
g_object_notify (G_OBJECT (arrow), "shadow-type");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,6 +270,7 @@ gtk_arrow_expose (GtkWidget *widget,
|
|||||||
if (gtk_widget_is_drawable (widget))
|
if (gtk_widget_is_drawable (widget))
|
||||||
{
|
{
|
||||||
GtkArrow *arrow = GTK_ARROW (widget);
|
GtkArrow *arrow = GTK_ARROW (widget);
|
||||||
|
GtkArrowPriv *priv = arrow->priv;
|
||||||
GtkMisc *misc = GTK_MISC (widget);
|
GtkMisc *misc = GTK_MISC (widget);
|
||||||
GtkShadowType shadow_type;
|
GtkShadowType shadow_type;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
@ -261,16 +285,16 @@ gtk_arrow_expose (GtkWidget *widget,
|
|||||||
width = widget->allocation.width - misc->xpad * 2;
|
width = widget->allocation.width - misc->xpad * 2;
|
||||||
height = widget->allocation.height - misc->ypad * 2;
|
height = widget->allocation.height - misc->ypad * 2;
|
||||||
extent = MIN (width, height) * arrow_scaling;
|
extent = MIN (width, height) * arrow_scaling;
|
||||||
effective_arrow_type = arrow->arrow_type;
|
effective_arrow_type = priv->arrow_type;
|
||||||
|
|
||||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
||||||
xalign = misc->xalign;
|
xalign = misc->xalign;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xalign = 1.0 - misc->xalign;
|
xalign = 1.0 - misc->xalign;
|
||||||
if (arrow->arrow_type == GTK_ARROW_LEFT)
|
if (priv->arrow_type == GTK_ARROW_LEFT)
|
||||||
effective_arrow_type = GTK_ARROW_RIGHT;
|
effective_arrow_type = GTK_ARROW_RIGHT;
|
||||||
else if (arrow->arrow_type == GTK_ARROW_RIGHT)
|
else if (priv->arrow_type == GTK_ARROW_RIGHT)
|
||||||
effective_arrow_type = GTK_ARROW_LEFT;
|
effective_arrow_type = GTK_ARROW_LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +303,7 @@ gtk_arrow_expose (GtkWidget *widget,
|
|||||||
y = floor (widget->allocation.y + misc->ypad
|
y = floor (widget->allocation.y + misc->ypad
|
||||||
+ ((widget->allocation.height - extent) * misc->yalign));
|
+ ((widget->allocation.height - extent) * misc->yalign));
|
||||||
|
|
||||||
shadow_type = arrow->shadow_type;
|
shadow_type = priv->shadow_type;
|
||||||
|
|
||||||
if (widget->state == GTK_STATE_ACTIVE)
|
if (widget->state == GTK_STATE_ACTIVE)
|
||||||
{
|
{
|
||||||
|
@ -45,16 +45,16 @@ G_BEGIN_DECLS
|
|||||||
#define GTK_IS_ARROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ARROW))
|
#define GTK_IS_ARROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ARROW))
|
||||||
#define GTK_ARROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ARROW, GtkArrowClass))
|
#define GTK_ARROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ARROW, GtkArrowClass))
|
||||||
|
|
||||||
|
typedef struct _GtkArrow GtkArrow;
|
||||||
typedef struct _GtkArrow GtkArrow;
|
typedef struct _GtkArrowPriv GtkArrowPriv;
|
||||||
typedef struct _GtkArrowClass GtkArrowClass;
|
typedef struct _GtkArrowClass GtkArrowClass;
|
||||||
|
|
||||||
struct _GtkArrow
|
struct _GtkArrow
|
||||||
{
|
{
|
||||||
GtkMisc misc;
|
GtkMisc misc;
|
||||||
|
|
||||||
gint16 GSEAL (arrow_type);
|
/*< private >*/
|
||||||
gint16 GSEAL (shadow_type);
|
GtkArrowPriv *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkArrowClass
|
struct _GtkArrowClass
|
||||||
|
@ -234,21 +234,28 @@ gail_button_get_name (AtkObject *obj)
|
|||||||
static gboolean
|
static gboolean
|
||||||
gail_button_is_default_press (GtkWidget *widget)
|
gail_button_is_default_press (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
|
GtkArrowType arrow_type;
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
GtkWidget *parent;
|
GtkWidget *parent;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
const gchar *parent_type_name;
|
const gchar *parent_type_name;
|
||||||
|
|
||||||
child = GTK_BIN (widget)->child;
|
child = GTK_BIN (widget)->child;
|
||||||
if (GTK_IS_ARROW (child) &&
|
if (GTK_IS_ARROW (child))
|
||||||
GTK_ARROW (child)->arrow_type == GTK_ARROW_DOWN)
|
|
||||||
{
|
{
|
||||||
parent = gtk_widget_get_parent (widget);
|
g_object_get (child,
|
||||||
if (parent)
|
"arrow_type", &arrow_type,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (arrow_type == GTK_ARROW_DOWN)
|
||||||
{
|
{
|
||||||
parent_type_name = g_type_name (G_OBJECT_TYPE (parent));
|
parent = gtk_widget_get_parent (widget);
|
||||||
if (strcmp (parent_type_name, "ColorCombo"))
|
if (parent)
|
||||||
return TRUE;
|
{
|
||||||
|
parent_type_name = g_type_name (G_OBJECT_TYPE (parent));
|
||||||
|
if (g_strcmp0 (parent_type_name, "ColorCombo"))
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user