Commit 0828676d authored by Bastien Nocera's avatar Bastien Nocera Committed by Bastien Nocera

Lock the screensaver when only audio is playing, but allow the user to

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)


svn path=/trunk/; revision=5036
parent 24eeb798
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)
2008-01-21 Bastien Nocera <hadess@hadess.net>
Patch from Patrick Hulin <patrick.hulin@gmail.com>
......
<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>
......
......@@ -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>
......
......@@ -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 @@ static void
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 @@ property_notify_cb (TotemObject *totem,
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 @@ impl_deactivate (TotemPlugin *plugin,
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);
}
......@@ -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);
......@@ -197,6 +200,18 @@ checkbutton3_toggled_cb (GtkToggleButton *togglebutton, Totem *totem)
totem->autoload_subs = value;
}
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)
{
......@@ -253,7 +268,7 @@ auto_resize_changed_cb (GConfClient *client, guint cnxn_id,
static void
show_vfx_changed_cb (GConfClient *client, guint cnxn_id,
GConfEntry *entry, Totem *totem)
GConfEntry *entry, Totem *totem)
{
GObject *item;
......@@ -269,6 +284,24 @@ show_vfx_changed_cb (GConfClient *client, guint cnxn_id,
G_CALLBACK (checkbutton2_toggled_cb), totem);
}
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 @@ totem_setup_preferences (Totem *totem)
{
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 @@ totem_setup_preferences (Totem *totem)
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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment