Merge lp:~midori/midori/adblock-icon into lp:midori

Proposed by Paweł Forysiuk
Status: Merged
Merge reported by: Cris Dywan
Merged at revision: not available
Proposed branch: lp:~midori/midori/adblock-icon
Merge into: lp:midori
Diff against target: 372 lines (+289/-3)
6 files modified
data/adblock/adblock-disabled.svg (+46/-0)
data/adblock/adblock-enabled.svg (+80/-0)
data/adblock/adblock-enabled2.svg (+46/-0)
data/adblock/adblock-symbolic.svg (+46/-0)
extensions/adblock/config.vala (+7/-1)
extensions/adblock/extension.vala (+64/-2)
To merge this branch: bzr merge lp:~midori/midori/adblock-icon
Reviewer Review Type Date Requested Status
Midori Devs Pending
Review via email: mp+208964@code.launchpad.net

Commit message

Add adblock icon to statusbar

Description of the change

[Todo]
- make it work properly with different browser windows
- enable/disable on middle click
- disable per domain/tab - would need some kind of backend in the end
- nicer icons

To post a comment you must log in.
lp:~midori/midori/adblock-icon updated
6579. By Paweł Forysiuk

Save a preference of wheter adblock was disabled or not

6580. By Paweł Forysiuk

Specify widget to Katze.popup_widget

6581. By Paweł Forysiuk

