]> git.ktnx.net Git - icedeb.git/blob - chrome/icedeb.js
add gimp source for bts button image
[icedeb.git] / chrome / icedeb.js
1 function getClipboardText() {
2     var clip = Components.classes['@mozilla.org/widget/clipboard;1']
3         .getService(Components.interfaces.nsIClipboard);
4     if (!clip) return null;
5
6     var trans = Components.classes['@mozilla.org/widget/transferable;1']
7         .createInstance(Components.interfaces.nsITransferable);
8     if (!trans) return null;
9
10     trans.addDataFlavor("text/unicode");
11     clip.getData(trans,
12             clip.supportsSelectionClipboard()
13             ? clip.kSelectionClipboard
14             : clip.kGlobalClipboard
15     );
16
17     var str = new Object;
18     var strLength = new Object;
19     trans.getTransferData("text/unicode", str, strLength);
20
21     var text = null;
22
23     if (str) str  = str.value.QueryInterface(Components.interfaces.nsISupportsString);
24     if (str) text = str.data.substring(0, strLength.value / 2);
25
26     return text;
27 }
28
29 function lookup_bts(in_new) {
30     var bug = getClipboardText();
31     if (!bug) return null;
32     bug = bug.replace(/^#/, '');
33     var uri="http://bugs.debian.org/" + bug;
34
35     if (in_new) {
36         var b = getBrowser();
37         var new_tab = b.addTab(uri);
38         b.selectedTab = new_tab;
39     }
40     else {
41         loadURI(uri);
42     }
43 }
44
45 Debian = {
46     btsButton: function (e) {
47         if ( e.button == 0 )
48             lookup_bts(false)
49         else if ( e.button == 1 )
50             lookup_bts(true);
51     }
52 }
53