Compare commits

...

3 Commits

Author SHA1 Message Date
Matthias Clasen
7fb2102399 video: Don't hide the controls while active
If the user is changing the volume, we don't
want to hide the controls.
2020-04-28 01:17:23 -04:00
Matthias Clasen
a3035b0397 mediacontrols: Add an active property
Currently, this just forwards the volume buttons
active property. It will be used to prevent the
controls from being hidden while the user interacts
with them.
2020-04-28 01:16:18 -04:00
Matthias Clasen
116eb992c1 scalebutton: Add an active property
This is set to TRUE while the popup is visible.
We will use it to prevent the button from being
hidden while the user is interacting with it.
2020-04-28 01:15:29 -04:00
3 changed files with 56 additions and 1 deletions

View File

@@ -51,12 +51,14 @@ struct _GtkMediaControls
GtkWidget *time_label;
GtkWidget *seek_scale;
GtkWidget *duration_label;
GtkWidget *volume_button;
};
enum
{
PROP_0,
PROP_MEDIA_STREAM,
PROP_ACTIVE,
N_PROPS
};
@@ -226,6 +228,14 @@ gtk_media_controls_get_property (GObject *object,
g_value_set_object (value, controls->stream);
break;
case PROP_ACTIVE:
{
gboolean active;
g_object_get (controls->volume_button, "active", &active, NULL);
g_value_set_boolean (value, active);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -279,6 +289,13 @@ gtk_media_controls_class_init (GtkMediaControlsClass *klass)
GTK_TYPE_MEDIA_STREAM,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
properties[PROP_ACTIVE] =
g_param_spec_boolean ("active",
P_("Active"),
P_("Active"),
FALSE,
G_PARAM_READABLE);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkmediacontrols.ui");
@@ -290,6 +307,7 @@ gtk_media_controls_class_init (GtkMediaControlsClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkMediaControls, time_label);
gtk_widget_class_bind_template_child (widget_class, GtkMediaControls, seek_scale);
gtk_widget_class_bind_template_child (widget_class, GtkMediaControls, duration_label);
gtk_widget_class_bind_template_child (widget_class, GtkMediaControls, volume_button);
gtk_widget_class_bind_template_callback (widget_class, play_button_clicked);
gtk_widget_class_bind_template_callback (widget_class, time_adjustment_changed);
@@ -298,10 +316,20 @@ gtk_media_controls_class_init (GtkMediaControlsClass *klass)
gtk_widget_class_set_css_name (widget_class, I_("controls"));
}
static void
notify_active (GObject *object,
GParamSpec *pspec,
GObject *controls)
{
g_object_notify (controls, "active");
}
static void
gtk_media_controls_init (GtkMediaControls *controls)
{
gtk_widget_init_template (GTK_WIDGET (controls));
g_signal_connect (controls->volume_button, "notify::active",
G_CALLBACK (notify_active), controls);
}
/**

View File

@@ -98,7 +98,8 @@ enum
PROP_VALUE,
PROP_SIZE,
PROP_ADJUSTMENT,
PROP_ICONS
PROP_ICONS,
PROP_ACTIVE
};
typedef struct
@@ -248,6 +249,13 @@ gtk_scale_button_class_init (GtkScaleButtonClass *klass)
G_TYPE_STRV,
GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_ACTIVE,
g_param_spec_boolean ("active",
P_("Active"),
P_("Active"),
FALSE,
G_PARAM_READABLE));
/**
* GtkScaleButton::value-changed:
* @button: the object which received the signal
@@ -403,6 +411,14 @@ gtk_scale_button_closed (GtkScaleButton *button)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), FALSE);
}
static void
notify_active (GObject *object,
GParamSpec *pspec,
GObject *button)
{
g_object_notify (button, "active");
}
static void
gtk_scale_button_init (GtkScaleButton *button)
{
@@ -416,6 +432,9 @@ gtk_scale_button_init (GtkScaleButton *button)
gtk_widget_init_template (GTK_WIDGET (button));
gtk_widget_set_parent (priv->dock, GTK_WIDGET (button));
g_signal_connect (priv->dock, "notify::visible",
G_CALLBACK (notify_active), button);
/* Need a local reference to the adjustment */
priv->adjustment = gtk_adjustment_new (0, 0, 100, 2, 20, 0);
g_object_ref_sink (priv->adjustment);
@@ -503,6 +522,9 @@ gtk_scale_button_get_property (GObject *object,
case PROP_ICONS:
g_value_set_boxed (value, priv->icon_list);
break;
case PROP_ACTIVE:
g_value_set_boolean (value, gtk_widget_get_visible (priv->dock));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;

View File

@@ -81,6 +81,11 @@ static gboolean
gtk_video_hide_controls (gpointer data)
{
GtkVideo *self = data;
gboolean active;
g_object_get (self->controls, "active", &active, NULL);
if (active)
return G_SOURCE_CONTINUE;
gtk_revealer_set_reveal_child (GTK_REVEALER (self->controls_revealer), FALSE);