From ff088da3bd5e436af0f205f01cf858a9c0a7004d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 5 May 2010 22:30:31 +0200 Subject: mix and match vala and c --- configure.ac | 10 ++++-- src/Makefile.am | 101 ++++++++++++++++++++++++++++++++++++---------------- src/sound-service.c | 20 ++++++----- 3 files changed, 89 insertions(+), 42 deletions(-) diff --git a/configure.ac b/configure.ac index 23e8d9b..b751fb2 100644 --- a/configure.ac +++ b/configure.ac @@ -9,6 +9,9 @@ AM_INIT_AUTOMAKE(indicator-sound, 0.2.3) AM_MAINTAINER_MODE IT_PROG_INTLTOOL([0.35.0]) +AM_PROG_VALAC([0.7.8]) +AS_IF([test -z "$VALAC"], [AC_MSG_ERROR(["No valac compiler found."])]) + AC_ISC_POSIX AC_PROG_CC @@ -31,16 +34,17 @@ DBUSMENUGTK_REQUIRED_VERSION=0.2.2 POLKIT_REQUIRED_VERSION=0.92 PULSE_AUDIO_REQUIRED_VERSION=0.9.19 INDICATOR_DISPLAY_OBJECTS=0.1.4 +INDICATE_REQUIRED_VERSION=0.3.0 +DBUSMENUGLIB_REQUIRED_VERSION=0.1.1 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION - dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION + dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS) AC_SUBST(APPLET_CFLAGS) AC_SUBST(APPLET_LIBS) -DBUSMENUGLIB_REQUIRED_VERSION=0.1.1 PKG_CHECK_MODULES(PULSEAUDIO, libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION) AC_SUBST(PULSEAUDIO_CFLAGS) @@ -48,7 +52,7 @@ AC_SUBST(PULSEAUDIO_LIBS) PKG_CHECK_MODULES(SOUNDSERVICE, dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION -) + indicate >= $INDICATOR_REQUIRED_VERSION) AC_SUBST(SOUNDSERVICE_CFLAGS) AC_SUBST(SOUNDERVICE_LIBS) diff --git a/src/Makefile.am b/src/Makefile.am index f472662..7a747a3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,11 +7,11 @@ libexec_PROGRAMS = indicator-sound-service soundmenulibdir = $(INDICATORDIR) soundmenulib_LTLIBRARIES = libsoundmenu.la libsoundmenu_la_SOURCES = \ - common-defs.h \ + common-defs.h \ indicator-sound.h \ indicator-sound.c \ dbus-shared-names.h \ - sound-service-client.h + sound-service-client.h libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror -DG_LOG_DOMAIN=\"Indicator-Sound\" libsoundmenu_la_LIBADD = $(APPLET_LIBS) @@ -29,25 +29,13 @@ sound-service-client.h: $(srcdir)/sound-service.xml $(srcdir)/sound-service.xml +#################################################################### +# Sound Service +#################################################################### + ################# -# Session Stuff +# dbus interface ################# -indicator_sound_service_SOURCES = \ - common-defs.h \ - sound-service.h \ - sound-service.c \ - dbus-menu-manager.c \ - dbus-menu-manager.h \ - pulse-manager.h \ - pulse-manager.c \ - sound-service-dbus.h \ - sound-service-dbus.c \ - sound-service-server.h \ - slider-menu-item.h \ - slider-menu-item.c -indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall -Werror -indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS) - sound-service-server.h: $(srcdir)/sound-service.xml dbus-binding-tool \ --prefix=_sound_service_server \ @@ -55,21 +43,72 @@ sound-service-server.h: $(srcdir)/sound-service.xml --output=sound-service-server.h \ $(srcdir)/sound-service.xml -############### -# Other Stuff -############### -BUILT_SOURCES = \ - sound-service-client.h \ - sound-service-server.h +##################### +# libsoundmenu vala +##################### +music_bridge_VALASOURCES = \ + music-bridge.vala + +music_bridge_VALAFLAGS = \ + --ccode \ + -H music-bridge.h -d . \ + --library music-bridge \ + --vapidir=./ \ + --vapidir=$(abs_top_builddir)/vapi/ \ + --thread \ + --pkg gee-1.0 \ + --pkg indicate \ + --pkg DbusmenuGlib-0.2 \ + $(MAINTAINER_VALAFLAGS) + +music_bridge_APIFILES = \ + music-bridge.h + + +music_bridge_vala.stamp $(music_bridge_APIFILES): $(music_bridge_VALASOURCES) + $(AM_V_GEN) $(VALAC) $(music_bridge_VALAFLAGS) $^ + touch music_bridge_vala.stamp + +############################### +# libsoundmenu C +############################### +indicator_sound_service_SOURCES = \ + common-defs.h \ + sound-service.h \ + sound-service.c \ + dbus-menu-manager.c \ + dbus-menu-manager.h \ + pulse-manager.h \ + pulse-manager.c \ + sound-service-dbus.h \ + sound-service-dbus.c \ + sound-service-server.h \ + slider-menu-item.h \ + slider-menu-item.c \ + $(music_bridge_VALASOURCES:.vala=.c) +indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall -Werror +indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS) + +######################### +# Extra stuff to package +######################### EXTRA_DIST = \ - sound-service.xml \ - sound-service.list + sound-service.xml \ + sound-service.list \ + $(music_bridge_la_APIFILES) \ + $(music_bridge_la_VALASOURCES) + +####################### +# Stuff to clean Stuff +####################### +BUILT_SOURCES = \ + music_bridge_vala.stamp \ + sound-service-client.h \ + sound-service-server.h \ + $(music_bridge_la_APIFILES) \ + $(music_bridge_la_VALASOURCES:.vala=.c) CLEANFILES = \ $(BUILT_SOURCES) - - - - diff --git a/src/sound-service.c b/src/sound-service.c index d70971e..a061e86 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -23,6 +23,7 @@ with this program. If not, see . #include "sound-service.h" #include "dbus-menu-manager.h" #include "pulse-manager.h" +#include "music-bridge.h" static GMainLoop *mainloop = NULL; @@ -44,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); +/* close_pulse_activites();*/ +/* g_main_loop_quit(mainloop);*/ } return; } @@ -57,7 +58,7 @@ main: int main (int argc, char ** argv) { - g_type_init(); + g_type_init(); setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); @@ -69,13 +70,16 @@ main (int argc, char ** argv) INDICATOR_SERVICE_SIGNAL_SHUTDOWN, G_CALLBACK(service_shutdown), NULL); - dbus_menu_manager_setup(); + dbus_menu_manager_setup(); + BridgeServer* server = bridge_server_new(); + bridge_server_test_me(server); + //g_object_new(bridge_server_new, NULL); // Run the loop - mainloop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(mainloop); - - return 0; + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return 0; } -- cgit v1.2.3 From 4a17bff0cb034345ecce8e623a82026e8f60be3c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 7 May 2010 19:06:16 +0200 Subject: music bridge in place --- src/Makefile.am | 8 +++-- src/music-bridge.vala | 76 +++++++++++++++++++++++++++++++++++++++++++ src/pulse-manager.c | 74 ++++++++++++++++++++--------------------- src/rhythmbox-controller.vala | 40 +++++++++++++++++++++++ src/sound-service-dbus.c | 8 ++--- 5 files changed, 162 insertions(+), 44 deletions(-) create mode 100644 src/music-bridge.vala create mode 100644 src/rhythmbox-controller.vala diff --git a/src/Makefile.am b/src/Makefile.am index 7a747a3..12db62c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,7 +47,8 @@ sound-service-server.h: $(srcdir)/sound-service.xml # libsoundmenu vala ##################### music_bridge_VALASOURCES = \ - music-bridge.vala + music-bridge.vala \ + rhythmbox-controller.vala music_bridge_VALAFLAGS = \ --ccode \ @@ -59,11 +60,12 @@ music_bridge_VALAFLAGS = \ --pkg gee-1.0 \ --pkg indicate \ --pkg DbusmenuGlib-0.2 \ + --pkg dbus-glib-1 + $(MAINTAINER_VALAFLAGS) music_bridge_APIFILES = \ - music-bridge.h - + music-bridge.h music_bridge_vala.stamp $(music_bridge_APIFILES): $(music_bridge_VALASOURCES) $(AM_V_GEN) $(VALAC) $(music_bridge_VALAFLAGS) $^ diff --git a/src/music-bridge.vala b/src/music-bridge.vala new file mode 100644 index 0000000..55c115a --- /dev/null +++ b/src/music-bridge.vala @@ -0,0 +1,76 @@ +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; + + 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 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"); + } + + 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){ + 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_count_changed(Indicate.ListenerServer object, uint i){ + debug("BridgeServer -> on_server_count_changed with value %u", i); + } + +} + + +//public void main (string[] args) { + +// // Creating a GLib main loop with a default context +// var loop = new MainLoop(null, false); + +// BridgeServer server = new BridgeServer(); + +// // Start GLib mainloop +// loop.run(); +//} + + + diff --git a/src/pulse-manager.c b/src/pulse-manager.c index c84cfcc..7323797 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -89,14 +89,14 @@ Gracefully close our connection with the Pulse async library. void close_pulse_activites() { if (pulse_context != NULL){ - g_debug("freeing the pulse context"); +/* g_debug("freeing the pulse context");*/ pa_context_unref(pulse_context); pulse_context = NULL; } g_hash_table_destroy(sink_hash); pa_glib_mainloop_free(pa_main_loop); pa_main_loop = NULL; - g_debug("I just closed communication with Pulse"); +/* g_debug("I just closed communication with Pulse");*/ } /** @@ -147,7 +147,7 @@ static gboolean determine_sink_availability() // Firstly check to see if we have any sinks // if not get the hell out of here ! if (g_hash_table_size(sink_hash) < 1){ - g_debug("Sink_available returning false because sinks_hash is empty !!!"); +/* g_debug("Sink_available returning false because sinks_hash is empty !!!"); */ DEFAULT_SINK_INDEX = -1; return FALSE; } @@ -166,9 +166,9 @@ static gboolean determine_sink_availability() // Up until now the most rebust method to test this is to manually remove the available sink device // kernel module and then reload (rmmod & modprobe). // TODO: Edge case of dynamic loading and unloading of sinks should be handled also. - g_debug("About to test for to see if the available sink is null - s->name = %s", s->name); +/* g_debug("About to test for to see if the available sink is null - s->name = %s", s->name);*/ gboolean available = g_ascii_strncasecmp("auto_null", s->name, 9) != 0; - g_debug("PA_Manager -> determine_sink_availability: %i", available); +/* g_debug("PA_Manager -> determine_sink_availability: %i", available);*/ return available; } @@ -184,7 +184,7 @@ static gboolean default_sink_is_muted() static void check_sink_input_while_muted_event(gint sink_index) { - g_debug("SINKINPUTWHILEMUTED SIGNAL EVENT TO BE SENT FROM PA MANAGER - check trace for value"); +/* g_debug("SINKINPUTWHILEMUTED SIGNAL EVENT TO BE SENT FROM PA MANAGER - check trace for value");*/ if (default_sink_is_muted(sink_index) == TRUE){ sound_service_dbus_sink_input_while_muted (dbus_service, TRUE); @@ -201,7 +201,7 @@ static gdouble get_default_sink_volume() sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); pa_volume_t vol = pa_cvolume_avg(&s->volume); gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; - g_debug("software volume = %f", volume_percent); +/* g_debug("software volume = %f", volume_percent);*/ return volume_percent; } @@ -216,13 +216,13 @@ static void mute_each_sink(gpointer key, gpointer value, gpointer user_data) sound_service_dbus_update_sink_volume(dbus_service, get_default_sink_volume()); } - g_debug("in the pulse manager: mute each sink %i", GPOINTER_TO_INT(user_data)); +/* g_debug("in the pulse manager: mute each sink %i", GPOINTER_TO_INT(user_data));*/ } void toggle_global_mute(gboolean mute_value) { g_hash_table_foreach(sink_hash, mute_each_sink, GINT_TO_POINTER(mute_value)); - g_debug("in the pulse manager: toggle global mute value %i", mute_value); +/* g_debug("in the pulse manager: toggle global mute value %i", mute_value);*/ } @@ -234,7 +234,7 @@ void set_sink_volume(gdouble percent) { if(pa_server_available == FALSE) return; - g_debug("in the pulse manager:set_sink_volume with percent %f", percent); +/* g_debug("in the pulse manager:set_sink_volume with percent %f", percent);*/ if(DEFAULT_SINK_INDEX < 0) { @@ -287,7 +287,7 @@ static void gather_pulse_information(pa_context *c, void *userdata) static void context_success_callback(pa_context *c, int success, void *userdata) { - g_debug("Context Success Callback - result = %i", success); +/* g_debug("Context Success Callback - result = %i", success);*/ } /** @@ -315,7 +315,7 @@ static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, in } } else{ - g_debug("About to add an item to our hash"); +/* g_debug("About to add an item to our hash");*/ sink_info *value; value = g_new0(sink_info, 1); value->index = sink->index; @@ -325,7 +325,7 @@ static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, in value->base_volume = sink->base_volume; value->channel_map = sink->channel_map; g_hash_table_insert(sink_hash, GINT_TO_POINTER(sink->index), value); - g_debug("After adding an item to our hash"); +/* g_debug("After adding an item to our hash");*/ } } @@ -339,7 +339,7 @@ static void pulse_default_sink_info_callback(pa_context *c, const pa_sink_info * } else{ DEFAULT_SINK_INDEX = info->index; - g_debug("Just set the default sink index to %i", DEFAULT_SINK_INDEX); +/* g_debug("Just set the default sink index to %i", DEFAULT_SINK_INDEX); */ GList *keys = g_hash_table_get_keys(sink_hash); gint position = g_list_index(keys, GINT_TO_POINTER(info->index)); // Only update sink-list if the index is not in our already fetched list. @@ -358,17 +358,17 @@ static void pulse_sink_input_info_callback(pa_context *c, const pa_sink_input_in if (eol > 0) { if (pa_context_errno(c) == PA_ERR_NOENTITY) return; - g_warning("Sink INPUT info callback failure"); +/* g_warning("Sink INPUT info callback failure");*/ return; } else{ if (info == NULL) { // TODO: watch this carefully - PA async api should not be doing this . . . - g_warning("\n Sink input info callback : SINK INPUT INFO IS NULL BUT EOL was not POSITIVE!!!"); +/* g_warning("\n Sink input info callback : SINK INPUT INFO IS NULL BUT EOL was not POSITIVE!!!");*/ return; } - g_debug("\n SINK INPUT INFO sink index : %d \n", info->sink); +/* g_debug("\n SINK INPUT INFO sink index : %d \n", info->sink);*/ check_sink_input_while_muted_event(info->sink); } } @@ -378,7 +378,7 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v if (eol > 0) { if (pa_context_errno(c) == PA_ERR_NOENTITY) return; - g_warning("Sink INPUT info callback failure"); +/* g_warning("Sink INPUT info callback failure");*/ return; } gint position = -1; @@ -414,19 +414,19 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v { pa_volume_t vol = pa_cvolume_max(&s->volume); gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; - g_debug("Updating volume from PA manager with volume = %f", volume_percent); +/* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/ sound_service_dbus_update_sink_volume(dbus_service, volume_percent); } if (mute_changed == TRUE) { - g_debug("Updating Mute from PA manager with mute = %i", s->mute); +/* g_debug("Updating Mute from PA manager with mute = %i", s->mute);*/ sound_service_dbus_update_sink_mute(dbus_service, s->mute); dbus_menu_manager_update_mute_ui(s->mute); if(s->mute == FALSE){ pa_volume_t vol = pa_cvolume_max(&s->volume); gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; - g_debug("Updating volume from PA manager with volume = %f", volume_percent); +/* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/ sound_service_dbus_update_sink_volume(dbus_service, volume_percent); } } @@ -443,7 +443,7 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v value->channel_map = info->channel_map; value->base_volume = info->base_volume; g_hash_table_insert(sink_hash, GINT_TO_POINTER(value->index), value); - g_debug("pulse-manager:update_sink_info -> After adding a new sink to our hash"); +/* g_debug("pulse-manager:update_sink_info -> After adding a new sink to our hash");*/ sound_service_dbus_update_sink_availability(dbus_service, TRUE); } } @@ -457,7 +457,7 @@ static gboolean has_volume_changed(const pa_sink_info* new_sink, sink_info* cach pa_cvolume new_vol = construct_mono_volume(&new_sink->volume); if(pa_cvolume_equal(&new_vol, &(cached_sink->volume)) == TRUE){ - g_debug("has_volume_changed: volumes appear to be equal? no change triggered!"); +/* g_debug("has_volume_changed: volumes appear to be equal? no change triggered!"); */ return FALSE; } @@ -467,7 +467,7 @@ static gboolean has_volume_changed(const pa_sink_info* new_sink, sink_info* cach static void pulse_server_info_callback(pa_context *c, const pa_server_info *info, void *userdata) { - g_debug("server info callback"); +/* g_debug("server info callback");*/ pa_operation *operation; if (info == NULL) { @@ -507,32 +507,32 @@ static void subscribed_events_callback(pa_context *c, enum pa_subscription_event if(index == DEFAULT_SINK_INDEX) sound_service_dbus_update_sink_availability(dbus_service, FALSE); - g_debug("Subscribed_events_callback - removing sink of index %i from our sink hash - keep the cache tidy !", index); +/* g_debug("Subscribed_events_callback - removing sink of index %i from our sink hash - keep the cache tidy !", index);*/ g_hash_table_remove(sink_hash, GINT_TO_POINTER(index)); if(index == DEFAULT_SINK_INDEX){ - g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK REMOVAL: default sink %i has been removed.", DEFAULT_SINK_INDEX); +/* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK REMOVAL: default sink %i has been removed.", DEFAULT_SINK_INDEX); */ DEFAULT_SINK_INDEX = -1; determine_sink_availability(); } - g_debug("subscribed_events_callback - Now what is our default sink : %i", DEFAULT_SINK_INDEX); +/* g_debug("subscribed_events_callback - Now what is our default sink : %i", DEFAULT_SINK_INDEX); */ } else { - g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK: a generic sink event - will trigger an update"); +/* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK: a generic sink event - will trigger an update"); */ pa_operation_unref(pa_context_get_sink_info_by_index(c, index, update_sink_info, userdata)); } break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: - g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK_INPUT event triggered!!"); +/* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK_INPUT event triggered!!");*/ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { //handle the sink input remove event - not relevant for current design } else { - pa_operation_unref(pa_context_get_sink_input_info(c, index, pulse_sink_input_info_callback, userdata)); - } + pa_operation_unref(pa_context_get_sink_input_info(c, index, pulse_sink_input_info_callback, userdata)); + } break; case PA_SUBSCRIPTION_EVENT_SERVER: g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SERVER change of some description ???"); @@ -551,16 +551,16 @@ static void subscribed_events_callback(pa_context *c, enum pa_subscription_event static void context_state_callback(pa_context *c, void *userdata) { switch (pa_context_get_state(c)) { case PA_CONTEXT_UNCONNECTED: - g_debug("unconnected"); +/* g_debug("unconnected");*/ break; case PA_CONTEXT_CONNECTING: - g_debug("connecting - waiting for the server to become available"); +/* g_debug("connecting - waiting for the server to become available");*/ break; case PA_CONTEXT_AUTHORIZING: - g_debug("authorizing"); +/* g_debug("authorizing");*/ break; case PA_CONTEXT_SETTING_NAME: - g_debug("context setting name"); +/* g_debug("context setting name");*/ break; case PA_CONTEXT_FAILED: g_warning("FAILED to retrieve context - Is PulseAudio Daemon running ?"); @@ -568,10 +568,10 @@ static void context_state_callback(pa_context *c, void *userdata) { reconnect_to_pulse(); break; case PA_CONTEXT_TERMINATED: - g_debug("context terminated"); +/* g_debug("context terminated");*/ break; case PA_CONTEXT_READY: - g_debug("PA daemon is ready"); + g_debug("PA daemon is ready"); pa_operation *o; pa_context_set_subscribe_callback(c, subscribed_events_callback, userdata); diff --git a/src/rhythmbox-controller.vala b/src/rhythmbox-controller.vala new file mode 100644 index 0000000..da10daf --- /dev/null +++ b/src/rhythmbox-controller.vala @@ -0,0 +1,40 @@ +using DbusmenuGlib; + +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); + } + + 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_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); + } + + private void onUriChange(dynamic DBus.Object rhythmbox, string uri){ + debug("onUriChange, new uri : %s", uri); + } + + private void onElapsedChange(dynamic DBus.Object rhythmbox, uint32 time){ + debug("onElapsedChange, new time = %u", time); + } + +} diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 5c6c487..d1ddfc4 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -199,7 +199,7 @@ Utility methods to emit signals from the service into the ether. **/ void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gboolean block_value) { - g_debug("Emitting signal: SINK_INPUT_WHILE_MUTED, with block_value: %i", block_value); +/* g_debug("Emitting signal: SINK_INPUT_WHILE_MUTED, with block_value: %i", block_value);*/ g_signal_emit(obj, signals[SINK_INPUT_WHILE_MUTED], 0, @@ -211,7 +211,7 @@ void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_v SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); priv->volume_percent = sink_volume; - g_debug("Emitting signal: SINK_VOLUME_UPDATE, with sink_volme %f", priv->volume_percent); +/* g_debug("Emitting signal: SINK_VOLUME_UPDATE, with sink_volme %f", priv->volume_percent);*/ g_signal_emit(obj, signals[SINK_VOLUME_UPDATE], 0, @@ -220,7 +220,7 @@ void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_v void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mute) { - g_debug("Emitting signal: SINK_MUTE_UPDATE, with sink mute %i", sink_mute); +/* g_debug("Emitting signal: SINK_MUTE_UPDATE, with sink mute %i", sink_mute);*/ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); priv->mute = sink_mute; @@ -233,7 +233,7 @@ void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mu void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, gboolean sink_availability) { - g_debug("Emitting signal: SINK_AVAILABILITY_UPDATE, with value %i", sink_availability); +/* g_debug("Emitting signal: SINK_AVAILABILITY_UPDATE, with value %i", sink_availability);*/ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); priv->sink_availability = sink_availability; -- cgit v1.2.3 From 3631b8ecce614d1bdd1f66e87f9ab20c85709cc3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 7 May 2010 19:11:41 +0200 Subject: --- src/rhythmbox-controller.vala | 8 +- src/sound-service.c | 1 - vapi/indicate.vapi | 213 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+), 5 deletions(-) create mode 100644 vapi/indicate.vapi diff --git a/src/rhythmbox-controller.vala b/src/rhythmbox-controller.vala index da10daf..49cc9c0 100644 --- a/src/rhythmbox-controller.vala +++ b/src/rhythmbox-controller.vala @@ -18,7 +18,7 @@ public class RhythmboxController : GLib.Object{ 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.PlayingUriChanged += onUriChange; this.rhythmbox_player.elapsedChanged += onElapsedChange; this.rhythmbox_player.setMute(false); @@ -29,9 +29,9 @@ public class RhythmboxController : GLib.Object{ debug("New rhythmbox controller has been instantiated %i", (int)b); } - 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); +// } 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 a061e86..dad1bcd 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -73,7 +73,6 @@ main (int argc, char ** argv) dbus_menu_manager_setup(); BridgeServer* server = bridge_server_new(); bridge_server_test_me(server); - //g_object_new(bridge_server_new, NULL); // Run the loop mainloop = g_main_loop_new(NULL, FALSE); diff --git a/vapi/indicate.vapi b/vapi/indicate.vapi new file mode 100644 index 0000000..765ebc9 --- /dev/null +++ b/vapi/indicate.vapi @@ -0,0 +1,213 @@ +/* indicate.vapi generated by vapigen, do not modify. */ + +[CCode (cprefix = "Indicate", lower_case_cprefix = "indicate_")] +namespace Indicate { + [CCode (cheader_filename = "libindicate/indicator.h")] + public class Indicator : GLib.Object { + public weak GLib.Object parent; + [CCode (has_construct_function = false)] + public Indicator (); + public bool get_displayed (); + public uint get_id (); + public virtual GLib.Value get_property (string key); + public GLib.Value get_property_value (string key); + public Indicate.Server get_server (); + public bool is_visible (); + public virtual GLib.PtrArray list_properties (); + public void set_displayed (bool displayed); + public virtual void set_property (string key, GLib.Value data); + public void set_property_bool (string key, bool value); + public void set_property_int (string key, int value); + public void set_property_time (string key, GLib.TimeVal time); + public void set_property_value (string key, GLib.Value value); + public void set_server (Indicate.Server server); + [CCode (has_construct_function = false)] + public Indicator.with_server (Indicate.Server server); + public signal void displayed (bool object); + [HasEmitter] + public signal void hide (); + public signal void modified (string object); + [HasEmitter] + public signal void show (); + [HasEmitter] + public signal void user_display (uint object); + } + [CCode (cheader_filename = "libindicate/listener.h")] + public class Listener : GLib.Object { + public weak GLib.Object parent; + [CCode (has_construct_function = false)] + public Listener (); + public void display (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, uint timestamp); + public void displayed (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, bool displayed); + public void get_property (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_cb callback); + public void get_property_bool (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_bool_cb callback); + public void get_property_int (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_int_cb callback); + public void get_property_time (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_time_cb callback); + public void get_property_value (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_value_cb callback); + public static GLib.Type indicator_get_gtype (); + public static Indicate.Listener ref_default (); + public bool server_check_interest (Indicate.ListenerServer server, Indicate.Interests interest); + public void server_get_count (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_uint_property_cb callback); + public void server_get_desktop (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback); + public static GLib.Type server_get_gtype (); + public void server_get_menu (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback); + public static void server_get_type (Indicate.Listener listener, Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback); + public void server_remove_interest (Indicate.ListenerServer server, Indicate.Interests interest); + public void server_show_interest (Indicate.ListenerServer server, Indicate.Interests interest); + public void set_default_max_indicators (int max); + public void set_server_max_indicators (Indicate.ListenerServer server, int max); + public signal void indicator_added (Indicate.ListenerServer object, Indicate.ListenerIndicator p0); + public signal void indicator_modified (Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string p1); + public signal void indicator_removed (Indicate.ListenerServer object, Indicate.ListenerIndicator p0); + public signal void indicator_servers_report (); + public signal void server_added (Indicate.ListenerServer object, string p0); + public signal void server_count_changed (Indicate.ListenerServer object, uint p0); + public signal void server_removed (Indicate.ListenerServer object, string p0); + } + [CCode (cheader_filename = "libindicate/server.h")] + public class Server : GLib.Object { + public weak GLib.Object parent; + public void add_indicator (Indicate.Indicator indicator); + public virtual bool check_interest (Indicate.Interests interest); + public virtual bool get_indicator_count (out uint count) throws GLib.Error; + public virtual bool get_indicator_list (GLib.Array indicators) throws GLib.Error; + public virtual bool get_indicator_properties (uint id, string properties) throws GLib.Error; + public virtual bool get_indicator_property (uint id, owned string property, GLib.Value value) throws GLib.Error; + public virtual bool get_indicator_property_group (uint id, GLib.PtrArray properties, string value) throws GLib.Error; + public int get_max_indicators (); + public virtual uint get_next_id (); + public void hide (); + public virtual void indicator_added (uint id); + public virtual bool indicator_displayed (owned string sender, uint id, bool displayed) throws GLib.Error; + public virtual void indicator_removed (uint id); + public virtual int max_indicators_get (); + public virtual bool max_indicators_set (owned string sender, int max); + public static Indicate.Server ref_default (); + public void remove_indicator (Indicate.Indicator indicator); + public virtual bool remove_interest (owned string sender, Indicate.Interests interest); + public void set_count (uint count); + public static void set_dbus_object (string obj); + public void set_default (); + public void set_desktop_file (string path); + public void set_menu (DbusmenuGlib.DbusmenuServer menu); + public void set_type (string type); + public void show (); + public virtual bool show_indicator_to_user (uint id, uint timestamp) throws GLib.Error; + public virtual bool show_interest (owned string sender, Indicate.Interests interest); + public uint count { get; set; } + public string desktop { get; set; } + public string type { get; set; } + public signal void indicator_delete (uint object); + public signal void indicator_modified (uint object, string p0); + public signal void indicator_new (uint object); + public signal void interest_added (uint object); + public signal void interest_removed (uint object); + public signal void max_indicators_changed (int object); + public signal void server_count_changed (uint object); + public signal void server_display (uint object); + public signal void server_hide (string object); + public signal void server_show (string object); + } + [CCode (type_id = "INDICATE_TYPE_LISTENER_INDICATOR", cheader_filename = "libindicate/listener.h")] + public struct ListenerIndicator { + public uint get_id (); + } + [CCode (type_id = "INDICATE_TYPE_LISTENER_SERVER", cheader_filename = "libindicate/listener.h")] + public struct ListenerServer { + public unowned string get_dbusname (); + } + [CCode (cprefix = "INDICATE_INTEREST_", cheader_filename = "libindicate/interests.h")] + public enum Interests { + NONE, + SERVER_DISPLAY, + SERVER_SIGNAL, + INDICATOR_DISPLAY, + INDICATOR_SIGNAL, + INDICATOR_COUNT, + LAST + } + [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] + public delegate void listener_get_property_bool_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, bool propertydata, void* data); + [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] + public delegate void listener_get_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, string propertydata, void* data); + [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] + public delegate void listener_get_property_int_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, int propertydata, void* data); + [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] + public delegate void listener_get_property_time_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, GLib.TimeVal propertydata, void* data); + [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] + public delegate void listener_get_property_value_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, GLib.Value propertydata, void* data); + [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] + public delegate void listener_get_server_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, owned string value, void* data); + [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] + public delegate void listener_get_server_uint_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, uint value, void* data); + [CCode (cheader_filename = "Indicate-0.2.h")] + public const int INDICATOR_H_INCLUDED__; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const int INDICATOR_MESSAGES_H_INCLUDED__; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_MESSAGES_PROP_ATTENTION; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_MESSAGES_PROP_COUNT; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_MESSAGES_PROP_ICON; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_MESSAGES_PROP_NAME; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_MESSAGES_PROP_TIME; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_MESSAGES_SERVER_TYPE; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_SIGNAL_DISPLAY; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_SIGNAL_DISPLAYED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_SIGNAL_HIDE; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_SIGNAL_MODIFIED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_SIGNAL_SHOW; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_VALUE_FALSE; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string INDICATOR_VALUE_TRUE; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const int INTERESTS_H_INCLUDED__; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const int LISTENER_H_INCLUDED__; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string LISTENER_SIGNAL_INDICATOR_ADDED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string LISTENER_SIGNAL_INDICATOR_MODIFIED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string LISTENER_SIGNAL_INDICATOR_REMOVED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string LISTENER_SIGNAL_SERVER_ADDED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string LISTENER_SIGNAL_SERVER_COUNT_CHANGED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string LISTENER_SIGNAL_SERVER_REMOVED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const int SERVER_H_INCLUDED__; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const int SERVER_INDICATOR_NULL; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string SERVER_SIGNAL_INDICATOR_ADDED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string SERVER_SIGNAL_INDICATOR_MODIFIED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string SERVER_SIGNAL_INDICATOR_REMOVED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string SERVER_SIGNAL_INTEREST_ADDED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string SERVER_SIGNAL_INTEREST_REMOVED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string SERVER_SIGNAL_MAX_INDICATORS_CHANGED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string SERVER_SIGNAL_SERVER_COUNT_CHANGED; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string SERVER_SIGNAL_SERVER_DISPLAY; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string SERVER_SIGNAL_SERVER_HIDE; + [CCode (cheader_filename = "Indicate-0.2.h")] + public const string SERVER_SIGNAL_SERVER_SHOW; +} -- cgit v1.2.3 From d73292111b3c141f62508ffb28971e6c5b36d751 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 7 May 2010 20:52:39 +0200 Subject: oh my god --- src/music-bridge.vala | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/music-bridge.vala b/src/music-bridge.vala index 55c115a..cef9d02 100644 --- a/src/music-bridge.vala +++ b/src/music-bridge.vala @@ -5,18 +5,20 @@ 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 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); + 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(){ @@ -45,7 +47,7 @@ public class BridgeServer : GLib.Object{ else{ debug("client of type %s has registered with us", type); if (type.contains("rhythmbox") == true){ - new RhythmboxController(); + rb = new RhythmboxController(); } } } -- cgit v1.2.3 From 19eed06d9ad20121a17a6824297312f2b5ea8a7c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 18 May 2010 00:52:39 +0100 Subject: root menuitem passed in at start up the music-bridge - vapi file for dbusmenuitem need to be fixed --- src/dbus-menu-manager.c | 4 +- src/dbus-menu-manager.h | 4 +- src/music-bridge.vala | 120 ++++++++++++++++++++++-------------------- src/rhythmbox-controller.vala | 56 +++++++++++--------- src/sound-service.c | 4 +- 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 . #include #include -#include #include #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 + /* 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 . */ -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(str_hash,str_equal); + HashTable 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); -- cgit v1.2.3 From 8e2bd9c87d812a07caaa2c5aba0bbf819b445e56 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 20 May 2010 12:58:15 +0100 Subject: registered clients now add menuitems to the menu - the bullet trace is complete --- src/music-bridge.vala | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/music-bridge.vala b/src/music-bridge.vala index 1cadc36..e0900ba 100644 --- a/src/music-bridge.vala +++ b/src/music-bridge.vala @@ -1,16 +1,19 @@ using Indicate; using DbusmenuGlib; using DbusmenuMenuitem; +//using Gee; public class BridgeServer : GLib.Object { private Listener listener; - private RhythmboxController rb; - private DbusmenuMenuitem root_menu; - + private DbusmenuMenuitem root_menu; + //private HashMap registered_clients; + public BridgeServer() { + //registered_clients = new HashMap (); + root_menu = null; listener = Listener.ref_default(); listener.indicator_added.connect(on_indicator_added); listener.indicator_removed.connect(on_indicator_removed); @@ -48,11 +51,17 @@ public class BridgeServer : GLib.Object if (type.contains("music") == false) { debug("server is of no interest, it is not an music server"); return; - } else { + } + else { debug("client of type %s has registered with us", type); - if (type.contains("rhythmbox") == true) { - rb = new RhythmboxController(); - } + if (root_menu != null){ + debug("Just about to create the registration menu item"); + DbusmenuMenuitem client_item = new DbusmenuMenuitem(); + string client_name = type.split(".")[1]; + client_item.property_set(DBUSMENU_MENUITEM_PROP_LABEL, client_name.concat(" is registered")); + //registered_clients.set(client_name, client_item); + root_menu.child_append(client_item); + } } } -- cgit v1.2.3 From 14d9ed691abf09a2600f978aa7be13f841bc1ce5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 20 May 2010 18:50:44 +0100 Subject: We have clients properly registering and unregistering dynamically --- configure.ac | 3 +- src/Makefile.am | 12 +++--- src/music-bridge.vala | 93 -------------------------------------------- src/music-player-bridge.vala | 89 ++++++++++++++++++++++++++++++++++++++++++ src/sound-service.c | 6 +-- 5 files changed, 99 insertions(+), 104 deletions(-) delete mode 100644 src/music-bridge.vala create mode 100644 src/music-player-bridge.vala diff --git a/configure.ac b/configure.ac index b751fb2..0abf6c1 100644 --- a/configure.ac +++ b/configure.ac @@ -52,7 +52,8 @@ AC_SUBST(PULSEAUDIO_LIBS) PKG_CHECK_MODULES(SOUNDSERVICE, dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION - indicate >= $INDICATOR_REQUIRED_VERSION) + indicate >= $INDICATOR_REQUIRED_VERSION + gee-1.0) AC_SUBST(SOUNDSERVICE_CFLAGS) AC_SUBST(SOUNDERVICE_LIBS) diff --git a/src/Makefile.am b/src/Makefile.am index 12db62c..a1ecece 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,25 +47,23 @@ sound-service-server.h: $(srcdir)/sound-service.xml # libsoundmenu vala ##################### music_bridge_VALASOURCES = \ - music-bridge.vala \ - rhythmbox-controller.vala + music-player-bridge.vala music_bridge_VALAFLAGS = \ --ccode \ - -H music-bridge.h -d . \ + -H music-player-bridge.h -d . \ --library music-bridge \ --vapidir=./ \ - --vapidir=$(abs_top_builddir)/vapi/ \ --thread \ --pkg gee-1.0 \ - --pkg indicate \ - --pkg DbusmenuGlib-0.2 \ + --pkg Indicate-0.2 \ + --pkg Dbusmenu-Glib-0.2 \ --pkg dbus-glib-1 $(MAINTAINER_VALAFLAGS) music_bridge_APIFILES = \ - music-bridge.h + music-player-bridge.h music_bridge_vala.stamp $(music_bridge_APIFILES): $(music_bridge_VALASOURCES) $(AM_V_GEN) $(VALAC) $(music_bridge_VALAFLAGS) $^ diff --git a/src/music-bridge.vala b/src/music-bridge.vala deleted file mode 100644 index e0900ba..0000000 --- a/src/music-bridge.vala +++ /dev/null @@ -1,93 +0,0 @@ -using Indicate; -using DbusmenuGlib; -using DbusmenuMenuitem; -//using Gee; - -public class BridgeServer : GLib.Object -{ - - private Listener listener; - private DbusmenuMenuitem root_menu; - //private HashMap registered_clients; - - public BridgeServer() - { - //registered_clients = new HashMap (); - root_menu = null; - 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 (root_menu != null){ - debug("Just about to create the registration menu item"); - DbusmenuMenuitem client_item = new DbusmenuMenuitem(); - string client_name = type.split(".")[1]; - client_item.property_set(DBUSMENU_MENUITEM_PROP_LABEL, client_name.concat(" is registered")); - //registered_clients.set(client_name, client_item); - root_menu.child_append(client_item); - } - } - } - - 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 main (string[] args) { - -// // Creating a GLib main loop with a default context -// var loop = new MainLoop(null, false); - -// BridgeServer server = new BridgeServer(); - -// // Start GLib mainloop -// loop.run(); -//} - - - diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala new file mode 100644 index 0000000..c2cfc7a --- /dev/null +++ b/src/music-player-bridge.vala @@ -0,0 +1,89 @@ +using Indicate; +using Dbusmenu; +using Gee; + +public class MusicPlayerBridge : GLib.Object +{ + + private Listener listener; + private Dbusmenu.Menuitem root_menu; + private HashMap registered_clients; + + public MusicPlayerBridge() + { + registered_clients = new HashMap (); + 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(Dbusmenu.Menuitem menu) + { + debug("MusicPlayerBridge -> set_root_menu_item"); + root_menu = menu; + } + + public void on_indicator_added(Indicate.ListenerServer object, Indicate.ListenerIndicator p0) + { + debug("MusicPlayerBridge-> on_indicator_added"); + } + + public void on_indicator_removed(Indicate.ListenerServer object, Indicate.ListenerIndicator p0) + { + debug("MusicPlayerBridge -> on_indicator_removed"); + } + + public void on_indicator_modified(Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string s) + { + debug("MusicPlayerBridge -> indicator_modified with vale %s", s ); + } + + public void on_server_added(Indicate.ListenerServer object, string type) + { + debug("MusicPlayerBridge -> on_server_added with value %s", type); + if(server_is_not_of_interest(type)) return; + string client_name = type.split(".")[1]; + if (root_menu != null && client_name != null){ + Dbusmenu.Menuitem client_item = new Dbusmenu.Menuitem(); + client_item.property_set(MENUITEM_PROP_LABEL, client_name.concat(" is registered")); + registered_clients.set(client_name, client_item); + root_menu.child_append(client_item); + debug("client of name %s has successfully registered with us", client_name); + } + } + + public void on_server_removed(Indicate.ListenerServer object, string type) + { + debug("MusicPlayerBridge -> on_server_removed with value %s", type); + if(server_is_not_of_interest(type)) return; + string client_name = type.split(".")[1]; + if (root_menu != null && client_name != null){ + root_menu.child_delete(registered_clients[client_name]); + registered_clients.remove(client_name); + debug("Successively removed menu_item for client %s from registered_clients", client_name); + } + } + + private bool server_is_not_of_interest(string type){ + if (type == null) return true; + if (type.contains("music") == false) { + debug("server is of no interest, it is not an music server"); + return true; + } + return false; + } + + public void on_server_count_changed(Indicate.ListenerServer object, uint i) + { + debug("MusicPlayerBridge-> on_server_count_changed with value %u", i); + } + +} + + + + diff --git a/src/sound-service.c b/src/sound-service.c index db48676..84ad7f1 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -23,7 +23,7 @@ with this program. If not, see . #include "sound-service.h" #include "dbus-menu-manager.h" #include "pulse-manager.h" -#include "music-bridge.h" +#include "music-player-bridge.h" static GMainLoop *mainloop = NULL; @@ -71,8 +71,8 @@ main (int argc, char ** argv) G_CALLBACK(service_shutdown), NULL); DbusmenuMenuitem* root_menuitem = dbus_menu_manager_setup(); - BridgeServer* server = bridge_server_new(); - bridge_server_set_root_menu_item(server, root_menuitem); + MusicPlayerBridge* server = music_player_bridge_new(); + music_player_bridge_set_root_menu_item(server, root_menuitem); // Run the loop mainloop = g_main_loop_new(NULL, FALSE); -- cgit v1.2.3 From 9137d7849f09d78805bc39863b74188555d92699 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 21 May 2010 19:14:16 +0100 Subject: updated version to 0.3.0 --- configure.ac | 4 ++-- src/sound-service.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 0abf6c1..80d8f08 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(indicator-sound, 0.2.3, conor.curran@canonical.com) +AC_INIT(indicator-sound, 0.3.0, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.2.3) +AM_INIT_AUTOMAKE(indicator-sound, 0.3.0) AM_MAINTAINER_MODE diff --git a/src/sound-service.c b/src/sound-service.c index 84ad7f1..e20de30 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -45,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! -/* close_pulse_activites();*/ -/* g_main_loop_quit(mainloop);*/ + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From d202231fdac665634667af3985e4683e23003d25 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 21 May 2010 19:30:48 +0100 Subject: removed redundant vapi --- vapi/indicate.vapi | 213 ----------------------------------------------------- 1 file changed, 213 deletions(-) delete mode 100644 vapi/indicate.vapi diff --git a/vapi/indicate.vapi b/vapi/indicate.vapi deleted file mode 100644 index 765ebc9..0000000 --- a/vapi/indicate.vapi +++ /dev/null @@ -1,213 +0,0 @@ -/* indicate.vapi generated by vapigen, do not modify. */ - -[CCode (cprefix = "Indicate", lower_case_cprefix = "indicate_")] -namespace Indicate { - [CCode (cheader_filename = "libindicate/indicator.h")] - public class Indicator : GLib.Object { - public weak GLib.Object parent; - [CCode (has_construct_function = false)] - public Indicator (); - public bool get_displayed (); - public uint get_id (); - public virtual GLib.Value get_property (string key); - public GLib.Value get_property_value (string key); - public Indicate.Server get_server (); - public bool is_visible (); - public virtual GLib.PtrArray list_properties (); - public void set_displayed (bool displayed); - public virtual void set_property (string key, GLib.Value data); - public void set_property_bool (string key, bool value); - public void set_property_int (string key, int value); - public void set_property_time (string key, GLib.TimeVal time); - public void set_property_value (string key, GLib.Value value); - public void set_server (Indicate.Server server); - [CCode (has_construct_function = false)] - public Indicator.with_server (Indicate.Server server); - public signal void displayed (bool object); - [HasEmitter] - public signal void hide (); - public signal void modified (string object); - [HasEmitter] - public signal void show (); - [HasEmitter] - public signal void user_display (uint object); - } - [CCode (cheader_filename = "libindicate/listener.h")] - public class Listener : GLib.Object { - public weak GLib.Object parent; - [CCode (has_construct_function = false)] - public Listener (); - public void display (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, uint timestamp); - public void displayed (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, bool displayed); - public void get_property (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_cb callback); - public void get_property_bool (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_bool_cb callback); - public void get_property_int (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_int_cb callback); - public void get_property_time (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_time_cb callback); - public void get_property_value (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_value_cb callback); - public static GLib.Type indicator_get_gtype (); - public static Indicate.Listener ref_default (); - public bool server_check_interest (Indicate.ListenerServer server, Indicate.Interests interest); - public void server_get_count (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_uint_property_cb callback); - public void server_get_desktop (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback); - public static GLib.Type server_get_gtype (); - public void server_get_menu (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback); - public static void server_get_type (Indicate.Listener listener, Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback); - public void server_remove_interest (Indicate.ListenerServer server, Indicate.Interests interest); - public void server_show_interest (Indicate.ListenerServer server, Indicate.Interests interest); - public void set_default_max_indicators (int max); - public void set_server_max_indicators (Indicate.ListenerServer server, int max); - public signal void indicator_added (Indicate.ListenerServer object, Indicate.ListenerIndicator p0); - public signal void indicator_modified (Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string p1); - public signal void indicator_removed (Indicate.ListenerServer object, Indicate.ListenerIndicator p0); - public signal void indicator_servers_report (); - public signal void server_added (Indicate.ListenerServer object, string p0); - public signal void server_count_changed (Indicate.ListenerServer object, uint p0); - public signal void server_removed (Indicate.ListenerServer object, string p0); - } - [CCode (cheader_filename = "libindicate/server.h")] - public class Server : GLib.Object { - public weak GLib.Object parent; - public void add_indicator (Indicate.Indicator indicator); - public virtual bool check_interest (Indicate.Interests interest); - public virtual bool get_indicator_count (out uint count) throws GLib.Error; - public virtual bool get_indicator_list (GLib.Array indicators) throws GLib.Error; - public virtual bool get_indicator_properties (uint id, string properties) throws GLib.Error; - public virtual bool get_indicator_property (uint id, owned string property, GLib.Value value) throws GLib.Error; - public virtual bool get_indicator_property_group (uint id, GLib.PtrArray properties, string value) throws GLib.Error; - public int get_max_indicators (); - public virtual uint get_next_id (); - public void hide (); - public virtual void indicator_added (uint id); - public virtual bool indicator_displayed (owned string sender, uint id, bool displayed) throws GLib.Error; - public virtual void indicator_removed (uint id); - public virtual int max_indicators_get (); - public virtual bool max_indicators_set (owned string sender, int max); - public static Indicate.Server ref_default (); - public void remove_indicator (Indicate.Indicator indicator); - public virtual bool remove_interest (owned string sender, Indicate.Interests interest); - public void set_count (uint count); - public static void set_dbus_object (string obj); - public void set_default (); - public void set_desktop_file (string path); - public void set_menu (DbusmenuGlib.DbusmenuServer menu); - public void set_type (string type); - public void show (); - public virtual bool show_indicator_to_user (uint id, uint timestamp) throws GLib.Error; - public virtual bool show_interest (owned string sender, Indicate.Interests interest); - public uint count { get; set; } - public string desktop { get; set; } - public string type { get; set; } - public signal void indicator_delete (uint object); - public signal void indicator_modified (uint object, string p0); - public signal void indicator_new (uint object); - public signal void interest_added (uint object); - public signal void interest_removed (uint object); - public signal void max_indicators_changed (int object); - public signal void server_count_changed (uint object); - public signal void server_display (uint object); - public signal void server_hide (string object); - public signal void server_show (string object); - } - [CCode (type_id = "INDICATE_TYPE_LISTENER_INDICATOR", cheader_filename = "libindicate/listener.h")] - public struct ListenerIndicator { - public uint get_id (); - } - [CCode (type_id = "INDICATE_TYPE_LISTENER_SERVER", cheader_filename = "libindicate/listener.h")] - public struct ListenerServer { - public unowned string get_dbusname (); - } - [CCode (cprefix = "INDICATE_INTEREST_", cheader_filename = "libindicate/interests.h")] - public enum Interests { - NONE, - SERVER_DISPLAY, - SERVER_SIGNAL, - INDICATOR_DISPLAY, - INDICATOR_SIGNAL, - INDICATOR_COUNT, - LAST - } - [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] - public delegate void listener_get_property_bool_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, bool propertydata, void* data); - [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] - public delegate void listener_get_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, string propertydata, void* data); - [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] - public delegate void listener_get_property_int_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, int propertydata, void* data); - [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] - public delegate void listener_get_property_time_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, GLib.TimeVal propertydata, void* data); - [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] - public delegate void listener_get_property_value_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, GLib.Value propertydata, void* data); - [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] - public delegate void listener_get_server_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, owned string value, void* data); - [CCode (cheader_filename = "Indicate-0.2.h", has_target = false)] - public delegate void listener_get_server_uint_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, uint value, void* data); - [CCode (cheader_filename = "Indicate-0.2.h")] - public const int INDICATOR_H_INCLUDED__; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const int INDICATOR_MESSAGES_H_INCLUDED__; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_MESSAGES_PROP_ATTENTION; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_MESSAGES_PROP_COUNT; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_MESSAGES_PROP_ICON; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_MESSAGES_PROP_NAME; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_MESSAGES_PROP_TIME; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_MESSAGES_SERVER_TYPE; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_SIGNAL_DISPLAY; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_SIGNAL_DISPLAYED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_SIGNAL_HIDE; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_SIGNAL_MODIFIED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_SIGNAL_SHOW; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_VALUE_FALSE; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string INDICATOR_VALUE_TRUE; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const int INTERESTS_H_INCLUDED__; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const int LISTENER_H_INCLUDED__; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string LISTENER_SIGNAL_INDICATOR_ADDED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string LISTENER_SIGNAL_INDICATOR_MODIFIED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string LISTENER_SIGNAL_INDICATOR_REMOVED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string LISTENER_SIGNAL_SERVER_ADDED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string LISTENER_SIGNAL_SERVER_COUNT_CHANGED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string LISTENER_SIGNAL_SERVER_REMOVED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const int SERVER_H_INCLUDED__; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const int SERVER_INDICATOR_NULL; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string SERVER_SIGNAL_INDICATOR_ADDED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string SERVER_SIGNAL_INDICATOR_MODIFIED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string SERVER_SIGNAL_INDICATOR_REMOVED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string SERVER_SIGNAL_INTEREST_ADDED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string SERVER_SIGNAL_INTEREST_REMOVED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string SERVER_SIGNAL_MAX_INDICATORS_CHANGED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string SERVER_SIGNAL_SERVER_COUNT_CHANGED; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string SERVER_SIGNAL_SERVER_DISPLAY; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string SERVER_SIGNAL_SERVER_HIDE; - [CCode (cheader_filename = "Indicate-0.2.h")] - public const string SERVER_SIGNAL_SERVER_SHOW; -} -- cgit v1.2.3 From ed0f4a53abcce977b74ca2647fddbb08b4284982 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Sat, 22 May 2010 18:51:09 +0100 Subject: dependency versions updated --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 80d8f08..1478bec 100644 --- a/configure.ac +++ b/configure.ac @@ -34,8 +34,8 @@ DBUSMENUGTK_REQUIRED_VERSION=0.2.2 POLKIT_REQUIRED_VERSION=0.92 PULSE_AUDIO_REQUIRED_VERSION=0.9.19 INDICATOR_DISPLAY_OBJECTS=0.1.4 -INDICATE_REQUIRED_VERSION=0.3.0 -DBUSMENUGLIB_REQUIRED_VERSION=0.1.1 +INDICATE_REQUIRED_VERSION=0.3.6 +DBUSMENUGLIB_REQUIRED_VERSION=0.2.9 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION @@ -52,7 +52,7 @@ AC_SUBST(PULSEAUDIO_LIBS) PKG_CHECK_MODULES(SOUNDSERVICE, dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION - indicate >= $INDICATOR_REQUIRED_VERSION + indicate >= $INDICATE_REQUIRED_VERSION gee-1.0) AC_SUBST(SOUNDSERVICE_CFLAGS) -- cgit v1.2.3 From 5a9881a144df8a9c36f9d5b96ea53e872c76949b Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 8 Jun 2010 14:26:57 +0100 Subject: new transport bar --- src/Makefile.am | 3 +- src/common-defs.h | 1 + src/indicator-sound.c | 197 ++++++++++++++++++++++--------------------- src/music-player-bridge.vala | 1 + src/slider-menu-item.c | 18 ++-- src/transport-bar.c | 94 +++++++++++++++++++++ src/transport-bar.h | 49 +++++++++++ src/transport-menu-item.vala | 19 +++++ 8 files changed, 277 insertions(+), 105 deletions(-) create mode 100644 src/transport-bar.c create mode 100644 src/transport-bar.h create mode 100644 src/transport-menu-item.vala diff --git a/src/Makefile.am b/src/Makefile.am index a1ecece..716cab2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,7 +47,8 @@ sound-service-server.h: $(srcdir)/sound-service.xml # libsoundmenu vala ##################### music_bridge_VALASOURCES = \ - music-player-bridge.vala + music-player-bridge.vala \ + transport-menu-item.vala music_bridge_VALAFLAGS = \ --ccode \ diff --git a/src/common-defs.h b/src/common-defs.h index 9be1da5..94c178e 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -27,3 +27,4 @@ with this program. If not, see . // DBUS items #define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item" #define DBUSMENU_SLIDER_MENUITEM_PROP_VOLUME "volume" +#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar" diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 18f48d8..31f023e 100755 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -91,6 +91,9 @@ static void slider_grabbed(GtkWidget *widget, gpointer user_data); static void slider_released(GtkWidget *widget, gpointer user_data); static void style_changed_cb(GtkWidget *widget, gpointer user_data); +//transport bar related +static gboolean new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); + // DBUS communication static DBusGProxy *sound_dbus_proxy = NULL; static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata); @@ -150,9 +153,9 @@ indicator_sound_class_init (IndicatorSoundClass *klass) io_class->get_label = get_label; io_class->get_image = get_icon; io_class->get_menu = get_menu; - io_class->scroll = scroll; + io_class->scroll = scroll; - design_team_size = gtk_icon_size_register("design-team-size", 22, 22); + design_team_size = gtk_icon_size_register("design-team-size", 22, 22); return; } @@ -217,9 +220,9 @@ get_label (IndicatorObject * io) static GtkImage * get_icon (IndicatorObject * io) -{ - gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); - g_debug("At start-up attempting to set the image to %s", current_name); +{ + gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); + g_debug("At start-up attempting to set the image to %s", current_name); speaker_image = indicator_image_helper(current_name); gtk_widget_show(GTK_WIDGET(speaker_image)); return speaker_image; @@ -231,16 +234,15 @@ get_icon (IndicatorObject * io) static GtkMenu * get_menu (IndicatorObject * io) { - DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT); - DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); - - g_object_set_data (G_OBJECT (client), - "indicator", io); - dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item); + DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT); + DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); + g_object_set_data (G_OBJECT (client), "indicator", io); + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item); + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TRANSPORT_MENUITEM_TYPE, new_transport_bar); - // register Key-press listening on the menu widget as the slider does not allow this. - g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), NULL); - return GTK_MENU(menu); + // register Key-press listening on the menu widget as the slider does not allow this. + g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), NULL); + return GTK_MENU(menu); } static void @@ -307,6 +309,13 @@ new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuC return TRUE; } +static gboolean new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + g_debug("indicator-sound: new_transport_bar() called "); + return TRUE; +} + + static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata) { @@ -337,11 +346,11 @@ connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer u dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID); dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_CALLBACK(catch_signal_sink_availability_update), NULL, NULL); - // Ensure we are in a coherent state with the service at start up. - // Preserve ordering! - fetch_volume_percent_from_dbus(); - fetch_mute_value_from_dbus(); - fetch_sink_availability_from_dbus(); + // Ensure we are in a coherent state with the service at start up. + // Preserve ordering! + fetch_volume_percent_from_dbus(); + fetch_mute_value_from_dbus(); + fetch_sink_availability_from_dbus(); } } else { @@ -645,7 +654,6 @@ catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_valu /*******************************************************************/ //UI callbacks /******************************************************************/ - /** value_changed_event_cb: This callback will get triggered irregardless of whether its a user change or a programmatic change. @@ -692,94 +700,93 @@ key_press_cb: static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) { - gboolean digested = FALSE; + gboolean digested = FALSE; - GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); - GtkRange* range = (GtkRange*)slider; - gdouble current_value = gtk_range_get_value(range); - gdouble new_value = current_value; - const gdouble five_percent = 5; - GtkWidget *menuitem; - - menuitem = GTK_MENU_SHELL (widget)->active_menu_item; - if(IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE) + GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); + GtkRange* range = (GtkRange*)slider; + gdouble current_value = gtk_range_get_value(range); + gdouble new_value = current_value; + const gdouble five_percent = 5; + GtkWidget *menuitem; + + menuitem = GTK_MENU_SHELL (widget)->active_menu_item; + if(IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE) + { + switch(event->keyval) { - switch(event->keyval) - { - case GDK_Right: - digested = TRUE; - if(event->state & GDK_CONTROL_MASK) - { - new_value = 100; - } - else - { - new_value = current_value + five_percent; - } - break; - case GDK_Left: - digested = TRUE; - if(event->state & GDK_CONTROL_MASK) - { - new_value = 0; - } - else - { - new_value = current_value - five_percent; - } - break; - case GDK_plus: - digested = TRUE; - new_value = current_value + five_percent; - break; - case GDK_minus: - digested = TRUE; - new_value = current_value - five_percent; - break; - default: - break; - } - - new_value = CLAMP(new_value, 0, 100); - if(new_value != current_value && current_state != STATE_MUTED) - { - g_debug("Attempting to set the range from the key listener to %f", new_value); - // In order to ensure that the exterior filtering does not catch this, reset the exterior_vol_update - // to ensure these updates. - exterior_vol_update = OUT_OF_RANGE; - gtk_range_set_value(range, new_value); - } + case GDK_Right: + digested = TRUE; + if(event->state & GDK_CONTROL_MASK) + { + new_value = 100; + } + else + { + new_value = current_value + five_percent; + } + break; + case GDK_Left: + digested = TRUE; + if(event->state & GDK_CONTROL_MASK) + { + new_value = 0; + } + else + { + new_value = current_value - five_percent; + } + break; + case GDK_plus: + digested = TRUE; + new_value = current_value + five_percent; + break; + case GDK_minus: + digested = TRUE; + new_value = current_value - five_percent; + break; + default: + break; } - return digested; + + new_value = CLAMP(new_value, 0, 100); + if(new_value != current_value && current_state != STATE_MUTED) + { + g_debug("Attempting to set the range from the key listener to %f", new_value); + // In order to ensure that the exterior filtering does not catch this, reset the exterior_vol_update + // to ensure these updates. + exterior_vol_update = OUT_OF_RANGE; + gtk_range_set_value(range, new_value); + } + } + return digested; } static void style_changed_cb(GtkWidget *widget, gpointer user_data) { - g_debug("Just caught a style change event"); - update_state(current_state); - reset_mute_blocking_animation(); - update_state(current_state); - free_the_animation_list(); - prepare_blocked_animation(); + g_debug("Just caught a style change event"); + update_state(current_state); + reset_mute_blocking_animation(); + update_state(current_state); + free_the_animation_list(); + prepare_blocked_animation(); } static void scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction) { - if (device_available == FALSE || current_state == STATE_MUTED) - return; + if (device_available == FALSE || current_state == STATE_MUTED) + return; - IndicatorSound *sound = INDICATOR_SOUND (io); - GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (sound->slider)); - gdouble value = gtk_range_get_value (GTK_RANGE (sound->slider)); + IndicatorSound *sound = INDICATOR_SOUND (io); + GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (sound->slider)); + gdouble value = gtk_range_get_value (GTK_RANGE (sound->slider)); - if (direction == INDICATOR_OBJECT_SCROLL_UP){ - value += adj->step_increment; - } - else{ - value -= adj->step_increment; - } - gtk_range_set_value (GTK_RANGE (sound->slider), - value); + if (direction == INDICATOR_OBJECT_SCROLL_UP){ + value += adj->step_increment; + } + else{ + value -= adj->step_increment; + } + gtk_range_set_value (GTK_RANGE (sound->slider), value); } diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index c2cfc7a..cd5d65d 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -49,6 +49,7 @@ public class MusicPlayerBridge : GLib.Object string client_name = type.split(".")[1]; if (root_menu != null && client_name != null){ Dbusmenu.Menuitem client_item = new Dbusmenu.Menuitem(); + client_item.property_set(MENUITEM_PROP_LABEL, client_name.concat(" is registered")); registered_clients.set(client_name, client_item); root_menu.child_append(client_item); diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index cb72524..8a21fcf 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -53,8 +53,8 @@ static void slider_menu_item_class_init (SliderMenuItemClass *klass) object_class->dispose = slider_menu_item_dispose; object_class->finalize = slider_menu_item_finalize; - DbusmenuMenuitemClass * mclass = DBUSMENU_MENUITEM_CLASS(klass); - mclass->handle_event = handle_event; + DbusmenuMenuitemClass * mclass = DBUSMENU_MENUITEM_CLASS(klass); + mclass->handle_event = handle_event; return; } @@ -81,10 +81,10 @@ static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) { g_debug("in the handle event method of slider_menu_item"); - gdouble volume_input = 0; - volume_input = g_value_get_double(value); - if(value != NULL) - set_sink_volume(volume_input); + gdouble volume_input = 0; + volume_input = g_value_get_double(value); + if(value != NULL) + set_sink_volume(volume_input); } @@ -92,9 +92,9 @@ handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, g SliderMenuItem* slider_menu_item_new(gboolean sinks_available, gdouble start_volume) { SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_SLIDER_MENUITEM_TYPE); - dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ENABLED, sinks_available); - dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, sinks_available); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_SLIDER_MENUITEM_TYPE); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ENABLED, sinks_available); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, sinks_available); return self; } diff --git a/src/transport-bar.c b/src/transport-bar.c new file mode 100644 index 0000000..ef1edb4 --- /dev/null +++ b/src/transport-bar.c @@ -0,0 +1,94 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "transport-bar.h" +#include "common-defs.h" + +typedef struct _TransportBarPrivate TransportBarPrivate; + +struct _TransportBarPrivate +{ +}; + +#define TRANSPORT_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_BAR_TYPE, TransportBarPrivate)) + +/* Prototypes */ +static void transport_bar_class_init (TransportBarClass *klass); +static void transport_bar_init (TransportBar *self); +static void transport_bar_dispose (GObject *object); +static void transport_bar_finalize (GObject *object); +//static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); +G_DEFINE_TYPE (TransportBar, transport_bar, DBUSMENU_TYPE_MENUITEM); + +static void +transport_bar_class_init (TransportBarClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (TransportBarPrivate)); + + object_class->dispose = transport_bar_dispose; + object_class->finalize = transport_bar_finalize; + + //DbusmenuMenuitemClass * mclass = DBUSMENU_MENUITEM_CLASS(klass); + //mclass->handle_event = handle_event; + return; +} + +static void +transport_bar_init (TransportBar *self) +{ + g_debug("Building new Transport Item"); + return; +} + +static void +transport_bar_dispose (GObject *object) +{ + G_OBJECT_CLASS (transport_bar_parent_class)->dispose (object); + return; +} + +static void +transport_bar_finalize (GObject *object) +{ + G_OBJECT_CLASS (transport_bar_parent_class)->finalize (object); +} + + +//static void +//handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) +//{ +// g_debug("TransportBar -> handle event caught!"); +//} + + + +TransportBar* +transport_bar_new() +{ + TransportBar *self = g_object_new(TRANSPORT_BAR_TYPE, NULL); + //dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE); + return self; +} diff --git a/src/transport-bar.h b/src/transport-bar.h new file mode 100644 index 0000000..77a1a97 --- /dev/null +++ b/src/transport-bar.h @@ -0,0 +1,49 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ +#ifndef __TRANSPORT_BAR_H__ +#define __TRANSPORT_BAR_H__ + +#include +#include + +G_BEGIN_DECLS + +#define TRANSPORT_BAR_TYPE (transport_bar_get_type ()) +#define TRANSPORT_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRANSPORT_BAR_TYPE, TransportBar)) +#define TRANSPORT_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRANSPORT_BAR_TYPE, TransportBarClass)) +#define IS_TRANSPORT_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRANSPORT_BAR_TYPE)) +#define IS_TRANSPORT_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRANSPORT_BAR_TYPE)) +#define TRANSPORT_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRANSPORT_BAR_TYPE, TransportBarClass)) + +typedef struct _TransportBar TransportBar; +typedef struct _TransportBarClass TransportBarClass; + +struct _TransportBarClass { +}; + +struct _TransportBar { +}; + +GType transport_item_get_type (void); +TransportBar* transport_item_new(); + +G_END_DECLS + +#endif + diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala new file mode 100644 index 0000000..812ef6a --- /dev/null +++ b/src/transport-menu-item.vala @@ -0,0 +1,19 @@ +using Dbusmenu; +using Gee; + +public class TransportMenuItem : Dbusmenu.Menuitem +{ + /* Not ideal duplicate definition of const - see common-defs/h */ + const string DBUSMENU_TRANSPORT_MENUITEM_TYPE = "x-canonical-transport-bar"; + + public TransportMenuItem() + { + this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE); + } + + public override void handle_event(string name, GLib.Value value, uint timestamp) + { + debug("TransportItem -> handle event caught!"); + } + +} \ No newline at end of file -- cgit v1.2.3 From 744083d4483291a87f4f348d6937257d8887cfb1 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 8 Jun 2010 18:09:48 +0100 Subject: moving in the right direction --- src/Makefile.am | 4 +++- src/indicator-sound.c | 2 ++ src/music-player-bridge.vala | 9 ++++----- src/sound-service.c | 6 +++--- src/transport-bar.c | 25 ++++++++++++------------- src/transport-bar.h | 4 ++-- src/transport-menu-item.vala | 2 +- 7 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 716cab2..f7fb1a1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,6 +9,8 @@ soundmenulib_LTLIBRARIES = libsoundmenu.la libsoundmenu_la_SOURCES = \ common-defs.h \ indicator-sound.h \ + transport-bar.c \ + transport-bar.h \ indicator-sound.c \ dbus-shared-names.h \ sound-service-client.h @@ -88,7 +90,7 @@ indicator_sound_service_SOURCES = \ slider-menu-item.c \ $(music_bridge_VALASOURCES:.vala=.c) -indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall -Werror +indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS) ######################### diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 31f023e..e13c52b 100755 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -38,6 +38,7 @@ with this program. If not, see . #include #include "indicator-sound.h" +#include "transport-bar" #include "dbus-shared-names.h" #include "sound-service-client.h" #include "common-defs.h" @@ -312,6 +313,7 @@ new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuC static gboolean new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { g_debug("indicator-sound: new_transport_bar() called "); + TransportBar* bar = transport_bar_new(); return TRUE; } diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index cd5d65d..dc66101 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -48,11 +48,10 @@ public class MusicPlayerBridge : GLib.Object if(server_is_not_of_interest(type)) return; string client_name = type.split(".")[1]; if (root_menu != null && client_name != null){ - Dbusmenu.Menuitem client_item = new Dbusmenu.Menuitem(); - - client_item.property_set(MENUITEM_PROP_LABEL, client_name.concat(" is registered")); - registered_clients.set(client_name, client_item); - root_menu.child_append(client_item); + TransportMenuItem transport_item = new TransportMenuItem(); + //client_item.property_set(MENUITEM_PROP_LABEL, client_name.concat(" is registered")); + registered_clients.set(client_name, transport_item); + root_menu.child_append(transport_item); debug("client of name %s has successfully registered with us", client_name); } } diff --git a/src/sound-service.c b/src/sound-service.c index e20de30..3ec7a60 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -44,9 +44,9 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); - // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); + // TODO: uncomment for release !! + //close_pulse_activites(); + //g_main_loop_quit(mainloop); } return; } diff --git a/src/transport-bar.c b/src/transport-bar.c index ef1edb4..8573cae 100644 --- a/src/transport-bar.c +++ b/src/transport-bar.c @@ -24,11 +24,16 @@ with this program. If not, see . #include #include "transport-bar.h" #include "common-defs.h" +#include typedef struct _TransportBarPrivate TransportBarPrivate; struct _TransportBarPrivate { + GtkWidget* hBox; + GtkWidget* previous_button; + GtkWidget* play_button; + GtkWidget* next_button; }; #define TRANSPORT_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_BAR_TYPE, TransportBarPrivate)) @@ -38,7 +43,6 @@ static void transport_bar_class_init (TransportBarClass *klass); static void transport_bar_init (TransportBar *self); static void transport_bar_dispose (GObject *object); static void transport_bar_finalize (GObject *object); -//static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); G_DEFINE_TYPE (TransportBar, transport_bar, DBUSMENU_TYPE_MENUITEM); static void @@ -51,8 +55,6 @@ transport_bar_class_init (TransportBarClass *klass) object_class->dispose = transport_bar_dispose; object_class->finalize = transport_bar_finalize; - //DbusmenuMenuitemClass * mclass = DBUSMENU_MENUITEM_CLASS(klass); - //mclass->handle_event = handle_event; return; } @@ -60,6 +62,13 @@ static void transport_bar_init (TransportBar *self) { g_debug("Building new Transport Item"); + hBox = gtk_hbox_new(TRUE, 2)); + previous_button = gtk_button_new_with_label("Previous")); + next_button = gtk_button_new_with_label("Next")); + play_button = gtk_button_new_with_label("Play")); + gtk_container_add((GtkContainer*) hBox, previous_button); + gtk_container_add((GtkContainer*) hBox, next_button); + gtk_container_add((GtkContainer*) hBox, play_button); return; } @@ -76,19 +85,9 @@ transport_bar_finalize (GObject *object) G_OBJECT_CLASS (transport_bar_parent_class)->finalize (object); } - -//static void -//handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) -//{ -// g_debug("TransportBar -> handle event caught!"); -//} - - - TransportBar* transport_bar_new() { TransportBar *self = g_object_new(TRANSPORT_BAR_TYPE, NULL); - //dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE); return self; } diff --git a/src/transport-bar.h b/src/transport-bar.h index 77a1a97..e931298 100644 --- a/src/transport-bar.h +++ b/src/transport-bar.h @@ -40,8 +40,8 @@ struct _TransportBarClass { struct _TransportBar { }; -GType transport_item_get_type (void); -TransportBar* transport_item_new(); +GType transport_bar_get_type (void); +TransportBar* transport_bar_new(); G_END_DECLS diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 812ef6a..11120b0 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -11,7 +11,7 @@ public class TransportMenuItem : Dbusmenu.Menuitem this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE); } - public override void handle_event(string name, GLib.Value value, uint timestamp) + public override void handle_event(string name, GLib.Value input_value, uint timestamp) { debug("TransportItem -> handle event caught!"); } -- cgit v1.2.3 From 664a45a398020f82f1e8f8e22f1627392a06a0c2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 9 Jun 2010 12:13:59 +0100 Subject: buttons added - events being received --- src/indicator-sound.c | 112 ++++++++++++++++++++++++++++---------------------- src/transport-bar.c | 45 ++++++++++++-------- src/transport-bar.h | 7 ++-- 3 files changed, 94 insertions(+), 70 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index e13c52b..48fde56 100755 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -38,7 +38,7 @@ with this program. If not, see . #include #include "indicator-sound.h" -#include "transport-bar" +#include "transport-bar.h" #include "dbus-shared-names.h" #include "sound-service-client.h" #include "common-defs.h" @@ -62,7 +62,7 @@ struct _IndicatorSoundClass { //GObject instance struct struct _IndicatorSound { IndicatorObject parent; - GtkWidget *slider; + GtkWidget *slider; IndicatorServiceManager *service; }; // GObject Boiler plate @@ -166,17 +166,17 @@ indicator_sound_init (IndicatorSound *self) { self->service = NULL; self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION); - prepare_state_machine(); - prepare_blocked_animation(); - animation_id = 0; - blocked_id = 0; - initial_mute = FALSE; - device_available = TRUE; - slider_in_direct_use = FALSE; - exterior_vol_update = OUT_OF_RANGE; + prepare_state_machine(); + prepare_blocked_animation(); + animation_id = 0; + blocked_id = 0; + initial_mute = FALSE; + device_available = TRUE; + slider_in_direct_use = FALSE; + exterior_vol_update = OUT_OF_RANGE; g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); - return; + return; } static void @@ -188,9 +188,9 @@ indicator_sound_dispose (GObject *object) g_object_unref(G_OBJECT(self->service)); self->service = NULL; } - g_hash_table_destroy(volume_states); + g_hash_table_destroy(volume_states); - free_the_animation_list(); + free_the_animation_list(); G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object); return; @@ -199,11 +199,11 @@ indicator_sound_dispose (GObject *object) static void free_the_animation_list() { - if(blocked_animation_list != NULL){ - g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL); - g_list_free(blocked_animation_list); - blocked_animation_list = NULL; - } + if(blocked_animation_list != NULL){ + g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL); + g_list_free(blocked_animation_list); + blocked_animation_list = NULL; + } } static void @@ -313,7 +313,19 @@ new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuC static gboolean new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { g_debug("indicator-sound: new_transport_bar() called "); - TransportBar* bar = transport_bar_new(); + + GtkWidget* bar = NULL; + + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); + g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + + bar = transport_bar_new(); + GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar); + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_transport_bar, parent); + + gtk_widget_show_all(bar); + return TRUE; } @@ -387,34 +399,34 @@ Only called at startup. static void prepare_blocked_animation() { - gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); - gchar* muted_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED)); + gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); + gchar* muted_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED)); - GtkImage* temp_image = indicator_image_helper(muted_name); - GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image); + GtkImage* temp_image = indicator_image_helper(muted_name); + GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image); - temp_image = indicator_image_helper(blocked_name); - GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image); + temp_image = indicator_image_helper(blocked_name); + GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image); - if(mute_buf == NULL || blocked_buf == NULL){ - g_debug("Don bother with the animation, the theme aint got the goods !"); - return; - } + if(mute_buf == NULL || blocked_buf == NULL){ + g_debug("Don bother with the animation, the theme aint got the goods !"); + return; + } - int i; + int i; - // sample 51 snapshots - range : 0-256 - for(i = 0; i < 51; i++) - { - gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0, - gdk_pixbuf_get_width(mute_buf), - gdk_pixbuf_get_height(mute_buf), - 0, 0, 1, 1, GDK_INTERP_BILINEAR, MIN(255, i * 5)); - blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf)); - } - g_object_ref_sink(mute_buf); + // sample 51 snapshots - range : 0-256 + for(i = 0; i < 51; i++) + { + gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0, + gdk_pixbuf_get_width(mute_buf), + gdk_pixbuf_get_height(mute_buf), + 0, 0, 1, 1, GDK_INTERP_BILINEAR, MIN(255, i * 5)); + blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf)); + } + g_object_ref_sink(mute_buf); g_object_unref(mute_buf); - g_object_ref_sink(blocked_buf); + g_object_ref_sink(blocked_buf); g_object_unref(blocked_buf); } @@ -422,26 +434,26 @@ prepare_blocked_animation() gint get_state() { - return current_state; + return current_state; } gchar* get_state_image_name(gint state) { - return g_hash_table_lookup(volume_states, GINT_TO_POINTER(state)); + return g_hash_table_lookup(volume_states, GINT_TO_POINTER(state)); } void prepare_for_tests(IndicatorObject *io) { - prepare_state_machine(); - get_icon(io); + prepare_state_machine(); + get_icon(io); } void tidy_up_hash() { - g_hash_table_destroy(volume_states); + g_hash_table_destroy(volume_states); } static void @@ -449,13 +461,13 @@ update_state(const gint state) { /* g_debug("update state beginning - previous_state = %i", previous_state);*/ - previous_state = current_state; + previous_state = current_state; /* g_debug("update state 3rd line - previous_state = %i", previous_state);*/ - current_state = state; - gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); - indicator_image_helper_update(speaker_image, image_name); + current_state = state; + gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); + indicator_image_helper_update(speaker_image, image_name); } diff --git a/src/transport-bar.c b/src/transport-bar.c index 8573cae..34f590e 100644 --- a/src/transport-bar.c +++ b/src/transport-bar.c @@ -30,7 +30,7 @@ typedef struct _TransportBarPrivate TransportBarPrivate; struct _TransportBarPrivate { - GtkWidget* hBox; + GtkWidget* hbox; GtkWidget* previous_button; GtkWidget* play_button; GtkWidget* next_button; @@ -43,7 +43,8 @@ static void transport_bar_class_init (TransportBarClass *klass); static void transport_bar_init (TransportBar *self); static void transport_bar_dispose (GObject *object); static void transport_bar_finalize (GObject *object); -G_DEFINE_TYPE (TransportBar, transport_bar, DBUSMENU_TYPE_MENUITEM); + +G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM); static void transport_bar_class_init (TransportBarClass *klass) @@ -54,29 +55,35 @@ transport_bar_class_init (TransportBarClass *klass) object_class->dispose = transport_bar_dispose; object_class->finalize = transport_bar_finalize; - - return; } static void transport_bar_init (TransportBar *self) { - g_debug("Building new Transport Item"); - hBox = gtk_hbox_new(TRUE, 2)); - previous_button = gtk_button_new_with_label("Previous")); - next_button = gtk_button_new_with_label("Next")); - play_button = gtk_button_new_with_label("Play")); - gtk_container_add((GtkContainer*) hBox, previous_button); - gtk_container_add((GtkContainer*) hBox, next_button); - gtk_container_add((GtkContainer*) hBox, play_button); - return; + g_debug("TransportBar::transport_bar_init"); + + TransportBarPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(self); + GtkWidget *hbox; + + hbox = gtk_hbox_new(TRUE, 2); + priv->previous_button = gtk_button_new_with_label("Previous"); + priv->next_button = gtk_button_new_with_label("Next"); + priv->play_button = gtk_button_new_with_label("Play"); + + gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, FALSE, 0); + + priv->hbox = hbox; + + gtk_widget_show_all (priv->hbox); + gtk_container_add (GTK_CONTAINER (self), hbox); } static void transport_bar_dispose (GObject *object) { G_OBJECT_CLASS (transport_bar_parent_class)->dispose (object); - return; } static void @@ -85,9 +92,13 @@ transport_bar_finalize (GObject *object) G_OBJECT_CLASS (transport_bar_parent_class)->finalize (object); } -TransportBar* +/** + * transport_new: + * @returns: a new #TransportBar. + **/ +GtkWidget* transport_bar_new() { - TransportBar *self = g_object_new(TRANSPORT_BAR_TYPE, NULL); - return self; + return g_object_new(TRANSPORT_BAR_TYPE, NULL); } + diff --git a/src/transport-bar.h b/src/transport-bar.h index e931298..e90e39c 100644 --- a/src/transport-bar.h +++ b/src/transport-bar.h @@ -19,8 +19,7 @@ with this program. If not, see . #ifndef __TRANSPORT_BAR_H__ #define __TRANSPORT_BAR_H__ -#include -#include +#include G_BEGIN_DECLS @@ -35,13 +34,15 @@ typedef struct _TransportBar TransportBar; typedef struct _TransportBarClass TransportBarClass; struct _TransportBarClass { + GtkMenuItemClass parent_class; }; struct _TransportBar { + GtkMenuItem parent; }; GType transport_bar_get_type (void); -TransportBar* transport_bar_new(); +GtkWidget* transport_bar_new(); G_END_DECLS -- cgit v1.2.3 From 8e51465790989d6b8ed8194a0d9a86fe7b3412d5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 9 Jun 2010 18:36:12 +0100 Subject: play controls in progress --- src/music-player-bridge.vala | 11 +++++++++-- src/transport-bar.c | 42 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index dc66101..92f9dc5 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -48,10 +48,15 @@ public class MusicPlayerBridge : GLib.Object if(server_is_not_of_interest(type)) return; string client_name = type.split(".")[1]; if (root_menu != null && client_name != null){ + Dbusmenu.Menuitem client_item = new Dbusmenu.Menuitem(); + client_item.property_set(MENUITEM_PROP_LABEL, client_name.concat(" is registered")); TransportMenuItem transport_item = new TransportMenuItem(); - //client_item.property_set(MENUITEM_PROP_LABEL, client_name.concat(" is registered")); - registered_clients.set(client_name, transport_item); + root_menu.child_append(client_item); root_menu.child_append(transport_item); + + registered_clients.set(client_name, client_item); + // hackery -> need to wrap player sections into its own object + registered_clients.set("transport", transport_item); debug("client of name %s has successfully registered with us", client_name); } } @@ -63,7 +68,9 @@ public class MusicPlayerBridge : GLib.Object string client_name = type.split(".")[1]; if (root_menu != null && client_name != null){ root_menu.child_delete(registered_clients[client_name]); + root_menu.child_delete(registered_clients["transport"]); registered_clients.remove(client_name); + registered_clients.remove("transport"); debug("Successively removed menu_item for client %s from registered_clients", client_name); } } diff --git a/src/transport-bar.c b/src/transport-bar.c index 34f590e..bafd917 100644 --- a/src/transport-bar.c +++ b/src/transport-bar.c @@ -44,17 +44,29 @@ static void transport_bar_init (TransportBar *self); static void transport_bar_dispose (GObject *object); static void transport_bar_finalize (GObject *object); + +static gboolean transport_bar_button_press_event (GtkWidget *menuitem, + GdkEventButton *event); +static gboolean transport_bar_button_release_event (GtkWidget *menuitem, + GdkEventButton *event); + + G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM); static void transport_bar_class_init (TransportBarClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + //GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + widget_class->button_press_event = transport_bar_button_press_event; + widget_class->button_release_event = transport_bar_button_release_event; + g_type_class_add_private (klass, sizeof (TransportBarPrivate)); - object_class->dispose = transport_bar_dispose; - object_class->finalize = transport_bar_finalize; + gobject_class->dispose = transport_bar_dispose; + gobject_class->finalize = transport_bar_finalize; } static void @@ -66,9 +78,9 @@ transport_bar_init (TransportBar *self) GtkWidget *hbox; hbox = gtk_hbox_new(TRUE, 2); - priv->previous_button = gtk_button_new_with_label("Previous"); - priv->next_button = gtk_button_new_with_label("Next"); - priv->play_button = gtk_button_new_with_label("Play"); + priv->previous_button = gtk_button_new_with_label("<<"); + priv->next_button = gtk_button_new_with_label(">>"); + priv->play_button = gtk_button_new_with_label(">"); gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, FALSE, 0); @@ -77,6 +89,7 @@ transport_bar_init (TransportBar *self) priv->hbox = hbox; gtk_widget_show_all (priv->hbox); + gtk_widget_set_sensitive(GTK_WIDGET(self), FALSE); gtk_container_add (GTK_CONTAINER (self), hbox); } @@ -92,6 +105,23 @@ transport_bar_finalize (GObject *object) G_OBJECT_CLASS (transport_bar_parent_class)->finalize (object); } +/* keyevents */ +static gboolean +transport_bar_button_press_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + g_debug("TransportBar::button_press_event"); + return TRUE; +} + +static gboolean +transport_bar_button_release_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + g_debug("TransportBar::button_release_event"); + return TRUE; +} + /** * transport_new: * @returns: a new #TransportBar. -- cgit v1.2.3 From c98d1cd6c1f1bc875eae17d77680c8ce5d6acb5f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 10 Jun 2010 12:46:17 +0100 Subject: player controller object underway --- src/Makefile.am | 3 ++- src/music-player-bridge.vala | 19 +++++------------- src/player-controller.vala | 47 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 15 deletions(-) create mode 100644 src/player-controller.vala diff --git a/src/Makefile.am b/src/Makefile.am index f7fb1a1..3479cb9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,7 +50,8 @@ sound-service-server.h: $(srcdir)/sound-service.xml ##################### music_bridge_VALASOURCES = \ music-player-bridge.vala \ - transport-menu-item.vala + transport-menu-item.vala \ + player-controller.vala music_bridge_VALAFLAGS = \ --ccode \ diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 92f9dc5..89f633b 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -7,11 +7,11 @@ public class MusicPlayerBridge : GLib.Object private Listener listener; private Dbusmenu.Menuitem root_menu; - private HashMap registered_clients; + private HashMap registered_clients; public MusicPlayerBridge() { - registered_clients = new HashMap (); + registered_clients = new HashMap (); listener = Listener.ref_default(); listener.indicator_added.connect(on_indicator_added); listener.indicator_removed.connect(on_indicator_removed); @@ -48,15 +48,8 @@ public class MusicPlayerBridge : GLib.Object if(server_is_not_of_interest(type)) return; string client_name = type.split(".")[1]; if (root_menu != null && client_name != null){ - Dbusmenu.Menuitem client_item = new Dbusmenu.Menuitem(); - client_item.property_set(MENUITEM_PROP_LABEL, client_name.concat(" is registered")); - TransportMenuItem transport_item = new TransportMenuItem(); - root_menu.child_append(client_item); - root_menu.child_append(transport_item); - - registered_clients.set(client_name, client_item); - // hackery -> need to wrap player sections into its own object - registered_clients.set("transport", transport_item); + PlayerController ctrl = new PlayerController(root_menu, client_name, true); + registered_clients.set(client_name, ctrl); debug("client of name %s has successfully registered with us", client_name); } } @@ -67,10 +60,8 @@ public class MusicPlayerBridge : GLib.Object if(server_is_not_of_interest(type)) return; string client_name = type.split(".")[1]; if (root_menu != null && client_name != null){ - root_menu.child_delete(registered_clients[client_name]); - root_menu.child_delete(registered_clients["transport"]); + registered_clients[client_name].vanish(); registered_clients.remove(client_name); - registered_clients.remove("transport"); debug("Successively removed menu_item for client %s from registered_clients", client_name); } } diff --git a/src/player-controller.vala b/src/player-controller.vala new file mode 100644 index 0000000..9cdf527 --- /dev/null +++ b/src/player-controller.vala @@ -0,0 +1,47 @@ +using Dbusmenu; +using Gee; + +public class PlayerController : GLib.Object +{ + private Dbusmenu.Menuitem root_menu; + private string name; + private bool is_active; + private ArrayList custom_items; + + public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active) + { + this.root_menu = root; + this.name = format_client_name(client_name); + this.is_active = active; + this.custom_items = new ArrayList(); + //Dbusmenu.Menuitem[]; + self_construct(); + } + + public void self_construct() + { + Dbusmenu.Menuitem client_item = new Dbusmenu.Menuitem(); + this.custom_items.add(client_item); + client_item.property_set(MENUITEM_PROP_LABEL, this.name.concat("")); + TransportMenuItem transport_item = new TransportMenuItem(); + this.custom_items.add(transport_item); + root_menu.child_append(client_item); + root_menu.child_append(transport_item); + } + + public void vanish() + { + foreach(Dbusmenu.Menuitem item in this.custom_items){ + root_menu.child_delete(item); + } + } + + public static string format_client_name(string client_name) + { + debug("PlayerController->format_client_name"); + //string first_letter = client_name.slice(1); + //debug("PlayerController->format_client_name - first_letter: %s", first_letter); + return client_name; + } + +} \ No newline at end of file -- cgit v1.2.3 From 50497b6b375cb96b77ed1700f58b8b8991f4c1ae Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 10 Jun 2010 16:04:06 +0100 Subject: working on some signals --- src/player-controller.vala | 31 +++++++++++--------- src/transport-bar.c | 73 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 83 insertions(+), 21 deletions(-) diff --git a/src/player-controller.vala b/src/player-controller.vala index 9cdf527..86f0e0f 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -11,14 +11,20 @@ public class PlayerController : GLib.Object public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active) { this.root_menu = root; - this.name = format_client_name(client_name); + this.name = format_client_name(client_name.strip()); this.is_active = active; this.custom_items = new ArrayList(); - //Dbusmenu.Menuitem[]; self_construct(); } - public void self_construct() + public void vanish() + { + foreach(Dbusmenu.Menuitem item in this.custom_items){ + root_menu.child_delete(item); + } + } + + private void self_construct() { Dbusmenu.Menuitem client_item = new Dbusmenu.Menuitem(); this.custom_items.add(client_item); @@ -29,19 +35,16 @@ public class PlayerController : GLib.Object root_menu.child_append(transport_item); } - public void vanish() + private static string format_client_name(string client_name) { - foreach(Dbusmenu.Menuitem item in this.custom_items){ - root_menu.child_delete(item); + string formatted = client_name; + //debug("PlayerController->format_client_name"); + if(formatted.len() > 1){ + formatted = client_name.up(1).concat(client_name.slice(1, client_name.len())); + debug("PlayerController->format_client_name - : %s", formatted); } + + return formatted; } - public static string format_client_name(string client_name) - { - debug("PlayerController->format_client_name"); - //string first_letter = client_name.slice(1); - //debug("PlayerController->format_client_name - first_letter: %s", first_letter); - return client_name; - } - } \ No newline at end of file diff --git a/src/transport-bar.c b/src/transport-bar.c index bafd917..aa618d2 100644 --- a/src/transport-bar.c +++ b/src/transport-bar.c @@ -36,6 +36,16 @@ struct _TransportBarPrivate GtkWidget* next_button; }; +enum { + PLAY, + PAUSE, + NEXT, + PREVIOUS, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + #define TRANSPORT_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_BAR_TYPE, TransportBarPrivate)) /* Prototypes */ @@ -49,6 +59,9 @@ static gboolean transport_bar_button_press_event (GtkWidget *menuite GdkEventButton *event); static gboolean transport_bar_button_release_event (GtkWidget *menuitem, GdkEventButton *event); +static gboolean transport_bar_play_button_trigger (GtkWidget* widget, + GdkEventButton *event, + gpointer user_data); G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM); @@ -57,7 +70,6 @@ static void transport_bar_class_init (TransportBarClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - //GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); widget_class->button_press_event = transport_bar_button_press_event; @@ -67,6 +79,39 @@ transport_bar_class_init (TransportBarClass *klass) gobject_class->dispose = transport_bar_dispose; gobject_class->finalize = transport_bar_finalize; + + signals[PLAY] = g_signal_new ("play", + G_OBJECT_CLASS_TYPE (gobject_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[PAUSE] = g_signal_new ("pause", + G_OBJECT_CLASS_TYPE (gobject_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + + signals[NEXT] = g_signal_new ("next", + G_OBJECT_CLASS_TYPE (gobject_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[PREVIOUS] = g_signal_new ("previous", + G_OBJECT_CLASS_TYPE (gobject_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } static void @@ -85,12 +130,16 @@ transport_bar_init (TransportBar *self) gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, FALSE, 0); + + g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_bar_play_button_trigger), NULL); + priv->hbox = hbox; gtk_widget_show_all (priv->hbox); - gtk_widget_set_sensitive(GTK_WIDGET(self), FALSE); gtk_container_add (GTK_CONTAINER (self), hbox); + + } static void @@ -110,19 +159,29 @@ static gboolean transport_bar_button_press_event (GtkWidget *menuitem, GdkEventButton *event) { - g_debug("TransportBar::button_press_event"); - return TRUE; + g_debug("TransportBar::menu_press_event"); + return FALSE; } static gboolean transport_bar_button_release_event (GtkWidget *menuitem, GdkEventButton *event) { - g_debug("TransportBar::button_release_event"); - return TRUE; + g_debug("TransportBar::menu_release_event"); + return FALSE; +} + +/* Individual keyevents on the buttons */ +static gboolean +transport_bar_play_button_trigger(GtkWidget* widget, + GdkEventButton *event, + gpointer user_data) +{ + g_debug("TransportBar::PLAY button_press_event"); + return FALSE; } -/** + /** * transport_new: * @returns: a new #TransportBar. **/ -- cgit v1.2.3 From da91c666d6b66163077ddb9e59bf556fb4d44953 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 11 Jun 2010 08:59:06 +0100 Subject: --- src/common-defs.h | 6 +++--- src/indicator-sound.c | 2 +- src/player-controller.vala | 40 ++++++++++++++++++++++++++++++---------- src/transport-bar.c | 34 +++++++++++++++++++++++++--------- src/transport-bar.h | 2 ++ src/transport-menu-item.vala | 4 +++- 6 files changed, 64 insertions(+), 24 deletions(-) diff --git a/src/common-defs.h b/src/common-defs.h index 94c178e..5393400 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -24,7 +24,7 @@ with this program. If not, see . #define SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate" #define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" -// DBUS items +/* DBUS Custom Items */ #define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item" -#define DBUSMENU_SLIDER_MENUITEM_PROP_VOLUME "volume" -#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar" +#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar" +#define DBUSMENU_TRANSPORT_MENUITEM_STATE "x-canonical-transport-state" \ No newline at end of file diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 48fde56..a3856c4 100755 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -319,7 +319,7 @@ static gboolean new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - bar = transport_bar_new(); + bar = transport_bar_new(newitem); GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_transport_bar, parent); diff --git a/src/player-controller.vala b/src/player-controller.vala index 86f0e0f..a92d8bf 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -7,7 +7,8 @@ public class PlayerController : GLib.Object private string name; private bool is_active; private ArrayList custom_items; - + + // TODO: pass in the appropriate position for the menu public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active) { this.root_menu = root; @@ -24,21 +25,40 @@ public class PlayerController : GLib.Object } } - private void self_construct() + private bool self_construct() { - Dbusmenu.Menuitem client_item = new Dbusmenu.Menuitem(); - this.custom_items.add(client_item); - client_item.property_set(MENUITEM_PROP_LABEL, this.name.concat("")); - TransportMenuItem transport_item = new TransportMenuItem(); + // Separator item + Dbusmenu.Menuitem separator_item = new Dbusmenu.Menuitem(); + separator_item.property_set(MENUITEM_PROP_TYPE, CLIENT_TYPES_SEPARATOR); + this.custom_items.add(separator_item); + + // Title item + Dbusmenu.Menuitem title_item = new Dbusmenu.Menuitem(); + title_item.property_set(MENUITEM_PROP_LABEL, this.name.concat("")); + title_item.property_set(MENUITEM_PROP_ICON_NAME, "applications-multimedia"); + this.custom_items.add(title_item); + + // Transport item + TransportMenuItem transport_item = new TransportMenuItem(); this.custom_items.add(transport_item); - root_menu.child_append(client_item); - root_menu.child_append(transport_item); - } + + int offset = 2; + foreach(Dbusmenu.Menuitem item in this.custom_items){ + root_menu.child_add_position(item, offset + this.custom_items.index_of(item)); + } + return true; + } +// if(!root_menu.child_add_position(client_item, 2) || +// !root_menu.child_add_position(transport_item, 3)){ +// //TODO raise here! +// return false; +// } +// return true; + private static string format_client_name(string client_name) { string formatted = client_name; - //debug("PlayerController->format_client_name"); if(formatted.len() > 1){ formatted = client_name.up(1).concat(client_name.slice(1, client_name.len())); debug("PlayerController->format_client_name - : %s", formatted); diff --git a/src/transport-bar.c b/src/transport-bar.c index aa618d2..46611dc 100644 --- a/src/transport-bar.c +++ b/src/transport-bar.c @@ -26,6 +26,9 @@ with this program. If not, see . #include "common-defs.h" #include +// TODO: think about leakage: ted ! + + typedef struct _TransportBarPrivate TransportBarPrivate; struct _TransportBarPrivate @@ -59,10 +62,11 @@ static gboolean transport_bar_button_press_event (GtkWidget *menuite GdkEventButton *event); static gboolean transport_bar_button_release_event (GtkWidget *menuitem, GdkEventButton *event); -static gboolean transport_bar_play_button_trigger (GtkWidget* widget, - GdkEventButton *event, - gpointer user_data); - +static gboolean transport_bar_play_button_trigger (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); +static void transport_bar_update_state(gchar * property, + GValue * value); G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM); @@ -132,19 +136,22 @@ transport_bar_init (TransportBar *self) gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, FALSE, 0); g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_bar_play_button_trigger), NULL); - - priv->hbox = hbox; + + g_signal_connect(DBUSMENU_MENUITEM(self), "property-changed", G_CALLBACK(transport_bar_update_state), NULL); gtk_widget_show_all (priv->hbox); gtk_container_add (GTK_CONTAINER (self), hbox); - } static void transport_bar_dispose (GObject *object) { + //if(IS_TRANSPORT_BAR(object) == TRUE){ + // TransportBarPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(TRANSPORT_BAR(object)); + // g_object_unref(priv->previous_button); + //} G_OBJECT_CLASS (transport_bar_parent_class)->dispose (object); } @@ -174,13 +181,22 @@ transport_bar_button_release_event (GtkWidget *menuitem, /* Individual keyevents on the buttons */ static gboolean transport_bar_play_button_trigger(GtkWidget* widget, - GdkEventButton *event, - gpointer user_data) + GdkEventButton *event, + gpointer user_data) { g_debug("TransportBar::PLAY button_press_event"); return FALSE; } +static void transport_bar_update_state(gchar *property, GValue *value) +{ + g_debug("transport_bar_update_state - %s", property); +} + +void transport_bar_connect_with_other_half(TransportBar *self, DbusmenuMenuitem *twin_item) +{ + +} /** * transport_new: * @returns: a new #TransportBar. diff --git a/src/transport-bar.h b/src/transport-bar.h index e90e39c..93136e1 100644 --- a/src/transport-bar.h +++ b/src/transport-bar.h @@ -20,6 +20,7 @@ with this program. If not, see . #define __TRANSPORT_BAR_H__ #include +#include G_BEGIN_DECLS @@ -43,6 +44,7 @@ struct _TransportBar { GType transport_bar_get_type (void); GtkWidget* transport_bar_new(); +void connect_with_other_half(DbusmenuMenuitem *twin_item); G_END_DECLS diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 11120b0..9af52d1 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -5,10 +5,12 @@ public class TransportMenuItem : Dbusmenu.Menuitem { /* Not ideal duplicate definition of const - see common-defs/h */ const string DBUSMENU_TRANSPORT_MENUITEM_TYPE = "x-canonical-transport-bar"; + const string DBUSMENU_TRANSPORT_MENUITEM_STATE = "x-canonical-transport-state"; public TransportMenuItem() { - this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE); + this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE); + this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_STATE); } public override void handle_event(string name, GLib.Value input_value, uint timestamp) -- cgit v1.2.3 From 448e45e3fa53620804ab8ec9c5940946f45a8b62 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 11 Jun 2010 15:09:07 +0100 Subject: new widget for the metadata --- src/Makefile.am | 3 + src/common-defs.h | 8 +- src/metadata-menu-item.vala | 26 +++++++ src/metadata-widget.c | 179 +++++++++++++++++++++++++++++++++++++++++++ src/metadata-widget.c~ | 179 +++++++++++++++++++++++++++++++++++++++++++ src/metadata-widget.h | 51 ++++++++++++ src/metadata-widget.h~ | 51 ++++++++++++ src/player-controller.vala | 17 ++-- src/transport-bar.c | 51 +++++++++--- src/transport-bar.h | 3 +- src/transport-menu-item.vala | 10 +-- 11 files changed, 551 insertions(+), 27 deletions(-) create mode 100644 src/metadata-menu-item.vala create mode 100644 src/metadata-widget.c create mode 100644 src/metadata-widget.c~ create mode 100644 src/metadata-widget.h create mode 100644 src/metadata-widget.h~ diff --git a/src/Makefile.am b/src/Makefile.am index 3479cb9..b28903b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,8 @@ libsoundmenu_la_SOURCES = \ indicator-sound.h \ transport-bar.c \ transport-bar.h \ + metadata-widget.c \ + metadata-widget.h \ indicator-sound.c \ dbus-shared-names.h \ sound-service-client.h @@ -51,6 +53,7 @@ sound-service-server.h: $(srcdir)/sound-service.xml music_bridge_VALASOURCES = \ music-player-bridge.vala \ transport-menu-item.vala \ + metadata-menu-item.vala \ player-controller.vala music_bridge_VALAFLAGS = \ diff --git a/src/common-defs.h b/src/common-defs.h index 5393400..e38b15f 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -27,4 +27,10 @@ with this program. If not, see . /* DBUS Custom Items */ #define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item" #define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar" -#define DBUSMENU_TRANSPORT_MENUITEM_STATE "x-canonical-transport-state" \ No newline at end of file +#define DBUSMENU_TRANSPORT_MENUITEM_STATE "x-canonical-transport-state" + +#define DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item"; +#define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist"; +#define DBUSMENU_METADATA_MENUITEM_TEXT_PIECE = "x-canonical-metadata-text-piece"; +#define DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER = "x-canonical-metadata-text-container"; +#define DBUSMENU_METADATA_MENUITEM_IMAGE = "x-canonical-metadata-image"; diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala new file mode 100644 index 0000000..0f6d7d5 --- /dev/null +++ b/src/metadata-menu-item.vala @@ -0,0 +1,26 @@ +using Dbusmenu; +using Gee; + +public class MetadataMenuitem : Dbusmenu.Menuitem +{ + /* Not ideal duplicate definition of const - see common-defs/h */ + const string DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item"; + const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist"; + const string DBUSMENU_METADATA_MENUITEM_TEXT_PIECE = "x-canonical-metadata-text-piece"; + const string DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER = "x-canonical-metadata-text-container"; + const string DBUSMENU_METADATA_MENUITEM_IMAGE = "x-canonical-metadata-image"; + + public MetadataMenuitem() + { + this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_METADATA_MENUITEM_TYPE); + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, "Sonnamble"); + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, "Nocturne"); + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, "Seven Months in E minor"); + this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE, ""); + } + + public override void handle_event(string name, GLib.Value input_value, uint timestamp) + { + debug("MetadataItem -> handle event caught!"); + } +} \ No newline at end of file diff --git a/src/metadata-widget.c b/src/metadata-widget.c new file mode 100644 index 0000000..5e20f15 --- /dev/null +++ b/src/metadata-widget.c @@ -0,0 +1,179 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "metadata-widget.h" +#include "common-defs.h" +#include + +// TODO: think about leakage: ted ! + + + +static DbusmenuMenuitem* twin_item; + +typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; + +struct _MetadataWidgetPrivate +{ + GtkWidget* hbox; +}; + +#define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate)) + +/* Prototypes */ +static void metadata_widget_class_init (MetadataWidgetClass *klass); +static void metadata_widget_init (MetadataWidget *self); +static void metadata_widget_dispose (GObject *object); +static void metadata_widget_finalize (GObject *object); +// keyevent consumers +static gboolean metadata_widget_button_press_event (GtkWidget *menuitem, + GdkEventButton *event); +static gboolean metadata_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event); + + +// Dbusmenuitem update callback +static void metadata_widget_update_state(gchar * property, + GValue * value, + gpointer userdata); + + + +G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); + + + +static void +metadata_widget_class_init (MetadataWidgetClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->button_press_event = metadata_widget_button_press_event; + widget_class->button_release_event = metadata_widget_button_release_event; + + g_type_class_add_private (klass, sizeof (MetadataWidgetPrivate)); + + gobject_class->dispose = metadata_widget_dispose; + gobject_class->finalize = metadata_widget_finalize; + +} + +static void +metadata_widget_init (MetadataWidget *self) +{ + g_debug("MetadataWidget::metadata_widget_init"); + + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + GtkWidget *hbox; + + hbox = gtk_hbox_new(TRUE, 2); + + g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(metadata_widget_update_state), self); + + gtk_widget_show_all (priv->hbox); + gtk_container_add (GTK_CONTAINER (self), hbox); + +} + +static void +metadata_widget_dispose (GObject *object) +{ + //if(IS_METADATA_WIDGET(object) == TRUE){ + // MetadataWidget * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object)); + // g_object_unref(priv->previous_button); + //} + G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object); +} + +static void +metadata_widget_finalize (GObject *object) +{ + G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object); +} + +/* Suppress/consume keyevents */ +static gboolean +metadata_widget_button_press_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + g_debug("MetadataWidget::menu_press_event"); + return TRUE; +} + +static gboolean +metadata_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + g_debug("MetadataWidget::menu_release_event"); + return TRUE; +} + + +//TODO figure out why the userdata is not what I expect it to be. +static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata) +{ + //MetadataWidget* bar = (MetadataWidget*)userdata; + // TODO problem line + //if(IS_METADATA_WIDGET(bar)){ + //g_debug("after line 1!!"); + + //MetadataWidget *priv = METADATA_WIDGET_GET_PRIVATE(bar); + //g_debug("after line 2!!"); + //gchar* label = "changed"; + //g_debug("after line 3!!"); + //gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); + //} + //if(GTK_IS_BUTTON(GTK_BUTTON(priv->play_button))){ + + // gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); + // g_debug("its a button"); + //} + //else{ + //g_debug("No Goddamn button!!"); + //} + //} + g_debug("metadata_widget_update_state - with property %s", property); + + if (value == NULL){ + g_debug("value is null"); + return; + } + // TODO problem line + //gchar* input = g_strdup(g_value_get_string(value)); + //g_debug("metadata_widget_update_state - with value %s", input); + +} + + /** + * transport_new: + * @returns: a new #MetadataWidget. + **/ +GtkWidget* +metadata_widget_new(DbusmenuMenuitem *item) +{ + twin_item = item; + return g_object_new(METADATA_WIDGET_TYPE, NULL); +} + diff --git a/src/metadata-widget.c~ b/src/metadata-widget.c~ new file mode 100644 index 0000000..39a42db --- /dev/null +++ b/src/metadata-widget.c~ @@ -0,0 +1,179 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "metadata-widget.h" +#include "common-defs.h" +#include + +// TODO: think about leakage: ted ! + + + +static DbusmenuMenuitem* twin_item; + +typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; + +struct _MetadataWidgetPrivate +{ + GtkWidget* hbox; +}; + +#define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate)) + +/* Prototypes */ +static void metadata_widget_class_init (MetadataWidgetClass *klass); +static void metadata_widget_init (MetadataWidget *self); +static void metadata_widget_dispose (GObject *object); +static void metadata_widget_finalize (GObject *object); +// keyevent consumers +static gboolean metadata_widget_button_press_event (GtkWidget *menuitem, + GdkEventButton *event); +static gboolean metadata_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event); + + +// Dbusmenuitem update callback +static void metadata_widget_update_state(gchar * property, + GValue * value, + gpointer userdata); + + + +G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); + + + +static void +metadata_widget_class_init (MetadataWidgetClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->button_press_event = metadata_widget_press_event; + widget_class->button_release_event = metadata_widget_button_release_event; + + g_type_class_add_private (klass, sizeof (MetadataWidgetPrivate)); + + gobject_class->dispose = metadata_widget_dispose; + gobject_class->finalize = metadata_widget_finalize; + +} + +static void +metadata_widget_init (MetadataWidget *self) +{ + g_debug("MetadataWidget::metadata_widget_init"); + + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + GtkWidget *hbox; + + hbox = gtk_hbox_new(TRUE, 2); + + g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(metadata_widget_update_state), self); + + gtk_widget_show_all (priv->hbox); + gtk_container_add (GTK_CONTAINER (self), hbox); + +} + +static void +metadata_widget_dispose (GObject *object) +{ + //if(IS_METADATA_WIDGET(object) == TRUE){ + // MetadataWidget * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object)); + // g_object_unref(priv->previous_button); + //} + G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object); +} + +static void +metadata_widget_finalize (GObject *object) +{ + G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object); +} + +/* Suppress/consume keyevents */ +static gboolean +metadata_widget_button_press_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + g_debug("MetadataWidget::menu_press_event"); + return TRUE; +} + +static gboolean +metadata_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + g_debug("MetadataWidget::menu_release_event"); + return TRUE; +} + + +//TODO figure out why the userdata is not what I expect it to be. +static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata) +{ + //MetadataWidget* bar = (MetadataWidget*)userdata; + // TODO problem line + //if(IS_METADATA_WIDGET(bar)){ + //g_debug("after line 1!!"); + + //MetadataWidget *priv = METADATA_WIDGET_GET_PRIVATE(bar); + //g_debug("after line 2!!"); + //gchar* label = "changed"; + //g_debug("after line 3!!"); + //gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); + //} + //if(GTK_IS_BUTTON(GTK_BUTTON(priv->play_button))){ + + // gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); + // g_debug("its a button"); + //} + //else{ + //g_debug("No Goddamn button!!"); + //} + //} + g_debug("metadata_widget_update_state - with property %s", property); + + if (value == NULL){ + g_debug("value is null"); + return; + } + // TODO problem line + //gchar* input = g_strdup(g_value_get_string(value)); + //g_debug("metadata_widget_update_state - with value %s", input); + +} + + /** + * transport_new: + * @returns: a new #MetadataWidget. + **/ +GtkWidget* +metadata_widget_new(DbusmenuMenuitem *item) +{ + twin_item = item; + return g_object_new(METADATA_WIDGET_TYPE, NULL); +} + diff --git a/src/metadata-widget.h b/src/metadata-widget.h new file mode 100644 index 0000000..ce7df5f --- /dev/null +++ b/src/metadata-widget.h @@ -0,0 +1,51 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ +#ifndef __METADATA_WIDGET_H__ +#define __METADATA_WIDGET_H__ + +#include +#include + +G_BEGIN_DECLS + +#define METADATA_WIDGET_TYPE (metadata_widget_get_type ()) +#define METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), METADATA_WIDGET_TYPE, TransportBar)) +#define METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), METADATA_WIDGET_TYPE, MetadataWidgetClass)) +#define IS_METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), METADATA_WIDGET_TYPE)) +#define IS_METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), METADATA_WIDGET_TYPE)) +#define METADATA_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), METADATA_WIDGET_TYPE, MetadataWidgetClass)) + +typedef struct _MetadataWidget MetadataWidget; +typedef struct _MetadataWidgetClass MetadataWidgetClass; + +struct _MetadataWidgetClass { + GtkMenuItemClass parent_class; +}; + +struct _MetadataWidget { + GtkMenuItem parent; +}; + +GType metadata_widget_get_type (void); +GtkWidget* metadata_widget_new(DbusmenuMenuitem *twin_item); + +G_END_DECLS + +#endif + diff --git a/src/metadata-widget.h~ b/src/metadata-widget.h~ new file mode 100644 index 0000000..edffdf2 --- /dev/null +++ b/src/metadata-widget.h~ @@ -0,0 +1,51 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ +#ifndef __METADATA_WIDGET_H__ +#define __METADATA_WIDGET_H__ + +#include +#include + +G_BEGIN_DECLS + +#define METADATA_WIDGET_TYPE (metadata_widget_get_type ()) +#define METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), METADATA_WIDGET_TYPE, TransportBar)) +#define METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), METADATA_WIDGET_TYPE, TransportBarClass)) +#define IS_METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), METADATA_WIDGET_TYPE)) +#define IS_METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), METADATA_WIDGET_TYPE)) +#define METADATA_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), METADATA_WIDGET_TYPE, TransportBarClass)) + +typedef struct _TransportBar TransportBar; +typedef struct _TransportBarClass TransportBarClass; + +struct _TransportBarClass { + GtkMenuItemClass parent_class; +}; + +struct _TransportBar { + GtkMenuItem parent; +}; + +GType metadata_widget_get_type (void); +GtkWidget* metadata_widget_new(DbusmenuMenuitem *twin_item); + +G_END_DECLS + +#endif + diff --git a/src/player-controller.vala b/src/player-controller.vala index a92d8bf..26ad1ff 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -8,7 +8,7 @@ public class PlayerController : GLib.Object private bool is_active; private ArrayList custom_items; - // TODO: pass in the appropriate position for the menu + // TODO: pass in the appropriate position for the menu (to handle multiple players) public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active) { this.root_menu = root; @@ -38,8 +38,12 @@ public class PlayerController : GLib.Object title_item.property_set(MENUITEM_PROP_ICON_NAME, "applications-multimedia"); this.custom_items.add(title_item); + // Metadata item + MetadataMenuitem metadata_item = new MetadataMenuitem(); + this.custom_items.add(metadata_item); + // Transport item - TransportMenuItem transport_item = new TransportMenuItem(); + TransportMenuitem transport_item = new TransportMenuitem(); this.custom_items.add(transport_item); int offset = 2; @@ -48,12 +52,6 @@ public class PlayerController : GLib.Object } return true; } -// if(!root_menu.child_add_position(client_item, 2) || -// !root_menu.child_add_position(transport_item, 3)){ -// //TODO raise here! -// return false; -// } -// return true; private static string format_client_name(string client_name) @@ -62,8 +60,7 @@ public class PlayerController : GLib.Object if(formatted.len() > 1){ formatted = client_name.up(1).concat(client_name.slice(1, client_name.len())); debug("PlayerController->format_client_name - : %s", formatted); - } - + } return formatted; } diff --git a/src/transport-bar.c b/src/transport-bar.c index 46611dc..02d9a45 100644 --- a/src/transport-bar.c +++ b/src/transport-bar.c @@ -29,6 +29,9 @@ with this program. If not, see . // TODO: think about leakage: ted ! + +static DbusmenuMenuitem* twin_item; + typedef struct _TransportBarPrivate TransportBarPrivate; struct _TransportBarPrivate @@ -66,10 +69,13 @@ static gboolean transport_bar_play_button_trigger (GtkWidget *widget, GdkEventButton *event, gpointer user_data); static void transport_bar_update_state(gchar * property, - GValue * value); + GValue * value, + gpointer userdata); G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM); + + static void transport_bar_class_init (TransportBarClass *klass) { @@ -138,7 +144,7 @@ transport_bar_init (TransportBar *self) g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_bar_play_button_trigger), NULL); priv->hbox = hbox; - g_signal_connect(DBUSMENU_MENUITEM(self), "property-changed", G_CALLBACK(transport_bar_update_state), NULL); + g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_bar_update_state), self); gtk_widget_show_all (priv->hbox); gtk_container_add (GTK_CONTAINER (self), hbox); @@ -188,22 +194,49 @@ transport_bar_play_button_trigger(GtkWidget* widget, return FALSE; } -static void transport_bar_update_state(gchar *property, GValue *value) -{ - g_debug("transport_bar_update_state - %s", property); -} - -void transport_bar_connect_with_other_half(TransportBar *self, DbusmenuMenuitem *twin_item) +//TODO figure out why the userdata is not what I expect it to be. +static void transport_bar_update_state(gchar *property, GValue *value, gpointer userdata) { + //TransportBar* bar = (TransportBar*)userdata; + // TODO problem line + //if(IS_TRANSPORT_BAR(bar)){ + //g_debug("after line 1!!"); + + //TransportBarPrivate *priv = TRANSPORT_BAR_GET_PRIVATE(bar); + //g_debug("after line 2!!"); + //gchar* label = "changed"; + //g_debug("after line 3!!"); + //gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); + //} + //if(GTK_IS_BUTTON(GTK_BUTTON(priv->play_button))){ + // gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); + // g_debug("its a button"); + //} + //else{ + //g_debug("No Goddamn button!!"); + //} + //} + g_debug("transport_bar_update_state - with property %s", property); + + if (value == NULL){ + g_debug("value is null"); + return; + } + // TODO problem line + //gchar* input = g_strdup(g_value_get_string(value)); + //g_debug("transport_bar_update_state - with value %s", input); + } + /** * transport_new: * @returns: a new #TransportBar. **/ GtkWidget* -transport_bar_new() +transport_bar_new(DbusmenuMenuitem *item) { + twin_item = item; return g_object_new(TRANSPORT_BAR_TYPE, NULL); } diff --git a/src/transport-bar.h b/src/transport-bar.h index 93136e1..8a791ff 100644 --- a/src/transport-bar.h +++ b/src/transport-bar.h @@ -43,8 +43,7 @@ struct _TransportBar { }; GType transport_bar_get_type (void); -GtkWidget* transport_bar_new(); -void connect_with_other_half(DbusmenuMenuitem *twin_item); +GtkWidget* transport_bar_new(DbusmenuMenuitem *twin_item); G_END_DECLS diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 9af52d1..0ecc9b1 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -1,21 +1,21 @@ using Dbusmenu; using Gee; -public class TransportMenuItem : Dbusmenu.Menuitem +public class TransportMenuitem : Dbusmenu.Menuitem { /* Not ideal duplicate definition of const - see common-defs/h */ const string DBUSMENU_TRANSPORT_MENUITEM_TYPE = "x-canonical-transport-bar"; const string DBUSMENU_TRANSPORT_MENUITEM_STATE = "x-canonical-transport-state"; - public TransportMenuItem() + public TransportMenuitem() { this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE); - this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_STATE); + this.property_set(DBUSMENU_TRANSPORT_MENUITEM_STATE, "play"); } public override void handle_event(string name, GLib.Value input_value, uint timestamp) { + this.property_set(DBUSMENU_TRANSPORT_MENUITEM_STATE, "1"); debug("TransportItem -> handle event caught!"); - } - + } } \ No newline at end of file -- cgit v1.2.3 From 1a3e82434ad971872d5be3181b91071fccdc0fea Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 11 Jun 2010 18:17:22 +0100 Subject: properties working --- src/transport-bar.c | 64 +++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/src/transport-bar.c b/src/transport-bar.c index 02d9a45..96ae287 100644 --- a/src/transport-bar.c +++ b/src/transport-bar.c @@ -28,8 +28,6 @@ with this program. If not, see . // TODO: think about leakage: ted ! - - static DbusmenuMenuitem* twin_item; typedef struct _TransportBarPrivate TransportBarPrivate; @@ -54,13 +52,13 @@ static guint signals[LAST_SIGNAL] = { 0 }; #define TRANSPORT_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_BAR_TYPE, TransportBarPrivate)) -/* Prototypes */ +/* Gobject boiler plate */ static void transport_bar_class_init (TransportBarClass *klass); static void transport_bar_init (TransportBar *self); static void transport_bar_dispose (GObject *object); static void transport_bar_finalize (GObject *object); - +/* UI and dbus callbacks */ static gboolean transport_bar_button_press_event (GtkWidget *menuitem, GdkEventButton *event); static gboolean transport_bar_button_release_event (GtkWidget *menuitem, @@ -68,9 +66,12 @@ static gboolean transport_bar_button_release_event (GtkWidget *menui static gboolean transport_bar_play_button_trigger (GtkWidget *widget, GdkEventButton *event, gpointer user_data); -static void transport_bar_update_state(gchar * property, +static void transport_bar_update_state(DbusmenuMenuitem* item, + gchar * property, GValue * value, gpointer userdata); +// utility methods +static gchar* transport_bar_determine_play_label(gchar* state); G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM); @@ -194,39 +195,34 @@ transport_bar_play_button_trigger(GtkWidget* widget, return FALSE; } -//TODO figure out why the userdata is not what I expect it to be. -static void transport_bar_update_state(gchar *property, GValue *value, gpointer userdata) +/** +* transport_bar_update_state() +* Callback for updates from the other side of dbus +**/ +static void transport_bar_update_state(DbusmenuMenuitem* item, gchar* property, + GValue* value, gpointer userdata) { - //TransportBar* bar = (TransportBar*)userdata; - // TODO problem line - //if(IS_TRANSPORT_BAR(bar)){ - //g_debug("after line 1!!"); - - //TransportBarPrivate *priv = TRANSPORT_BAR_GET_PRIVATE(bar); - //g_debug("after line 2!!"); - //gchar* label = "changed"; - //g_debug("after line 3!!"); - //gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); - //} - //if(GTK_IS_BUTTON(GTK_BUTTON(priv->play_button))){ - - // gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); - // g_debug("its a button"); - //} - //else{ - //g_debug("No Goddamn button!!"); - //} - //} g_debug("transport_bar_update_state - with property %s", property); + gchar* input = g_strdup(g_value_get_string(value)); + g_debug("transport_bar_update_state - with value %s", input); - if (value == NULL){ - g_debug("value is null"); - return; - } - // TODO problem line - //gchar* input = g_strdup(g_value_get_string(value)); - //g_debug("transport_bar_update_state - with value %s", input); + TransportBar* bar = (TransportBar*)userdata; + TransportBarPrivate *priv = TRANSPORT_BAR_GET_PRIVATE(bar); + + gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_bar_determine_play_label(property))); +} +// will be needed for image swapping +static gchar* transport_bar_determine_play_label(gchar* state) +{ + gchar* label = ">"; + if(g_strcmp0(state, "pause") == 0){ + label = "||"; + } + else if(g_strcmp0(state, "play") == 0){ + label = ">"; + } + return label; } /** -- cgit v1.2.3 From 3337497532d6d726d9eaa42b5b1b3ed8e4dbedc7 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Sun, 13 Jun 2010 22:27:50 +0100 Subject: album art underway --- src/common-defs.h | 18 ++++++++--------- src/metadata-menu-item.vala | 4 ++-- src/metadata-widget.c | 45 ++++++++++++------------------------------- src/metadata-widget.c~ | 47 +++++++++++++-------------------------------- src/player-controller.vala | 2 +- 5 files changed, 37 insertions(+), 79 deletions(-) diff --git a/src/common-defs.h b/src/common-defs.h index e38b15f..014d864 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -25,12 +25,12 @@ with this program. If not, see . #define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" /* DBUS Custom Items */ -#define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item" -#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar" -#define DBUSMENU_TRANSPORT_MENUITEM_STATE "x-canonical-transport-state" - -#define DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item"; -#define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist"; -#define DBUSMENU_METADATA_MENUITEM_TEXT_PIECE = "x-canonical-metadata-text-piece"; -#define DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER = "x-canonical-metadata-text-container"; -#define DBUSMENU_METADATA_MENUITEM_IMAGE = "x-canonical-metadata-image"; +#define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item" +#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar" +#define DBUSMENU_TRANSPORT_MENUITEM_STATE "x-canonical-transport-state" + +#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-metadata-menu-item" +#define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST "x-canonical-metadata-text-artist" +#define DBUSMENU_METADATA_MENUITEM_TEXT_PIECE "x-canonical-metadata-text-piece" +#define DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER "x-canonical-metadata-text-container" +#define DBUSMENU_METADATA_MENUITEM_IMAGE_PATH "x-canonical-metadata-image" diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 0f6d7d5..c9daee6 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -8,7 +8,7 @@ public class MetadataMenuitem : Dbusmenu.Menuitem const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist"; const string DBUSMENU_METADATA_MENUITEM_TEXT_PIECE = "x-canonical-metadata-text-piece"; const string DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER = "x-canonical-metadata-text-container"; - const string DBUSMENU_METADATA_MENUITEM_IMAGE = "x-canonical-metadata-image"; + const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH = "x-canonical-metadata-image"; public MetadataMenuitem() { @@ -16,7 +16,7 @@ public class MetadataMenuitem : Dbusmenu.Menuitem this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, "Sonnamble"); this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, "Nocturne"); this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, "Seven Months in E minor"); - this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE, ""); + this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, "/home/ronoc/Desktop/Sonnamble/Sonnamble_CD.jpg"); } public override void handle_event(string name, GLib.Value input_value, uint timestamp) diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 5e20f15..b414969 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -26,10 +26,6 @@ with this program. If not, see . #include "common-defs.h" #include -// TODO: think about leakage: ted ! - - - static DbusmenuMenuitem* twin_item; typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; @@ -37,6 +33,8 @@ typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; struct _MetadataWidgetPrivate { GtkWidget* hbox; + GtkWidget* album_art; + gchar* our_path; }; #define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate)) @@ -90,7 +88,16 @@ metadata_widget_init (MetadataWidget *self) hbox = gtk_hbox_new(TRUE, 2); - g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(metadata_widget_update_state), self); + const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH); + + g_debug("MetadataWidget:init - path = %s", path); + + priv->our_path = g_strdup(path); + + priv->album_art = gtk_image_new_from_file(priv->our_path); + + g_signal_connect(G_OBJECT(twin_item), "property-changed", + G_CALLBACK(metadata_widget_update_state), self); gtk_widget_show_all (priv->hbox); gtk_container_add (GTK_CONTAINER (self), hbox); @@ -100,10 +107,6 @@ metadata_widget_init (MetadataWidget *self) static void metadata_widget_dispose (GObject *object) { - //if(IS_METADATA_WIDGET(object) == TRUE){ - // MetadataWidget * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object)); - // g_object_unref(priv->previous_button); - //} G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object); } @@ -134,36 +137,12 @@ metadata_widget_button_release_event (GtkWidget *menuitem, //TODO figure out why the userdata is not what I expect it to be. static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata) { - //MetadataWidget* bar = (MetadataWidget*)userdata; - // TODO problem line - //if(IS_METADATA_WIDGET(bar)){ - //g_debug("after line 1!!"); - - //MetadataWidget *priv = METADATA_WIDGET_GET_PRIVATE(bar); - //g_debug("after line 2!!"); - //gchar* label = "changed"; - //g_debug("after line 3!!"); - //gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); - //} - //if(GTK_IS_BUTTON(GTK_BUTTON(priv->play_button))){ - - // gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); - // g_debug("its a button"); - //} - //else{ - //g_debug("No Goddamn button!!"); - //} - //} g_debug("metadata_widget_update_state - with property %s", property); if (value == NULL){ g_debug("value is null"); return; } - // TODO problem line - //gchar* input = g_strdup(g_value_get_string(value)); - //g_debug("metadata_widget_update_state - with value %s", input); - } /** diff --git a/src/metadata-widget.c~ b/src/metadata-widget.c~ index 39a42db..81c6f75 100644 --- a/src/metadata-widget.c~ +++ b/src/metadata-widget.c~ @@ -26,10 +26,6 @@ with this program. If not, see . #include "common-defs.h" #include -// TODO: think about leakage: ted ! - - - static DbusmenuMenuitem* twin_item; typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; @@ -37,6 +33,8 @@ typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; struct _MetadataWidgetPrivate { GtkWidget* hbox; + GtkWidget* album_art; + gchar* our_path; }; #define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate)) @@ -70,7 +68,7 @@ metadata_widget_class_init (MetadataWidgetClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - widget_class->button_press_event = metadata_widget_press_event; + widget_class->button_press_event = metadata_widget_button_press_event; widget_class->button_release_event = metadata_widget_button_release_event; g_type_class_add_private (klass, sizeof (MetadataWidgetPrivate)); @@ -90,7 +88,16 @@ metadata_widget_init (MetadataWidget *self) hbox = gtk_hbox_new(TRUE, 2); - g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(metadata_widget_update_state), self); + const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE); + + g_debug("MetadataWidget:init - path = %s", path); + + priv->our_path = g_strdup(path); + + priv->album_art = gtk_image_new_from_file(priv->our_path); + + g_signal_connect(G_OBJECT(twin_item), "property-changed", + G_CALLBACK(metadata_widget_update_state), self); gtk_widget_show_all (priv->hbox); gtk_container_add (GTK_CONTAINER (self), hbox); @@ -100,10 +107,6 @@ metadata_widget_init (MetadataWidget *self) static void metadata_widget_dispose (GObject *object) { - //if(IS_METADATA_WIDGET(object) == TRUE){ - // MetadataWidget * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object)); - // g_object_unref(priv->previous_button); - //} G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object); } @@ -134,36 +137,12 @@ metadata_widget_button_release_event (GtkWidget *menuitem, //TODO figure out why the userdata is not what I expect it to be. static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata) { - //MetadataWidget* bar = (MetadataWidget*)userdata; - // TODO problem line - //if(IS_METADATA_WIDGET(bar)){ - //g_debug("after line 1!!"); - - //MetadataWidget *priv = METADATA_WIDGET_GET_PRIVATE(bar); - //g_debug("after line 2!!"); - //gchar* label = "changed"; - //g_debug("after line 3!!"); - //gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); - //} - //if(GTK_IS_BUTTON(GTK_BUTTON(priv->play_button))){ - - // gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label)); - // g_debug("its a button"); - //} - //else{ - //g_debug("No Goddamn button!!"); - //} - //} g_debug("metadata_widget_update_state - with property %s", property); if (value == NULL){ g_debug("value is null"); return; } - // TODO problem line - //gchar* input = g_strdup(g_value_get_string(value)); - //g_debug("metadata_widget_update_state - with value %s", input); - } /** diff --git a/src/player-controller.vala b/src/player-controller.vala index 26ad1ff..dcb428b 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -34,7 +34,7 @@ public class PlayerController : GLib.Object // Title item Dbusmenu.Menuitem title_item = new Dbusmenu.Menuitem(); - title_item.property_set(MENUITEM_PROP_LABEL, this.name.concat("")); + title_item.property_set(MENUITEM_PROP_LABEL, this.name); title_item.property_set(MENUITEM_PROP_ICON_NAME, "applications-multimedia"); this.custom_items.add(title_item); -- cgit v1.2.3 From 11741257873bf35670e2503184821e2bd075c9f6 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 14 Jun 2010 11:07:28 +0100 Subject: properties working now both ways --- src/indicator-sound.c | 32 ++++++++++++++++++++++++++++++-- src/metadata-menu-item.vala | 3 +++ src/metadata-widget.c | 5 ----- src/metadata-widget.c~ | 9 ++------- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index a3856c4..af2a6f9 100755 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -39,6 +39,7 @@ with this program. If not, see . #include "indicator-sound.h" #include "transport-bar.h" +#include "metadata-widget.h" #include "dbus-shared-names.h" #include "sound-service-client.h" #include "common-defs.h" @@ -92,8 +93,9 @@ static void slider_grabbed(GtkWidget *widget, gpointer user_data); static void slider_released(GtkWidget *widget, gpointer user_data); static void style_changed_cb(GtkWidget *widget, gpointer user_data); -//transport bar related +//player widgets related static gboolean new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); +static gboolean new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); // DBUS communication static DBusGProxy *sound_dbus_proxy = NULL; @@ -240,6 +242,7 @@ get_menu (IndicatorObject * io) g_object_set_data (G_OBJECT (client), "indicator", io); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TRANSPORT_MENUITEM_TYPE, new_transport_bar); + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget); // register Key-press listening on the menu widget as the slider does not allow this. g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), NULL); @@ -310,7 +313,8 @@ new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuC return TRUE; } -static gboolean new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +static gboolean +new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { g_debug("indicator-sound: new_transport_bar() called "); @@ -329,6 +333,30 @@ static gboolean new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * return TRUE; } +static gboolean +new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + g_debug("indicator-sound: new_metadata_widget"); + + GtkWidget* metadata = NULL; + + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); + g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + + metadata = metadata_widget_new (newitem); + GtkMenuItem *menu_metadata_widget = GTK_MENU_ITEM(metadata); + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_metadata_widget, parent); + + gtk_widget_show_all(metadata); + + return TRUE; +} + +//const gchar* path = dbusmenu_menuitem_property_get(new_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH); + +//g_debug("New transport bar path = %s", path); + static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata) diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index c9daee6..ef72143 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -17,6 +17,9 @@ public class MetadataMenuitem : Dbusmenu.Menuitem this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, "Nocturne"); this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, "Seven Months in E minor"); this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, "/home/ronoc/Desktop/Sonnamble/Sonnamble_CD.jpg"); + + debug("image_path property set %s:", this.property_get(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH)); + } public override void handle_event(string name, GLib.Value input_value, uint timestamp) diff --git a/src/metadata-widget.c b/src/metadata-widget.c index b414969..70542e9 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -138,11 +138,6 @@ metadata_widget_button_release_event (GtkWidget *menuitem, static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata) { g_debug("metadata_widget_update_state - with property %s", property); - - if (value == NULL){ - g_debug("value is null"); - return; - } } /** diff --git a/src/metadata-widget.c~ b/src/metadata-widget.c~ index 81c6f75..df58de5 100644 --- a/src/metadata-widget.c~ +++ b/src/metadata-widget.c~ @@ -88,9 +88,9 @@ metadata_widget_init (MetadataWidget *self) hbox = gtk_hbox_new(TRUE, 2); - const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE); + //const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH); - g_debug("MetadataWidget:init - path = %s", path); + //g_debug("MetadataWidget:init - path = %s", path); priv->our_path = g_strdup(path); @@ -138,11 +138,6 @@ metadata_widget_button_release_event (GtkWidget *menuitem, static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata) { g_debug("metadata_widget_update_state - with property %s", property); - - if (value == NULL){ - g_debug("value is null"); - return; - } } /** -- cgit v1.2.3 From b5684bb4f3480c59d63a02b5f658382d7b0e52a7 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 14 Jun 2010 19:48:11 +0100 Subject: rename of transport-bar --- src/Makefile.am | 4 +-- src/indicator-sound.c | 6 ++-- src/metadata-widget.c | 52 ++++++++++++++++++++-------- src/metadata-widget.c~ | 57 ++++++++++++++++++++++--------- src/transport-bar.c | 92 +++++++++++++++++++++++++------------------------- src/transport-bar.h | 28 +++++++-------- 6 files changed, 144 insertions(+), 95 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index b28903b..2a19c3d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,8 +9,8 @@ soundmenulib_LTLIBRARIES = libsoundmenu.la libsoundmenu_la_SOURCES = \ common-defs.h \ indicator-sound.h \ - transport-bar.c \ - transport-bar.h \ + transport-widget.c \ + transport-widget.h \ metadata-widget.c \ metadata-widget.h \ indicator-sound.c \ diff --git a/src/indicator-sound.c b/src/indicator-sound.c index af2a6f9..ebafd9a 100755 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -38,7 +38,7 @@ with this program. If not, see . #include #include "indicator-sound.h" -#include "transport-bar.h" +#include "transport-widget.h" #include "metadata-widget.h" #include "dbus-shared-names.h" #include "sound-service-client.h" @@ -314,7 +314,7 @@ new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuC } static gboolean -new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { g_debug("indicator-sound: new_transport_bar() called "); @@ -323,7 +323,7 @@ new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmen g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - bar = transport_bar_new(newitem); + bar = transport_widget_new(newitem); GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_transport_bar, parent); diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 70542e9..a451ad7 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -34,7 +34,10 @@ struct _MetadataWidgetPrivate { GtkWidget* hbox; GtkWidget* album_art; - gchar* our_path; + gchar* our_path; + GtkWidget* artist_label; + GtkWidget* piece_label; + GtkWidget* container_label; }; #define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate)) @@ -49,13 +52,11 @@ static gboolean metadata_widget_button_press_event (GtkWidget *menuitem, GdkEventButton *event); static gboolean metadata_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event); - - -// Dbusmenuitem update callback +// Dbusmenuitem properties update callback static void metadata_widget_update_state(gchar * property, GValue * value, gpointer userdata); - +//static void update_content( G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); @@ -84,22 +85,47 @@ metadata_widget_init (MetadataWidget *self) g_debug("MetadataWidget::metadata_widget_init"); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); - GtkWidget *hbox; - hbox = gtk_hbox_new(TRUE, 2); + GtkWidget *hbox; + hbox = gtk_hbox_new(TRUE, 0); + priv->hbox = hbox; + + // image const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH); - g_debug("MetadataWidget:init - path = %s", path); - priv->our_path = g_strdup(path); + GdkPixbuf* pixbuf; + pixbuf=gdk_pixbuf_new_from_file(path, NULL); + pixbuf=gdk_pixbuf_scale_simple(pixbuf,60,60,GDK_INTERP_BILINEAR); + priv->album_art = gtk_image_new_from_pixbuf(pixbuf); + g_object_unref(pixbuf); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0); + GtkWidget* vbox = gtk_vbox_new(TRUE, 0); + + // artist + GtkWidget* artist; + artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST)); + priv->artist_label = artist; + gtk_box_pack_start (GTK_BOX (vbox), priv->artist_label, FALSE, FALSE, 0); + + // piece + GtkWidget* piece; + piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_PIECE)); + priv->piece_label = piece; + gtk_box_pack_start (GTK_BOX (vbox), priv->piece_label, FALSE, FALSE, 0); - priv->album_art = gtk_image_new_from_file(priv->our_path); + // container + GtkWidget* container; + container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER)); + priv->container_label = container; + gtk_box_pack_start (GTK_BOX (vbox), priv->container_label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), vbox, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(metadata_widget_update_state), self); - - gtk_widget_show_all (priv->hbox); + gtk_widget_show_all (priv->hbox); gtk_container_add (GTK_CONTAINER (self), hbox); } @@ -133,8 +159,6 @@ metadata_widget_button_release_event (GtkWidget *menuitem, return TRUE; } - -//TODO figure out why the userdata is not what I expect it to be. static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata) { g_debug("metadata_widget_update_state - with property %s", property); diff --git a/src/metadata-widget.c~ b/src/metadata-widget.c~ index df58de5..add3c36 100644 --- a/src/metadata-widget.c~ +++ b/src/metadata-widget.c~ @@ -34,7 +34,10 @@ struct _MetadataWidgetPrivate { GtkWidget* hbox; GtkWidget* album_art; - gchar* our_path; + gchar* our_path; + GtkWidget* artist_label; + GtkWidget* piece_label; + GtkWidget* container_label; }; #define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate)) @@ -49,13 +52,11 @@ static gboolean metadata_widget_button_press_event (GtkWidget *menuitem, GdkEventButton *event); static gboolean metadata_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event); - - -// Dbusmenuitem update callback +// Dbusmenuitem properties update callback static void metadata_widget_update_state(gchar * property, GValue * value, gpointer userdata); - +//static void update_content( G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); @@ -84,22 +85,48 @@ metadata_widget_init (MetadataWidget *self) g_debug("MetadataWidget::metadata_widget_init"); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); - GtkWidget *hbox; - hbox = gtk_hbox_new(TRUE, 2); - - //const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH); - - //g_debug("MetadataWidget:init - path = %s", path); + GtkWidget *hbox; + hbox = gtk_hbox_new(TRUE, 0); + priv->hbox = hbox; + + // image + const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH); + g_debug("MetadataWidget:init - path = %s", path); priv->our_path = g_strdup(path); + GdkPixbuf* pixbuf; + pixbuf=gdk_pixbuf_new_from_file(path, NULL); + pixbuf=gdk_pixbuf_scale_simple(pixbuf,60,60,GDK_INTERP_BILINEAR); + priv->album_art = gtk_image_new_from_pixbuf(pixbuf); + g_object_unref(pixbuf); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0); + GtkWidget* vbox = gtk_vbox_new(TRUE, 0); + + // artist + GtkWidget* artist; + artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST)); + priv->artist_label = artist; + gtk_box_pack_start (GTK_BOX (vbox), priv->artist_label, FALSE, FALSE, 0); + + + // piece + GtkWidget* piece; + piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_PIECE)); + priv->piece_label = piece; + gtk_box_pack_start (GTK_BOX (vbox), priv->piece_label, FALSE, FALSE, 0); - priv->album_art = gtk_image_new_from_file(priv->our_path); + // container + GtkWidget* container; + container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER)); + priv->container_label = container; + gtk_box_pack_start (GTK_BOX (vbox), priv->container_label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), vbox, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(metadata_widget_update_state), self); - - gtk_widget_show_all (priv->hbox); + gtk_widget_show_all (priv->hbox); gtk_container_add (GTK_CONTAINER (self), hbox); } @@ -133,8 +160,6 @@ metadata_widget_button_release_event (GtkWidget *menuitem, return TRUE; } - -//TODO figure out why the userdata is not what I expect it to be. static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata) { g_debug("metadata_widget_update_state - with property %s", property); diff --git a/src/transport-bar.c b/src/transport-bar.c index 96ae287..bc2ee40 100644 --- a/src/transport-bar.c +++ b/src/transport-bar.c @@ -30,9 +30,9 @@ with this program. If not, see . static DbusmenuMenuitem* twin_item; -typedef struct _TransportBarPrivate TransportBarPrivate; +typedef struct _TransportWidgetPrivate TransportWidgetPrivate; -struct _TransportBarPrivate +struct _TransportWidgetPrivate { GtkWidget* hbox; GtkWidget* previous_button; @@ -50,46 +50,46 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -#define TRANSPORT_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_BAR_TYPE, TransportBarPrivate)) +#define TRANSPORT_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_WIDGET_TYPE, TransportWidgetPrivate)) /* Gobject boiler plate */ -static void transport_bar_class_init (TransportBarClass *klass); -static void transport_bar_init (TransportBar *self); -static void transport_bar_dispose (GObject *object); -static void transport_bar_finalize (GObject *object); +static void transport_widget_class_init (TransportWidgetClass *klass); +static void transport_widget_init (TransportWidget *self); +static void transport_widget_dispose (GObject *object); +static void transport_widget_finalize (GObject *object); /* UI and dbus callbacks */ -static gboolean transport_bar_button_press_event (GtkWidget *menuitem, +static gboolean transport_widget_button_press_event (GtkWidget *menuitem, GdkEventButton *event); -static gboolean transport_bar_button_release_event (GtkWidget *menuitem, +static gboolean transport_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event); -static gboolean transport_bar_play_button_trigger (GtkWidget *widget, +static gboolean transport_widget_play_button_trigger (GtkWidget *widget, GdkEventButton *event, gpointer user_data); -static void transport_bar_update_state(DbusmenuMenuitem* item, +static void transport_widget_update_state(DbusmenuMenuitem* item, gchar * property, GValue * value, gpointer userdata); // utility methods -static gchar* transport_bar_determine_play_label(gchar* state); +static gchar* transport_widget_determine_play_label(gchar* state); -G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM); +G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM); static void -transport_bar_class_init (TransportBarClass *klass) +transport_widget_class_init (TransportWidgetClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - widget_class->button_press_event = transport_bar_button_press_event; - widget_class->button_release_event = transport_bar_button_release_event; + widget_class->button_press_event = transport_widget_button_press_event; + widget_class->button_release_event = transport_widget_button_release_event; - g_type_class_add_private (klass, sizeof (TransportBarPrivate)); + g_type_class_add_private (klass, sizeof (TransportWidgetPrivate)); - gobject_class->dispose = transport_bar_dispose; - gobject_class->finalize = transport_bar_finalize; + gobject_class->dispose = transport_widget_dispose; + gobject_class->finalize = transport_widget_finalize; signals[PLAY] = g_signal_new ("play", G_OBJECT_CLASS_TYPE (gobject_class), @@ -126,11 +126,11 @@ transport_bar_class_init (TransportBarClass *klass) } static void -transport_bar_init (TransportBar *self) +transport_widget_init (TransportWidget *self) { - g_debug("TransportBar::transport_bar_init"); + g_debug("TransportWidget::transport_widget_init"); - TransportBarPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(self); + TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(self); GtkWidget *hbox; hbox = gtk_hbox_new(TRUE, 2); @@ -142,10 +142,10 @@ transport_bar_init (TransportBar *self) gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, FALSE, 0); - g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_bar_play_button_trigger), NULL); + g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_widget_play_button_trigger), NULL); priv->hbox = hbox; - g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_bar_update_state), self); + g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_update_state), self); gtk_widget_show_all (priv->hbox); gtk_container_add (GTK_CONTAINER (self), hbox); @@ -153,67 +153,67 @@ transport_bar_init (TransportBar *self) } static void -transport_bar_dispose (GObject *object) +transport_widget_dispose (GObject *object) { //if(IS_TRANSPORT_BAR(object) == TRUE){ - // TransportBarPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(TRANSPORT_BAR(object)); + // TransportWidgetPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(TRANSPORT_BAR(object)); // g_object_unref(priv->previous_button); //} - G_OBJECT_CLASS (transport_bar_parent_class)->dispose (object); + G_OBJECT_CLASS (transport_widget_parent_class)->dispose (object); } static void -transport_bar_finalize (GObject *object) +transport_widget_finalize (GObject *object) { - G_OBJECT_CLASS (transport_bar_parent_class)->finalize (object); + G_OBJECT_CLASS (transport_widget_parent_class)->finalize (object); } /* keyevents */ static gboolean -transport_bar_button_press_event (GtkWidget *menuitem, +transport_widget_button_press_event (GtkWidget *menuitem, GdkEventButton *event) { - g_debug("TransportBar::menu_press_event"); + g_debug("TransportWidget::menu_press_event"); return FALSE; } static gboolean -transport_bar_button_release_event (GtkWidget *menuitem, +transport_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event) { - g_debug("TransportBar::menu_release_event"); + g_debug("TransportWidget::menu_release_event"); return FALSE; } /* Individual keyevents on the buttons */ static gboolean -transport_bar_play_button_trigger(GtkWidget* widget, +transport_widget_play_button_trigger(GtkWidget* widget, GdkEventButton *event, gpointer user_data) { - g_debug("TransportBar::PLAY button_press_event"); + g_debug("TransportWidget::PLAY button_press_event"); return FALSE; } /** -* transport_bar_update_state() +* transport_widget_update_state() * Callback for updates from the other side of dbus **/ -static void transport_bar_update_state(DbusmenuMenuitem* item, gchar* property, +static void transport_widget_update_state(DbusmenuMenuitem* item, gchar* property, GValue* value, gpointer userdata) { - g_debug("transport_bar_update_state - with property %s", property); + g_debug("transport_widget_update_state - with property %s", property); gchar* input = g_strdup(g_value_get_string(value)); - g_debug("transport_bar_update_state - with value %s", input); + g_debug("transport_widget_update_state - with value %s", input); - TransportBar* bar = (TransportBar*)userdata; - TransportBarPrivate *priv = TRANSPORT_BAR_GET_PRIVATE(bar); + TransportWidget* bar = (TransportWidget*)userdata; + TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar); - gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_bar_determine_play_label(property))); + gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_determine_play_label(property))); } // will be needed for image swapping -static gchar* transport_bar_determine_play_label(gchar* state) +static gchar* transport_widget_determine_play_label(gchar* state) { gchar* label = ">"; if(g_strcmp0(state, "pause") == 0){ @@ -227,12 +227,12 @@ static gchar* transport_bar_determine_play_label(gchar* state) /** * transport_new: - * @returns: a new #TransportBar. + * @returns: a new #TransportWidget. **/ GtkWidget* -transport_bar_new(DbusmenuMenuitem *item) +transport_widget_new(DbusmenuMenuitem *item) { twin_item = item; - return g_object_new(TRANSPORT_BAR_TYPE, NULL); + return g_object_new(TRANSPORT_WIDGET_TYPE, NULL); } diff --git a/src/transport-bar.h b/src/transport-bar.h index 8a791ff..1d1aa6e 100644 --- a/src/transport-bar.h +++ b/src/transport-bar.h @@ -16,34 +16,34 @@ PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef __TRANSPORT_BAR_H__ -#define __TRANSPORT_BAR_H__ +#ifndef __TRANSPORT_WIDGET_H__ +#define __TRANSPORT_WIDGET_H__ #include #include G_BEGIN_DECLS -#define TRANSPORT_BAR_TYPE (transport_bar_get_type ()) -#define TRANSPORT_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRANSPORT_BAR_TYPE, TransportBar)) -#define TRANSPORT_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRANSPORT_BAR_TYPE, TransportBarClass)) -#define IS_TRANSPORT_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRANSPORT_BAR_TYPE)) -#define IS_TRANSPORT_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRANSPORT_BAR_TYPE)) -#define TRANSPORT_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRANSPORT_BAR_TYPE, TransportBarClass)) +#define TRANSPORT_WIDGET_TYPE (transport_widget_get_type ()) +#define TRANSPORT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRANSPORT_WIDGET_TYPE, TransportWidget)) +#define TRANSPORT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRANSPORT_WIDGET_TYPE, TransportWidgetClass)) +#define IS_TRANSPORT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRANSPORT_WIDGET_TYPE)) +#define IS_TRANSPORT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRANSPORT_WIDGET_TYPE)) +#define TRANSPORT_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRANSPORT_WIDGET_TYPE, TransportWidgetClass)) -typedef struct _TransportBar TransportBar; -typedef struct _TransportBarClass TransportBarClass; +typedef struct _TransportWidget TransportWidget; +typedef struct _TransportWidgetClass TransportWidgetClass; -struct _TransportBarClass { +struct _TransportWidgetClass { GtkMenuItemClass parent_class; }; -struct _TransportBar { +struct _TransportWidget { GtkMenuItem parent; }; -GType transport_bar_get_type (void); -GtkWidget* transport_bar_new(DbusmenuMenuitem *twin_item); +GType transport_widget_get_type (void); +GtkWidget* transport_widget_new(DbusmenuMenuitem *twin_item); G_END_DECLS -- cgit v1.2.3 From 5e806e9c5f16751a39a9d943c9483754ba73884a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 14 Jun 2010 19:48:52 +0100 Subject: and the actual rename --- src/transport-bar.c | 238 ------------------------------------------------- src/transport-bar.h | 51 ----------- src/transport-widget.c | 238 +++++++++++++++++++++++++++++++++++++++++++++++++ src/transport-widget.h | 51 +++++++++++ 4 files changed, 289 insertions(+), 289 deletions(-) delete mode 100644 src/transport-bar.c delete mode 100644 src/transport-bar.h create mode 100644 src/transport-widget.c create mode 100644 src/transport-widget.h diff --git a/src/transport-bar.c b/src/transport-bar.c deleted file mode 100644 index bc2ee40..0000000 --- a/src/transport-bar.c +++ /dev/null @@ -1,238 +0,0 @@ -/* -Copyright 2010 Canonical Ltd. - -Authors: - Conor Curran - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "transport-bar.h" -#include "common-defs.h" -#include - -// TODO: think about leakage: ted ! - -static DbusmenuMenuitem* twin_item; - -typedef struct _TransportWidgetPrivate TransportWidgetPrivate; - -struct _TransportWidgetPrivate -{ - GtkWidget* hbox; - GtkWidget* previous_button; - GtkWidget* play_button; - GtkWidget* next_button; -}; - -enum { - PLAY, - PAUSE, - NEXT, - PREVIOUS, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -#define TRANSPORT_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_WIDGET_TYPE, TransportWidgetPrivate)) - -/* Gobject boiler plate */ -static void transport_widget_class_init (TransportWidgetClass *klass); -static void transport_widget_init (TransportWidget *self); -static void transport_widget_dispose (GObject *object); -static void transport_widget_finalize (GObject *object); - -/* UI and dbus callbacks */ -static gboolean transport_widget_button_press_event (GtkWidget *menuitem, - GdkEventButton *event); -static gboolean transport_widget_button_release_event (GtkWidget *menuitem, - GdkEventButton *event); -static gboolean transport_widget_play_button_trigger (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); -static void transport_widget_update_state(DbusmenuMenuitem* item, - gchar * property, - GValue * value, - gpointer userdata); -// utility methods -static gchar* transport_widget_determine_play_label(gchar* state); - -G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM); - - - -static void -transport_widget_class_init (TransportWidgetClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - widget_class->button_press_event = transport_widget_button_press_event; - widget_class->button_release_event = transport_widget_button_release_event; - - g_type_class_add_private (klass, sizeof (TransportWidgetPrivate)); - - gobject_class->dispose = transport_widget_dispose; - gobject_class->finalize = transport_widget_finalize; - - signals[PLAY] = g_signal_new ("play", - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - signals[PAUSE] = g_signal_new ("pause", - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - - signals[NEXT] = g_signal_new ("next", - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - signals[PREVIOUS] = g_signal_new ("previous", - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -transport_widget_init (TransportWidget *self) -{ - g_debug("TransportWidget::transport_widget_init"); - - TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(self); - GtkWidget *hbox; - - hbox = gtk_hbox_new(TRUE, 2); - priv->previous_button = gtk_button_new_with_label("<<"); - priv->next_button = gtk_button_new_with_label(">>"); - priv->play_button = gtk_button_new_with_label(">"); - - gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, FALSE, 0); - - g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_widget_play_button_trigger), NULL); - priv->hbox = hbox; - - g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_update_state), self); - - gtk_widget_show_all (priv->hbox); - gtk_container_add (GTK_CONTAINER (self), hbox); - -} - -static void -transport_widget_dispose (GObject *object) -{ - //if(IS_TRANSPORT_BAR(object) == TRUE){ - // TransportWidgetPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(TRANSPORT_BAR(object)); - // g_object_unref(priv->previous_button); - //} - G_OBJECT_CLASS (transport_widget_parent_class)->dispose (object); -} - -static void -transport_widget_finalize (GObject *object) -{ - G_OBJECT_CLASS (transport_widget_parent_class)->finalize (object); -} - -/* keyevents */ -static gboolean -transport_widget_button_press_event (GtkWidget *menuitem, - GdkEventButton *event) -{ - g_debug("TransportWidget::menu_press_event"); - return FALSE; -} - -static gboolean -transport_widget_button_release_event (GtkWidget *menuitem, - GdkEventButton *event) -{ - g_debug("TransportWidget::menu_release_event"); - return FALSE; -} - -/* Individual keyevents on the buttons */ -static gboolean -transport_widget_play_button_trigger(GtkWidget* widget, - GdkEventButton *event, - gpointer user_data) -{ - g_debug("TransportWidget::PLAY button_press_event"); - return FALSE; -} - -/** -* transport_widget_update_state() -* Callback for updates from the other side of dbus -**/ -static void transport_widget_update_state(DbusmenuMenuitem* item, gchar* property, - GValue* value, gpointer userdata) -{ - g_debug("transport_widget_update_state - with property %s", property); - gchar* input = g_strdup(g_value_get_string(value)); - g_debug("transport_widget_update_state - with value %s", input); - - TransportWidget* bar = (TransportWidget*)userdata; - TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar); - - gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_determine_play_label(property))); -} - -// will be needed for image swapping -static gchar* transport_widget_determine_play_label(gchar* state) -{ - gchar* label = ">"; - if(g_strcmp0(state, "pause") == 0){ - label = "||"; - } - else if(g_strcmp0(state, "play") == 0){ - label = ">"; - } - return label; -} - - /** - * transport_new: - * @returns: a new #TransportWidget. - **/ -GtkWidget* -transport_widget_new(DbusmenuMenuitem *item) -{ - twin_item = item; - return g_object_new(TRANSPORT_WIDGET_TYPE, NULL); -} - diff --git a/src/transport-bar.h b/src/transport-bar.h deleted file mode 100644 index 1d1aa6e..0000000 --- a/src/transport-bar.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2010 Canonical Ltd. - -Authors: - Conor Curran - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ -#ifndef __TRANSPORT_WIDGET_H__ -#define __TRANSPORT_WIDGET_H__ - -#include -#include - -G_BEGIN_DECLS - -#define TRANSPORT_WIDGET_TYPE (transport_widget_get_type ()) -#define TRANSPORT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRANSPORT_WIDGET_TYPE, TransportWidget)) -#define TRANSPORT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRANSPORT_WIDGET_TYPE, TransportWidgetClass)) -#define IS_TRANSPORT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRANSPORT_WIDGET_TYPE)) -#define IS_TRANSPORT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRANSPORT_WIDGET_TYPE)) -#define TRANSPORT_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRANSPORT_WIDGET_TYPE, TransportWidgetClass)) - -typedef struct _TransportWidget TransportWidget; -typedef struct _TransportWidgetClass TransportWidgetClass; - -struct _TransportWidgetClass { - GtkMenuItemClass parent_class; -}; - -struct _TransportWidget { - GtkMenuItem parent; -}; - -GType transport_widget_get_type (void); -GtkWidget* transport_widget_new(DbusmenuMenuitem *twin_item); - -G_END_DECLS - -#endif - diff --git a/src/transport-widget.c b/src/transport-widget.c new file mode 100644 index 0000000..bc2ee40 --- /dev/null +++ b/src/transport-widget.c @@ -0,0 +1,238 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "transport-bar.h" +#include "common-defs.h" +#include + +// TODO: think about leakage: ted ! + +static DbusmenuMenuitem* twin_item; + +typedef struct _TransportWidgetPrivate TransportWidgetPrivate; + +struct _TransportWidgetPrivate +{ + GtkWidget* hbox; + GtkWidget* previous_button; + GtkWidget* play_button; + GtkWidget* next_button; +}; + +enum { + PLAY, + PAUSE, + NEXT, + PREVIOUS, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +#define TRANSPORT_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_WIDGET_TYPE, TransportWidgetPrivate)) + +/* Gobject boiler plate */ +static void transport_widget_class_init (TransportWidgetClass *klass); +static void transport_widget_init (TransportWidget *self); +static void transport_widget_dispose (GObject *object); +static void transport_widget_finalize (GObject *object); + +/* UI and dbus callbacks */ +static gboolean transport_widget_button_press_event (GtkWidget *menuitem, + GdkEventButton *event); +static gboolean transport_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event); +static gboolean transport_widget_play_button_trigger (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); +static void transport_widget_update_state(DbusmenuMenuitem* item, + gchar * property, + GValue * value, + gpointer userdata); +// utility methods +static gchar* transport_widget_determine_play_label(gchar* state); + +G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM); + + + +static void +transport_widget_class_init (TransportWidgetClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->button_press_event = transport_widget_button_press_event; + widget_class->button_release_event = transport_widget_button_release_event; + + g_type_class_add_private (klass, sizeof (TransportWidgetPrivate)); + + gobject_class->dispose = transport_widget_dispose; + gobject_class->finalize = transport_widget_finalize; + + signals[PLAY] = g_signal_new ("play", + G_OBJECT_CLASS_TYPE (gobject_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[PAUSE] = g_signal_new ("pause", + G_OBJECT_CLASS_TYPE (gobject_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + + signals[NEXT] = g_signal_new ("next", + G_OBJECT_CLASS_TYPE (gobject_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[PREVIOUS] = g_signal_new ("previous", + G_OBJECT_CLASS_TYPE (gobject_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); +} + +static void +transport_widget_init (TransportWidget *self) +{ + g_debug("TransportWidget::transport_widget_init"); + + TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(self); + GtkWidget *hbox; + + hbox = gtk_hbox_new(TRUE, 2); + priv->previous_button = gtk_button_new_with_label("<<"); + priv->next_button = gtk_button_new_with_label(">>"); + priv->play_button = gtk_button_new_with_label(">"); + + gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, FALSE, 0); + + g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_widget_play_button_trigger), NULL); + priv->hbox = hbox; + + g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_update_state), self); + + gtk_widget_show_all (priv->hbox); + gtk_container_add (GTK_CONTAINER (self), hbox); + +} + +static void +transport_widget_dispose (GObject *object) +{ + //if(IS_TRANSPORT_BAR(object) == TRUE){ + // TransportWidgetPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(TRANSPORT_BAR(object)); + // g_object_unref(priv->previous_button); + //} + G_OBJECT_CLASS (transport_widget_parent_class)->dispose (object); +} + +static void +transport_widget_finalize (GObject *object) +{ + G_OBJECT_CLASS (transport_widget_parent_class)->finalize (object); +} + +/* keyevents */ +static gboolean +transport_widget_button_press_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + g_debug("TransportWidget::menu_press_event"); + return FALSE; +} + +static gboolean +transport_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + g_debug("TransportWidget::menu_release_event"); + return FALSE; +} + +/* Individual keyevents on the buttons */ +static gboolean +transport_widget_play_button_trigger(GtkWidget* widget, + GdkEventButton *event, + gpointer user_data) +{ + g_debug("TransportWidget::PLAY button_press_event"); + return FALSE; +} + +/** +* transport_widget_update_state() +* Callback for updates from the other side of dbus +**/ +static void transport_widget_update_state(DbusmenuMenuitem* item, gchar* property, + GValue* value, gpointer userdata) +{ + g_debug("transport_widget_update_state - with property %s", property); + gchar* input = g_strdup(g_value_get_string(value)); + g_debug("transport_widget_update_state - with value %s", input); + + TransportWidget* bar = (TransportWidget*)userdata; + TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar); + + gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_determine_play_label(property))); +} + +// will be needed for image swapping +static gchar* transport_widget_determine_play_label(gchar* state) +{ + gchar* label = ">"; + if(g_strcmp0(state, "pause") == 0){ + label = "||"; + } + else if(g_strcmp0(state, "play") == 0){ + label = ">"; + } + return label; +} + + /** + * transport_new: + * @returns: a new #TransportWidget. + **/ +GtkWidget* +transport_widget_new(DbusmenuMenuitem *item) +{ + twin_item = item; + return g_object_new(TRANSPORT_WIDGET_TYPE, NULL); +} + diff --git a/src/transport-widget.h b/src/transport-widget.h new file mode 100644 index 0000000..1d1aa6e --- /dev/null +++ b/src/transport-widget.h @@ -0,0 +1,51 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ +#ifndef __TRANSPORT_WIDGET_H__ +#define __TRANSPORT_WIDGET_H__ + +#include +#include + +G_BEGIN_DECLS + +#define TRANSPORT_WIDGET_TYPE (transport_widget_get_type ()) +#define TRANSPORT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRANSPORT_WIDGET_TYPE, TransportWidget)) +#define TRANSPORT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRANSPORT_WIDGET_TYPE, TransportWidgetClass)) +#define IS_TRANSPORT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRANSPORT_WIDGET_TYPE)) +#define IS_TRANSPORT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRANSPORT_WIDGET_TYPE)) +#define TRANSPORT_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRANSPORT_WIDGET_TYPE, TransportWidgetClass)) + +typedef struct _TransportWidget TransportWidget; +typedef struct _TransportWidgetClass TransportWidgetClass; + +struct _TransportWidgetClass { + GtkMenuItemClass parent_class; +}; + +struct _TransportWidget { + GtkMenuItem parent; +}; + +GType transport_widget_get_type (void); +GtkWidget* transport_widget_new(DbusmenuMenuitem *twin_item); + +G_END_DECLS + +#endif + -- cgit v1.2.3 From ede4ad390ac3d4282a4a99a58d6f398e42169ba4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 14 Jun 2010 19:49:51 +0100 Subject: and the actual rename --- src/metadata-widget.c~ | 178 ------------------------------------------------- src/metadata-widget.h~ | 51 -------------- 2 files changed, 229 deletions(-) delete mode 100644 src/metadata-widget.c~ delete mode 100644 src/metadata-widget.h~ diff --git a/src/metadata-widget.c~ b/src/metadata-widget.c~ deleted file mode 100644 index add3c36..0000000 --- a/src/metadata-widget.c~ +++ /dev/null @@ -1,178 +0,0 @@ -/* -Copyright 2010 Canonical Ltd. - -Authors: - Conor Curran - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "metadata-widget.h" -#include "common-defs.h" -#include - -static DbusmenuMenuitem* twin_item; - -typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; - -struct _MetadataWidgetPrivate -{ - GtkWidget* hbox; - GtkWidget* album_art; - gchar* our_path; - GtkWidget* artist_label; - GtkWidget* piece_label; - GtkWidget* container_label; -}; - -#define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate)) - -/* Prototypes */ -static void metadata_widget_class_init (MetadataWidgetClass *klass); -static void metadata_widget_init (MetadataWidget *self); -static void metadata_widget_dispose (GObject *object); -static void metadata_widget_finalize (GObject *object); -// keyevent consumers -static gboolean metadata_widget_button_press_event (GtkWidget *menuitem, - GdkEventButton *event); -static gboolean metadata_widget_button_release_event (GtkWidget *menuitem, - GdkEventButton *event); -// Dbusmenuitem properties update callback -static void metadata_widget_update_state(gchar * property, - GValue * value, - gpointer userdata); -//static void update_content( - - -G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); - - - -static void -metadata_widget_class_init (MetadataWidgetClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - widget_class->button_press_event = metadata_widget_button_press_event; - widget_class->button_release_event = metadata_widget_button_release_event; - - g_type_class_add_private (klass, sizeof (MetadataWidgetPrivate)); - - gobject_class->dispose = metadata_widget_dispose; - gobject_class->finalize = metadata_widget_finalize; - -} - -static void -metadata_widget_init (MetadataWidget *self) -{ - g_debug("MetadataWidget::metadata_widget_init"); - - MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); - - GtkWidget *hbox; - - hbox = gtk_hbox_new(TRUE, 0); - priv->hbox = hbox; - - // image - const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH); - g_debug("MetadataWidget:init - path = %s", path); - priv->our_path = g_strdup(path); - GdkPixbuf* pixbuf; - pixbuf=gdk_pixbuf_new_from_file(path, NULL); - pixbuf=gdk_pixbuf_scale_simple(pixbuf,60,60,GDK_INTERP_BILINEAR); - priv->album_art = gtk_image_new_from_pixbuf(pixbuf); - g_object_unref(pixbuf); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0); - GtkWidget* vbox = gtk_vbox_new(TRUE, 0); - - // artist - GtkWidget* artist; - artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST)); - priv->artist_label = artist; - gtk_box_pack_start (GTK_BOX (vbox), priv->artist_label, FALSE, FALSE, 0); - - - // piece - GtkWidget* piece; - piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_PIECE)); - priv->piece_label = piece; - gtk_box_pack_start (GTK_BOX (vbox), priv->piece_label, FALSE, FALSE, 0); - - // container - GtkWidget* container; - container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER)); - priv->container_label = container; - gtk_box_pack_start (GTK_BOX (vbox), priv->container_label, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (priv->hbox), vbox, FALSE, FALSE, 0); - - g_signal_connect(G_OBJECT(twin_item), "property-changed", - G_CALLBACK(metadata_widget_update_state), self); - gtk_widget_show_all (priv->hbox); - gtk_container_add (GTK_CONTAINER (self), hbox); - -} - -static void -metadata_widget_dispose (GObject *object) -{ - G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object); -} - -static void -metadata_widget_finalize (GObject *object) -{ - G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object); -} - -/* Suppress/consume keyevents */ -static gboolean -metadata_widget_button_press_event (GtkWidget *menuitem, - GdkEventButton *event) -{ - g_debug("MetadataWidget::menu_press_event"); - return TRUE; -} - -static gboolean -metadata_widget_button_release_event (GtkWidget *menuitem, - GdkEventButton *event) -{ - g_debug("MetadataWidget::menu_release_event"); - return TRUE; -} - -static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata) -{ - g_debug("metadata_widget_update_state - with property %s", property); -} - - /** - * transport_new: - * @returns: a new #MetadataWidget. - **/ -GtkWidget* -metadata_widget_new(DbusmenuMenuitem *item) -{ - twin_item = item; - return g_object_new(METADATA_WIDGET_TYPE, NULL); -} - diff --git a/src/metadata-widget.h~ b/src/metadata-widget.h~ deleted file mode 100644 index edffdf2..0000000 --- a/src/metadata-widget.h~ +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2010 Canonical Ltd. - -Authors: - Conor Curran - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ -#ifndef __METADATA_WIDGET_H__ -#define __METADATA_WIDGET_H__ - -#include -#include - -G_BEGIN_DECLS - -#define METADATA_WIDGET_TYPE (metadata_widget_get_type ()) -#define METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), METADATA_WIDGET_TYPE, TransportBar)) -#define METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), METADATA_WIDGET_TYPE, TransportBarClass)) -#define IS_METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), METADATA_WIDGET_TYPE)) -#define IS_METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), METADATA_WIDGET_TYPE)) -#define METADATA_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), METADATA_WIDGET_TYPE, TransportBarClass)) - -typedef struct _TransportBar TransportBar; -typedef struct _TransportBarClass TransportBarClass; - -struct _TransportBarClass { - GtkMenuItemClass parent_class; -}; - -struct _TransportBar { - GtkMenuItem parent; -}; - -GType metadata_widget_get_type (void); -GtkWidget* metadata_widget_new(DbusmenuMenuitem *twin_item); - -G_END_DECLS - -#endif - -- cgit v1.2.3 From b8519dc8b908adf85f88299c743106c9c3627b64 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 14 Jun 2010 19:52:25 +0100 Subject: and it compiles --- src/indicator-sound.c | 4 ++-- src/transport-widget.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index ebafd9a..9f7e136 100755 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -94,7 +94,7 @@ static void slider_released(GtkWidget *widget, gpointer user_data); static void style_changed_cb(GtkWidget *widget, gpointer user_data); //player widgets related -static gboolean new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); +static gboolean new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); // DBUS communication @@ -241,7 +241,7 @@ get_menu (IndicatorObject * io) DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); g_object_set_data (G_OBJECT (client), "indicator", io); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item); - dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TRANSPORT_MENUITEM_TYPE, new_transport_bar); + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TRANSPORT_MENUITEM_TYPE, new_transport_widget); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget); // register Key-press listening on the menu widget as the slider does not allow this. diff --git a/src/transport-widget.c b/src/transport-widget.c index bc2ee40..cd73a17 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -22,7 +22,7 @@ with this program. If not, see . #endif #include -#include "transport-bar.h" +#include "transport-widget.h" #include "common-defs.h" #include -- cgit v1.2.3 From ca99bae318b2768e721c2fa0834e8d12c196b245 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 15 Jun 2010 00:32:27 +0100 Subject: key events are not going to be easy --- src/transport-menu-item.vala | 2 - src/transport-widget.c | 91 +++++++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 28 deletions(-) diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 0ecc9b1..7687a92 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -15,7 +15,5 @@ public class TransportMenuitem : Dbusmenu.Menuitem public override void handle_event(string name, GLib.Value input_value, uint timestamp) { - this.property_set(DBUSMENU_TRANSPORT_MENUITEM_STATE, "1"); - debug("TransportItem -> handle event caught!"); } } \ No newline at end of file diff --git a/src/transport-widget.c b/src/transport-widget.c index cd73a17..7e26c68 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -58,14 +58,21 @@ static void transport_widget_init (TransportWidget *self); static void transport_widget_dispose (GObject *object); static void transport_widget_finalize (GObject *object); -/* UI and dbus callbacks */ -static gboolean transport_widget_button_press_event (GtkWidget *menuitem, - GdkEventButton *event); +/* UI and dbusmenu callbacks */ +static gboolean transport_widget_button_press_event (GtkWidget *menuitem, + GdkEventButton *event); static gboolean transport_widget_button_release_event (GtkWidget *menuitem, - GdkEventButton *event); -static gboolean transport_widget_play_button_trigger (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); + GdkEventButton *event); +static gboolean transport_widget_play_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); +static gboolean transport_widget_previous_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); +static gboolean transport_widget_next_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); + static void transport_widget_update_state(DbusmenuMenuitem* item, gchar * property, GValue * value, @@ -138,27 +145,26 @@ transport_widget_init (TransportWidget *self) priv->next_button = gtk_button_new_with_label(">>"); priv->play_button = gtk_button_new_with_label(">"); - gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, TRUE, 0); + + g_signal_connect(GTK_OBJECT(priv->play_button), "button-press-event", G_CALLBACK(transport_widget_play_button_press_event), priv->play_button); + g_signal_connect(GTK_OBJECT(priv->previous_button), "button-press-event", G_CALLBACK(transport_widget_previous_button_press_event), NULL); + g_signal_connect(GTK_OBJECT(priv->next_button), "button-press-event", G_CALLBACK(transport_widget_next_button_press_event), NULL); - g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_widget_play_button_trigger), NULL); - priv->hbox = hbox; + priv->hbox = hbox; g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_update_state), self); - gtk_widget_show_all (priv->hbox); - gtk_container_add (GTK_CONTAINER (self), hbox); + gtk_container_add (GTK_CONTAINER (self), priv->hbox); + gtk_widget_show_all (priv->hbox); } static void transport_widget_dispose (GObject *object) { - //if(IS_TRANSPORT_BAR(object) == TRUE){ - // TransportWidgetPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(TRANSPORT_BAR(object)); - // g_object_unref(priv->previous_button); - //} G_OBJECT_CLASS (transport_widget_parent_class)->dispose (object); } @@ -171,10 +177,25 @@ transport_widget_finalize (GObject *object) /* keyevents */ static gboolean transport_widget_button_press_event (GtkWidget *menuitem, - GdkEventButton *event) + GdkEventButton *event) { g_debug("TransportWidget::menu_press_event"); - return FALSE; + //TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem)); + //gtk_button_pressed(GTK_BUTTON(priv->play_button)); + //gtk_button_pressed(GTK_BUTTON(priv->previous_button)); + //gtk_button_pressed(GTK_BUTTON(priv->next_button)); + + //if (event->type == GDK_BUTTON_PRESS) { + //GdkEventButton *bevent = (GdkEventButton *) event; + //gtk_button_pressed(bevent->button); +//gtk_menu_popup (GTK_MENU (menuitem), NULL, NULL, NULL, NULL, +// bevent->button, bevent->time); + /* Tell calling code that we have handled this event; the buck + * stops here. */ + //return TRUE; + //} + + return TRUE; } static gboolean @@ -182,17 +203,35 @@ transport_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event) { g_debug("TransportWidget::menu_release_event"); - return FALSE; + return TRUE; } /* Individual keyevents on the buttons */ static gboolean -transport_widget_play_button_trigger(GtkWidget* widget, - GdkEventButton *event, - gpointer user_data) +transport_widget_play_button_press_event( GtkWidget* widget, + GdkEventButton *event, + gpointer user_data) +{ + g_debug("!!!!! TransportWidget::PLAY button_press_event"); + return TRUE; +} + +static gboolean +transport_widget_previous_button_press_event( GtkWidget* widget, + GdkEventButton *event, + gpointer user_data) +{ + g_debug("!!!!! TransportWidget::PREVIOUS button_press_event"); + return TRUE; +} + +static gboolean +transport_widget_next_button_press_event( GtkWidget* widget, + GdkEventButton *event, + gpointer user_data) { - g_debug("TransportWidget::PLAY button_press_event"); - return FALSE; + g_debug("!!!!! TransportWidget::NEXT button_press_event"); + return TRUE; } /** -- cgit v1.2.3 From 50bea3ce0fad1e36d0a657430a96567986a46638 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 15 Jun 2010 11:33:07 +0100 Subject: for now activated one button due to gtk button press oddness --- src/transport-widget.c | 111 ++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 52 deletions(-) diff --git a/src/transport-widget.c b/src/transport-widget.c index 7e26c68..b3f2ee1 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -35,9 +35,9 @@ typedef struct _TransportWidgetPrivate TransportWidgetPrivate; struct _TransportWidgetPrivate { GtkWidget* hbox; - GtkWidget* previous_button; + //GtkWidget* previous_button; GtkWidget* play_button; - GtkWidget* next_button; + //GtkWidget* next_button; }; enum { @@ -63,22 +63,22 @@ static gboolean transport_widget_button_press_event (GtkWidget *men GdkEventButton *event); static gboolean transport_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event); -static gboolean transport_widget_play_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); -static gboolean transport_widget_previous_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); -static gboolean transport_widget_next_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); +//static gboolean transport_widget_play_button_press_event (GtkWidget *widget, +// GdkEventButton *event, +// gpointer user_data); +//static gboolean transport_widget_previous_button_press_event (GtkWidget *widget, +// GdkEventButton *event, +// gpointer user_data); +//static gboolean transport_widget_next_button_press_event (GtkWidget *widget, +// GdkEventButton *event, +// gpointer user_data); static void transport_widget_update_state(DbusmenuMenuitem* item, gchar * property, GValue * value, gpointer userdata); // utility methods -static gchar* transport_widget_determine_play_label(gchar* state); +static gchar* transport_widget_determine_play_label(const gchar* state); G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM); @@ -141,24 +141,29 @@ transport_widget_init (TransportWidget *self) GtkWidget *hbox; hbox = gtk_hbox_new(TRUE, 2); - priv->previous_button = gtk_button_new_with_label("<<"); - priv->next_button = gtk_button_new_with_label(">>"); + //priv->previous_button = gtk_button_new_with_label("<<"); + //priv->next_button = gtk_button_new_with_label(">>"); priv->play_button = gtk_button_new_with_label(">"); - gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, TRUE, 0); + //gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, TRUE, 0); + //gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, TRUE, 0); - g_signal_connect(GTK_OBJECT(priv->play_button), "button-press-event", G_CALLBACK(transport_widget_play_button_press_event), priv->play_button); - g_signal_connect(GTK_OBJECT(priv->previous_button), "button-press-event", G_CALLBACK(transport_widget_previous_button_press_event), NULL); - g_signal_connect(GTK_OBJECT(priv->next_button), "button-press-event", G_CALLBACK(transport_widget_next_button_press_event), NULL); + //g_signal_connect(GTK_OBJECT(priv->play_button), "button-press-event", G_CALLBACK(transport_widget_play_button_press_event), priv->play_button); + //g_signal_connect(GTK_OBJECT(priv->previous_button), "button-press-event", G_CALLBACK(transport_widget_previous_button_press_event), NULL); + //g_signal_connect(GTK_OBJECT(priv->next_button), "button-press-event", G_CALLBACK(transport_widget_next_button_press_event), NULL); priv->hbox = hbox; g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_update_state), self); gtk_container_add (GTK_CONTAINER (self), priv->hbox); - + + //GtkWidget* parent = gtk_widget_get_parent(GTK_WIDGET(priv->hbox)); + //if (GTK_IS_MENU_ITEM(parent)){ + // g_debug("as expected the transport item is the parent"); + //} + //gtk_widget_set_parent(GTK_WIDGET(priv->hbox), GTK_WIDGET(self)); gtk_widget_show_all (priv->hbox); } @@ -180,7 +185,9 @@ transport_widget_button_press_event (GtkWidget *menuitem, GdkEventButton *event) { g_debug("TransportWidget::menu_press_event"); - //TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem)); + TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem)); + gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_determine_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button))))); + //gtk_button_pressed(GTK_BUTTON(priv->play_button)); //gtk_button_pressed(GTK_BUTTON(priv->previous_button)); //gtk_button_pressed(GTK_BUTTON(priv->next_button)); @@ -207,32 +214,32 @@ transport_widget_button_release_event (GtkWidget *menuitem, } /* Individual keyevents on the buttons */ -static gboolean -transport_widget_play_button_press_event( GtkWidget* widget, - GdkEventButton *event, - gpointer user_data) -{ - g_debug("!!!!! TransportWidget::PLAY button_press_event"); - return TRUE; -} - -static gboolean -transport_widget_previous_button_press_event( GtkWidget* widget, - GdkEventButton *event, - gpointer user_data) -{ - g_debug("!!!!! TransportWidget::PREVIOUS button_press_event"); - return TRUE; -} - -static gboolean -transport_widget_next_button_press_event( GtkWidget* widget, - GdkEventButton *event, - gpointer user_data) -{ - g_debug("!!!!! TransportWidget::NEXT button_press_event"); - return TRUE; -} +//static gboolean +//transport_widget_play_button_press_event( GtkWidget* widget, +// GdkEventButton *event, +// gpointer user_data) +//{ +// g_debug("!!!!! TransportWidget::PLAY button_press_event"); +// return TRUE; +//} + +//static gboolean +//transport_widget_previous_button_press_event( GtkWidget* widget, +// GdkEventButton *event, +// gpointer user_data) +//{ +// g_debug("!!!!! TransportWidget::PREVIOUS button_press_event"); +// return TRUE; +//} + +//static gboolean +//transport_widget_next_button_press_event( GtkWidget* widget, +// GdkEventButton *event, +// gpointer user_data) +//{ +// g_debug("!!!!! TransportWidget::NEXT button_press_event"); +// return TRUE; +//} /** * transport_widget_update_state() @@ -252,15 +259,15 @@ static void transport_widget_update_state(DbusmenuMenuitem* item, gchar* propert } // will be needed for image swapping -static gchar* transport_widget_determine_play_label(gchar* state) +static gchar* transport_widget_determine_play_label(const gchar* state) { gchar* label = ">"; - if(g_strcmp0(state, "pause") == 0){ + //if(g_strcmp0(state, "||") == 0){ + // label = "||"; + //} + if(g_strcmp0(state, ">") == 0){ label = "||"; } - else if(g_strcmp0(state, "play") == 0){ - label = ">"; - } return label; } -- cgit v1.2.3 From 6cb898210daa87978405e270e159ef2c0d63fb26 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 15 Jun 2010 12:19:01 +0100 Subject: removed commented code --- src/transport-widget.c | 68 -------------------------------------------------- 1 file changed, 68 deletions(-) diff --git a/src/transport-widget.c b/src/transport-widget.c index b3f2ee1..2c32315 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -35,9 +35,7 @@ typedef struct _TransportWidgetPrivate TransportWidgetPrivate; struct _TransportWidgetPrivate { GtkWidget* hbox; - //GtkWidget* previous_button; GtkWidget* play_button; - //GtkWidget* next_button; }; enum { @@ -63,15 +61,6 @@ static gboolean transport_widget_button_press_event (GtkWidget *men GdkEventButton *event); static gboolean transport_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event); -//static gboolean transport_widget_play_button_press_event (GtkWidget *widget, -// GdkEventButton *event, -// gpointer user_data); -//static gboolean transport_widget_previous_button_press_event (GtkWidget *widget, -// GdkEventButton *event, -// gpointer user_data); -//static gboolean transport_widget_next_button_press_event (GtkWidget *widget, -// GdkEventButton *event, -// gpointer user_data); static void transport_widget_update_state(DbusmenuMenuitem* item, gchar * property, @@ -141,17 +130,10 @@ transport_widget_init (TransportWidget *self) GtkWidget *hbox; hbox = gtk_hbox_new(TRUE, 2); - //priv->previous_button = gtk_button_new_with_label("<<"); - //priv->next_button = gtk_button_new_with_label(">>"); priv->play_button = gtk_button_new_with_label(">"); - //gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0); - //gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, TRUE, 0); - //g_signal_connect(GTK_OBJECT(priv->play_button), "button-press-event", G_CALLBACK(transport_widget_play_button_press_event), priv->play_button); - //g_signal_connect(GTK_OBJECT(priv->previous_button), "button-press-event", G_CALLBACK(transport_widget_previous_button_press_event), NULL); - //g_signal_connect(GTK_OBJECT(priv->next_button), "button-press-event", G_CALLBACK(transport_widget_next_button_press_event), NULL); priv->hbox = hbox; @@ -159,11 +141,6 @@ transport_widget_init (TransportWidget *self) gtk_container_add (GTK_CONTAINER (self), priv->hbox); - //GtkWidget* parent = gtk_widget_get_parent(GTK_WIDGET(priv->hbox)); - //if (GTK_IS_MENU_ITEM(parent)){ - // g_debug("as expected the transport item is the parent"); - //} - //gtk_widget_set_parent(GTK_WIDGET(priv->hbox), GTK_WIDGET(self)); gtk_widget_show_all (priv->hbox); } @@ -187,20 +164,6 @@ transport_widget_button_press_event (GtkWidget *menuitem, g_debug("TransportWidget::menu_press_event"); TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem)); gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_determine_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button))))); - - //gtk_button_pressed(GTK_BUTTON(priv->play_button)); - //gtk_button_pressed(GTK_BUTTON(priv->previous_button)); - //gtk_button_pressed(GTK_BUTTON(priv->next_button)); - - //if (event->type == GDK_BUTTON_PRESS) { - //GdkEventButton *bevent = (GdkEventButton *) event; - //gtk_button_pressed(bevent->button); -//gtk_menu_popup (GTK_MENU (menuitem), NULL, NULL, NULL, NULL, -// bevent->button, bevent->time); - /* Tell calling code that we have handled this event; the buck - * stops here. */ - //return TRUE; - //} return TRUE; } @@ -213,34 +176,6 @@ transport_widget_button_release_event (GtkWidget *menuitem, return TRUE; } -/* Individual keyevents on the buttons */ -//static gboolean -//transport_widget_play_button_press_event( GtkWidget* widget, -// GdkEventButton *event, -// gpointer user_data) -//{ -// g_debug("!!!!! TransportWidget::PLAY button_press_event"); -// return TRUE; -//} - -//static gboolean -//transport_widget_previous_button_press_event( GtkWidget* widget, -// GdkEventButton *event, -// gpointer user_data) -//{ -// g_debug("!!!!! TransportWidget::PREVIOUS button_press_event"); -// return TRUE; -//} - -//static gboolean -//transport_widget_next_button_press_event( GtkWidget* widget, -// GdkEventButton *event, -// gpointer user_data) -//{ -// g_debug("!!!!! TransportWidget::NEXT button_press_event"); -// return TRUE; -//} - /** * transport_widget_update_state() * Callback for updates from the other side of dbus @@ -262,9 +197,6 @@ static void transport_widget_update_state(DbusmenuMenuitem* item, gchar* propert static gchar* transport_widget_determine_play_label(const gchar* state) { gchar* label = ">"; - //if(g_strcmp0(state, "||") == 0){ - // label = "||"; - //} if(g_strcmp0(state, ">") == 0){ label = "||"; } -- cgit v1.2.3 From a1f24dc28b91bd52ef7175813762d23dd0fd3b38 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 15 Jun 2010 13:02:02 +0100 Subject: uncommented auto service shutdown --- src/sound-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound-service.c b/src/sound-service.c index 3ec7a60..38e5fba 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -45,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - //close_pulse_activites(); - //g_main_loop_quit(mainloop); + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From ba57d27e4da9d145f08f1305d01a327612702ff2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 15 Jun 2010 14:38:21 +0100 Subject: remove redundant source --- src/rhythmbox-controller.vala | 44 ------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 src/rhythmbox-controller.vala diff --git a/src/rhythmbox-controller.vala b/src/rhythmbox-controller.vala deleted file mode 100644 index 734c8bd..0000000 --- a/src/rhythmbox-controller.vala +++ /dev/null @@ -1,44 +0,0 @@ -using DbusmenuGlib; - -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); - } - - 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_player.playingUriChanged += onUriChange; - this.rhythmbox_player.elapsedChanged += onElapsedChange; - - debug("New rhythmbox controller has been instantiated"); - } - - private void onUriChange(dynamic DBus.Object rhythmbox, string uri) - { - debug("onUriChange, new uri : %s", uri); - //;// = new HashTable(str_hash,str_equal); - HashTable 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); - } - -} -- cgit v1.2.3 From fbc95f69319a6659ccf321eef370189072c4f279 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 15 Jun 2010 16:46:27 +0100 Subject: fixed the version numbers for libindicate and dbusmenu-glib --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 1478bec..2c58cc2 100644 --- a/configure.ac +++ b/configure.ac @@ -34,8 +34,8 @@ DBUSMENUGTK_REQUIRED_VERSION=0.2.2 POLKIT_REQUIRED_VERSION=0.92 PULSE_AUDIO_REQUIRED_VERSION=0.9.19 INDICATOR_DISPLAY_OBJECTS=0.1.4 -INDICATE_REQUIRED_VERSION=0.3.6 -DBUSMENUGLIB_REQUIRED_VERSION=0.2.9 +INDICATE_REQUIRED_VERSION=0.4.1 +DBUSMENUGLIB_REQUIRED_VERSION=0.3.1 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION -- cgit v1.2.3 From 71d315d3abec5b62e43b821232d70262bec92bd1 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 16 Jun 2010 18:19:35 +0100 Subject: metadata being updated dynamically --- src/Makefile.am | 4 ++- src/metadata-menu-item.vala | 15 ++++++----- src/metadata-widget.c | 21 +++++++++++---- src/metadata-widget.h | 2 +- src/mpris-controller-v2.vala | 28 ++++++++++++++++++++ src/mpris-controller.vala | 61 ++++++++++++++++++++++++++++++++++++++++++++ src/music-player-bridge.vala | 21 ++++++++++++++- src/player-controller.vala | 37 ++++++++++++++++++++++++++- src/sound-service.c | 4 +-- src/transport-menu-item.vala | 20 +++++++++++++++ 10 files changed, 195 insertions(+), 18 deletions(-) create mode 100644 src/mpris-controller-v2.vala create mode 100644 src/mpris-controller.vala diff --git a/src/Makefile.am b/src/Makefile.am index 2a19c3d..ac7beb9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,7 +54,9 @@ music_bridge_VALASOURCES = \ music-player-bridge.vala \ transport-menu-item.vala \ metadata-menu-item.vala \ - player-controller.vala + player-controller.vala \ + mpris-controller-v2.vala \ + mpris-controller.vala music_bridge_VALAFLAGS = \ --ccode \ diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index ef72143..894ad3c 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -13,15 +13,16 @@ public class MetadataMenuitem : Dbusmenu.Menuitem public MetadataMenuitem() { this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_METADATA_MENUITEM_TYPE); - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, "Sonnamble"); - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, "Nocturne"); - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, "Seven Months in E minor"); - this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, "/home/ronoc/Desktop/Sonnamble/Sonnamble_CD.jpg"); - - debug("image_path property set %s:", this.property_get(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH)); - } + public void update(HashMap data) + { + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist")); + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, data.get("title")); + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, data.get("album")); + this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, data.get("arturl")); + } + public override void handle_event(string name, GLib.Value input_value, uint timestamp) { debug("MetadataItem -> handle event caught!"); diff --git a/src/metadata-widget.c b/src/metadata-widget.c index a451ad7..e69a9dd 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -53,9 +53,9 @@ static gboolean metadata_widget_button_press_event (GtkWidget *menuitem, static gboolean metadata_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event); // Dbusmenuitem properties update callback -static void metadata_widget_update_state(gchar * property, - GValue * value, - gpointer userdata); +static void metadata_widget_update_state(DbusmenuMenuitem* item, gchar* property, + GValue* value, gpointer userdata); + //static void update_content( @@ -159,9 +159,20 @@ metadata_widget_button_release_event (GtkWidget *menuitem, return TRUE; } -static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata) +static void +metadata_widget_update_state(DbusmenuMenuitem* item, gchar* property, + GValue* value, gpointer userdata) { - g_debug("metadata_widget_update_state - with property %s", property); + //g_debug("metadata_widget_update_state - with property %s", property); + MetadataWidget* mitem = METADATA_WIDGET(userdata); + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(mitem); + + if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, property) == 0){ + gtk_label_set_text(GTK_LABEL(priv->artist_label), g_value_get_string(value)); + } + else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, property) == 0){ + gtk_label_set_text(GTK_LABEL(priv->piece_label), g_value_get_string(value)); + } } /** diff --git a/src/metadata-widget.h b/src/metadata-widget.h index ce7df5f..6f1d4d3 100644 --- a/src/metadata-widget.h +++ b/src/metadata-widget.h @@ -25,7 +25,7 @@ with this program. If not, see . G_BEGIN_DECLS #define METADATA_WIDGET_TYPE (metadata_widget_get_type ()) -#define METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), METADATA_WIDGET_TYPE, TransportBar)) +#define METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), METADATA_WIDGET_TYPE, MetadataWidget)) #define METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), METADATA_WIDGET_TYPE, MetadataWidgetClass)) #define IS_METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), METADATA_WIDGET_TYPE)) #define IS_METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), METADATA_WIDGET_TYPE)) diff --git a/src/mpris-controller-v2.vala b/src/mpris-controller-v2.vala new file mode 100644 index 0000000..0392cfc --- /dev/null +++ b/src/mpris-controller-v2.vala @@ -0,0 +1,28 @@ +/* +This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ +using Gee; + +public class MprisControllerV2 : MprisController +{ + public MprisControllerV2(string name, PlayerController controller){ + base(name, controller, "org.mpris.MediaPlayer.Player"); + } + +} diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala new file mode 100644 index 0000000..f606b32 --- /dev/null +++ b/src/mpris-controller.vala @@ -0,0 +1,61 @@ +/* +This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ +using Gee; + +public class MprisController : GLib.Object +{ + private DBus.Connection connection; + private dynamic DBus.Object mpris_player; + private PlayerController controller; + + public MprisController(string name, PlayerController controller, string mpris_interface="org.freedesktop.MediaPlayer"){ + try { + this.connection = DBus.Bus.get (DBus.BusType.SESSION); + } catch (Error e) { + error("Problems connecting to the session bus - %s", e.message); + } + this.controller = controller; + this.mpris_player = this.connection.get_object ("org.mpris.".concat(name.down()) , "/Player", mpris_interface); + this.mpris_player.TrackChange += onTrackChange; + this.controller.update_playing_info(get_track_data()); + } + + public HashMap get_track_data() + { + return format_metadata(this.mpris_player.GetMetadata()); + } + + private void onTrackChange(dynamic DBus.Object mpris_client, HashTable ht) + { + this.controller.update_playing_info(format_metadata(ht)); + } + + private static HashMap format_metadata(HashTable data) + { + HashMap results = new HashMap(); + debug("format_metadata - title = %s", (string)data.lookup("title")); + results.set("title", (string)data.lookup("title")); + results.set("artist", (string)data.lookup("artist")); + results.set("album", (string)data.lookup("album")); + results.set("arturl", (string)data.lookup("arturl")); + return results; + } + +} diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 89f633b..b03ecbd 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -1,3 +1,23 @@ +/* +This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + using Indicate; using Dbusmenu; using Gee; @@ -23,7 +43,6 @@ public class MusicPlayerBridge : GLib.Object public void set_root_menu_item(Dbusmenu.Menuitem menu) { - debug("MusicPlayerBridge -> set_root_menu_item"); root_menu = menu; } diff --git a/src/player-controller.vala b/src/player-controller.vala index dcb428b..4c09c12 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -1,12 +1,35 @@ +/* +This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + + using Dbusmenu; using Gee; public class PlayerController : GLib.Object { + private const int METADATA = 2; private Dbusmenu.Menuitem root_menu; private string name; private bool is_active; private ArrayList custom_items; + private MprisController mpris_adaptor; // TODO: pass in the appropriate position for the menu (to handle multiple players) public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active) @@ -16,6 +39,12 @@ public class PlayerController : GLib.Object this.is_active = active; this.custom_items = new ArrayList(); self_construct(); + // Temporary scenario to handle both v1 and v2 of MPRIS. + if(this.name == "Vlc"){ + this.mpris_adaptor = new MprisControllerV2(this.name, this); + }else{ + this.mpris_adaptor = new MprisController(this.name, this); + } } public void vanish() @@ -52,7 +81,13 @@ public class PlayerController : GLib.Object } return true; } - + + public void update_playing_info(HashMap data) + { + debug("PlayerController - update_playing_info"); + MetadataMenuitem item = (MetadataMenuitem)this.custom_items[METADATA]; + item.update(data); + } private static string format_client_name(string client_name) { diff --git a/src/sound-service.c b/src/sound-service.c index 38e5fba..3ec7a60 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -45,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); + //close_pulse_activites(); + //g_main_loop_quit(mainloop); } return; } diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 7687a92..2259e43 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -1,3 +1,23 @@ +/* +This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + using Dbusmenu; using Gee; -- cgit v1.2.3 From 4125fd9e2eb0de55d04482b3c035aa91fe7d547a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 16 Jun 2010 19:40:15 +0100 Subject: album art updates working just fine --- src/metadata-widget.c | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/metadata-widget.c b/src/metadata-widget.c index e69a9dd..e0dca6e 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -34,7 +34,7 @@ struct _MetadataWidgetPrivate { GtkWidget* hbox; GtkWidget* album_art; - gchar* our_path; + gchar* image_path; GtkWidget* artist_label; GtkWidget* piece_label; GtkWidget* container_label; @@ -53,10 +53,10 @@ static gboolean metadata_widget_button_press_event (GtkWidget *menuitem, static gboolean metadata_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event); // Dbusmenuitem properties update callback -static void metadata_widget_update_state(DbusmenuMenuitem* item, gchar* property, +static void metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, GValue* value, gpointer userdata); -//static void update_content( +static void update_album_art(MetadataWidget* self); G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); @@ -92,14 +92,9 @@ metadata_widget_init (MetadataWidget *self) priv->hbox = hbox; // image - const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH); - g_debug("MetadataWidget:init - path = %s", path); - priv->our_path = g_strdup(path); - GdkPixbuf* pixbuf; - pixbuf=gdk_pixbuf_new_from_file(path, NULL); - pixbuf=gdk_pixbuf_scale_simple(pixbuf,60,60,GDK_INTERP_BILINEAR); - priv->album_art = gtk_image_new_from_pixbuf(pixbuf); - g_object_unref(pixbuf); + priv->album_art = gtk_image_new(); + priv->image_path = g_strdup(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH)); + update_album_art(self); gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0); GtkWidget* vbox = gtk_vbox_new(TRUE, 0); @@ -107,24 +102,28 @@ metadata_widget_init (MetadataWidget *self) GtkWidget* artist; artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST)); priv->artist_label = artist; - gtk_box_pack_start (GTK_BOX (vbox), priv->artist_label, FALSE, FALSE, 0); + // piece GtkWidget* piece; piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_PIECE)); priv->piece_label = piece; - gtk_box_pack_start (GTK_BOX (vbox), priv->piece_label, FALSE, FALSE, 0); - + + // container GtkWidget* container; container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER)); priv->container_label = container; + + // Pack in the right order + gtk_box_pack_start (GTK_BOX (vbox), priv->piece_label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), priv->artist_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), priv->container_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (priv->hbox), vbox, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(twin_item), "property-changed", - G_CALLBACK(metadata_widget_update_state), self); + G_CALLBACK(metadata_widget_property_update), self); gtk_widget_show_all (priv->hbox); gtk_container_add (GTK_CONTAINER (self), hbox); @@ -160,10 +159,9 @@ metadata_widget_button_release_event (GtkWidget *menuitem, } static void -metadata_widget_update_state(DbusmenuMenuitem* item, gchar* property, +metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, GValue* value, gpointer userdata) { - //g_debug("metadata_widget_update_state - with property %s", property); MetadataWidget* mitem = METADATA_WIDGET(userdata); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(mitem); @@ -173,6 +171,22 @@ metadata_widget_update_state(DbusmenuMenuitem* item, gchar* property, else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->piece_label), g_value_get_string(value)); } + else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, property) == 0){ + gtk_label_set_text(GTK_LABEL(priv->container_label), g_value_get_string(value)); + } + else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, property) == 0){ + priv->image_path = g_strdup(g_value_get_string(value)); + update_album_art(mitem); + } +} + +static void update_album_art(MetadataWidget* self){ + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + GdkPixbuf* pixbuf; + pixbuf = gdk_pixbuf_new_from_file(priv->image_path, NULL); + pixbuf = gdk_pixbuf_scale_simple(pixbuf,60,60,GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf); + g_object_unref(pixbuf); } /** -- cgit v1.2.3 From 05e82f2c6a8a72aeb3a589b702e5a9f1d68251d9 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 17 Jun 2010 16:41:54 +0100 Subject: transport plugged in --- src/metadata-menu-item.vala | 20 +++++++++++++++----- src/metadata-widget.c | 8 ++++++-- src/mpris-controller.vala | 42 +++++++++++++++++++++++++++++++++++++++++- src/player-controller.vala | 18 +++++++++++++----- src/sound-service.c | 4 ++-- src/transport-menu-item.vala | 19 +++++++++++++++++-- src/transport-widget.c | 32 +++++++++++++++++++++++--------- 7 files changed, 117 insertions(+), 26 deletions(-) diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 894ad3c..be078bd 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -17,12 +17,22 @@ public class MetadataMenuitem : Dbusmenu.Menuitem public void update(HashMap data) { - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist")); - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, data.get("title")); - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, data.get("album")); - this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, data.get("arturl")); + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist").strip()); + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, data.get("title").strip()); + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, data.get("album").strip()); + this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl"))); } - + + public static string sanitize_image_path(string path) + { + string result = path.strip(); + if(result.contains("file:///")){ + result = result.slice(7, result.len()); + } + debug("Sanitize image path - result = %s", result); + return result; + } + public override void handle_event(string name, GLib.Value input_value, uint timestamp) { debug("MetadataItem -> handle event caught!"); diff --git a/src/metadata-widget.c b/src/metadata-widget.c index e0dca6e..357c31a 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -176,7 +176,9 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, property) == 0){ priv->image_path = g_strdup(g_value_get_string(value)); - update_album_art(mitem); + if(priv->image_path != NULL){ + update_album_art(mitem); + } } } @@ -184,11 +186,13 @@ static void update_album_art(MetadataWidget* self){ MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); GdkPixbuf* pixbuf; pixbuf = gdk_pixbuf_new_from_file(priv->image_path, NULL); - pixbuf = gdk_pixbuf_scale_simple(pixbuf,60,60,GDK_INTERP_BILINEAR); + pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60,GDK_INTERP_BILINEAR); + g_debug("attempting to set the image with path %s", priv->image_path); gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf); g_object_unref(pixbuf); } + /** * transport_new: * @returns: a new #MetadataWidget. diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index f606b32..7e65594 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -17,13 +17,22 @@ PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ + using Gee; + public class MprisController : GLib.Object { private DBus.Connection connection; - private dynamic DBus.Object mpris_player; + public dynamic DBus.Object mpris_player; private PlayerController controller; + struct status { + public int32 playback; + public int32 shuffle; + public int32 repeat; + public int32 endless; + } + public MprisController(string name, PlayerController controller, string mpris_interface="org.freedesktop.MediaPlayer"){ try { @@ -34,6 +43,7 @@ public class MprisController : GLib.Object this.controller = controller; this.mpris_player = this.connection.get_object ("org.mpris.".concat(name.down()) , "/Player", mpris_interface); this.mpris_player.TrackChange += onTrackChange; + this.mpris_player.StatusChange += onStatusChange; this.controller.update_playing_info(get_track_data()); } @@ -47,6 +57,36 @@ public class MprisController : GLib.Object this.controller.update_playing_info(format_metadata(ht)); } + /** + * TRUE => Playing + * FALSE => Paused + **/ + public void toggle_playback(bool state) + { + if(state == true){ + debug("about to play"); + this.mpris_player.Play(); + } + else{ + debug("about to pause"); + this.mpris_player.Pause(); + } + } + + private void onStatusChange(dynamic DBus.Object mpris_client, status st) + { + debug("onStatusChange - signal received"); + //ValueArray a = new ValueArray(4); + //Value v = new Value(typeof(int32)); + //v.set_int(st.playback); + //a.append(v); + //debug("onStatusChange - play %i", a.get_nth(0).get_int()); + //int playback = (ValueArray)st.get_nth(0).get_int(); + //int shuffle = ar.get_nth(1).get_int(); + //int repeat = ar.get_nth(2).get_int(); + //int endless = ar.get_nth(3).get_int(); + } + private static HashMap format_metadata(HashTable data) { HashMap results = new HashMap(); diff --git a/src/player-controller.vala b/src/player-controller.vala index 4c09c12..aa72cac 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -18,20 +18,20 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - using Dbusmenu; using Gee; public class PlayerController : GLib.Object { - private const int METADATA = 2; + private const int METADATA = 2; + private const int TRANSPORT = 3; + private Dbusmenu.Menuitem root_menu; private string name; private bool is_active; private ArrayList custom_items; private MprisController mpris_adaptor; - // TODO: pass in the appropriate position for the menu (to handle multiple players) public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active) { this.root_menu = root; @@ -39,12 +39,20 @@ public class PlayerController : GLib.Object this.is_active = active; this.custom_items = new ArrayList(); self_construct(); + // Temporary scenario to handle both v1 and v2 of MPRIS. if(this.name == "Vlc"){ this.mpris_adaptor = new MprisControllerV2(this.name, this); - }else{ + } + else{ this.mpris_adaptor = new MprisController(this.name, this); - } + } + + // TODO subclass dbusmenuMenuitem to something like a playermenuitem + // and use this type to collectively + // control widgets. + TransportMenuitem t = (TransportMenuitem)this.custom_items[TRANSPORT]; + t.set_adaptor(this.mpris_adaptor); } public void vanish() diff --git a/src/sound-service.c b/src/sound-service.c index 3ec7a60..38e5fba 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -45,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - //close_pulse_activites(); - //g_main_loop_quit(mainloop); + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 2259e43..2e1ed0b 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -26,14 +26,29 @@ public class TransportMenuitem : Dbusmenu.Menuitem /* Not ideal duplicate definition of const - see common-defs/h */ const string DBUSMENU_TRANSPORT_MENUITEM_TYPE = "x-canonical-transport-bar"; const string DBUSMENU_TRANSPORT_MENUITEM_STATE = "x-canonical-transport-state"; - + private MprisController mpris_adaptor; + public TransportMenuitem() { this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE); - this.property_set(DBUSMENU_TRANSPORT_MENUITEM_STATE, "play"); + // Hardcode the set up state until we can get the struct vala bug fixed + this.property_set_bool(DBUSMENU_TRANSPORT_MENUITEM_STATE, false); + debug("transport on the vala side"); } + public void set_adaptor(MprisController adaptor) + { + this.mpris_adaptor = adaptor; + } + + /** + Callback method for the handle_event + * TRUE => Playing + * FALSE => Paused + **/ public override void handle_event(string name, GLib.Value input_value, uint timestamp) { + debug("handle_event with bool value %s", input_value.get_boolean().to_string()); + this.mpris_adaptor.toggle_playback(input_value.get_boolean()); } } \ No newline at end of file diff --git a/src/transport-widget.c b/src/transport-widget.c index 2c32315..ce364e3 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -62,12 +62,12 @@ static gboolean transport_widget_button_press_event (GtkWidget *men static gboolean transport_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event); -static void transport_widget_update_state(DbusmenuMenuitem* item, +static void transport_widget_property_update(DbusmenuMenuitem* item, gchar * property, GValue * value, gpointer userdata); // utility methods -static gchar* transport_widget_determine_play_label(const gchar* state); +static gchar* transport_widget_toggle_play_label(const gchar* state); G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM); @@ -130,14 +130,18 @@ transport_widget_init (TransportWidget *self) GtkWidget *hbox; hbox = gtk_hbox_new(TRUE, 2); - priv->play_button = gtk_button_new_with_label(">"); - gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0); + gchar* label = ">"; + if(dbusmenu_menuitem_property_get_bool(twin_item, DBUSMENU_TRANSPORT_MENUITEM_STATE) == TRUE){ + label = "||"; + } + priv->play_button = gtk_button_new_with_label(g_strdup(label)); + gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0); priv->hbox = hbox; - g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_update_state), self); + g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_property_update), self); gtk_container_add (GTK_CONTAINER (self), priv->hbox); @@ -163,7 +167,16 @@ transport_widget_button_press_event (GtkWidget *menuitem, { g_debug("TransportWidget::menu_press_event"); TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem)); - gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_determine_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button))))); + + gboolean state = g_ascii_strcasecmp(gtk_button_get_label(GTK_BUTTON(priv->play_button)), ">") == 0; + + gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_toggle_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button))))); + GValue value = {0}; + g_value_init(&value, G_TYPE_BOOLEAN); + g_debug("TransportWidget::menu_press_event - going to send value %i", state); + + g_value_set_boolean(&value, state); + dbusmenu_menuitem_handle_event (twin_item, "Transport state change", &value, 0); return TRUE; } @@ -180,7 +193,8 @@ transport_widget_button_release_event (GtkWidget *menuitem, * transport_widget_update_state() * Callback for updates from the other side of dbus **/ -static void transport_widget_update_state(DbusmenuMenuitem* item, gchar* property, +static void +transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, GValue* value, gpointer userdata) { g_debug("transport_widget_update_state - with property %s", property); @@ -190,11 +204,11 @@ static void transport_widget_update_state(DbusmenuMenuitem* item, gchar* propert TransportWidget* bar = (TransportWidget*)userdata; TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar); - gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_determine_play_label(property))); + gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_toggle_play_label(property))); } // will be needed for image swapping -static gchar* transport_widget_determine_play_label(const gchar* state) +static gchar* transport_widget_toggle_play_label(const gchar* state) { gchar* label = ">"; if(g_strcmp0(state, ">") == 0){ -- cgit v1.2.3 From 5f7e8583de28afb9424666bbf9652b9774cf9499 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 17 Jun 2010 18:02:38 +0100 Subject: merge request comments applied --- src/metadata-menu-item.vala | 2 +- src/metadata-widget.c | 12 ++++++++++-- src/transport-widget.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index be078bd..82926b1 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -26,7 +26,7 @@ public class MetadataMenuitem : Dbusmenu.Menuitem public static string sanitize_image_path(string path) { string result = path.strip(); - if(result.contains("file:///")){ + if(result.has_prefix("file:///")){ result = result.slice(7, result.len()); } debug("Sanitize image path - result = %s", result); diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 357c31a..c4d3b50 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -158,10 +158,13 @@ metadata_widget_button_release_event (GtkWidget *menuitem, return TRUE; } +// TODO: Manage empty/mangled music details etc. static void metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, GValue* value, gpointer userdata) { + g_return_if_fail (IS_METADATA_WIDGET (userdata)); + MetadataWidget* mitem = METADATA_WIDGET(userdata); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(mitem); @@ -175,8 +178,13 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, gtk_label_set_text(GTK_LABEL(priv->container_label), g_value_get_string(value)); } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, property) == 0){ - priv->image_path = g_strdup(g_value_get_string(value)); - if(priv->image_path != NULL){ + if(priv->image_path != NULL){ + g_free(priv->image_path); + } + + priv->image_path = g_value_dup_string(value); + + if(priv->image_path != NULL){ update_album_art(mitem); } } diff --git a/src/transport-widget.c b/src/transport-widget.c index ce364e3..c53513d 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -170,7 +170,7 @@ transport_widget_button_press_event (GtkWidget *menuitem, gboolean state = g_ascii_strcasecmp(gtk_button_get_label(GTK_BUTTON(priv->play_button)), ">") == 0; - gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_toggle_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button))))); + gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button)))); GValue value = {0}; g_value_init(&value, G_TYPE_BOOLEAN); g_debug("TransportWidget::menu_press_event - going to send value %i", state); -- cgit v1.2.3 From f7d98d5d61055dbe05effdf35f600607203b7377 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Thu, 17 Jun 2010 14:26:03 -0400 Subject: fix distcheck --- src/Makefile.am | 11 ++++++----- tests/Makefile.am | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index ac7beb9..5a42dc6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,7 @@ libexec_PROGRAMS = indicator-sound-service soundmenulibdir = $(INDICATORDIR) soundmenulib_LTLIBRARIES = libsoundmenu.la libsoundmenu_la_SOURCES = \ - common-defs.h \ + common-defs.h \ indicator-sound.h \ transport-widget.c \ transport-widget.h \ @@ -105,8 +105,8 @@ indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_ EXTRA_DIST = \ sound-service.xml \ sound-service.list \ - $(music_bridge_la_APIFILES) \ - $(music_bridge_la_VALASOURCES) + $(music_bridge_APIFILES) \ + $(music_bridge_VALASOURCES) ####################### # Stuff to clean Stuff @@ -115,8 +115,9 @@ BUILT_SOURCES = \ music_bridge_vala.stamp \ sound-service-client.h \ sound-service-server.h \ - $(music_bridge_la_APIFILES) \ - $(music_bridge_la_VALASOURCES:.vala=.c) + music-bridge.vapi \ + $(music_bridge_APIFILES) \ + $(music_bridge_VALASOURCES:.vala=.c) CLEANFILES = \ $(BUILT_SOURCES) diff --git a/tests/Makefile.am b/tests/Makefile.am index 8d24b2b..620668e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -32,7 +32,8 @@ test_indicator_sound_CFLAGS = \ test_indicator_sound_LDADD = \ libmockpulse.la \ $(PULSEAUDIO_LIBS) \ - $(APPLET_LIBS) + $(APPLET_LIBS) \ + ../src/libsoundmenu.la ######################################### -- cgit v1.2.3 From 5e7e3b4a09d5b5ea431d6e86f40fa1229756f4a1 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 18 Jun 2010 10:02:20 +0100 Subject: reformatted old files to fix all spacing issues --- src/dbus-menu-manager.c | 220 +++++++------- src/dbus-menu-manager.h | 12 +- src/indicator-sound.c | 600 ++++++++++++++++++------------------- src/indicator-sound.h | 12 +- src/pulse-manager.c | 761 +++++++++++++++++++++++------------------------ src/pulse-manager.h | 14 +- src/slider-menu-item.c | 49 ++- src/slider-menu-item.h | 16 +- src/sound-service-dbus.c | 201 +++++++------ src/sound-service-dbus.h | 5 +- src/sound-service.c | 54 ++-- src/sound-service.h | 12 +- 12 files changed, 950 insertions(+), 1006 deletions(-) mode change 100755 => 100644 src/indicator-sound.c diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index 9d62adb..d19bfbb 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -5,16 +5,16 @@ Copyright 2010 Canonical Ltd. Authors: Conor Curran -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along +You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -27,8 +27,8 @@ with this program. If not, see . #include #include -#include "dbus-menu-manager.h" -#include "sound-service-dbus.h" +#include "dbus-menu-manager.h" +#include "sound-service-dbus.h" #include "pulse-manager.h" #include "slider-menu-item.h" @@ -53,7 +53,7 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service static void refresh_menu(); /*-------------------------------------------------------------------------*/ -// Public Methods +// Public Methods /*-------------------------------------------------------------------------*/ /** @@ -61,17 +61,17 @@ setup: **/ DbusmenuMenuitem* dbus_menu_manager_setup() { - root_menuitem = dbusmenu_menuitem_new(); - g_debug("Root ID: %d", dbusmenu_menuitem_get_id(root_menuitem)); - - g_idle_add(idle_routine, root_menuitem); + root_menuitem = dbusmenu_menuitem_new(); + g_debug("Root ID: %d", dbusmenu_menuitem_get_id(root_menuitem)); - dbus_interface = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL); + g_idle_add(idle_routine, root_menuitem); - DbusmenuServer *server = dbusmenu_server_new(INDICATOR_SOUND_DBUS_OBJECT); - dbusmenu_server_set_root(server, root_menuitem); - establish_pulse_activities(dbus_interface); - return root_menuitem; + dbus_interface = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL); + + DbusmenuServer *server = dbusmenu_server_new(INDICATOR_SOUND_DBUS_OBJECT); + dbusmenu_server_set_root(server, root_menuitem); + establish_pulse_activities(dbus_interface); + return root_menuitem; } /** @@ -79,7 +79,7 @@ teardown: **/ void dbus_menu_manager_teardown() { - //TODO tidy up dbus_interface and items! + //TODO tidy up dbus_interface and items! } /** @@ -87,25 +87,24 @@ update_pa_state: **/ void dbus_menu_manager_update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_muted, gdouble percent) { - b_sink_available = sink_available; - b_all_muted = sink_muted; - b_pulse_ready = pa_state; - volume_percent = percent; - g_debug("update pa state with state %i, availability of %i, mute value of %i and a volume percent is %f", pa_state, sink_available, sink_muted, volume_percent); - // Only rebuild the menu on start up... - if(b_startup == TRUE){ - rebuild_sound_menu(root_menuitem, dbus_interface); - b_startup = FALSE; - } - else{ - refresh_menu(); - } - // Emit the signals after the menus are setup/torn down - // preserve ordering ! - sound_service_dbus_update_sink_availability(dbus_interface, sink_available); - sound_service_dbus_update_sink_volume(dbus_interface, percent); - sound_service_dbus_update_sink_mute(dbus_interface, sink_muted); - dbus_menu_manager_update_mute_ui(b_all_muted); + b_sink_available = sink_available; + b_all_muted = sink_muted; + b_pulse_ready = pa_state; + volume_percent = percent; + g_debug("update pa state with state %i, availability of %i, mute value of %i and a volume percent is %f", pa_state, sink_available, sink_muted, volume_percent); + // Only rebuild the menu on start up... + if (b_startup == TRUE) { + rebuild_sound_menu(root_menuitem, dbus_interface); + b_startup = FALSE; + } else { + refresh_menu(); + } + // Emit the signals after the menus are setup/torn down + // preserve ordering ! + sound_service_dbus_update_sink_availability(dbus_interface, sink_available); + sound_service_dbus_update_sink_volume(dbus_interface, percent); + sound_service_dbus_update_sink_mute(dbus_interface, sink_muted); + dbus_menu_manager_update_mute_ui(b_all_muted); } /** @@ -114,46 +113,44 @@ update_mute_ui: **/ void dbus_menu_manager_update_mute_ui(gboolean incoming_mute_value) { - b_all_muted = incoming_mute_value; - dbusmenu_menuitem_property_set(mute_all_menuitem, - DBUSMENU_MENUITEM_PROP_LABEL, - b_all_muted == FALSE ? _("Mute All") : _("Unmute")); + b_all_muted = incoming_mute_value; + dbusmenu_menuitem_property_set(mute_all_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + b_all_muted == FALSE ? _("Mute All") : _("Unmute")); } /*-------------------------------------------------------------------------*/ -// Private Methods +// Private Methods /*-------------------------------------------------------------------------*/ static void refresh_menu() { - g_debug("in the refresh menu method"); - if(b_sink_available == FALSE || b_pulse_ready == FALSE) - { - - dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), - DBUSMENU_MENUITEM_PROP_ENABLED, - FALSE); - dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), - DBUSMENU_MENUITEM_PROP_VISIBLE, - FALSE); - dbusmenu_menuitem_property_set_bool(mute_all_menuitem, - DBUSMENU_MENUITEM_PROP_ENABLED, - FALSE); - - } - else if(b_sink_available == TRUE && b_pulse_ready == TRUE){ - - dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), - DBUSMENU_MENUITEM_PROP_ENABLED, - TRUE); - dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), - DBUSMENU_MENUITEM_PROP_VISIBLE, - TRUE); - dbusmenu_menuitem_property_set_bool(mute_all_menuitem, - DBUSMENU_MENUITEM_PROP_ENABLED, - TRUE); - } + g_debug("in the refresh menu method"); + if (b_sink_available == FALSE || b_pulse_ready == FALSE) { + + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_ENABLED, + FALSE); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_VISIBLE, + FALSE); + dbusmenu_menuitem_property_set_bool(mute_all_menuitem, + DBUSMENU_MENUITEM_PROP_ENABLED, + FALSE); + + } else if (b_sink_available == TRUE && b_pulse_ready == TRUE) { + + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_ENABLED, + TRUE); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_VISIBLE, + TRUE); + dbusmenu_menuitem_property_set_bool(mute_all_menuitem, + DBUSMENU_MENUITEM_PROP_ENABLED, + TRUE); + } } @@ -163,23 +160,22 @@ Something for glip mainloop to do when idle **/ static gboolean idle_routine (gpointer data) { - return FALSE; + return FALSE; } - + /** show_sound_settings_dialog: Bring up the gnome volume preferences dialog **/ -static void show_sound_settings_dialog (DbusmenuMenuitem *mi, gpointer user_data) +static void show_sound_settings_dialog (DbusmenuMenuitem *mi, gpointer user_data) { - GError * error = NULL; - if (!g_spawn_command_line_async("gnome-volume-control", &error)) - { - g_warning("Unable to show dialog: %s", error->message); - g_error_free(error); - } + GError * error = NULL; + if (!g_spawn_command_line_async("gnome-volume-control", &error)) { + g_warning("Unable to show dialog: %s", error->message); + g_error_free(error); + } } /** @@ -188,35 +184,35 @@ Build the DBus menu items, mute/unmute, slider, separator and sound preferences **/ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service) { - // Mute button - mute_all_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, b_all_muted == FALSE ? _("Mute All") : _("Unmute")); - g_signal_connect(G_OBJECT(mute_all_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(set_global_mute_from_ui), NULL); - dbusmenu_menuitem_property_set_bool(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, b_sink_available); - - // Slider - volume_slider_menuitem = slider_menu_item_new(b_sink_available, volume_percent); - dbusmenu_menuitem_child_append(root, mute_all_menuitem); - dbusmenu_menuitem_child_append(root, DBUSMENU_MENUITEM(volume_slider_menuitem)); - dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), - DBUSMENU_MENUITEM_PROP_ENABLED, - b_sink_available && !b_all_muted); - g_debug("!!!!!!**in the rebuild sound menu - slider active = %i", b_sink_available && !b_all_muted); - dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), - DBUSMENU_MENUITEM_PROP_VISIBLE, - b_sink_available); - // Separator - DbusmenuMenuitem *separator = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(root, separator); - - // Sound preferences dialog - DbusmenuMenuitem *settings_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sound Preferences...")); + // Mute button + mute_all_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, b_all_muted == FALSE ? _("Mute All") : _("Unmute")); + g_signal_connect(G_OBJECT(mute_all_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(set_global_mute_from_ui), NULL); + dbusmenu_menuitem_property_set_bool(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, b_sink_available); + + // Slider + volume_slider_menuitem = slider_menu_item_new(b_sink_available, volume_percent); + dbusmenu_menuitem_child_append(root, mute_all_menuitem); + dbusmenu_menuitem_child_append(root, DBUSMENU_MENUITEM(volume_slider_menuitem)); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_ENABLED, + b_sink_available && !b_all_muted); + g_debug("!!!!!!**in the rebuild sound menu - slider active = %i", b_sink_available && !b_all_muted); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_MENUITEM_PROP_VISIBLE, + b_sink_available); + // Separator + DbusmenuMenuitem *separator = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append(root, separator); + + // Sound preferences dialog + DbusmenuMenuitem *settings_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sound Preferences...")); //_("Sound Preferences...")); - dbusmenu_menuitem_child_append(root, settings_mi); - g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_sound_settings_dialog), NULL); + dbusmenu_menuitem_child_append(root, settings_mi); + g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_sound_settings_dialog), NULL); } /** @@ -225,11 +221,11 @@ Callback for the dbusmenuitem button **/ static void set_global_mute_from_ui() { - b_all_muted = !b_all_muted; - toggle_global_mute(b_all_muted); - dbusmenu_menuitem_property_set(mute_all_menuitem, - DBUSMENU_MENUITEM_PROP_LABEL, - b_all_muted == FALSE ? _("Mute All") : _("Unmute")); + b_all_muted = !b_all_muted; + toggle_global_mute(b_all_muted); + dbusmenu_menuitem_property_set(mute_all_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + b_all_muted == FALSE ? _("Mute All") : _("Unmute")); } diff --git a/src/dbus-menu-manager.h b/src/dbus-menu-manager.h index a5286ca..926e292 100644 --- a/src/dbus-menu-manager.h +++ b/src/dbus-menu-manager.h @@ -10,16 +10,16 @@ Copyright 2010 Canonical Ltd. Authors: Conor Curran -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along +You should have received a copy of the GNU General Public License along with this program. If not, see . */ diff --git a/src/indicator-sound.c b/src/indicator-sound.c old mode 100755 new mode 100644 index 9f7e136..3f0d2d3 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -57,14 +57,14 @@ typedef struct _IndicatorSoundClass IndicatorSoundClass; //GObject class struct struct _IndicatorSoundClass { - IndicatorObjectClass parent_class; + IndicatorObjectClass parent_class; }; //GObject instance struct struct _IndicatorSound { - IndicatorObject parent; + IndicatorObject parent; GtkWidget *slider; - IndicatorServiceManager *service; + IndicatorServiceManager *service; }; // GObject Boiler plate GType indicator_sound_get_type (void); @@ -147,27 +147,27 @@ static void free_the_animation_list(); static void indicator_sound_class_init (IndicatorSoundClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->dispose = indicator_sound_dispose; - object_class->finalize = indicator_sound_finalize; + object_class->dispose = indicator_sound_dispose; + object_class->finalize = indicator_sound_finalize; - IndicatorObjectClass *io_class = INDICATOR_OBJECT_CLASS(klass); - io_class->get_label = get_label; - io_class->get_image = get_icon; - io_class->get_menu = get_menu; + IndicatorObjectClass *io_class = INDICATOR_OBJECT_CLASS(klass); + io_class->get_label = get_label; + io_class->get_image = get_icon; + io_class->get_menu = get_menu; io_class->scroll = scroll; design_team_size = gtk_icon_size_register("design-team-size", 22, 22); - return; + return; } static void indicator_sound_init (IndicatorSound *self) { - self->service = NULL; - self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION); + self->service = NULL; + self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION); prepare_state_machine(); prepare_blocked_animation(); animation_id = 0; @@ -177,31 +177,31 @@ indicator_sound_init (IndicatorSound *self) slider_in_direct_use = FALSE; exterior_vol_update = OUT_OF_RANGE; - g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); + g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); return; } static void indicator_sound_dispose (GObject *object) { - IndicatorSound * self = INDICATOR_SOUND(object); + IndicatorSound * self = INDICATOR_SOUND(object); - if (self->service != NULL) { - g_object_unref(G_OBJECT(self->service)); - self->service = NULL; - } + if (self->service != NULL) { + g_object_unref(G_OBJECT(self->service)); + self->service = NULL; + } g_hash_table_destroy(volume_states); free_the_animation_list(); - G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object); - return; + G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object); + return; } -static void +static void free_the_animation_list() { - if(blocked_animation_list != NULL){ + if (blocked_animation_list != NULL) { g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL); g_list_free(blocked_animation_list); blocked_animation_list = NULL; @@ -211,24 +211,24 @@ free_the_animation_list() static void indicator_sound_finalize (GObject *object) { - G_OBJECT_CLASS (indicator_sound_parent_class)->finalize (object); - return; + G_OBJECT_CLASS (indicator_sound_parent_class)->finalize (object); + return; } static GtkLabel * get_label (IndicatorObject * io) { - return NULL; + return NULL; } static GtkImage * get_icon (IndicatorObject * io) -{ +{ gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); g_debug("At start-up attempting to set the image to %s", current_name); - speaker_image = indicator_image_helper(current_name); - gtk_widget_show(GTK_WIDGET(speaker_image)); - return speaker_image; + speaker_image = indicator_image_helper(current_name); + gtk_widget_show(GTK_WIDGET(speaker_image)); + return speaker_image; } /* Indicator based function to get the menu for the whole @@ -241,8 +241,8 @@ get_menu (IndicatorObject * io) DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); g_object_set_data (G_OBJECT (client), "indicator", io); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item); - dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TRANSPORT_MENUITEM_TYPE, new_transport_widget); - dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget); + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TRANSPORT_MENUITEM_TYPE, new_transport_widget); + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget); // register Key-press listening on the menu widget as the slider does not allow this. g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), NULL); @@ -253,8 +253,8 @@ static void slider_parent_changed (GtkWidget *widget, gpointer user_data) { - gtk_widget_set_size_request (widget, 200, -1); - g_debug("slider parent changed"); + gtk_widget_set_size_request (widget, 200, -1); + g_debug("slider parent changed"); } /** @@ -264,93 +264,93 @@ Create a new dBusMenu Slider item. static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { - IndicatorObject *io = NULL; + IndicatorObject *io = NULL; - g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); - g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); + g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - io = g_object_get_data (G_OBJECT (client), "indicator"); + io = g_object_get_data (G_OBJECT (client), "indicator"); - volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 1); - g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL); + volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 1); + g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL); - g_signal_connect (volume_slider, - "notify::parent", G_CALLBACK (slider_parent_changed), - NULL); + g_signal_connect (volume_slider, + "notify::parent", G_CALLBACK (slider_parent_changed), + NULL); - GtkMenuItem *menu_volume_slider = GTK_MENU_ITEM(volume_slider); + GtkMenuItem *menu_volume_slider = GTK_MENU_ITEM(volume_slider); - dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent); + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent); - // register slider changes listening on the range - GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); + // register slider changes listening on the range + GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); - INDICATOR_SOUND (io)->slider = slider; + INDICATOR_SOUND (io)->slider = slider; - g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem); - g_signal_connect(volume_slider, "slider-grabbed", G_CALLBACK(slider_grabbed), NULL); - g_signal_connect(volume_slider, "slider-released", G_CALLBACK(slider_released), NULL); - g_signal_connect(slider, "style-set", G_CALLBACK(style_changed_cb), NULL); + g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem); + g_signal_connect(volume_slider, "slider-grabbed", G_CALLBACK(slider_grabbed), NULL); + g_signal_connect(volume_slider, "slider-released", G_CALLBACK(slider_released), NULL); + g_signal_connect(slider, "style-set", G_CALLBACK(style_changed_cb), NULL); - // Set images on the ido - GtkWidget* primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); - GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO))); - gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU); - g_object_unref(primary_gicon); + // Set images on the ido + GtkWidget* primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); + GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO))); + gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU); + g_object_unref(primary_gicon); - GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); - GIcon * secondary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH))); - gtk_image_set_from_gicon(GTK_IMAGE(secondary_image), secondary_gicon, GTK_ICON_SIZE_MENU); - g_object_unref(secondary_gicon); + GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); + GIcon * secondary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH))); + gtk_image_set_from_gicon(GTK_IMAGE(secondary_image), secondary_gicon, GTK_ICON_SIZE_MENU); + g_object_unref(secondary_gicon); - gtk_widget_set_sensitive(volume_slider, !initial_mute); + gtk_widget_set_sensitive(volume_slider, !initial_mute); - GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (slider)); - gtk_adjustment_set_step_increment(adj, 3); + GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (slider)); + gtk_adjustment_set_step_increment(adj, 3); - gtk_widget_show_all(volume_slider); + gtk_widget_show_all(volume_slider); - return TRUE; + return TRUE; } static gboolean new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { - g_debug("indicator-sound: new_transport_bar() called "); + g_debug("indicator-sound: new_transport_bar() called "); + + GtkWidget* bar = NULL; - GtkWidget* bar = NULL; - - g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - bar = transport_widget_new(newitem); + bar = transport_widget_new(newitem); GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_transport_bar, parent); - - gtk_widget_show_all(bar); - - return TRUE; + + gtk_widget_show_all(bar); + + return TRUE; } static gboolean new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { - g_debug("indicator-sound: new_metadata_widget"); + g_debug("indicator-sound: new_metadata_widget"); - GtkWidget* metadata = NULL; + GtkWidget* metadata = NULL; - g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - metadata = metadata_widget_new (newitem); - GtkMenuItem *menu_metadata_widget = GTK_MENU_ITEM(metadata); - + metadata = metadata_widget_new (newitem); + GtkMenuItem *menu_metadata_widget = GTK_MENU_ITEM(metadata); + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_metadata_widget, parent); - gtk_widget_show_all(metadata); + gtk_widget_show_all(metadata); - return TRUE; + return TRUE; } //const gchar* path = dbusmenu_menuitem_property_get(new_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH); @@ -361,62 +361,62 @@ new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata) { - if (connected) { - if (sound_dbus_proxy == NULL) { - GError * error = NULL; - - DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - - sound_dbus_proxy = dbus_g_proxy_new_for_name_owner(sbus, - INDICATOR_SOUND_DBUS_NAME, - INDICATOR_SOUND_SERVICE_DBUS_OBJECT, - INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, - &error); + if (connected) { + if (sound_dbus_proxy == NULL) { + GError * error = NULL; - if (error != NULL) { - g_warning("Unable to get status proxy: %s", error->message); - g_error_free(error); - } - g_debug("about to connect to the signals"); - dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_TYPE_BOOLEAN, G_TYPE_INVALID); + DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_CALLBACK(catch_signal_sink_input_while_muted), NULL, NULL); - dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_TYPE_DOUBLE, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_CALLBACK(catch_signal_sink_volume_update), NULL, NULL); - dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_CALLBACK(catch_signal_sink_mute_update), NULL, NULL); - dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_CALLBACK(catch_signal_sink_availability_update), NULL, NULL); + sound_dbus_proxy = dbus_g_proxy_new_for_name_owner(sbus, + INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_SERVICE_DBUS_OBJECT, + INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, + &error); - // Ensure we are in a coherent state with the service at start up. - // Preserve ordering! - fetch_volume_percent_from_dbus(); - fetch_mute_value_from_dbus(); - fetch_sink_availability_from_dbus(); - } + if (error != NULL) { + g_warning("Unable to get status proxy: %s", error->message); + g_error_free(error); + } + g_debug("about to connect to the signals"); + dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_TYPE_BOOLEAN, G_TYPE_INVALID); + + dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_CALLBACK(catch_signal_sink_input_while_muted), NULL, NULL); + dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_TYPE_DOUBLE, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_CALLBACK(catch_signal_sink_volume_update), NULL, NULL); + dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_CALLBACK(catch_signal_sink_mute_update), NULL, NULL); + dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_CALLBACK(catch_signal_sink_availability_update), NULL, NULL); + + // Ensure we are in a coherent state with the service at start up. + // Preserve ordering! + fetch_volume_percent_from_dbus(); + fetch_mute_value_from_dbus(); + fetch_sink_availability_from_dbus(); + } - } else { - //TODO : will need to handle this scenario - // Not much can we do here really, if there is no dbus connection tis goosed. - } + } else { + //TODO : will need to handle this scenario + // Not much can we do here really, if there is no dbus connection tis goosed. + } - return; + return; } /* Prepare states Array. */ -void +void prepare_state_machine() { - volume_states = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED), g_strdup("audio-volume-muted-panel")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_ZERO), g_strdup("audio-volume-low-zero-panel")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_LOW), g_strdup("audio-volume-low-panel")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MEDIUM), g_strdup("audio-volume-medium-panel")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_HIGH), g_strdup("audio-volume-high-panel")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT), g_strdup("audio-volume-muted-blocking-panel")); - g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_SINKS_NONE), g_strdup("audio-output-none-panel")); + volume_states = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED), g_strdup("audio-volume-muted-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_ZERO), g_strdup("audio-volume-low-zero-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_LOW), g_strdup("audio-volume-low-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MEDIUM), g_strdup("audio-volume-medium-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_HIGH), g_strdup("audio-volume-high-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT), g_strdup("audio-volume-muted-blocking-panel")); + g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_SINKS_NONE), g_strdup("audio-output-none-panel")); } /* @@ -436,7 +436,7 @@ prepare_blocked_animation() temp_image = indicator_image_helper(blocked_name); GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image); - if(mute_buf == NULL || blocked_buf == NULL){ + if (mute_buf == NULL || blocked_buf == NULL) { g_debug("Don bother with the animation, the theme aint got the goods !"); return; } @@ -444,8 +444,7 @@ prepare_blocked_animation() int i; // sample 51 snapshots - range : 0-256 - for(i = 0; i < 51; i++) - { + for (i = 0; i < 51; i++) { gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0, gdk_pixbuf_get_width(mute_buf), gdk_pixbuf_get_height(mute_buf), @@ -453,9 +452,9 @@ prepare_blocked_animation() blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf)); } g_object_ref_sink(mute_buf); - g_object_unref(mute_buf); + g_object_unref(mute_buf); g_object_ref_sink(blocked_buf); - g_object_unref(blocked_buf); + g_object_unref(blocked_buf); } @@ -487,11 +486,11 @@ tidy_up_hash() static void update_state(const gint state) { -/* g_debug("update state beginning - previous_state = %i", previous_state);*/ + /* g_debug("update state beginning - previous_state = %i", previous_state);*/ previous_state = current_state; -/* g_debug("update state 3rd line - previous_state = %i", previous_state);*/ + /* g_debug("update state 3rd line - previous_state = %i", previous_state);*/ current_state = state; gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); @@ -502,51 +501,46 @@ update_state(const gint state) void determine_state_from_volume(gdouble volume_percent) { -/* g_debug("determine_state_from_volume - previous_state = %i", previous_state);*/ - if (device_available == FALSE) - return; - gint state = previous_state; - if (volume_percent < 30.0 && volume_percent > 0){ - state = STATE_LOW; - } - else if(volume_percent < 70.0 && volume_percent >= 30.0){ - state = STATE_MEDIUM; - } - else if(volume_percent >= 70.0){ - state = STATE_HIGH; - } - else if(volume_percent == 0.0){ - state = STATE_ZERO; - } - update_state(state); + /* g_debug("determine_state_from_volume - previous_state = %i", previous_state);*/ + if (device_available == FALSE) + return; + gint state = previous_state; + if (volume_percent < 30.0 && volume_percent > 0) { + state = STATE_LOW; + } else if (volume_percent < 70.0 && volume_percent >= 30.0) { + state = STATE_MEDIUM; + } else if (volume_percent >= 70.0) { + state = STATE_HIGH; + } else if (volume_percent == 0.0) { + state = STATE_ZERO; + } + update_state(state); } static gboolean start_animation() { - blocked_iter = blocked_animation_list; - blocked_id = 0; - g_debug("exit from blocked hold start the animation\n"); - animation_id = g_timeout_add(50, fade_back_to_mute_image, NULL); - return FALSE; + blocked_iter = blocked_animation_list; + blocked_id = 0; + g_debug("exit from blocked hold start the animation\n"); + animation_id = g_timeout_add(50, fade_back_to_mute_image, NULL); + return FALSE; } static gboolean fade_back_to_mute_image() { - if(blocked_iter != NULL) - { - g_debug("in animation 'loop'\n"); - gtk_image_set_from_pixbuf(speaker_image, blocked_iter->data); - blocked_iter = blocked_iter->next; - return TRUE; - } - else{ - animation_id = 0; - g_debug("exit from animation now\n"); - return FALSE; - } + if (blocked_iter != NULL) { + g_debug("in animation 'loop'\n"); + gtk_image_set_from_pixbuf(speaker_image, blocked_iter->data); + blocked_iter = blocked_iter->next; + return TRUE; + } else { + animation_id = 0; + g_debug("exit from animation now\n"); + return FALSE; + } } /*******************************************************************/ @@ -555,67 +549,67 @@ fade_back_to_mute_image() static void fetch_sink_availability_from_dbus() { - GError * error = NULL; - gboolean * available_input; - available_input = g_new0(gboolean, 1); - org_ayatana_indicator_sound_get_sink_availability(sound_dbus_proxy, available_input, &error); - if (error != NULL) { - g_warning("Unable to fetch AVAILABILITY at indicator start up: %s", error->message); - g_error_free(error); - g_free(available_input); - return; - } - device_available = *available_input; - if (device_available == FALSE){ - update_state(STATE_SINKS_NONE); - g_debug("NO DEVICE AVAILABLE"); - } - - if (GTK_IS_WIDGET (volume_slider)) - gtk_widget_set_sensitive(volume_slider, device_available); - + GError * error = NULL; + gboolean * available_input; + available_input = g_new0(gboolean, 1); + org_ayatana_indicator_sound_get_sink_availability(sound_dbus_proxy, available_input, &error); + if (error != NULL) { + g_warning("Unable to fetch AVAILABILITY at indicator start up: %s", error->message); + g_error_free(error); g_free(available_input); - g_debug("IndicatorSound::fetch_sink_availability_from_dbus -> AVAILABILTY returned from dbus method is %i", device_available); + return; + } + device_available = *available_input; + if (device_available == FALSE) { + update_state(STATE_SINKS_NONE); + g_debug("NO DEVICE AVAILABLE"); + } + + if (GTK_IS_WIDGET (volume_slider)) + gtk_widget_set_sensitive(volume_slider, device_available); + + g_free(available_input); + g_debug("IndicatorSound::fetch_sink_availability_from_dbus -> AVAILABILTY returned from dbus method is %i", device_available); } -static void +static void fetch_volume_percent_from_dbus() { - GError * error = NULL; - gdouble *volume_percent_input; - volume_percent_input = g_new0(gdouble, 1); - org_ayatana_indicator_sound_get_sink_volume(sound_dbus_proxy, volume_percent_input, &error); - if (error != NULL) { - g_warning("Unable to fetch VOLUME at indicator start up: %s", error->message); - g_error_free(error); - g_free(volume_percent_input); - return; - } - initial_volume_percent = *volume_percent_input; - determine_state_from_volume(initial_volume_percent); + GError * error = NULL; + gdouble *volume_percent_input; + volume_percent_input = g_new0(gdouble, 1); + org_ayatana_indicator_sound_get_sink_volume(sound_dbus_proxy, volume_percent_input, &error); + if (error != NULL) { + g_warning("Unable to fetch VOLUME at indicator start up: %s", error->message); + g_error_free(error); g_free(volume_percent_input); - g_debug("at the indicator start up and the volume percent returned from dbus method is %f", initial_volume_percent); + return; + } + initial_volume_percent = *volume_percent_input; + determine_state_from_volume(initial_volume_percent); + g_free(volume_percent_input); + g_debug("at the indicator start up and the volume percent returned from dbus method is %f", initial_volume_percent); } -static void +static void fetch_mute_value_from_dbus() { - GError * error = NULL; - gboolean *mute_input; - mute_input = g_new0(gboolean, 1); - org_ayatana_indicator_sound_get_sink_mute(sound_dbus_proxy, mute_input, &error); - if (error != NULL) { - g_warning("Unable to fetch MUTE at indicator start up: %s", error->message); - g_error_free(error); - g_free(mute_input); - return; - } - initial_mute = *mute_input; - if (initial_mute == TRUE) - update_state(STATE_MUTED); + GError * error = NULL; + gboolean *mute_input; + mute_input = g_new0(gboolean, 1); + org_ayatana_indicator_sound_get_sink_mute(sound_dbus_proxy, mute_input, &error); + if (error != NULL) { + g_warning("Unable to fetch MUTE at indicator start up: %s", error->message); + g_error_free(error); g_free(mute_input); - g_debug("at the indicator start up and the MUTE returned from dbus method is %i", initial_mute); + return; + } + initial_mute = *mute_input; + if (initial_mute == TRUE) + update_state(STATE_MUTED); + g_free(mute_input); + g_debug("at the indicator start up and the MUTE returned from dbus method is %i", initial_mute); } /*******************************************************************/ @@ -624,70 +618,68 @@ fetch_mute_value_from_dbus() static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gpointer userdata) { - g_debug("signal caught - sink input while muted with value %i", block_value); - if (block_value == 1 && blocked_id == 0 && animation_id == 0 && blocked_animation_list != NULL) { - gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); - indicator_image_helper_update(speaker_image, image_name); - blocked_id = g_timeout_add_seconds(5, start_animation, NULL); - } + g_debug("signal caught - sink input while muted with value %i", block_value); + if (block_value == 1 && blocked_id == 0 && animation_id == 0 && blocked_animation_list != NULL) { + gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); + indicator_image_helper_update(speaker_image, image_name); + blocked_id = g_timeout_add_seconds(5, start_animation, NULL); + } } static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_percent, gpointer userdata) { - if (slider_in_direct_use == FALSE){ - GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); - GtkRange *range = (GtkRange*)slider; + if (slider_in_direct_use == FALSE) { + GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); + GtkRange *range = (GtkRange*)slider; - // DEBUG - gdouble current_value = gtk_range_get_value(range); - g_debug("SIGNAL- update sink volume - current_value : %f and new value : %f", current_value, volume_percent); - exterior_vol_update = volume_percent; - gtk_range_set_value(range, volume_percent); - determine_state_from_volume(volume_percent); - } + // DEBUG + gdouble current_value = gtk_range_get_value(range); + g_debug("SIGNAL- update sink volume - current_value : %f and new value : %f", current_value, volume_percent); + exterior_vol_update = volume_percent; + gtk_range_set_value(range, volume_percent); + determine_state_from_volume(volume_percent); + } } static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata) { - //We can be sure the service won't send a mute signal unless it has changed ! - //UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here. - if(mute_value == TRUE && device_available == TRUE) - { - update_state(STATE_MUTED); - } - else{ - reset_mute_blocking_animation(); - } - g_debug("signal caught - sink mute update with mute value: %i", mute_value); - gtk_widget_set_sensitive(volume_slider, !mute_value); + //We can be sure the service won't send a mute signal unless it has changed ! + //UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here. + if (mute_value == TRUE && device_available == TRUE) { + update_state(STATE_MUTED); + } else { + reset_mute_blocking_animation(); + } + g_debug("signal caught - sink mute update with mute value: %i", mute_value); + gtk_widget_set_sensitive(volume_slider, !mute_value); } static void reset_mute_blocking_animation() { - if(animation_id != 0){ - g_debug("about to remove the animation_id callback from the mainloop!!**"); - g_source_remove(animation_id); - animation_id = 0; - } - if(blocked_id != 0){ - g_debug("about to remove the blocked_id callback from the mainloop!!**"); - g_source_remove(blocked_id); - blocked_id = 0; - } + if (animation_id != 0) { + g_debug("about to remove the animation_id callback from the mainloop!!**"); + g_source_remove(animation_id); + animation_id = 0; + } + if (blocked_id != 0) { + g_debug("about to remove the blocked_id callback from the mainloop!!**"); + g_source_remove(blocked_id); + blocked_id = 0; + } } static void catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_value, gpointer userdata) { - device_available = available_value; - if (device_available == FALSE){ - update_state(STATE_SINKS_NONE); - } - g_debug("signal caught - sink availability update with value: %i", available_value); + device_available = available_value; + if (device_available == FALSE) { + update_state(STATE_SINKS_NONE); + } + g_debug("signal caught - sink availability update with value: %i", available_value); } @@ -703,36 +695,36 @@ This callback will get triggered irregardless of whether its a user change or a static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data) { - gdouble current_value = CLAMP(gtk_range_get_value(range), 0, 100); - if(current_value == exterior_vol_update){ - g_debug("ignore the value changed event - its come from the outside"); - return FALSE; - } - DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; - GValue value = {0}; - g_value_init(&value, G_TYPE_DOUBLE); - g_value_set_double(&value, current_value); - g_debug("Value changed callback - = %f", current_value); - dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0); - // This is not ideal in that the icon ui will update on ui actions and not on actual service feedback. - // but necessary for now as the server does not send volume update information if the source of change was this ui. - determine_state_from_volume(current_value); + gdouble current_value = CLAMP(gtk_range_get_value(range), 0, 100); + if (current_value == exterior_vol_update) { + g_debug("ignore the value changed event - its come from the outside"); return FALSE; + } + DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; + GValue value = {0}; + g_value_init(&value, G_TYPE_DOUBLE); + g_value_set_double(&value, current_value); + g_debug("Value changed callback - = %f", current_value); + dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0); + // This is not ideal in that the icon ui will update on ui actions and not on actual service feedback. + // but necessary for now as the server does not send volume update information if the source of change was this ui. + determine_state_from_volume(current_value); + return FALSE; } static void slider_grabbed (GtkWidget *widget, gpointer user_data) { - slider_in_direct_use = TRUE; - g_debug ("!!!!!! grabbed\n"); + slider_in_direct_use = TRUE; + g_debug ("!!!!!! grabbed\n"); } static void slider_released (GtkWidget *widget, gpointer user_data) { - slider_in_direct_use = FALSE; - g_debug ("!!!!!! released\n"); + slider_in_direct_use = FALSE; + g_debug ("!!!!!! released\n"); } @@ -752,30 +744,22 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) GtkWidget *menuitem; menuitem = GTK_MENU_SHELL (widget)->active_menu_item; - if(IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE) - { - switch(event->keyval) - { + if (IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE) { + switch (event->keyval) { case GDK_Right: - digested = TRUE; - if(event->state & GDK_CONTROL_MASK) - { - new_value = 100; - } - else - { + digested = TRUE; + if (event->state & GDK_CONTROL_MASK) { + new_value = 100; + } else { new_value = current_value + five_percent; - } - break; - case GDK_Left: - digested = TRUE; - if(event->state & GDK_CONTROL_MASK) - { - new_value = 0; } - else - { - new_value = current_value - five_percent; + break; + case GDK_Left: + digested = TRUE; + if (event->state & GDK_CONTROL_MASK) { + new_value = 0; + } else { + new_value = current_value - five_percent; } break; case GDK_plus: @@ -791,11 +775,10 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) } new_value = CLAMP(new_value, 0, 100); - if(new_value != current_value && current_state != STATE_MUTED) - { + if (new_value != current_value && current_state != STATE_MUTED) { g_debug("Attempting to set the range from the key listener to %f", new_value); // In order to ensure that the exterior filtering does not catch this, reset the exterior_vol_update - // to ensure these updates. + // to ensure these updates. exterior_vol_update = OUT_OF_RANGE; gtk_range_set_value(range, new_value); } @@ -817,18 +800,17 @@ style_changed_cb(GtkWidget *widget, gpointer user_data) static void scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction) { - if (device_available == FALSE || current_state == STATE_MUTED) - return; + if (device_available == FALSE || current_state == STATE_MUTED) + return; IndicatorSound *sound = INDICATOR_SOUND (io); GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (sound->slider)); gdouble value = gtk_range_get_value (GTK_RANGE (sound->slider)); - - if (direction == INDICATOR_OBJECT_SCROLL_UP){ - value += adj->step_increment; - } - else{ - value -= adj->step_increment; + + if (direction == INDICATOR_OBJECT_SCROLL_UP) { + value += adj->step_increment; + } else { + value -= adj->step_increment; } gtk_range_set_value (GTK_RANGE (sound->slider), value); } diff --git a/src/indicator-sound.h b/src/indicator-sound.h index e508390..386ad2a 100644 --- a/src/indicator-sound.h +++ b/src/indicator-sound.h @@ -11,16 +11,16 @@ Authors: Conor Curran Ted Gould -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along +You should have received a copy of the GNU General Public License along with this program. If not, see . */ diff --git a/src/pulse-manager.c b/src/pulse-manager.c index 7323797..a9a47e4 100644 --- a/src/pulse-manager.c +++ b/src/pulse-manager.c @@ -50,7 +50,7 @@ static pa_cvolume construct_mono_volume(const pa_cvolume* vol); /** Future Refactoring notes - - Push all UI updates out through update PA state in the service. + - Push all UI updates out through update PA state in the service. - Collapse 3 update_sink_info into one. The essentially do the same thing from different contexts. **/ @@ -59,18 +59,18 @@ Entry point **/ void establish_pulse_activities(SoundServiceDbus *service) { - dbus_service = service; - pa_main_loop = pa_glib_mainloop_new(g_main_context_default()); - g_assert(pa_main_loop); - pulse_context = pa_context_new(pa_glib_mainloop_get_api(pa_main_loop), "ayatana.indicator.sound"); - g_assert(pulse_context); - - sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info); - - // Establish event callback registration - pa_context_set_state_callback(pulse_context, context_state_callback, NULL); - dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0); - pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL); + dbus_service = service; + pa_main_loop = pa_glib_mainloop_new(g_main_context_default()); + g_assert(pa_main_loop); + pulse_context = pa_context_new(pa_glib_mainloop_get_api(pa_main_loop), "ayatana.indicator.sound"); + g_assert(pulse_context); + + sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info); + + // Establish event callback registration + pa_context_set_state_callback(pulse_context, context_state_callback, NULL); + dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0); + pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL); } /** @@ -79,7 +79,7 @@ Needed for testing - bah! **/ pa_context* get_context() { - return pulse_context; + return pulse_context; } /** @@ -88,44 +88,44 @@ Gracefully close our connection with the Pulse async library. **/ void close_pulse_activites() { - if (pulse_context != NULL){ -/* g_debug("freeing the pulse context");*/ - pa_context_unref(pulse_context); - pulse_context = NULL; - } - g_hash_table_destroy(sink_hash); - pa_glib_mainloop_free(pa_main_loop); - pa_main_loop = NULL; -/* g_debug("I just closed communication with Pulse");*/ + if (pulse_context != NULL) { + /* g_debug("freeing the pulse context");*/ + pa_context_unref(pulse_context); + pulse_context = NULL; + } + g_hash_table_destroy(sink_hash); + pa_glib_mainloop_free(pa_main_loop); + pa_main_loop = NULL; + /* g_debug("I just closed communication with Pulse");*/ } -/** +/** reconnect_to_pulse() In the event of Pulseaudio flapping in the wind handle gracefully without memory leaks ! */ static void reconnect_to_pulse() { - // reset - if (pulse_context != NULL){ - g_debug("freeing the pulse context"); - pa_context_unref(pulse_context); - pulse_context = NULL; - } - - if(sink_hash != NULL){ - g_hash_table_destroy(sink_hash); - sink_hash = NULL; - } - - // reconnect - pulse_context = pa_context_new(pa_glib_mainloop_get_api(pa_main_loop), "ayatana.indicator.sound"); - g_assert(pulse_context); - sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info); - // Establish event callback registration - pa_context_set_state_callback(pulse_context, context_state_callback, NULL); - dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0); - pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL); + // reset + if (pulse_context != NULL) { + g_debug("freeing the pulse context"); + pa_context_unref(pulse_context); + pulse_context = NULL; + } + + if (sink_hash != NULL) { + g_hash_table_destroy(sink_hash); + sink_hash = NULL; + } + + // reconnect + pulse_context = pa_context_new(pa_glib_mainloop_get_api(pa_main_loop), "ayatana.indicator.sound"); + g_assert(pulse_context); + sink_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_sink_info); + // Establish event callback registration + pa_context_set_state_callback(pulse_context, context_state_callback, NULL); + dbus_menu_manager_update_pa_state(FALSE, FALSE, FALSE, 0); + pa_context_connect(pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL); } /** @@ -134,9 +134,9 @@ item destructor method for the sink_info hash **/ static void destroy_sink_info(void *value) { - sink_info *sink = (sink_info*)value; - g_free(sink->name); - g_free(sink); + sink_info *sink = (sink_info*)value; + g_free(sink->name); + g_free(sink); } /* @@ -144,125 +144,122 @@ Controllers & Utilities */ static gboolean determine_sink_availability() { - // Firstly check to see if we have any sinks - // if not get the hell out of here ! - if (g_hash_table_size(sink_hash) < 1){ -/* g_debug("Sink_available returning false because sinks_hash is empty !!!"); */ - DEFAULT_SINK_INDEX = -1; - return FALSE; - } - // Secondly, make sure the default sink index is set - // If the default sink index has not been set - // (via the server or has been reset because default sink has been removed), - // it will attempt to set it to the value of the first - // index in the array of keys from the sink_hash. - GList* keys = g_hash_table_get_keys(sink_hash); - GList* key = g_list_first(keys); - - DEFAULT_SINK_INDEX = (DEFAULT_SINK_INDEX < 0) ? GPOINTER_TO_INT(key->data) : DEFAULT_SINK_INDEX; - - // Thirdly ensure the default sink index does not have the name "auto_null" - sink_info* s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); - // Up until now the most rebust method to test this is to manually remove the available sink device - // kernel module and then reload (rmmod & modprobe). - // TODO: Edge case of dynamic loading and unloading of sinks should be handled also. -/* g_debug("About to test for to see if the available sink is null - s->name = %s", s->name);*/ - gboolean available = g_ascii_strncasecmp("auto_null", s->name, 9) != 0; -/* g_debug("PA_Manager -> determine_sink_availability: %i", available);*/ - return available; + // Firstly check to see if we have any sinks + // if not get the hell out of here ! + if (g_hash_table_size(sink_hash) < 1) { + /* g_debug("Sink_available returning false because sinks_hash is empty !!!"); */ + DEFAULT_SINK_INDEX = -1; + return FALSE; + } + // Secondly, make sure the default sink index is set + // If the default sink index has not been set + // (via the server or has been reset because default sink has been removed), + // it will attempt to set it to the value of the first + // index in the array of keys from the sink_hash. + GList* keys = g_hash_table_get_keys(sink_hash); + GList* key = g_list_first(keys); + + DEFAULT_SINK_INDEX = (DEFAULT_SINK_INDEX < 0) ? GPOINTER_TO_INT(key->data) : DEFAULT_SINK_INDEX; + + // Thirdly ensure the default sink index does not have the name "auto_null" + sink_info* s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); + // Up until now the most rebust method to test this is to manually remove the available sink device + // kernel module and then reload (rmmod & modprobe). + // TODO: Edge case of dynamic loading and unloading of sinks should be handled also. + /* g_debug("About to test for to see if the available sink is null - s->name = %s", s->name);*/ + gboolean available = g_ascii_strncasecmp("auto_null", s->name, 9) != 0; + /* g_debug("PA_Manager -> determine_sink_availability: %i", available);*/ + return available; } static gboolean default_sink_is_muted() { - if(DEFAULT_SINK_INDEX < 0) - return FALSE; - if (g_hash_table_size(sink_hash) < 1) - return FALSE; - sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); - return s->mute; + if (DEFAULT_SINK_INDEX < 0) + return FALSE; + if (g_hash_table_size(sink_hash) < 1) + return FALSE; + sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); + return s->mute; } static void check_sink_input_while_muted_event(gint sink_index) { -/* g_debug("SINKINPUTWHILEMUTED SIGNAL EVENT TO BE SENT FROM PA MANAGER - check trace for value");*/ + /* g_debug("SINKINPUTWHILEMUTED SIGNAL EVENT TO BE SENT FROM PA MANAGER - check trace for value");*/ - if (default_sink_is_muted(sink_index) == TRUE){ - sound_service_dbus_sink_input_while_muted (dbus_service, TRUE); - } - else{ - sound_service_dbus_sink_input_while_muted(dbus_service, FALSE); - } + if (default_sink_is_muted(sink_index) == TRUE) { + sound_service_dbus_sink_input_while_muted (dbus_service, TRUE); + } else { + sound_service_dbus_sink_input_while_muted(dbus_service, FALSE); + } } static gdouble get_default_sink_volume() { - if (DEFAULT_SINK_INDEX < 0) - return 0; - sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); - pa_volume_t vol = pa_cvolume_avg(&s->volume); - gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; -/* g_debug("software volume = %f", volume_percent);*/ - return volume_percent; + if (DEFAULT_SINK_INDEX < 0) + return 0; + sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); + pa_volume_t vol = pa_cvolume_avg(&s->volume); + gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; + /* g_debug("software volume = %f", volume_percent);*/ + return volume_percent; } static void mute_each_sink(gpointer key, gpointer value, gpointer user_data) { - sink_info *info = (sink_info*)value; - pa_operation_unref(pa_context_set_sink_mute_by_index(pulse_context, info->index, GPOINTER_TO_INT(user_data), context_success_callback, NULL)); - if(GPOINTER_TO_INT(user_data) == 1){ - sound_service_dbus_update_sink_mute(dbus_service, TRUE); - } - else{ - sound_service_dbus_update_sink_volume(dbus_service, get_default_sink_volume()); - } - -/* g_debug("in the pulse manager: mute each sink %i", GPOINTER_TO_INT(user_data));*/ + sink_info *info = (sink_info*)value; + pa_operation_unref(pa_context_set_sink_mute_by_index(pulse_context, info->index, GPOINTER_TO_INT(user_data), context_success_callback, NULL)); + if (GPOINTER_TO_INT(user_data) == 1) { + sound_service_dbus_update_sink_mute(dbus_service, TRUE); + } else { + sound_service_dbus_update_sink_volume(dbus_service, get_default_sink_volume()); + } + + /* g_debug("in the pulse manager: mute each sink %i", GPOINTER_TO_INT(user_data));*/ } void toggle_global_mute(gboolean mute_value) { - g_hash_table_foreach(sink_hash, mute_each_sink, GINT_TO_POINTER(mute_value)); -/* g_debug("in the pulse manager: toggle global mute value %i", mute_value);*/ + g_hash_table_foreach(sink_hash, mute_each_sink, GINT_TO_POINTER(mute_value)); + /* g_debug("in the pulse manager: toggle global mute value %i", mute_value);*/ } /* -Refine the resolution of the slider or binary scale it to achieve a more subtle volume control. -Use the base volume stored in the sink struct to calculate actual linear volumes. +Refine the resolution of the slider or binary scale it to achieve a more subtle volume control. +Use the base volume stored in the sink struct to calculate actual linear volumes. */ void set_sink_volume(gdouble percent) { - if(pa_server_available == FALSE) - return; -/* g_debug("in the pulse manager:set_sink_volume with percent %f", percent);*/ - - if(DEFAULT_SINK_INDEX < 0) - { - g_warning("We have no default sink !!! - returning after not attempting to set any volume of any sink"); - return; - } + if (pa_server_available == FALSE) + return; + /* g_debug("in the pulse manager:set_sink_volume with percent %f", percent);*/ + + if (DEFAULT_SINK_INDEX < 0) { + g_warning("We have no default sink !!! - returning after not attempting to set any volume of any sink"); + return; + } - sink_info *cached_sink = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); + sink_info *cached_sink = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); - pa_cvolume new_volume; - pa_cvolume_init(&new_volume); - new_volume.channels = 1; - pa_volume_t new_volume_value = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100); - pa_cvolume_set(&new_volume, 1, new_volume_value); - pa_cvolume_set(&cached_sink->volume, cached_sink->channel_map.channels, new_volume_value); - pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &new_volume, NULL, NULL)); + pa_cvolume new_volume; + pa_cvolume_init(&new_volume); + new_volume.channels = 1; + pa_volume_t new_volume_value = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100); + pa_cvolume_set(&new_volume, 1, new_volume_value); + pa_cvolume_set(&cached_sink->volume, cached_sink->channel_map.channels, new_volume_value); + pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &new_volume, NULL, NULL)); } static pa_cvolume construct_mono_volume(const pa_cvolume* vol) { - pa_cvolume new_volume; - pa_cvolume_init(&new_volume); - new_volume.channels = 1; - pa_volume_t max_vol = pa_cvolume_max(vol); - pa_cvolume_set(&new_volume, 1, max_vol); - return new_volume; -} + pa_cvolume new_volume; + pa_cvolume_init(&new_volume); + new_volume.channels = 1; + pa_volume_t max_vol = pa_cvolume_max(vol); + pa_cvolume_set(&new_volume, 1, max_vol); + return new_volume; +} /**********************************************************************************************************************/ // Pulse-Audio asychronous call-backs @@ -270,24 +267,22 @@ static pa_cvolume construct_mono_volume(const pa_cvolume* vol) static void gather_pulse_information(pa_context *c, void *userdata) { - pa_operation *operation; - if(!(operation = pa_context_get_server_info(c, pulse_server_info_callback, userdata))) - { - g_warning("pa_context_get_server_info failed"); - if (!(operation = pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL))) - { - g_warning("pa_context_get_sink_info_list() failed - cannot fetch server or sink info - leaving . . ."); - return; - } + pa_operation *operation; + if (!(operation = pa_context_get_server_info(c, pulse_server_info_callback, userdata))) { + g_warning("pa_context_get_server_info failed"); + if (!(operation = pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL))) { + g_warning("pa_context_get_sink_info_list() failed - cannot fetch server or sink info - leaving . . ."); + return; } - pa_operation_unref(operation); - return; + } + pa_operation_unref(operation); + return; } static void context_success_callback(pa_context *c, int success, void *userdata) { -/* g_debug("Context Success Callback - result = %i", success);*/ + /* g_debug("Context Success Callback - result = %i", success);*/ } /** @@ -298,296 +293,270 @@ Major candidate for refactoring. **/ static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, int eol, void *userdata) { - if (eol > 0) { - - gboolean device_available = determine_sink_availability(); - if(device_available == TRUE) - { - dbus_menu_manager_update_pa_state(TRUE, - device_available, - default_sink_is_muted(), - get_default_sink_volume()); - } - else{ - //Update the indicator to show PA either is not ready or has no available sink - g_warning("Cannot find a suitable default sink ..."); - dbus_menu_manager_update_pa_state(FALSE, device_available, default_sink_is_muted(), get_default_sink_volume()); - } - } - else{ -/* g_debug("About to add an item to our hash");*/ - sink_info *value; - value = g_new0(sink_info, 1); - value->index = sink->index; - value->name = g_strdup(sink->name); - value->mute = !!sink->mute; - value->volume = construct_mono_volume(&sink->volume); - value->base_volume = sink->base_volume; - value->channel_map = sink->channel_map; - g_hash_table_insert(sink_hash, GINT_TO_POINTER(sink->index), value); -/* g_debug("After adding an item to our hash");*/ + if (eol > 0) { + + gboolean device_available = determine_sink_availability(); + if (device_available == TRUE) { + dbus_menu_manager_update_pa_state(TRUE, + device_available, + default_sink_is_muted(), + get_default_sink_volume()); + } else { + //Update the indicator to show PA either is not ready or has no available sink + g_warning("Cannot find a suitable default sink ..."); + dbus_menu_manager_update_pa_state(FALSE, device_available, default_sink_is_muted(), get_default_sink_volume()); } + } else { + /* g_debug("About to add an item to our hash");*/ + sink_info *value; + value = g_new0(sink_info, 1); + value->index = sink->index; + value->name = g_strdup(sink->name); + value->mute = !!sink->mute; + value->volume = construct_mono_volume(&sink->volume); + value->base_volume = sink->base_volume; + value->channel_map = sink->channel_map; + g_hash_table_insert(sink_hash, GINT_TO_POINTER(sink->index), value); + /* g_debug("After adding an item to our hash");*/ + } } static void pulse_default_sink_info_callback(pa_context *c, const pa_sink_info *info, int eol, void *userdata) { - if (eol > 0) { - if (pa_context_errno(c) == PA_ERR_NOENTITY) - return; - g_warning("Default Sink info callback failure"); - return; - } - else{ - DEFAULT_SINK_INDEX = info->index; -/* g_debug("Just set the default sink index to %i", DEFAULT_SINK_INDEX); */ - GList *keys = g_hash_table_get_keys(sink_hash); - gint position = g_list_index(keys, GINT_TO_POINTER(info->index)); - // Only update sink-list if the index is not in our already fetched list. - if(position < 0) - { - pa_operation_unref(pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL)); - } - else - { - dbus_menu_manager_update_pa_state(TRUE, determine_sink_availability(), default_sink_is_muted(), get_default_sink_volume()); - } + if (eol > 0) { + if (pa_context_errno(c) == PA_ERR_NOENTITY) + return; + g_warning("Default Sink info callback failure"); + return; + } else { + DEFAULT_SINK_INDEX = info->index; + /* g_debug("Just set the default sink index to %i", DEFAULT_SINK_INDEX); */ + GList *keys = g_hash_table_get_keys(sink_hash); + gint position = g_list_index(keys, GINT_TO_POINTER(info->index)); + // Only update sink-list if the index is not in our already fetched list. + if (position < 0) { + pa_operation_unref(pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL)); + } else { + dbus_menu_manager_update_pa_state(TRUE, determine_sink_availability(), default_sink_is_muted(), get_default_sink_volume()); } + } } -static void pulse_sink_input_info_callback(pa_context *c, const pa_sink_input_info *info, int eol, void *userdata){ - if (eol > 0) { - if (pa_context_errno(c) == PA_ERR_NOENTITY) - return; -/* g_warning("Sink INPUT info callback failure");*/ - return; +static void pulse_sink_input_info_callback(pa_context *c, const pa_sink_input_info *info, int eol, void *userdata) +{ + if (eol > 0) { + if (pa_context_errno(c) == PA_ERR_NOENTITY) + return; + /* g_warning("Sink INPUT info callback failure");*/ + return; + } else { + if (info == NULL) { + // TODO: watch this carefully - PA async api should not be doing this . . . + /* g_warning("\n Sink input info callback : SINK INPUT INFO IS NULL BUT EOL was not POSITIVE!!!");*/ + return; } - else{ - if (info == NULL) - { - // TODO: watch this carefully - PA async api should not be doing this . . . -/* g_warning("\n Sink input info callback : SINK INPUT INFO IS NULL BUT EOL was not POSITIVE!!!");*/ - return; - } -/* g_debug("\n SINK INPUT INFO sink index : %d \n", info->sink);*/ - check_sink_input_while_muted_event(info->sink); - } + /* g_debug("\n SINK INPUT INFO sink index : %d \n", info->sink);*/ + check_sink_input_while_muted_event(info->sink); + } } static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, void *userdata) { - if (eol > 0) { - if (pa_context_errno(c) == PA_ERR_NOENTITY) - return; -/* g_warning("Sink INPUT info callback failure");*/ - return; - } - gint position = -1; - GList *keys = g_hash_table_get_keys(sink_hash); + if (eol > 0) { + if (pa_context_errno(c) == PA_ERR_NOENTITY) + return; + /* g_warning("Sink INPUT info callback failure");*/ + return; + } + gint position = -1; + GList *keys = g_hash_table_get_keys(sink_hash); + + if (info == NULL) + return; - if(info == NULL) - return; - - position = g_list_index(keys, GINT_TO_POINTER(info->index)); - - if(position >= 0) // => index is within the keys of the hash. - { - sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(info->index)); - s->name = g_strdup(info->name); - gboolean mute_changed = s->mute != !!info->mute; - s->mute = !!info->mute; - gboolean volume_changed = has_volume_changed(info, s); - -/* g_debug("new balance : %i", (int)(pa_cvolume_get_balance(&info->volume, &info->channel_map) * 100));*/ -/* g_debug("cached balance : %i", (int)(pa_cvolume_get_balance(&s->volume, &s->channel_map) * 100));*/ -/* g_debug("update_sink_info: new_volume input : %f", (gdouble)(pa_cvolume_max(&info->volume)));*/ -/* g_debug("update sink info: cached volume is at: %f", (gdouble)(pa_cvolume_max(&s->volume)));*/ -/* g_debug("update sink info : volume changed = %i", volume_changed);*/ -/* g_debug("update sink info : compatibility = %i", pa_cvolume_compatible_with_channel_map(&info->volume, &s->channel_map));*/ - - s->volume = construct_mono_volume(&info->volume); - s->channel_map = info->channel_map; - - if(DEFAULT_SINK_INDEX == s->index) - { - //update the UI - if (volume_changed == TRUE && s->mute == FALSE) - { - pa_volume_t vol = pa_cvolume_max(&s->volume); - gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; -/* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/ - sound_service_dbus_update_sink_volume(dbus_service, volume_percent); - } - - if (mute_changed == TRUE) - { -/* g_debug("Updating Mute from PA manager with mute = %i", s->mute);*/ - sound_service_dbus_update_sink_mute(dbus_service, s->mute); - dbus_menu_manager_update_mute_ui(s->mute); - if(s->mute == FALSE){ - pa_volume_t vol = pa_cvolume_max(&s->volume); - gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; -/* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/ - sound_service_dbus_update_sink_volume(dbus_service, volume_percent); - } - } + position = g_list_index(keys, GINT_TO_POINTER(info->index)); + + if (position >= 0) { // => index is within the keys of the hash. + sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(info->index)); + s->name = g_strdup(info->name); + gboolean mute_changed = s->mute != !!info->mute; + s->mute = !!info->mute; + gboolean volume_changed = has_volume_changed(info, s); + + /* g_debug("new balance : %i", (int)(pa_cvolume_get_balance(&info->volume, &info->channel_map) * 100));*/ + /* g_debug("cached balance : %i", (int)(pa_cvolume_get_balance(&s->volume, &s->channel_map) * 100));*/ + /* g_debug("update_sink_info: new_volume input : %f", (gdouble)(pa_cvolume_max(&info->volume)));*/ + /* g_debug("update sink info: cached volume is at: %f", (gdouble)(pa_cvolume_max(&s->volume)));*/ + /* g_debug("update sink info : volume changed = %i", volume_changed);*/ + /* g_debug("update sink info : compatibility = %i", pa_cvolume_compatible_with_channel_map(&info->volume, &s->channel_map));*/ + + s->volume = construct_mono_volume(&info->volume); + s->channel_map = info->channel_map; + + if (DEFAULT_SINK_INDEX == s->index) { + //update the UI + if (volume_changed == TRUE && s->mute == FALSE) { + pa_volume_t vol = pa_cvolume_max(&s->volume); + gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; + /* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/ + sound_service_dbus_update_sink_volume(dbus_service, volume_percent); + } + + if (mute_changed == TRUE) { + /* g_debug("Updating Mute from PA manager with mute = %i", s->mute);*/ + sound_service_dbus_update_sink_mute(dbus_service, s->mute); + dbus_menu_manager_update_mute_ui(s->mute); + if (s->mute == FALSE) { + pa_volume_t vol = pa_cvolume_max(&s->volume); + gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; + /* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/ + sound_service_dbus_update_sink_volume(dbus_service, volume_percent); } + } } - else - { - sink_info *value; - value = g_new0(sink_info, 1); - value->index = info->index; - value->name = g_strdup(info->name); - value->mute = !!info->mute; - value->volume = construct_mono_volume(&info->volume); - value->channel_map = info->channel_map; - value->base_volume = info->base_volume; - g_hash_table_insert(sink_hash, GINT_TO_POINTER(value->index), value); -/* g_debug("pulse-manager:update_sink_info -> After adding a new sink to our hash");*/ - sound_service_dbus_update_sink_availability(dbus_service, TRUE); - } + } else { + sink_info *value; + value = g_new0(sink_info, 1); + value->index = info->index; + value->name = g_strdup(info->name); + value->mute = !!info->mute; + value->volume = construct_mono_volume(&info->volume); + value->channel_map = info->channel_map; + value->base_volume = info->base_volume; + g_hash_table_insert(sink_hash, GINT_TO_POINTER(value->index), value); + /* g_debug("pulse-manager:update_sink_info -> After adding a new sink to our hash");*/ + sound_service_dbus_update_sink_availability(dbus_service, TRUE); + } } static gboolean has_volume_changed(const pa_sink_info* new_sink, sink_info* cached_sink) { - if(pa_cvolume_compatible_with_channel_map(&new_sink->volume, &cached_sink->channel_map) == FALSE) - return FALSE; + if (pa_cvolume_compatible_with_channel_map(&new_sink->volume, &cached_sink->channel_map) == FALSE) + return FALSE; - pa_cvolume new_vol = construct_mono_volume(&new_sink->volume); + pa_cvolume new_vol = construct_mono_volume(&new_sink->volume); - if(pa_cvolume_equal(&new_vol, &(cached_sink->volume)) == TRUE){ -/* g_debug("has_volume_changed: volumes appear to be equal? no change triggered!"); */ - return FALSE; - } - - return TRUE; + if (pa_cvolume_equal(&new_vol, &(cached_sink->volume)) == TRUE) { + /* g_debug("has_volume_changed: volumes appear to be equal? no change triggered!"); */ + return FALSE; + } + + return TRUE; } static void pulse_server_info_callback(pa_context *c, const pa_server_info *info, void *userdata) { -/* g_debug("server info callback");*/ - pa_operation *operation; - if (info == NULL) - { - g_warning("No server - get the hell out of here"); - dbus_menu_manager_update_pa_state(FALSE, FALSE, TRUE, 0); - pa_server_available = FALSE; - return; - } - pa_server_available = TRUE; - if(info->default_sink_name != NULL) - { - if (!(operation = pa_context_get_sink_info_by_name(c, info->default_sink_name, pulse_default_sink_info_callback, userdata))) - { - g_warning("pa_context_get_sink_info_by_name() failed"); - } - else{ - pa_operation_unref(operation); - return; - } + /* g_debug("server info callback");*/ + pa_operation *operation; + if (info == NULL) { + g_warning("No server - get the hell out of here"); + dbus_menu_manager_update_pa_state(FALSE, FALSE, TRUE, 0); + pa_server_available = FALSE; + return; + } + pa_server_available = TRUE; + if (info->default_sink_name != NULL) { + if (!(operation = pa_context_get_sink_info_by_name(c, info->default_sink_name, pulse_default_sink_info_callback, userdata))) { + g_warning("pa_context_get_sink_info_by_name() failed"); + } else { + pa_operation_unref(operation); + return; } - if (!(operation = pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL))) - { - g_warning("pa_context_get_sink_info_list() failed"); - return; - } - pa_operation_unref(operation); + } + if (!(operation = pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL))) { + g_warning("pa_context_get_sink_info_list() failed"); + return; + } + pa_operation_unref(operation); } static void subscribed_events_callback(pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) { - switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) - { - case PA_SUBSCRIPTION_EVENT_SINK: - if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) - { - if(index == DEFAULT_SINK_INDEX) - sound_service_dbus_update_sink_availability(dbus_service, FALSE); - -/* g_debug("Subscribed_events_callback - removing sink of index %i from our sink hash - keep the cache tidy !", index);*/ - g_hash_table_remove(sink_hash, GINT_TO_POINTER(index)); - - if(index == DEFAULT_SINK_INDEX){ -/* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK REMOVAL: default sink %i has been removed.", DEFAULT_SINK_INDEX); */ - DEFAULT_SINK_INDEX = -1; - determine_sink_availability(); - } -/* g_debug("subscribed_events_callback - Now what is our default sink : %i", DEFAULT_SINK_INDEX); */ - } - else - { -/* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK: a generic sink event - will trigger an update"); */ - pa_operation_unref(pa_context_get_sink_info_by_index(c, index, update_sink_info, userdata)); - } - break; - case PA_SUBSCRIPTION_EVENT_SINK_INPUT: -/* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK_INPUT event triggered!!");*/ - if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) - { - //handle the sink input remove event - not relevant for current design - } - else - { - pa_operation_unref(pa_context_get_sink_input_info(c, index, pulse_sink_input_info_callback, userdata)); - } - break; - case PA_SUBSCRIPTION_EVENT_SERVER: - g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SERVER change of some description ???"); - pa_operation *o; - if(!(o = pa_context_get_server_info(c, pulse_server_info_callback, userdata))) - { - g_warning("subscribed_events_callback - pa_context_get_server_info() failed"); - return; - } - pa_operation_unref(o); - break; - } + switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) { + case PA_SUBSCRIPTION_EVENT_SINK: + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { + if (index == DEFAULT_SINK_INDEX) + sound_service_dbus_update_sink_availability(dbus_service, FALSE); + + /* g_debug("Subscribed_events_callback - removing sink of index %i from our sink hash - keep the cache tidy !", index);*/ + g_hash_table_remove(sink_hash, GINT_TO_POINTER(index)); + + if (index == DEFAULT_SINK_INDEX) { + /* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK REMOVAL: default sink %i has been removed.", DEFAULT_SINK_INDEX); */ + DEFAULT_SINK_INDEX = -1; + determine_sink_availability(); + } + /* g_debug("subscribed_events_callback - Now what is our default sink : %i", DEFAULT_SINK_INDEX); */ + } else { + /* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK: a generic sink event - will trigger an update"); */ + pa_operation_unref(pa_context_get_sink_info_by_index(c, index, update_sink_info, userdata)); + } + break; + case PA_SUBSCRIPTION_EVENT_SINK_INPUT: + /* g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SINK_INPUT event triggered!!");*/ + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { + //handle the sink input remove event - not relevant for current design + } else { + pa_operation_unref(pa_context_get_sink_input_info(c, index, pulse_sink_input_info_callback, userdata)); + } + break; + case PA_SUBSCRIPTION_EVENT_SERVER: + g_debug("subscribed_events_callback - PA_SUBSCRIPTION_EVENT_SERVER change of some description ???"); + pa_operation *o; + if (!(o = pa_context_get_server_info(c, pulse_server_info_callback, userdata))) { + g_warning("subscribed_events_callback - pa_context_get_server_info() failed"); + return; + } + pa_operation_unref(o); + break; + } } -static void context_state_callback(pa_context *c, void *userdata) { - switch (pa_context_get_state(c)) { - case PA_CONTEXT_UNCONNECTED: -/* g_debug("unconnected");*/ - break; - case PA_CONTEXT_CONNECTING: -/* g_debug("connecting - waiting for the server to become available");*/ - break; - case PA_CONTEXT_AUTHORIZING: -/* g_debug("authorizing");*/ - break; - case PA_CONTEXT_SETTING_NAME: -/* g_debug("context setting name");*/ - break; - case PA_CONTEXT_FAILED: - g_warning("FAILED to retrieve context - Is PulseAudio Daemon running ?"); - pa_server_available = FALSE; - reconnect_to_pulse(); - break; - case PA_CONTEXT_TERMINATED: -/* g_debug("context terminated");*/ - break; - case PA_CONTEXT_READY: - g_debug("PA daemon is ready"); - pa_operation *o; - - pa_context_set_subscribe_callback(c, subscribed_events_callback, userdata); - - if (!(o = pa_context_subscribe(c, (pa_subscription_mask_t) - (PA_SUBSCRIPTION_MASK_SINK| - PA_SUBSCRIPTION_MASK_SINK_INPUT| - PA_SUBSCRIPTION_MASK_SERVER), NULL, NULL))) { - g_warning("pa_context_subscribe() failed"); - return; - } - pa_operation_unref(o); - - gather_pulse_information(c, userdata); - - break; +static void context_state_callback(pa_context *c, void *userdata) +{ + switch (pa_context_get_state(c)) { + case PA_CONTEXT_UNCONNECTED: + /* g_debug("unconnected");*/ + break; + case PA_CONTEXT_CONNECTING: + /* g_debug("connecting - waiting for the server to become available");*/ + break; + case PA_CONTEXT_AUTHORIZING: + /* g_debug("authorizing");*/ + break; + case PA_CONTEXT_SETTING_NAME: + /* g_debug("context setting name");*/ + break; + case PA_CONTEXT_FAILED: + g_warning("FAILED to retrieve context - Is PulseAudio Daemon running ?"); + pa_server_available = FALSE; + reconnect_to_pulse(); + break; + case PA_CONTEXT_TERMINATED: + /* g_debug("context terminated");*/ + break; + case PA_CONTEXT_READY: + g_debug("PA daemon is ready"); + pa_operation *o; + + pa_context_set_subscribe_callback(c, subscribed_events_callback, userdata); + + if (!(o = pa_context_subscribe(c, (pa_subscription_mask_t) + (PA_SUBSCRIPTION_MASK_SINK| + PA_SUBSCRIPTION_MASK_SINK_INPUT| + PA_SUBSCRIPTION_MASK_SERVER), NULL, NULL))) { + g_warning("pa_context_subscribe() failed"); + return; } + pa_operation_unref(o); + + gather_pulse_information(c, userdata); + + break; + } } diff --git a/src/pulse-manager.h b/src/pulse-manager.h index 54978bb..fc01f1c 100644 --- a/src/pulse-manager.h +++ b/src/pulse-manager.h @@ -29,19 +29,19 @@ with this program. If not, see . typedef struct { - gchar* name; - gint index; - pa_cvolume volume; - pa_channel_map channel_map; - gboolean mute; - pa_volume_t base_volume; + gchar* name; + gint index; + pa_cvolume volume; + pa_channel_map channel_map; + gboolean mute; + pa_volume_t base_volume; } sink_info; pa_context* get_context(void); void establish_pulse_activities(SoundServiceDbus *service); void set_sink_volume(gdouble percent); -void toggle_global_mute(gboolean mute_value); +void toggle_global_mute(gboolean mute_value); void close_pulse_activites(); #endif diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index 8a21fcf..d56422a 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -4,16 +4,16 @@ Copyright 2010 Canonical Ltd. Authors: Conor Curran -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along +You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifdef HAVE_CONFIG_H @@ -28,9 +28,8 @@ with this program. If not, see . typedef struct _SliderMenuItemPrivate SliderMenuItemPrivate; -struct _SliderMenuItemPrivate -{ - gdouble slider_value; +struct _SliderMenuItemPrivate { + gdouble slider_value; }; #define SLIDER_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SLIDER_MENU_ITEM_TYPE, SliderMenuItemPrivate)) @@ -46,58 +45,58 @@ G_DEFINE_TYPE (SliderMenuItem, slider_menu_item, DBUSMENU_TYPE_MENUITEM); static void slider_menu_item_class_init (SliderMenuItemClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (SliderMenuItemPrivate)); + g_type_class_add_private (klass, sizeof (SliderMenuItemPrivate)); - object_class->dispose = slider_menu_item_dispose; - object_class->finalize = slider_menu_item_finalize; + object_class->dispose = slider_menu_item_dispose; + object_class->finalize = slider_menu_item_finalize; DbusmenuMenuitemClass * mclass = DBUSMENU_MENUITEM_CLASS(klass); mclass->handle_event = handle_event; - return; + return; } static void slider_menu_item_init (SliderMenuItem *self) { - g_debug("Building new Slider Menu Item"); - return; + g_debug("Building new Slider Menu Item"); + return; } static void slider_menu_item_dispose (GObject *object) { - G_OBJECT_CLASS (slider_menu_item_parent_class)->dispose (object); - return; + G_OBJECT_CLASS (slider_menu_item_parent_class)->dispose (object); + return; } static void slider_menu_item_finalize (GObject *object) { - G_OBJECT_CLASS (slider_menu_item_parent_class)->finalize (object); + G_OBJECT_CLASS (slider_menu_item_parent_class)->finalize (object); } static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) { - g_debug("in the handle event method of slider_menu_item"); + g_debug("in the handle event method of slider_menu_item"); gdouble volume_input = 0; volume_input = g_value_get_double(value); - if(value != NULL) - set_sink_volume(volume_input); + if (value != NULL) + set_sink_volume(volume_input); } SliderMenuItem* slider_menu_item_new(gboolean sinks_available, gdouble start_volume) { - SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL); + SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_SLIDER_MENUITEM_TYPE); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ENABLED, sinks_available); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, sinks_available); - return self; + return self; } - + diff --git a/src/slider-menu-item.h b/src/slider-menu-item.h index c2acf63..763944f 100644 --- a/src/slider-menu-item.h +++ b/src/slider-menu-item.h @@ -4,16 +4,16 @@ Copyright 2010 Canonical Ltd. Authors: Conor Curran -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along +You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef __SLIDER_MENU_ITEM_H__ @@ -37,11 +37,11 @@ typedef struct _SliderMenuItem SliderMenuItem; typedef struct _SliderMenuItemClass SliderMenuItemClass; struct _SliderMenuItemClass { - DbusmenuMenuitemClass parent_class; + DbusmenuMenuitemClass parent_class; }; struct _SliderMenuItem { - DbusmenuMenuitem parent; + DbusmenuMenuitem parent; }; GType slider_menu_item_get_type (void); diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index d1ddfc4..85945d0 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -28,7 +28,7 @@ #include "common-defs.h" #include "pulse-manager.h" -// DBUS methods +// DBUS methods static gboolean sound_service_dbus_get_sink_volume(SoundServiceDbus* service, gdouble* volume_percent_input, GError** gerror); static gboolean sound_service_dbus_get_sink_mute(SoundServiceDbus* service, gboolean* mute_input, GError** gerror); static gboolean sound_service_dbus_get_sink_availability(SoundServiceDbus* service, gboolean* availability_input, GError** gerror); @@ -38,12 +38,11 @@ static void sound_service_dbus_set_sink_volume(SoundServiceDbus* service, const typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate; -struct _SoundServiceDbusPrivate -{ - DBusGConnection *connection; - gdouble volume_percent; - gboolean mute; - gboolean sink_availability; +struct _SoundServiceDbusPrivate { + DBusGConnection *connection; + gdouble volume_percent; + gboolean mute; + gboolean sink_availability; }; @@ -73,47 +72,47 @@ G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT); static void sound_service_dbus_class_init (SoundServiceDbusClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (object_class, sizeof(SoundServiceDbusPrivate)); - - object_class->dispose = sound_service_dbus_dispose; - object_class->finalize = sound_service_dbus_finalize; - - g_assert(klass != NULL); - dbus_g_object_type_install_info(SOUND_SERVICE_DBUS_TYPE, - &dbus_glib__sound_service_server_object_info); - - signals[SINK_INPUT_WHILE_MUTED] = g_signal_new("sink-input-while-muted", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - - signals[SINK_VOLUME_UPDATE] = g_signal_new("sink-volume-update", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__DOUBLE, - G_TYPE_NONE, 1, G_TYPE_DOUBLE); - - signals[SINK_MUTE_UPDATE] = g_signal_new("sink-mute-update", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - signals[SINK_AVAILABLE_UPDATE] = g_signal_new("sink-available-update", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof(SoundServiceDbusPrivate)); + + object_class->dispose = sound_service_dbus_dispose; + object_class->finalize = sound_service_dbus_finalize; + + g_assert(klass != NULL); + dbus_g_object_type_install_info(SOUND_SERVICE_DBUS_TYPE, + &dbus_glib__sound_service_server_object_info); + + signals[SINK_INPUT_WHILE_MUTED] = g_signal_new("sink-input-while-muted", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + + signals[SINK_VOLUME_UPDATE] = g_signal_new("sink-volume-update", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__DOUBLE, + G_TYPE_NONE, 1, G_TYPE_DOUBLE); + + signals[SINK_MUTE_UPDATE] = g_signal_new("sink-mute-update", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + signals[SINK_AVAILABLE_UPDATE] = g_signal_new("sink-available-update", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); @@ -122,41 +121,41 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) static void sound_service_dbus_init (SoundServiceDbus *self) { - GError *error = NULL; - SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self); - - priv->connection = NULL; - priv->volume_percent = 0; - priv->mute = FALSE; - priv->sink_availability = FALSE; - - /* Fetch the session bus */ - priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); - - if (error != NULL) { - g_error("sound-service-dbus:Unable to connect to the session bus when creating indicator sound service : %s", error->message); - g_error_free(error); - return; - } - /* register the service on it */ - dbus_g_connection_register_g_object(priv->connection, - INDICATOR_SOUND_SERVICE_DBUS_OBJECT, - G_OBJECT(self)); + GError *error = NULL; + SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self); + + priv->connection = NULL; + priv->volume_percent = 0; + priv->mute = FALSE; + priv->sink_availability = FALSE; + + /* Fetch the session bus */ + priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + + if (error != NULL) { + g_error("sound-service-dbus:Unable to connect to the session bus when creating indicator sound service : %s", error->message); + g_error_free(error); + return; + } + /* register the service on it */ + dbus_g_connection_register_g_object(priv->connection, + INDICATOR_SOUND_SERVICE_DBUS_OBJECT, + G_OBJECT(self)); } static void sound_service_dbus_dispose (GObject *object) { - G_OBJECT_CLASS (sound_service_dbus_parent_class)->dispose (object); - return; + G_OBJECT_CLASS (sound_service_dbus_parent_class)->dispose (object); + return; } static void sound_service_dbus_finalize (GObject *object) { - G_OBJECT_CLASS (sound_service_dbus_parent_class)->finalize (object); - return; + G_OBJECT_CLASS (sound_service_dbus_parent_class)->finalize (object); + return; } @@ -165,32 +164,32 @@ DBUS Method Callbacks **/ static void sound_service_dbus_set_sink_volume(SoundServiceDbus* service, const guint volume_percent, GError** gerror) { - g_debug("in the set sink volume method in the sound service dbus!, with volume_percent of %i", volume_percent); - set_sink_volume(volume_percent); + g_debug("in the set sink volume method in the sound service dbus!, with volume_percent of %i", volume_percent); + set_sink_volume(volume_percent); } static gboolean sound_service_dbus_get_sink_volume (SoundServiceDbus *self, gdouble *volume_percent_input, GError** gerror) { - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); - g_debug("Get sink volume method in the sound service dbus!, about to send over volume percent of %f", priv->volume_percent); - *volume_percent_input = priv->volume_percent; - return TRUE; + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); + g_debug("Get sink volume method in the sound service dbus!, about to send over volume percent of %f", priv->volume_percent); + *volume_percent_input = priv->volume_percent; + return TRUE; } static gboolean sound_service_dbus_get_sink_mute (SoundServiceDbus *self, gboolean *mute_input, GError** gerror) { - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); - g_debug("Get sink mute - sound service dbus!, about to send over mute_value of %i", priv->mute); - *mute_input = priv->mute; - return TRUE; + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); + g_debug("Get sink mute - sound service dbus!, about to send over mute_value of %i", priv->mute); + *mute_input = priv->mute; + return TRUE; } static gboolean sound_service_dbus_get_sink_availability (SoundServiceDbus *self, gboolean *availability_input, GError** gerror) { - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); - g_debug("Get sink availability - sound service dbus!, about to send over availability_value of %i", priv->sink_availability); - *availability_input = priv->sink_availability; - return TRUE; + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); + g_debug("Get sink availability - sound service dbus!, about to send over availability_value of %i", priv->sink_availability); + *availability_input = priv->sink_availability; + return TRUE; } /** @@ -199,8 +198,8 @@ Utility methods to emit signals from the service into the ether. **/ void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gboolean block_value) { -/* g_debug("Emitting signal: SINK_INPUT_WHILE_MUTED, with block_value: %i", block_value);*/ - g_signal_emit(obj, + /* g_debug("Emitting signal: SINK_INPUT_WHILE_MUTED, with block_value: %i", block_value);*/ + g_signal_emit(obj, signals[SINK_INPUT_WHILE_MUTED], 0, block_value); @@ -208,11 +207,11 @@ void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gboolean void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_volume) { - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); - priv->volume_percent = sink_volume; + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); + priv->volume_percent = sink_volume; -/* g_debug("Emitting signal: SINK_VOLUME_UPDATE, with sink_volme %f", priv->volume_percent);*/ - g_signal_emit(obj, + /* g_debug("Emitting signal: SINK_VOLUME_UPDATE, with sink_volme %f", priv->volume_percent);*/ + g_signal_emit(obj, signals[SINK_VOLUME_UPDATE], 0, priv->volume_percent); @@ -220,12 +219,12 @@ void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_v void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mute) { -/* g_debug("Emitting signal: SINK_MUTE_UPDATE, with sink mute %i", sink_mute);*/ + /* g_debug("Emitting signal: SINK_MUTE_UPDATE, with sink mute %i", sink_mute);*/ - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); - priv->mute = sink_mute; + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); + priv->mute = sink_mute; - g_signal_emit(obj, + g_signal_emit(obj, signals[SINK_MUTE_UPDATE], 0, priv->mute); @@ -233,16 +232,16 @@ void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mu void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, gboolean sink_availability) { -/* g_debug("Emitting signal: SINK_AVAILABILITY_UPDATE, with value %i", sink_availability);*/ + /* g_debug("Emitting signal: SINK_AVAILABILITY_UPDATE, with value %i", sink_availability);*/ - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); - priv->sink_availability = sink_availability; + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); + priv->sink_availability = sink_availability; - g_signal_emit(obj, + g_signal_emit(obj, signals[SINK_AVAILABLE_UPDATE], 0, priv->sink_availability); } - + diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h index ae4953e..258b610 100644 --- a/src/sound-service-dbus.h +++ b/src/sound-service-dbus.h @@ -38,8 +38,7 @@ typedef struct _SoundServiceDbus SoundServiceDbus; typedef struct _SoundServiceDbusClass SoundServiceDbusClass; typedef struct _SoundData SoundData; -struct _SoundData -{ +struct _SoundData { SoundServiceDbus *service; }; @@ -49,7 +48,7 @@ struct _SoundServiceDbus { struct _SoundServiceDbusClass { GObjectClass parent_class; -}; +}; GType sound_service_dbus_get_type (void) G_GNUC_CONST; // Utility methods to get the SIGNAL messages across into the sound-service-dbus diff --git a/src/sound-service.c b/src/sound-service.c index 38e5fba..ea04e4b 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -7,16 +7,16 @@ Authors: Ted Gould Cody Russell -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along +You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -35,49 +35,49 @@ static GMainLoop *mainloop = NULL; /** service_shutdown: When the service interface starts to shutdown, we -should follow it. +should follow it. **/ void service_shutdown (IndicatorService *service, gpointer user_data) { - if (mainloop != NULL) { - g_debug("Service shutdown !"); + if (mainloop != NULL) { + g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); - } - return; + //close_pulse_activites(); + //g_main_loop_quit(mainloop); + } + return; } /** -main: +main: **/ int main (int argc, char ** argv) { g_type_init(); - setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - textdomain (GETTEXT_PACKAGE); + setlocale (LC_ALL, ""); + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + textdomain (GETTEXT_PACKAGE); - IndicatorService *service = indicator_service_new_version(INDICATOR_SOUND_DBUS_NAME, - INDICATOR_SOUND_DBUS_VERSION); - g_signal_connect(G_OBJECT(service), - INDICATOR_SERVICE_SIGNAL_SHUTDOWN, - G_CALLBACK(service_shutdown), NULL); + IndicatorService *service = indicator_service_new_version(INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_DBUS_VERSION); + g_signal_connect(G_OBJECT(service), + INDICATOR_SERVICE_SIGNAL_SHUTDOWN, + G_CALLBACK(service_shutdown), NULL); - DbusmenuMenuitem* root_menuitem = dbus_menu_manager_setup(); - MusicPlayerBridge* server = music_player_bridge_new(); - music_player_bridge_set_root_menu_item(server, root_menuitem); + DbusmenuMenuitem* root_menuitem = dbus_menu_manager_setup(); + MusicPlayerBridge* server = music_player_bridge_new(); + music_player_bridge_set_root_menu_item(server, root_menuitem); - // Run the loop + // Run the loop mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); - + return 0; } diff --git a/src/sound-service.h b/src/sound-service.h index cefbf45..e95d4c7 100644 --- a/src/sound-service.h +++ b/src/sound-service.h @@ -10,16 +10,16 @@ Authors: Ted Gould Cody Russell -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along +You should have received a copy of the GNU General Public License along with this program. If not, see . */ -- cgit v1.2.3 From c8b2631eb77064a3f828aaeb9f2e7a09b257b332 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 18 Jun 2010 10:03:07 +0100 Subject: and the service --- src/sound-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound-service.c b/src/sound-service.c index ea04e4b..bcdac07 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -45,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - //close_pulse_activites(); - //g_main_loop_quit(mainloop); + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From 1b9837ab2ddfac074149d020e700e9272579b211 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Jun 2010 11:36:58 +0100 Subject: lots of changes --- src/Makefile.am | 5 ++++- src/common-defs.h | 6 +++--- src/metadata-menu-item.vala | 28 +++++++++++++++++++++------- src/metadata-widget.c | 8 ++++---- src/mpris-controller.vala | 13 ++++++------- src/player-controller.vala | 21 ++++++--------------- src/sound-service.c | 4 ++-- src/transport-menu-item.vala | 15 ++++----------- src/transport-widget.c | 20 +++++++++++++++++++- 9 files changed, 69 insertions(+), 51 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 5a42dc6..e556eed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -56,17 +56,20 @@ music_bridge_VALASOURCES = \ metadata-menu-item.vala \ player-controller.vala \ mpris-controller-v2.vala \ - mpris-controller.vala + mpris-controller.vala \ + player-item.vala music_bridge_VALAFLAGS = \ --ccode \ -H music-player-bridge.h -d . \ --library music-bridge \ --vapidir=./ \ + --vapidir=$(topsrcdir)/vapi \ --thread \ --pkg gee-1.0 \ --pkg Indicate-0.2 \ --pkg Dbusmenu-Glib-0.2 \ + --pkg music-bridge \ --pkg dbus-glib-1 $(MAINTAINER_VALAFLAGS) diff --git a/src/common-defs.h b/src/common-defs.h index 014d864..d35c672 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -31,6 +31,6 @@ with this program. If not, see . #define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-metadata-menu-item" #define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST "x-canonical-metadata-text-artist" -#define DBUSMENU_METADATA_MENUITEM_TEXT_PIECE "x-canonical-metadata-text-piece" -#define DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER "x-canonical-metadata-text-container" -#define DBUSMENU_METADATA_MENUITEM_IMAGE_PATH "x-canonical-metadata-image" +#define DBUSMENU_METADATA_MENUITEM_TEXT_TITLE "x-canonical-metadata-text-title" +#define DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM "x-canonical-metadata-text-album" +#define DBUSMENU_METADATA_MENUITEM_IMAGE_PATH "x-canonical-metadata-image" diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 82926b1..28e034a 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -1,21 +1,23 @@ using Dbusmenu; using Gee; +using CommonDefs; -public class MetadataMenuitem : Dbusmenu.Menuitem +public class MetadataMenuitem : PlayerItem { /* Not ideal duplicate definition of const - see common-defs/h */ - const string DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item"; - const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist"; - const string DBUSMENU_METADATA_MENUITEM_TEXT_PIECE = "x-canonical-metadata-text-piece"; - const string DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER = "x-canonical-metadata-text-container"; - const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH = "x-canonical-metadata-image"; + //const string DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item"; + //const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist"; + //const string DBUSMENU_METADATA_MENUITEM_TEXT_TITLE = "x-canonical-metadata-text-title"; + //const string DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM = "x-canonical-metadata-text-album"; + //const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH = "x-canonical-metadata-image"; public MetadataMenuitem() { this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_METADATA_MENUITEM_TYPE); + } - public void update(HashMap data) + public override void update(HashMap data) { this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist").strip()); this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, data.get("title").strip()); @@ -37,4 +39,16 @@ public class MetadataMenuitem : Dbusmenu.Menuitem { debug("MetadataItem -> handle event caught!"); } + + public static HashMap attributes() + { + HashMap result = new HashMap(); + result.set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, typeof(string)); + result.set("x-canonical-metadata-text-title", typeof(string)); + result.set("x-canonical-metadata-text-album", typeof(string)); + result.set("x-canonical-metadata-text-image", typeof(string)); + + return result; + } + } \ No newline at end of file diff --git a/src/metadata-widget.c b/src/metadata-widget.c index c4d3b50..b2ca255 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -106,13 +106,13 @@ metadata_widget_init (MetadataWidget *self) // piece GtkWidget* piece; - piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_PIECE)); + piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_TITLE)); priv->piece_label = piece; // container GtkWidget* container; - container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER)); + container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM)); priv->container_label = container; // Pack in the right order @@ -171,10 +171,10 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->artist_label), g_value_get_string(value)); } - else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, property) == 0){ + else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->piece_label), g_value_get_string(value)); } - else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, property) == 0){ + else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->container_label), g_value_get_string(value)); } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, property) == 0){ diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index 7e65594..cd1d2db 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -76,13 +76,12 @@ public class MprisController : GLib.Object private void onStatusChange(dynamic DBus.Object mpris_client, status st) { debug("onStatusChange - signal received"); - //ValueArray a = new ValueArray(4); - //Value v = new Value(typeof(int32)); - //v.set_int(st.playback); - //a.append(v); - //debug("onStatusChange - play %i", a.get_nth(0).get_int()); - //int playback = (ValueArray)st.get_nth(0).get_int(); - //int shuffle = ar.get_nth(1).get_int(); + status* status = &st; + unowned ValueArray ar = (ValueArray)status; + + int playback = ar.get_nth(0).get_int(); + debug("onStatusChange - play %i", ar.get_nth(0).get_int()); + //int repeat = ar.get_nth(2).get_int(); //int endless = ar.get_nth(3).get_int(); } diff --git a/src/player-controller.vala b/src/player-controller.vala index aa72cac..22a200e 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -29,7 +29,7 @@ public class PlayerController : GLib.Object private Dbusmenu.Menuitem root_menu; private string name; private bool is_active; - private ArrayList custom_items; + private ArrayList custom_items; private MprisController mpris_adaptor; public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active) @@ -37,7 +37,7 @@ public class PlayerController : GLib.Object this.root_menu = root; this.name = format_client_name(client_name.strip()); this.is_active = active; - this.custom_items = new ArrayList(); + this.custom_items = new ArrayList(); self_construct(); // Temporary scenario to handle both v1 and v2 of MPRIS. @@ -48,11 +48,7 @@ public class PlayerController : GLib.Object this.mpris_adaptor = new MprisController(this.name, this); } - // TODO subclass dbusmenuMenuitem to something like a playermenuitem - // and use this type to collectively - // control widgets. - TransportMenuitem t = (TransportMenuitem)this.custom_items[TRANSPORT]; - t.set_adaptor(this.mpris_adaptor); + this.custom_items[TRANSPORT].set_adaptor(this.mpris_adaptor); } public void vanish() @@ -65,15 +61,10 @@ public class PlayerController : GLib.Object private bool self_construct() { // Separator item - Dbusmenu.Menuitem separator_item = new Dbusmenu.Menuitem(); - separator_item.property_set(MENUITEM_PROP_TYPE, CLIENT_TYPES_SEPARATOR); - this.custom_items.add(separator_item); + this.custom_items.add(PlayerItem.new_separator_item()); // Title item - Dbusmenu.Menuitem title_item = new Dbusmenu.Menuitem(); - title_item.property_set(MENUITEM_PROP_LABEL, this.name); - title_item.property_set(MENUITEM_PROP_ICON_NAME, "applications-multimedia"); - this.custom_items.add(title_item); + this.custom_items.add(PlayerItem.new_title_item(this.name)); // Metadata item MetadataMenuitem metadata_item = new MetadataMenuitem(); @@ -84,7 +75,7 @@ public class PlayerController : GLib.Object this.custom_items.add(transport_item); int offset = 2; - foreach(Dbusmenu.Menuitem item in this.custom_items){ + foreach(PlayerItem item in this.custom_items){ root_menu.child_add_position(item, offset + this.custom_items.index_of(item)); } return true; diff --git a/src/sound-service.c b/src/sound-service.c index bcdac07..ea04e4b 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -45,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); + //close_pulse_activites(); + //g_main_loop_quit(mainloop); } return; } diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 2e1ed0b..7dc1c7f 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -21,31 +21,24 @@ with this program. If not, see . using Dbusmenu; using Gee; -public class TransportMenuitem : Dbusmenu.Menuitem +public class TransportMenuitem : PlayerItem { /* Not ideal duplicate definition of const - see common-defs/h */ const string DBUSMENU_TRANSPORT_MENUITEM_TYPE = "x-canonical-transport-bar"; const string DBUSMENU_TRANSPORT_MENUITEM_STATE = "x-canonical-transport-state"; - private MprisController mpris_adaptor; public TransportMenuitem() { this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE); - // Hardcode the set up state until we can get the struct vala bug fixed this.property_set_bool(DBUSMENU_TRANSPORT_MENUITEM_STATE, false); debug("transport on the vala side"); } - public void set_adaptor(MprisController adaptor) + public override void update(HashMap data) { - this.mpris_adaptor = adaptor; + debug("TransportMenuitem::update()"); } - - /** - Callback method for the handle_event - * TRUE => Playing - * FALSE => Paused - **/ + public override void handle_event(string name, GLib.Value input_value, uint timestamp) { debug("handle_event with bool value %s", input_value.get_boolean().to_string()); diff --git a/src/transport-widget.c b/src/transport-widget.c index c53513d..10b96df 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -61,7 +61,9 @@ static gboolean transport_widget_button_press_event (GtkWidget *men GdkEventButton *event); static gboolean transport_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event); - +static void transport_widget_play_clicked (GtkWidget* button, + TransportWidget* self); + static void transport_widget_property_update(DbusmenuMenuitem* item, gchar * property, GValue * value, @@ -78,7 +80,9 @@ transport_widget_class_init (TransportWidgetClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + GtkMenuItemClass *menu_item_class = GTK_MENU_ITEM_CLASS(klass); + menu_item_class->hide_on_activate = FALSE; widget_class->button_press_event = transport_widget_button_press_event; widget_class->button_release_event = transport_widget_button_release_event; @@ -143,6 +147,8 @@ transport_widget_init (TransportWidget *self) g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_property_update), self); + g_signal_connect(priv->play_button, "clicked", G_CALLBACK(transport_widget_play_clicked), self); + gtk_container_add (GTK_CONTAINER (self), priv->hbox); gtk_widget_show_all (priv->hbox); @@ -166,8 +172,10 @@ transport_widget_button_press_event (GtkWidget *menuitem, GdkEventButton *event) { g_debug("TransportWidget::menu_press_event"); + TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem)); + gtk_widget_event (priv->hbox, (GdkEvent*)event); gboolean state = g_ascii_strcasecmp(gtk_button_get_label(GTK_BUTTON(priv->play_button)), ">") == 0; gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button)))); @@ -181,11 +189,21 @@ transport_widget_button_press_event (GtkWidget *menuitem, return TRUE; } +static void +transport_widget_play_clicked(GtkWidget* button, + TransportWidget* self) +{ + g_debug("Transport_widget_play_clicked"); +} + static gboolean transport_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event) { g_debug("TransportWidget::menu_release_event"); + TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem)); + gtk_widget_event (priv->hbox, (GdkEvent*)event); + return TRUE; } -- cgit v1.2.3 From 869af4c3707c109b725b05bba70da2d8816051c4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Jun 2010 11:50:47 +0100 Subject: moved the vapi file --- src/Makefile.am | 2 +- vapi/music-bridge.vapi | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 vapi/music-bridge.vapi diff --git a/src/Makefile.am b/src/Makefile.am index e556eed..a1a1deb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -64,7 +64,7 @@ music_bridge_VALAFLAGS = \ -H music-player-bridge.h -d . \ --library music-bridge \ --vapidir=./ \ - --vapidir=$(topsrcdir)/vapi \ + --vapidir=../vapi/ \ --thread \ --pkg gee-1.0 \ --pkg Indicate-0.2 \ diff --git a/vapi/music-bridge.vapi b/vapi/music-bridge.vapi new file mode 100644 index 0000000..65d40ec --- /dev/null +++ b/vapi/music-bridge.vapi @@ -0,0 +1,4 @@ +/* music-bridge.vapi generated by valac, do not modify. */ +[CCode (cheader_filename = "common-defs.h")] +namespace CommonDefs{ +} \ No newline at end of file -- cgit v1.2.3 From 4f84a27c35c47d5833547a4727016514ef98f2b0 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Jun 2010 11:54:28 +0100 Subject: player item src --- src/player-item.vala | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/player-item.vala diff --git a/src/player-item.vala b/src/player-item.vala new file mode 100644 index 0000000..a0ea25a --- /dev/null +++ b/src/player-item.vala @@ -0,0 +1,65 @@ +/* +This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +using Dbusmenu; +using Gee; + +public class PlayerItem : Dbusmenu.Menuitem +{ + public MprisController mpris_adaptor; + + public PlayerItem() + { + } + + public virtual void update(HashMap data) + { + debug("PlayerItem::update()"); + foreach(var key in this.attributes().keys){ + this.attributes.get(key); + } + } + + public void set_adaptor(MprisController adaptor) + { + this.mpris_adaptor = adaptor; + } + + // Bespoke constructors for player items + // Title item + public static PlayerItem new_title_item(dynamic string name) + { + PlayerItem item = new PlayerItem(); + item.property_set(MENUITEM_PROP_LABEL, name); + item.property_set(MENUITEM_PROP_ICON_NAME, "applications-multimedia"); + return item; + } + + // Separator item + public static PlayerItem new_separator_item() + { + PlayerItem separator = new PlayerItem(); + separator.property_set(MENUITEM_PROP_TYPE, CLIENT_TYPES_SEPARATOR); + return separator; + } + + +} + -- cgit v1.2.3 From 2357b40b5530215fc018302eaa288241b436d025 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Jun 2010 12:21:43 +0100 Subject: changed name of local vapi for common defs --- src/metadata-menu-item.vala | 23 ++++++++--------------- src/player-item.vala | 6 +++--- vapi/common-defs.vapi | 9 +++++++++ vapi/music-bridge.vapi | 4 ---- 4 files changed, 20 insertions(+), 22 deletions(-) create mode 100644 vapi/common-defs.vapi delete mode 100644 vapi/music-bridge.vapi diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 28e034a..02ae1c9 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -4,25 +4,18 @@ using CommonDefs; public class MetadataMenuitem : PlayerItem { - /* Not ideal duplicate definition of const - see common-defs/h */ - //const string DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item"; - //const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist"; - //const string DBUSMENU_METADATA_MENUITEM_TEXT_TITLE = "x-canonical-metadata-text-title"; - //const string DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM = "x-canonical-metadata-text-album"; - //const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH = "x-canonical-metadata-image"; - public MetadataMenuitem() { - this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_METADATA_MENUITEM_TYPE); + this.property_set(MENUITEM_PROP_TYPE, CommonDefs.DBUSMENU_METADATA_MENUITEM_TYPE); } public override void update(HashMap data) { - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist").strip()); - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, data.get("title").strip()); - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, data.get("album").strip()); - this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl"))); + this.property_set(CommonDefs.DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist").strip()); + this.property_set(CommonDefs.DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, data.get("title").strip()); + this.property_set(CommonDefs.DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, data.get("album").strip()); + this.property_set(CommonDefs.DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl"))); } public static string sanitize_image_path(string path) @@ -44,9 +37,9 @@ public class MetadataMenuitem : PlayerItem { HashMap result = new HashMap(); result.set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, typeof(string)); - result.set("x-canonical-metadata-text-title", typeof(string)); - result.set("x-canonical-metadata-text-album", typeof(string)); - result.set("x-canonical-metadata-text-image", typeof(string)); + result.set(DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, typeof(string)); + result.set(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, typeof(string)); + result.set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, typeof(string)); return result; } diff --git a/src/player-item.vala b/src/player-item.vala index a0ea25a..aa35b33 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -32,9 +32,9 @@ public class PlayerItem : Dbusmenu.Menuitem public virtual void update(HashMap data) { debug("PlayerItem::update()"); - foreach(var key in this.attributes().keys){ - this.attributes.get(key); - } + //foreach(var key in this.attributes().keys){ + // this.attributes.get(key); + //} } public void set_adaptor(MprisController adaptor) diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi new file mode 100644 index 0000000..8f374d0 --- /dev/null +++ b/vapi/common-defs.vapi @@ -0,0 +1,9 @@ +/* music-bridge.vapi generated by valac, do not modify. */ +[CCode (cheader_filename = "common-defs.h")] +namespace CommonDefs{ + public const string DBUSMENU_METADATA_MENUITEM_TYPE; + public const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST; + public const string DBUSMENU_METADATA_MENUITEM_TEXT_TITLE; + public const string DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM; + public const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH; +} \ No newline at end of file diff --git a/vapi/music-bridge.vapi b/vapi/music-bridge.vapi deleted file mode 100644 index 65d40ec..0000000 --- a/vapi/music-bridge.vapi +++ /dev/null @@ -1,4 +0,0 @@ -/* music-bridge.vapi generated by valac, do not modify. */ -[CCode (cheader_filename = "common-defs.h")] -namespace CommonDefs{ -} \ No newline at end of file -- cgit v1.2.3 From 87445b8921774ec705b4bb62429a5f69be941737 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Jun 2010 12:25:46 +0100 Subject: more refactoring of vapis --- src/Makefile.am | 2 +- src/metadata-menu-item.vala | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index a1a1deb..a2a54e8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -69,7 +69,7 @@ music_bridge_VALAFLAGS = \ --pkg gee-1.0 \ --pkg Indicate-0.2 \ --pkg Dbusmenu-Glib-0.2 \ - --pkg music-bridge \ + --pkg common-defs \ --pkg dbus-glib-1 $(MAINTAINER_VALAFLAGS) diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 02ae1c9..2b865f7 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -6,16 +6,16 @@ public class MetadataMenuitem : PlayerItem { public MetadataMenuitem() { - this.property_set(MENUITEM_PROP_TYPE, CommonDefs.DBUSMENU_METADATA_MENUITEM_TYPE); + this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_METADATA_MENUITEM_TYPE); } public override void update(HashMap data) { - this.property_set(CommonDefs.DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist").strip()); - this.property_set(CommonDefs.DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, data.get("title").strip()); - this.property_set(CommonDefs.DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, data.get("album").strip()); - this.property_set(CommonDefs.DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl"))); + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist").strip()); + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, data.get("title").strip()); + this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, data.get("album").strip()); + this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl"))); } public static string sanitize_image_path(string path) -- cgit v1.2.3 From 7be2c7248a0b29ea74e8e36db405d5974995a57b Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Jun 2010 16:25:16 +0100 Subject: going for generic property updates --- src/common-defs.h | 2 +- src/metadata-menu-item.vala | 48 ++++++++++++++++++++++++--------------------- src/metadata-widget.c | 6 +++--- src/mpris-controller.vala | 13 +----------- src/player-controller.vala | 2 +- src/player-item.vala | 16 +++++++-------- vapi/common-defs.vapi | 12 ++++++------ 7 files changed, 46 insertions(+), 53 deletions(-) diff --git a/src/common-defs.h b/src/common-defs.h index d35c672..1e53e07 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -33,4 +33,4 @@ with this program. If not, see . #define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST "x-canonical-metadata-text-artist" #define DBUSMENU_METADATA_MENUITEM_TEXT_TITLE "x-canonical-metadata-text-title" #define DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM "x-canonical-metadata-text-album" -#define DBUSMENU_METADATA_MENUITEM_IMAGE_PATH "x-canonical-metadata-image" +#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-metadata-image" diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 2b865f7..5464074 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -1,22 +1,21 @@ using Dbusmenu; using Gee; -using CommonDefs; +using DbusmenuMetadata; public class MetadataMenuitem : PlayerItem { public MetadataMenuitem() { - this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_METADATA_MENUITEM_TYPE); - + this.property_set(MENUITEM_PROP_TYPE, MENUITEM_TYPE); } - public override void update(HashMap data) - { - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, data.get("artist").strip()); - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, data.get("title").strip()); - this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, data.get("album").strip()); - this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl"))); - } + //public override void update(HashMap data) + //{ + // this.property_set(MENUITEM_TEXT_ARTIST, data.get("artist").strip()); + // this.property_set(MENUITEM_TEXT_TITLE, data.get("title").strip()); + // this.property_set(MENUITEM_TEXT_ALBUM, data.get("album").strip()); + // this.property_set(MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl"))); + //} public static string sanitize_image_path(string path) { @@ -27,21 +26,26 @@ public class MetadataMenuitem : PlayerItem debug("Sanitize image path - result = %s", result); return result; } - - public override void handle_event(string name, GLib.Value input_value, uint timestamp) + + public static HashMap attributes_format() { - debug("MetadataItem -> handle event caught!"); - } + HashMap results = new HashMap(); + results.set(MENUITEM_TEXT_TITLE, typeof(string)); + results.set(MENUITEM_TEXT_ARTIST, typeof(string)); + results.set(MENUITEM_TEXT_ALBUM, typeof(string)); + results.set(MENUITEM_TEXT_ARTURL, typeof(string)); + return results; + } + - public static HashMap attributes() + public static HashMap format_updates(HashMap data) { - HashMap result = new HashMap(); - result.set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, typeof(string)); - result.set(DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, typeof(string)); - result.set(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, typeof(string)); - result.set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, typeof(string)); + HashMap results = new HashMap(); - return result; + results.set(MENUITEM_TEXT_TITLE, (string)data.lookup("title").strip()); + results.set(MENUITEM_TEXT_ARTIST, (string)data.lookup("artist").strip()); + results.set(MENUITEM_TEXT_ALBUM, (string)data.lookup("album").strip(), typeof(string)); + results.set(MENUITEM_TEXT_ARTURL, sanitize_image_path((string)data.lookup("arturl").strip()), typeof(string)); + return results; } - } \ No newline at end of file diff --git a/src/metadata-widget.c b/src/metadata-widget.c index b2ca255..66e8cac 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -93,7 +93,7 @@ metadata_widget_init (MetadataWidget *self) // image priv->album_art = gtk_image_new(); - priv->image_path = g_strdup(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH)); + priv->image_path = g_strdup(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL)); update_album_art(self); gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0); GtkWidget* vbox = gtk_vbox_new(TRUE, 0); @@ -177,7 +177,7 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->container_label), g_value_get_string(value)); } - else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, property) == 0){ + else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){ if(priv->image_path != NULL){ g_free(priv->image_path); } @@ -194,7 +194,7 @@ static void update_album_art(MetadataWidget* self){ MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); GdkPixbuf* pixbuf; pixbuf = gdk_pixbuf_new_from_file(priv->image_path, NULL); - pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60,GDK_INTERP_BILINEAR); + pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60, GDK_INTERP_BILINEAR); g_debug("attempting to set the image with path %s", priv->image_path); gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf); g_object_unref(pixbuf); diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index cd1d2db..98473ad 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -54,7 +54,7 @@ public class MprisController : GLib.Object private void onTrackChange(dynamic DBus.Object mpris_client, HashTable ht) { - this.controller.update_playing_info(format_metadata(ht)); + this.controller.update_playing_info(MetadataMenuitem.format_updates(ht)); } /** @@ -85,16 +85,5 @@ public class MprisController : GLib.Object //int repeat = ar.get_nth(2).get_int(); //int endless = ar.get_nth(3).get_int(); } - - private static HashMap format_metadata(HashTable data) - { - HashMap results = new HashMap(); - debug("format_metadata - title = %s", (string)data.lookup("title")); - results.set("title", (string)data.lookup("title")); - results.set("artist", (string)data.lookup("artist")); - results.set("album", (string)data.lookup("album")); - results.set("arturl", (string)data.lookup("arturl")); - return results; - } } diff --git a/src/player-controller.vala b/src/player-controller.vala index 22a200e..ef1e130 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -84,7 +84,7 @@ public class PlayerController : GLib.Object public void update_playing_info(HashMap data) { debug("PlayerController - update_playing_info"); - MetadataMenuitem item = (MetadataMenuitem)this.custom_items[METADATA]; + MetadataMenuitem item = this.custom_items[METADATA] as MetadataMenuitem; item.update(data); } diff --git a/src/player-item.vala b/src/player-item.vala index aa35b33..10dedc2 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -26,15 +26,17 @@ public class PlayerItem : Dbusmenu.Menuitem public MprisController mpris_adaptor; public PlayerItem() - { + { } - public virtual void update(HashMap data) + public void update(HashMap data, Type type) { debug("PlayerItem::update()"); - //foreach(var key in this.attributes().keys){ - // this.attributes.get(key); - //} + HashMap attributes = type.attributes_format(); + foreach(var property in data){ + //property.value as attributes.get(property.key) + //this.property_set(property.key, ); + } } public void set_adaptor(MprisController adaptor) @@ -58,8 +60,6 @@ public class PlayerItem : Dbusmenu.Menuitem PlayerItem separator = new PlayerItem(); separator.property_set(MENUITEM_PROP_TYPE, CLIENT_TYPES_SEPARATOR); return separator; - } - - + } } diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index 8f374d0..ce77929 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -1,9 +1,9 @@ /* music-bridge.vapi generated by valac, do not modify. */ [CCode (cheader_filename = "common-defs.h")] -namespace CommonDefs{ - public const string DBUSMENU_METADATA_MENUITEM_TYPE; - public const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST; - public const string DBUSMENU_METADATA_MENUITEM_TEXT_TITLE; - public const string DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM; - public const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH; +namespace DbusmenuMetadata{ + public const string MENUITEM_TYPE; + public const string MENUITEM_TEXT_ARTIST; + public const string MENUITEM_TEXT_TITLE; + public const string MENUITEM_TEXT_ALBUM; + public const string MENUITEM_ARTURL; } \ No newline at end of file -- cgit v1.2.3 From 6e001f4e0606bce9d3eb070df97d44a7b10081c5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Jun 2010 19:36:21 +0100 Subject: wip --- src/common-defs.h | 2 +- src/metadata-menu-item.vala | 13 +------------ src/mpris-controller.vala | 13 +++++++------ src/player-controller.vala | 17 ++++++++--------- src/player-item.vala | 32 +++++++++++++++++++++++++++++--- src/transport-menu-item.vala | 8 ++++---- 6 files changed, 50 insertions(+), 35 deletions(-) diff --git a/src/common-defs.h b/src/common-defs.h index 1e53e07..c12d9c1 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -33,4 +33,4 @@ with this program. If not, see . #define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST "x-canonical-metadata-text-artist" #define DBUSMENU_METADATA_MENUITEM_TEXT_TITLE "x-canonical-metadata-text-title" #define DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM "x-canonical-metadata-text-album" -#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-metadata-image" +#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-metadata-arturl" diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 5464074..8d626ca 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -33,19 +33,8 @@ public class MetadataMenuitem : PlayerItem results.set(MENUITEM_TEXT_TITLE, typeof(string)); results.set(MENUITEM_TEXT_ARTIST, typeof(string)); results.set(MENUITEM_TEXT_ALBUM, typeof(string)); - results.set(MENUITEM_TEXT_ARTURL, typeof(string)); + results.set(MENUITEM_ARTURL, typeof(string)); return results; } - - public static HashMap format_updates(HashMap data) - { - HashMap results = new HashMap(); - - results.set(MENUITEM_TEXT_TITLE, (string)data.lookup("title").strip()); - results.set(MENUITEM_TEXT_ARTIST, (string)data.lookup("artist").strip()); - results.set(MENUITEM_TEXT_ALBUM, (string)data.lookup("album").strip(), typeof(string)); - results.set(MENUITEM_TEXT_ARTURL, sanitize_image_path((string)data.lookup("arturl").strip()), typeof(string)); - return results; - } } \ No newline at end of file diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index 98473ad..c71662a 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -44,17 +44,18 @@ public class MprisController : GLib.Object this.mpris_player = this.connection.get_object ("org.mpris.".concat(name.down()) , "/Player", mpris_interface); this.mpris_player.TrackChange += onTrackChange; this.mpris_player.StatusChange += onStatusChange; - this.controller.update_playing_info(get_track_data()); + //this.controller.update_playing_info(get_track_data()); } - public HashMap get_track_data() - { - return format_metadata(this.mpris_player.GetMetadata()); - } + //public HashMap get_track_data() + //{ + //return format_metadata(this.mpris_player.GetMetadata()); + //} private void onTrackChange(dynamic DBus.Object mpris_client, HashTable ht) { - this.controller.update_playing_info(MetadataMenuitem.format_updates(ht)); + this.controller.custom_items[this.controller.METADATA].update(ht, + MetadataMenuitem.attributes_format()); } /** diff --git a/src/player-controller.vala b/src/player-controller.vala index ef1e130..862bb29 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -23,13 +23,13 @@ using Gee; public class PlayerController : GLib.Object { - private const int METADATA = 2; + public const int METADATA = 2; private const int TRANSPORT = 3; private Dbusmenu.Menuitem root_menu; private string name; private bool is_active; - private ArrayList custom_items; + public ArrayList custom_items; private MprisController mpris_adaptor; public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active) @@ -47,7 +47,6 @@ public class PlayerController : GLib.Object else{ this.mpris_adaptor = new MprisController(this.name, this); } - this.custom_items[TRANSPORT].set_adaptor(this.mpris_adaptor); } @@ -81,12 +80,12 @@ public class PlayerController : GLib.Object return true; } - public void update_playing_info(HashMap data) - { - debug("PlayerController - update_playing_info"); - MetadataMenuitem item = this.custom_items[METADATA] as MetadataMenuitem; - item.update(data); - } + //public void update_playing_info(HashMap data) + //{ + // debug("PlayerController - update_playing_info"); + // MetadataMenuitem item = this.custom_items[METADATA] as MetadataMenuitem; + // item.update(data, MetadataMenuitem.attributes_format()); + //} private static string format_client_name(string client_name) { diff --git a/src/player-item.vala b/src/player-item.vala index 10dedc2..ee09074 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -29,11 +29,26 @@ public class PlayerItem : Dbusmenu.Menuitem { } - public void update(HashMap data, Type type) + public void update(HashTable data, HashMap attributes) { debug("PlayerItem::update()"); - HashMap attributes = type.attributes_format(); - foreach(var property in data){ + foreach(var property in attributes){ + //debug("property value = %s", attributes.get(property.key).name()); + GLib.Object obj = GLib.Object.new(attributes.get(property.key)); + debug("bang line"); + Type t = obj.get_type(); + if(t.is_a(typeof(string)) == true){ + debug("obj is a string !!! we can tell -halla fucking lula!"); + } + //string[] input_keys = property.key.split("-"); + //string search_key = input_keys[input_keys.length-1 : input_keys.length][0]; + //debug("key parsed from properties is %s", search_key); + //debug("and the bloody type should be %s", property.value.name()); + //var input_value = data.lookup(search_key) as property.value.name(); + //foreach(var s in input_keys){ + // debug("string = %s", s); + //} + //string[] st = input_keys[input_keys.length-1 : input_keys.length]; //property.value as attributes.get(property.key) //this.property_set(property.key, ); } @@ -44,6 +59,17 @@ public class PlayerItem : Dbusmenu.Menuitem this.mpris_adaptor = adaptor; } + public static HashMap format_updates(HashTable ht) + { + HashMap results = new HashMap(); + //HashMap attrs = attributes_format(); + //results.set(MENUITEM_TEXT_TITLE, (string)data.lookup("title").strip()); + //results.set(MENUITEM_TEXT_ARTIST, (string)data.lookup("artist").strip()); + //results.set(MENUITEM_TEXT_ALBUM, (string)data.lookup("album").strip(), typeof(string)); + //results.set(MENUITEM_TEXT_ARTURL, sanitize_image_path((string)data.lookup("arturl").strip()), typeof(string)); + return results; + } + // Bespoke constructors for player items // Title item public static PlayerItem new_title_item(dynamic string name) diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 7dc1c7f..bfa81d3 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -34,10 +34,10 @@ public class TransportMenuitem : PlayerItem debug("transport on the vala side"); } - public override void update(HashMap data) - { - debug("TransportMenuitem::update()"); - } + //public override void update(HashMap data) + //{ + // debug("TransportMenuitem::update()"); + //} public override void handle_event(string name, GLib.Value input_value, uint timestamp) { -- cgit v1.2.3 From 39e811f976a80011703e7b0c04b891a1f1abdd68 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Jun 2010 20:54:28 +0100 Subject: finally --- src/metadata-menu-item.vala | 32 ++++++-------------------- src/player-item.vala | 54 ++++++++++++++++++++------------------------ src/transport-menu-item.vala | 13 +++-------- vapi/common-defs.vapi | 6 +++++ 4 files changed, 40 insertions(+), 65 deletions(-) diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 8d626ca..08b1b85 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -9,32 +9,14 @@ public class MetadataMenuitem : PlayerItem this.property_set(MENUITEM_PROP_TYPE, MENUITEM_TYPE); } - //public override void update(HashMap data) - //{ - // this.property_set(MENUITEM_TEXT_ARTIST, data.get("artist").strip()); - // this.property_set(MENUITEM_TEXT_TITLE, data.get("title").strip()); - // this.property_set(MENUITEM_TEXT_ALBUM, data.get("album").strip()); - // this.property_set(MENUITEM_IMAGE_PATH, sanitize_image_path(data.get("arturl"))); - //} - - public static string sanitize_image_path(string path) - { - string result = path.strip(); - if(result.has_prefix("file:///")){ - result = result.slice(7, result.len()); - } - debug("Sanitize image path - result = %s", result); - return result; - } - - public static HashMap attributes_format() + public static HashSet attributes_format() { - HashMap results = new HashMap(); - results.set(MENUITEM_TEXT_TITLE, typeof(string)); - results.set(MENUITEM_TEXT_ARTIST, typeof(string)); - results.set(MENUITEM_TEXT_ALBUM, typeof(string)); - results.set(MENUITEM_ARTURL, typeof(string)); - return results; + HashSet attrs = new HashSet(); + attrs.add(MENUITEM_TEXT_TITLE); + attrs.add(MENUITEM_TEXT_ARTIST); + attrs.add(MENUITEM_TEXT_ALBUM); + attrs.add(MENUITEM_ARTURL); + return attrs; } } \ No newline at end of file diff --git a/src/player-item.vala b/src/player-item.vala index ee09074..7bf1063 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -28,49 +28,43 @@ public class PlayerItem : Dbusmenu.Menuitem public PlayerItem() { } - - public void update(HashTable data, HashMap attributes) + + public void update(HashTable data, HashSet attributes) { debug("PlayerItem::update()"); - foreach(var property in attributes){ - //debug("property value = %s", attributes.get(property.key).name()); - GLib.Object obj = GLib.Object.new(attributes.get(property.key)); - debug("bang line"); - Type t = obj.get_type(); - if(t.is_a(typeof(string)) == true){ - debug("obj is a string !!! we can tell -halla fucking lula!"); + foreach(string property in attributes){ + string[] input_keys = property.split("-"); + string search_key = input_keys[input_keys.length-1 : input_keys.length][0]; + if (data.lookup(search_key).holds (typeof (string))){ + this.property_set(property, this.sanitize_string(data.lookup(search_key) as string)); + } + else if (data.lookup(search_key).holds (typeof (int))){ + // Circumvent weird vala bug + int* v = (int*)data.lookup(search_key); + int r = *v; + this.property_set_int(property, r); } - //string[] input_keys = property.key.split("-"); - //string search_key = input_keys[input_keys.length-1 : input_keys.length][0]; - //debug("key parsed from properties is %s", search_key); - //debug("and the bloody type should be %s", property.value.name()); - //var input_value = data.lookup(search_key) as property.value.name(); - //foreach(var s in input_keys){ - // debug("string = %s", s); - //} - //string[] st = input_keys[input_keys.length-1 : input_keys.length]; - //property.value as attributes.get(property.key) - //this.property_set(property.key, ); } - } + } public void set_adaptor(MprisController adaptor) { this.mpris_adaptor = adaptor; } - public static HashMap format_updates(HashTable ht) + + public static string sanitize_string(string st) { - HashMap results = new HashMap(); - //HashMap attrs = attributes_format(); - //results.set(MENUITEM_TEXT_TITLE, (string)data.lookup("title").strip()); - //results.set(MENUITEM_TEXT_ARTIST, (string)data.lookup("artist").strip()); - //results.set(MENUITEM_TEXT_ALBUM, (string)data.lookup("album").strip(), typeof(string)); - //results.set(MENUITEM_TEXT_ARTURL, sanitize_image_path((string)data.lookup("arturl").strip()), typeof(string)); - return results; + string result = st.strip(); + if(result.has_prefix("file:///")){ + result = result.slice(7, result.len()); + } + debug("Sanitize string - result = %s", result); + return result; } + - // Bespoke constructors for player items + //----- Custom constructors for player items ----------------// // Title item public static PlayerItem new_title_item(dynamic string name) { diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index bfa81d3..3c49e1c 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -20,25 +20,18 @@ with this program. If not, see . using Dbusmenu; using Gee; +using DbusmenuTransport; public class TransportMenuitem : PlayerItem { - /* Not ideal duplicate definition of const - see common-defs/h */ - const string DBUSMENU_TRANSPORT_MENUITEM_TYPE = "x-canonical-transport-bar"; - const string DBUSMENU_TRANSPORT_MENUITEM_STATE = "x-canonical-transport-state"; public TransportMenuitem() { - this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE); - this.property_set_bool(DBUSMENU_TRANSPORT_MENUITEM_STATE, false); + this.property_set(MENUITEM_PROP_TYPE, MENUITEM_TYPE); + this.property_set_bool(MENUITEM_STATE, false); debug("transport on the vala side"); } - //public override void update(HashMap data) - //{ - // debug("TransportMenuitem::update()"); - //} - public override void handle_event(string name, GLib.Value input_value, uint timestamp) { debug("handle_event with bool value %s", input_value.get_boolean().to_string()); diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index ce77929..67dc1f3 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -6,4 +6,10 @@ namespace DbusmenuMetadata{ public const string MENUITEM_TEXT_TITLE; public const string MENUITEM_TEXT_ALBUM; public const string MENUITEM_ARTURL; +} + +[CCode (cheader_filename = "common-defs.h")] +namespace DbusmenuTransport{ + public const string MENUITEM_TYPE; + public const string MENUITEM_STATE; } \ No newline at end of file -- cgit v1.2.3 From 3c42ee89d903f2bd1a239f2e3e8c236bfe2ef2ba Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Jun 2010 23:28:31 +0100 Subject: trying for support --- src/mpris-controller.vala | 22 +++++++++------------- src/player-item.vala | 5 +++++ src/transport-menu-item.vala | 7 +++++++ src/transport-widget.c | 2 +- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index c71662a..62077d1 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -20,7 +20,6 @@ with this program. If not, see . using Gee; - public class MprisController : GLib.Object { private DBus.Connection connection; @@ -33,7 +32,6 @@ public class MprisController : GLib.Object public int32 endless; } - public MprisController(string name, PlayerController controller, string mpris_interface="org.freedesktop.MediaPlayer"){ try { this.connection = DBus.Bus.get (DBus.BusType.SESSION); @@ -44,18 +42,13 @@ public class MprisController : GLib.Object this.mpris_player = this.connection.get_object ("org.mpris.".concat(name.down()) , "/Player", mpris_interface); this.mpris_player.TrackChange += onTrackChange; this.mpris_player.StatusChange += onStatusChange; - //this.controller.update_playing_info(get_track_data()); } - //public HashMap get_track_data() - //{ - //return format_metadata(this.mpris_player.GetMetadata()); - //} private void onTrackChange(dynamic DBus.Object mpris_client, HashTable ht) { this.controller.custom_items[this.controller.METADATA].update(ht, - MetadataMenuitem.attributes_format()); + MetadataMenuitem.attributes_format()); } /** @@ -80,11 +73,14 @@ public class MprisController : GLib.Object status* status = &st; unowned ValueArray ar = (ValueArray)status; - int playback = ar.get_nth(0).get_int(); - debug("onStatusChange - play %i", ar.get_nth(0).get_int()); - - //int repeat = ar.get_nth(2).get_int(); - //int endless = ar.get_nth(3).get_int(); + bool play_state = (ar.get_nth(0).get_int() == 1); + debug("onStatusChange - play state %s", play_state.to_string()); + HashTable ht = new HashTable(str_hash, str_equal); + Value v = Value(typeof(bool)); + v.set_boolean(play_state); + ht.insert("state", play_state); + this.controller.custom_items[this.controller.TRANSPORT].update(ht, + TransportMenuitem.attributes_format()); } } diff --git a/src/player-item.vala b/src/player-item.vala index 7bf1063..fe1eeab 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -44,6 +44,11 @@ public class PlayerItem : Dbusmenu.Menuitem int r = *v; this.property_set_int(property, r); } + else if(data.lookup(search_key).holds (typeof (bool))){ + bool* b = (bool*)data.lookup(search_key); + bool input = *b; + this.property_set_bool(property, input); + } } } diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 3c49e1c..aae07cc 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -36,5 +36,12 @@ public class TransportMenuitem : PlayerItem { debug("handle_event with bool value %s", input_value.get_boolean().to_string()); this.mpris_adaptor.toggle_playback(input_value.get_boolean()); + } + + public static HashSet attributes_format() + { + HashSet attrs = new HashSet(); + attrs.add(MENUITEM_STATE); + return attrs; } } \ No newline at end of file diff --git a/src/transport-widget.c b/src/transport-widget.c index 10b96df..e1baa68 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -222,7 +222,7 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, TransportWidget* bar = (TransportWidget*)userdata; TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar); - gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_toggle_play_label(property))); + gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(property)); } // will be needed for image swapping -- cgit v1.2.3 From 770b3266e2e7a92efb220f990d10ee0e36577b0f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 22 Jun 2010 11:31:31 +0100 Subject: automatic updates at start up now working properly - still vala oddities to solve but functionality has not been hampered --- src/common-defs.h | 2 +- src/mpris-controller.vala | 27 ++++++++++++++++++--------- src/player-item.vala | 2 ++ src/sound-service.c | 4 ++-- src/transport-menu-item.vala | 8 ++++++-- src/transport-widget.c | 23 +++++++++-------------- vapi/common-defs.vapi | 2 +- 7 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/common-defs.h b/src/common-defs.h index c12d9c1..5fbf743 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -27,7 +27,7 @@ with this program. If not, see . /* DBUS Custom Items */ #define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item" #define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar" -#define DBUSMENU_TRANSPORT_MENUITEM_STATE "x-canonical-transport-state" +#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-transport-state" #define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-metadata-menu-item" #define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST "x-canonical-metadata-text-artist" diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index 62077d1..4515c00 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -41,12 +41,21 @@ public class MprisController : GLib.Object this.controller = controller; this.mpris_player = this.connection.get_object ("org.mpris.".concat(name.down()) , "/Player", mpris_interface); this.mpris_player.TrackChange += onTrackChange; - this.mpris_player.StatusChange += onStatusChange; + this.mpris_player.StatusChange += onStatusChange; + + status st = this.mpris_player.GetStatus(); + int play_state = st.playback; + debug("GetStatusChange - play state %i", play_state); + (this.controller.custom_items[this.controller.TRANSPORT] as TransportMenuitem).change_play_state(play_state); + this.controller.custom_items[this.controller.METADATA].update(this.mpris_player.GetMetadata(), + MetadataMenuitem.attributes_format()); + } private void onTrackChange(dynamic DBus.Object mpris_client, HashTable ht) { + debug("onTrackChange"); this.controller.custom_items[this.controller.METADATA].update(ht, MetadataMenuitem.attributes_format()); } @@ -73,14 +82,14 @@ public class MprisController : GLib.Object status* status = &st; unowned ValueArray ar = (ValueArray)status; - bool play_state = (ar.get_nth(0).get_int() == 1); - debug("onStatusChange - play state %s", play_state.to_string()); - HashTable ht = new HashTable(str_hash, str_equal); - Value v = Value(typeof(bool)); - v.set_boolean(play_state); - ht.insert("state", play_state); - this.controller.custom_items[this.controller.TRANSPORT].update(ht, - TransportMenuitem.attributes_format()); + int play_state = ar.get_nth(0).get_int(); + debug("onStatusChange - play state %i", play_state); + //HashTable ht = new HashTable(str_hash, str_equal); + //int* type = &play_state; + //Value v = Value(typeof(int*)); + //v.set_pointer(type); + //ht.insert("state", v); + (this.controller.custom_items[this.controller.TRANSPORT] as TransportMenuitem).change_play_state(play_state); } } diff --git a/src/player-item.vala b/src/player-item.vala index fe1eeab..3cac208 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -35,7 +35,9 @@ public class PlayerItem : Dbusmenu.Menuitem foreach(string property in attributes){ string[] input_keys = property.split("-"); string search_key = input_keys[input_keys.length-1 : input_keys.length][0]; + debug("search key = %s", search_key); if (data.lookup(search_key).holds (typeof (string))){ + debug("track data change player item update"); this.property_set(property, this.sanitize_string(data.lookup(search_key) as string)); } else if (data.lookup(search_key).holds (typeof (int))){ diff --git a/src/sound-service.c b/src/sound-service.c index ea04e4b..bcdac07 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -45,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - //close_pulse_activites(); - //g_main_loop_quit(mainloop); + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index aae07cc..c8733c0 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -28,10 +28,14 @@ public class TransportMenuitem : PlayerItem public TransportMenuitem() { this.property_set(MENUITEM_PROP_TYPE, MENUITEM_TYPE); - this.property_set_bool(MENUITEM_STATE, false); debug("transport on the vala side"); } + public void change_play_state(int state) + { + this.property_set_int(MENUITEM_PLAY_STATE, state); + } + public override void handle_event(string name, GLib.Value input_value, uint timestamp) { debug("handle_event with bool value %s", input_value.get_boolean().to_string()); @@ -41,7 +45,7 @@ public class TransportMenuitem : PlayerItem public static HashSet attributes_format() { HashSet attrs = new HashSet(); - attrs.add(MENUITEM_STATE); + attrs.add(MENUITEM_PLAY_STATE); return attrs; } } \ No newline at end of file diff --git a/src/transport-widget.c b/src/transport-widget.c index e1baa68..9077c41 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -69,7 +69,7 @@ static void transport_widget_property_update(DbusmenuMenuitem* item, GValue * value, gpointer userdata); // utility methods -static gchar* transport_widget_toggle_play_label(const gchar* state); +static gchar* transport_widget_toggle_play_label(gint state); G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM); @@ -134,13 +134,8 @@ transport_widget_init (TransportWidget *self) GtkWidget *hbox; hbox = gtk_hbox_new(TRUE, 2); - - gchar* label = ">"; - if(dbusmenu_menuitem_property_get_bool(twin_item, DBUSMENU_TRANSPORT_MENUITEM_STATE) == TRUE){ - label = "||"; - } - - priv->play_button = gtk_button_new_with_label(g_strdup(label)); + gchar* symbol = transport_widget_toggle_play_label(dbusmenu_menuitem_property_get_int(twin_item, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE)); + priv->play_button = gtk_button_new_with_label(symbol); gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0); priv->hbox = hbox; @@ -178,7 +173,7 @@ transport_widget_button_press_event (GtkWidget *menuitem, gtk_widget_event (priv->hbox, (GdkEvent*)event); gboolean state = g_ascii_strcasecmp(gtk_button_get_label(GTK_BUTTON(priv->play_button)), ">") == 0; - gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(gtk_button_get_label(GTK_BUTTON(priv->play_button)))); + gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label((gint)state)); GValue value = {0}; g_value_init(&value, G_TYPE_BOOLEAN); g_debug("TransportWidget::menu_press_event - going to send value %i", state); @@ -216,20 +211,20 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, GValue* value, gpointer userdata) { g_debug("transport_widget_update_state - with property %s", property); - gchar* input = g_strdup(g_value_get_string(value)); - g_debug("transport_widget_update_state - with value %s", input); + int update_value = g_value_get_int(value); + g_debug("transport_widget_update_state - with value %i", update_value); TransportWidget* bar = (TransportWidget*)userdata; TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar); - gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(property)); + gtk_button_set_label(GTK_BUTTON(priv->play_button), transport_widget_toggle_play_label(update_value)); } // will be needed for image swapping -static gchar* transport_widget_toggle_play_label(const gchar* state) +static gchar* transport_widget_toggle_play_label(int play_state) { gchar* label = ">"; - if(g_strcmp0(state, ">") == 0){ + if(play_state == 1){ label = "||"; } return label; diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index 67dc1f3..48f8a8f 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -11,5 +11,5 @@ namespace DbusmenuMetadata{ [CCode (cheader_filename = "common-defs.h")] namespace DbusmenuTransport{ public const string MENUITEM_TYPE; - public const string MENUITEM_STATE; + public const string MENUITEM_PLAY_STATE; } \ No newline at end of file -- cgit v1.2.3 From 38e16eeeff6ec6f54662cc4da194e2ad1e024241 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 22 Jun 2010 12:43:24 +0100 Subject: silly vala errors rectified --- src/common-defs.h | 2 +- src/metadata-menu-item.vala | 19 +++++++++++++++++++ src/mpris-controller.vala | 14 ++++++-------- src/player-item.vala | 23 ++++++++++------------- src/transport-menu-item.vala | 1 - vapi/common-defs.vapi | 20 +++++++++++++++++++- 6 files changed, 55 insertions(+), 24 deletions(-) diff --git a/src/common-defs.h b/src/common-defs.h index 5fbf743..dca21cc 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -27,7 +27,7 @@ with this program. If not, see . /* DBUS Custom Items */ #define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item" #define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar" -#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-transport-state" +#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-transport-play-state" #define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-metadata-menu-item" #define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST "x-canonical-metadata-text-artist" diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 08b1b85..f62cd46 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -1,3 +1,22 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + using Dbusmenu; using Gee; using DbusmenuMetadata; diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index 4515c00..64a46e6 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -80,16 +80,14 @@ public class MprisController : GLib.Object { debug("onStatusChange - signal received"); status* status = &st; - unowned ValueArray ar = (ValueArray)status; - + unowned ValueArray ar = (ValueArray)status; int play_state = ar.get_nth(0).get_int(); debug("onStatusChange - play state %i", play_state); - //HashTable ht = new HashTable(str_hash, str_equal); - //int* type = &play_state; - //Value v = Value(typeof(int*)); - //v.set_pointer(type); - //ht.insert("state", v); - (this.controller.custom_items[this.controller.TRANSPORT] as TransportMenuitem).change_play_state(play_state); + HashTable ht = new HashTable(str_hash, str_equal); + Value v = Value(typeof(int)); + v.set_int(play_state); + ht.insert("state", v); + this.controller.custom_items[this.controller.TRANSPORT].update(ht, TransportMenuitem.attributes_format()); } } diff --git a/src/player-item.vala b/src/player-item.vala index 3cac208..09b0e6b 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -1,5 +1,4 @@ /* -This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. Copyright 2010 Canonical Ltd. Authors: @@ -36,20 +35,18 @@ public class PlayerItem : Dbusmenu.Menuitem string[] input_keys = property.split("-"); string search_key = input_keys[input_keys.length-1 : input_keys.length][0]; debug("search key = %s", search_key); - if (data.lookup(search_key).holds (typeof (string))){ - debug("track data change player item update"); - this.property_set(property, this.sanitize_string(data.lookup(search_key) as string)); + + Value v = data.lookup(search_key); + + if (v.holds (typeof (string))){ + this.property_set(property, this.sanitize_string(v.get_string())); } - else if (data.lookup(search_key).holds (typeof (int))){ - // Circumvent weird vala bug - int* v = (int*)data.lookup(search_key); - int r = *v; - this.property_set_int(property, r); + else if (v.holds (typeof (int))){ + debug("with value : %i", v.get_int()); + this.property_set_int(property, v.get_int()); } - else if(data.lookup(search_key).holds (typeof (bool))){ - bool* b = (bool*)data.lookup(search_key); - bool input = *b; - this.property_set_bool(property, input); + else if(v.holds (typeof (bool))){ + this.property_set_bool(property, v.get_boolean()); } } } diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index c8733c0..39a0cab 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -1,5 +1,4 @@ /* -This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. Copyright 2010 Canonical Ltd. Authors: diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index 48f8a8f..222fb67 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -1,4 +1,22 @@ -/* music-bridge.vapi generated by valac, do not modify. */ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + [CCode (cheader_filename = "common-defs.h")] namespace DbusmenuMetadata{ public const string MENUITEM_TYPE; -- cgit v1.2.3 From b77c81f85bc219790f5a079e9b888b6ae3627739 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 22 Jun 2010 14:54:03 +0100 Subject: merge requests point of interest --- src/mpris-controller.vala | 1 + src/transport-widget.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index 64a46e6..a6d27be 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -89,5 +89,6 @@ public class MprisController : GLib.Object ht.insert("state", v); this.controller.custom_items[this.controller.TRANSPORT].update(ht, TransportMenuitem.attributes_format()); } + } diff --git a/src/transport-widget.c b/src/transport-widget.c index 9077c41..bc9df53 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -136,6 +136,7 @@ transport_widget_init (TransportWidget *self) hbox = gtk_hbox_new(TRUE, 2); gchar* symbol = transport_widget_toggle_play_label(dbusmenu_menuitem_property_get_int(twin_item, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE)); priv->play_button = gtk_button_new_with_label(symbol); + //g_free(symbol); gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, TRUE, 0); priv->hbox = hbox; @@ -167,6 +168,9 @@ transport_widget_button_press_event (GtkWidget *menuitem, GdkEventButton *event) { g_debug("TransportWidget::menu_press_event"); + if(IS_TRANSPORT_WIDGET(menuitem) == FALSE){ + return FALSE; + } TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem)); @@ -196,6 +200,10 @@ transport_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event) { g_debug("TransportWidget::menu_release_event"); + if(IS_TRANSPORT_WIDGET(menuitem) == FALSE){ + return FALSE; + } + TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem)); gtk_widget_event (priv->hbox, (GdkEvent*)event); @@ -208,7 +216,7 @@ transport_widget_button_release_event (GtkWidget *menuitem, **/ static void transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, - GValue* value, gpointer userdata) + GValue* value, gpointer userdata) { g_debug("transport_widget_update_state - with property %s", property); int update_value = g_value_get_int(value); -- cgit v1.2.3 From 446a0a14416bec0337477f7ef40eb947891c8cd5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 22 Jun 2010 17:58:21 +0100 Subject: vapi path fix --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index a2a54e8..d2a82f6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -64,7 +64,7 @@ music_bridge_VALAFLAGS = \ -H music-player-bridge.h -d . \ --library music-bridge \ --vapidir=./ \ - --vapidir=../vapi/ \ + --vapidir=$(top_srcdir)/vapi/ \ --thread \ --pkg gee-1.0 \ --pkg Indicate-0.2 \ -- cgit v1.2.3 From a07a88311d4efbaa8682354c199910a8d96eb0a7 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 24 Jun 2010 01:25:13 +0100 Subject: attempting to subscribe to client desktop file path notifications --- src/Makefile.am | 3 +- src/familiar-players-db.vala | 152 +++++++++++++++++++++++++++++++++++++++++++ src/music-player-bridge.vala | 45 ++++++++----- src/sound-service.c | 4 +- 4 files changed, 185 insertions(+), 19 deletions(-) create mode 100644 src/familiar-players-db.vala diff --git a/src/Makefile.am b/src/Makefile.am index a2a54e8..685ef71 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -57,7 +57,8 @@ music_bridge_VALASOURCES = \ player-controller.vala \ mpris-controller-v2.vala \ mpris-controller.vala \ - player-item.vala + player-item.vala \ + familiar-players-db.vala music_bridge_VALAFLAGS = \ --ccode \ diff --git a/src/familiar-players-db.vala b/src/familiar-players-db.vala new file mode 100644 index 0000000..5ed209b --- /dev/null +++ b/src/familiar-players-db.vala @@ -0,0 +1,152 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +using Gee; +using GLib.Path; +using GLib.DirUtils; +using GLib.FileUtils; +using GLib.Timeout; +using GLib.Environment; + +// TODO: more refactoring needed here +public class FamiliarPlayersDB : GLib.Object +{ + private const string GROUP_NAME = "Seen Database"; + private const string KEY_NAME = "DesktopFiles"; + private HashMap players_DB; + private string file_name; + private string dir_name; + private KeyFile key_file; + private uint write_id; + + public FamiliarPlayersDB() + { + this.write_id = 0; + this.players_DB = new HashMap(); + this.dir_name = build_filename(get_user_cache_dir(), "indicators", "sound"); + this.file_name = build_filename(this.dir_name, "familiar-players-db.keyfile"); + if(create_key_file() && check_for_keys() && load_data_from_key_file()){ + debug("keyfiles in place and ready for action"); + } + else{ + this.key_file = null; + warning("FamiliarPlayersDB:: problems loading key file - can't go any further"); + } + } + + private bool create_key_file(){ + if (test(this.file_name, GLib.FileTest.EXISTS)) { + this.key_file = new KeyFile(); + try{ + if (this.key_file.load_from_file(this.file_name, KeyFileFlags.NONE) == true) { + return true; + } + } + catch(FileError e){ + warning("FamiliarPlayersDB - error trying to load KeyFile"); + } + } + return false; + } + + private bool check_for_keys(){ + try{ + if(this.key_file.has_key(GROUP_NAME, KEY_NAME) == true){ + return true; + } + } + catch(KeyFileError e){ + return false; + } + warning("Seen DB '%s' does not have key '%s' in group '%s'", this.file_name, KEY_NAME, GROUP_NAME); + return false; + } + + private bool load_data_from_key_file() + { + try{ + string[] desktops = this.key_file.get_string_list(GROUP_NAME, + KEY_NAME); + + int i = 0; + while (desktops[i] != null) { + this.players_DB.set(desktops[i], true); + } + return true; + } + catch(FileError error){ + warning("Error loading the Desktop string list"); + return false; + } + } + + private bool write_db() + { + KeyFile keyfile = new KeyFile(); + string[] desktops = {}; + //Set keys = this.players_DB.keys; + foreach(string key in this.players_DB.keys){ + desktops += key; + } + keyfile.set_string_list(GROUP_NAME, + KEY_NAME, + desktops); + size_t data_length; + string data = null; + try{ + data = keyfile.to_data(out data_length); + } + catch(Error e){ + warning("Problems dumping keyfile to a string"); + return false; + } + + if(create_with_parents(this.dir_name, 0700) != 0){ + warning("Unable to make directory: %s", this.dir_name); + return false; + } + + try{ + if(set_contents(this.file_name, data, (ssize_t)data_length) == false){ + warning("Unable to write out file '%s'", this.file_name); + } + } + catch(FileError err){ + warning("Unable to write out file '%s'", this.file_name); + } + return true; + } + + public void db_add(string desktop) + { + if(already_familiar(desktop) == false){ + if(this.write_id != 0){ + Source.remove(this.write_id); + this.write_id = 0; + } + this.write_id = Timeout.add_seconds(60, write_db); + this.players_DB.set(desktop.dup(), true); + } + } + + public bool already_familiar(string desktop) + { + return this.players_DB.get(desktop); + } +} \ No newline at end of file diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index b03ecbd..fb63866 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -1,5 +1,4 @@ /* -This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. Copyright 2010 Canonical Ltd. Authors: @@ -28,9 +27,11 @@ public class MusicPlayerBridge : GLib.Object private Listener listener; private Dbusmenu.Menuitem root_menu; private HashMap registered_clients; + private FamiliarPlayersDB playersDB; public MusicPlayerBridge() { + playersDB = new FamiliarPlayersDB(); registered_clients = new HashMap (); listener = Listener.ref_default(); listener.indicator_added.connect(on_indicator_added); @@ -46,26 +47,24 @@ public class MusicPlayerBridge : GLib.Object root_menu = menu; } - public void on_indicator_added(Indicate.ListenerServer object, Indicate.ListenerIndicator p0) - { - debug("MusicPlayerBridge-> on_indicator_added"); - } - - public void on_indicator_removed(Indicate.ListenerServer object, Indicate.ListenerIndicator p0) - { - debug("MusicPlayerBridge -> on_indicator_removed"); - } - - public void on_indicator_modified(Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string s) - { - debug("MusicPlayerBridge -> indicator_modified with vale %s", s ); - } +//static void +//desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data) - public void on_server_added(Indicate.ListenerServer object, string type) + public void desktop_info_callback(Indicate.Listener listener, + Indicate.ListenerServer server, + owned string value, void* data) + { + + } + + public void on_server_added(Indicate.ListenerServer object, string type) { debug("MusicPlayerBridge -> on_server_added with value %s", type); if(server_is_not_of_interest(type)) return; string client_name = type.split(".")[1]; + listener_get_server_property_cb cb = (listener_get_server_property_cb)desktop_info_callback; + this.listener.server_get_desktop(object, cb); + if (root_menu != null && client_name != null){ PlayerController ctrl = new PlayerController(root_menu, client_name, true); registered_clients.set(client_name, ctrl); @@ -98,6 +97,20 @@ public class MusicPlayerBridge : GLib.Object { debug("MusicPlayerBridge-> on_server_count_changed with value %u", i); } + public void on_indicator_added(Indicate.ListenerServer object, Indicate.ListenerIndicator p0) + { + debug("MusicPlayerBridge-> on_indicator_added"); + } + + public void on_indicator_removed(Indicate.ListenerServer object, Indicate.ListenerIndicator p0) + { + debug("MusicPlayerBridge -> on_indicator_removed"); + } + + public void on_indicator_modified(Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string s) + { + debug("MusicPlayerBridge -> indicator_modified with vale %s", s ); + } } diff --git a/src/sound-service.c b/src/sound-service.c index bcdac07..ea04e4b 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -45,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); + //close_pulse_activites(); + //g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From 61cdd08c447d756b14a6208e9caaeba0be9ccb56 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 24 Jun 2010 10:37:46 +0100 Subject: fixes to top level Makefile.am --- Makefile.am | 2 +- src/Makefile.am | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9f75289..466806a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ SUBDIRS = \ tests \ po -EXTRA_DIST = autogen.sh +EXTRA_DIST = autogen.sh vapi/common-defs.vapi DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall diff --git a/src/Makefile.am b/src/Makefile.am index d2a82f6..8e7bc94 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,7 +62,6 @@ music_bridge_VALASOURCES = \ music_bridge_VALAFLAGS = \ --ccode \ -H music-player-bridge.h -d . \ - --library music-bridge \ --vapidir=./ \ --vapidir=$(top_srcdir)/vapi/ \ --thread \ @@ -70,8 +69,7 @@ music_bridge_VALAFLAGS = \ --pkg Indicate-0.2 \ --pkg Dbusmenu-Glib-0.2 \ --pkg common-defs \ - --pkg dbus-glib-1 - + --pkg dbus-glib-1 \ $(MAINTAINER_VALAFLAGS) music_bridge_APIFILES = \ @@ -118,7 +116,6 @@ BUILT_SOURCES = \ music_bridge_vala.stamp \ sound-service-client.h \ sound-service-server.h \ - music-bridge.vapi \ $(music_bridge_APIFILES) \ $(music_bridge_VALASOURCES:.vala=.c) -- cgit v1.2.3 From 98c55dde34ae7ed062ae22712b998ef4787b14ee Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 24 Jun 2010 14:09:49 +0100 Subject: record of played application being stored correctly in keyfile --- configure.ac | 4 ++-- src/Makefile.am | 2 +- src/familiar-players-db.vala | 9 +++++++-- src/music-player-bridge.vala | 40 ++++++++++++++++++++++------------------ src/player-item.vala | 19 +++++++++++++++++-- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index e55123e..781e815 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(indicator-sound, 0.3.1, conor.curran@canonical.com) +AC_INIT(indicator-sound, 0.3.2, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.3.1) +AM_INIT_AUTOMAKE(indicator-sound, 0.3.2) AM_MAINTAINER_MODE diff --git a/src/Makefile.am b/src/Makefile.am index 685ef71..e64d13d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -64,8 +64,8 @@ music_bridge_VALAFLAGS = \ --ccode \ -H music-player-bridge.h -d . \ --library music-bridge \ + --vapidir=$(top_srcdir)/vapi/ \ --vapidir=./ \ - --vapidir=../vapi/ \ --thread \ --pkg gee-1.0 \ --pkg Indicate-0.2 \ diff --git a/src/familiar-players-db.vala b/src/familiar-players-db.vala index 5ed209b..3d7da1f 100644 --- a/src/familiar-players-db.vala +++ b/src/familiar-players-db.vala @@ -100,7 +100,6 @@ public class FamiliarPlayersDB : GLib.Object { KeyFile keyfile = new KeyFile(); string[] desktops = {}; - //Set keys = this.players_DB.keys; foreach(string key in this.players_DB.keys){ desktops += key; } @@ -133,7 +132,7 @@ public class FamiliarPlayersDB : GLib.Object return true; } - public void db_add(string desktop) + public void insert(string desktop) { if(already_familiar(desktop) == false){ if(this.write_id != 0){ @@ -149,4 +148,10 @@ public class FamiliarPlayersDB : GLib.Object { return this.players_DB.get(desktop); } + + public Gee.Set records() + { + return this.players_DB.keys; + } + } \ No newline at end of file diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index fb63866..02333a6 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -32,6 +32,7 @@ public class MusicPlayerBridge : GLib.Object public MusicPlayerBridge() { playersDB = new FamiliarPlayersDB(); + try_to_add_inactive_familiar_clients(); registered_clients = new HashMap (); listener = Listener.ref_default(); listener.indicator_added.connect(on_indicator_added); @@ -42,30 +43,20 @@ public class MusicPlayerBridge : GLib.Object listener.server_count_changed.connect(on_server_count_changed); } - public void set_root_menu_item(Dbusmenu.Menuitem menu) - { - root_menu = menu; - } - -//static void -//desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data) - - public void desktop_info_callback(Indicate.Listener listener, - Indicate.ListenerServer server, - owned string value, void* data) - { - + private void try_to_add_inactive_familiar_clients(){ + //foreach(string app in this.playersDB.records()){ + // + //} } public void on_server_added(Indicate.ListenerServer object, string type) { debug("MusicPlayerBridge -> on_server_added with value %s", type); if(server_is_not_of_interest(type)) return; - string client_name = type.split(".")[1]; - listener_get_server_property_cb cb = (listener_get_server_property_cb)desktop_info_callback; - this.listener.server_get_desktop(object, cb); - + string client_name = type.split(".")[1]; if (root_menu != null && client_name != null){ + listener_get_server_property_cb cb = (listener_get_server_property_cb)desktop_info_callback; + this.listener.server_get_desktop(object, cb, this); PlayerController ctrl = new PlayerController(root_menu, client_name, true); registered_clients.set(client_name, ctrl); debug("client of name %s has successfully registered with us", client_name); @@ -93,7 +84,20 @@ public class MusicPlayerBridge : GLib.Object return false; } - public void on_server_count_changed(Indicate.ListenerServer object, uint i) + private void desktop_info_callback(Indicate.ListenerServer server, + owned string path, void* data) + { + debug("we got a desktop file path hopefully: %s", path); + MusicPlayerBridge bridge = data as MusicPlayerBridge; + bridge.playersDB.insert(path); + } + + public void set_root_menu_item(Dbusmenu.Menuitem menu) + { + root_menu = menu; + } + + public void on_server_count_changed(Indicate.ListenerServer object, uint i) { debug("MusicPlayerBridge-> on_server_count_changed with value %u", i); } diff --git a/src/player-item.vala b/src/player-item.vala index 09b0e6b..d1cf08c 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -28,17 +28,32 @@ public class PlayerItem : Dbusmenu.Menuitem { } + private static bool ensure_valid_updates(HashTable data, HashSet attributes) + { + if(data == null){ + return false; + } + if(data.size() < attributes.size){ + warning("update hash was too small for the target"); + return false; + } + return true; + } + public void update(HashTable data, HashSet attributes) { debug("PlayerItem::update()"); + if(ensure_valid_updates(data, attributes) == false){ + debug("PlayerItem::Update -> update hash is not what we were expecting"); + return; + } foreach(string property in attributes){ string[] input_keys = property.split("-"); string search_key = input_keys[input_keys.length-1 : input_keys.length][0]; debug("search key = %s", search_key); - Value v = data.lookup(search_key); - if (v.holds (typeof (string))){ + debug("with value : %s", v.get_string()); this.property_set(property, this.sanitize_string(v.get_string())); } else if (v.holds (typeof (int))){ -- cgit v1.2.3 From 81d9af3fc3f1d3784e623ede592e6d91032353ad Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 24 Jun 2010 17:23:39 +0100 Subject: moving towards offline application launching --- src/Makefile.am | 3 ++- src/familiar-players-db.vala | 9 +++------ src/metadata-menu-item.vala | 11 +++++++++++ src/music-player-bridge.vala | 35 +++++++++++++++++++++++++++++------ src/player-controller.vala | 14 ++++++-------- src/player-item.vala | 31 ++++++++++++++++++------------- src/sound-service.c | 4 ++-- src/transport-menu-item.vala | 5 +++++ 8 files changed, 76 insertions(+), 36 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index e64d13d..8805ff9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -71,7 +71,8 @@ music_bridge_VALAFLAGS = \ --pkg Indicate-0.2 \ --pkg Dbusmenu-Glib-0.2 \ --pkg common-defs \ - --pkg dbus-glib-1 + --pkg dbus-glib-1 \ + --pkg gio-unix-2.0 $(MAINTAINER_VALAFLAGS) diff --git a/src/familiar-players-db.vala b/src/familiar-players-db.vala index 3d7da1f..88bc01f 100644 --- a/src/familiar-players-db.vala +++ b/src/familiar-players-db.vala @@ -78,15 +78,12 @@ public class FamiliarPlayersDB : GLib.Object return false; } - private bool load_data_from_key_file() - { + private bool load_data_from_key_file(){ try{ string[] desktops = this.key_file.get_string_list(GROUP_NAME, KEY_NAME); - - int i = 0; - while (desktops[i] != null) { - this.players_DB.set(desktops[i], true); + foreach(string s in desktops){ + this.players_DB.set(s, true); } return true; } diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index f62cd46..541fbf4 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -37,5 +37,16 @@ public class MetadataMenuitem : PlayerItem attrs.add(MENUITEM_ARTURL); return attrs; } + + public override void check_layout(){ + this.property_set_bool(MENUITEM_PROP_VISIBLE, this.populated()); + debug("check layout for the metadata = %s", this.populated().to_string()); + } + + public bool populated() + { + return (this.property_get(MENUITEM_TEXT_TITLE) != null && + this.property_get(MENUITEM_TEXT_TITLE) != ""); + } } \ No newline at end of file diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 02333a6..6fc9032 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -20,6 +20,7 @@ with this program. If not, see . using Indicate; using Dbusmenu; using Gee; +using GLib; public class MusicPlayerBridge : GLib.Object { @@ -32,7 +33,6 @@ public class MusicPlayerBridge : GLib.Object public MusicPlayerBridge() { playersDB = new FamiliarPlayersDB(); - try_to_add_inactive_familiar_clients(); registered_clients = new HashMap (); listener = Listener.ref_default(); listener.indicator_added.connect(on_indicator_added); @@ -42,11 +42,33 @@ public class MusicPlayerBridge : GLib.Object listener.server_removed.connect(on_server_removed); listener.server_count_changed.connect(on_server_count_changed); } - + // Alpha 2 not in use ... yet. private void try_to_add_inactive_familiar_clients(){ - //foreach(string app in this.playersDB.records()){ - // - //} + // for now just use one of the entries. + int count = 0; + foreach(string app in this.playersDB.records()){ + if(count == 0){ + debug("we have found %s", app); + string[] bits = app.split("/"); + + try{ + string app_name = bits[bits.length -1].split(".")[0]; + debug("we have found %s", app_name); + PlayerController ctrl = new PlayerController(this.root_menu, + app_name, + false); + this.registered_clients.set(app_name, ctrl); + DesktopAppInfo info = new DesktopAppInfo.from_filename(app_name); + string desc = info.get_display_name(); + debug("description from app %s", desc); + count += 1; + } + catch(Error er){ + warning("desktop path in cache is not formatted as we have anticipated"); + } + } + break; + } } public void on_server_added(Indicate.ListenerServer object, string type) @@ -94,7 +116,8 @@ public class MusicPlayerBridge : GLib.Object public void set_root_menu_item(Dbusmenu.Menuitem menu) { - root_menu = menu; + this.root_menu = menu; + //try_to_add_inactive_familiar_clients(); } public void on_server_count_changed(Indicate.ListenerServer object, uint i) diff --git a/src/player-controller.vala b/src/player-controller.vala index 862bb29..0d8dc01 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -31,7 +31,8 @@ public class PlayerController : GLib.Object private bool is_active; public ArrayList custom_items; private MprisController mpris_adaptor; - + private string desktop_path; + public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active) { this.root_menu = root; @@ -48,6 +49,10 @@ public class PlayerController : GLib.Object this.mpris_adaptor = new MprisController(this.name, this); } this.custom_items[TRANSPORT].set_adaptor(this.mpris_adaptor); + + // At start up if there is no metadata then hide the item. + // TODO: NOT working -> dbus menu bug ? + //((MetadataMenuitem)this.custom_items[METADATA]).check_layout(); } public void vanish() @@ -80,13 +85,6 @@ public class PlayerController : GLib.Object return true; } - //public void update_playing_info(HashMap data) - //{ - // debug("PlayerController - update_playing_info"); - // MetadataMenuitem item = this.custom_items[METADATA] as MetadataMenuitem; - // item.update(data, MetadataMenuitem.attributes_format()); - //} - private static string format_client_name(string client_name) { string formatted = client_name; diff --git a/src/player-item.vala b/src/player-item.vala index d1cf08c..7fcf912 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -27,24 +27,12 @@ public class PlayerItem : Dbusmenu.Menuitem public PlayerItem() { } - - private static bool ensure_valid_updates(HashTable data, HashSet attributes) - { - if(data == null){ - return false; - } - if(data.size() < attributes.size){ - warning("update hash was too small for the target"); - return false; - } - return true; - } public void update(HashTable data, HashSet attributes) { debug("PlayerItem::update()"); if(ensure_valid_updates(data, attributes) == false){ - debug("PlayerItem::Update -> update hash is not what we were expecting"); + debug("PlayerItem::Update -> The hashtable update does not contain what we were expecting - just leave it!"); return; } foreach(string property in attributes){ @@ -64,6 +52,8 @@ public class PlayerItem : Dbusmenu.Menuitem this.property_set_bool(property, v.get_boolean()); } } + // TODO: not working + //this.check_layout(); } public void set_adaptor(MprisController adaptor) @@ -71,6 +61,17 @@ public class PlayerItem : Dbusmenu.Menuitem this.mpris_adaptor = adaptor; } + private static bool ensure_valid_updates(HashTable data, HashSet attributes) + { + if(data == null){ + return false; + } + if(data.size() < attributes.size){ + warning("update hash was too small for the target"); + return false; + } + return true; + } public static string sanitize_string(string st) { @@ -100,5 +101,9 @@ public class PlayerItem : Dbusmenu.Menuitem separator.property_set(MENUITEM_PROP_TYPE, CLIENT_TYPES_SEPARATOR); return separator; } + + public virtual void check_layout(){ + warning("this should not be hit"); + } } diff --git a/src/sound-service.c b/src/sound-service.c index ea04e4b..bcdac07 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -45,8 +45,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - //close_pulse_activites(); - //g_main_loop_quit(mainloop); + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 39a0cab..264e153 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -41,6 +41,11 @@ public class TransportMenuitem : PlayerItem this.mpris_adaptor.toggle_playback(input_value.get_boolean()); } + public override void check_layout(){ + // nothing to be done for this item - always active + } + + public static HashSet attributes_format() { HashSet attrs = new HashSet(); -- cgit v1.2.3 From 1d721c275ba6962d60f47b184849db7bd2a5290a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 24 Jun 2010 17:24:29 +0100 Subject: and my hacked indicate vapi --- vapi/Indicate-0.2.vapi | 218 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 vapi/Indicate-0.2.vapi diff --git a/vapi/Indicate-0.2.vapi b/vapi/Indicate-0.2.vapi new file mode 100644 index 0000000..1381037 --- /dev/null +++ b/vapi/Indicate-0.2.vapi @@ -0,0 +1,218 @@ +/* Indicate-0.2.vapi generated by vapigen, do not modify. */ + +[CCode (cprefix = "Indicate", lower_case_cprefix = "indicate_")] +namespace Indicate { + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public class Indicator : GLib.Object { + public weak GLib.Object parent; + [CCode (has_construct_function = false)] + public Indicator (); + public bool get_displayed (); + public uint get_id (); + public virtual GLib.Value get_property (string key); + public GLib.Value get_property_value (string key); + public Indicate.Server get_server (); + public bool is_visible (); + public string[] list_properties (); + public void set_displayed (bool displayed); + public virtual void set_property (string key, GLib.Value data); + public void set_property_bool (string key, bool value); + public void set_property_int (string key, int value); + public void set_property_time (string key, GLib.TimeVal time); + public void set_property_value (string key, GLib.Value value); + public void set_server (Indicate.Server server); + [CCode (has_construct_function = false)] + public Indicator.with_server (Indicate.Server server); + public signal void displayed (bool object); + [HasEmitter] + public signal void hide (); + public signal void modified (string object); + [HasEmitter] + public signal void show (); + [HasEmitter] + public signal void user_display (uint object); + } + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public class Listener : GLib.Object { + public weak GLib.Object parent; + [CCode (has_construct_function = false)] + public Listener (); + public void display (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, uint timestamp); + public void displayed (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, bool displayed); + public void get_property (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_cb callback); + public void get_property_bool (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_bool_cb callback); + public void get_property_int (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_int_cb callback); + public void get_property_time (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_time_cb callback); + public void get_property_value (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_value_cb callback); + public static GLib.Type indicator_get_gtype (); + public static Indicate.Listener ref_default (); + public bool server_check_interest (Indicate.ListenerServer server, Indicate.Interests interest); + public void server_get_count (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_uint_property_cb callback); + public void server_get_desktop (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback, void* data); + public static GLib.Type server_get_gtype (); + public void server_get_menu (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback); + public static void server_get_type (Indicate.Listener listener, Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback); + public void server_remove_interest (Indicate.ListenerServer server, Indicate.Interests interest); + public void server_show_interest (Indicate.ListenerServer server, Indicate.Interests interest); + public void set_default_max_indicators (int max); + public void set_server_max_indicators (Indicate.ListenerServer server, int max); + public signal void indicator_added (Indicate.ListenerServer object, Indicate.ListenerIndicator p0); + public signal void indicator_modified (Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string p1); + public signal void indicator_removed (Indicate.ListenerServer object, Indicate.ListenerIndicator p0); + public signal void indicator_servers_report (); + public signal void server_added (Indicate.ListenerServer object, string p0); + public signal void server_count_changed (Indicate.ListenerServer object, uint p0); + public signal void server_removed (Indicate.ListenerServer object, string p0); + } + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public class Server : GLib.Object { + public weak GLib.Object parent; + public void add_indicator (Indicate.Indicator indicator); + public virtual bool check_interest (Indicate.Interests interest); + public virtual bool get_indicator_count (out uint count) throws GLib.Error; + public virtual bool get_indicator_property (uint id, owned string property, GLib.Value value) throws GLib.Error; + public int get_max_indicators (); + public virtual uint get_next_id (); + public void hide (); + public virtual void indicator_added (uint id); + public virtual bool indicator_displayed (owned string sender, uint id, bool displayed) throws GLib.Error; + public virtual void indicator_removed (uint id); + public virtual int max_indicators_get (); + public virtual bool max_indicators_set (owned string sender, int max); + public static Indicate.Server ref_default (); + public void remove_indicator (Indicate.Indicator indicator); + public virtual bool remove_interest (owned string sender, Indicate.Interests interest); + public void set_count (uint count); + public static void set_dbus_object (string obj); + public void set_default (); + public void set_desktop_file (string path); + public void set_menu (Dbusmenu.Server menu); + public void set_type (string type); + public void show (); + public virtual bool show_indicator_to_user (uint id, uint timestamp) throws GLib.Error; + public virtual bool show_interest (owned string sender, Indicate.Interests interest); + public uint count { get; set; } + public string desktop { get; set; } + public string type { get; set; } + public signal void indicator_delete (uint object); + public signal void indicator_modified (uint object, string p0); + public signal void indicator_new (uint object); + public signal void interest_added (uint object); + public signal void interest_removed (uint object); + public signal void max_indicators_changed (int object); + public signal void server_count_changed (uint object); + public signal void server_display (uint object); + public signal void server_hide (string object); + public signal void server_show (string object); + } + [CCode (type_id = "INDICATE_TYPE_LISTENER_INDICATOR", cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public struct ListenerIndicator { + public uint get_id (); + } + [CCode (type_id = "INDICATE_TYPE_LISTENER_SERVER", cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public struct ListenerServer { + public unowned string get_dbusname (); + } + [CCode (cprefix = "INDICATE_INTEREST_", cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public enum Interests { + NONE, + SERVER_DISPLAY, + SERVER_SIGNAL, + INDICATOR_DISPLAY, + INDICATOR_SIGNAL, + INDICATOR_COUNT, + LAST + } + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] + public delegate string[] indicator_list_properties_slot_t (Indicate.Indicator indicator); + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] + public delegate void listener_get_property_bool_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, bool propertydata, void* data); + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] + public delegate void listener_get_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, string propertydata, void* data); + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] + public delegate void listener_get_property_int_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, int propertydata, void* data); + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] + public delegate void listener_get_property_time_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, GLib.TimeVal propertydata, void* data); + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] + public delegate void listener_get_property_value_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, GLib.Value propertydata, void* data); + [CCode (cname ="indicate_listener_get_server_property_cb", cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] + public delegate void listener_get_server_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, owned string value, void* data); + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] + public delegate void listener_get_server_uint_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, uint value, void* data); + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] + public delegate bool server_get_indicator_list_slot_t (Indicate.Server server, out unowned Indicate.Indicator[] indicators); + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] + public delegate bool server_get_indicator_properties_slot_t (Indicate.Server server, uint id, out string[] properties); + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] + public delegate bool server_get_indicator_property_group_slot_t (Indicate.Server server, uint id, string[] properties, out string[] value); + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const int INDICATOR_H_INCLUDED__; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const int INDICATOR_MESSAGES_H_INCLUDED__; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_MESSAGES_PROP_ATTENTION; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_MESSAGES_PROP_COUNT; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_MESSAGES_PROP_ICON; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_MESSAGES_PROP_NAME; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_MESSAGES_PROP_TIME; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_MESSAGES_SERVER_TYPE; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_SIGNAL_DISPLAY; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_SIGNAL_DISPLAYED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_SIGNAL_HIDE; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_SIGNAL_MODIFIED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_SIGNAL_SHOW; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_VALUE_FALSE; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string INDICATOR_VALUE_TRUE; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const int INTERESTS_H_INCLUDED__; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const int LISTENER_H_INCLUDED__; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string LISTENER_SIGNAL_INDICATOR_ADDED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string LISTENER_SIGNAL_INDICATOR_MODIFIED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string LISTENER_SIGNAL_INDICATOR_REMOVED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string LISTENER_SIGNAL_SERVER_ADDED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string LISTENER_SIGNAL_SERVER_COUNT_CHANGED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string LISTENER_SIGNAL_SERVER_REMOVED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const int SERVER_H_INCLUDED__; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const int SERVER_INDICATOR_NULL; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string SERVER_SIGNAL_INDICATOR_ADDED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string SERVER_SIGNAL_INDICATOR_MODIFIED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string SERVER_SIGNAL_INDICATOR_REMOVED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string SERVER_SIGNAL_INTEREST_ADDED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string SERVER_SIGNAL_INTEREST_REMOVED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string SERVER_SIGNAL_MAX_INDICATORS_CHANGED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string SERVER_SIGNAL_SERVER_COUNT_CHANGED; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string SERVER_SIGNAL_SERVER_DISPLAY; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string SERVER_SIGNAL_SERVER_HIDE; + [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] + public const string SERVER_SIGNAL_SERVER_SHOW; +} -- cgit v1.2.3 From df55c0f3142de41dd742eda7a59a4b1392882d2b Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 25 Jun 2010 12:59:15 +0100 Subject: fixes two bugs, album art crasher and unreported metadata reset on trackchange --- src/mpris-controller.vala | 1 + src/player-item.vala | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala index a6d27be..beaf02c 100644 --- a/src/mpris-controller.vala +++ b/src/mpris-controller.vala @@ -56,6 +56,7 @@ public class MprisController : GLib.Object private void onTrackChange(dynamic DBus.Object mpris_client, HashTable ht) { debug("onTrackChange"); + this.controller.custom_items[this.controller.METADATA].reset(MetadataMenuitem.attributes_format()); this.controller.custom_items[this.controller.METADATA].update(ht, MetadataMenuitem.attributes_format()); } diff --git a/src/player-item.vala b/src/player-item.vala index 7fcf912..a5c5512 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -27,6 +27,13 @@ public class PlayerItem : Dbusmenu.Menuitem public PlayerItem() { } + + public void reset(HashSet attrs){ + foreach(string s in attrs){ + debug("attempting to set prop %s to null", s); + this.property_set(s, null); + } + } public void update(HashTable data, HashSet attributes) { @@ -39,7 +46,8 @@ public class PlayerItem : Dbusmenu.Menuitem string[] input_keys = property.split("-"); string search_key = input_keys[input_keys.length-1 : input_keys.length][0]; debug("search key = %s", search_key); - Value v = data.lookup(search_key); + Value? v = data.lookup(search_key); + if (v.holds (typeof (string))){ debug("with value : %s", v.get_string()); this.property_set(property, this.sanitize_string(v.get_string())); -- cgit v1.2.3 From d5e278e57cd7a1df14907580d4e6ba4a00dd7fe9 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 25 Jun 2010 16:04:14 +0100 Subject: bumped rev no for 0.3.3 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 781e815..b302f5b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(indicator-sound, 0.3.2, conor.curran@canonical.com) +AC_INIT(indicator-sound, 0.3.3, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.3.2) +AM_INIT_AUTOMAKE(indicator-sound, 0.3.3) AM_MAINTAINER_MODE -- cgit v1.2.3 From fa621d0cc1b357223b9b520857ffb74cdf4ea308 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 28 Jun 2010 13:31:04 +0100 Subject: tidied the metadata widget to be spec compliant --- src/metadata-widget.c | 84 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 12 deletions(-) diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 66e8cac..ce3bcd1 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -57,6 +57,9 @@ static void metadata_widget_property_update(DbusmenuMenuitem* item, gchar* prope GValue* value, gpointer userdata); static void update_album_art(MetadataWidget* self); +static void style_artist_text(MetadataWidget* self); +static void style_title_text(MetadataWidget* self); +static void style_album_text(MetadataWidget* self); G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); @@ -88,32 +91,52 @@ metadata_widget_init (MetadataWidget *self) GtkWidget *hbox; - hbox = gtk_hbox_new(TRUE, 0); + hbox = gtk_hbox_new(FALSE, 0); priv->hbox = hbox; - + // image priv->album_art = gtk_image_new(); priv->image_path = g_strdup(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL)); update_album_art(self); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0); - GtkWidget* vbox = gtk_vbox_new(TRUE, 0); + + GtkWidget* vbox = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); // artist GtkWidget* artist; - artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST)); - priv->artist_label = artist; + artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, + DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST)); + gtk_misc_set_alignment(GTK_MISC(artist), (gfloat)0, (gfloat)0); + gtk_label_set_width_chars(GTK_LABEL(artist), 20); + gtk_label_set_ellipsize(GTK_LABEL(artist), PANGO_ELLIPSIZE_END); + priv->artist_label = artist; + // Style it up. + style_artist_text(self); // piece GtkWidget* piece; - piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_TITLE)); + piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, + DBUSMENU_METADATA_MENUITEM_TEXT_TITLE)); + gtk_misc_set_alignment(GTK_MISC(piece), (gfloat)0, (gfloat)0); + gtk_label_set_width_chars(GTK_LABEL(piece), 16); + gtk_label_set_ellipsize(GTK_LABEL(piece), PANGO_ELLIPSIZE_END); priv->piece_label = piece; - + // Style it up. + style_title_text(self); // container GtkWidget* container; - container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM)); + container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, + DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM)); + gtk_misc_set_alignment(GTK_MISC(container), (gfloat)0, (gfloat)0); + gtk_label_set_width_chars(GTK_LABEL(container), 20); + gtk_label_set_ellipsize(GTK_LABEL(container), PANGO_ELLIPSIZE_END); priv->container_label = container; + // Style it up. + style_album_text(self); // Pack in the right order gtk_box_pack_start (GTK_BOX (vbox), priv->piece_label, FALSE, FALSE, 0); @@ -170,27 +193,29 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->artist_label), g_value_get_string(value)); + style_artist_text(mitem); } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_TITLE, property) == 0){ - gtk_label_set_text(GTK_LABEL(priv->piece_label), g_value_get_string(value)); + gtk_label_set_text(GTK_LABEL(priv->piece_label), g_value_get_string(value)); + style_title_text(mitem); } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->container_label), g_value_get_string(value)); + style_album_text(mitem); } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){ if(priv->image_path != NULL){ g_free(priv->image_path); } - priv->image_path = g_value_dup_string(value); - if(priv->image_path != NULL){ update_album_art(mitem); } } } -static void update_album_art(MetadataWidget* self){ +static void +update_album_art(MetadataWidget* self){ MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); GdkPixbuf* pixbuf; pixbuf = gdk_pixbuf_new_from_file(priv->image_path, NULL); @@ -200,6 +225,41 @@ static void update_album_art(MetadataWidget* self){ g_object_unref(pixbuf); } +// TODO refactor next 3 methods into one once the style has been +// "signed off" by design +static void +style_artist_text(MetadataWidget* self) +{ + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + char* markup; + markup = g_markup_printf_escaped ("%s", + gtk_label_get_text(GTK_LABEL(priv->artist_label))); + gtk_label_set_markup (GTK_LABEL (priv->artist_label), markup); + g_free(markup); +} + +static void +style_title_text(MetadataWidget* self) +{ + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + + char* markup; + markup = g_markup_printf_escaped ("%s", + gtk_label_get_text(GTK_LABEL(priv->piece_label))); + gtk_label_set_markup (GTK_LABEL (priv->piece_label), markup); + g_free(markup); +} + +static void +style_album_text(MetadataWidget* self) +{ + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + char* markup; + markup = g_markup_printf_escaped ("%s", + gtk_label_get_text(GTK_LABEL(priv->container_label))); + gtk_label_set_markup (GTK_LABEL (priv->container_label), markup); + g_free(markup); +} /** * transport_new: -- cgit v1.2.3 From a0c3edbbe3d6cbb160049716cec66bf2673784e4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 28 Jun 2010 15:56:39 +0100 Subject: bumped the revision no. and changed credits on sound-service --- configure.ac | 4 ++-- src/sound-service.c | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index b302f5b..b6c4fe3 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(indicator-sound, 0.3.3, conor.curran@canonical.com) +AC_INIT(indicator-sound, 0.3.4, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.3.3) +AM_INIT_AUTOMAKE(indicator-sound, 0.3.4) AM_MAINTAINER_MODE diff --git a/src/sound-service.c b/src/sound-service.c index bcdac07..8f4e941 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -4,9 +4,7 @@ Copyright 2010 Canonical Ltd. Authors: Conor Curran - Ted Gould - Cody Russell - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. -- cgit v1.2.3