~ubuntu-branches/ubuntu/natty/indicator-sound/natty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Ken VanDine
  • Date: 2011-03-23 12:03:02 UTC
  • mfrom: (67.1.23 indicator-sound-ubuntu)
  • Revision ID: james.westby@ubuntu.com-20110323120302-7dv2px8v6pa72a69
Tags: 0.6.5-0ubuntu1
* New upstream release.
  - Media player should be automatically started up when play button is 
    pressed (LP: #714750)
  - volume goes to zero when using some players like banshee or 
    rhythmbox (LP: #730925)
  - handle banshee id change (LP: #737447)
  - filter out video playlists (LP: #739273)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
using Transport;
24
24
 
25
25
public class TransportMenuitem : PlayerItem
26
 
{
27
 
  
 
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
 
28
35
  public TransportMenuitem(PlayerController parent)
29
36
  {
30
37
    Object(item_type: MENUITEM_TYPE, owner: parent);
31
 
    this.property_set_int(MENUITEM_PLAY_STATE, 1);
32
 
  }
33
 
 
34
 
  public void change_play_state(Transport.State update)
35
 
  {
36
 
    //debug("UPDATING THE TRANSPORT DBUSMENUITEM PLAY STATE WITH VALUE %i",
37
 
    //      (int)update);
 
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
  {
38
64
    int temp = (int)update;
39
65
    this.property_set_int(MENUITEM_PLAY_STATE, temp); 
40
66
  }
43
69
                                    Variant input_value,
44
70
                                    uint timestamp)
45
71
  {
46
 
    /*debug ( "Handle event in transport menu item - input variant is of type %s", 
47
 
             input_value.get_type_string() );*/
48
72
    Variant v = input_value;
49
 
    if ( input_value.is_of_type ( VariantType.VARIANT) ){
 
73
    if ( input_value.is_of_type (VariantType.VARIANT)){
50
74
      v = input_value.get_variant();
51
75
    }
52
76
    
53
77
    int32 input = v.get_int32();
54
 
    //debug("transport menu item -> handle_event with value %s", input.to_string());
55
 
    //debug("transport owner name = %s", this.owner.app_info.get_name());
56
 
    this.owner.mpris_bridge.transport_update((Transport.Action)input);
 
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
    }
57
87
  } 
58
88
 
59
89
  public static HashSet<string> attributes_format()
63
93
    return attrs;
64
94
  } 
65
95
 
66
 
}
 
 
b'\\ No newline at end of file'
 
96
}