aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-08-26 16:51:33 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2013-08-26 16:51:33 +0200
commit2bc9546ec1d4c1eb1aaf5973478a0b1edcc17278 (patch)
tree68b5fcf44d1bb14c535a6f909d8554252a1300da /src
parent2094cc8a534baf610f028676092deee6e29e8beb (diff)
parentdc721ac25d910a08fc3806330b2f8bd8d3b2a4dd (diff)
downloadayatana-indicator-sound-2bc9546ec1d4c1eb1aaf5973478a0b1edcc17278.tar.gz
ayatana-indicator-sound-2bc9546ec1d4c1eb1aaf5973478a0b1edcc17278.tar.bz2
ayatana-indicator-sound-2bc9546ec1d4c1eb1aaf5973478a0b1edcc17278.zip
Merge trunk
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt123
-rw-r--r--src/Makefile.am.THIS (renamed from src/Makefile.am)0
-rw-r--r--src/service.vala45
-rw-r--r--src/sound-menu.vala3
4 files changed, 153 insertions, 18 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..a28147d
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,123 @@
+
+###########################
+# Vala Generation
+###########################
+
+set(HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound-service.h")
+set(SYMBOLS_PATH "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound-service.def")
+
+vala_init(indicator-sound-service
+ PACKAGES
+ config
+ gio-2.0
+ gio-unix-2.0
+ libxml-2.0
+ libpulse
+ libpulse-mainloop-glib
+ OPTIONS
+ --ccode
+ --thread
+ --vapidir=${CMAKE_SOURCE_DIR}/vapi/
+ --vapidir=.
+ --target-glib=2.36
+ --pkg=bus-watcher
+)
+
+vala_add(indicator-sound-service
+ service.vala
+ DEPENDS
+ sound-menu
+ volume-control
+ media-player
+ media-player-list
+)
+vala_add(indicator-sound-service
+ main.vala
+ DEPENDS
+ service
+)
+vala_add(indicator-sound-service
+ volume-control.vala
+)
+vala_add(indicator-sound-service
+ media-player.vala
+ DEPENDS
+ mpris2-interfaces
+)
+vala_add(indicator-sound-service
+ media-player-list.vala
+ DEPENDS
+ media-player
+ mpris2-interfaces
+)
+vala_add(indicator-sound-service
+ mpris2-interfaces.vala
+)
+vala_add(indicator-sound-service
+ freedesktop-interfaces.vala
+)
+vala_add(indicator-sound-service
+ sound-menu.vala
+ DEPENDS
+ media-player
+)
+
+vala_finish(indicator-sound-service
+ SOURCES
+ project_VALA_SOURCES
+ OUTPUTS
+ project_VALA_C
+ GENERATE_HEADER
+ ${HEADER_PATH}
+ GENERATE_SYMBOLS
+ ${SYMBOLS_PATH}
+)
+
+set_source_files_properties(
+ ${project_VALA_SOURCES}
+ PROPERTIES
+ HEADER_FILE_ONLY TRUE
+)
+
+set(
+ INDICATOR_SOUND_SOURCES
+ ${project_VALA_SOURCES}
+ ${project_VALA_C}
+ bus-watch-namespace.c
+ ${SYMBOLS_PATH}
+)
+
+###########################
+# Executable
+###########################
+
+add_definitions(
+ -w
+)
+
+add_executable(
+ indicator-sound-service-bin
+ ${INDICATOR_SOUND_SOURCES}
+)
+
+set_target_properties(
+ indicator-sound-service-bin
+ PROPERTIES
+ OUTPUT_NAME "indicator-sound-service"
+)
+
+target_link_libraries(
+ indicator-sound-service-bin
+ ${PULSEAUDIO_LIBRARIES}
+ ${SOUNDSERVICE_LIBRARIES}
+)
+
+###########################
+# Installation
+###########################
+
+install(
+ TARGETS indicator-sound-service-bin
+ RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/indicator-sound/
+)
+
diff --git a/src/Makefile.am b/src/Makefile.am.THIS
index 1a82a18..1a82a18 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am.THIS
diff --git a/src/service.vala b/src/service.vala
index 8fbd871..4d64502 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -17,9 +17,6 @@
* Lars Uebernickel <lars.uebernickel@canonical.com>
*/
-/* Icon.serialize() is not yet in gio-2.0.vapi; remove this when it is */
-extern Variant? g_icon_serialize (Icon icon);
-
public class IndicatorSound.Service {
public Service () {
this.settings = new Settings ("com.canonical.indicator.sound");
@@ -31,7 +28,7 @@ public class IndicatorSound.Service {
this.players.player_removed.connect (this.player_removed);
this.actions = new SimpleActionGroup ();
- this.actions.add_entries (action_entries, this);
+ this.actions.add_action_entries (action_entries, this);
this.actions.add_action (this.create_mute_action ());
this.actions.add_action (this.create_volume_action ());
this.actions.add_action (this.create_mic_volume_action ());
@@ -125,8 +122,20 @@ public class IndicatorSound.Service {
else
icon = "audio-volume-high-panel";
- var root_action = this.actions.lookup ("root") as SimpleAction;
- root_action.set_state (new Variant.parsed ("{ 'icon': %v }", serialize_themed_icon (icon)));
+ string accessible_name;
+ if (this.volume_control.mute) {
+ accessible_name = "Volume (muted)";
+ } else {
+ int volume_int = (int)(volume * 100);
+ accessible_name = @"Volume ($volume_int%)";
+ }
+
+ var root_action = actions.lookup_action ("root") as SimpleAction;
+ var builder = new VariantBuilder (new VariantType ("a{sv}"));
+ builder.add ("{sv}", "accessible-desc", new Variant.string (accessible_name));
+ builder.add ("{sv}", "icon", serialize_themed_icon (icon));
+ builder.add ("{sv}", "visible", new Variant.boolean (true));
+ root_action.set_state (builder.end());
}
Action create_mute_action () {
@@ -149,7 +158,7 @@ public class IndicatorSound.Service {
}
void volume_changed (double volume) {
- var volume_action = this.actions.lookup ("volume") as SimpleAction;
+ var volume_action = this.actions.lookup_action ("volume") as SimpleAction;
volume_action.set_state (volume);
this.update_root_icon ();
@@ -214,7 +223,7 @@ public class IndicatorSound.Service {
bool update_player_actions () {
foreach (var player in this.players) {
- SimpleAction? action = this.actions.lookup (player.id) as SimpleAction;
+ SimpleAction? action = this.actions.lookup_action (player.id) as SimpleAction;
if (action != null)
action.set_state (this.action_state_for_player (player));
}
@@ -240,11 +249,11 @@ public class IndicatorSound.Service {
SimpleAction action = new SimpleAction.stateful (player.id, null, this.action_state_for_player (player));
action.activate.connect ( () => { player.launch (); });
- this.actions.insert (action);
+ this.actions.add_action (action);
var play_action = new SimpleAction.stateful ("play." + player.id, null, player.state);
play_action.activate.connect ( () => player.play_pause () );
- this.actions.insert (play_action);
+ this.actions.add_action (play_action);
player.notify.connect ( (object, pspec) => {
if (pspec.name == "state")
play_action.set_state (player.state);
@@ -252,15 +261,15 @@ public class IndicatorSound.Service {
var next_action = new SimpleAction ("next." + player.id, null);
next_action.activate.connect ( () => player.next () );
- this.actions.insert (next_action);
+ this.actions.add_action (next_action);
var prev_action = new SimpleAction ("previous." + player.id, null);
prev_action.activate.connect ( () => player.previous () );
- this.actions.insert (prev_action);
+ this.actions.add_action (prev_action);
var playlist_action = new SimpleAction ("play-playlist." + player.id, VariantType.STRING);
playlist_action.activate.connect ( (parameter) => player.activate_playlist_by_name (parameter.get_string ()) );
- this.actions.insert (playlist_action);
+ this.actions.add_action (playlist_action);
player.notify.connect (this.eventually_update_player_actions);
@@ -268,11 +277,11 @@ public class IndicatorSound.Service {
}
void player_removed (MediaPlayer player) {
- this.actions.remove (player.id);
- this.actions.remove ("play." + player.id);
- this.actions.remove ("next." + player.id);
- this.actions.remove ("previous." + player.id);
- this.actions.remove ("play-playlist." + player.id);
+ this.actions.remove_action (player.id);
+ this.actions.remove_action ("play." + player.id);
+ this.actions.remove_action ("next." + player.id);
+ this.actions.remove_action ("previous." + player.id);
+ this.actions.remove_action ("play-playlist." + player.id);
this.menus.@foreach ( (profile, menu) => menu.remove_player (player));
diff --git a/src/sound-menu.vala b/src/sound-menu.vala
index de5500e..415a5be 100644
--- a/src/sound-menu.vala
+++ b/src/sound-menu.vala
@@ -17,6 +17,9 @@
* Lars Uebernickel <lars.uebernickel@canonical.com>
*/
+/* Icon.serialize() is not yet in gio-2.0.vapi; remove this when it is */
+extern Variant? g_icon_serialize (Icon icon);
+
class SoundMenu: Object
{
public SoundMenu (string settings_action) {