totem r5036 - in trunk: . data src src/plugins/screensaver



Author: hadess
Date: Fri Jan 25 14:55:43 2008
New Revision: 5036
URL: http://svn.gnome.org/viewvc/totem?rev=5036&view=rev

Log:
2008-01-25  Bastien Nocera  <hadess hadess net>

	* data/totem.schemas.in:
	* data/totem.ui:
	* src/plugins/screensaver/totem-screensaver.c:
	(totem_screensaver_update_from_state),
	(lock_screensaver_on_audio_changed_cb), (impl_activate),
	(impl_deactivate):
	* src/totem-preferences.c: (checkbutton4_toggled_cb),
	(lock_screensaver_on_audio_changed_cb), (totem_setup_preferences):
	Lock the screensaver when only audio is playing, but allow the
	user to override that, to avoid monitor-powered speakers being
	turned off

	Based on patch by Patrick Hulin <patrick hulin gmail com>

	(Closes: #481080)



Modified:
   trunk/ChangeLog
   trunk/data/totem.schemas.in
   trunk/data/totem.ui
   trunk/src/plugins/screensaver/totem-screensaver.c
   trunk/src/totem-preferences.c

Modified: trunk/data/totem.schemas.in
==============================================================================
--- trunk/data/totem.schemas.in	(original)
+++ trunk/data/totem.schemas.in	Fri Jan 25 14:55:43 2008
@@ -1,5 +1,20 @@
 <gconfschemafile>
-    <schemalist>    
+  <schemalist>
+
+      <schema>
+        <key>/schemas/apps/totem/lock_screensaver_on_audio</key>
+	<applyto>/apps/totem/lock_screensaver_on_audio</applyto>
+	<owner>totem</owner>
+	<type>bool</type>
+	<default>true</default>
+	<locale name="C">
+	  <short>Allow the screensaver to activate even when audio-only is playing</short>
+	  <long>
+	    Allow the screensaver to activate even when audio-only is playing.
+	    This is useful for monitor powered speakers.
+	  </long>
+	</locale>
+      </schema>
 
       <schema>
         <key>/schemas/apps/totem/show_vfx</key>

Modified: trunk/data/totem.ui
==============================================================================
--- trunk/data/totem.ui	(original)
+++ trunk/data/totem.ui	Fri Jan 25 14:55:43 2008
@@ -1238,7 +1238,40 @@
 		      <property name="expand">False</property>
 		      <property name="fill">False</property>
 		    </packing>
+	    </child>
+		  <child>
+		    <object class="GtkAlignment" id="alignment8">
+		      <property name="visible">True</property>
+		      <property name="xalign">0.5</property>
+		      <property name="yalign">0.5</property>
+		      <property name="xscale">1</property>
+		      <property name="yscale">1</property>
+		      <property name="top_padding">0</property>
+		      <property name="bottom_padding">0</property>
+		      <property name="left_padding">12</property>
+		      <property name="right_padding">0</property>
+		      <child>
+                <object class="GtkCheckButton" id="tpw_screensaver_checkbutton">
+                  <property name="visible">True</property>
+                  <property name="can_focus">True</property>
+                  <property name="label" translatable="yes">_Allow the screensaver to activate even when audio-only is playing</property>
+                  <property name="use_underline">True</property>
+                  <property name="relief">GTK_RELIEF_NORMAL</property>
+                  <property name="focus_on_click">True</property>
+                  <property name="active">False</property>
+                  <property name="inconsistent">False</property>
+                  <property name="draw_indicator">True</property>
+                  <signal name="toggled" handler="checkbutton4_toggled_cb"/>
+                </object>
+		      </child>
+		    </object>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
 		  </child>
+
 		</object>
 		<packing>
 		  <property name="padding">0</property>

Modified: trunk/src/plugins/screensaver/totem-screensaver.c
==============================================================================
--- trunk/src/plugins/screensaver/totem-screensaver.c	(original)
+++ trunk/src/plugins/screensaver/totem-screensaver.c	Fri Jan 25 14:55:43 2008
@@ -30,12 +30,15 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <glib/gi18n-lib.h>
+#include <gconf/gconf-client.h>
+
 #include <gmodule.h>
 #include <string.h>
 
 #include "totem-plugin.h"
 #include "totem.h"
 #include "totem-scrsaver.h"
+#include "backend/bacon-video-widget.h"
 
 #define TOTEM_TYPE_SCREENSAVER_PLUGIN		(totem_screensaver_plugin_get_type ())
 #define TOTEM_SCREENSAVER_PLUGIN(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), TOTEM_TYPE_SCREENSAVER_PLUGIN, TotemScreensaverPlugin))
@@ -47,9 +50,11 @@
 typedef struct
 {
 	TotemPlugin   parent;
+	TotemObject  *totem;
 
 	TotemScrsaver *scr;
 	guint          handler_id_playing;
+	guint          handler_id_gconf;
 } TotemScreensaverPlugin;
 
 typedef struct
@@ -100,11 +105,27 @@
 totem_screensaver_update_from_state (TotemObject *totem,
 				     TotemScreensaverPlugin *pi)
 {
-	if (totem_is_playing (totem) != FALSE) {
+	gboolean lock_screensaver_on_audio, visual_effects, can_get_frames;
+	BaconVideoWidget *bvw;
+	GConfClient *gc;
+
+	bvw = BACON_VIDEO_WIDGET (totem_get_video_widget ((Totem *)(totem)));
+	gc = gconf_client_get_default ();
+
+	visual_effects = gconf_client_get_bool (gc,
+						GCONF_PREFIX"/show_vfx",
+						NULL);
+	lock_screensaver_on_audio = gconf_client_get_bool (gc, 
+							   GCONF_PREFIX"/lock_screensaver_on_audio",
+							   NULL);
+	can_get_frames = bacon_video_widget_can_get_frames (bvw, NULL);
+
+	if (totem_is_playing (totem) != FALSE && (lock_screensaver_on_audio || can_get_frames))
 		totem_scrsaver_disable (pi->scr);
-	} else {
+	else
 		totem_scrsaver_enable (pi->scr);
-	}
+
+	g_object_unref (gc);
 }
 
 static void
@@ -115,18 +136,36 @@
 	totem_screensaver_update_from_state (totem, pi);
 }
 
