mate applet: Use name+path for icon keys instead of just the name.
This is necessary now that multiple icons can appear under the same
name.
Michael Webster
2 years ago
371 | 371 | self.monitor.connect("icon-added", self.on_icon_added) |
372 | 372 | self.monitor.connect("icon-removed", self.on_icon_removed) |
373 | 373 | |
374 | def make_key(self, proxy): | |
375 | name = proxy.get_name() | |
376 | path = proxy.get_object_path() | |
377 | ||
378 | print("Key: %s" % (name+path)) | |
379 | return name + path | |
380 | ||
374 | 381 | def destroy_monitor (self): |
375 | 382 | for key in self.indicators.keys(): |
376 | 383 | self.indicator_box.remove(self.indicators[key]) |
379 | 386 | self.indicators = {} |
380 | 387 | |
381 | 388 | def on_icon_added(self, monitor, proxy): |
382 | name = proxy.get_name() | |
383 | ||
384 | self.indicators[name] = StatusWidget(proxy, self.applet.get_orient(), self.applet.get_size()) | |
385 | self.indicator_box.add(self.indicators[name]) | |
386 | self.indicators[name].connect("re-sort", self.sort_icons) | |
389 | key = self.make_key(proxy) | |
390 | ||
391 | self.indicators[key] = StatusWidget(proxy, self.applet.get_orient(), self.applet.get_size()) | |
392 | self.indicator_box.add(self.indicators[key]) | |
393 | self.indicators[key].connect("re-sort", self.sort_icons) | |
387 | 394 | |
388 | 395 | self.sort_icons() |
389 | 396 | |
390 | 397 | def on_icon_removed(self, monitor, proxy): |
391 | name = proxy.get_name() | |
392 | ||
393 | self.indicator_box.remove(self.indicators[name]) | |
394 | self.indicators[name].disconnect_by_func(self.sort_icons) | |
395 | del(self.indicators[name]) | |
398 | key = self.make_key(proxy) | |
399 | ||
400 | self.indicator_box.remove(self.indicators[key]) | |
401 | self.indicators[key].disconnect_by_func(self.sort_icons) | |
402 | del(self.indicators[key]) | |
396 | 403 | |
397 | 404 | self.sort_icons() |
398 | 405 |