2
Copyright 2010 Canonical Ltd.
5
Conor Curran <conor.curran@canonical.com>
7
This program is free software: you can redistribute it and/or modify it
8
under the terms of the GNU General Public License version 3, as published
9
by the Free Software Foundation.
11
This program is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranties of
13
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
PURPOSE. See the GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License along
17
with this program. If not, see <http://www.gnu.org/licenses/>.
22
using DbusmenuTransport;
25
public class TransportMenuitem : PlayerItem
27
private Transport.Action cached_action;
29
private bool running {
31
return this.owner.current_state == PlayerController.state.CONNECTED;
35
public TransportMenuitem(PlayerController parent)
37
Object(item_type: MENUITEM_TYPE, owner: parent);
40
this.property_set_int(MENUITEM_PLAY_STATE, (int)Transport.State.PAUSED);
41
this.cached_action = Transport.Action.NO_ACTION;
45
Please remove this timeout when the default player can handle mpris commands
46
immediately once it raises its dbus interface
48
public void handle_cached_action()
50
if (this.cached_action != Transport.Action.NO_ACTION){
51
Timeout.add_seconds (1, send_cached_action);
55
private bool send_cached_action()
57
this.owner.mpris_bridge.transport_update(this.cached_action);
58
this.cached_action = Transport.Action.NO_ACTION;
62
public void change_play_state (Transport.State update)
64
int temp = (int)update;
65
this.property_set_int(MENUITEM_PLAY_STATE, temp);
68
public override void handle_event(string name,
72
Variant v = input_value;
73
if ( input_value.is_of_type (VariantType.VARIANT)){
74
v = input_value.get_variant();
77
int32 input = v.get_int32();
79
if (this.running == true){
80
this.owner.mpris_bridge.transport_update((Transport.Action)input);
83
this.cached_action = (Transport.Action)input;
84
this.owner.instantiate();
85
this.property_set_int (MENUITEM_PLAY_STATE, (int)Transport.State.LAUNCHING);
89
public static HashSet<string> attributes_format()
91
HashSet<string> attrs = new HashSet<string>();
92
attrs.add(MENUITEM_PLAY_STATE);