~didrocks/unity/connect-on-super

« back to all changes in this revision

Viewing changes to src/PanelTray.cpp

  • Committer: Neil Jagdish Patel
  • Date: 2011-04-14 13:30:37 UTC
  • mfrom: (1119.2.8 fixes-2011-04-14)
  • Revision ID: neil.patel@canonical.com-20110414133037-7574sejjs6a5crp6
Defer the loading of the place daemons (calling Connect () on a Place) until
just before we actually require them. This allows us to avoid trashing the
CPU or disk on log in by starting up N place daemons that could set off
a bunch of other things.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
PanelTray::PanelTray ()
25
25
: _n_children (0),
 
26
  _tray (NULL),
26
27
  _last_x (0),
27
 
  _last_y (0)
 
28
  _last_y (0),
 
29
  _tray_icon_added_id (0)
28
30
{
29
31
  _settings = g_settings_new (SETTINGS_NAME);
30
32
  _whitelist = g_settings_get_strv (_settings, "systray-whitelist");
50
52
                                    GTK_ORIENTATION_HORIZONTAL,
51
53
                                    (NaTrayFilterCallback)FilterTrayCallback,
52
54
                                    this);
53
 
    g_signal_connect (na_tray_get_manager (_tray), "tray_icon_removed",
54
 
                      G_CALLBACK (PanelTray::OnTrayIconRemoved), this);
 
55
    _tray_icon_added_id = g_signal_connect (na_tray_get_manager (_tray), "tray_icon_removed",
 
56
                                            G_CALLBACK (PanelTray::OnTrayIconRemoved), this);
55
57
 
56
58
    gtk_container_add (GTK_CONTAINER (_window), GTK_WIDGET (_tray));
57
59
    gtk_widget_show (GTK_WIDGET (_tray));
62
64
 
63
65
PanelTray::~PanelTray ()
64
66
{
 
67
  if (_tray)
 
68
  {
 
69
    g_signal_handler_disconnect (na_tray_get_manager (_tray), _tray_icon_added_id);
 
70
    g_object_unref (_tray);
 
71
    _tray = NULL;
 
72
  }
 
73
 
 
74
  g_idle_remove_by_data (this);
 
75
 
65
76
  if (_tray_expose_id)
66
77
    g_signal_handler_disconnect (_window, _tray_expose_id);
67
 
  g_idle_remove_by_data (this);
68
78
  
 
79
  gtk_widget_destroy (_window);
69
80
  g_strfreev (_whitelist);
70
81
  g_object_unref (_settings);
71
82
}
93
104
void
94
105
PanelTray::Sync ()
95
106
{
96
 
  SetMinMaxSize ((_n_children * 24) + (PADDING * 2), 24);
97
 
  QueueRelayout ();
98
 
  QueueDraw ();
 
107
  if (_tray)
 
108
  {
 
109
    SetMinMaxSize ((_n_children * 24) + (PADDING * 2), 24);
 
110
    QueueRelayout ();
 
111
    QueueDraw ();
 
112
  }
99
113
}
100
114
 
101
115
gboolean