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

Proposed by Djax
Status: Merged
Approved by: Cody Garver
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 Approve
Kirill Romanov (community) test Approve
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

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

Revision history for this message
Kirill Romanov (djaler1) wrote :

Works great. The code also fine.

review: Approve (test)
Revision history for this message
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
=== modified file 'src/Indicator.vala'
--- src/Indicator.vala 2015-06-20 17:55:36 +0000
+++ src/Indicator.vala 2016-07-24 18:47:16 +0000
@@ -16,7 +16,7 @@
16 */16 */
1717
18public class AyatanaCompatibility.MetaIndicator : Wingpanel.Indicator {18public class AyatanaCompatibility.MetaIndicator : Wingpanel.Indicator {
1919 private Gee.HashSet<string> blacklist;
20 private IndicatorFactory indicator_loader;20 private IndicatorFactory indicator_loader;
2121
22 public MetaIndicator () {22 public MetaIndicator () {
@@ -24,13 +24,15 @@
24 display_name: _("Ayatana Compatibility"),24 display_name: _("Ayatana Compatibility"),
25 description:_("Ayatana Compatibility Meta Indicator"));25 description:_("Ayatana Compatibility Meta Indicator"));
2626
27 load_blacklist ();
27 indicator_loader = new IndicatorFactory ();28 indicator_loader = new IndicatorFactory ();
2829
29 this.visible = false;30 this.visible = false;
30 var indicators = indicator_loader.get_indicators ();31 var indicators = indicator_loader.get_indicators ();
3132
32 foreach (var indicator in indicators)33 foreach (var indicator in indicators) {
33 load_indicator (indicator);34 load_indicator (indicator);
35 }
34 }36 }
3537
36 public override Gtk.Widget get_display_widget () {38 public override Gtk.Widget get_display_widget () {
@@ -40,14 +42,19 @@
40 private void load_indicator (IndicatorIface indicator) {42 private void load_indicator (IndicatorIface indicator) {
41 var entries = indicator.get_entries ();43 var entries = indicator.get_entries ();
4244
43 foreach (var entry in entries)45 foreach (var entry in entries) {
44 create_entry (entry);46 create_entry (entry);
47 }
4548
46 indicator.entry_added.connect (create_entry);49 indicator.entry_added.connect (create_entry);
47 indicator.entry_removed.connect (delete_entry);50 indicator.entry_removed.connect (delete_entry);
48 }51 }
4952
50 private void create_entry (Indicator indicator) {53 private void create_entry (Indicator indicator) {
54 if (blacklist.contains (indicator.name_hint ())) {
55 return;
56 }
57
51 Wingpanel.IndicatorManager.get_default ().register_indicator (indicator.code_name, indicator);58 Wingpanel.IndicatorManager.get_default ().register_indicator (indicator.code_name, indicator);
52 }59 }
5360
@@ -65,6 +72,35 @@
65 public override void closed () {72 public override void closed () {
66 }73 }
6774
75 private void load_blacklist () {
76 blacklist = new Gee.HashSet<string> ();
77 var blacklist_file = File.new_for_path ("/etc/wingpanel.d/ayatana.blacklist");
78 foreach (var entry in get_restrictions_from_file (blacklist_file)) {
79 blacklist.add (entry);
80 }
81 }
82
83 private string[] get_restrictions_from_file (File file) {
84 var restrictions = new string[] {};
85
86 if (file.query_exists ()) {
87 try {
88 var dis = new DataInputStream (file.read ());
89 string? line = null;
90
91 while ((line = dis.read_line ()) != null) {
92 if (line.strip () != "") {
93 restrictions += line;
94 }
95 }
96 } catch (Error error) {
97 warning ("Unable to load restrictions file %s: %s\n", file.get_basename (), error.message);
98 }
99 }
100
101 return restrictions;
102 }
103
68}104}
69105
70public Wingpanel.Indicator? get_indicator (Module module, Wingpanel.IndicatorManager.ServerType server_type) {106public Wingpanel.Indicator? get_indicator (Module module, Wingpanel.IndicatorManager.ServerType server_type) {

Subscribers

People subscribed via source and target branches

to all changes: