~ubuntu-branches/ubuntu/quantal/indicator-sound/quantal

« back to all changes in this revision

Viewing changes to src/transport-menu-item.vala

  • Committer: Ken VanDine
  • Date: 2012-03-16 17:59:34 UTC
  • mfrom: (28.174.10)
  • mto: This revision was merged to the branch mainline in revision 110.
  • Revision ID: ken.vandine@canonical.com-20120316175934-90d5u1pg365513an
* New upstream release.
  - indicator-sound "Choose Playlist" menu item does nothing when using 
    Rhythmbox (LP: #952550)
  - crashed with SIGSEGV in g_strdup() (LP: #946607)
  - crashed with SIGABRT in pa_operation_unref() (LP: #944148)
  - crashed with signal 5 in g_type_create_instance() (LP: #921755)
  - slider on unmute resets volume (LP: #921065)
  - play controls not exposed in HUD (LP: #949032)
  - unity-panel-service at 100% cpu when opened /w rb without album 
    cover (LP: #806848)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
Copyright 2010 Canonical Ltd.
3
 
 
4
 
Authors:
5
 
    Conor Curran <conor.curran@canonical.com>
6
 
 
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.
10
 
 
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.
15
 
 
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/>.
18
 
*/
19
 
 
20
 
using Dbusmenu;
21
 
using Gee;
22
 
using DbusmenuTransport;
23
 
using Transport;
24
 
 
25
 
public class TransportMenuitem : PlayerItem
26
 
27
 
  private Transport.Action cached_action;
28
 
 
29
 
  private bool running {
30
 
    get{
31
 
      return this.owner.current_state == PlayerController.state.CONNECTED;
32
 
    } 
33
 
  }
34
 
 
35
 
  public TransportMenuitem(PlayerController parent)
36
 
  {
37
 
    Object(item_type: MENUITEM_TYPE, owner: parent);
38
 
  }
39
 
  construct{
40
 
    this.property_set_int(MENUITEM_PLAY_STATE, (int)Transport.State.PAUSED);
41
 
    this.cached_action = Transport.Action.NO_ACTION;
42
 
  }
43
 
 
44
 
  /**
45
 
  Please remove this timeout when the default player can handle mpris commands
46
 
  immediately once it raises its dbus interface
47
 
  **/
48
 
  public void handle_cached_action()
49
 
  {
50
 
    if (this.cached_action != Transport.Action.NO_ACTION){
51
 
      Timeout.add_seconds (1, send_cached_action);
52
 
    }
53
 
  }
54
 
 
55
 
  private bool send_cached_action()
56
 
  {
57
 
    this.owner.mpris_bridge.transport_update(this.cached_action);
58
 
    this.cached_action = Transport.Action.NO_ACTION;
59
 
    return false;
60
 
  }
61
 
 
62
 
  public void change_play_state (Transport.State update)
63
 
  {
64
 
    int temp = (int)update;
65
 
    this.property_set_int(MENUITEM_PLAY_STATE, temp); 
66
 
  }
67
 
  
68
 
  public override void handle_event(string name,
69
 
                                    Variant input_value,
70
 
                                    uint timestamp)
71
 
  {
72
 
    Variant v = input_value;
73
 
    if ( input_value.is_of_type (VariantType.VARIANT)){
74
 
      v = input_value.get_variant();
75
 
    }
76
 
    
77
 
    int32 input = v.get_int32();
78
 
    
79
 
    if (this.running == true){
80
 
      this.owner.mpris_bridge.transport_update((Transport.Action)input);
81
 
    }
82
 
    else{
83
 
      this.cached_action = (Transport.Action)input;
84
 
      this.owner.instantiate();
85
 
      this.property_set_int (MENUITEM_PLAY_STATE, (int)Transport.State.LAUNCHING);
86
 
    }
87
 
  } 
88
 
 
89
 
  public static HashSet<string> attributes_format()
90
 
  {
91
 
    HashSet<string> attrs = new HashSet<string>();    
92
 
    attrs.add(MENUITEM_PLAY_STATE);
93
 
    return attrs;
94
 
  } 
95
 
 
96
 
}