Tweak option text

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'data/adblock'
2=== added file 'data/adblock/adblock-disabled.svg'
3--- data/adblock/adblock-disabled.svg 1970-01-01 00:00:00 +0000
4+++ data/adblock/adblock-disabled.svg 2014-03-02 17:51:55 +0000
5@@ -0,0 +1,46 @@
6+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
7+<!-- Created with Inkscape (http://www.inkscape.org/) -->
8+
9+<svg
10+ xmlns:dc="http://purl.org/dc/elements/1.1/"
11+ xmlns:cc="http://creativecommons.org/ns#"
12+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
13+ xmlns:svg="http://www.w3.org/2000/svg"
14+ xmlns="http://www.w3.org/2000/svg"
15+ version="1.1"
16+ width="16"
17+ height="16"
18+ id="svg7384">
19+ <title
20+ id="title9167">Gnome Symbolic Icon Theme</title>
21+ <defs
22+ id="defs10" />
23+ <metadata
24+ id="metadata90">
25+ <rdf:RDF>
26+ <cc:Work
27+ rdf:about="">
28+ <dc:format>image/svg+xml</dc:format>
29+ <dc:type
30+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
31+ <dc:title>Gnome Symbolic Icon Theme</dc:title>
32+ </cc:Work>
33+ </rdf:RDF>
34+ </metadata>
35+ <g
36+ transform="translate(-111.61542,-601.4038)"
37+ id="layer12">
38+ <path
39+ d="m 228.01,607.02 c -3.86,0 -7.0073,3.166 -7.0073,7.0103 0,3.8443 3.1472,6.9787 7.0073,6.9787 3.86,0 7.0073,-3.1344 7.0073,-6.9787 0,-3.8443 -3.1472,-7.0103 -7.0073,-7.0103 z m 0,2.021 c 2.7769,0 5.0097,2.2237 5.0097,4.9893 0,2.7656 -2.2328,4.9577 -5.0097,4.9577 -2.777,0 -5.0097,-2.1921 -5.0097,-4.9577 0,-2.7656 2.2328,-4.9893 5.0097,-4.9893 z"
40+ id="path4222"
41+ style="text-indent:0;text-transform:none;block-progression:tb;color:#000000;fill:#bebebe" />
42+ <path
43+ d="m 231.41,609.44 -8,8 1.4062,1.4062 8,-8 -1.4062,-1.4062 z"
44+ id="path4992"
45+ style="text-indent:0;text-transform:none;block-progression:tb;color:#000000;fill:#bebebe" />
46+ </g>
47+ <path
48+ d="m 7.96875,0.6875 c -2.8420838,0 -2.8771973,1.9949742 -6.625,2.3125 0,0 -0.98752557,2.5363552 0.34375,6 0.8399195,2.18526 4.3935259,5.981297 6.1875,6 l 0.25,0 C 9.9189736,14.9813 13.472581,11.18526 14.3125,9 15.643775,5.5363552 14.65625,3 14.65625,3 10.908448,2.6824742 10.873333,0.6875 8.03125,0.6875 l -0.0625,0 z m -0.625,2 c 0.1719617,-0.02159 0.3665606,0 0.625,0 l 0.0625,0 c 1.0337572,0 1.1746055,0.1513488 2.03125,0.625 0.133299,0.073703 0.361318,0.1808693 0.53125,0.28125 L 4.0625,9.25 C 3.8118632,8.860346 3.6127069,8.4931804 3.53125,8.28125 2.8541774,6.5196771 2.8806279,5.4183698 3,4.65625 4.2800363,4.3579974 5.3166759,3.6557627 5.9375,3.3125 6.5799833,2.9572616 6.8278648,2.7522692 7.34375,2.6875 z m 5.21875,1.84375 c 0.146121,0.046432 0.28409,0.089255 0.4375,0.125 0.119372,0.7621199 0.145822,1.863427 -0.53125,3.625 -0.223946,0.5826518 -1.210812,2.079776 -2.28125,3.15625 -0.535219,0.538237 -1.0931989,0.993886 -1.53125,1.28125 -0.2903916,0.190498 -0.5086712,0.283423 -0.5625,0.3125 l -0.15625,0 C 7.9117131,13.007739 7.6583409,12.925123 7.34375,12.71875 6.905699,12.431386 6.3477189,11.975737 5.8125,11.4375 5.6307383,11.254713 5.4548666,11.044257 5.28125,10.84375 l 7.28125,-6.3125 z"
49+ id="path3016-2"
50+ style="color:#000000;fill:#cc0000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
51+</svg>
52
53=== added file 'data/adblock/adblock-enabled.svg'
54--- data/adblock/adblock-enabled.svg 1970-01-01 00:00:00 +0000
55+++ data/adblock/adblock-enabled.svg 2014-03-02 17:51:55 +0000
56@@ -0,0 +1,80 @@
57+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
58+<!-- Created with Inkscape (http://www.inkscape.org/) -->
59+
60+<svg
61+ xmlns:dc="http://purl.org/dc/elements/1.1/"
62+ xmlns:cc="http://creativecommons.org/ns#"
63+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
64+ xmlns:svg="http://www.w3.org/2000/svg"
65+ xmlns="http://www.w3.org/2000/svg"
66+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
67+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
68+ version="1.1"
69+ width="16"
70+ height="16"
71+ id="svg7384"
72+ inkscape:version="0.48.4 r9939"
73+ sodipodi:docname="adblock-enabled.svg">
74+ <sodipodi:namedview
75+ pagecolor="#ffffff"
76+ bordercolor="#666666"
77+ borderopacity="1"
78+ objecttolerance="10"
79+ gridtolerance="10"
80+ guidetolerance="10"
81+ inkscape:pageopacity="0"
82+ inkscape:pageshadow="2"
83+ inkscape:window-width="1920"
84+ inkscape:window-height="1026"
85+ id="namedview10"
86+ showgrid="false"
87+ inkscape:zoom="14.75"
88+ inkscape:cx="8"
89+ inkscape:cy="8"
90+ inkscape:window-x="0"
91+ inkscape:window-y="32"
92+ inkscape:window-maximized="1"
93+ inkscape:current-layer="svg7384" />
94+ <title
95+ id="title9167">Gnome Symbolic Icon Theme</title>
96+ <defs
97+ id="defs10" />
98+ <metadata
99+ id="metadata90">
100+ <rdf:RDF>
101+ <cc:Work
102+ rdf:about="">
103+ <dc:format>image/svg+xml</dc:format>
104+ <dc:type
105+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
106+ <dc:title>Gnome Symbolic Icon Theme</dc:title>
107+ </cc:Work>
108+ </rdf:RDF>
109+ </metadata>
110+ <g
111+ transform="translate(-111.61542,-601.4038)"
112+ id="layer12">
113+ <path
114+ d="m 228.01,607.02 c -3.86,0 -7.0073,3.166 -7.0073,7.0103 0,3.8443 3.1472,6.9787 7.0073,6.9787 3.86,0 7.0073,-3.1344 7.0073,-6.9787 0,-3.8443 -3.1472,-7.0103 -7.0073,-7.0103 z m 0,2.021 c 2.7769,0 5.0097,2.2237 5.0097,4.9893 0,2.7656 -2.2328,4.9577 -5.0097,4.9577 -2.777,0 -5.0097,-2.1921 -5.0097,-4.9577 0,-2.7656 2.2328,-4.9893 5.0097,-4.9893 z"
115+ id="path4222"
116+ style="text-indent:0;text-transform:none;block-progression:tb;color:#000000;fill:#bebebe" />
117+ <path
118+ d="m 231.41,609.44 -8,8 1.4062,1.4062 8,-8 -1.4062,-1.4062 z"
119+ id="path4992"
120+ style="text-indent:0;text-transform:none;block-progression:tb;color:#000000;fill:#bebebe" />
121+ </g>
122+ <path
123+ d="m 7.96875,0.6875 c -2.8420838,0 -2.8771973,1.9949742 -6.625,2.3125 0,0 -0.98752557,2.5363552 0.34375,6 0.8399195,2.18526 4.3935259,5.981297 6.1875,6 l 0.25,0 C 9.9189736,14.9813 13.472581,11.18526 14.3125,9 15.643775,5.5363552 14.65625,3 14.65625,3 10.908448,2.6824742 10.873333,0.6875 8.03125,0.6875 l -0.0625,0 z m -0.625,2 c 0.1719617,-0.02159 0.3665606,0 0.625,0 l 0.0625,0 c 1.0337572,0 1.1746055,0.1513488 2.03125,0.625 0.133299,0.073703 0.361318,0.1808693 0.53125,0.28125 L 4.0625,9.25 C 3.8118632,8.860346 3.6127069,8.4931804 3.53125,8.28125 2.8541774,6.5196771 2.8806279,5.4183698 3,4.65625 4.2800363,4.3579974 5.3166759,3.6557627 5.9375,3.3125 6.5799833,2.9572616 6.8278648,2.7522692 7.34375,2.6875 z m 5.21875,1.84375 c 0.146121,0.046432 0.28409,0.089255 0.4375,0.125 0.119372,0.7621199 0.145822,1.863427 -0.53125,3.625 -0.223946,0.5826518 -1.210812,2.079776 -2.28125,3.15625 -0.535219,0.538237 -1.0931989,0.993886 -1.53125,1.28125 -0.2903916,0.190498 -0.5086712,0.283423 -0.5625,0.3125 l -0.15625,0 C 7.9117131,13.007739 7.6583409,12.925123 7.34375,12.71875 6.905699,12.431386 6.3477189,11.975737 5.8125,11.4375 5.6307383,11.254713 5.4548666,11.044257 5.28125,10.84375 l 7.28125,-6.3125 z"
124+ id="path3016-2"
125+ style="color:#000000;fill:#4e9a06;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
126+ <path
127+ style="fill:#000000;fill-opacity:0"
128+ d="M 3.8914706,8.8841635 C 3.4103263,8.1221753 3.0583616,6.8749414 3.003735,5.7383534 2.9786317,5.2160416 2.9904131,4.8722447 3.036357,4.7863976 3.0800139,4.7048241 3.2418563,4.6177843 3.4482218,4.5648944 3.8914458,4.4512995 4.5265161,4.1442388 5.8961843,3.3812883 L 7.0127075,2.7593478 7.7697676,2.7353155 C 8.6627475,2.7069685 9.052772,2.7983017 9.8276868,3.2172249 10.1089,3.3692502 10.375652,3.52161 10.420468,3.5558023 10.491273,3.609822 8.8213493,5.090833 4.1912034,9.0803713 4.0886836,9.1687069 4.0587803,9.149132 3.8914706,8.8841635 l 0,0 z"
129+ id="path2987"
130+ inkscape:connector-curvature="0" />
131+ <path
132+ style="fill:#000000;fill-opacity:0"
133+ d="M 7.5676774,12.795393 C 7.0256619,12.469009 6.4290755,11.979639 5.8305085,11.370422 5.33023,10.861243 5.3242581,10.851054 5.4600194,10.738315 5.5359114,10.675293 7.1641368,9.2661017 9.0782981,7.6067797 11.684369,5.3476641 12.594872,4.5953246 12.703024,4.6117025 c 0.291451,0.044135 0.329784,0.1886522 0.290923,1.0967721 -0.07204,1.6834953 -0.589725,2.9526655 -1.866622,4.5762714 -0.495094,0.629525 -1.366327,1.526375 -1.8854314,1.94087 C 8.8466967,12.541173 8.091686,13.030508 8,13.030508 c -0.023031,0 -0.2175765,-0.105802 -0.4323226,-0.235115 z"
134+ id="path2989"
135+ inkscape:connector-curvature="0" />
136+</svg>
137
138=== added file 'data/adblock/adblock-enabled2.svg'
139--- data/adblock/adblock-enabled2.svg 1970-01-01 00:00:00 +0000
140+++ data/adblock/adblock-enabled2.svg 2014-03-02 17:51:55 +0000
141@@ -0,0 +1,46 @@
142+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
143+<!-- Created with Inkscape (http://www.inkscape.org/) -->
144+
145+<svg
146+ xmlns:dc="http://purl.org/dc/elements/1.1/"
147+ xmlns:cc="http://creativecommons.org/ns#"
148+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
149+ xmlns:svg="http://www.w3.org/2000/svg"
150+ xmlns="http://www.w3.org/2000/svg"
151+ version="1.1"
152+ width="16"
153+ height="16"
154+ id="svg7384">
155+ <title
156+ id="title9167">Gnome Symbolic Icon Theme</title>
157+ <defs
158+ id="defs10" />
159+ <metadata
160+ id="metadata90">
161+ <rdf:RDF>
162+ <cc:Work
163+ rdf:about="">
164+ <dc:format>image/svg+xml</dc:format>
165+ <dc:type
166+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
167+ <dc:title>Gnome Symbolic Icon Theme</dc:title>
168+ </cc:Work>
169+ </rdf:RDF>
170+ </metadata>
171+ <g
172+ transform="translate(-111.61542,-601.4038)"
173+ id="layer12">
174+ <path
175+ d="m 228.01,607.02 c -3.86,0 -7.0073,3.166 -7.0073,7.0103 0,3.8443 3.1472,6.9787 7.0073,6.9787 3.86,0 7.0073,-3.1344 7.0073,-6.9787 0,-3.8443 -3.1472,-7.0103 -7.0073,-7.0103 z m 0,2.021 c 2.7769,0 5.0097,2.2237 5.0097,4.9893 0,2.7656 -2.2328,4.9577 -5.0097,4.9577 -2.777,0 -5.0097,-2.1921 -5.0097,-4.9577 0,-2.7656 2.2328,-4.9893 5.0097,-4.9893 z"
176+ id="path4222"
177+ style="text-indent:0;text-transform:none;block-progression:tb;color:#000000;fill:#bebebe" />
178+ <path
179+ d="m 231.41,609.44 -8,8 1.4062,1.4062 8,-8 -1.4062,-1.4062 z"
180+ id="path4992"
181+ style="text-indent:0;text-transform:none;block-progression:tb;color:#000000;fill:#bebebe" />
182+ </g>
183+ <path
184+ d="m 7.96875,0.6875 c -2.8420838,0 -2.8771973,1.9949742 -6.625,2.3125 0,0 -0.98752557,2.5363552 0.34375,6 0.8399195,2.18526 4.3935259,5.981297 6.1875,6 l 0.25,0 C 9.9189736,14.9813 13.472581,11.18526 14.3125,9 15.643775,5.5363552 14.65625,3 14.65625,3 10.908448,2.6824742 10.873333,0.6875 8.03125,0.6875 l -0.0625,0 z m -0.625,2 c 0.1719617,-0.02159 0.3665606,0 0.625,0 l 0.0625,0 c 1.0337572,0 1.1746055,0.1513488 2.03125,0.625 0.133299,0.073703 0.361318,0.1808693 0.53125,0.28125 L 4.0625,9.25 C 3.8118632,8.860346 3.6127069,8.4931804 3.53125,8.28125 2.8541774,6.5196771 2.8806279,5.4183698 3,4.65625 4.2800363,4.3579974 5.3166759,3.6557627 5.9375,3.3125 6.5799833,2.9572616 6.8278648,2.7522692 7.34375,2.6875 z m 5.21875,1.84375 c 0.146121,0.046432 0.28409,0.089255 0.4375,0.125 0.119372,0.7621199 0.145822,1.863427 -0.53125,3.625 -0.223946,0.5826518 -1.210812,2.079776 -2.28125,3.15625 -0.535219,0.538237 -1.0931989,0.993886 -1.53125,1.28125 -0.2903916,0.190498 -0.5086712,0.283423 -0.5625,0.3125 l -0.15625,0 C 7.9117131,13.007739 7.6583409,12.925123 7.34375,12.71875 6.905699,12.431386 6.3477189,11.975737 5.8125,11.4375 5.6307383,11.254713 5.4548666,11.044257 5.28125,10.84375 l 7.28125,-6.3125 z"
185+ id="path3016-2"
186+ style="color:#000000;fill:#ffa500;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
187+</svg>
188
189=== added file 'data/adblock/adblock-symbolic.svg'
190--- data/adblock/adblock-symbolic.svg 1970-01-01 00:00:00 +0000
191+++ data/adblock/adblock-symbolic.svg 2014-03-02 17:51:55 +0000
192@@ -0,0 +1,46 @@
193+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
194+<!-- Created with Inkscape (http://www.inkscape.org/) -->
195+
196+<svg
197+ xmlns:dc="http://purl.org/dc/elements/1.1/"
198+ xmlns:cc="http://creativecommons.org/ns#"
199+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
200+ xmlns:svg="http://www.w3.org/2000/svg"
201+ xmlns="http://www.w3.org/2000/svg"
202+ version="1.1"
203+ width="16"
204+ height="16"
205+ id="svg7384">
206+ <title
207+ id="title9167">Gnome Symbolic Icon Theme</title>
208+ <defs
209+ id="defs10" />
210+ <metadata
211+ id="metadata90">
212+ <rdf:RDF>
213+ <cc:Work
214+ rdf:about="">
215+ <dc:format>image/svg+xml</dc:format>
216+ <dc:type
217+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
218+ <dc:title>Gnome Symbolic Icon Theme</dc:title>
219+ </cc:Work>
220+ </rdf:RDF>
221+ </metadata>
222+ <g
223+ transform="translate(-111.61542,-601.4038)"
224+ id="layer12">
225+ <path
226+ d="m 228.01,607.02 c -3.86,0 -7.0073,3.166 -7.0073,7.0103 0,3.8443 3.1472,6.9787 7.0073,6.9787 3.86,0 7.0073,-3.1344 7.0073,-6.9787 0,-3.8443 -3.1472,-7.0103 -7.0073,-7.0103 z m 0,2.021 c 2.7769,0 5.0097,2.2237 5.0097,4.9893 0,2.7656 -2.2328,4.9577 -5.0097,4.9577 -2.777,0 -5.0097,-2.1921 -5.0097,-4.9577 0,-2.7656 2.2328,-4.9893 5.0097,-4.9893 z"
227+ id="path4222"
228+ style="text-indent:0;text-transform:none;block-progression:tb;color:#000000;fill:#bebebe" />
229+ <path
230+ d="m 231.41,609.44 -8,8 1.4062,1.4062 8,-8 -1.4062,-1.4062 z"
231+ id="path4992"
232+ style="text-indent:0;text-transform:none;block-progression:tb;color:#000000;fill:#bebebe" />
233+ </g>
234+ <path
235+ d="m 7.96875,0.6875 c -2.8420838,0 -2.8771973,1.9949742 -6.625,2.3125 0,0 -0.98752557,2.5363552 0.34375,6 0.8399195,2.18526 4.3935259,5.981297 6.1875,6 l 0.25,0 C 9.9189736,14.9813 13.472581,11.18526 14.3125,9 15.643775,5.5363552 14.65625,3 14.65625,3 10.908448,2.6824742 10.873333,0.6875 8.03125,0.6875 l -0.0625,0 z m -0.625,2 c 0.1719617,-0.02159 0.3665606,0 0.625,0 l 0.0625,0 c 1.0337572,0 1.1746055,0.1513488 2.03125,0.625 0.133299,0.073703 0.361318,0.1808693 0.53125,0.28125 L 4.0625,9.25 C 3.8118632,8.860346 3.6127069,8.4931804 3.53125,8.28125 2.8541774,6.5196771 2.8806279,5.4183698 3,4.65625 4.2800363,4.3579974 5.3166759,3.6557627 5.9375,3.3125 6.5799833,2.9572616 6.8278648,2.7522692 7.34375,2.6875 z m 5.21875,1.84375 c 0.146121,0.046432 0.28409,0.089255 0.4375,0.125 0.119372,0.7621199 0.145822,1.863427 -0.53125,3.625 -0.223946,0.5826518 -1.210812,2.079776 -2.28125,3.15625 -0.535219,0.538237 -1.0931989,0.993886 -1.53125,1.28125 -0.2903916,0.190498 -0.5086712,0.283423 -0.5625,0.3125 l -0.15625,0 C 7.9117131,13.007739 7.6583409,12.925123 7.34375,12.71875 6.905699,12.431386 6.3477189,11.975737 5.8125,11.4375 5.6307383,11.254713 5.4548666,11.044257 5.28125,10.84375 l 7.28125,-6.3125 z"
236+ id="path3016-2"
237+ style="color:#000000;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
238+</svg>
239
240=== modified file 'extensions/adblock/config.vala'
241--- extensions/adblock/config.vala 2014-02-20 18:27:01 +0000
242+++ extensions/adblock/config.vala 2014-03-02 17:51:55 +0000
243@@ -13,7 +13,7 @@
244 public class Config : GLib.Object {
245 List<Subscription> subscriptions;
246 string? path;
247- KeyFile keyfile;
248+ public KeyFile keyfile;
249 Subscription? custom;
250
251 public Config (string? path) {
252@@ -81,6 +81,12 @@
253
254 string[] list = (filters.str.slice (0, -1)).split (";");
255 keyfile.set_string_list ("settings", "filters", list);
256+
257+ save ();
258+ }
259+
260+
261+ public void save () {
262 try {
263 string filename = GLib.Path.build_filename (path, "config");
264 FileUtils.set_contents (filename, keyfile.to_data ());
265
266=== modified file 'extensions/adblock/extension.vala'
267--- extensions/adblock/extension.vala 2014-02-24 00:06:18 +0000
268+++ extensions/adblock/extension.vala 2014-03-02 17:51:55 +0000
269@@ -19,6 +19,8 @@
270 public class Extension : Midori.Extension {
271 Config config;
272 HashTable<string, Directive?> cache;
273+ bool disable_toggled;
274+ Gtk.Button toggle_button;
275
276 #if HAVE_WEBKIT2
277 public Extension (WebKit.WebExtension web_extension) {
278@@ -146,18 +148,69 @@
279 app.add_browser.connect (browser_added);
280 }
281
282+ Gtk.Image get_icon_image_for_state (bool disable_toggled) {
283+ string res_dir = Midori.Paths.get_res_filename ("adblock");
284+ string filename;
285+
286+ if (disable_toggled)
287+ filename = GLib.Path.build_filename (res_dir, "adblock-disabled.svg");
288+ else
289+ filename = GLib.Path.build_filename (res_dir, "adblock-enabled.svg");
290+
291+ return new Gtk.Image.from_file (filename);
292+ }
293+
294 void browser_added (Midori.Browser browser) {
295 foreach (var tab in browser.get_tabs ())
296 tab_added (tab);
297 browser.add_tab.connect (tab_added);
298+
299+ toggle_button = new Gtk.Button ();
300+ Gtk.Image img = get_icon_image_for_state (disable_toggled);
301+ toggle_button.set_image (img);
302+ browser.statusbar.pack_start (toggle_button, false, false, 3);
303+ toggle_button.show ();
304+
305+ toggle_button.clicked.connect (icon_clicked);
306+ }
307+
308+ void icon_clicked () {
309+ var menu = new Gtk.Menu ();
310+ var checkitem = new Gtk.CheckMenuItem.with_label (_("Disabled"));
311+ checkitem.set_active (disable_toggled);
312+ checkitem.toggled.connect (() => {
313+ disable_toggled = checkitem.active;
314+ Gtk.Image img = get_icon_image_for_state (disable_toggled);
315+ toggle_button.set_image (img);
316+ toggle_button.show ();
317+
318+ config.keyfile.set_boolean ("settings", "disabled", disable_toggled);
319+ config.save ();
320+ });
321+ menu.append (checkitem);
322+
323+ var menuitem = new Gtk.ImageMenuItem.with_label (_("Preferences"));
324+ var image = new Gtk.Image.from_stock (Gtk.STOCK_PREFERENCES, Gtk.IconSize.MENU);
325+ menuitem.always_show_image = true;
326+ menuitem.set_image (image);
327+ menuitem.activate.connect (() => {
328+ open_preferences ();
329+ });
330+ menu.append (menuitem);
331+
332+ menu.show_all ();
333+ Katze.widget_popup (toggle_button, menu, null, Katze.MenuPos.CURSOR);
334 }
335
336 void tab_added (Midori.View view) {
337 view.web_view.resource_request_starting.connect (resource_requested);
338 view.web_view.navigation_policy_decision_requested.connect (navigation_requested);
339 view.notify["load-status"].connect ((pspec) => {
340- if (view.load_status == Midori.LoadStatus.FINISHED)
341- inject_css (view, view.uri);
342+ if (!disable_toggled)
343+ {
344+ if (view.load_status == Midori.LoadStatus.FINISHED)
345+ inject_css (view, view.uri);
346+ }
347 });
348 view.context_menu.connect (context_menu);
349 }
350@@ -316,6 +369,12 @@
351 string config_dir = Midori.Paths.get_extension_config_dir ("adblock");
352 config = new Config (config_dir);
353 reload_rules ();
354+
355+ try {
356+ disable_toggled = config.keyfile.get_boolean ("settings", "disabled");
357+ } catch (GLib.Error settings_error) {
358+ warning ("Error reading settings: %s\n", settings_error.message);
359+ }
360 }
361
362 void reload_rules () {
363@@ -330,6 +389,9 @@
364 }
365
366 bool request_handled (string page_uri, string request_uri) {
367+ if (disable_toggled)
368+ return false;
369+
370 /* Always allow the main page */
371 if (request_uri == page_uri)
372 return false;

Subscribers

People subscribed via source and target branches

to all changes: