diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-03-09 14:17:12 +0000 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-03-09 14:17:12 +0000 |
commit | 017cbc3be8b4bf1e365d013ede94c848e774d5ef (patch) | |
tree | 89030ddcaf650f030d40ad7fa3018ca2a0181d1b /src | |
parent | 5bae6af22449e60aa0c3eaf0dd08a518979f2df9 (diff) | |
download | ayatana-indicator-sound-017cbc3be8b4bf1e365d013ede94c848e774d5ef.tar.gz ayatana-indicator-sound-017cbc3be8b4bf1e365d013ede94c848e774d5ef.tar.bz2 ayatana-indicator-sound-017cbc3be8b4bf1e365d013ede94c848e774d5ef.zip |
refactored transport enums so as both vala and c are using the same definitions in common defs
Diffstat (limited to 'src')
-rw-r--r-- | src/common-defs.h | 14 | ||||
-rw-r--r-- | src/indicator-sound.c | 12 | ||||
-rw-r--r-- | src/mpris2-controller.vala | 35 | ||||
-rw-r--r-- | src/sound-service.c | 2 | ||||
-rw-r--r-- | src/transport-menu-item.vala | 17 |
5 files changed, 43 insertions, 37 deletions
diff --git a/src/common-defs.h b/src/common-defs.h index 2184a48..da504de 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -31,6 +31,20 @@ typedef enum { AVAILABLE }SoundState; +typedef enum { + TRANSPORT_ACTION_PREVIOUS, + TRANSPORT_ACTION_PLAY_PAUSE, + TRANSPORT_ACTION_NEXT, + TRANSPORT_ACTION_REWIND, + TRANSPORT_ACTION_FORWIND, + TRANSPORT_ACTION_NO_ACTION +}TransportAction; + +typedef enum { + TRANSPORT_STATE_PLAYING, + TRANSPORT_STATE_PAUSED +}TransportState; + #define NOT_ACTIVE -1 #define DBUSMENU_PROPERTY_EMPTY -1 diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 6e1acc9..7851e8a 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -532,17 +532,17 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) switch (event->keyval) { case GDK_Right: transport_widget_react_to_key_press_event ( transport_widget, - TRANSPORT_NEXT ); + TRANSPORT_ACTION_NEXT ); digested = TRUE; break; case GDK_Left: transport_widget_react_to_key_press_event ( transport_widget, - TRANSPORT_PREVIOUS ); + TRANSPORT_ACTION_PREVIOUS ); digested = TRUE; break; case GDK_KEY_space: transport_widget_react_to_key_press_event ( transport_widget, - TRANSPORT_PLAY_PAUSE ); + TRANSPORT_ACTION_PLAY_PAUSE ); digested = TRUE; break; case GDK_Up: @@ -587,17 +587,17 @@ key_release_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) switch (event->keyval) { case GDK_Right: transport_widget_react_to_key_release_event ( transport_widget, - TRANSPORT_NEXT ); + TRANSPORT_ACTION_NEXT ); digested = TRUE; break; case GDK_Left: transport_widget_react_to_key_release_event ( transport_widget, - TRANSPORT_PREVIOUS ); + TRANSPORT_ACTION_PREVIOUS ); digested = TRUE; break; case GDK_KEY_space: transport_widget_react_to_key_release_event ( transport_widget, - TRANSPORT_PLAY_PAUSE ); + TRANSPORT_ACTION_PLAY_PAUSE ); digested = TRUE; break; case GDK_Up: diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 7838a67..6129458 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ using Dbusmenu; +using Transport; /* This class will entirely replace mpris-controller.vala hence why there is no @@ -33,7 +34,7 @@ public class Mpris2Controller : GLib.Object public Mpris2Controller(PlayerController ctrl) { - GLib.Object(owner: ctrl); + GLib.Object(owner: ctrl); } construct{ @@ -77,7 +78,7 @@ public class Mpris2Controller : GLib.Object string state = this.player.PlaybackStatus; //debug("in the property update and the playback status = %s and update = %s", state, (string)play_v); Timeout.add ( 200, ensure_correct_playback_status ); - TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(state); + Transport.State p = (Transport.State)this.determine_play_state(state); (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p); } Variant? meta_v = changed_properties.lookup("Metadata"); @@ -115,7 +116,7 @@ public class Mpris2Controller : GLib.Object private bool ensure_correct_playback_status(){ //debug("TEST playback status = %s", this.player.PlaybackStatus); - TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(this.player.PlaybackStatus); + Transport.State p = (Transport.State)this.determine_play_state(this.player.PlaybackStatus); (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p); return false; } @@ -142,19 +143,19 @@ public class Mpris2Controller : GLib.Object return changed_updates; } - private TransportMenuitem.state determine_play_state(string? status){ + private Transport.State determine_play_state(string? status){ if(status != null && status == "Playing"){ - return TransportMenuitem.state.PLAYING; + return Transport.State.PLAYING; } - return TransportMenuitem.state.PAUSED; + return Transport.State.PAUSED; } public void initial_update() { - TransportMenuitem.state update; + Transport.State update; if(this.player.PlaybackStatus == null){ - update = TransportMenuitem.state.PAUSED; + update = Transport.State.PAUSED; } else{ update = determine_play_state (this.player.PlaybackStatus); @@ -174,25 +175,25 @@ public class Mpris2Controller : GLib.Object } } - public void transport_update(TransportMenuitem.action command) + public void transport_update(Transport.Action command) { //debug("transport_event input = %i", (int)command); - if(command == TransportMenuitem.action.PLAY_PAUSE){ + if(command == Transport.Action.PLAY_PAUSE){ this.player.PlayPause.begin(); } - else if(command == TransportMenuitem.action.PREVIOUS){ + else if(command == Transport.Action.PREVIOUS){ this.player.Previous.begin(); } - else if(command == TransportMenuitem.action.NEXT){ + else if(command == Transport.Action.NEXT){ this.player.Next.begin(); } - else if(command == TransportMenuitem.action.REWIND){ - debug("transport_event rewind = %i", (int)command); + else if(command == Transport.Action.REWIND){ + //debug("transport_event rewind = %i", (int)command); this.player.Seek.begin(-500000); } - else if(command == TransportMenuitem.action.FORWIND){ - debug("transport_event input = %i", (int)command); - this.player.Seek.begin(350000); + else if(command == Transport.Action.FORWIND){ + //debug("transport_event input = %i", (int)command); + this.player.Seek.begin(400000); } } diff --git a/src/sound-service.c b/src/sound-service.c index c79b9f6..eeab33e 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -40,8 +40,10 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); +/* close_pulse_activites(); g_main_loop_quit(mainloop); +*/ } return; diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index d5ae283..67e9562 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -20,21 +20,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>. using Dbusmenu; using Gee; using DbusmenuTransport; +using Transport; public class TransportMenuitem : PlayerItem { - public enum action{ - PREVIOUS, - PLAY_PAUSE, - NEXT, - REWIND, - FORWIND - } - - public enum state{ - PLAYING, - PAUSED - } public TransportMenuitem(PlayerController parent) { @@ -42,7 +31,7 @@ public class TransportMenuitem : PlayerItem this.property_set_int(MENUITEM_PLAY_STATE, 1); } - public void change_play_state(state update) + public void change_play_state(Transport.State update) { //debug("UPDATING THE TRANSPORT DBUSMENUITEM PLAY STATE WITH VALUE %i", // (int)update); @@ -64,7 +53,7 @@ public class TransportMenuitem : PlayerItem int32 input = v.get_int32(); //debug("transport menu item -> handle_event with value %s", input.to_string()); //debug("transport owner name = %s", this.owner.app_info.get_name()); - this.owner.mpris_bridge.transport_update((action)input); + this.owner.mpris_bridge.transport_update((Transport.Action)input); } public static HashSet<string> attributes_format() |