diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2015-06-11 18:52:12 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-06-11 18:52:12 +0200 |
commit | 40e21cea24b56e068b4a23ef17b5f5491c064b47 (patch) | |
tree | 31b0b7aca2fc4adacdfb66ba7c3fea84cfbf71e1 /playback | |
parent | b5e35ad70bd171c9fd4748d8c3fcba7f60ccb4e3 (diff) |
playback/player: gtk: Inhibit the screen saver when playing something
Diffstat (limited to 'playback')
-rw-r--r-- | playback/player/gtk/gtk-play.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/playback/player/gtk/gtk-play.c b/playback/player/gtk/gtk-play.c index df0f5b9..8204362 100644 --- a/playback/player/gtk/gtk-play.c +++ b/playback/player/gtk/gtk-play.c @@ -57,6 +57,7 @@ typedef struct GList *uris; GList *current_uri; + guint inhibit_cookie; GtkWidget *play_pause_button; GtkWidget *prev_button, *next_button; @@ -172,7 +173,19 @@ play_pause_clicked_cb (GtkButton * button, GtkPlay * play) GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (play->play_pause_button), image); play->playing = FALSE; + + if (play->inhibit_cookie) + gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()), + play->inhibit_cookie); + play->inhibit_cookie = 0; } 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); image = 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 gst_player_set_uri (play->player, uri->data); 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); - else + } else { 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); } @@ -1417,6 +1441,10 @@ eos_cb (GstPlayer * unused, GtkPlay * play) GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (play->play_pause_button), image); 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->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); create_ui (self); @@ -1671,6 +1706,11 @@ gtk_play_dispose (GObject * 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) g_free (self->uri); self->uri = NULL; |