~unity-team/unity/remote-panel

« back to all changes in this revision

Viewing changes to unity-private/panel/panel-indicator-model.vala

  • Committer: Neil Jagdish Patel
  • Date: 2010-07-12 15:51:07 UTC
  • Revision ID: neil.patel@canonical.com-20100712155107-c93nwqa5k0gd3qcc
Add some support for restarting the service

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
 
58
58
    public Dee.Model indicators_model;
59
59
 
 
60
    dynamic DBus.Object service;
 
61
 
60
62
    public IndicatorsDbusModel ()
61
63
    {
62
64
      Object ();
64
66
 
65
67
    construct
66
68
    {
 
69
      reconnect ();
 
70
 
67
71
      indicators = new Gee.ArrayList<Indicator.Object> ();
68
72
 
69
73
      indicators_model = new Dee.SharedModel.with_name (name);
70
74
      (indicators_model as Dee.SharedModel).connect ();
71
75
    }
72
76
 
 
77
    private void reconnect ()
 
78
    {
 
79
      try {
 
80
        var conn = DBus.Bus.get (DBus.BusType.SESSION);
 
81
 
 
82
        service = conn.get_object_for_name_owner ("com.canonical.Unity.Panel.Service",
 
83
                                                  "/com.canonical/Unity/Panel/Service",
 
84
                                                  "com.canonical.Unity.Panel.Service");
 
85
        service.destroy.connect (on_service_lost);
 
86
 
 
87
      } catch (Error e) {
 
88
        warning ("Unable to connect to Unity panel indicator service: %s",
 
89
                 e.message);
 
90
      }
 
91
    }
 
92
 
 
93
    private void on_service_lost ()
 
94
    {
 
95
      /* Remove all the indicators before re-connecting, otherwise we'll have
 
96
       * double indicators
 
97
       */
 
98
     indicators_model.clear ();
 
99
 
 
100
     reconnect ();
 
101
    }
 
102
 
73
103
    public override Gee.ArrayList<Indicator.Object> get_indicators ()
74
104
    {
75
105
      return indicators;