+static void
+lock_screensaver_on_audio_changed_cb (GConfClient *client, guint cnxn_id,
+				      GConfEntry *entry, TotemScreensaverPlugin *pi)
+{
+	totem_screensaver_update_from_state (pi->totem, pi);
+}
+
 static gboolean
 impl_activate (TotemPlugin *plugin,
 	       TotemObject *totem,
 	       GError **error)
 {
 	TotemScreensaverPlugin *pi = TOTEM_SCREENSAVER_PLUGIN (plugin);
+	GConfClient *gc;
+
+	gc = gconf_client_get_default ();
+	gconf_client_add_dir (gc, GCONF_PREFIX,
+			      GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+	pi->handler_id_gconf = gconf_client_notify_add (gc, GCONF_PREFIX"/lock_screensaver_on_audio",
+							(GConfClientNotifyFunc) lock_screensaver_on_audio_changed_cb,
+							plugin, NULL, NULL);
+	g_object_unref (gc);
 
 	pi->handler_id_playing = g_signal_connect (G_OBJECT (totem),
 				"notify::playing",
 				G_CALLBACK (property_notify_cb),
 				pi);
 
+	pi->totem = g_object_ref (totem);
+
 	/* Force setting the current status */
 	totem_screensaver_update_from_state (totem, pi);
 
@@ -138,9 +177,16 @@
 		 TotemObject *totem)
 {
 	TotemScreensaverPlugin *pi = TOTEM_SCREENSAVER_PLUGIN (plugin);
+	GConfClient *gc;
+
+	gc = gconf_client_get_default ();
+	gconf_client_notify_remove (gc, pi->handler_id_gconf);
+	g_object_unref (gc);
 
 	g_signal_handler_disconnect (G_OBJECT (totem), pi->handler_id_playing);
 
+	g_object_unref (pi->totem);
+
 	totem_scrsaver_enable (pi->scr);
 }
 

Modified: trunk/src/totem-preferences.c
==============================================================================
--- trunk/src/totem-preferences.c	(original)
+++ trunk/src/totem-preferences.c	Fri Jan 25 14:55:43 2008
@@ -41,6 +41,8 @@
 #include "totem-interface.h"
 #include "video-utils.h"
 #include "totem-subtitle-encoding.h"
+#include "totem-plugin.h"
+#include "totem-plugins-engine.h"
 
 #include "debug.h"
 
@@ -48,6 +50,7 @@
 void checkbutton1_toggled_cb (GtkToggleButton *togglebutton, Totem *totem);
 void checkbutton2_toggled_cb (GtkToggleButton *togglebutton, Totem *totem);
 void checkbutton3_toggled_cb (GtkToggleButton *togglebutton, Totem *totem);
+void checkbutton4_toggled_cb (GtkToggleButton *togglebutton, Totem *totem);
 void tvout_toggled_cb (GtkToggleButton *togglebutton, Totem *totem);
 void connection_combobox_changed (GtkComboBox *combobox, Totem *totem);
 void visual_menu_changed (GtkComboBox *combobox, Totem *totem);
@@ -198,6 +201,18 @@
 }
 
 void
