totem r5827 - in trunk: . src



Author: hadess
Date: Fri Dec  5 15:12:30 2008
New Revision: 5827
URL: http://svn.gnome.org/viewvc/totem?rev=5827&view=rev

Log:
2008-12-05  Bastien Nocera  <hadess hadess net>

	* src/totem-options.c (totem_options_process_for_server):
	* src/totem-options.h:
	* src/totem-private.h:
	* src/totem.c (totem_action_exit), (totem_action_volume_relative),
	(totem_action_volume_toggle_mute),
	(volume_button_value_changed_cb), (totem_action_remote):
	* src/totem.h: Add proper support for mute toggling through
	the remote interface, and add a command-line option for it
	(Closes: #554318)



Modified:
   trunk/ChangeLog
   trunk/src/totem-options.c
   trunk/src/totem-options.h
   trunk/src/totem-private.h
   trunk/src/totem.c
   trunk/src/totem.h

Modified: trunk/src/totem-options.c
==============================================================================
--- trunk/src/totem-options.c	(original)
+++ trunk/src/totem-options.c	Fri Dec  5 15:12:30 2008
@@ -56,6 +56,7 @@
 	{"seek-bwd", '\0', 0, G_OPTION_ARG_NONE, &optionstate.seekbwd, N_("Seek Backwards"), NULL},
 	{"volume-up", '\0', 0, G_OPTION_ARG_NONE, &optionstate.volumeup, N_("Volume Up"), NULL},
 	{"volume-down", '\0', 0, G_OPTION_ARG_NONE, &optionstate.volumedown, N_("Volume Down"), NULL},
+	{"mute", '\0', 0, G_OPTION_ARG_NONE, &optionstate.mute, N_("Mute sound"), NULL},
 	{"fullscreen", '\0', 0, G_OPTION_ARG_NONE, &optionstate.fullscreen, N_("Toggle Fullscreen"), NULL},
 	{"toggle-controls", '\0', 0, G_OPTION_ARG_NONE, &optionstate.togglecontrols, N_("Show/Hide Controls"), NULL},
 	{"quit", '\0', 0, G_OPTION_ARG_NONE, &optionstate.quit, N_("Quit"), NULL},
@@ -216,6 +217,11 @@
 					  (TOTEM_REMOTE_COMMAND_VOLUME_DOWN));
 	}
 
+	if (options->mute) {
+		commands = g_list_append (commands, totem_option_create_line
+					  (TOTEM_REMOTE_COMMAND_MUTE));
+	}
+
 	if (options->fullscreen) {
 		commands = g_list_append (commands, totem_option_create_line
 					  (TOTEM_REMOTE_COMMAND_FULLSCREEN));

Modified: trunk/src/totem-options.h
==============================================================================
--- trunk/src/totem-options.h	(original)
+++ trunk/src/totem-options.h	Fri Dec  5 15:12:30 2008
@@ -43,6 +43,7 @@
 	gboolean seekbwd;
 	gboolean volumeup;
 	gboolean volumedown;
+	gboolean mute;
 	gboolean fullscreen;
 	gboolean togglecontrols;
 	gboolean quit;

Modified: trunk/src/totem-private.h
==============================================================================
--- trunk/src/totem-private.h	(original)
+++ trunk/src/totem-private.h	Fri Dec  5 15:12:30 2008
@@ -115,6 +115,8 @@
 	/* Volume */
 	GtkWidget *volume;
 	gboolean volume_sensitive;
+	gboolean muted;
+	double prev_volume;
 
 	/* Subtitles/Languages menus */
 	GtkWidget *subtitles;

Modified: trunk/src/totem.c
==============================================================================
--- trunk/src/totem.c	(original)
+++ trunk/src/totem.c	Fri Dec  5 15:12:30 2008
@@ -264,7 +264,10 @@
 	if (totem->bvw) {
 		int vol;
 
-		vol = bacon_video_widget_get_volume (totem->bvw) * 100.0 + 0.5;
+		if (totem->muted != FALSE)
+			vol = totem->prev_volume * 100.0 + 0.5;
+		else
+			vol = bacon_video_widget_get_volume (totem->bvw) * 100.0 + 0.5;
 		/* FIXME move the volume to the static file? */
 		gconf_client_set_int (totem->gc,
 				GCONF_PREFIX"/volume",
@@ -1370,12 +1373,33 @@
 
 	if (bacon_video_widget_can_set_volume (totem->bvw) == FALSE)
 		return;
+	if (totem->muted != FALSE)
+		totem_action_volume_toggle_mute (totem);
 
 	vol = bacon_video_widget_get_volume (totem->bvw);
 	bacon_video_widget_set_volume (totem->bvw, vol + off_pct);
 }
 
 /**
+ * totem_action_volume_toggle_mute:
+ * @totem: a #TotemObject
+ *
+ * Toggles the mute status.
+ **/
+void
+totem_action_volume_toggle_mute (Totem *totem)
+{
+	if (totem->muted == FALSE) {
+		totem->muted = TRUE;
+		totem->prev_volume = bacon_video_widget_get_volume (totem->bvw);
+		bacon_video_widget_set_volume (totem->bvw, 0.0);
+	} else {
+		totem->muted = FALSE;
+		bacon_video_widget_set_volume (totem->bvw, totem->prev_volume);
+	}
+}
+
+/**
  * totem_action_toggle_aspect_ratio:
  * @totem: a #TotemObject
  *
@@ -1831,6 +1855,7 @@
 void
 volume_button_value_changed_cb (GtkScaleButton *button, gdouble value, Totem *totem)
 {
+	totem->muted = FALSE;
 	bacon_video_widget_set_volume (totem->bvw, value);
 }
 
@@ -2358,7 +2383,7 @@
 		/* TODO - how to see if can, and play the DVD (like the menu item) */
 		break;
 	case TOTEM_REMOTE_COMMAND_MUTE:
-		totem_action_volume_relative (totem, -1.0);
+		totem_action_volume_toggle_mute (totem);
 		break;
 	case TOTEM_REMOTE_COMMAND_TOGGLE_ASPECT:
 		totem_action_toggle_aspect_ratio (totem);

Modified: trunk/src/totem.h
==============================================================================
--- trunk/src/totem.h	(original)
+++ trunk/src/totem.h	Fri Dec  5 15:12:30 2008
@@ -131,6 +131,7 @@
 void	totem_action_seek_time			(Totem *totem, gint64 sec);
 void	totem_action_seek_relative		(Totem *totem, gint64 offset);
 void	totem_action_volume_relative		(Totem *totem, double off_pct);
+void	totem_action_volume_toggle_mute		(Totem *totem);
 gboolean totem_action_set_mrl			(Totem *totem,
 						 const char *mrl,
 						 const char *subtitle);



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