mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 14:00:09 +00:00
Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master See merge request GNOME/gtk!1579
This commit is contained in:
commit
2c7afc0556
File diff suppressed because it is too large
Load Diff
@ -91,21 +91,7 @@ enum {
|
||||
struct _GtkAccelLabel
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
};
|
||||
|
||||
struct _GtkAccelLabelClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
char *mod_name_shift;
|
||||
char *mod_name_control;
|
||||
char *mod_name_alt;
|
||||
char *mod_separator;
|
||||
};
|
||||
|
||||
typedef struct _GtkAccelLabelPrivate GtkAccelLabelPrivate;
|
||||
struct _GtkAccelLabelPrivate
|
||||
{
|
||||
GtkWidget *text_label;
|
||||
GtkWidget *accel_label;
|
||||
|
||||
@ -113,6 +99,11 @@ struct _GtkAccelLabelPrivate
|
||||
GdkModifierType accel_mods;
|
||||
};
|
||||
|
||||
struct _GtkAccelLabelClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
GParamSpec *props[LAST_PROP] = { NULL, };
|
||||
|
||||
static void gtk_accel_label_set_property (GObject *object,
|
||||
@ -125,7 +116,7 @@ static void gtk_accel_label_get_property (GObject *object,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_accel_label_finalize (GObject *object);
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_WIDGET)
|
||||
G_DEFINE_TYPE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
gtk_accel_label_class_init (GtkAccelLabelClass *class)
|
||||
@ -165,9 +156,7 @@ gtk_accel_label_set_property (GObject *object,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAccelLabel *accel_label;
|
||||
|
||||
accel_label = GTK_ACCEL_LABEL (object);
|
||||
GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -208,16 +197,14 @@ gtk_accel_label_get_property (GObject *object,
|
||||
static void
|
||||
gtk_accel_label_init (GtkAccelLabel *accel_label)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
priv->text_label = gtk_label_new ("");
|
||||
gtk_widget_set_hexpand (priv->text_label, TRUE);
|
||||
gtk_label_set_xalign (GTK_LABEL (priv->text_label), 0.0f);
|
||||
priv->accel_label = g_object_new (GTK_TYPE_LABEL,
|
||||
"css-name", "accelerator",
|
||||
NULL);
|
||||
gtk_widget_set_parent (priv->text_label, GTK_WIDGET (accel_label));
|
||||
gtk_widget_set_parent (priv->accel_label, GTK_WIDGET (accel_label));
|
||||
accel_label->text_label = gtk_label_new ("");
|
||||
gtk_widget_set_hexpand (accel_label->text_label, TRUE);
|
||||
gtk_label_set_xalign (GTK_LABEL (accel_label->text_label), 0.0f);
|
||||
accel_label->accel_label = g_object_new (GTK_TYPE_LABEL,
|
||||
"css-name", "accelerator",
|
||||
NULL);
|
||||
gtk_widget_set_parent (accel_label->text_label, GTK_WIDGET (accel_label));
|
||||
gtk_widget_set_parent (accel_label->accel_label, GTK_WIDGET (accel_label));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,25 +218,18 @@ gtk_accel_label_init (GtkAccelLabel *accel_label)
|
||||
GtkWidget *
|
||||
gtk_accel_label_new (const gchar *string)
|
||||
{
|
||||
GtkAccelLabel *accel_label;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
|
||||
accel_label = g_object_new (GTK_TYPE_ACCEL_LABEL,
|
||||
"label", string,
|
||||
NULL);
|
||||
|
||||
return GTK_WIDGET (accel_label);
|
||||
return g_object_new (GTK_TYPE_ACCEL_LABEL,
|
||||
"label", string,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_accel_label_finalize (GObject *object)
|
||||
{
|
||||
GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (object);
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
gtk_widget_unparent (priv->accel_label);
|
||||
gtk_widget_unparent (priv->text_label);
|
||||
gtk_widget_unparent (accel_label->accel_label);
|
||||
gtk_widget_unparent (accel_label->text_label);
|
||||
|
||||
G_OBJECT_CLASS (gtk_accel_label_parent_class)->finalize (object);
|
||||
}
|
||||
@ -267,12 +247,11 @@ gtk_accel_label_finalize (GObject *object)
|
||||
guint
|
||||
gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
int min;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ACCEL_LABEL (accel_label), 0);
|
||||
|
||||
gtk_widget_measure (priv->accel_label, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
gtk_widget_measure (accel_label->accel_label, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
&min, NULL, NULL, NULL);
|
||||
|
||||
return min;
|
||||
@ -291,7 +270,6 @@ gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label)
|
||||
gboolean
|
||||
gtk_accel_label_refetch (GtkAccelLabel *accel_label)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
gboolean enable_accels;
|
||||
char *accel_string = NULL;
|
||||
|
||||
@ -301,17 +279,17 @@ gtk_accel_label_refetch (GtkAccelLabel *accel_label)
|
||||
"gtk-enable-accels", &enable_accels,
|
||||
NULL);
|
||||
|
||||
if (enable_accels && priv->accel_key)
|
||||
if (enable_accels && accel_label->accel_key)
|
||||
{
|
||||
gboolean have_accel = FALSE;
|
||||
guint accel_key;
|
||||
GdkModifierType accel_mods;
|
||||
|
||||
/* First check for a manual accel set with _set_accel() */
|
||||
if (priv->accel_key)
|
||||
if (accel_label->accel_key)
|
||||
{
|
||||
accel_mods = priv->accel_mods;
|
||||
accel_key = priv->accel_key;
|
||||
accel_mods = accel_label->accel_mods;
|
||||
accel_key = accel_label->accel_key;
|
||||
have_accel = TRUE;
|
||||
}
|
||||
|
||||
@ -326,7 +304,7 @@ gtk_accel_label_refetch (GtkAccelLabel *accel_label)
|
||||
if (!accel_string)
|
||||
accel_string = g_strdup ("");
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (priv->accel_label), accel_string);
|
||||
gtk_label_set_label (GTK_LABEL (accel_label->accel_label), accel_string);
|
||||
|
||||
g_free (accel_string);
|
||||
|
||||
@ -352,12 +330,10 @@ gtk_accel_label_set_accel (GtkAccelLabel *accel_label,
|
||||
guint accelerator_key,
|
||||
GdkModifierType accelerator_mods)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCEL_LABEL (accel_label));
|
||||
|
||||
priv->accel_key = accelerator_key;
|
||||
priv->accel_mods = accelerator_mods;
|
||||
accel_label->accel_key = accelerator_key;
|
||||
accel_label->accel_mods = accelerator_mods;
|
||||
|
||||
gtk_accel_label_refetch (accel_label);
|
||||
}
|
||||
@ -376,12 +352,10 @@ gtk_accel_label_get_accel (GtkAccelLabel *accel_label,
|
||||
guint *accelerator_key,
|
||||
GdkModifierType *accelerator_mods)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCEL_LABEL (accel_label));
|
||||
|
||||
*accelerator_key = priv->accel_key;
|
||||
*accelerator_mods = priv->accel_mods;
|
||||
*accelerator_key = accel_label->accel_key;
|
||||
*accelerator_mods = accel_label->accel_mods;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -396,11 +370,9 @@ void
|
||||
gtk_accel_label_set_label (GtkAccelLabel *accel_label,
|
||||
const char *text)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCEL_LABEL (accel_label));
|
||||
|
||||
gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->text_label), text);
|
||||
gtk_label_set_text_with_mnemonic (GTK_LABEL (accel_label->text_label), text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -415,11 +387,9 @@ gtk_accel_label_set_label (GtkAccelLabel *accel_label,
|
||||
const char *
|
||||
gtk_accel_label_get_label (GtkAccelLabel *accel_label)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ACCEL_LABEL (accel_label), NULL);
|
||||
|
||||
return gtk_label_get_label (GTK_LABEL (priv->text_label));
|
||||
return gtk_label_get_label (GTK_LABEL (accel_label->text_label));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -434,18 +404,13 @@ void
|
||||
gtk_accel_label_set_use_underline (GtkAccelLabel *accel_label,
|
||||
gboolean setting)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCEL_LABEL (accel_label));
|
||||
|
||||
setting = !!setting;
|
||||
if (setting == gtk_label_get_use_underline (GTK_LABEL (accel_label->text_label)))
|
||||
return;
|
||||
|
||||
if (setting != gtk_label_get_use_underline (GTK_LABEL (priv->text_label)))
|
||||
{
|
||||
gtk_label_set_use_underline (GTK_LABEL (priv->text_label), setting);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (accel_label), props[PROP_USE_UNDERLINE]);
|
||||
}
|
||||
gtk_label_set_use_underline (GTK_LABEL (accel_label->text_label), setting);
|
||||
g_object_notify_by_pspec (G_OBJECT (accel_label), props[PROP_USE_UNDERLINE]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -461,9 +426,7 @@ gtk_accel_label_set_use_underline (GtkAccelLabel *accel_label,
|
||||
gboolean
|
||||
gtk_accel_label_get_use_underline (GtkAccelLabel *accel_label)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ACCEL_LABEL (accel_label), FALSE);
|
||||
|
||||
return gtk_label_get_use_underline (GTK_LABEL (priv->text_label));
|
||||
return gtk_label_get_use_underline (GTK_LABEL (accel_label->text_label));
|
||||
}
|
||||
|
@ -54,12 +54,16 @@
|
||||
* GtkActionBar has a single CSS node with name actionbar.
|
||||
*/
|
||||
|
||||
typedef struct _GtkActionBarPrivate GtkActionBarPrivate;
|
||||
typedef struct _GtkActionBarClass GtkActionBarClass;
|
||||
|
||||
struct _GtkActionBar
|
||||
{
|
||||
GtkContainer container;
|
||||
|
||||
GtkWidget *center_box;
|
||||
GtkWidget *start_box;
|
||||
GtkWidget *end_box;
|
||||
GtkWidget *revealer;
|
||||
};
|
||||
|
||||
struct _GtkActionBarClass
|
||||
@ -67,14 +71,6 @@ struct _GtkActionBarClass
|
||||
GtkContainerClass parent_class;
|
||||
};
|
||||
|
||||
struct _GtkActionBarPrivate
|
||||
{
|
||||
GtkWidget *center_box;
|
||||
GtkWidget *start_box;
|
||||
GtkWidget *end_box;
|
||||
GtkWidget *revealer;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_REVEALED,
|
||||
@ -85,7 +81,6 @@ static GParamSpec *props[LAST_PROP] = { NULL, };
|
||||
static void gtk_action_bar_buildable_interface_init (GtkBuildableIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkActionBar, gtk_action_bar, GTK_TYPE_CONTAINER,
|
||||
G_ADD_PRIVATE (GtkActionBar)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
||||
gtk_action_bar_buildable_interface_init))
|
||||
|
||||
@ -93,24 +88,24 @@ static void
|
||||
gtk_action_bar_add (GtkContainer *container,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container));
|
||||
GtkActionBar *self = GTK_ACTION_BAR (container);
|
||||
|
||||
/* Default for pack-type is start */
|
||||
gtk_container_add (GTK_CONTAINER (priv->start_box), child);
|
||||
gtk_container_add (GTK_CONTAINER (self->start_box), child);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_action_bar_remove (GtkContainer *container,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container));
|
||||
GtkActionBar *self = GTK_ACTION_BAR (container);
|
||||
|
||||
if (gtk_widget_get_parent (child) == priv->start_box)
|
||||
gtk_container_remove (GTK_CONTAINER (priv->start_box), child);
|
||||
else if (gtk_widget_get_parent (child) == priv->end_box)
|
||||
gtk_container_remove (GTK_CONTAINER (priv->end_box), child);
|
||||
else if (child == gtk_center_box_get_center_widget (GTK_CENTER_BOX (priv->center_box)))
|
||||
gtk_center_box_set_center_widget (GTK_CENTER_BOX (priv->center_box), NULL);
|
||||
if (gtk_widget_get_parent (child) == self->start_box)
|
||||
gtk_container_remove (GTK_CONTAINER (self->start_box), child);
|
||||
else if (gtk_widget_get_parent (child) == self->end_box)
|
||||
gtk_container_remove (GTK_CONTAINER (self->end_box), child);
|
||||
else if (child == gtk_center_box_get_center_widget (GTK_CENTER_BOX (self->center_box)))
|
||||
gtk_center_box_set_center_widget (GTK_CENTER_BOX (self->center_box), NULL);
|
||||
else
|
||||
g_warning ("Can't remove non-child %s %p from GtkActionBar %p",
|
||||
G_OBJECT_TYPE_NAME (child), child, container);
|
||||
@ -121,24 +116,24 @@ gtk_action_bar_forall (GtkContainer *container,
|
||||
GtkCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container));
|
||||
GtkActionBar *self = GTK_ACTION_BAR (container);
|
||||
|
||||
if (priv->start_box != NULL)
|
||||
gtk_container_forall (GTK_CONTAINER (priv->start_box), callback, callback_data);
|
||||
if (self->start_box != NULL)
|
||||
gtk_container_forall (GTK_CONTAINER (self->start_box), callback, callback_data);
|
||||
|
||||
if (gtk_center_box_get_center_widget (GTK_CENTER_BOX (priv->center_box)) != NULL)
|
||||
(*callback) (gtk_center_box_get_center_widget (GTK_CENTER_BOX (priv->center_box)), callback_data);
|
||||
if (gtk_center_box_get_center_widget (GTK_CENTER_BOX (self->center_box)) != NULL)
|
||||
(*callback) (gtk_center_box_get_center_widget (GTK_CENTER_BOX (self->center_box)), callback_data);
|
||||
|
||||
if (priv->end_box != NULL)
|
||||
gtk_container_forall (GTK_CONTAINER (priv->end_box), callback, callback_data);
|
||||
if (self->end_box != NULL)
|
||||
gtk_container_forall (GTK_CONTAINER (self->end_box), callback, callback_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_action_bar_finalize (GObject *object)
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (object));
|
||||
GtkActionBar *self = GTK_ACTION_BAR (object);
|
||||
|
||||
gtk_widget_unparent (priv->revealer);
|
||||
gtk_widget_unparent (self->revealer);
|
||||
G_OBJECT_CLASS (gtk_action_bar_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@ -154,12 +149,12 @@ gtk_action_bar_set_property (GObject *object,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkActionBar *action_bar = GTK_ACTION_BAR (object);
|
||||
GtkActionBar *self = GTK_ACTION_BAR (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_REVEALED:
|
||||
gtk_action_bar_set_revealed (action_bar, g_value_get_boolean (value));
|
||||
gtk_action_bar_set_revealed (self, g_value_get_boolean (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -173,12 +168,12 @@ gtk_action_bar_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkActionBar *action_bar = GTK_ACTION_BAR (object);
|
||||
GtkActionBar *self = GTK_ACTION_BAR (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_REVEALED:
|
||||
g_value_set_boolean (value, gtk_action_bar_get_revealed (action_bar));
|
||||
g_value_set_boolean (value, gtk_action_bar_get_revealed (self));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -190,14 +185,13 @@ static void
|
||||
gtk_action_bar_destroy (GtkWidget *widget)
|
||||
{
|
||||
GtkActionBar *self = GTK_ACTION_BAR (widget);
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (self);
|
||||
|
||||
gtk_center_box_set_start_widget (GTK_CENTER_BOX (priv->center_box), NULL);
|
||||
gtk_center_box_set_center_widget (GTK_CENTER_BOX (priv->center_box), NULL);
|
||||
gtk_center_box_set_end_widget (GTK_CENTER_BOX (priv->center_box), NULL);
|
||||
gtk_center_box_set_start_widget (GTK_CENTER_BOX (self->center_box), NULL);
|
||||
gtk_center_box_set_center_widget (GTK_CENTER_BOX (self->center_box), NULL);
|
||||
gtk_center_box_set_end_widget (GTK_CENTER_BOX (self->center_box), NULL);
|
||||
|
||||
priv->start_box = NULL;
|
||||
priv->end_box = NULL;
|
||||
self->start_box = NULL;
|
||||
self->end_box = NULL;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_action_bar_parent_class)->destroy (widget);
|
||||
}
|
||||
@ -239,25 +233,24 @@ gtk_action_bar_class_init (GtkActionBarClass *klass)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_action_bar_init (GtkActionBar *action_bar)
|
||||
gtk_action_bar_init (GtkActionBar *self)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (action_bar);
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
||||
GtkWidget *widget = GTK_WIDGET (self);
|
||||
|
||||
priv->revealer = gtk_revealer_new ();
|
||||
gtk_widget_set_parent (priv->revealer, widget);
|
||||
self->revealer = gtk_revealer_new ();
|
||||
gtk_widget_set_parent (self->revealer, widget);
|
||||
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), TRUE);
|
||||
gtk_revealer_set_transition_type (GTK_REVEALER (priv->revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), TRUE);
|
||||
gtk_revealer_set_transition_type (GTK_REVEALER (self->revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
|
||||
|
||||
priv->start_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
priv->end_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
self->start_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
self->end_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
|
||||
priv->center_box = gtk_center_box_new ();
|
||||
gtk_center_box_set_start_widget (GTK_CENTER_BOX (priv->center_box), priv->start_box);
|
||||
gtk_center_box_set_end_widget (GTK_CENTER_BOX (priv->center_box), priv->end_box);
|
||||
self->center_box = gtk_center_box_new ();
|
||||
gtk_center_box_set_start_widget (GTK_CENTER_BOX (self->center_box), self->start_box);
|
||||
gtk_center_box_set_end_widget (GTK_CENTER_BOX (self->center_box), self->end_box);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (priv->revealer), priv->center_box);
|
||||
gtk_container_add (GTK_CONTAINER (self->revealer), self->center_box);
|
||||
}
|
||||
|
||||
static GtkBuildableIface *parent_buildable_iface;
|
||||
@ -268,14 +261,14 @@ gtk_action_bar_buildable_add_child (GtkBuildable *buildable,
|
||||
GObject *child,
|
||||
const gchar *type)
|
||||
{
|
||||
GtkActionBar *action_bar = GTK_ACTION_BAR (buildable);
|
||||
GtkActionBar *self = GTK_ACTION_BAR (buildable);
|
||||
|
||||
if (g_strcmp0 (type, "center") == 0)
|
||||
gtk_action_bar_set_center_widget (action_bar, GTK_WIDGET (child));
|
||||
gtk_action_bar_set_center_widget (self, GTK_WIDGET (child));
|
||||
else if (g_strcmp0 (type, "start") == 0)
|
||||
gtk_action_bar_pack_start (action_bar, GTK_WIDGET (child));
|
||||
gtk_action_bar_pack_start (self, GTK_WIDGET (child));
|
||||
else if (g_strcmp0 (type, "end") == 0)
|
||||
gtk_action_bar_pack_end (action_bar, GTK_WIDGET (child));
|
||||
gtk_action_bar_pack_end (self, GTK_WIDGET (child));
|
||||
else
|
||||
parent_buildable_iface->add_child (buildable, builder, child, type);
|
||||
}
|
||||
@ -299,9 +292,7 @@ void
|
||||
gtk_action_bar_pack_start (GtkActionBar *action_bar,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (priv->start_box), child);
|
||||
gtk_container_add (GTK_CONTAINER (action_bar->start_box), child);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,9 +307,7 @@ void
|
||||
gtk_action_bar_pack_end (GtkActionBar *action_bar,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
||||
|
||||
gtk_box_insert_child_after (GTK_BOX (priv->end_box), child, NULL);
|
||||
gtk_box_insert_child_after (GTK_BOX (action_bar->end_box), child, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -332,9 +321,7 @@ void
|
||||
gtk_action_bar_set_center_widget (GtkActionBar *action_bar,
|
||||
GtkWidget *center_widget)
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
||||
|
||||
gtk_center_box_set_center_widget (GTK_CENTER_BOX (priv->center_box), center_widget);
|
||||
gtk_center_box_set_center_widget (GTK_CENTER_BOX (action_bar->center_box), center_widget);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -348,11 +335,9 @@ gtk_action_bar_set_center_widget (GtkActionBar *action_bar,
|
||||
GtkWidget *
|
||||
gtk_action_bar_get_center_widget (GtkActionBar *action_bar)
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ACTION_BAR (action_bar), NULL);
|
||||
|
||||
return gtk_center_box_get_center_widget (GTK_CENTER_BOX (priv->center_box));
|
||||
return gtk_center_box_get_center_widget (GTK_CENTER_BOX (action_bar->center_box));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -384,16 +369,13 @@ void
|
||||
gtk_action_bar_set_revealed (GtkActionBar *action_bar,
|
||||
gboolean revealed)
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
||||
|
||||
g_return_if_fail (GTK_IS_ACTION_BAR (action_bar));
|
||||
|
||||
revealed = !!revealed;
|
||||
if (revealed != gtk_revealer_get_reveal_child (GTK_REVEALER (priv->revealer)))
|
||||
{
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), revealed);
|
||||
g_object_notify_by_pspec (G_OBJECT (action_bar), props[PROP_REVEALED]);
|
||||
}
|
||||
if (revealed == gtk_revealer_get_reveal_child (GTK_REVEALER (action_bar->revealer)))
|
||||
return;
|
||||
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (action_bar->revealer), revealed);
|
||||
g_object_notify_by_pspec (G_OBJECT (action_bar), props[PROP_REVEALED]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -407,9 +389,7 @@ gtk_action_bar_set_revealed (GtkActionBar *action_bar,
|
||||
gboolean
|
||||
gtk_action_bar_get_revealed (GtkActionBar *action_bar)
|
||||
{
|
||||
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ACTION_BAR (action_bar), FALSE);
|
||||
|
||||
return gtk_revealer_get_reveal_child (GTK_REVEALER (priv->revealer));
|
||||
return gtk_revealer_get_reveal_child (GTK_REVEALER (action_bar->revealer));
|
||||
}
|
||||
|
@ -62,17 +62,10 @@
|
||||
#include <gio/gio.h>
|
||||
|
||||
typedef struct _GtkAppChooserDialogClass GtkAppChooserDialogClass;
|
||||
typedef struct _GtkAppChooserDialogPrivate GtkAppChooserDialogPrivate;
|
||||
|
||||
struct _GtkAppChooserDialog {
|
||||
GtkDialog parent;
|
||||
};
|
||||
|
||||
struct _GtkAppChooserDialogClass {
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
struct _GtkAppChooserDialogPrivate {
|
||||
char *content_type;
|
||||
GFile *gfile;
|
||||
char *heading;
|
||||
@ -94,6 +87,10 @@ struct _GtkAppChooserDialogPrivate {
|
||||
gboolean dismissed;
|
||||
};
|
||||
|
||||
struct _GtkAppChooserDialogClass {
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_GFILE = 1,
|
||||
PROP_CONTENT_TYPE,
|
||||
@ -102,7 +99,6 @@ enum {
|
||||
|
||||
static void gtk_app_chooser_dialog_iface_init (GtkAppChooserIface *iface);
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkAppChooserDialog, gtk_app_chooser_dialog, GTK_TYPE_DIALOG,
|
||||
G_ADD_PRIVATE (GtkAppChooserDialog)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER,
|
||||
gtk_app_chooser_dialog_iface_init));
|
||||
|
||||
@ -110,7 +106,6 @@ G_DEFINE_TYPE_WITH_CODE (GtkAppChooserDialog, gtk_app_chooser_dialog, GTK_TYPE_D
|
||||
static void
|
||||
add_or_find_application (GtkAppChooserDialog *self)
|
||||
{
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
GAppInfo *app;
|
||||
|
||||
app = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self));
|
||||
@ -118,9 +113,9 @@ add_or_find_application (GtkAppChooserDialog *self)
|
||||
if (app)
|
||||
{
|
||||
/* we don't care about reporting errors here */
|
||||
if (priv->content_type)
|
||||
if (self->content_type)
|
||||
g_app_info_set_as_last_used_for_type (app,
|
||||
priv->content_type,
|
||||
self->content_type,
|
||||
NULL);
|
||||
g_object_unref (app);
|
||||
}
|
||||
@ -132,7 +127,6 @@ gtk_app_chooser_dialog_response (GtkDialog *dialog,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (dialog);
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
|
||||
switch (response_id)
|
||||
{
|
||||
@ -141,7 +135,7 @@ gtk_app_chooser_dialog_response (GtkDialog *dialog,
|
||||
break;
|
||||
case GTK_RESPONSE_CANCEL:
|
||||
case GTK_RESPONSE_DELETE_EVENT:
|
||||
priv->dismissed = TRUE;
|
||||
self->dismissed = TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -153,9 +147,7 @@ widget_application_selected_cb (GtkAppChooserWidget *widget,
|
||||
GAppInfo *app_info,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkDialog *self = user_data;
|
||||
|
||||
gtk_dialog_set_response_sensitive (self, GTK_RESPONSE_OK, TRUE);
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (user_data), GTK_RESPONSE_OK, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -163,9 +155,7 @@ widget_application_activated_cb (GtkAppChooserWidget *widget,
|
||||
GAppInfo *app_info,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserDialog *self = user_data;
|
||||
|
||||
gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_OK);
|
||||
gtk_dialog_response (GTK_DIALOG (user_data), GTK_RESPONSE_OK);
|
||||
}
|
||||
|
||||
static char *
|
||||
@ -184,7 +174,6 @@ get_extension (const char *basename)
|
||||
static void
|
||||
set_dialog_properties (GtkAppChooserDialog *self)
|
||||
{
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
gchar *name;
|
||||
gchar *extension;
|
||||
gchar *description;
|
||||
@ -200,16 +189,16 @@ set_dialog_properties (GtkAppChooserDialog *self)
|
||||
description = NULL;
|
||||
unknown = TRUE;
|
||||
|
||||
if (priv->gfile != NULL)
|
||||
if (self->gfile != NULL)
|
||||
{
|
||||
name = g_file_get_basename (priv->gfile);
|
||||
name = g_file_get_basename (self->gfile);
|
||||
extension = get_extension (name);
|
||||
}
|
||||
|
||||
if (priv->content_type)
|
||||
if (self->content_type)
|
||||
{
|
||||
description = g_content_type_get_description (priv->content_type);
|
||||
unknown = g_content_type_is_unknown (priv->content_type);
|
||||
description = g_content_type_get_description (self->content_type);
|
||||
unknown = g_content_type_is_unknown (self->content_type);
|
||||
}
|
||||
|
||||
if (name != NULL)
|
||||
@ -224,9 +213,9 @@ set_dialog_properties (GtkAppChooserDialog *self)
|
||||
title = g_strdup (_("Select Application"));
|
||||
/* Translators: %s is a file type description */
|
||||
subtitle = g_strdup_printf (_("Opening “%s” files."),
|
||||
unknown ? priv->content_type : description);
|
||||
unknown ? self->content_type : description);
|
||||
string = g_strdup_printf (_("No applications found for “%s” files"),
|
||||
unknown ? priv->content_type : description);
|
||||
unknown ? self->content_type : description);
|
||||
}
|
||||
|
||||
g_object_get (self, "use-header-bar", &use_header, NULL);
|
||||
@ -241,17 +230,17 @@ set_dialog_properties (GtkAppChooserDialog *self)
|
||||
gtk_window_set_title (GTK_WINDOW (self), _("Select Application"));
|
||||
}
|
||||
|
||||
if (priv->heading != NULL)
|
||||
if (self->heading != NULL)
|
||||
{
|
||||
gtk_label_set_markup (GTK_LABEL (priv->label), priv->heading);
|
||||
gtk_widget_show (priv->label);
|
||||
gtk_label_set_markup (GTK_LABEL (self->label), self->heading);
|
||||
gtk_widget_show (self->label);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (priv->label);
|
||||
gtk_widget_hide (self->label);
|
||||
}
|
||||
|
||||
gtk_app_chooser_widget_set_default_text (GTK_APP_CHOOSER_WIDGET (priv->app_chooser_widget),
|
||||
gtk_app_chooser_widget_set_default_text (GTK_APP_CHOOSER_WIDGET (self->app_chooser_widget),
|
||||
string);
|
||||
|
||||
g_free (title);
|
||||
@ -267,16 +256,15 @@ show_more_button_clicked_cb (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserDialog *self = user_data;
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
|
||||
g_object_set (priv->app_chooser_widget,
|
||||
g_object_set (self->app_chooser_widget,
|
||||
"show-recommended", TRUE,
|
||||
"show-fallback", TRUE,
|
||||
"show-other", TRUE,
|
||||
NULL);
|
||||
|
||||
gtk_widget_hide (priv->show_more_button);
|
||||
priv->show_more_clicked = TRUE;
|
||||
gtk_widget_hide (self->show_more_button);
|
||||
self->show_more_clicked = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -285,51 +273,49 @@ widget_notify_for_button_cb (GObject *source,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserDialog *self = user_data;
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
GtkAppChooserWidget *widget = GTK_APP_CHOOSER_WIDGET (source);
|
||||
gboolean should_hide;
|
||||
|
||||
should_hide = gtk_app_chooser_widget_get_show_other (widget) ||
|
||||
priv->show_more_clicked;
|
||||
self->show_more_clicked;
|
||||
|
||||
if (should_hide)
|
||||
gtk_widget_hide (priv->show_more_button);
|
||||
gtk_widget_hide (self->show_more_button);
|
||||
}
|
||||
|
||||
static void
|
||||
construct_appchooser_widget (GtkAppChooserDialog *self)
|
||||
{
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
GAppInfo *info;
|
||||
|
||||
/* Need to build the appchooser widget after, because of the content-type construct-only property */
|
||||
priv->app_chooser_widget = gtk_app_chooser_widget_new (priv->content_type);
|
||||
gtk_widget_set_vexpand (priv->app_chooser_widget, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (priv->inner_box), priv->app_chooser_widget);
|
||||
self->app_chooser_widget = gtk_app_chooser_widget_new (self->content_type);
|
||||
gtk_widget_set_vexpand (self->app_chooser_widget, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (self->inner_box), self->app_chooser_widget);
|
||||
|
||||
g_signal_connect (priv->app_chooser_widget, "application-selected",
|
||||
g_signal_connect (self->app_chooser_widget, "application-selected",
|
||||
G_CALLBACK (widget_application_selected_cb), self);
|
||||
g_signal_connect (priv->app_chooser_widget, "application-activated",
|
||||
g_signal_connect (self->app_chooser_widget, "application-activated",
|
||||
G_CALLBACK (widget_application_activated_cb), self);
|
||||
g_signal_connect (priv->app_chooser_widget, "notify::show-other",
|
||||
g_signal_connect (self->app_chooser_widget, "notify::show-other",
|
||||
G_CALLBACK (widget_notify_for_button_cb), self);
|
||||
|
||||
/* Add the custom button to the new appchooser */
|
||||
gtk_container_add (GTK_CONTAINER (priv->inner_box),
|
||||
priv->show_more_button);
|
||||
gtk_container_add (GTK_CONTAINER (self->inner_box),
|
||||
self->show_more_button);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (priv->inner_box),
|
||||
priv->software_button);
|
||||
gtk_container_add (GTK_CONTAINER (self->inner_box),
|
||||
self->software_button);
|
||||
|
||||
info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (priv->app_chooser_widget));
|
||||
info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->app_chooser_widget));
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, info != NULL);
|
||||
if (info)
|
||||
g_object_unref (info);
|
||||
|
||||
_gtk_app_chooser_widget_set_search_entry (GTK_APP_CHOOSER_WIDGET (priv->app_chooser_widget),
|
||||
GTK_EDITABLE (priv->search_entry));
|
||||
_gtk_app_chooser_widget_set_search_entry (GTK_APP_CHOOSER_WIDGET (self->app_chooser_widget),
|
||||
GTK_EDITABLE (self->search_entry));
|
||||
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (priv->search_bar),
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (self->search_bar),
|
||||
GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
@ -337,18 +323,17 @@ static void
|
||||
set_gfile_and_content_type (GtkAppChooserDialog *self,
|
||||
GFile *file)
|
||||
{
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
GFileInfo *info;
|
||||
|
||||
if (file == NULL)
|
||||
return;
|
||||
|
||||
priv->gfile = g_object_ref (file);
|
||||
self->gfile = g_object_ref (file);
|
||||
|
||||
info = g_file_query_info (priv->gfile,
|
||||
info = g_file_query_info (self->gfile,
|
||||
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
|
||||
0, NULL, NULL);
|
||||
priv->content_type = g_strdup (g_file_info_get_content_type (info));
|
||||
self->content_type = g_strdup (g_file_info_get_content_type (info));
|
||||
|
||||
g_object_unref (info);
|
||||
}
|
||||
@ -357,18 +342,16 @@ static GAppInfo *
|
||||
gtk_app_chooser_dialog_get_app_info (GtkAppChooser *object)
|
||||
{
|
||||
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
|
||||
return gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (priv->app_chooser_widget));
|
||||
return gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->app_chooser_widget));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_app_chooser_dialog_refresh (GtkAppChooser *object)
|
||||
{
|
||||
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
|
||||
gtk_app_chooser_refresh (GTK_APP_CHOOSER (priv->app_chooser_widget));
|
||||
gtk_app_chooser_refresh (GTK_APP_CHOOSER (self->app_chooser_widget));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -398,13 +381,12 @@ static void
|
||||
software_button_clicked_cb (GtkButton *button,
|
||||
GtkAppChooserDialog *self)
|
||||
{
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
GSubprocess *process;
|
||||
GError *error = NULL;
|
||||
gchar *option;
|
||||
|
||||
if (priv->content_type)
|
||||
option = g_strconcat ("--search=", priv->content_type, NULL);
|
||||
if (self->content_type)
|
||||
option = g_strconcat ("--search=", self->content_type, NULL);
|
||||
else
|
||||
option = g_strdup ("--mode=overview");
|
||||
|
||||
@ -424,14 +406,13 @@ software_button_clicked_cb (GtkButton *button,
|
||||
static void
|
||||
ensure_software_button (GtkAppChooserDialog *self)
|
||||
{
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
gchar *path;
|
||||
|
||||
path = g_find_program_in_path ("gnome-software");
|
||||
if (path != NULL)
|
||||
gtk_widget_show (priv->software_button);
|
||||
gtk_widget_show (self->software_button);
|
||||
else
|
||||
gtk_widget_hide (priv->software_button);
|
||||
gtk_widget_hide (self->software_button);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
@ -439,7 +420,6 @@ ensure_software_button (GtkAppChooserDialog *self)
|
||||
static void
|
||||
setup_search (GtkAppChooserDialog *self)
|
||||
{
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
gboolean use_header;
|
||||
|
||||
g_object_get (self, "use-header-bar", &use_header, NULL);
|
||||
@ -458,12 +438,12 @@ setup_search (GtkAppChooserDialog *self)
|
||||
|
||||
header = gtk_dialog_get_header_bar (GTK_DIALOG (self));
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
gtk_size_group_add_widget (priv->buttons, button);
|
||||
gtk_size_group_add_widget (self->buttons, button);
|
||||
|
||||
g_object_bind_property (button, "active",
|
||||
priv->search_bar, "search-mode-enabled",
|
||||
self->search_bar, "search-mode-enabled",
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
g_object_bind_property (priv->search_entry, "sensitive",
|
||||
g_object_bind_property (self->search_entry, "sensitive",
|
||||
button, "sensitive",
|
||||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
}
|
||||
@ -487,11 +467,10 @@ static void
|
||||
gtk_app_chooser_dialog_dispose (GObject *object)
|
||||
{
|
||||
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
|
||||
g_clear_object (&priv->gfile);
|
||||
g_clear_object (&self->gfile);
|
||||
|
||||
priv->dismissed = TRUE;
|
||||
self->dismissed = TRUE;
|
||||
|
||||
G_OBJECT_CLASS (gtk_app_chooser_dialog_parent_class)->dispose (object);
|
||||
}
|
||||
@ -500,10 +479,9 @@ static void
|
||||
gtk_app_chooser_dialog_finalize (GObject *object)
|
||||
{
|
||||
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
|
||||
g_free (priv->content_type);
|
||||
g_free (priv->heading);
|
||||
g_free (self->content_type);
|
||||
g_free (self->heading);
|
||||
|
||||
G_OBJECT_CLASS (gtk_app_chooser_dialog_parent_class)->finalize (object);
|
||||
}
|
||||
@ -515,7 +493,6 @@ gtk_app_chooser_dialog_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
@ -524,8 +501,8 @@ gtk_app_chooser_dialog_set_property (GObject *object,
|
||||
break;
|
||||
case PROP_CONTENT_TYPE:
|
||||
/* don't try to override a value previously set with the GFile */
|
||||
if (priv->content_type == NULL)
|
||||
priv->content_type = g_value_dup_string (value);
|
||||
if (self->content_type == NULL)
|
||||
self->content_type = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_HEADING:
|
||||
gtk_app_chooser_dialog_set_heading (self, g_value_get_string (value));
|
||||
@ -543,19 +520,18 @@ gtk_app_chooser_dialog_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GFILE:
|
||||
if (priv->gfile != NULL)
|
||||
g_value_set_object (value, priv->gfile);
|
||||
if (self->gfile != NULL)
|
||||
g_value_set_object (value, self->gfile);
|
||||
break;
|
||||
case PROP_CONTENT_TYPE:
|
||||
g_value_set_string (value, priv->content_type);
|
||||
g_value_set_string (value, self->content_type);
|
||||
break;
|
||||
case PROP_HEADING:
|
||||
g_value_set_string (value, priv->heading);
|
||||
g_value_set_string (value, self->heading);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
@ -621,13 +597,13 @@ gtk_app_chooser_dialog_class_init (GtkAppChooserDialogClass *klass)
|
||||
*/
|
||||
gtk_widget_class_set_template_from_resource (widget_class,
|
||||
"/org/gtk/libgtk/ui/gtkappchooserdialog.ui");
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserDialog, label);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserDialog, show_more_button);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserDialog, software_button);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserDialog, inner_box);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserDialog, search_bar);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserDialog, search_entry);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserDialog, buttons);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserDialog, label);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserDialog, show_more_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserDialog, software_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserDialog, inner_box);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserDialog, search_bar);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkAppChooserDialog, search_entry);
|
||||
gtk_widget_class_bind_template_child(widget_class, GtkAppChooserDialog, buttons);
|
||||
gtk_widget_class_bind_template_callback (widget_class, show_more_button_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, software_button_clicked_cb);
|
||||
}
|
||||
@ -729,11 +705,9 @@ gtk_app_chooser_dialog_new_for_content_type (GtkWindow *parent,
|
||||
GtkWidget *
|
||||
gtk_app_chooser_dialog_get_widget (GtkAppChooserDialog *self)
|
||||
{
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_APP_CHOOSER_DIALOG (self), NULL);
|
||||
|
||||
return priv->app_chooser_widget;
|
||||
return self->app_chooser_widget;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -748,23 +722,21 @@ void
|
||||
gtk_app_chooser_dialog_set_heading (GtkAppChooserDialog *self,
|
||||
const gchar *heading)
|
||||
{
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_DIALOG (self));
|
||||
|
||||
g_free (priv->heading);
|
||||
priv->heading = g_strdup (heading);
|
||||
g_free (self->heading);
|
||||
self->heading = g_strdup (heading);
|
||||
|
||||
if (priv->label)
|
||||
if (self->label)
|
||||
{
|
||||
if (priv->heading)
|
||||
if (self->heading)
|
||||
{
|
||||
gtk_label_set_markup (GTK_LABEL (priv->label), priv->heading);
|
||||
gtk_widget_show (priv->label);
|
||||
gtk_label_set_markup (GTK_LABEL (self->label), self->heading);
|
||||
gtk_widget_show (self->label);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (priv->label);
|
||||
gtk_widget_hide (self->label);
|
||||
}
|
||||
}
|
||||
|
||||
@ -783,9 +755,7 @@ gtk_app_chooser_dialog_set_heading (GtkAppChooserDialog *self,
|
||||
const gchar *
|
||||
gtk_app_chooser_dialog_get_heading (GtkAppChooserDialog *self)
|
||||
{
|
||||
GtkAppChooserDialogPrivate *priv = gtk_app_chooser_dialog_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_APP_CHOOSER_DIALOG (self), NULL);
|
||||
|
||||
return priv->heading;
|
||||
return self->heading;
|
||||
}
|
||||
|
167
gtk/gtkimage.c
167
gtk/gtkimage.c
@ -81,16 +81,7 @@ typedef struct _GtkImageClass GtkImageClass;
|
||||
struct _GtkImage
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
};
|
||||
|
||||
struct _GtkImageClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkIconHelper *icon_helper;
|
||||
GtkIconSize icon_size;
|
||||
|
||||
@ -98,7 +89,13 @@ typedef struct
|
||||
|
||||
char *filename;
|
||||
char *resource_path;
|
||||
} GtkImagePrivate;
|
||||
};
|
||||
|
||||
struct _GtkImageClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
static void gtk_image_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot);
|
||||
@ -141,7 +138,7 @@ enum
|
||||
|
||||
static GParamSpec *image_props[NUM_PROPERTIES] = { NULL, };
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkImage, gtk_image, GTK_TYPE_WIDGET)
|
||||
G_DEFINE_TYPE (GtkImage, gtk_image, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
gtk_image_class_init (GtkImageClass *class)
|
||||
@ -269,26 +266,24 @@ gtk_image_class_init (GtkImageClass *class)
|
||||
static void
|
||||
gtk_image_init (GtkImage *image)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
GtkCssNode *widget_node;
|
||||
|
||||
widget_node = gtk_widget_get_css_node (GTK_WIDGET (image));
|
||||
|
||||
priv->icon_helper = gtk_icon_helper_new (widget_node, GTK_WIDGET (image));
|
||||
image->icon_helper = gtk_icon_helper_new (widget_node, GTK_WIDGET (image));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_image_finalize (GObject *object)
|
||||
{
|
||||
GtkImage *image = GTK_IMAGE (object);
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
gtk_image_clear (image);
|
||||
|
||||
g_clear_object (&priv->icon_helper);
|
||||
g_clear_object (&image->icon_helper);
|
||||
|
||||
g_free (priv->filename);
|
||||
g_free (priv->resource_path);
|
||||
g_free (image->filename);
|
||||
g_free (image->resource_path);
|
||||
|
||||
G_OBJECT_CLASS (gtk_image_parent_class)->finalize (object);
|
||||
};
|
||||
@ -300,7 +295,6 @@ gtk_image_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkImage *image = GTK_IMAGE (object);
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -327,7 +321,7 @@ gtk_image_set_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_USE_FALLBACK:
|
||||
if (_gtk_icon_helper_set_use_fallback (priv->icon_helper, g_value_get_boolean (value)))
|
||||
if (_gtk_icon_helper_set_use_fallback (image->icon_helper, g_value_get_boolean (value)))
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
break;
|
||||
|
||||
@ -344,36 +338,35 @@ gtk_image_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkImage *image = GTK_IMAGE (object);
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_PAINTABLE:
|
||||
g_value_set_object (value, _gtk_icon_helper_peek_paintable (priv->icon_helper));
|
||||
g_value_set_object (value, _gtk_icon_helper_peek_paintable (image->icon_helper));
|
||||
break;
|
||||
case PROP_FILE:
|
||||
g_value_set_string (value, priv->filename);
|
||||
g_value_set_string (value, image->filename);
|
||||
break;
|
||||
case PROP_ICON_SIZE:
|
||||
g_value_set_enum (value, priv->icon_size);
|
||||
g_value_set_enum (value, image->icon_size);
|
||||
break;
|
||||
case PROP_PIXEL_SIZE:
|
||||
g_value_set_int (value, _gtk_icon_helper_get_pixel_size (priv->icon_helper));
|
||||
g_value_set_int (value, _gtk_icon_helper_get_pixel_size (image->icon_helper));
|
||||
break;
|
||||
case PROP_ICON_NAME:
|
||||
g_value_set_string (value, _gtk_icon_helper_get_icon_name (priv->icon_helper));
|
||||
g_value_set_string (value, _gtk_icon_helper_get_icon_name (image->icon_helper));
|
||||
break;
|
||||
case PROP_GICON:
|
||||
g_value_set_object (value, _gtk_icon_helper_peek_gicon (priv->icon_helper));
|
||||
g_value_set_object (value, _gtk_icon_helper_peek_gicon (image->icon_helper));
|
||||
break;
|
||||
case PROP_RESOURCE:
|
||||
g_value_set_string (value, priv->resource_path);
|
||||
g_value_set_string (value, image->resource_path);
|
||||
break;
|
||||
case PROP_USE_FALLBACK:
|
||||
g_value_set_boolean (value, _gtk_icon_helper_get_use_fallback (priv->icon_helper));
|
||||
g_value_set_boolean (value, _gtk_icon_helper_get_use_fallback (image->icon_helper));
|
||||
break;
|
||||
case PROP_STORAGE_TYPE:
|
||||
g_value_set_enum (value, _gtk_icon_helper_get_storage_type (priv->icon_helper));
|
||||
g_value_set_enum (value, _gtk_icon_helper_get_storage_type (image->icon_helper));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -655,7 +648,6 @@ void
|
||||
gtk_image_set_from_file (GtkImage *image,
|
||||
const gchar *filename)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
GdkPixbufAnimation *anim;
|
||||
gint scale_factor;
|
||||
GdkTexture *texture;
|
||||
@ -669,7 +661,7 @@ gtk_image_set_from_file (GtkImage *image,
|
||||
|
||||
if (filename == NULL)
|
||||
{
|
||||
priv->filename = NULL;
|
||||
image->filename = NULL;
|
||||
g_object_thaw_notify (G_OBJECT (image));
|
||||
return;
|
||||
}
|
||||
@ -692,7 +684,7 @@ gtk_image_set_from_file (GtkImage *image,
|
||||
g_object_unref (texture);
|
||||
g_object_unref (anim);
|
||||
|
||||
priv->filename = g_strdup (filename);
|
||||
image->filename = g_strdup (filename);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (image));
|
||||
}
|
||||
@ -738,7 +730,6 @@ void
|
||||
gtk_image_set_from_resource (GtkImage *image,
|
||||
const gchar *resource_path)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
GdkPixbufAnimation *animation;
|
||||
gint scale_factor = 1;
|
||||
GdkTexture *texture;
|
||||
@ -781,7 +772,7 @@ gtk_image_set_from_resource (GtkImage *image,
|
||||
g_object_unref (scaler);
|
||||
g_object_unref (texture);
|
||||
|
||||
priv->resource_path = g_strdup (resource_path);
|
||||
image->resource_path = g_strdup (resource_path);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_RESOURCE]);
|
||||
|
||||
@ -836,8 +827,6 @@ void
|
||||
gtk_image_set_from_icon_name (GtkImage *image,
|
||||
const gchar *icon_name)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_if_fail (GTK_IS_IMAGE (image));
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (image));
|
||||
@ -845,7 +834,7 @@ gtk_image_set_from_icon_name (GtkImage *image,
|
||||
gtk_image_clear (image);
|
||||
|
||||
if (icon_name)
|
||||
_gtk_icon_helper_set_icon_name (priv->icon_helper, icon_name);
|
||||
_gtk_icon_helper_set_icon_name (image->icon_helper, icon_name);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_ICON_NAME]);
|
||||
|
||||
@ -867,8 +856,6 @@ void
|
||||
gtk_image_set_from_gicon (GtkImage *image,
|
||||
GIcon *icon)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_if_fail (GTK_IS_IMAGE (image));
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (image));
|
||||
@ -880,7 +867,7 @@ gtk_image_set_from_gicon (GtkImage *image,
|
||||
|
||||
if (icon)
|
||||
{
|
||||
_gtk_icon_helper_set_gicon (priv->icon_helper, icon);
|
||||
_gtk_icon_helper_set_gicon (image->icon_helper, icon);
|
||||
g_object_unref (icon);
|
||||
}
|
||||
|
||||
@ -900,9 +887,7 @@ static void
|
||||
gtk_image_paintable_invalidate_size (GdkPaintable *paintable,
|
||||
GtkImage *image)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
gtk_icon_helper_invalidate (priv->icon_helper);
|
||||
gtk_icon_helper_invalidate (image->icon_helper);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -916,8 +901,6 @@ void
|
||||
gtk_image_set_from_paintable (GtkImage *image,
|
||||
GdkPaintable *paintable)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_if_fail (GTK_IS_IMAGE (image));
|
||||
g_return_if_fail (paintable == NULL || GDK_IS_PAINTABLE (paintable));
|
||||
|
||||
@ -932,7 +915,7 @@ gtk_image_set_from_paintable (GtkImage *image,
|
||||
{
|
||||
const guint flags = gdk_paintable_get_flags (paintable);
|
||||
|
||||
_gtk_icon_helper_set_paintable (priv->icon_helper, paintable);
|
||||
_gtk_icon_helper_set_paintable (image->icon_helper, paintable);
|
||||
|
||||
if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0)
|
||||
g_signal_connect (paintable,
|
||||
@ -966,11 +949,9 @@ gtk_image_set_from_paintable (GtkImage *image,
|
||||
GtkImageType
|
||||
gtk_image_get_storage_type (GtkImage *image)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_IMAGE (image), GTK_IMAGE_EMPTY);
|
||||
|
||||
return _gtk_icon_helper_get_storage_type (priv->icon_helper);
|
||||
return _gtk_icon_helper_get_storage_type (image->icon_helper);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -989,11 +970,9 @@ gtk_image_get_storage_type (GtkImage *image)
|
||||
GdkPaintable *
|
||||
gtk_image_get_paintable (GtkImage *image)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_IMAGE (image), NULL);
|
||||
|
||||
return _gtk_icon_helper_peek_paintable (priv->icon_helper);
|
||||
return _gtk_icon_helper_peek_paintable (image->icon_helper);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1015,11 +994,9 @@ gtk_image_get_paintable (GtkImage *image)
|
||||
const gchar *
|
||||
gtk_image_get_icon_name (GtkImage *image)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_IMAGE (image), NULL);
|
||||
|
||||
return _gtk_icon_helper_get_icon_name (priv->icon_helper);
|
||||
return _gtk_icon_helper_get_icon_name (image->icon_helper);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1041,11 +1018,9 @@ gtk_image_get_icon_name (GtkImage *image)
|
||||
GIcon *
|
||||
gtk_image_get_gicon (GtkImage *image)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_IMAGE (image), NULL);
|
||||
|
||||
return _gtk_icon_helper_peek_gicon (priv->icon_helper);
|
||||
return _gtk_icon_helper_peek_gicon (image->icon_helper);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1065,9 +1040,8 @@ static void
|
||||
gtk_image_unrealize (GtkWidget *widget)
|
||||
{
|
||||
GtkImage *image = GTK_IMAGE (widget);
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
gtk_icon_helper_invalidate (priv->icon_helper);
|
||||
gtk_icon_helper_invalidate (image->icon_helper);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_image_parent_class)->unrealize (widget);
|
||||
}
|
||||
@ -1077,23 +1051,21 @@ gtk_image_get_baseline_align (GtkImage *image)
|
||||
{
|
||||
PangoContext *pango_context;
|
||||
PangoFontMetrics *metrics;
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
|
||||
if (priv->baseline_align == 0.0)
|
||||
if (image->baseline_align == 0.0)
|
||||
{
|
||||
pango_context = gtk_widget_get_pango_context (GTK_WIDGET (image));
|
||||
metrics = pango_context_get_metrics (pango_context,
|
||||
pango_context_get_font_description (pango_context),
|
||||
pango_context_get_language (pango_context));
|
||||
priv->baseline_align =
|
||||
image->baseline_align =
|
||||
(float)pango_font_metrics_get_ascent (metrics) /
|
||||
(pango_font_metrics_get_ascent (metrics) + pango_font_metrics_get_descent (metrics));
|
||||
|
||||
pango_font_metrics_unref (metrics);
|
||||
}
|
||||
|
||||
return priv->baseline_align;
|
||||
return image->baseline_align;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1101,18 +1073,17 @@ gtk_image_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkImage *image = GTK_IMAGE (widget);
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
double ratio;
|
||||
int x, y, width, height, baseline;
|
||||
double w, h;
|
||||
|
||||
width = gtk_widget_get_width (widget);
|
||||
height = gtk_widget_get_height (widget);
|
||||
ratio = gdk_paintable_get_intrinsic_aspect_ratio (GDK_PAINTABLE (priv->icon_helper));
|
||||
ratio = gdk_paintable_get_intrinsic_aspect_ratio (GDK_PAINTABLE (image->icon_helper));
|
||||
|
||||
if (ratio == 0)
|
||||
{
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (priv->icon_helper), snapshot, width, height);
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (image->icon_helper), snapshot, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1141,12 +1112,12 @@ gtk_image_snapshot (GtkWidget *widget,
|
||||
{
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (priv->icon_helper), snapshot, w, h);
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (image->icon_helper), snapshot, w, h);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (priv->icon_helper), snapshot, w, h);
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (image->icon_helper), snapshot, w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1176,8 +1147,6 @@ void
|
||||
gtk_image_set_from_definition (GtkImage *image,
|
||||
GtkImageDefinition *def)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_if_fail (GTK_IS_IMAGE (image));
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (image));
|
||||
@ -1186,7 +1155,7 @@ gtk_image_set_from_definition (GtkImage *image,
|
||||
|
||||
if (def != NULL)
|
||||
{
|
||||
_gtk_icon_helper_set_definition (priv->icon_helper, def);
|
||||
_gtk_icon_helper_set_definition (image->icon_helper, def);
|
||||
|
||||
gtk_image_notify_for_storage_type (image, gtk_image_definition_get_storage_type (def));
|
||||
}
|
||||
@ -1197,9 +1166,7 @@ gtk_image_set_from_definition (GtkImage *image,
|
||||
GtkImageDefinition *
|
||||
gtk_image_get_definition (GtkImage *image)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
return gtk_icon_helper_get_definition (priv->icon_helper);
|
||||
return gtk_icon_helper_get_definition (image->icon_helper);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1211,7 +1178,6 @@ gtk_image_get_definition (GtkImage *image)
|
||||
void
|
||||
gtk_image_clear (GtkImage *image)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
GtkImageType storage_type;
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (image));
|
||||
@ -1224,23 +1190,23 @@ gtk_image_clear (GtkImage *image)
|
||||
|
||||
gtk_image_notify_for_storage_type (image, storage_type);
|
||||
|
||||
if (priv->filename)
|
||||
if (image->filename)
|
||||
{
|
||||
g_free (priv->filename);
|
||||
priv->filename = NULL;
|
||||
g_free (image->filename);
|
||||
image->filename = NULL;
|
||||
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_FILE]);
|
||||
}
|
||||
|
||||
if (priv->resource_path)
|
||||
if (image->resource_path)
|
||||
{
|
||||
g_free (priv->resource_path);
|
||||
priv->resource_path = NULL;
|
||||
g_free (image->resource_path);
|
||||
image->resource_path = NULL;
|
||||
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_RESOURCE]);
|
||||
}
|
||||
|
||||
if (storage_type == GTK_IMAGE_PAINTABLE)
|
||||
{
|
||||
GdkPaintable *paintable = _gtk_icon_helper_peek_paintable (priv->icon_helper);
|
||||
GdkPaintable *paintable = _gtk_icon_helper_peek_paintable (image->icon_helper);
|
||||
const guint flags = gdk_paintable_get_flags (paintable);
|
||||
|
||||
if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0)
|
||||
@ -1254,7 +1220,7 @@ gtk_image_clear (GtkImage *image)
|
||||
image);
|
||||
}
|
||||
|
||||
_gtk_icon_helper_clear (priv->icon_helper);
|
||||
_gtk_icon_helper_clear (image->icon_helper);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (image));
|
||||
}
|
||||
@ -1268,10 +1234,10 @@ gtk_image_measure (GtkWidget *widget,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (GTK_IMAGE (widget));
|
||||
GtkImage *image = GTK_IMAGE (widget);
|
||||
float baseline_align;
|
||||
|
||||
*minimum = *natural = gtk_icon_helper_get_size (priv->icon_helper);
|
||||
*minimum = *natural = gtk_icon_helper_get_size (image->icon_helper);
|
||||
|
||||
if (orientation == GTK_ORIENTATION_VERTICAL)
|
||||
{
|
||||
@ -1288,13 +1254,12 @@ gtk_image_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkImage *image = GTK_IMAGE (widget);
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
gtk_icon_helper_invalidate_for_change (priv->icon_helper, change);
|
||||
gtk_icon_helper_invalidate_for_change (image->icon_helper, change);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_image_parent_class)->css_changed (widget, change);
|
||||
|
||||
priv->baseline_align = 0.0;
|
||||
image->baseline_align = 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1310,11 +1275,9 @@ void
|
||||
gtk_image_set_pixel_size (GtkImage *image,
|
||||
gint pixel_size)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_if_fail (GTK_IS_IMAGE (image));
|
||||
|
||||
if (_gtk_icon_helper_set_pixel_size (priv->icon_helper, pixel_size))
|
||||
if (_gtk_icon_helper_set_pixel_size (image->icon_helper, pixel_size))
|
||||
{
|
||||
if (gtk_widget_get_visible (GTK_WIDGET (image)))
|
||||
gtk_widget_queue_resize (GTK_WIDGET (image));
|
||||
@ -1333,11 +1296,9 @@ gtk_image_set_pixel_size (GtkImage *image,
|
||||
gint
|
||||
gtk_image_get_pixel_size (GtkImage *image)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_IMAGE (image), -1);
|
||||
|
||||
return _gtk_icon_helper_get_pixel_size (priv->icon_helper);
|
||||
return _gtk_icon_helper_get_pixel_size (image->icon_helper);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1351,14 +1312,12 @@ void
|
||||
gtk_image_set_icon_size (GtkImage *image,
|
||||
GtkIconSize icon_size)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_if_fail (GTK_IS_IMAGE (image));
|
||||
|
||||
if (priv->icon_size == icon_size)
|
||||
if (image->icon_size == icon_size)
|
||||
return;
|
||||
|
||||
priv->icon_size = icon_size;
|
||||
image->icon_size = icon_size;
|
||||
gtk_icon_size_set_style_classes (gtk_widget_get_css_node (GTK_WIDGET (image)), icon_size);
|
||||
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_ICON_SIZE]);
|
||||
}
|
||||
@ -1374,11 +1333,9 @@ gtk_image_set_icon_size (GtkImage *image,
|
||||
GtkIconSize
|
||||
gtk_image_get_icon_size (GtkImage *image)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_IMAGE (image), GTK_ICON_SIZE_INHERIT);
|
||||
|
||||
return priv->icon_size;
|
||||
return image->icon_size;
|
||||
}
|
||||
|
||||
void
|
||||
@ -1386,7 +1343,5 @@ gtk_image_get_image_size (GtkImage *image,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
*width = *height = gtk_icon_helper_get_size (priv->icon_helper);
|
||||
*width = *height = gtk_icon_helper_get_size (image->icon_helper);
|
||||
}
|
||||
|
164
gtk/gtkinfobar.c
164
gtk/gtkinfobar.c
@ -145,6 +145,15 @@ typedef struct _GtkInfoBarClass GtkInfoBarClass;
|
||||
struct _GtkInfoBar
|
||||
{
|
||||
GtkContainer parent_instance;
|
||||
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *action_area;
|
||||
GtkWidget *close_button;
|
||||
GtkWidget *revealer;
|
||||
|
||||
GtkMessageType message_type;
|
||||
int default_response;
|
||||
gboolean default_response_sensitive;
|
||||
};
|
||||
|
||||
struct _GtkInfoBarClass
|
||||
@ -155,18 +164,6 @@ struct _GtkInfoBarClass
|
||||
void (* close) (GtkInfoBar *info_bar);
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *action_area;
|
||||
GtkWidget *close_button;
|
||||
GtkWidget *revealer;
|
||||
|
||||
GtkMessageType message_type;
|
||||
int default_response;
|
||||
gboolean default_response_sensitive;
|
||||
} GtkInfoBarPrivate;
|
||||
|
||||
typedef struct _ResponseData ResponseData;
|
||||
|
||||
struct _ResponseData
|
||||
@ -212,7 +209,6 @@ static void gtk_info_bar_buildable_add_child (GtkBuildable *buildable
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkInfoBar, gtk_info_bar, GTK_TYPE_CONTAINER,
|
||||
G_ADD_PRIVATE (GtkInfoBar)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
||||
gtk_info_bar_buildable_interface_init))
|
||||
|
||||
@ -296,11 +292,10 @@ static GtkWidget *
|
||||
find_button (GtkInfoBar *info_bar,
|
||||
gint response_id)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
GList *children, *list;
|
||||
GtkWidget *child = NULL;
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (priv->action_area));
|
||||
children = gtk_container_get_children (GTK_CONTAINER (info_bar->action_area));
|
||||
|
||||
for (list = children; list; list = list->next)
|
||||
{
|
||||
@ -321,10 +316,8 @@ find_button (GtkInfoBar *info_bar,
|
||||
static void
|
||||
gtk_info_bar_close (GtkInfoBar *info_bar)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
if (!gtk_widget_get_visible (priv->close_button)
|
||||
&& !find_button (info_bar, GTK_RESPONSE_CANCEL))
|
||||
if (!gtk_widget_get_visible (info_bar->close_button) &&
|
||||
!find_button (info_bar, GTK_RESPONSE_CANCEL))
|
||||
return;
|
||||
|
||||
gtk_info_bar_response (GTK_INFO_BAR (info_bar),
|
||||
@ -336,9 +329,8 @@ gtk_info_bar_add (GtkContainer *container,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkInfoBar *self = GTK_INFO_BAR (container);
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (self);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (priv->content_area), child);
|
||||
gtk_container_add (GTK_CONTAINER (self->content_area), child);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -346,9 +338,8 @@ gtk_info_bar_remove (GtkContainer *container,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkInfoBar *self = GTK_INFO_BAR (container);
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (self);
|
||||
|
||||
gtk_container_remove (GTK_CONTAINER (priv->content_area), child);
|
||||
gtk_container_remove (GTK_CONTAINER (self->content_area), child);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -357,19 +348,17 @@ gtk_info_bar_forall (GtkContainer *container,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkInfoBar *self = GTK_INFO_BAR (container);
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (self);
|
||||
|
||||
if (priv->revealer)
|
||||
(*callback) (priv->revealer, user_data);
|
||||
if (self->revealer)
|
||||
(*callback) (self->revealer, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_info_bar_dispose (GObject *object)
|
||||
{
|
||||
GtkInfoBar *self = GTK_INFO_BAR (object);
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (self);
|
||||
|
||||
g_clear_pointer (&priv->revealer, gtk_widget_unparent);
|
||||
g_clear_pointer (&self->revealer, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (gtk_info_bar_parent_class)->dispose (object);
|
||||
}
|
||||
@ -476,8 +465,7 @@ static void
|
||||
close_button_clicked_cb (GtkWidget *button,
|
||||
GtkInfoBar *info_bar)
|
||||
{
|
||||
gtk_info_bar_response (GTK_INFO_BAR (info_bar),
|
||||
GTK_RESPONSE_CLOSE);
|
||||
gtk_info_bar_response (GTK_INFO_BAR (info_bar), GTK_RESPONSE_CLOSE);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -487,16 +475,13 @@ click_released_cb (GtkGestureClick *gesture,
|
||||
gdouble y,
|
||||
GtkInfoBar *info_bar)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
if (priv->default_response && priv->default_response_sensitive)
|
||||
gtk_info_bar_response (info_bar, priv->default_response);
|
||||
if (info_bar->default_response && info_bar->default_response_sensitive)
|
||||
gtk_info_bar_response (info_bar, info_bar->default_response);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_info_bar_init (GtkInfoBar *info_bar)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
GtkWidget *widget = GTK_WIDGET (info_bar);
|
||||
GtkWidget *main_box;
|
||||
GtkGesture *gesture;
|
||||
@ -504,30 +489,30 @@ gtk_info_bar_init (GtkInfoBar *info_bar)
|
||||
/* message-type is a CONSTRUCT property, so we init to a value
|
||||
* different from its default to trigger its property setter
|
||||
* during construction */
|
||||
priv->message_type = GTK_MESSAGE_OTHER;
|
||||
info_bar->message_type = GTK_MESSAGE_OTHER;
|
||||
|
||||
priv->revealer = gtk_revealer_new ();
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), TRUE);
|
||||
gtk_widget_set_parent (priv->revealer, widget);
|
||||
info_bar->revealer = gtk_revealer_new ();
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (info_bar->revealer), TRUE);
|
||||
gtk_widget_set_parent (info_bar->revealer, widget);
|
||||
|
||||
main_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (priv->revealer), main_box);
|
||||
gtk_container_add (GTK_CONTAINER (info_bar->revealer), main_box);
|
||||
|
||||
priv->content_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_hexpand (priv->content_area, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (main_box), priv->content_area);
|
||||
info_bar->content_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_hexpand (info_bar->content_area, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (main_box), info_bar->content_area);
|
||||
|
||||
priv->action_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_halign (priv->action_area, GTK_ALIGN_END);
|
||||
gtk_widget_set_valign (priv->action_area, GTK_ALIGN_CENTER);
|
||||
gtk_container_add (GTK_CONTAINER (main_box), priv->action_area);
|
||||
info_bar->action_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_halign (info_bar->action_area, GTK_ALIGN_END);
|
||||
gtk_widget_set_valign (info_bar->action_area, GTK_ALIGN_CENTER);
|
||||
gtk_container_add (GTK_CONTAINER (main_box), info_bar->action_area);
|
||||
|
||||
priv->close_button = gtk_button_new_from_icon_name ("window-close-symbolic");
|
||||
gtk_widget_hide (priv->close_button);
|
||||
gtk_widget_set_valign (priv->close_button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_add_css_class (priv->close_button, "close");
|
||||
gtk_container_add (GTK_CONTAINER (main_box), priv->close_button);
|
||||
g_signal_connect (priv->close_button, "clicked",
|
||||
info_bar->close_button = gtk_button_new_from_icon_name ("window-close-symbolic");
|
||||
gtk_widget_hide (info_bar->close_button);
|
||||
gtk_widget_set_valign (info_bar->close_button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_add_css_class (info_bar->close_button, "close");
|
||||
gtk_container_add (GTK_CONTAINER (main_box), info_bar->close_button);
|
||||
g_signal_connect (info_bar->close_button, "clicked",
|
||||
G_CALLBACK (close_button_clicked_cb), info_bar);
|
||||
|
||||
gesture = gtk_gesture_click_new ();
|
||||
@ -587,7 +572,6 @@ gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,
|
||||
GtkWidget *child,
|
||||
gint response_id)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
ResponseData *ad;
|
||||
guint signal_id;
|
||||
|
||||
@ -615,7 +599,7 @@ gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,
|
||||
else
|
||||
g_warning ("Only 'activatable' widgets can be packed into the action area of a GtkInfoBar");
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (priv->action_area), child);
|
||||
gtk_container_add (GTK_CONTAINER (info_bar->action_area), child);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -754,10 +738,8 @@ update_default_response (GtkInfoBar *info_bar,
|
||||
int response_id,
|
||||
gboolean sensitive)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
priv->default_response = response_id;
|
||||
priv->default_response_sensitive = sensitive;
|
||||
info_bar->default_response = response_id;
|
||||
info_bar->default_response_sensitive = sensitive;
|
||||
|
||||
if (response_id && sensitive)
|
||||
gtk_widget_add_css_class (GTK_WIDGET (info_bar), "action");
|
||||
@ -780,12 +762,11 @@ gtk_info_bar_set_response_sensitive (GtkInfoBar *info_bar,
|
||||
gint response_id,
|
||||
gboolean setting)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
GList *children, *list;
|
||||
|
||||
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (priv->action_area));
|
||||
children = gtk_container_get_children (GTK_CONTAINER (info_bar->action_area));
|
||||
|
||||
for (list = children; list; list = list->next)
|
||||
{
|
||||
@ -798,7 +779,7 @@ gtk_info_bar_set_response_sensitive (GtkInfoBar *info_bar,
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
if (response_id == priv->default_response)
|
||||
if (response_id == info_bar->default_response)
|
||||
update_default_response (info_bar, response_id, setting);
|
||||
}
|
||||
|
||||
@ -818,13 +799,12 @@ void
|
||||
gtk_info_bar_set_default_response (GtkInfoBar *info_bar,
|
||||
gint response_id)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
GList *children, *list;
|
||||
gboolean sensitive = TRUE;
|
||||
|
||||
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (priv->action_area));
|
||||
children = gtk_container_get_children (GTK_CONTAINER (info_bar->action_area));
|
||||
|
||||
for (list = children; list; list = list->next)
|
||||
{
|
||||
@ -1081,12 +1061,11 @@ gtk_info_bar_buildable_add_child (GtkBuildable *buildable,
|
||||
const char *type)
|
||||
{
|
||||
GtkInfoBar *info_bar = GTK_INFO_BAR (buildable);
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
if (!type)
|
||||
gtk_container_add (GTK_CONTAINER (priv->content_area), GTK_WIDGET (child));
|
||||
gtk_container_add (GTK_CONTAINER (info_bar->content_area), GTK_WIDGET (child));
|
||||
else if (g_strcmp0 (type, "action") == 0)
|
||||
gtk_container_add (GTK_CONTAINER (priv->action_area), GTK_WIDGET (child));
|
||||
gtk_container_add (GTK_CONTAINER (info_bar->action_area), GTK_WIDGET (child));
|
||||
else
|
||||
parent_buildable_iface->add_child (buildable, builder, child, type);
|
||||
}
|
||||
@ -1104,11 +1083,9 @@ void
|
||||
gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
|
||||
GtkMessageType message_type)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
||||
|
||||
if (priv->message_type != message_type)
|
||||
if (info_bar->message_type != message_type)
|
||||
{
|
||||
AtkObject *atk_obj;
|
||||
const char *type_class[] = {
|
||||
@ -1119,10 +1096,10 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
|
||||
NULL
|
||||
};
|
||||
|
||||
if (type_class[priv->message_type])
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (info_bar), type_class[priv->message_type]);
|
||||
if (type_class[info_bar->message_type])
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (info_bar), type_class[info_bar->message_type]);
|
||||
|
||||
priv->message_type = message_type;
|
||||
info_bar->message_type = message_type;
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (info_bar));
|
||||
|
||||
@ -1163,8 +1140,8 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
|
||||
atk_object_set_name (atk_obj, name);
|
||||
}
|
||||
|
||||
if (type_class[priv->message_type])
|
||||
gtk_widget_add_css_class (GTK_WIDGET (info_bar), type_class[priv->message_type]);
|
||||
if (type_class[info_bar->message_type])
|
||||
gtk_widget_add_css_class (GTK_WIDGET (info_bar), type_class[info_bar->message_type]);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_MESSAGE_TYPE]);
|
||||
}
|
||||
@ -1181,11 +1158,9 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
|
||||
GtkMessageType
|
||||
gtk_info_bar_get_message_type (GtkInfoBar *info_bar)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), GTK_MESSAGE_OTHER);
|
||||
|
||||
return priv->message_type;
|
||||
return info_bar->message_type;
|
||||
}
|
||||
|
||||
|
||||
@ -1201,15 +1176,13 @@ void
|
||||
gtk_info_bar_set_show_close_button (GtkInfoBar *info_bar,
|
||||
gboolean setting)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
||||
|
||||
if (setting != gtk_info_bar_get_show_close_button (info_bar))
|
||||
{
|
||||
gtk_widget_set_visible (priv->close_button, setting);
|
||||
g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_SHOW_CLOSE_BUTTON]);
|
||||
}
|
||||
if (setting == gtk_info_bar_get_show_close_button (info_bar))
|
||||
return;
|
||||
|
||||
gtk_widget_set_visible (info_bar->close_button, setting);
|
||||
g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_SHOW_CLOSE_BUTTON]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1223,11 +1196,9 @@ gtk_info_bar_set_show_close_button (GtkInfoBar *info_bar,
|
||||
gboolean
|
||||
gtk_info_bar_get_show_close_button (GtkInfoBar *info_bar)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), FALSE);
|
||||
|
||||
return gtk_widget_get_visible (priv->close_button);
|
||||
return gtk_widget_get_visible (info_bar->close_button);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1245,16 +1216,13 @@ void
|
||||
gtk_info_bar_set_revealed (GtkInfoBar *info_bar,
|
||||
gboolean revealed)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
||||
|
||||
revealed = !!revealed;
|
||||
if (revealed != gtk_revealer_get_reveal_child (GTK_REVEALER (priv->revealer)))
|
||||
{
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), revealed);
|
||||
g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_REVEALED]);
|
||||
}
|
||||
if (revealed == gtk_revealer_get_reveal_child (GTK_REVEALER (info_bar->revealer)))
|
||||
return;
|
||||
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (info_bar->revealer), revealed);
|
||||
g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_REVEALED]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1268,9 +1236,7 @@ gtk_info_bar_set_revealed (GtkInfoBar *info_bar,
|
||||
gboolean
|
||||
gtk_info_bar_get_revealed (GtkInfoBar *info_bar)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), FALSE);
|
||||
|
||||
return gtk_revealer_get_reveal_child (GTK_REVEALER (priv->revealer));
|
||||
return gtk_revealer_get_reveal_child (GTK_REVEALER (info_bar->revealer));
|
||||
}
|
||||
|
@ -136,15 +136,7 @@ typedef struct _GtkMenuButtonPrivate GtkMenuButtonPrivate;
|
||||
struct _GtkMenuButton
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
};
|
||||
|
||||
struct _GtkMenuButtonClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
struct _GtkMenuButtonPrivate
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkWidget *popover; /* Only one at a time can be set */
|
||||
GMenuModel *model;
|
||||
@ -159,6 +151,11 @@ struct _GtkMenuButtonPrivate
|
||||
GtkArrowType arrow_type;
|
||||
};
|
||||
|
||||
struct _GtkMenuButtonClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
@ -175,7 +172,7 @@ enum
|
||||
|
||||
static GParamSpec *menu_button_props[LAST_PROP];
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkMenuButton, gtk_menu_button, GTK_TYPE_WIDGET)
|
||||
G_DEFINE_TYPE (GtkMenuButton, gtk_menu_button, GTK_TYPE_WIDGET)
|
||||
|
||||
static void gtk_menu_button_dispose (GObject *object);
|
||||
|
||||
@ -224,21 +221,21 @@ gtk_menu_button_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (GTK_MENU_BUTTON (object));
|
||||
GtkMenuButton *self = GTK_MENU_BUTTON (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_MENU_MODEL:
|
||||
g_value_set_object (value, priv->model);
|
||||
g_value_set_object (value, self->model);
|
||||
break;
|
||||
case PROP_ALIGN_WIDGET:
|
||||
g_value_set_object (value, priv->align_widget);
|
||||
g_value_set_object (value, self->align_widget);
|
||||
break;
|
||||
case PROP_DIRECTION:
|
||||
g_value_set_enum (value, priv->arrow_type);
|
||||
g_value_set_enum (value, self->arrow_type);
|
||||
break;
|
||||
case PROP_POPOVER:
|
||||
g_value_set_object (value, priv->popover);
|
||||
g_value_set_object (value, self->popover);
|
||||
break;
|
||||
case PROP_ICON_NAME:
|
||||
g_value_set_string (value, gtk_menu_button_get_icon_name (GTK_MENU_BUTTON (object)));
|
||||
@ -261,34 +258,32 @@ static void
|
||||
gtk_menu_button_state_flags_changed (GtkWidget *widget,
|
||||
GtkStateFlags previous_state_flags)
|
||||
{
|
||||
GtkMenuButton *button = GTK_MENU_BUTTON (widget);
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (button);
|
||||
GtkMenuButton *self = GTK_MENU_BUTTON (widget);
|
||||
|
||||
if (!gtk_widget_is_sensitive (widget))
|
||||
{
|
||||
if (priv->popover)
|
||||
gtk_widget_hide (priv->popover);
|
||||
if (self->popover)
|
||||
gtk_widget_hide (self->popover);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_button_toggled (GtkMenuButton *menu_button)
|
||||
gtk_menu_button_toggled (GtkMenuButton *self)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
const gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button));
|
||||
const gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->button));
|
||||
|
||||
/* Might set a new menu/popover */
|
||||
if (active && priv->create_popup_func)
|
||||
if (active && self->create_popup_func)
|
||||
{
|
||||
priv->create_popup_func (menu_button, priv->create_popup_user_data);
|
||||
self->create_popup_func (self, self->create_popup_user_data);
|
||||
}
|
||||
|
||||
if (priv->popover)
|
||||
if (self->popover)
|
||||
{
|
||||
if (active)
|
||||
gtk_popover_popup (GTK_POPOVER (priv->popover));
|
||||
gtk_popover_popup (GTK_POPOVER (self->popover));
|
||||
else
|
||||
gtk_popover_popdown (GTK_POPOVER (priv->popover));
|
||||
gtk_popover_popdown (GTK_POPOVER (self->popover));
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,10 +296,9 @@ gtk_menu_button_measure (GtkWidget *widget,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
GtkMenuButton *menu_button = GTK_MENU_BUTTON (widget);
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
GtkMenuButton *self = GTK_MENU_BUTTON (widget);
|
||||
|
||||
gtk_widget_measure (priv->button,
|
||||
gtk_widget_measure (self->button,
|
||||
orientation,
|
||||
for_size,
|
||||
minimum, natural,
|
||||
@ -318,25 +312,23 @@ gtk_menu_button_size_allocate (GtkWidget *widget,
|
||||
int height,
|
||||
int baseline)
|
||||
{
|
||||
GtkMenuButton *button = GTK_MENU_BUTTON (widget);
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (button);
|
||||
GtkMenuButton *self= GTK_MENU_BUTTON (widget);
|
||||
|
||||
gtk_widget_size_allocate (priv->button,
|
||||
gtk_widget_size_allocate (self->button,
|
||||
&(GtkAllocation) { 0, 0, width, height },
|
||||
baseline);
|
||||
if (priv->popover)
|
||||
gtk_native_check_resize (GTK_NATIVE (priv->popover));
|
||||
if (self->popover)
|
||||
gtk_native_check_resize (GTK_NATIVE (self->popover));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_menu_button_focus (GtkWidget *widget,
|
||||
GtkDirectionType direction)
|
||||
{
|
||||
GtkMenuButton *button = GTK_MENU_BUTTON (widget);
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (button);
|
||||
GtkMenuButton *self = GTK_MENU_BUTTON (widget);
|
||||
|
||||
if (priv->popover && gtk_widget_get_visible (priv->popover))
|
||||
return gtk_widget_child_focus (priv->popover, direction);
|
||||
if (self->popover && gtk_widget_get_visible (self->popover))
|
||||
return gtk_widget_child_focus (self->popover, direction);
|
||||
else
|
||||
return GTK_WIDGET_CLASS (gtk_menu_button_parent_class)->focus (widget, direction);
|
||||
}
|
||||
@ -471,32 +463,29 @@ set_arrow_type (GtkImage *image,
|
||||
}
|
||||
|
||||
static void
|
||||
add_arrow (GtkMenuButton *menu_button)
|
||||
add_arrow (GtkMenuButton *self)
|
||||
{
|
||||
GtkWidget *arrow;
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
arrow = gtk_image_new ();
|
||||
set_arrow_type (GTK_IMAGE (arrow), priv->arrow_type);
|
||||
gtk_container_add (GTK_CONTAINER (priv->button), arrow);
|
||||
priv->arrow_widget = arrow;
|
||||
set_arrow_type (GTK_IMAGE (arrow), self->arrow_type);
|
||||
gtk_container_add (GTK_CONTAINER (self->button), arrow);
|
||||
self->arrow_widget = arrow;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_button_init (GtkMenuButton *menu_button)
|
||||
gtk_menu_button_init (GtkMenuButton *self)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
self->arrow_type = GTK_ARROW_DOWN;
|
||||
|
||||
priv->arrow_type = GTK_ARROW_DOWN;
|
||||
self->button = gtk_toggle_button_new ();
|
||||
gtk_widget_set_parent (self->button, GTK_WIDGET (self));
|
||||
g_signal_connect_swapped (self->button, "toggled", G_CALLBACK (gtk_menu_button_toggled), self);
|
||||
add_arrow (self);
|
||||
|
||||
priv->button = gtk_toggle_button_new ();
|
||||
gtk_widget_set_parent (priv->button, GTK_WIDGET (menu_button));
|
||||
g_signal_connect_swapped (priv->button, "toggled", G_CALLBACK (gtk_menu_button_toggled), menu_button);
|
||||
add_arrow (menu_button);
|
||||
gtk_widget_set_sensitive (self->button, FALSE);
|
||||
|
||||
gtk_widget_set_sensitive (priv->button, FALSE);
|
||||
|
||||
gtk_widget_add_css_class (GTK_WIDGET (menu_button), "popup");
|
||||
gtk_widget_add_css_class (GTK_WIDGET (self), "popup");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -515,21 +504,17 @@ gtk_menu_button_new (void)
|
||||
}
|
||||
|
||||
static void
|
||||
update_sensitivity (GtkMenuButton *menu_button)
|
||||
update_sensitivity (GtkMenuButton *self)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
gtk_widget_set_sensitive (priv->button,
|
||||
priv->popover != NULL ||
|
||||
priv->create_popup_func != NULL);
|
||||
gtk_widget_set_sensitive (self->button,
|
||||
self->popover != NULL ||
|
||||
self->create_popup_func != NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
menu_deactivate_cb (GtkMenuButton *menu_button)
|
||||
menu_deactivate_cb (GtkMenuButton *self)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), FALSE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->button), FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -553,8 +538,6 @@ void
|
||||
gtk_menu_button_set_menu_model (GtkMenuButton *menu_button,
|
||||
GMenuModel *menu_model)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
g_return_if_fail (G_IS_MENU_MODEL (menu_model) || menu_model == NULL);
|
||||
|
||||
@ -575,7 +558,7 @@ gtk_menu_button_set_menu_model (GtkMenuButton *menu_button,
|
||||
gtk_menu_button_set_popover (menu_button, NULL);
|
||||
}
|
||||
|
||||
priv->model = menu_model;
|
||||
menu_button->model = menu_model;
|
||||
g_object_notify_by_pspec (G_OBJECT (menu_button), menu_button_props[PROP_MENU_MODEL]);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (menu_button));
|
||||
@ -592,26 +575,22 @@ gtk_menu_button_set_menu_model (GtkMenuButton *menu_button,
|
||||
GMenuModel *
|
||||
gtk_menu_button_get_menu_model (GtkMenuButton *menu_button)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
|
||||
|
||||
return priv->model;
|
||||
return menu_button->model;
|
||||
}
|
||||
|
||||
static void
|
||||
set_align_widget_pointer (GtkMenuButton *menu_button,
|
||||
set_align_widget_pointer (GtkMenuButton *self,
|
||||
GtkWidget *align_widget)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
if (self->align_widget)
|
||||
g_object_remove_weak_pointer (G_OBJECT (self->align_widget), (gpointer *) &self->align_widget);
|
||||
|
||||
if (priv->align_widget)
|
||||
g_object_remove_weak_pointer (G_OBJECT (priv->align_widget), (gpointer *) &priv->align_widget);
|
||||
self->align_widget = align_widget;
|
||||
|
||||
priv->align_widget = align_widget;
|
||||
|
||||
if (priv->align_widget)
|
||||
g_object_add_weak_pointer (G_OBJECT (priv->align_widget), (gpointer *) &priv->align_widget);
|
||||
if (self->align_widget)
|
||||
g_object_add_weak_pointer (G_OBJECT (self->align_widget), (gpointer *) &self->align_widget);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -632,12 +611,10 @@ void
|
||||
gtk_menu_button_set_align_widget (GtkMenuButton *menu_button,
|
||||
GtkWidget *align_widget)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
g_return_if_fail (align_widget == NULL || gtk_widget_is_ancestor (GTK_WIDGET (menu_button), align_widget));
|
||||
|
||||
if (priv->align_widget == align_widget)
|
||||
if (menu_button->align_widget == align_widget)
|
||||
return;
|
||||
|
||||
set_align_widget_pointer (menu_button, align_widget);
|
||||
@ -656,35 +633,31 @@ gtk_menu_button_set_align_widget (GtkMenuButton *menu_button,
|
||||
GtkWidget *
|
||||
gtk_menu_button_get_align_widget (GtkMenuButton *menu_button)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
|
||||
|
||||
return priv->align_widget;
|
||||
return menu_button->align_widget;
|
||||
}
|
||||
|
||||
static void
|
||||
update_popover_direction (GtkMenuButton *menu_button)
|
||||
update_popover_direction (GtkMenuButton *self)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
if (!priv->popover)
|
||||
if (!self->popover)
|
||||
return;
|
||||
|
||||
switch (priv->arrow_type)
|
||||
switch (self->arrow_type)
|
||||
{
|
||||
case GTK_ARROW_UP:
|
||||
gtk_popover_set_position (GTK_POPOVER (priv->popover), GTK_POS_TOP);
|
||||
gtk_popover_set_position (GTK_POPOVER (self->popover), GTK_POS_TOP);
|
||||
break;
|
||||
case GTK_ARROW_DOWN:
|
||||
case GTK_ARROW_NONE:
|
||||
gtk_popover_set_position (GTK_POPOVER (priv->popover), GTK_POS_BOTTOM);
|
||||
gtk_popover_set_position (GTK_POPOVER (self->popover), GTK_POS_BOTTOM);
|
||||
break;
|
||||
case GTK_ARROW_LEFT:
|
||||
gtk_popover_set_position (GTK_POPOVER (priv->popover), GTK_POS_LEFT);
|
||||
gtk_popover_set_position (GTK_POPOVER (self->popover), GTK_POS_LEFT);
|
||||
break;
|
||||
case GTK_ARROW_RIGHT:
|
||||
gtk_popover_set_position (GTK_POPOVER (priv->popover), GTK_POS_RIGHT);
|
||||
gtk_popover_set_position (GTK_POPOVER (self->popover), GTK_POS_RIGHT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -716,23 +689,22 @@ void
|
||||
gtk_menu_button_set_direction (GtkMenuButton *menu_button,
|
||||
GtkArrowType direction)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
GtkWidget *child;
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
|
||||
if (priv->arrow_type == direction)
|
||||
if (menu_button->arrow_type == direction)
|
||||
return;
|
||||
|
||||
priv->arrow_type = direction;
|
||||
menu_button->arrow_type = direction;
|
||||
g_object_notify_by_pspec (G_OBJECT (menu_button), menu_button_props[PROP_DIRECTION]);
|
||||
|
||||
/* Is it custom content? We don't change that */
|
||||
child = gtk_bin_get_child (GTK_BIN (priv->button));
|
||||
if (priv->arrow_widget != child)
|
||||
child = gtk_bin_get_child (GTK_BIN (menu_button->button));
|
||||
if (menu_button->arrow_widget != child)
|
||||
return;
|
||||
|
||||
set_arrow_type (GTK_IMAGE (child), priv->arrow_type);
|
||||
set_arrow_type (GTK_IMAGE (child), menu_button->arrow_type);
|
||||
update_popover_direction (menu_button);
|
||||
}
|
||||
|
||||
@ -747,37 +719,35 @@ gtk_menu_button_set_direction (GtkMenuButton *menu_button,
|
||||
GtkArrowType
|
||||
gtk_menu_button_get_direction (GtkMenuButton *menu_button)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), GTK_ARROW_DOWN);
|
||||
|
||||
return priv->arrow_type;
|
||||
return menu_button->arrow_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_button_dispose (GObject *object)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (GTK_MENU_BUTTON (object));
|
||||
GtkMenuButton *self = GTK_MENU_BUTTON (object);
|
||||
|
||||
if (priv->popover)
|
||||
if (self->popover)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (priv->popover,
|
||||
g_signal_handlers_disconnect_by_func (self->popover,
|
||||
menu_deactivate_cb,
|
||||
object);
|
||||
g_signal_handlers_disconnect_by_func (priv->popover,
|
||||
g_signal_handlers_disconnect_by_func (self->popover,
|
||||
popover_destroy_cb,
|
||||
object);
|
||||
gtk_widget_unparent (priv->popover);
|
||||
priv->popover = NULL;
|
||||
gtk_widget_unparent (self->popover);
|
||||
self->popover = NULL;
|
||||
}
|
||||
|
||||
set_align_widget_pointer (GTK_MENU_BUTTON (object), NULL);
|
||||
|
||||
g_clear_object (&priv->model);
|
||||
g_clear_pointer (&priv->button, gtk_widget_unparent);
|
||||
g_clear_object (&self->model);
|
||||
g_clear_pointer (&self->button, gtk_widget_unparent);
|
||||
|
||||
if (priv->create_popup_destroy_notify)
|
||||
priv->create_popup_destroy_notify (priv->create_popup_user_data);
|
||||
if (self->create_popup_destroy_notify)
|
||||
self->create_popup_destroy_notify (self->create_popup_user_data);
|
||||
|
||||
G_OBJECT_CLASS (gtk_menu_button_parent_class)->dispose (object);
|
||||
}
|
||||
@ -797,38 +767,36 @@ void
|
||||
gtk_menu_button_set_popover (GtkMenuButton *menu_button,
|
||||
GtkWidget *popover)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
g_return_if_fail (GTK_IS_POPOVER (popover) || popover == NULL);
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (menu_button));
|
||||
|
||||
g_clear_object (&priv->model);
|
||||
g_clear_object (&menu_button->model);
|
||||
|
||||
if (priv->popover)
|
||||
if (menu_button->popover)
|
||||
{
|
||||
if (gtk_widget_get_visible (priv->popover))
|
||||
gtk_widget_hide (priv->popover);
|
||||
if (gtk_widget_get_visible (menu_button->popover))
|
||||
gtk_widget_hide (menu_button->popover);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (priv->popover,
|
||||
g_signal_handlers_disconnect_by_func (menu_button->popover,
|
||||
menu_deactivate_cb,
|
||||
menu_button);
|
||||
g_signal_handlers_disconnect_by_func (priv->popover,
|
||||
g_signal_handlers_disconnect_by_func (menu_button->popover,
|
||||
popover_destroy_cb,
|
||||
menu_button);
|
||||
|
||||
gtk_widget_unparent (priv->popover);
|
||||
gtk_widget_unparent (menu_button->popover);
|
||||
}
|
||||
|
||||
priv->popover = popover;
|
||||
menu_button->popover = popover;
|
||||
|
||||
if (popover)
|
||||
{
|
||||
gtk_widget_set_parent (priv->popover, GTK_WIDGET (menu_button));
|
||||
g_signal_connect_swapped (priv->popover, "closed",
|
||||
gtk_widget_set_parent (menu_button->popover, GTK_WIDGET (menu_button));
|
||||
g_signal_connect_swapped (menu_button->popover, "closed",
|
||||
G_CALLBACK (menu_deactivate_cb), menu_button);
|
||||
g_signal_connect_swapped (priv->popover, "destroy",
|
||||
g_signal_connect_swapped (menu_button->popover, "destroy",
|
||||
G_CALLBACK (popover_destroy_cb), menu_button);
|
||||
update_popover_direction (menu_button);
|
||||
}
|
||||
@ -853,11 +821,9 @@ gtk_menu_button_set_popover (GtkMenuButton *menu_button,
|
||||
GtkPopover *
|
||||
gtk_menu_button_get_popover (GtkMenuButton *menu_button)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
|
||||
|
||||
return GTK_POPOVER (priv->popover);
|
||||
return GTK_POPOVER (menu_button->popover);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -871,11 +837,9 @@ void
|
||||
gtk_menu_button_set_icon_name (GtkMenuButton *menu_button,
|
||||
const char *icon_name)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
|
||||
gtk_button_set_icon_name (GTK_BUTTON (priv->button), icon_name);
|
||||
gtk_button_set_icon_name (GTK_BUTTON (menu_button->button), icon_name);
|
||||
g_object_notify_by_pspec (G_OBJECT (menu_button), menu_button_props[PROP_ICON_NAME]);
|
||||
}
|
||||
|
||||
@ -890,11 +854,9 @@ gtk_menu_button_set_icon_name (GtkMenuButton *menu_button,
|
||||
const char *
|
||||
gtk_menu_button_get_icon_name (GtkMenuButton *menu_button)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
|
||||
|
||||
return gtk_button_get_icon_name (GTK_BUTTON (priv->button));
|
||||
return gtk_button_get_icon_name (GTK_BUTTON (menu_button->button));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -908,7 +870,6 @@ void
|
||||
gtk_menu_button_set_label (GtkMenuButton *menu_button,
|
||||
const char *label)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
GtkWidget *child;
|
||||
GtkWidget *box;
|
||||
GtkWidget *label_widget;
|
||||
@ -916,22 +877,22 @@ gtk_menu_button_set_label (GtkMenuButton *menu_button,
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (priv->button));
|
||||
child = gtk_bin_get_child (GTK_BIN (menu_button->button));
|
||||
if (child)
|
||||
gtk_container_remove (GTK_CONTAINER (priv->button), child);
|
||||
gtk_container_remove (GTK_CONTAINER (menu_button->button), child);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
label_widget = gtk_label_new (label);
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
gtk_label_set_xalign (GTK_LABEL (label_widget), 0);
|
||||
gtk_label_set_use_underline (GTK_LABEL (label_widget),
|
||||
gtk_button_get_use_underline (GTK_BUTTON (priv->button)));
|
||||
gtk_button_get_use_underline (GTK_BUTTON (menu_button->button)));
|
||||
gtk_widget_set_hexpand (label_widget, TRUE);
|
||||
image = gtk_image_new_from_icon_name ("pan-down-symbolic");
|
||||
gtk_container_add (GTK_CONTAINER (box), label_widget);
|
||||
gtk_container_add (GTK_CONTAINER (box), image);
|
||||
gtk_container_add (GTK_CONTAINER (priv->button), box);
|
||||
priv->label_widget = label_widget;
|
||||
gtk_container_add (GTK_CONTAINER (menu_button->button), box);
|
||||
menu_button->label_widget = label_widget;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (menu_button), menu_button_props[PROP_LABEL]);
|
||||
}
|
||||
@ -947,12 +908,11 @@ gtk_menu_button_set_label (GtkMenuButton *menu_button,
|
||||
const char *
|
||||
gtk_menu_button_get_label (GtkMenuButton *menu_button)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
GtkWidget *child;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (priv->button));
|
||||
child = gtk_bin_get_child (GTK_BIN (menu_button->button));
|
||||
if (GTK_IS_BOX (child))
|
||||
{
|
||||
child = gtk_widget_get_first_child (child);
|
||||
@ -977,14 +937,12 @@ void
|
||||
gtk_menu_button_set_relief (GtkMenuButton *menu_button,
|
||||
GtkReliefStyle relief)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
|
||||
if (relief == gtk_button_get_relief (GTK_BUTTON (priv->button)))
|
||||
if (relief == gtk_button_get_relief (GTK_BUTTON (menu_button->button)))
|
||||
return;
|
||||
|
||||
gtk_button_set_relief (GTK_BUTTON (priv->button), relief);
|
||||
gtk_button_set_relief (GTK_BUTTON (menu_button->button), relief);
|
||||
g_object_notify_by_pspec (G_OBJECT (menu_button), menu_button_props[PROP_RELIEF]);
|
||||
}
|
||||
|
||||
@ -999,11 +957,9 @@ gtk_menu_button_set_relief (GtkMenuButton *menu_button,
|
||||
GtkReliefStyle
|
||||
gtk_menu_button_get_relief (GtkMenuButton *menu_button)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), GTK_RELIEF_NORMAL);
|
||||
|
||||
return gtk_button_get_relief (GTK_BUTTON (priv->button));
|
||||
return gtk_button_get_relief (GTK_BUTTON (menu_button->button));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1015,11 +971,9 @@ gtk_menu_button_get_relief (GtkMenuButton *menu_button)
|
||||
void
|
||||
gtk_menu_button_popup (GtkMenuButton *menu_button)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (menu_button->button), TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1031,25 +985,22 @@ gtk_menu_button_popup (GtkMenuButton *menu_button)
|
||||
void
|
||||
gtk_menu_button_popdown (GtkMenuButton *menu_button)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), FALSE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (menu_button->button), FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_menu_button_add_child (GtkMenuButton *menu_button,
|
||||
GtkWidget *new_child)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
GtkWidget *child;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (priv->button));
|
||||
child = gtk_bin_get_child (GTK_BIN (menu_button->button));
|
||||
if (child)
|
||||
gtk_container_remove (GTK_CONTAINER (priv->button), child);
|
||||
gtk_container_remove (GTK_CONTAINER (menu_button->button), child);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (priv->button), new_child);
|
||||
gtk_container_add (GTK_CONTAINER (menu_button->button), new_child);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1079,16 +1030,14 @@ gtk_menu_button_set_create_popup_func (GtkMenuButton *menu_button
|
||||
gpointer user_data,
|
||||
GDestroyNotify destroy_notify)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
|
||||
if (priv->create_popup_destroy_notify)
|
||||
priv->create_popup_destroy_notify (priv->create_popup_user_data);
|
||||
if (menu_button->create_popup_destroy_notify)
|
||||
menu_button->create_popup_destroy_notify (menu_button->create_popup_user_data);
|
||||
|
||||
priv->create_popup_func = func;
|
||||
priv->create_popup_user_data = user_data;
|
||||
priv->create_popup_destroy_notify = destroy_notify;
|
||||
menu_button->create_popup_func = func;
|
||||
menu_button->create_popup_user_data = user_data;
|
||||
menu_button->create_popup_destroy_notify = destroy_notify;
|
||||
|
||||
update_sensitivity (menu_button);
|
||||
}
|
||||
@ -1097,16 +1046,14 @@ void
|
||||
gtk_menu_button_set_use_underline (GtkMenuButton *menu_button,
|
||||
gboolean use_underline)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
|
||||
|
||||
if (gtk_button_get_use_underline (GTK_BUTTON (priv->button)) == use_underline)
|
||||
if (gtk_button_get_use_underline (GTK_BUTTON (menu_button->button)) == use_underline)
|
||||
return;
|
||||
|
||||
gtk_button_set_use_underline (GTK_BUTTON (priv->button), use_underline);
|
||||
if (priv->label_widget)
|
||||
gtk_label_set_use_underline (GTK_LABEL (priv->label_widget), use_underline);
|
||||
gtk_button_set_use_underline (GTK_BUTTON (menu_button->button), use_underline);
|
||||
if (menu_button->label_widget)
|
||||
gtk_label_set_use_underline (GTK_LABEL (menu_button->label_widget), use_underline);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (menu_button), menu_button_props[PROP_USE_UNDERLINE]);
|
||||
}
|
||||
@ -1114,9 +1061,7 @@ gtk_menu_button_set_use_underline (GtkMenuButton *menu_button,
|
||||
gboolean
|
||||
gtk_menu_button_get_use_underline (GtkMenuButton *menu_button)
|
||||
{
|
||||
GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), FALSE);
|
||||
|
||||
return gtk_button_get_use_underline (GTK_BUTTON (priv->button));
|
||||
return gtk_button_get_use_underline (GTK_BUTTON (menu_button->button));
|
||||
}
|
||||
|
@ -101,6 +101,16 @@ typedef struct _GtkSearchEntryClass GtkSearchEntryClass;
|
||||
struct _GtkSearchEntry
|
||||
{
|
||||
GtkWidget parent;
|
||||
|
||||
GtkWidget *capture_widget;
|
||||
GtkEventController *capture_widget_controller;
|
||||
|
||||
GtkWidget *entry;
|
||||
GtkWidget *icon;
|
||||
|
||||
guint delayed_changed_id;
|
||||
gboolean content_changed;
|
||||
gboolean search_stopped;
|
||||
};
|
||||
|
||||
struct _GtkSearchEntryClass
|
||||
@ -114,22 +124,9 @@ struct _GtkSearchEntryClass
|
||||
void (* stop_search) (GtkSearchEntry *entry);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
GtkWidget *capture_widget;
|
||||
GtkEventController *capture_widget_controller;
|
||||
|
||||
GtkWidget *entry;
|
||||
GtkWidget *icon;
|
||||
|
||||
guint delayed_changed_id;
|
||||
gboolean content_changed;
|
||||
gboolean search_stopped;
|
||||
} GtkSearchEntryPrivate;
|
||||
|
||||
static void gtk_search_entry_editable_init (GtkEditableInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkSearchEntry, gtk_search_entry, GTK_TYPE_WIDGET,
|
||||
G_ADD_PRIVATE (GtkSearchEntry)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
|
||||
gtk_search_entry_editable_init))
|
||||
|
||||
@ -139,24 +136,21 @@ G_DEFINE_TYPE_WITH_CODE (GtkSearchEntry, gtk_search_entry, GTK_TYPE_WIDGET,
|
||||
static void
|
||||
text_changed (GtkSearchEntry *entry)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
priv->content_changed = TRUE;
|
||||
entry->content_changed = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_search_entry_finalize (GObject *object)
|
||||
{
|
||||
GtkSearchEntry *entry = GTK_SEARCH_ENTRY (object);
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
gtk_editable_finish_delegate (GTK_EDITABLE (entry));
|
||||
|
||||
g_clear_pointer (&priv->entry, gtk_widget_unparent);
|
||||
g_clear_pointer (&priv->icon, gtk_widget_unparent);
|
||||
g_clear_pointer (&entry->entry, gtk_widget_unparent);
|
||||
g_clear_pointer (&entry->icon, gtk_widget_unparent);
|
||||
|
||||
if (priv->delayed_changed_id > 0)
|
||||
g_source_remove (priv->delayed_changed_id);
|
||||
if (entry->delayed_changed_id > 0)
|
||||
g_source_remove (entry->delayed_changed_id);
|
||||
|
||||
gtk_search_entry_set_key_capture_widget (GTK_SEARCH_ENTRY (object), NULL);
|
||||
|
||||
@ -166,9 +160,7 @@ gtk_search_entry_finalize (GObject *object)
|
||||
static void
|
||||
gtk_search_entry_stop_search (GtkSearchEntry *entry)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
priv->search_stopped = TRUE;
|
||||
entry->search_stopped = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -178,7 +170,6 @@ gtk_search_entry_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkSearchEntry *entry = GTK_SEARCH_ENTRY (object);
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
if (gtk_editable_delegate_set_property (object, prop_id, value, pspec))
|
||||
return;
|
||||
@ -186,13 +177,13 @@ gtk_search_entry_set_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_PLACEHOLDER_TEXT:
|
||||
gtk_text_set_placeholder_text (GTK_TEXT (priv->entry), g_value_get_string (value));
|
||||
gtk_text_set_placeholder_text (GTK_TEXT (entry->entry), g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_ACTIVATES_DEFAULT:
|
||||
if (gtk_text_get_activates_default (GTK_TEXT (priv->entry)) != g_value_get_boolean (value))
|
||||
if (gtk_text_get_activates_default (GTK_TEXT (entry->entry)) != g_value_get_boolean (value))
|
||||
{
|
||||
gtk_text_set_activates_default (GTK_TEXT (priv->entry), g_value_get_boolean (value));
|
||||
gtk_text_set_activates_default (GTK_TEXT (entry->entry), g_value_get_boolean (value));
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
}
|
||||
break;
|
||||
@ -209,7 +200,6 @@ gtk_search_entry_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkSearchEntry *entry = GTK_SEARCH_ENTRY (object);
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
if (gtk_editable_delegate_get_property (object, prop_id, value, pspec))
|
||||
return;
|
||||
@ -217,11 +207,11 @@ gtk_search_entry_get_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_PLACEHOLDER_TEXT:
|
||||
g_value_set_string (value, gtk_text_get_placeholder_text (GTK_TEXT (priv->entry)));
|
||||
g_value_set_string (value, gtk_text_get_placeholder_text (GTK_TEXT (entry->entry)));
|
||||
break;
|
||||
|
||||
case PROP_ACTIVATES_DEFAULT:
|
||||
g_value_set_boolean (value, gtk_text_get_activates_default (GTK_TEXT (priv->entry)));
|
||||
g_value_set_boolean (value, gtk_text_get_activates_default (GTK_TEXT (entry->entry)));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -244,9 +234,8 @@ static gboolean
|
||||
gtk_search_entry_grab_focus (GtkWidget *widget)
|
||||
{
|
||||
GtkSearchEntry *entry = GTK_SEARCH_ENTRY (widget);
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
return gtk_text_grab_focus_without_selecting (GTK_TEXT (priv->entry));
|
||||
return gtk_text_grab_focus_without_selecting (GTK_TEXT (entry->entry));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -254,9 +243,8 @@ gtk_search_entry_mnemonic_activate (GtkWidget *widget,
|
||||
gboolean group_cycling)
|
||||
{
|
||||
GtkSearchEntry *entry = GTK_SEARCH_ENTRY (widget);
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
gtk_widget_grab_focus (priv->entry);
|
||||
gtk_widget_grab_focus (entry->entry);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -420,10 +408,7 @@ gtk_search_entry_class_init (GtkSearchEntryClass *klass)
|
||||
static GtkEditable *
|
||||
gtk_search_entry_get_delegate (GtkEditable *editable)
|
||||
{
|
||||
GtkSearchEntry *entry = GTK_SEARCH_ENTRY (editable);
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
return GTK_EDITABLE (priv->entry);
|
||||
return GTK_EDITABLE (GTK_SEARCH_ENTRY (editable)->entry);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -439,19 +424,16 @@ gtk_search_entry_icon_release (GtkGestureClick *press,
|
||||
double y,
|
||||
GtkSearchEntry *entry)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
gtk_editable_set_text (GTK_EDITABLE (priv->entry), "");
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry->entry), "");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_search_entry_changed_timeout_cb (gpointer user_data)
|
||||
{
|
||||
GtkSearchEntry *entry = user_data;
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
g_signal_emit (entry, signals[SEARCH_CHANGED], 0);
|
||||
priv->delayed_changed_id = 0;
|
||||
entry->delayed_changed_id = 0;
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
@ -459,40 +441,37 @@ gtk_search_entry_changed_timeout_cb (gpointer user_data)
|
||||
static void
|
||||
reset_timeout (GtkSearchEntry *entry)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
if (priv->delayed_changed_id > 0)
|
||||
g_source_remove (priv->delayed_changed_id);
|
||||
priv->delayed_changed_id = g_timeout_add (DELAYED_TIMEOUT_ID,
|
||||
if (entry->delayed_changed_id > 0)
|
||||
g_source_remove (entry->delayed_changed_id);
|
||||
entry->delayed_changed_id = g_timeout_add (DELAYED_TIMEOUT_ID,
|
||||
gtk_search_entry_changed_timeout_cb,
|
||||
entry);
|
||||
g_source_set_name_by_id (priv->delayed_changed_id, "[gtk] gtk_search_entry_changed_timeout_cb");
|
||||
g_source_set_name_by_id (entry->delayed_changed_id, "[gtk] gtk_search_entry_changed_timeout_cb");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_search_entry_changed (GtkEditable *editable,
|
||||
gtk_search_entry_changed (GtkEditable *editable,
|
||||
GtkSearchEntry *entry)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
const char *str;
|
||||
|
||||
/* Update the icons first */
|
||||
str = gtk_editable_get_text (GTK_EDITABLE (priv->entry));
|
||||
str = gtk_editable_get_text (GTK_EDITABLE (entry->entry));
|
||||
|
||||
if (str == NULL || *str == '\0')
|
||||
{
|
||||
gtk_widget_set_child_visible (priv->icon, FALSE);
|
||||
gtk_widget_set_child_visible (entry->icon, FALSE);
|
||||
|
||||
if (priv->delayed_changed_id > 0)
|
||||
if (entry->delayed_changed_id > 0)
|
||||
{
|
||||
g_source_remove (priv->delayed_changed_id);
|
||||
priv->delayed_changed_id = 0;
|
||||
g_source_remove (entry->delayed_changed_id);
|
||||
entry->delayed_changed_id = 0;
|
||||
}
|
||||
g_signal_emit (entry, signals[SEARCH_CHANGED], 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_child_visible (priv->icon, TRUE);
|
||||
gtk_widget_set_child_visible (entry->icon, TRUE);
|
||||
|
||||
/* Queue up the timeout */
|
||||
reset_timeout (entry);
|
||||
@ -520,27 +499,26 @@ activate_cb (GtkText *text,
|
||||
static void
|
||||
gtk_search_entry_init (GtkSearchEntry *entry)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
GtkGesture *press;
|
||||
|
||||
priv->entry = gtk_text_new ();
|
||||
gtk_widget_set_parent (priv->entry, GTK_WIDGET (entry));
|
||||
gtk_widget_set_hexpand (priv->entry, TRUE);
|
||||
entry->entry = gtk_text_new ();
|
||||
gtk_widget_set_parent (entry->entry, GTK_WIDGET (entry));
|
||||
gtk_widget_set_hexpand (entry->entry, TRUE);
|
||||
gtk_editable_init_delegate (GTK_EDITABLE (entry));
|
||||
g_signal_connect_swapped (priv->entry, "changed", G_CALLBACK (text_changed), entry);
|
||||
g_signal_connect_after (priv->entry, "changed", G_CALLBACK (gtk_search_entry_changed), entry);
|
||||
g_signal_connect_swapped (priv->entry, "preedit-changed", G_CALLBACK (text_changed), entry);
|
||||
g_signal_connect (priv->entry, "notify", G_CALLBACK (notify_cb), entry);
|
||||
g_signal_connect (priv->entry, "activate", G_CALLBACK (activate_cb), entry);
|
||||
g_signal_connect_swapped (entry->entry, "changed", G_CALLBACK (text_changed), entry);
|
||||
g_signal_connect_after (entry->entry, "changed", G_CALLBACK (gtk_search_entry_changed), entry);
|
||||
g_signal_connect_swapped (entry->entry, "preedit-changed", G_CALLBACK (text_changed), entry);
|
||||
g_signal_connect (entry->entry, "notify", G_CALLBACK (notify_cb), entry);
|
||||
g_signal_connect (entry->entry, "activate", G_CALLBACK (activate_cb), entry);
|
||||
|
||||
priv->icon = gtk_image_new_from_icon_name ("edit-clear-all-symbolic");
|
||||
gtk_widget_set_tooltip_text (priv->icon, _("Clear entry"));
|
||||
gtk_widget_set_parent (priv->icon, GTK_WIDGET (entry));
|
||||
gtk_widget_set_child_visible (priv->icon, FALSE);
|
||||
entry->icon = gtk_image_new_from_icon_name ("edit-clear-all-symbolic");
|
||||
gtk_widget_set_tooltip_text (entry->icon, _("Clear entry"));
|
||||
gtk_widget_set_parent (entry->icon, GTK_WIDGET (entry));
|
||||
gtk_widget_set_child_visible (entry->icon, FALSE);
|
||||
|
||||
press = gtk_gesture_click_new ();
|
||||
g_signal_connect (press, "released", G_CALLBACK (gtk_search_entry_icon_release), entry);
|
||||
gtk_widget_add_controller (priv->icon, GTK_EVENT_CONTROLLER (press));
|
||||
gtk_widget_add_controller (entry->icon, GTK_EVENT_CONTROLLER (press));
|
||||
|
||||
gtk_widget_add_css_class (GTK_WIDGET (entry), I_("search"));
|
||||
}
|
||||
@ -586,9 +564,9 @@ capture_widget_key_handled (GtkEventControllerKey *controller,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
GtkWidget *entry)
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (GTK_SEARCH_ENTRY (entry));
|
||||
GtkSearchEntry *entry = GTK_SEARCH_ENTRY (widget);
|
||||
gboolean handled, was_empty;
|
||||
|
||||
if (gtk_search_entry_is_keynav (keyval, state) ||
|
||||
@ -596,13 +574,13 @@ capture_widget_key_handled (GtkEventControllerKey *controller,
|
||||
keyval == GDK_KEY_Menu)
|
||||
return FALSE;
|
||||
|
||||
priv->content_changed = FALSE;
|
||||
priv->search_stopped = FALSE;
|
||||
was_empty = (gtk_text_get_text_length (GTK_TEXT (priv->entry)) == 0);
|
||||
entry->content_changed = FALSE;
|
||||
entry->search_stopped = FALSE;
|
||||
was_empty = (gtk_text_get_text_length (GTK_TEXT (entry->entry)) == 0);
|
||||
|
||||
handled = gtk_event_controller_key_forward (controller, priv->entry);
|
||||
handled = gtk_event_controller_key_forward (controller, entry->entry);
|
||||
|
||||
if (handled && priv->content_changed && !priv->search_stopped)
|
||||
if (handled && entry->content_changed && !entry->search_stopped)
|
||||
{
|
||||
if (was_empty)
|
||||
g_signal_emit (entry, signals[SEARCH_STARTED], 0);
|
||||
@ -631,34 +609,32 @@ void
|
||||
gtk_search_entry_set_key_capture_widget (GtkSearchEntry *entry,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
g_return_if_fail (GTK_IS_SEARCH_ENTRY (entry));
|
||||
g_return_if_fail (!widget || GTK_IS_WIDGET (widget));
|
||||
|
||||
if (priv->capture_widget)
|
||||
if (entry->capture_widget)
|
||||
{
|
||||
gtk_widget_remove_controller (priv->capture_widget,
|
||||
priv->capture_widget_controller);
|
||||
g_object_remove_weak_pointer (G_OBJECT (priv->capture_widget),
|
||||
(gpointer *) &priv->capture_widget);
|
||||
gtk_widget_remove_controller (entry->capture_widget,
|
||||
entry->capture_widget_controller);
|
||||
g_object_remove_weak_pointer (G_OBJECT (entry->capture_widget),
|
||||
(gpointer *) &entry->capture_widget);
|
||||
}
|
||||
|
||||
priv->capture_widget = widget;
|
||||
entry->capture_widget = widget;
|
||||
|
||||
if (widget)
|
||||
{
|
||||
g_object_add_weak_pointer (G_OBJECT (priv->capture_widget),
|
||||
(gpointer *) &priv->capture_widget);
|
||||
g_object_add_weak_pointer (G_OBJECT (entry->capture_widget),
|
||||
(gpointer *) &entry->capture_widget);
|
||||
|
||||
priv->capture_widget_controller = gtk_event_controller_key_new ();
|
||||
gtk_event_controller_set_propagation_phase (priv->capture_widget_controller,
|
||||
entry->capture_widget_controller = gtk_event_controller_key_new ();
|
||||
gtk_event_controller_set_propagation_phase (entry->capture_widget_controller,
|
||||
GTK_PHASE_CAPTURE);
|
||||
g_signal_connect (priv->capture_widget_controller, "key-pressed",
|
||||
g_signal_connect (entry->capture_widget_controller, "key-pressed",
|
||||
G_CALLBACK (capture_widget_key_handled), entry);
|
||||
g_signal_connect (priv->capture_widget_controller, "key-released",
|
||||
g_signal_connect (entry->capture_widget_controller, "key-released",
|
||||
G_CALLBACK (capture_widget_key_handled), entry);
|
||||
gtk_widget_add_controller (widget, priv->capture_widget_controller);
|
||||
gtk_widget_add_controller (widget, entry->capture_widget_controller);
|
||||
}
|
||||
}
|
||||
|
||||
@ -673,25 +649,19 @@ gtk_search_entry_set_key_capture_widget (GtkSearchEntry *entry,
|
||||
GtkWidget *
|
||||
gtk_search_entry_get_key_capture_widget (GtkSearchEntry *entry)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SEARCH_ENTRY (entry), NULL);
|
||||
|
||||
return priv->capture_widget;
|
||||
return entry->capture_widget;
|
||||
}
|
||||
|
||||
GtkEventController *
|
||||
gtk_search_entry_get_key_controller (GtkSearchEntry *entry)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
return gtk_text_get_key_controller (GTK_TEXT (priv->entry));
|
||||
return gtk_text_get_key_controller (GTK_TEXT (entry->entry));
|
||||
}
|
||||
|
||||
GtkText *
|
||||
gtk_search_entry_get_text_widget (GtkSearchEntry *entry)
|
||||
{
|
||||
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
|
||||
|
||||
return GTK_TEXT (priv->entry);
|
||||
return GTK_TEXT (entry->entry);
|
||||
}
|
||||
|
@ -101,25 +101,13 @@
|
||||
#define DEFAULT_TIMEOUT_EXPAND 500
|
||||
|
||||
typedef struct _GtkSettingsClass GtkSettingsClass;
|
||||
|
||||
struct _GtkSettingsClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
typedef struct _GtkSettingsPropertyValue GtkSettingsPropertyValue;
|
||||
typedef struct _GtkSettingsValuePrivate GtkSettingsValuePrivate;
|
||||
|
||||
typedef struct _GtkSettingsPrivate GtkSettingsPrivate;
|
||||
|
||||
struct _GtkSettingsPrivate
|
||||
struct _GtkSettings
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GData *queued_settings; /* of type GtkSettingsValue* */
|
||||
GtkSettingsPropertyValue *property_values;
|
||||
GdkDisplay *display;
|
||||
@ -131,6 +119,11 @@ struct _GtkSettingsPrivate
|
||||
cairo_font_options_t *font_options;
|
||||
};
|
||||
|
||||
struct _GtkSettingsClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
struct _GtkSettingsValuePrivate
|
||||
{
|
||||
GtkSettingsValue public;
|
||||
@ -239,7 +232,6 @@ static GPtrArray *display_settings;
|
||||
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (GtkSettings, gtk_settings, G_TYPE_OBJECT, 0,
|
||||
G_ADD_PRIVATE (GtkSettings)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER,
|
||||
gtk_settings_provider_iface_init));
|
||||
|
||||
@ -247,19 +239,16 @@ G_DEFINE_TYPE_EXTENDED (GtkSettings, gtk_settings, G_TYPE_OBJECT, 0,
|
||||
static void
|
||||
gtk_settings_init (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv;
|
||||
GParamSpec **pspecs, **p;
|
||||
guint i = 0;
|
||||
gchar *path;
|
||||
const gchar * const *config_dirs;
|
||||
|
||||
priv = gtk_settings_get_instance_private (settings);
|
||||
|
||||
g_datalist_init (&priv->queued_settings);
|
||||
g_datalist_init (&settings->queued_settings);
|
||||
object_list = g_slist_prepend (object_list, settings);
|
||||
|
||||
priv->style_cascades = g_slist_prepend (NULL, _gtk_style_cascade_new ());
|
||||
priv->theme_provider = gtk_css_provider_new ();
|
||||
settings->style_cascades = g_slist_prepend (NULL, _gtk_style_cascade_new ());
|
||||
settings->theme_provider = gtk_css_provider_new ();
|
||||
|
||||
/* build up property array for all yet existing properties and queue
|
||||
* notification for them (at least notification for internal properties
|
||||
@ -269,7 +258,7 @@ gtk_settings_init (GtkSettings *settings)
|
||||
for (p = pspecs; *p; p++)
|
||||
if ((*p)->owner_type == G_OBJECT_TYPE (settings))
|
||||
i++;
|
||||
priv->property_values = g_new0 (GtkSettingsPropertyValue, i);
|
||||
settings->property_values = g_new0 (GtkSettingsPropertyValue, i);
|
||||
i = 0;
|
||||
g_object_freeze_notify (G_OBJECT (settings));
|
||||
|
||||
@ -280,11 +269,11 @@ gtk_settings_init (GtkSettings *settings)
|
||||
|
||||
if (pspec->owner_type != G_OBJECT_TYPE (settings))
|
||||
continue;
|
||||
g_value_init (&priv->property_values[i].value, value_type);
|
||||
g_param_value_set_default (pspec, &priv->property_values[i].value);
|
||||
g_value_init (&settings->property_values[i].value, value_type);
|
||||
g_param_value_set_default (pspec, &settings->property_values[i].value);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (settings), pspec);
|
||||
priv->property_values[i].source = GTK_SETTINGS_SOURCE_DEFAULT;
|
||||
settings->property_values[i].source = GTK_SETTINGS_SOURCE_DEFAULT;
|
||||
i++;
|
||||
}
|
||||
g_free (pspecs);
|
||||
@ -316,7 +305,7 @@ gtk_settings_init (GtkSettings *settings)
|
||||
g_object_thaw_notify (G_OBJECT (settings));
|
||||
|
||||
/* ensure that derived fields are initialized */
|
||||
if (priv->font_size == 0)
|
||||
if (settings->font_size == 0)
|
||||
settings_update_font_values (settings);
|
||||
}
|
||||
|
||||
@ -983,24 +972,23 @@ static void
|
||||
gtk_settings_finalize (GObject *object)
|
||||
{
|
||||
GtkSettings *settings = GTK_SETTINGS (object);
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
guint i;
|
||||
|
||||
object_list = g_slist_remove (object_list, settings);
|
||||
|
||||
for (i = 0; i < class_n_properties; i++)
|
||||
g_value_unset (&priv->property_values[i].value);
|
||||
g_free (priv->property_values);
|
||||
g_value_unset (&settings->property_values[i].value);
|
||||
g_free (settings->property_values);
|
||||
|
||||
g_datalist_clear (&priv->queued_settings);
|
||||
g_datalist_clear (&settings->queued_settings);
|
||||
|
||||
settings_update_provider (priv->display, &priv->theme_provider, NULL);
|
||||
g_slist_free_full (priv->style_cascades, g_object_unref);
|
||||
settings_update_provider (settings->display, &settings->theme_provider, NULL);
|
||||
g_slist_free_full (settings->style_cascades, g_object_unref);
|
||||
|
||||
if (priv->font_options)
|
||||
cairo_font_options_destroy (priv->font_options);
|
||||
if (settings->font_options)
|
||||
cairo_font_options_destroy (settings->font_options);
|
||||
|
||||
g_free (priv->font_family);
|
||||
g_free (settings->font_family);
|
||||
|
||||
G_OBJECT_CLASS (gtk_settings_parent_class)->finalize (object);
|
||||
}
|
||||
@ -1009,13 +997,12 @@ GtkStyleCascade *
|
||||
_gtk_settings_get_style_cascade (GtkSettings *settings,
|
||||
gint scale)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
GtkStyleCascade *new_cascade;
|
||||
GSList *list;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SETTINGS (settings), NULL);
|
||||
|
||||
for (list = priv->style_cascades; list; list = list->next)
|
||||
for (list = settings->style_cascades; list; list = list->next)
|
||||
{
|
||||
if (_gtk_style_cascade_get_scale (list->data) == scale)
|
||||
return list->data;
|
||||
@ -1030,7 +1017,7 @@ _gtk_settings_get_style_cascade (GtkSettings *settings,
|
||||
_gtk_style_cascade_set_parent (new_cascade, _gtk_settings_get_style_cascade (settings, 1));
|
||||
_gtk_style_cascade_set_scale (new_cascade, scale);
|
||||
|
||||
priv->style_cascades = g_slist_prepend (priv->style_cascades, new_cascade);
|
||||
settings->style_cascades = g_slist_prepend (settings->style_cascades, new_cascade);
|
||||
|
||||
return new_cascade;
|
||||
}
|
||||
@ -1038,7 +1025,6 @@ _gtk_settings_get_style_cascade (GtkSettings *settings,
|
||||
static void
|
||||
settings_init_style (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
static GtkCssProvider *css_provider = NULL;
|
||||
GtkStyleCascade *cascade;
|
||||
|
||||
@ -1070,7 +1056,7 @@ settings_init_style (GtkSettings *settings)
|
||||
GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
|
||||
|
||||
_gtk_style_cascade_add_provider (cascade,
|
||||
GTK_STYLE_PROVIDER (priv->theme_provider),
|
||||
GTK_STYLE_PROVIDER (settings->theme_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
|
||||
|
||||
settings_update_theme (settings);
|
||||
@ -1097,7 +1083,6 @@ static GtkSettings *
|
||||
gtk_settings_create_for_display (GdkDisplay *display)
|
||||
{
|
||||
GtkSettings *settings;
|
||||
GtkSettingsPrivate *priv;
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
if (GDK_IS_QUARTZ_DISPLAY (display))
|
||||
@ -1110,9 +1095,7 @@ gtk_settings_create_for_display (GdkDisplay *display)
|
||||
#endif
|
||||
settings = g_object_new (GTK_TYPE_SETTINGS, NULL);
|
||||
|
||||
priv = gtk_settings_get_instance_private (settings);
|
||||
|
||||
priv->display = display;
|
||||
settings->display = display;
|
||||
|
||||
g_signal_connect_object (display, "setting-changed", G_CALLBACK (setting_changed), settings, 0);
|
||||
|
||||
@ -1149,8 +1132,7 @@ gtk_settings_get_for_display (GdkDisplay *display)
|
||||
for (i = 0; i < display_settings->len; i++)
|
||||
{
|
||||
GtkSettings *settings = g_ptr_array_index (display_settings, i);
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
if (priv->display == display)
|
||||
if (settings->display == display)
|
||||
return settings;
|
||||
}
|
||||
|
||||
@ -1186,10 +1168,9 @@ gtk_settings_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkSettings *settings = GTK_SETTINGS (object);
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
|
||||
g_value_copy (value, &priv->property_values[property_id - 1].value);
|
||||
priv->property_values[property_id - 1].source = GTK_SETTINGS_SOURCE_APPLICATION;
|
||||
g_value_copy (value, &settings->property_values[property_id - 1].value);
|
||||
settings->property_values[property_id - 1].source = GTK_SETTINGS_SOURCE_APPLICATION;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1201,35 +1182,34 @@ settings_invalidate_style (GtkSettings *settings)
|
||||
static void
|
||||
settings_update_font_values (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
PangoFontDescription *desc;
|
||||
const gchar *font_name;
|
||||
|
||||
font_name = g_value_get_string (&priv->property_values[PROP_FONT_NAME - 1].value);
|
||||
font_name = g_value_get_string (&settings->property_values[PROP_FONT_NAME - 1].value);
|
||||
desc = pango_font_description_from_string (font_name);
|
||||
|
||||
if (desc != NULL &&
|
||||
(pango_font_description_get_set_fields (desc) & PANGO_FONT_MASK_SIZE) != 0)
|
||||
{
|
||||
priv->font_size = pango_font_description_get_size (desc);
|
||||
priv->font_size_absolute = pango_font_description_get_size_is_absolute (desc);
|
||||
settings->font_size = pango_font_description_get_size (desc);
|
||||
settings->font_size_absolute = pango_font_description_get_size_is_absolute (desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->font_size = 10 * PANGO_SCALE;
|
||||
priv->font_size_absolute = FALSE;
|
||||
settings->font_size = 10 * PANGO_SCALE;
|
||||
settings->font_size_absolute = FALSE;
|
||||
}
|
||||
|
||||
g_free (priv->font_family);
|
||||
g_free (settings->font_family);
|
||||
|
||||
if (desc != NULL &&
|
||||
(pango_font_description_get_set_fields (desc) & PANGO_FONT_MASK_FAMILY) != 0)
|
||||
{
|
||||
priv->font_family = g_strdup (pango_font_description_get_family (desc));
|
||||
settings->font_family = g_strdup (pango_font_description_get_family (desc));
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->font_family = g_strdup ("Sans");
|
||||
settings->font_family = g_strdup ("Sans");
|
||||
}
|
||||
|
||||
if (desc)
|
||||
@ -1241,10 +1221,9 @@ gtk_settings_notify (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkSettings *settings = GTK_SETTINGS (object);
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
guint property_id = pspec->param_id;
|
||||
|
||||
if (priv->display == NULL) /* initialization */
|
||||
if (settings->display == NULL) /* initialization */
|
||||
return;
|
||||
|
||||
switch (property_id)
|
||||
@ -1256,7 +1235,7 @@ gtk_settings_notify (GObject *object,
|
||||
case PROP_FONT_NAME:
|
||||
settings_update_font_values (settings);
|
||||
settings_invalidate_style (settings);
|
||||
gtk_style_context_reset_widgets (priv->display);
|
||||
gtk_style_context_reset_widgets (settings->display);
|
||||
break;
|
||||
case PROP_THEME_NAME:
|
||||
case PROP_APPLICATION_PREFER_DARK_THEME:
|
||||
@ -1267,21 +1246,21 @@ gtk_settings_notify (GObject *object,
|
||||
* widgets with gtk_widget_style_set(), and also causes more
|
||||
* recomputation than necessary.
|
||||
*/
|
||||
gtk_style_context_reset_widgets (priv->display);
|
||||
gtk_style_context_reset_widgets (settings->display);
|
||||
break;
|
||||
case PROP_XFT_ANTIALIAS:
|
||||
case PROP_XFT_HINTING:
|
||||
case PROP_XFT_HINTSTYLE:
|
||||
case PROP_XFT_RGBA:
|
||||
settings_update_font_options (settings);
|
||||
gtk_style_context_reset_widgets (priv->display);
|
||||
gtk_style_context_reset_widgets (settings->display);
|
||||
break;
|
||||
case PROP_FONTCONFIG_TIMESTAMP:
|
||||
if (settings_update_fontconfig (settings))
|
||||
gtk_style_context_reset_widgets (priv->display);
|
||||
gtk_style_context_reset_widgets (settings->display);
|
||||
break;
|
||||
case PROP_ENABLE_ANIMATIONS:
|
||||
gtk_style_context_reset_widgets (priv->display);
|
||||
gtk_style_context_reset_widgets (settings->display);
|
||||
break;
|
||||
case PROP_CURSOR_THEME_NAME:
|
||||
case PROP_CURSOR_THEME_SIZE:
|
||||
@ -1322,17 +1301,16 @@ apply_queued_setting (GtkSettings *settings,
|
||||
GParamSpec *pspec,
|
||||
GtkSettingsValuePrivate *qvalue)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
GValue tmp_value = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
if (_gtk_settings_parse_convert (&qvalue->public.value,
|
||||
pspec, &tmp_value))
|
||||
{
|
||||
if (priv->property_values[pspec->param_id - 1].source <= qvalue->source)
|
||||
if (settings->property_values[pspec->param_id - 1].source <= qvalue->source)
|
||||
{
|
||||
g_value_copy (&tmp_value, &priv->property_values[pspec->param_id - 1].value);
|
||||
priv->property_values[pspec->param_id - 1].source = qvalue->source;
|
||||
g_value_copy (&tmp_value, &settings->property_values[pspec->param_id - 1].value);
|
||||
settings->property_values[pspec->param_id - 1].source = qvalue->source;
|
||||
g_object_notify_by_pspec (G_OBJECT (settings), pspec);
|
||||
}
|
||||
|
||||
@ -1393,17 +1371,16 @@ settings_install_property_parser (GtkSettingsClass *class,
|
||||
for (node = object_list; node; node = node->next)
|
||||
{
|
||||
GtkSettings *settings = node->data;
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
GtkSettingsValuePrivate *qvalue;
|
||||
|
||||
priv->property_values = g_renew (GtkSettingsPropertyValue, priv->property_values, class_n_properties);
|
||||
priv->property_values[class_n_properties - 1].value.g_type = 0;
|
||||
g_value_init (&priv->property_values[class_n_properties - 1].value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
g_param_value_set_default (pspec, &priv->property_values[class_n_properties - 1].value);
|
||||
priv->property_values[class_n_properties - 1].source = GTK_SETTINGS_SOURCE_DEFAULT;
|
||||
settings->property_values = g_renew (GtkSettingsPropertyValue, settings->property_values, class_n_properties);
|
||||
settings->property_values[class_n_properties - 1].value.g_type = 0;
|
||||
g_value_init (&settings->property_values[class_n_properties - 1].value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
g_param_value_set_default (pspec, &settings->property_values[class_n_properties - 1].value);
|
||||
settings->property_values[class_n_properties - 1].source = GTK_SETTINGS_SOURCE_DEFAULT;
|
||||
g_object_notify_by_pspec (G_OBJECT (settings), pspec);
|
||||
|
||||
qvalue = g_datalist_id_dup_data (&priv->queued_settings, g_param_spec_get_name_quark (pspec), NULL, NULL);
|
||||
qvalue = g_datalist_id_dup_data (&settings->queued_settings, g_param_spec_get_name_quark (pspec), NULL, NULL);
|
||||
if (qvalue)
|
||||
apply_queued_setting (settings, pspec, qvalue);
|
||||
}
|
||||
@ -1433,7 +1410,6 @@ gtk_settings_set_property_value_internal (GtkSettings *settings,
|
||||
const GtkSettingsValue *new_value,
|
||||
GtkSettingsSource source)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
GtkSettingsValuePrivate *qvalue;
|
||||
GParamSpec *pspec;
|
||||
gchar *name;
|
||||
@ -1453,11 +1429,11 @@ gtk_settings_set_property_value_internal (GtkSettings *settings,
|
||||
name_quark = g_quark_from_string (name);
|
||||
g_free (name);
|
||||
|
||||
qvalue = g_datalist_id_dup_data (&priv->queued_settings, name_quark, NULL, NULL);
|
||||
qvalue = g_datalist_id_dup_data (&settings->queued_settings, name_quark, NULL, NULL);
|
||||
if (!qvalue)
|
||||
{
|
||||
qvalue = g_slice_new0 (GtkSettingsValuePrivate);
|
||||
g_datalist_id_set_data_full (&priv->queued_settings, name_quark, qvalue, free_value);
|
||||
g_datalist_id_set_data_full (&settings->queued_settings, name_quark, qvalue, free_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1476,7 +1452,6 @@ gtk_settings_set_property_value_internal (GtkSettings *settings,
|
||||
static void
|
||||
settings_update_double_click (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
gint double_click_time;
|
||||
gint double_click_distance;
|
||||
|
||||
@ -1485,14 +1460,13 @@ settings_update_double_click (GtkSettings *settings)
|
||||
"gtk-double-click-distance", &double_click_distance,
|
||||
NULL);
|
||||
|
||||
gdk_display_set_double_click_time (priv->display, double_click_time);
|
||||
gdk_display_set_double_click_distance (priv->display, double_click_distance);
|
||||
gdk_display_set_double_click_time (settings->display, double_click_time);
|
||||
gdk_display_set_double_click_distance (settings->display, double_click_distance);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_update_cursor_theme (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
gchar *theme = NULL;
|
||||
gint size = 0;
|
||||
|
||||
@ -1502,7 +1476,7 @@ settings_update_cursor_theme (GtkSettings *settings)
|
||||
NULL);
|
||||
if (theme)
|
||||
{
|
||||
gdk_display_set_cursor_theme (priv->display, theme, size);
|
||||
gdk_display_set_cursor_theme (settings->display, theme, size);
|
||||
g_free (theme);
|
||||
}
|
||||
}
|
||||
@ -1510,7 +1484,6 @@ settings_update_cursor_theme (GtkSettings *settings)
|
||||
static void
|
||||
settings_update_font_options (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
gint hinting;
|
||||
gchar *hint_style_str;
|
||||
cairo_hint_style_t hint_style;
|
||||
@ -1519,8 +1492,8 @@ settings_update_font_options (GtkSettings *settings)
|
||||
gchar *rgba_str;
|
||||
cairo_subpixel_order_t subpixel_order;
|
||||
|
||||
if (priv->font_options)
|
||||
cairo_font_options_destroy (priv->font_options);
|
||||
if (settings->font_options)
|
||||
cairo_font_options_destroy (settings->font_options);
|
||||
|
||||
g_object_get (settings,
|
||||
"gtk-xft-antialias", &antialias,
|
||||
@ -1529,9 +1502,9 @@ settings_update_font_options (GtkSettings *settings)
|
||||
"gtk-xft-rgba", &rgba_str,
|
||||
NULL);
|
||||
|
||||
priv->font_options = cairo_font_options_create ();
|
||||
settings->font_options = cairo_font_options_create ();
|
||||
|
||||
cairo_font_options_set_hint_metrics (priv->font_options, CAIRO_HINT_METRICS_OFF);
|
||||
cairo_font_options_set_hint_metrics (settings->font_options, CAIRO_HINT_METRICS_OFF);
|
||||
|
||||
hint_style = CAIRO_HINT_STYLE_DEFAULT;
|
||||
if (hinting == 0)
|
||||
@ -1555,7 +1528,7 @@ settings_update_font_options (GtkSettings *settings)
|
||||
|
||||
g_free (hint_style_str);
|
||||
|
||||
cairo_font_options_set_hint_style (priv->font_options, hint_style);
|
||||
cairo_font_options_set_hint_style (settings->font_options, hint_style);
|
||||
|
||||
subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
|
||||
if (rgba_str)
|
||||
@ -1572,7 +1545,7 @@ settings_update_font_options (GtkSettings *settings)
|
||||
|
||||
g_free (rgba_str);
|
||||
|
||||
cairo_font_options_set_subpixel_order (priv->font_options, subpixel_order);
|
||||
cairo_font_options_set_subpixel_order (settings->font_options, subpixel_order);
|
||||
|
||||
antialias_mode = CAIRO_ANTIALIAS_DEFAULT;
|
||||
if (antialias == 0)
|
||||
@ -1587,7 +1560,7 @@ settings_update_font_options (GtkSettings *settings)
|
||||
antialias_mode = CAIRO_ANTIALIAS_GRAY;
|
||||
}
|
||||
|
||||
cairo_font_options_set_antialias (priv->font_options, antialias_mode);
|
||||
cairo_font_options_set_antialias (settings->font_options, antialias_mode);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -1701,7 +1674,6 @@ get_theme_name (GtkSettings *settings,
|
||||
static void
|
||||
settings_update_theme (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
gchar *theme_name;
|
||||
gchar *theme_variant;
|
||||
const gchar *theme_dir;
|
||||
@ -1709,12 +1681,12 @@ settings_update_theme (GtkSettings *settings)
|
||||
|
||||
get_theme_name (settings, &theme_name, &theme_variant);
|
||||
|
||||
gtk_css_provider_load_named (priv->theme_provider,
|
||||
gtk_css_provider_load_named (settings->theme_provider,
|
||||
theme_name,
|
||||
theme_variant);
|
||||
|
||||
/* reload per-theme settings */
|
||||
theme_dir = _gtk_css_provider_get_theme_dir (priv->theme_provider);
|
||||
theme_dir = _gtk_css_provider_get_theme_dir (settings->theme_provider);
|
||||
if (theme_dir)
|
||||
{
|
||||
path = g_build_filename (theme_dir, "settings.ini", NULL);
|
||||
@ -1730,15 +1702,13 @@ settings_update_theme (GtkSettings *settings)
|
||||
const cairo_font_options_t *
|
||||
gtk_settings_get_font_options (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
return priv->font_options;
|
||||
return settings->font_options;
|
||||
}
|
||||
|
||||
GdkDisplay *
|
||||
_gtk_settings_get_display (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
return priv->display;
|
||||
return settings->display;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1884,15 +1854,14 @@ settings_update_xsetting (GtkSettings *settings,
|
||||
GParamSpec *pspec,
|
||||
gboolean force)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
GType value_type;
|
||||
GType fundamental_type;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
if (priv->property_values[pspec->param_id - 1].source == GTK_SETTINGS_SOURCE_APPLICATION)
|
||||
if (settings->property_values[pspec->param_id - 1].source == GTK_SETTINGS_SOURCE_APPLICATION)
|
||||
return FALSE;
|
||||
|
||||
if (priv->property_values[pspec->param_id - 1].source == GTK_SETTINGS_SOURCE_XSETTING && !force)
|
||||
if (settings->property_values[pspec->param_id - 1].source == GTK_SETTINGS_SOURCE_XSETTING && !force)
|
||||
return FALSE;
|
||||
|
||||
value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
|
||||
@ -1907,12 +1876,12 @@ settings_update_xsetting (GtkSettings *settings,
|
||||
|
||||
g_value_init (&val, value_type);
|
||||
|
||||
if (!gdk_display_get_setting (priv->display, pspec->name, &val))
|
||||
if (!gdk_display_get_setting (settings->display, pspec->name, &val))
|
||||
return FALSE;
|
||||
|
||||
g_param_value_validate (pspec, &val);
|
||||
g_value_copy (&val, &priv->property_values[pspec->param_id - 1].value);
|
||||
priv->property_values[pspec->param_id - 1].source = GTK_SETTINGS_SOURCE_XSETTING;
|
||||
g_value_copy (&val, &settings->property_values[pspec->param_id - 1].value);
|
||||
settings->property_values[pspec->param_id - 1].source = GTK_SETTINGS_SOURCE_XSETTING;
|
||||
|
||||
g_value_unset (&val);
|
||||
|
||||
@ -1945,25 +1914,23 @@ gtk_settings_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkSettings *settings = GTK_SETTINGS (object);
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
|
||||
settings_update_xsetting (settings, pspec, FALSE);
|
||||
|
||||
g_value_copy (&priv->property_values[property_id - 1].value, value);
|
||||
g_value_copy (&settings->property_values[property_id - 1].value, value);
|
||||
}
|
||||
|
||||
GtkSettingsSource
|
||||
_gtk_settings_get_setting_source (GtkSettings *settings,
|
||||
const gchar *name)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
GParamSpec *pspec;
|
||||
|
||||
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (settings), name);
|
||||
if (!pspec)
|
||||
return GTK_SETTINGS_SOURCE_DEFAULT;
|
||||
|
||||
return priv->property_values[pspec->param_id - 1].source;
|
||||
return settings->property_values[pspec->param_id - 1].source;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1980,7 +1947,6 @@ void
|
||||
gtk_settings_reset_property (GtkSettings *settings,
|
||||
const gchar *name)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
GParamSpec *pspec;
|
||||
GValue *value;
|
||||
GValue tmp_value = G_VALUE_INIT;
|
||||
@ -1993,19 +1959,18 @@ gtk_settings_reset_property (GtkSettings *settings,
|
||||
|
||||
g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
if (value && _gtk_settings_parse_convert (value, pspec, &tmp_value))
|
||||
g_value_copy (&tmp_value, &priv->property_values[pspec->param_id - 1].value);
|
||||
g_value_copy (&tmp_value, &settings->property_values[pspec->param_id - 1].value);
|
||||
else
|
||||
g_param_value_set_default (pspec, &priv->property_values[pspec->param_id - 1].value);
|
||||
g_param_value_set_default (pspec, &settings->property_values[pspec->param_id - 1].value);
|
||||
|
||||
priv->property_values[pspec->param_id - 1].source = GTK_SETTINGS_SOURCE_DEFAULT;
|
||||
settings->property_values[pspec->param_id - 1].source = GTK_SETTINGS_SOURCE_DEFAULT;
|
||||
g_object_notify_by_pspec (G_OBJECT (settings), pspec);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_settings_get_enable_animations (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
GtkSettingsPropertyValue *svalue = &priv->property_values[PROP_ENABLE_ANIMATIONS - 1];
|
||||
GtkSettingsPropertyValue *svalue = &settings->property_values[PROP_ENABLE_ANIMATIONS - 1];
|
||||
|
||||
if (svalue->source < GTK_SETTINGS_SOURCE_XSETTING)
|
||||
{
|
||||
@ -2022,8 +1987,7 @@ gtk_settings_get_enable_animations (GtkSettings *settings)
|
||||
gint
|
||||
gtk_settings_get_dnd_drag_threshold (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
GtkSettingsPropertyValue *svalue = &priv->property_values[PROP_DND_DRAG_THRESHOLD - 1];
|
||||
GtkSettingsPropertyValue *svalue = &settings->property_values[PROP_DND_DRAG_THRESHOLD - 1];
|
||||
|
||||
if (svalue->source < GTK_SETTINGS_SOURCE_XSETTING)
|
||||
{
|
||||
@ -2040,8 +2004,7 @@ gtk_settings_get_dnd_drag_threshold (GtkSettings *settings)
|
||||
static void
|
||||
settings_update_font_name (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
GtkSettingsPropertyValue *svalue = &priv->property_values[PROP_FONT_NAME - 1];
|
||||
GtkSettingsPropertyValue *svalue = &settings->property_values[PROP_FONT_NAME - 1];
|
||||
|
||||
if (svalue->source < GTK_SETTINGS_SOURCE_XSETTING)
|
||||
{
|
||||
@ -2056,26 +2019,23 @@ settings_update_font_name (GtkSettings *settings)
|
||||
const gchar *
|
||||
gtk_settings_get_font_family (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
settings_update_font_name (settings);
|
||||
|
||||
return priv->font_family;
|
||||
return settings->font_family;
|
||||
}
|
||||
|
||||
gint
|
||||
gtk_settings_get_font_size (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
settings_update_font_name (settings);
|
||||
|
||||
return priv->font_size;
|
||||
return settings->font_size;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_settings_get_font_size_is_absolute (GtkSettings *settings)
|
||||
{
|
||||
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
|
||||
settings_update_font_name (settings);
|
||||
|
||||
return priv->font_size_absolute;
|
||||
return settings->font_size_absolute;
|
||||
}
|
||||
|
@ -39,10 +39,6 @@ typedef struct _GtkSettingsValue GtkSettingsValue;
|
||||
|
||||
|
||||
/* --- structures --- */
|
||||
struct _GtkSettings
|
||||
{
|
||||
GObject parent_instance;
|
||||
};
|
||||
|
||||
/**
|
||||
* GtkSettingsValue:
|
||||
|
@ -85,6 +85,16 @@ typedef struct _GtkStatusbarClass GtkStatusbarClass;
|
||||
struct _GtkStatusbar
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GtkWidget *frame;
|
||||
GtkWidget *label;
|
||||
GtkWidget *message_area;
|
||||
|
||||
GSList *messages;
|
||||
GSList *keys;
|
||||
|
||||
guint seq_context_id;
|
||||
guint seq_message_id;
|
||||
};
|
||||
|
||||
struct _GtkStatusbarClass
|
||||
@ -99,20 +109,6 @@ struct _GtkStatusbarClass
|
||||
const gchar *text);
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *label;
|
||||
GtkWidget *message_area;
|
||||
|
||||
GSList *messages;
|
||||
GSList *keys;
|
||||
|
||||
guint seq_context_id;
|
||||
guint seq_message_id;
|
||||
} GtkStatusbarPrivate;
|
||||
|
||||
|
||||
struct _GtkStatusbarMsg
|
||||
{
|
||||
gchar *text;
|
||||
@ -134,14 +130,14 @@ static void gtk_statusbar_destroy (GtkWidget *widget);
|
||||
|
||||
static guint statusbar_signals[SIGNAL_LAST] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkStatusbar, gtk_statusbar, GTK_TYPE_WIDGET)
|
||||
G_DEFINE_TYPE (GtkStatusbar, gtk_statusbar, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
gtk_statusbar_dispose (GObject *object)
|
||||
{
|
||||
GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (GTK_STATUSBAR (object));
|
||||
GtkStatusbar *self = GTK_STATUSBAR (object);
|
||||
|
||||
g_clear_pointer (&priv->frame, gtk_widget_unparent);
|
||||
g_clear_pointer (&self->frame, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (gtk_statusbar_parent_class)->dispose (object);
|
||||
}
|
||||
@ -200,9 +196,9 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
|
||||
/* Bind class to template
|
||||
*/
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkstatusbar.ui");
|
||||
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkStatusbar, message_area);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkStatusbar, frame);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkStatusbar, label);
|
||||
gtk_widget_class_bind_template_child_internal (widget_class, GtkStatusbar, message_area);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkStatusbar, frame);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkStatusbar, label);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_STATUSBAR_ACCESSIBLE);
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
@ -212,12 +208,10 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
|
||||
static void
|
||||
gtk_statusbar_init (GtkStatusbar *statusbar)
|
||||
{
|
||||
GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (statusbar);
|
||||
|
||||
priv->seq_context_id = 1;
|
||||
priv->seq_message_id = 1;
|
||||
priv->messages = NULL;
|
||||
priv->keys = NULL;
|
||||
statusbar->seq_context_id = 1;
|
||||
statusbar->seq_message_id = 1;
|
||||
statusbar->messages = NULL;
|
||||
statusbar->keys = NULL;
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (statusbar));
|
||||
}
|
||||
@ -240,14 +234,12 @@ gtk_statusbar_update (GtkStatusbar *statusbar,
|
||||
guint context_id,
|
||||
const gchar *text)
|
||||
{
|
||||
GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (statusbar);
|
||||
|
||||
g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
|
||||
|
||||
if (!text)
|
||||
text = "";
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (priv->label), text);
|
||||
gtk_label_set_text (GTK_LABEL (statusbar->label), text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -266,7 +258,6 @@ guint
|
||||
gtk_statusbar_get_context_id (GtkStatusbar *statusbar,
|
||||
const gchar *context_description)
|
||||
{
|
||||
GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (statusbar);
|
||||
gchar *string;
|
||||
guint id;
|
||||
|
||||
@ -279,9 +270,9 @@ gtk_statusbar_get_context_id (GtkStatusbar *statusbar,
|
||||
id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (statusbar), string));
|
||||
if (id == 0)
|
||||
{
|
||||
id = priv->seq_context_id++;
|
||||
id = statusbar->seq_context_id++;
|
||||
g_object_set_data_full (G_OBJECT (statusbar), string, GUINT_TO_POINTER (id), NULL);
|
||||
priv->keys = g_slist_prepend (priv->keys, string);
|
||||
statusbar->keys = g_slist_prepend (statusbar->keys, string);
|
||||
}
|
||||
else
|
||||
g_free (string);
|
||||
@ -294,13 +285,12 @@ gtk_statusbar_msg_create (GtkStatusbar *statusbar,
|
||||
guint context_id,
|
||||
const gchar *text)
|
||||
{
|
||||
GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (statusbar);
|
||||
GtkStatusbarMsg *msg;
|
||||
|
||||
msg = g_slice_new (GtkStatusbarMsg);
|
||||
msg->text = g_strdup (text);
|
||||
msg->context_id = context_id;
|
||||
msg->message_id = priv->seq_message_id++;
|
||||
msg->message_id = statusbar->seq_message_id++;
|
||||
|
||||
return msg;
|
||||
}
|
||||
@ -329,14 +319,13 @@ gtk_statusbar_push (GtkStatusbar *statusbar,
|
||||
guint context_id,
|
||||
const gchar *text)
|
||||
{
|
||||
GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (statusbar);
|
||||
GtkStatusbarMsg *msg;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), 0);
|
||||
g_return_val_if_fail (text != NULL, 0);
|
||||
|
||||
msg = gtk_statusbar_msg_create (statusbar, context_id, text);
|
||||
priv->messages = g_slist_prepend (priv->messages, msg);
|
||||
statusbar->messages = g_slist_prepend (statusbar->messages, msg);
|
||||
|
||||
g_signal_emit (statusbar,
|
||||
statusbar_signals[SIGNAL_TEXT_PUSHED],
|
||||
@ -363,22 +352,21 @@ void
|
||||
gtk_statusbar_pop (GtkStatusbar *statusbar,
|
||||
guint context_id)
|
||||
{
|
||||
GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (statusbar);
|
||||
GtkStatusbarMsg *msg;
|
||||
|
||||
g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
|
||||
|
||||
if (priv->messages)
|
||||
if (statusbar->messages)
|
||||
{
|
||||
GSList *list;
|
||||
|
||||
for (list = priv->messages; list; list = list->next)
|
||||
for (list = statusbar->messages; list; list = list->next)
|
||||
{
|
||||
msg = list->data;
|
||||
|
||||
if (msg->context_id == context_id)
|
||||
{
|
||||
priv->messages = g_slist_remove_link (priv->messages, list);
|
||||
statusbar->messages = g_slist_remove_link (statusbar->messages, list);
|
||||
gtk_statusbar_msg_free (msg);
|
||||
g_slist_free_1 (list);
|
||||
break;
|
||||
@ -386,7 +374,7 @@ gtk_statusbar_pop (GtkStatusbar *statusbar,
|
||||
}
|
||||
}
|
||||
|
||||
msg = priv->messages ? priv->messages->data : NULL;
|
||||
msg = statusbar->messages ? statusbar->messages->data : NULL;
|
||||
|
||||
g_signal_emit (statusbar,
|
||||
statusbar_signals[SIGNAL_TEXT_POPPED],
|
||||
@ -409,13 +397,12 @@ gtk_statusbar_remove (GtkStatusbar *statusbar,
|
||||
guint context_id,
|
||||
guint message_id)
|
||||
{
|
||||
GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (statusbar);
|
||||
GtkStatusbarMsg *msg;
|
||||
|
||||
g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
|
||||
g_return_if_fail (message_id > 0);
|
||||
|
||||
msg = priv->messages ? priv->messages->data : NULL;
|
||||
msg = statusbar->messages ? statusbar->messages->data : NULL;
|
||||
if (msg)
|
||||
{
|
||||
GSList *list;
|
||||
@ -428,14 +415,14 @@ gtk_statusbar_remove (GtkStatusbar *statusbar,
|
||||
return;
|
||||
}
|
||||
|
||||
for (list = priv->messages; list; list = list->next)
|
||||
for (list = statusbar->messages; list; list = list->next)
|
||||
{
|
||||
msg = list->data;
|
||||
|
||||
if (msg->context_id == context_id &&
|
||||
msg->message_id == message_id)
|
||||
{
|
||||
priv->messages = g_slist_remove_link (priv->messages, list);
|
||||
statusbar->messages = g_slist_remove_link (statusbar->messages, list);
|
||||
gtk_statusbar_msg_free (msg);
|
||||
g_slist_free_1 (list);
|
||||
|
||||
@ -457,13 +444,12 @@ void
|
||||
gtk_statusbar_remove_all (GtkStatusbar *statusbar,
|
||||
guint context_id)
|
||||
{
|
||||
GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (statusbar);
|
||||
GtkStatusbarMsg *msg;
|
||||
GSList *prev, *list;
|
||||
|
||||
g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
|
||||
|
||||
if (priv->messages == NULL)
|
||||
if (statusbar->messages == NULL)
|
||||
return;
|
||||
|
||||
/* We special-case the topmost message at the bottom of this
|
||||
@ -471,7 +457,7 @@ gtk_statusbar_remove_all (GtkStatusbar *statusbar,
|
||||
* If we need to pop it, we have to update various state and we want
|
||||
* an up-to-date list of remaining messages in that case.
|
||||
*/
|
||||
prev = priv->messages;
|
||||
prev = statusbar->messages;
|
||||
list = prev->next;
|
||||
|
||||
while (list != NULL)
|
||||
@ -495,7 +481,7 @@ gtk_statusbar_remove_all (GtkStatusbar *statusbar,
|
||||
}
|
||||
|
||||
/* Treat topmost message here */
|
||||
msg = priv->messages->data;
|
||||
msg = statusbar->messages->data;
|
||||
if (msg->context_id == context_id)
|
||||
{
|
||||
gtk_statusbar_pop (statusbar, context_id);
|
||||
@ -513,24 +499,21 @@ gtk_statusbar_remove_all (GtkStatusbar *statusbar,
|
||||
const char*
|
||||
gtk_statusbar_get_message (GtkStatusbar *statusbar)
|
||||
{
|
||||
GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (statusbar);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), NULL);
|
||||
|
||||
return gtk_label_get_label (GTK_LABEL (priv->label));
|
||||
return gtk_label_get_label (GTK_LABEL (statusbar->label));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_statusbar_destroy (GtkWidget *widget)
|
||||
{
|
||||
GtkStatusbar *statusbar = GTK_STATUSBAR (widget);
|
||||
GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (statusbar);
|
||||
|
||||
g_slist_free_full (priv->messages, (GDestroyNotify) gtk_statusbar_msg_free);
|
||||
priv->messages = NULL;
|
||||
g_slist_free_full (statusbar->messages, (GDestroyNotify) gtk_statusbar_msg_free);
|
||||
statusbar->messages = NULL;
|
||||
|
||||
g_slist_free_full (priv->keys, g_free);
|
||||
priv->keys = NULL;
|
||||
g_slist_free_full (statusbar->keys, g_free);
|
||||
statusbar->keys = NULL;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->destroy (widget);
|
||||
}
|
||||
|
@ -31,8 +31,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef struct _GtkTextHandlePrivate GtkTextHandlePrivate;
|
||||
|
||||
enum {
|
||||
DRAG_STARTED,
|
||||
HANDLE_DRAGGED,
|
||||
@ -40,8 +38,10 @@ enum {
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
struct _GtkTextHandlePrivate
|
||||
struct _GtkTextHandle
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GtkWidget *parent;
|
||||
GdkSurface *surface;
|
||||
GskRenderer *renderer;
|
||||
@ -57,15 +57,9 @@ struct _GtkTextHandlePrivate
|
||||
guint has_point : 1;
|
||||
};
|
||||
|
||||
struct _GtkTextHandle
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
};
|
||||
|
||||
static void gtk_text_handle_native_interface_init (GtkNativeInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkTextHandle, gtk_text_handle, GTK_TYPE_WIDGET,
|
||||
G_ADD_PRIVATE (GtkTextHandle)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_NATIVE,
|
||||
gtk_text_handle_native_interface_init))
|
||||
|
||||
@ -74,19 +68,13 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
||||
static GdkSurface *
|
||||
gtk_text_handle_native_get_surface (GtkNative *native)
|
||||
{
|
||||
GtkTextHandle *handle = GTK_TEXT_HANDLE (native);
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
|
||||
return priv->surface;
|
||||
return GTK_TEXT_HANDLE (native)->surface;
|
||||
}
|
||||
|
||||
static GskRenderer *
|
||||
gtk_text_handle_native_get_renderer (GtkNative *native)
|
||||
{
|
||||
GtkTextHandle *handle = GTK_TEXT_HANDLE (native);
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
|
||||
return priv->renderer;
|
||||
return GTK_TEXT_HANDLE (native)->renderer;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -139,29 +127,28 @@ gtk_text_handle_get_padding (GtkTextHandle *handle,
|
||||
static void
|
||||
gtk_text_handle_present_surface (GtkTextHandle *handle)
|
||||
{
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
GtkWidget *widget = GTK_WIDGET (handle);
|
||||
GdkPopupLayout *layout;
|
||||
GdkRectangle rect;
|
||||
GtkRequisition req;
|
||||
|
||||
gtk_widget_get_preferred_size (widget, NULL, &req);
|
||||
gtk_text_handle_get_padding (handle, &priv->border);
|
||||
gtk_text_handle_get_padding (handle, &handle->border);
|
||||
|
||||
rect.x = priv->pointing_to.x;
|
||||
rect.y = priv->pointing_to.y + priv->pointing_to.height - priv->border.top;
|
||||
rect.width = req.width - priv->border.left - priv->border.right;
|
||||
rect.x = handle->pointing_to.x;
|
||||
rect.y = handle->pointing_to.y + handle->pointing_to.height - handle->border.top;
|
||||
rect.width = req.width - handle->border.left - handle->border.right;
|
||||
rect.height = 1;
|
||||
|
||||
gtk_widget_translate_coordinates (gtk_widget_get_parent (widget),
|
||||
gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW),
|
||||
rect.x, rect.y, &rect.x, &rect.y);
|
||||
|
||||
if (priv->role == GTK_TEXT_HANDLE_ROLE_CURSOR)
|
||||
if (handle->role == GTK_TEXT_HANDLE_ROLE_CURSOR)
|
||||
rect.x -= rect.width / 2;
|
||||
else if ((priv->role == GTK_TEXT_HANDLE_ROLE_SELECTION_END &&
|
||||
else if ((handle->role == GTK_TEXT_HANDLE_ROLE_SELECTION_END &&
|
||||
gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ||
|
||||
(priv->role == GTK_TEXT_HANDLE_ROLE_SELECTION_START &&
|
||||
(handle->role == GTK_TEXT_HANDLE_ROLE_SELECTION_START &&
|
||||
gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL))
|
||||
rect.x -= rect.width;
|
||||
|
||||
@ -171,15 +158,15 @@ gtk_text_handle_present_surface (GtkTextHandle *handle)
|
||||
gdk_popup_layout_set_anchor_hints (layout,
|
||||
GDK_ANCHOR_FLIP_Y | GDK_ANCHOR_SLIDE_X);
|
||||
|
||||
gdk_popup_present (GDK_POPUP (priv->surface),
|
||||
gdk_popup_present (GDK_POPUP (handle->surface),
|
||||
MAX (req.width, 1),
|
||||
MAX (req.height, 1),
|
||||
layout);
|
||||
gdk_popup_layout_unref (layout);
|
||||
|
||||
gtk_widget_allocate (widget,
|
||||
gdk_surface_get_width (priv->surface),
|
||||
gdk_surface_get_height (priv->surface),
|
||||
gdk_surface_get_width (handle->surface),
|
||||
gdk_surface_get_height (handle->surface),
|
||||
-1, NULL);
|
||||
}
|
||||
|
||||
@ -226,9 +213,8 @@ static void
|
||||
surface_mapped_changed (GtkWidget *widget)
|
||||
{
|
||||
GtkTextHandle *handle = GTK_TEXT_HANDLE (widget);
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
|
||||
gtk_widget_set_visible (widget, gdk_surface_get_mapped (priv->surface));
|
||||
gtk_widget_set_visible (widget, gdk_surface_get_mapped (handle->surface));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -247,55 +233,52 @@ static void
|
||||
gtk_text_handle_realize (GtkWidget *widget)
|
||||
{
|
||||
GtkTextHandle *handle = GTK_TEXT_HANDLE (widget);
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
GdkSurface *parent_surface;
|
||||
GtkWidget *parent;
|
||||
|
||||
parent = gtk_widget_get_parent (widget);
|
||||
parent_surface = gtk_native_get_surface (gtk_widget_get_native (parent));
|
||||
|
||||
priv->surface = gdk_surface_new_popup (parent_surface, FALSE);
|
||||
gdk_surface_set_widget (priv->surface, widget);
|
||||
handle->surface = gdk_surface_new_popup (parent_surface, FALSE);
|
||||
gdk_surface_set_widget (handle->surface, widget);
|
||||
|
||||
g_signal_connect_swapped (priv->surface, "notify::mapped",
|
||||
g_signal_connect_swapped (handle->surface, "notify::mapped",
|
||||
G_CALLBACK (surface_mapped_changed), widget);
|
||||
g_signal_connect (priv->surface, "render", G_CALLBACK (surface_render), widget);
|
||||
g_signal_connect (priv->surface, "event", G_CALLBACK (surface_event), widget);
|
||||
g_signal_connect (handle->surface, "render", G_CALLBACK (surface_render), widget);
|
||||
g_signal_connect (handle->surface, "event", G_CALLBACK (surface_event), widget);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_text_handle_parent_class)->realize (widget);
|
||||
|
||||
priv->renderer = gsk_renderer_new_for_surface (priv->surface);
|
||||
handle->renderer = gsk_renderer_new_for_surface (handle->surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_handle_unrealize (GtkWidget *widget)
|
||||
{
|
||||
GtkTextHandle *handle = GTK_TEXT_HANDLE (widget);
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_text_handle_parent_class)->unrealize (widget);
|
||||
|
||||
gsk_renderer_unrealize (priv->renderer);
|
||||
g_clear_object (&priv->renderer);
|
||||
gsk_renderer_unrealize (handle->renderer);
|
||||
g_clear_object (&handle->renderer);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (priv->surface, surface_render, widget);
|
||||
g_signal_handlers_disconnect_by_func (priv->surface, surface_event, widget);
|
||||
g_signal_handlers_disconnect_by_func (priv->surface, surface_mapped_changed, widget);
|
||||
g_signal_handlers_disconnect_by_func (handle->surface, surface_render, widget);
|
||||
g_signal_handlers_disconnect_by_func (handle->surface, surface_event, widget);
|
||||
g_signal_handlers_disconnect_by_func (handle->surface, surface_mapped_changed, widget);
|
||||
|
||||
gdk_surface_set_widget (priv->surface, NULL);
|
||||
gdk_surface_destroy (priv->surface);
|
||||
g_clear_object (&priv->surface);
|
||||
gdk_surface_set_widget (handle->surface, NULL);
|
||||
gdk_surface_destroy (handle->surface);
|
||||
g_clear_object (&handle->surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_handle_map (GtkWidget *widget)
|
||||
{
|
||||
GtkTextHandle *handle = GTK_TEXT_HANDLE (widget);
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_text_handle_parent_class)->map (widget);
|
||||
|
||||
if (priv->has_point)
|
||||
if (handle->has_point)
|
||||
gtk_text_handle_present_surface (handle);
|
||||
}
|
||||
|
||||
@ -303,10 +286,9 @@ static void
|
||||
gtk_text_handle_unmap (GtkWidget *widget)
|
||||
{
|
||||
GtkTextHandle *handle = GTK_TEXT_HANDLE (widget);
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_text_handle_parent_class)->unmap (widget);
|
||||
gdk_surface_hide (priv->surface);
|
||||
gdk_surface_hide (handle->surface);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -374,24 +356,23 @@ handle_drag_begin (GtkGestureDrag *gesture,
|
||||
gdouble y,
|
||||
GtkTextHandle *handle)
|
||||
{
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
if (priv->role == GTK_TEXT_HANDLE_ROLE_CURSOR)
|
||||
if (handle->role == GTK_TEXT_HANDLE_ROLE_CURSOR)
|
||||
x -= gtk_widget_get_width (widget) / 2;
|
||||
else if ((priv->role == GTK_TEXT_HANDLE_ROLE_SELECTION_END &&
|
||||
else if ((handle->role == GTK_TEXT_HANDLE_ROLE_SELECTION_END &&
|
||||
gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ||
|
||||
(priv->role == GTK_TEXT_HANDLE_ROLE_SELECTION_START &&
|
||||
(handle->role == GTK_TEXT_HANDLE_ROLE_SELECTION_START &&
|
||||
gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL))
|
||||
x -= gtk_widget_get_width (widget);
|
||||
|
||||
y += priv->border.top / 2;
|
||||
y += handle->border.top / 2;
|
||||
|
||||
priv->dx = x;
|
||||
priv->dy = y;
|
||||
priv->dragged = TRUE;
|
||||
handle->dx = x;
|
||||
handle->dy = y;
|
||||
handle->dragged = TRUE;
|
||||
g_signal_emit (handle, signals[DRAG_STARTED], 0);
|
||||
}
|
||||
|
||||
@ -401,23 +382,22 @@ handle_drag_update (GtkGestureDrag *gesture,
|
||||
gdouble offset_y,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkTextHandle *text_handle = GTK_TEXT_HANDLE (widget);
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (text_handle);
|
||||
GtkTextHandle *handle = GTK_TEXT_HANDLE (widget);
|
||||
gdouble start_x, start_y;
|
||||
gint x, y;
|
||||
|
||||
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
|
||||
|
||||
x = priv->pointing_to.x + priv->pointing_to.width / 2 +
|
||||
start_x + offset_x - priv->dx;
|
||||
y = priv->pointing_to.y + priv->pointing_to.height +
|
||||
start_y + offset_y - priv->dy;
|
||||
x = handle->pointing_to.x + handle->pointing_to.width / 2 +
|
||||
start_x + offset_x - handle->dx;
|
||||
y = handle->pointing_to.y + handle->pointing_to.height +
|
||||
start_y + offset_y - handle->dy;
|
||||
|
||||
if (priv->role == GTK_TEXT_HANDLE_ROLE_CURSOR)
|
||||
if (handle->role == GTK_TEXT_HANDLE_ROLE_CURSOR)
|
||||
x -= gtk_widget_get_width (widget) / 2;
|
||||
else if ((priv->role == GTK_TEXT_HANDLE_ROLE_SELECTION_END &&
|
||||
else if ((handle->role == GTK_TEXT_HANDLE_ROLE_SELECTION_END &&
|
||||
gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ||
|
||||
(priv->role == GTK_TEXT_HANDLE_ROLE_SELECTION_START &&
|
||||
(handle->role == GTK_TEXT_HANDLE_ROLE_SELECTION_START &&
|
||||
gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL))
|
||||
x -= gtk_widget_get_width (widget);
|
||||
|
||||
@ -430,31 +410,28 @@ handle_drag_end (GtkGestureDrag *gesture,
|
||||
gdouble offset_y,
|
||||
GtkTextHandle *handle)
|
||||
{
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
|
||||
g_signal_emit (handle, signals[DRAG_FINISHED], 0);
|
||||
priv->dragged = FALSE;
|
||||
handle->dragged = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_handle_update_for_role (GtkTextHandle *handle)
|
||||
{
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
GtkWidget *widget = GTK_WIDGET (handle);
|
||||
|
||||
if (priv->role == GTK_TEXT_HANDLE_ROLE_CURSOR)
|
||||
if (handle->role == GTK_TEXT_HANDLE_ROLE_CURSOR)
|
||||
{
|
||||
gtk_widget_remove_css_class (widget, GTK_STYLE_CLASS_TOP);
|
||||
gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_BOTTOM);
|
||||
gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_INSERTION_CURSOR);
|
||||
}
|
||||
else if (priv->role == GTK_TEXT_HANDLE_ROLE_SELECTION_END)
|
||||
else if (handle->role == GTK_TEXT_HANDLE_ROLE_SELECTION_END)
|
||||
{
|
||||
gtk_widget_remove_css_class (widget, GTK_STYLE_CLASS_TOP);
|
||||
gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_BOTTOM);
|
||||
gtk_widget_remove_css_class (widget, GTK_STYLE_CLASS_INSERTION_CURSOR);
|
||||
}
|
||||
else if (priv->role == GTK_TEXT_HANDLE_ROLE_SELECTION_START)
|
||||
else if (handle->role == GTK_TEXT_HANDLE_ROLE_SELECTION_START)
|
||||
{
|
||||
gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_TOP);
|
||||
gtk_widget_remove_css_class (widget, GTK_STYLE_CLASS_BOTTOM);
|
||||
@ -482,33 +459,27 @@ gtk_text_handle_init (GtkTextHandle *widget)
|
||||
GtkTextHandle *
|
||||
gtk_text_handle_new (GtkWidget *parent)
|
||||
{
|
||||
GtkWidget *handle;
|
||||
|
||||
handle = g_object_new (GTK_TYPE_TEXT_HANDLE,
|
||||
"css-name", I_("cursor-handle"),
|
||||
NULL);
|
||||
gtk_widget_set_parent (handle, parent);
|
||||
|
||||
return GTK_TEXT_HANDLE (handle);
|
||||
return g_object_new (GTK_TYPE_TEXT_HANDLE,
|
||||
"parent", parent,
|
||||
"css-name", I_("cursor-handle"),
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_text_handle_set_role (GtkTextHandle *handle,
|
||||
GtkTextHandleRole role)
|
||||
{
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
|
||||
g_return_if_fail (GTK_IS_TEXT_HANDLE (handle));
|
||||
|
||||
if (priv->role == role)
|
||||
if (handle->role == role)
|
||||
return;
|
||||
|
||||
priv->role = role;
|
||||
handle->role = role;
|
||||
gtk_text_handle_update_for_role (handle);
|
||||
|
||||
if (gtk_widget_get_visible (GTK_WIDGET (handle)))
|
||||
{
|
||||
if (priv->has_point)
|
||||
if (handle->has_point)
|
||||
gtk_text_handle_present_surface (handle);
|
||||
}
|
||||
}
|
||||
@ -516,29 +487,25 @@ gtk_text_handle_set_role (GtkTextHandle *handle,
|
||||
GtkTextHandleRole
|
||||
gtk_text_handle_get_role (GtkTextHandle *handle)
|
||||
{
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TEXT_HANDLE (handle), GTK_TEXT_HANDLE_ROLE_CURSOR);
|
||||
|
||||
return priv->role;
|
||||
return handle->role;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_text_handle_set_position (GtkTextHandle *handle,
|
||||
const GdkRectangle *rect)
|
||||
{
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
|
||||
g_return_if_fail (GTK_IS_TEXT_HANDLE (handle));
|
||||
|
||||
if (priv->pointing_to.x == rect->x &&
|
||||
priv->pointing_to.y == rect->y &&
|
||||
priv->pointing_to.width == rect->width &&
|
||||
priv->pointing_to.height == rect->height)
|
||||
if (handle->pointing_to.x == rect->x &&
|
||||
handle->pointing_to.y == rect->y &&
|
||||
handle->pointing_to.width == rect->width &&
|
||||
handle->pointing_to.height == rect->height)
|
||||
return;
|
||||
|
||||
priv->pointing_to = *rect;
|
||||
priv->has_point = TRUE;
|
||||
handle->pointing_to = *rect;
|
||||
handle->has_point = TRUE;
|
||||
|
||||
if (gtk_widget_is_visible (GTK_WIDGET (handle)))
|
||||
gtk_text_handle_present_surface (handle);
|
||||
@ -547,9 +514,7 @@ gtk_text_handle_set_position (GtkTextHandle *handle,
|
||||
gboolean
|
||||
gtk_text_handle_get_is_dragged (GtkTextHandle *handle)
|
||||
{
|
||||
GtkTextHandlePrivate *priv = gtk_text_handle_get_instance_private (handle);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TEXT_HANDLE (handle), FALSE);
|
||||
|
||||
return priv->dragged;
|
||||
return handle->dragged;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user