mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
playback/player: gtk: Inhibit the screen saver when playing something
This commit is contained in:
parent
b5e35ad70b
commit
40e21cea24
1 changed files with 42 additions and 2 deletions
|
@ -57,6 +57,7 @@ typedef struct
|
||||||
GList *uris;
|
GList *uris;
|
||||||
GList *current_uri;
|
GList *current_uri;
|
||||||
|
|
||||||
|
guint inhibit_cookie;
|
||||||
|
|
||||||
GtkWidget *play_pause_button;
|
GtkWidget *play_pause_button;
|
||||||
GtkWidget *prev_button, *next_button;
|
GtkWidget *prev_button, *next_button;
|
||||||
|
@ -172,7 +173,19 @@ play_pause_clicked_cb (GtkButton * button, GtkPlay * play)
|
||||||
GTK_ICON_SIZE_BUTTON);
|
GTK_ICON_SIZE_BUTTON);
|
||||||
gtk_button_set_image (GTK_BUTTON (play->play_pause_button), image);
|
gtk_button_set_image (GTK_BUTTON (play->play_pause_button), image);
|
||||||
play->playing = FALSE;
|
play->playing = FALSE;
|
||||||
|
|
||||||
|
if (play->inhibit_cookie)
|
||||||
|
gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
|
||||||
|
play->inhibit_cookie);
|
||||||
|
play->inhibit_cookie = 0;
|
||||||
} else {
|
} else {
|
||||||
|
if (play->inhibit_cookie)
|
||||||
|
gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
|
||||||
|
play->inhibit_cookie);
|
||||||
|
play->inhibit_cookie =
|
||||||
|
gtk_application_inhibit (GTK_APPLICATION (g_application_get_default ()),
|
||||||
|
GTK_WINDOW (play), GTK_APPLICATION_INHIBIT_IDLE, "Playing media");
|
||||||
|
|
||||||
gst_player_play (play->player);
|
gst_player_play (play->player);
|
||||||
image =
|
image =
|
||||||
gtk_image_new_from_icon_name ("media-playback-pause",
|
gtk_image_new_from_icon_name ("media-playback-pause",
|
||||||
|
@ -200,10 +213,21 @@ play_current_uri (GtkPlay * play, GList * uri, const gchar * ext_suburi)
|
||||||
else
|
else
|
||||||
gst_player_set_uri (play->player, uri->data);
|
gst_player_set_uri (play->player, uri->data);
|
||||||
play->current_uri = uri;
|
play->current_uri = uri;
|
||||||
if (play->playing)
|
if (play->playing) {
|
||||||
|
if (play->inhibit_cookie)
|
||||||
|
gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
|
||||||
|
play->inhibit_cookie);
|
||||||
|
play->inhibit_cookie =
|
||||||
|
gtk_application_inhibit (GTK_APPLICATION (g_application_get_default ()),
|
||||||
|
GTK_WINDOW (play), GTK_APPLICATION_INHIBIT_IDLE, "Playing media");
|
||||||
gst_player_play (play->player);
|
gst_player_play (play->player);
|
||||||
else
|
} else {
|
||||||
gst_player_pause (play->player);
|
gst_player_pause (play->player);
|
||||||
|
if (play->inhibit_cookie)
|
||||||
|
gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
|
||||||
|
play->inhibit_cookie);
|
||||||
|
play->inhibit_cookie = 0;
|
||||||
|
}
|
||||||
set_title (play, uri->data);
|
set_title (play, uri->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1417,6 +1441,10 @@ eos_cb (GstPlayer * unused, GtkPlay * play)
|
||||||
GTK_ICON_SIZE_BUTTON);
|
GTK_ICON_SIZE_BUTTON);
|
||||||
gtk_button_set_image (GTK_BUTTON (play->play_pause_button), image);
|
gtk_button_set_image (GTK_BUTTON (play->play_pause_button), image);
|
||||||
play->playing = FALSE;
|
play->playing = FALSE;
|
||||||
|
if (play->inhibit_cookie)
|
||||||
|
gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default
|
||||||
|
()), play->inhibit_cookie);
|
||||||
|
play->inhibit_cookie = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1634,6 +1662,13 @@ gtk_play_constructor (GType type, guint n_construct_params,
|
||||||
self->player = gst_player_new ();
|
self->player = gst_player_new ();
|
||||||
self->playing = TRUE;
|
self->playing = TRUE;
|
||||||
|
|
||||||
|
if (self->inhibit_cookie)
|
||||||
|
gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
|
||||||
|
self->inhibit_cookie);
|
||||||
|
self->inhibit_cookie =
|
||||||
|
gtk_application_inhibit (GTK_APPLICATION (g_application_get_default ()),
|
||||||
|
GTK_WINDOW (self), GTK_APPLICATION_INHIBIT_IDLE, "Playing media");
|
||||||
|
|
||||||
g_object_set (self->player, "dispatch-to-main-context", TRUE, NULL);
|
g_object_set (self->player, "dispatch-to-main-context", TRUE, NULL);
|
||||||
|
|
||||||
create_ui (self);
|
create_ui (self);
|
||||||
|
@ -1671,6 +1706,11 @@ gtk_play_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
GtkPlay *self = (GtkPlay *) object;
|
GtkPlay *self = (GtkPlay *) object;
|
||||||
|
|
||||||
|
if (self->inhibit_cookie)
|
||||||
|
gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
|
||||||
|
self->inhibit_cookie);
|
||||||
|
self->inhibit_cookie = 0;
|
||||||
|
|
||||||
if (self->uri)
|
if (self->uri)
|
||||||
g_free (self->uri);
|
g_free (self->uri);
|
||||||
self->uri = NULL;
|
self->uri = NULL;
|
||||||
|
|
Loading…
Reference in a new issue