[totem] browser-plugin: Use gtk_application_inhibit()



commit 219eaf4d5ba4f2c76fcb6db6161e1497b0ffe62e
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Mar 28 17:07:32 2012 +0200

    browser-plugin: Use gtk_application_inhibit()
    
    To inhibit the screensaver when playing.

 browser-plugin/Makefile.am           |    2 --
 browser-plugin/totem-plugin-viewer.c |   25 +++++++++++++++----------
 2 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/browser-plugin/Makefile.am b/browser-plugin/Makefile.am
index dbaa3a4..9bfe326 100644
--- a/browser-plugin/Makefile.am
+++ b/browser-plugin/Makefile.am
@@ -8,7 +8,6 @@ EXTRA_DIST = \
 
 AM_CPPFLAGS = \
 	-I$(top_srcdir)					\
-	-I$(top_srcdir)/lib				\
 	-I$(top_srcdir)/src				\
 	-I$(top_srcdir)/src/backend			\
 	-I$(top_builddir)/src				\
@@ -108,7 +107,6 @@ totem_plugin_viewer_CFLAGS = \
 totem_plugin_viewer_LDADD = \
 	$(top_builddir)/src/backend/libbaconvideowidget.la		\
 	$(top_builddir)/src/libtotem_player.la				\
-	$(top_builddir)/lib/libtotemscrsaver.la				\
 	$(DEPENDENCY_LIBS)	\
 	$(SN_LIBS)		\
 	$(DBUS_LIBS)		\
diff --git a/browser-plugin/totem-plugin-viewer.c b/browser-plugin/totem-plugin-viewer.c
index 93f4e35..3d8a8bb 100644
--- a/browser-plugin/totem-plugin-viewer.c
+++ b/browser-plugin/totem-plugin-viewer.c
@@ -40,7 +40,6 @@
 #include <gdk/gdkkeysyms.h>
 
 #include <totem-pl-parser.h>
-#include <totem-scrsaver.h>
 
 #include <dbus/dbus-glib.h>
 
@@ -110,7 +109,6 @@ typedef struct _TotemEmbedded {
 	GtkWidget *pp_button;
 	GtkWidget *pp_fs_button;
 	TotemStatusbar *statusbar;
-	TotemScrsaver *scrsaver;
 	int width, height;
         char *user_agent;
 	const char *mimetype;
@@ -125,6 +123,7 @@ typedef struct _TotemEmbedded {
 	BaconVideoWidget *bvw;
 	TotemStates state;
 	GdkCursor *cursor;
+	guint inhibit_id;
 
 	/* Playlist, a GList of TotemPlItem */
 	GList *playlist, *current;
@@ -379,8 +378,19 @@ totem_embedded_set_state (TotemEmbedded *emb, TotemStates state)
 		break;
 	}
 
-	if (emb->scrsaver != NULL)
-		totem_scrsaver_set_state (emb->scrsaver, (state == TOTEM_STATE_PLAYING) ? FALSE : TRUE);
+	if (state == TOTEM_STATE_PLAYING) {
+		if (emb->inhibit_id == 0) {
+			emb->inhibit_id = gtk_application_inhibit (GTK_APPLICATION (emb),
+								   NULL,
+								   GTK_APPLICATION_INHIBIT_IDLE,
+								   _("Playing a movie"));
+		}
+	} else {
+		if (emb->inhibit_id != 0) {
+			gtk_application_uninhibit (GTK_APPLICATION (emb), emb->inhibit_id);
+			emb->inhibit_id = 0;
+		}
+	}
 	gtk_image_set_from_icon_name (GTK_IMAGE (image), id, GTK_ICON_SIZE_MENU);
 	gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (emb->pp_fs_button), id);
 
@@ -1886,13 +1896,8 @@ totem_embedded_construct (TotemEmbedded *emb,
 
 	emb->statusbar = TOTEM_STATUSBAR (gtk_builder_get_object (emb->xml, "statusbar"));
 
-	if (!emb->hidden) {
+	if (!emb->hidden)
 		gtk_widget_set_size_request (emb->window, width, height);
-		emb->scrsaver = totem_scrsaver_new ();
-		g_object_set (emb->scrsaver,
-			      "reason", _("Playing a movie"),
-			      NULL);
-	}
 
 #ifdef GNOME_ENABLE_DEBUG
 	child = GTK_WIDGET (gtk_builder_get_object (emb->xml, "controls"));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]