aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dbus-menu-manager.c4
-rw-r--r--src/dbus-menu-manager.h4
-rw-r--r--src/music-bridge.vala120
-rw-r--r--src/rhythmbox-controller.vala56
-rw-r--r--src/sound-service.c4
5 files changed, 100 insertions, 88 deletions
diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c
index e084bb1..9d62adb 100644
--- a/src/dbus-menu-manager.c
+++ b/src/dbus-menu-manager.c
@@ -25,7 +25,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <dbus/dbus-glib-bindings.h>
#include <libdbusmenu-glib/server.h>
-#include <libdbusmenu-glib/menuitem.h>
#include <libdbusmenu-glib/client.h>
#include "dbus-menu-manager.h"
@@ -60,7 +59,7 @@ static void refresh_menu();
/**
setup:
**/
-void dbus_menu_manager_setup()
+DbusmenuMenuitem* dbus_menu_manager_setup()
{
root_menuitem = dbusmenu_menuitem_new();
g_debug("Root ID: %d", dbusmenu_menuitem_get_id(root_menuitem));
@@ -72,6 +71,7 @@ void dbus_menu_manager_setup()
DbusmenuServer *server = dbusmenu_server_new(INDICATOR_SOUND_DBUS_OBJECT);
dbusmenu_server_set_root(server, root_menuitem);
establish_pulse_activities(dbus_interface);
+ return root_menuitem;
}
/**
diff --git a/src/dbus-menu-manager.h b/src/dbus-menu-manager.h
index 5f49e5f..a5286ca 100644
--- a/src/dbus-menu-manager.h
+++ b/src/dbus-menu-manager.h
@@ -1,6 +1,8 @@
#ifndef __INCLUDE_DBUS_MENU_MANAGER_H__
#define __INCLUDE_DBUS_MENU_MANAGER_H__
+#include <libdbusmenu-glib/menuitem.h>
+
/*
This handles the management of the dbusmeneu items.
Copyright 2010 Canonical Ltd.
@@ -21,7 +23,7 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-void dbus_menu_manager_setup();
+DbusmenuMenuitem* dbus_menu_manager_setup();
void dbus_menu_manager_teardown();
void dbus_menu_manager_update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_muted, gdouble current_vol);
// TODO update pa_state should incorporate the method below !
diff --git a/src/music-bridge.vala b/src/music-bridge.vala
index cef9d02..1cadc36 100644
--- a/src/music-bridge.vala
+++ b/src/music-bridge.vala
@@ -1,66 +1,72 @@
using Indicate;
using DbusmenuGlib;
-
-public class BridgeServer : GLib.Object{
-
- private Listener listener;
-
- private static const int LISTENING_MODE = 0;
- private static const int MASTER_MODE = 0;
- private int current_mode = LISTENING_MODE;
- private RhythmboxController rb;
-
- public BridgeServer(){
- listener = Listener.ref_default();
- listener.indicator_added.connect(on_indicator_added);
- listener.indicator_removed.connect(on_indicator_removed);
- listener.indicator_modified.connect(on_indicator_modified);
- listener.server_added.connect(on_server_added);
- listener.server_removed.connect(on_server_removed);
- listener.server_count_changed.connect(on_server_count_changed);
- //rb = new RhythmboxController();
- }
-
- public void test_me(){
- debug("I'm being tested'");
- }
-
- public void on_indicator_added(Indicate.ListenerServer object, Indicate.ListenerIndicator p0){
- debug("BridgerServer -> on_indicator_added");
- }
-
- public void on_indicator_removed(Indicate.ListenerServer object, Indicate.ListenerIndicator p0){
- debug("BridgeServer -> on_indicator_removed");
+using DbusmenuMenuitem;
+
+public class BridgeServer : GLib.Object
+{
+
+ private Listener listener;
+ private RhythmboxController rb;
+ private DbusmenuMenuitem root_menu;
+
+ public BridgeServer()
+ {
+ listener = Listener.ref_default();
+ listener.indicator_added.connect(on_indicator_added);
+ listener.indicator_removed.connect(on_indicator_removed);
+ listener.indicator_modified.connect(on_indicator_modified);
+ listener.server_added.connect(on_server_added);
+ listener.server_removed.connect(on_server_removed);
+ listener.server_count_changed.connect(on_server_count_changed);
+ }
+
+ public void set_root_menu_item(DbusmenuMenuitem menu)
+ {
+ debug("BridgeServer -> set_root_menu_item");
+ root_menu = menu;
+ }
+
+ public void on_indicator_added(Indicate.ListenerServer object, Indicate.ListenerIndicator p0)
+ {
+ debug("BridgerServer -> on_indicator_added");
+ }
+
+ public void on_indicator_removed(Indicate.ListenerServer object, Indicate.ListenerIndicator p0)
+ {
+ debug("BridgeServer -> on_indicator_removed");
+ }
+
+ public void on_indicator_modified(Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string s)
+ {
+ debug("BridgeServer -> indicator_modified with vale %s", s );
+ }
+
+ public void on_server_added(Indicate.ListenerServer object, string type)
+ {
+ debug("BridgeServer -> on_server_added with value %s", type);
+ if (type == null) return;
+ if (type.contains("music") == false) {
+ debug("server is of no interest, it is not an music server");
+ return;
+ } else {
+ debug("client of type %s has registered with us", type);
+ if (type.contains("rhythmbox") == true) {
+ rb = new RhythmboxController();
+ }
}
+ }
- public void on_indicator_modified(Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string s){
- debug("BridgeServer -> indicator_modified with vale %s", s );
- }
-
- public void on_server_added(Indicate.ListenerServer object, string type){
- debug("BridgeServer -> on_server_added with value %s", type);
- if (type == null) return;
- if (type.contains("music") == false){
- debug("server is of no interest, it is not an music server");
- return;
- }
- else{
- debug("client of type %s has registered with us", type);
- if (type.contains("rhythmbox") == true){
- rb = new RhythmboxController();
- }
- }
- }
+ public void on_server_removed(Indicate.ListenerServer object, string s)
+ {
+ debug("BridgeServer -> on_server_removed with value %s", s);
+ }
- public void on_server_removed(Indicate.ListenerServer object, string s){
- debug("BridgeServer -> on_server_removed with value %s", s);
- }
-
- public void on_server_count_changed(Indicate.ListenerServer object, uint i){
- debug("BridgeServer -> on_server_count_changed with value %u", i);
- }
+ public void on_server_count_changed(Indicate.ListenerServer object, uint i)
+ {
+ debug("BridgeServer -> on_server_count_changed with value %u", i);
+ }
-}
+}
//public void main (string[] args) {
diff --git a/src/rhythmbox-controller.vala b/src/rhythmbox-controller.vala
index 49cc9c0..734c8bd 100644
--- a/src/rhythmbox-controller.vala
+++ b/src/rhythmbox-controller.vala
@@ -1,40 +1,44 @@
using DbusmenuGlib;
-public class RhythmboxController : GLib.Object{
+public class RhythmboxController : GLib.Object
+{
private DBus.Connection connection;
private dynamic DBus.Object rhythmbox_player;
private dynamic DBus.Object rhythmbox_shell;
private dynamic DBus.Object rhythmbox_playlistmgr;
- public RhythmboxController(){
- try{
- this.connection = DBus.Bus.get (DBus.BusType.SESSION);
- }
- catch(Error e){
- debug("Problems connecting to the session bus - %s", e.message);
- }
-
+ public RhythmboxController()
+ {
+ try {
+ this.connection = DBus.Bus.get (DBus.BusType.SESSION);
+ } catch (Error e) {
+ debug("Problems connecting to the session bus - %s", e.message);
+ }
+
this.rhythmbox_player = this.connection.get_object ("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Player", "org.gnome.Rhythmbox.Player");
- this.rhythmbox_shell = connection.get_object ("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Shell", "/org/gnome/Rhythmbox/Shell");
- this.rhythmbox_playlistmgr = connection.get_object ("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/PlaylistManager", "/org/gnome/Rhythmbox/PlaylistManager");
+ this.rhythmbox_shell = connection.get_object ("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Shell", "org.gnome.Rhythmbox.Shell");
+ this.rhythmbox_playlistmgr = connection.get_object ("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/PlaylistManager", "/org/gnome/Rhythmbox/PlaylistManager");
- //this.rhythmbox_player.PlayingUriChanged += onUriChange;
- this.rhythmbox_player.elapsedChanged += onElapsedChange;
+ this.rhythmbox_player.playingUriChanged += onUriChange;
+ this.rhythmbox_player.elapsedChanged += onElapsedChange;
- this.rhythmbox_player.setMute(false);
- bool b = this.rhythmbox_player.getMute();
- this.rhythmbox_player.playPause(true);
- //this.rhythmbox_playlistmgr.getPlaylists();
- //debug("playlist = %s", [0]);
- debug("New rhythmbox controller has been instantiated %i", (int)b);
- }
+ debug("New rhythmbox controller has been instantiated");
+ }
-// private void onUriChange(dynamic DBus.Object rhythmbox, string uri){
-// debug("onUriChange, new uri : %s", uri);
-// }
+ private void onUriChange(dynamic DBus.Object rhythmbox, string uri)
+ {
+ debug("onUriChange, new uri : %s", uri);
+ //;// = new HashTable<string, string>(str_hash,str_equal);
+ HashTable<string,Value?> ht = this.rhythmbox_shell.getSongProperties(uri);
+ var l = ht.get_keys();
+ foreach(string s in l){
+ debug("key = %s", s);
+ }
+ }
- private void onElapsedChange(dynamic DBus.Object rhythmbox, uint32 time){
- debug("onElapsedChange, new time = %u", time);
- }
+ private void onElapsedChange(dynamic DBus.Object rhythmbox, uint32 time)
+ {
+ debug("onElapsedChange, new time = %u", time);
+ }
}
diff --git a/src/sound-service.c b/src/sound-service.c
index dad1bcd..db48676 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -70,9 +70,9 @@ main (int argc, char ** argv)
INDICATOR_SERVICE_SIGNAL_SHUTDOWN,
G_CALLBACK(service_shutdown), NULL);
- dbus_menu_manager_setup();
+ DbusmenuMenuitem* root_menuitem = dbus_menu_manager_setup();
BridgeServer* server = bridge_server_new();
- bridge_server_test_me(server);
+ bridge_server_set_root_menu_item(server, root_menuitem);
// Run the loop
mainloop = g_main_loop_new(NULL, FALSE);