<feed xmlns="http://www.w3.org/2005/Atom"><title>DarkTrojan</title><link rel="alternate" type="text/html" href="http://www.darktrojan.net/news/" /><link rel="self" type="application/atom+xml" href="http://www.darktrojan.net/news/?atom" /><entry><title>nsIPrefBranch2 is no more</title><link rel="alternate" type="text/html" href="/news/2012-02/nsiprefbranch2-is-no-more" /><published>2012-02-16T00:29:19+13:00</published><updated>2012-02-16T00:29:19+13:00</updated><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>Yesterday I landed <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=718255">bug 718255</a>, taking the guts out of nsIPrefBranch2 and putting them into nsIPrefBranch. That means a QueryInterface call is no longer required to add or remove pref observers. (The interface still exists, to prevent stuff breaking, but it is empty now.)</p>
<p>Hackers and reviewers, please take note. I don't want to be clearing  out stray uses forever.</p></div></content></entry><entry><title>Test running script</title><link rel="alternate" type="text/html" href="/news/2012-01/test-running-script" /><published>2012-01-12T10:52:05+13:00</published><updated>2012-01-12T10:52:05+13:00</updated><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>Hey Mozilla devs, are you sick of typing <code>TEST_PATH=... make -C objdir mochitest-browser-chrome</code> only to remember halfway through that you're trying to run an XPC shell test, and have to type something completely different? Me too!</p>
<p>There's currently at least 7 makefile targets for running the common unit tests (mochitests, reftests and XPC shell tests). It's a pain remembering which one to use. So I've created a Python script which will do it for you, and you'll only need one command to run tests ever again:</p>
<pre>../scripts/runtest.py path/to/test</pre>
<p>"Where do I get this magic script?" you ask. It's <a href="http://hg.mozilla.org/users/geoff_darktrojan.net/scripts/file/tip/runtest.py">here</a>. It could be more efficient, it could be better documented, and it could be written by someone who actually knows what they're doing with Python. Who cares? It works.</p></div></content></entry><entry><title>7 things</title><link rel="alternate" type="text/html" href="/news/2011-09/7-things" /><published>2011-09-12T00:15:42+12:00</published><updated>2011-09-12T00:15:42+12:00</updated><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>Oh no, who started this again? <a href="http://theunfocused.net/2011/08/28/7-things-about-me-2/">Blair tagged me.</a></p>
<h3>4 Rules:</h3>
<ol>
<li>Link to your original tagger(s) and list these rules in your post.</li>
<li>Share seven facts about yourself in the post.</li>
<li>Tag seven people at the end of your post by leaving their names and the links to their blogs.</li>
<li>Let them know they&#8217;ve been tagged.</li>
</ol>
<h3>7 Things:</h3>
<ol>
<li>I was one of the first people in the country to create a high school art portfolio entirely on Photoshop. It scored really well. I still have it somewhere, and I still have the same version of Photoshop (11 years later).</li>
<li>I find dealing with people I don't know well exhausting.</li>
<li>In spite of #2, I work with school kids and teenagers. On Friday nights you'll find me playing touch rugby with 11-14 year-olds, I help run school holiday programmes at my church, and each year at Easter I help run a camp for kids from all over the region.</li>
<li>Unlike Blair, I don't fear heights. I've done stage lighting (as well as sound and A/V stuff, sometimes all three at the same time) for productions, musicals, concerts and church services.</li>
<li>My typical day starts at about 10am and goes until about 1am. I don't <em>do</em> mornings.</li>
<li>My online nickname has nothing to do with Greeks bearing gifts. It has nothing to do with anything really, I made it up when I needed a username for something. Two words that sounded cool, put them together, bam. This is a dumb idea. Don't do it.</li>
<li>I think, a lot more than I do. Things usually work a lot better in my head. Everything I write for this blog, for example.</li>
</ol>
<h3>7 People:</h3>
<p>Nah, can't be bothered doing this. It's my blog so I'll not do it if I don't want to.</p></div></content></entry><entry><title>Extension settings in a tab in Mozilla 7</title><link rel="alternate" type="text/html" href="/news/2011-06/extension-settings-in-a-tab-in-mozilla-7" /><published>2011-06-21T00:32:19+12:00</published><updated>2011-06-21T00:35:54+12:00</updated><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>In addition to <a href="/news/2011-06/new-in-addon-manager-extension-settings-in-mozilla-7">settings in the Addon Manager</a>, Firefox 7 also supports extension settings in a tab. Here's a quick bit of code you can use to provide backwards-compatibility.</p>
<p>Put this file at <code>chrome://mynamespace/content/redirect.xul</code>, point your <code>optionsURL</code> there, and set <code>optionsType</code> to 3.</p>
<pre>&lt;?xml version="1.0" ?&gt;<br />&lt;window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;<br />&lt;script type="application/javascript"&gt;&lt;![CDATA[<br /><br />const Ci = Components.interfaces;<br />const Cu = Components.utils;<br /><br />Cu.import('resource://gre/modules/Services.jsm');<br /><br />const FAKE_OPTIONS_URL = 'chrome://mynamespace/content/redirect.xul';<br />const REAL_OPTIONS_URL = 'chrome://mynamespace/content/settings.xul';<br /><br />window.onload = function () {<br />  var topWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)<br />                        .getInterface(Ci.nsIWebNavigation)<br />                        .QueryInterface(Ci.nsIDocShellTreeItem)<br />                        .rootTreeItem<br />                        .QueryInterface(Ci.nsIInterfaceRequestor)<br />                        .getInterface(Ci.nsIDOMWindow);<br /><br />  if (topWindow.document.documentURI == FAKE_OPTIONS_URL) {<br />    let recentWindow = Services.wm.getMostRecentWindow('navigator:browser');<br />    if (recentWindow &amp;&amp; 'switchToTabHavingURI' in recentWindow) {<br />      recentWindow.switchToTabHavingURI(REAL_OPTIONS_URL, true);<br />    } else {<br />      window.openDialog(REAL_OPTIONS_URL, null, 'width=1000,height=600,centerscreen,chrome');<br />    }<br />    setTimeout(window.close, 0);<br />  } else {<br />    location.replace (REAL_OPTIONS_URL);<br />  }<br />};<br /><br />//]]&gt;&lt;/script&gt;<br />&lt;/window&gt;<br /></pre>
<p>The code will open <code>REAL_OPTIONS_URL</code> in a new tab in Firefox 4+ and SeaMonkey 2.1+, and a window in anything else.</p></div></content></entry><entry><title>New in-Addon-Manager extension settings in Mozilla 7</title><link rel="alternate" type="text/html" href="/news/2011-06/new-in-addon-manager-extension-settings-in-mozilla-7" /><published>2011-06-15T23:08:05+12:00</published><updated>2011-06-21T11:29:46+12:00</updated><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>A new feature of the Mozilla 7 platform (soon to be on the Aurora channels) is the ability for extensions to have settings user-interface directly inside the Addon Manager. This will enable restartless extensions to easily have settings, and will also work for traditional extensions.</p>
<p>Here's how to use the new tools:</p>
<h3>Create an options file</h3>
<p>In most cases this will be a file called <code>options.xul</code>, and located inside the top-level directory of the extension (alongside <code>install.rdf</code> etc.). Alternatively, you can put this file elsewhere, and change <code>install.rdf</code> - <code>em:optionsURL</code> pointing to the file, and <code>em:optionsType</code> as 2.</p>
<p>Start with this:</p>
<pre>&lt;?xml version="1.0" ?&gt;<br />&lt;vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;<br />  &lt;!-- settings go here --&gt;<br />&lt;/vbox&gt;<br /></pre>
<p>The settings are represented as a list of <code>&lt;setting&gt;</code> elements of various types, for example:</p>
<pre>&lt;setting type="bool"<br />         title="Boolean Setting"<br />         desc="This is a description of the setting"<br />         pref="extensions.settings.bool"/&gt;<br /></pre>
<p>This node is represented with a checkbox. Clicking on the checkbox changes the value of the preference specified.</p>
<p>A description can be set with a <code>desc</code> attribute, or with text between the opening and closing <code>&lt;setting&gt;</code> tags. Other attributes can be use to alter the UI displayed. See the XUL documentation on MDC for control attributes.</p>
<p>Here's what this example looks like:</p>
<div class="image"><img src="/images/blog/bool-setting.jpg" alt="" width="522" height="56" /></div>
<h3>Settings Types</h3>
<table border="0">
<tbody>
<tr>
<th>type attribute</th><th>displayed as</th><th>preference stored as</th>
</tr>
<tr>
<td><code>bool</code></td>
<td><a href="https://developer.mozilla.org/en/XUL/checkbox">checkbox</a></td>
<td>boolean</td>
</tr>
<tr>
<td><code>boolint</code></td>
<td>checkbox</td>
<td>integer (use the attributes <code>on</code> and <code>off</code> to specify what values to store)<br /></td>
</tr>
<tr>
<td><code>integer<br /></code></td>
<td><a href="https://developer.mozilla.org/en/XUL/textbox">textbox</a> with type="number"<br /></td>
<td>integer<br /></td>
</tr>
<tr>
<td><code>string</code></td>
<td>textbox<br /></td>
<td>string</td>
</tr>
<tr>
<td><code>color</code></td>
<td><a href="https://developer.mozilla.org/en/XUL/colorpicker">colorpicker</a> with type="button"<br /></td>
<td>string (in the <code>#123456</code> format)</td>
</tr>
<tr>
<td><code>file</code></td>
<td>browse button and label</td>
<td>string</td>
</tr>
<tr>
<td><code>directory</code></td>
<td>browse button and label<br /></td>
<td>string</td>
</tr>
</tbody>
</table>
<p>(NB: color, file and directory types haven't landed just yet, see <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=662012">this bug</a>.)</p>
<p>There's also the <code>control</code> type, which allows you to have a button or menulist control:</p>
<pre>&lt;setting type="control" title="Button"&gt;<br />  &lt;button label="click me!" oncommand="alert('thanks!');"/&gt;<br />&lt;/setting&gt;<br />&lt;setting type="control" title="Menulist"&gt;<br />  &lt;menulist sizetopopup="always" onchange="alert(this.value);"&gt;<br />    &lt;menupopup&gt;<br />      &lt;menuitem label="alpha" value="1"/&gt;<br />      &lt;menuitem label="beta" value="2"/&gt;<br />      &lt;menuitem label="charlie" value="3"/&gt;<br />      &lt;menuitem label="delta" value="4"/&gt;<br />    &lt;/menupopup&gt;<br />  &lt;/menulist&gt;<br />&lt;/setting&gt;<br /></pre>
<p>Note that neither of these controls have <code>pref</code> attributes, you'll have to control them yourself. See below for details.</p>
<p>Here's what all these controls look like:</p>
<div class="image"><img src="/images/blog/all-settings.jpg" alt="" width="633" height="535" /></div>
<h3>Need script?</h3>
<p>Each time the UI is loaded, the notification <code><span class="line">addon-options-displayed</span></code><span class="line"> is sent. Here's how to use it:</span></p>
<pre><span class="line">var observer = {<br />  observe: function(aSubject, aTopic, aData) {<br />    if (aTopic == "addon-options-displayed" &amp;&amp; aData == "my@addon.id") {<br />      // your code here<br />      // aSubject is the Addon Manager document, so you can use aSubject.getElementById etc.<br />    }<br />  }<br />};<br />Services.obs.addObserver(observer, "addon-options-displayed", false);<br /></span></pre>
<p>Do NOT forget to remove your observer when your extension is shut down.</p>
<h3>Adding your own settings types</h3>
<p>If you're mad enough you can create your own setting type. Create your own XBL binding, using <code>chrome://mozapps/content/extensions/setting.xml</code> for example code, and bind your setting with it like this:</p>
<pre>&lt;setting type="mytype"<br />         style="display:-moz-grid-line; -moz-binding:url('chrome://mynamespace/content/mybindings.xml#binding-id');"/&gt;<br /></pre>
<p>If you think your setting type will be useful to others and should become a built-in type, <a href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Toolkit&amp;component=Add-ons%20Manager">file a bug</a> and CC me (geoff@darktrojan.net).</p></div></content></entry><entry><title>I'm no longer supporting Gecko 1.9.1</title><link rel="alternate" type="text/html" href="/news/2011-06/im-no-longer-supporting-gecko-1-9-1" /><published>2011-06-14T23:53:25+12:00</published><updated>2011-06-14T23:53:25+12:00</updated><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>Now that <a href="http://www.seamonkey-project.org/">SeaMonkey 2.1</a> has at last been released, I am no longer supporting any product based upon Mozilla's Gecko 1.9.1. That means users of Firefox 3.5, Thunderbird 3.0 and SeaMonkey 2.0, you won't get any new versions of my addons, and I'm not likely to answer your email. But let's face it, it's time you upgraded anyway.</p>
<p>This announcement makes me very happy.</p></div></content></entry><entry><title>What the heck: Open With is incompatible with AdBlock Plus, for some people</title><link rel="alternate" type="text/html" href="/news/2011-05/what-the-heck-open-with-is-incompatible-with-adblock-plus-for-some-people" /><published>2011-05-18T11:17:32+12:00</published><updated>2011-05-20T11:08:05+12:00</updated><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>In the last week or so, two people have reported Open With completely failing to initialise, when AdBlock Plus is enabled (Firefox and SeaMonkey). Apparently ABP must be disabled completely for OW to work.</p>
<p>Does this bug affect you? Have you got any relevant messages on the Error Console? Please <a href="mailto:openwith@darktrojan.net">email me</a>.</p>
<p>[update] I have found the bug and exterminated it! OW 5.0.3 is awaiting review now on addons.mozilla.org.</p></div></content></entry><entry><title>Bugs I've fixed for Firefox 5</title><link rel="alternate" type="text/html" href="/news/2011-04/bugs-ive-fixed-for-firefox-5" /><published>2011-04-13T11:18:21+12:00</published><updated>2011-04-13T11:18:21+12:00</updated><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>Zip. Zero. Nada.</p>
<p>In the few weeks since the last Firefox 4 beta I've done nothing, and now 5 has branched I won't be adding to it.</p></div></content></entry></feed>
