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.property_set (MENUITEM_PROP_LABEL, this.owner.app_info.get_name());
42
this.cached_action = Transport.Action.NO_ACTION;
46
Please remove this timeout when the default player can handle mpris commands
47
immediately once it raises its dbus interface
49
public void handle_cached_action()
51
if (this.cached_action != Transport.Action.NO_ACTION){
52
Timeout.add_seconds (1, send_cached_action);
56
private bool send_cached_action()
58
this.owner.mpris_bridge.transport_update(this.cached_action);
59
this.cached_action = Transport.Action.NO_ACTION;
63
public void change_play_state (Transport.State update)
65
int temp = (int)update;
66
this.property_set_int(MENUITEM_PLAY_STATE, temp);
69
public override void handle_event(string name,
73
Variant v = input_value;
74
if ( input_value.is_of_type (VariantType.VARIANT)){
75
v = input_value.get_variant();
78
int32 input = v.get_int32();
80
if (this.running == true){
81
this.owner.mpris_bridge.transport_update((Transport.Action)input);
84
this.cached_action = (Transport.Action)input;
85
this.owner.instantiate();
86
this.property_set_int (MENUITEM_PLAY_STATE, (int)Transport.State.LAUNCHING);
90
public static HashSet<string> attributes_format()
92
HashSet<string> attrs = new HashSet<string>();
93
attrs.add(MENUITEM_PLAY_STATE);