~marcobiscaro2112/unity/fixes-724739

« back to all changes in this revision

Viewing changes to src/PanelTray.cpp

  • Committer: Neil Jagdish Patel
  • Date: 2011-02-14 20:37:44 UTC
  • mto: This revision was merged to the branch mainline in revision 867.
  • Revision ID: neil.patel@canonical.com-20110214203744-ldo9poldicn196a2
Implement whitelisting for Skype, Java and Wine apps

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
#include "PanelTray.h"
20
20
 
 
21
#define SETTINGS_NAME "com.canonical.Unity.Panel"
 
22
 
21
23
PanelTray::PanelTray ()
22
24
: _n_children (0),
23
25
  _last_x (0),
24
26
  _last_y (0)
25
27
{
 
28
  _settings = g_settings_new (SETTINGS_NAME);
 
29
  _whitelist = g_settings_get_strv (_settings, "systray-whitelist");
 
30
 
26
31
  _window = gtk_window_new (GTK_WINDOW_POPUP);
27
32
  gtk_window_set_type_hint (GTK_WINDOW (_window), GDK_WINDOW_TYPE_HINT_DOCK);
28
33
  gtk_window_set_keep_above (GTK_WINDOW (_window), TRUE);
55
60
 
56
61
PanelTray::~PanelTray ()
57
62
{
 
63
  g_strfreev (_whitelist);
 
64
  g_object_unref (_settings);
58
65
}
59
66
 
60
67
void
89
96
gboolean
90
97
PanelTray::FilterTrayCallback (NaTray *tray, NaTrayChild *icon, PanelTray *self)
91
98
{
 
99
  char *title;
92
100
  char *res_name = NULL;
93
101
  char *res_class = NULL;
 
102
  char *name;
 
103
  int   i = 0;
 
104
  bool  accept = false;
94
105
 
 
106
  title = na_tray_child_get_title (icon);
95
107
  na_tray_child_get_wm_class (icon, &res_name, &res_class);
96
 
  if (na_tray_child_has_alpha (icon))
97
 
    na_tray_child_set_composited (icon, TRUE);
 
108
 
 
109
  while ((name = self->_whitelist[i]))
 
110
  {
 
111
    if (g_strcmp0 (name, "all") == 0)
 
112
    {
 
113
      accept = true;
 
114
      break;
 
115
    }
 
116
    else if (!name || g_strcmp0 (name, "") == 0)
 
117
    {
 
118
      accept = false;
 
119
      break;
 
120
    }
 
121
    else if (g_str_has_prefix (title, name)
 
122
             || g_str_has_prefix (res_name, name)
 
123
             || g_str_has_prefix (res_class, name))
 
124
    {
 
125
      accept = true;
 
126
      break;
 
127
    }
 
128
 
 
129
    i++;
 
130
  }
 
131
 
 
132
  if (accept)
 
133
  {
 
134
    if (na_tray_child_has_alpha (icon))
 
135
      na_tray_child_set_composited (icon, TRUE);
 
136
 
 
137
    self->_n_children++;
 
138
    g_idle_add ((GSourceFunc)IdleSync, self);
 
139
  }
98
140
 
99
141
  g_debug ("TrayChild %s: %s %s", na_tray_child_get_title (icon), res_name, res_class);
100
142
  
101
143
  g_free (res_name);
102
144
  g_free (res_class);
103
 
 
104
 
  self->_n_children++;  
105
 
 
106
 
  g_idle_add ((GSourceFunc)IdleSync, self);
107
 
  return TRUE;
 
145
  g_free (title);
 
146
 
 
147
  return accept ? TRUE : FALSE;
108
148
}
109
149
 
110
150
void