+checkbutton4_toggled_cb (GtkToggleButton *togglebutton, Totem *totem)
+{
+	gboolean value;
+
+	value = gtk_toggle_button_get_active (togglebutton);
+
+	gconf_client_set_bool (totem->gc,
+			       GCONF_PREFIX"/lock_screensaver_on_audio", 
+			       value, NULL);
+}
+
+void
 tvout_toggled_cb (GtkToggleButton *togglebutton, Totem *totem)
 {
 	TvOutType type;
@@ -253,7 +268,7 @@
 
 static void
 show_vfx_changed_cb (GConfClient *client, guint cnxn_id,
-		GConfEntry *entry, Totem *totem)
+		     GConfEntry *entry, Totem *totem)
 {
 	GObject *item;
 
@@ -270,6 +285,24 @@
 }
 
 static void
+lock_screensaver_on_audio_changed_cb (GConfClient *client, guint cnxn_id,
+				      GConfEntry *entry, Totem *totem)
+{
+	GObject *item;
+
+	item = gtk_builder_get_object (totem->xml, "tpw_screensaver_checkbutton");
+	g_signal_handlers_disconnect_by_func (item,
+					      checkbutton4_toggled_cb, totem);
+
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item),
+				      gconf_client_get_bool (totem->gc,
+							     GCONF_PREFIX"/lock_screensaver_on_audio", NULL));
+
+	g_signal_connect (item, "toggled",
+			  G_CALLBACK (checkbutton4_toggled_cb), totem);
+}
+
+static void
 autoload_subtitles_changed_cb (GConfClient *client, guint cnxn_id,
 			       GConfEntry *entry, Totem *totem)
 {
@@ -475,7 +508,7 @@
 {
 	GtkWidget *menu;
 	GtkAction *action;
-	gboolean show_visuals, auto_resize, is_local, deinterlace;
+	gboolean show_visuals, auto_resize, is_local, deinterlace, lock_screensaver_on_audio;
 	int connection_speed, i;
 	char *visual, *font, *encoding;
 	GList *list, *l;
@@ -539,6 +572,15 @@
 	bacon_video_widget_set_auto_resize
 		(BACON_VIDEO_WIDGET (totem->bvw), auto_resize);
 
+	/* Screensaver audio locking */
+	lock_screensaver_on_audio = gconf_client_get_bool (totem->gc,
+							   GCONF_PREFIX"/lock_screensaver_on_audio", NULL);
+	item = gtk_builder_get_object (totem->xml, "tpw_screensaver_checkbutton");
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), lock_screensaver_on_audio);
+	gconf_client_notify_add (totem->gc, GCONF_PREFIX"/lock_screensaver_on_audio",
+				 (GConfClientNotifyFunc) lock_screensaver_on_audio_changed_cb,
+				 totem, NULL, NULL);
+
 	/* Connection Speed */
 	connection_speed = bacon_video_widget_get_connection_speed (totem->bvw);
 	item = gtk_builder_get_object (totem->xml, "tpw_speed_combobox");



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