Merge lp:~parnold-x/wingpanel-indicator-ayatana/blacklist_support into lp:~wingpanel-devs/wingpanel-indicator-ayatana/trunk

Proposed by Djax on 2016-07-24
Status: Merged
Approved by: Cody Garver on 2016-07-28
Approved revision: 16
Merged at revision: 16
Proposed branch: lp:~parnold-x/wingpanel-indicator-ayatana/blacklist_support
Merge into: lp:~wingpanel-devs/wingpanel-indicator-ayatana/trunk
Diff against target: 86 lines (+39/-3)
1 file modified
src/Indicator.vala (+39/-3)
To merge this branch: bzr merge lp:~parnold-x/wingpanel-indicator-ayatana/blacklist_support
Reviewer Review Type Date Requested Status
Felipe Escoto 2016-07-24 Approve on 2016-07-28
Kirill Romanov (community) test Approve on 2016-07-27
Review via email: mp+301008@code.launchpad.net

Commit message

support for ayatana.blacklist in /etc/wingpanel.d/

To post a comment you must log in.
16. By Djax on 2016-07-24

support for ayatana.blacklist in /etc/wingpanel.d/

Kirill Romanov (djaler1) wrote :

Works great. The code also fine.

review: Approve (test)
Felipe Escoto (philip.scott) wrote :

I can also confirm the blacklist works! Tested with also blacklisting steam.

Waiting for https://code.launchpad.net/~djaler1/wingpanel-indicator-ayatana/fix-bug-1603643 to get approved before merging to have it all build at once

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Indicator.vala'
2--- src/Indicator.vala 2015-06-20 17:55:36 +0000
3+++ src/Indicator.vala 2016-07-24 18:47:16 +0000
4@@ -16,7 +16,7 @@
5 */
6
7 public class AyatanaCompatibility.MetaIndicator : Wingpanel.Indicator {
8-
9+ private Gee.HashSet<string> blacklist;
10 private IndicatorFactory indicator_loader;
11
12 public MetaIndicator () {
13@@ -24,13 +24,15 @@
14 display_name: _("Ayatana Compatibility"),
15 description:_("Ayatana Compatibility Meta Indicator"));
16
17+ load_blacklist ();
18 indicator_loader = new IndicatorFactory ();
19
20 this.visible = false;
21 var indicators = indicator_loader.get_indicators ();
22
23- foreach (var indicator in indicators)
24+ foreach (var indicator in indicators) {
25 load_indicator (indicator);
26+ }
27 }
28
29 public override Gtk.Widget get_display_widget () {
30@@ -40,14 +42,19 @@
31 private void load_indicator (IndicatorIface indicator) {
32 var entries = indicator.get_entries ();
33
34- foreach (var entry in entries)
35+ foreach (var entry in entries) {
36 create_entry (entry);
37+ }
38
39 indicator.entry_added.connect (create_entry);
40 indicator.entry_removed.connect (delete_entry);
41 }
42
43 private void create_entry (Indicator indicator) {
44+ if (blacklist.contains (indicator.name_hint ())) {
45+ return;
46+ }
47+
48 Wingpanel.IndicatorManager.get_default ().register_indicator (indicator.code_name, indicator);
49 }
50
51@@ -65,6 +72,35 @@
52 public override void closed () {
53 }
54
55+ private void load_blacklist () {
56+ blacklist = new Gee.HashSet<string> ();
57+ var blacklist_file = File.new_for_path ("/etc/wingpanel.d/ayatana.blacklist");
58+ foreach (var entry in get_restrictions_from_file (blacklist_file)) {
59+ blacklist.add (entry);
60+ }
61+ }
62+
63+ private string[] get_restrictions_from_file (File file) {
64+ var restrictions = new string[] {};
65+
66+ if (file.query_exists ()) {
67+ try {
68+ var dis = new DataInputStream (file.read ());
69+ string? line = null;
70+
71+ while ((line = dis.read_line ()) != null) {
72+ if (line.strip () != "") {
73+ restrictions += line;
74+ }
75+ }
76+ } catch (Error error) {
77+ warning ("Unable to load restrictions file %s: %s\n", file.get_basename (), error.message);
78+ }
79+ }
80+
81+ return restrictions;
82+ }
83+
84 }
85
86 public Wingpanel.Indicator? get_indicator (Module module, Wingpanel.IndicatorManager.ServerType server_type) {

Subscribers

People subscribed via source and target branches

to all changes: