Your Search Results

    Questions and answers from the newsgroups 2006 10 13

    Return to mozilla-dev-extensions


    FAQ

    Any suggestions to remove tool tip appears on the menu it when it should not?
    What you described was a bug (https://bugzilla.mozilla.org/show_bug.cgi?id=147670). It looks like it has been fixed for Firefox version 2.
    How to test a tab has been closed or not?
    You can capture the even of tab closing. You can get the tab that is being closed. This should be enough for you.
    Is it possible to fix the size exactly at 16x16 pixels avoiding any resize?
    Simply position the image and it will no longer be stretched to the size of the stack. <image left="0" top="0"> would seem to suffice.
    Could there be more than two images to reflect more than two states?
    Does the rules in the CSS file have to be in any particular order (if two rules match, which is chosen)?
    I have two states switching images in the tool bar and would have no problem implementing a third, so yes it's possible.

    //setting the state document.getElementById("toolbar-button").setAttribute("toolbar-button", "on");
    //or
    document.getElementById("toolbar-button").setAttribute("toolbar-button","off");

    //CSS

    #myExten-toolbar-button[myExten-toolbar-button="on"] {
       list-style-image: url("chrome://myExten/skin/toolbar-button.png");
       -moz-image-region: rect(0px 24px 24px 0px);
    }
     #myExten-toolbar-button[myExten-toolbar-button="off"] {
       list-style-image: url("chrome://myExten/skin/toolbar-button-off.png");
       -moz-image-region: rect(0px 24px 24px 0px);
    }
    To implement a third I would simply change add an attribute and the corresponding CSS
    See http://www.w3.org/TR/REC-CSS2/cascade.html#cascade

    Friday, October 13 - 20, 2006

    (↑ top)

    How to get a reference to the sidebar window
    Assuming you have chrome privileges, this should work:
    var Ci = Components.interfaces;
    var topLevelWindow = 
    window.QueryInterface(Ci.nsIInterfaceRequestor)
           .getInterface(Ci.nsIWebNavigation)
           .QueryInterface(Ci.nsIDocShellTreeItem)
           .rootTreeItem
           .QueryInterface(Ci.nsIInterfaceRequestor)
           .getInterface(Ci.nsIDOMWindow)
           .QueryInterface(Ci.nsIDOMChromeWindow);
    var sidebar = topLevelWindow.document.getElementById("sidebar");
    alert(sidebar.contentDocument); 
    
    Is there anyone successfully using Dojo in a Firefox extension and where to fine sample codes?
    The problem with most JS frameworks is that they bootstrap by dynamically appending script elements, which doesn't work in XUL, last I checked. Take a look at the bottom of http://svn.dojotoolkit.org/dojo/trunk/dojo.js

    see what it's trying to load and write out the script element by hand.

    Could someone write an extension that would collapse the current sidebar in Firefox?
    These are called "Grippies"
    <https://addons.mozilla.org/firefox/2242/>

    This extension brings grippies back to Firefox (and Thunderbird!)

    Would anyone be able to suggest the best way to do source level debugging in a Firefox extension?
    In the Debug menu, uncheck Exclude Browser Files.
    Use the debugger by typing in a command like this: /break chrome://myextension/content/myfile.js 123
    Then I suggest using flat chrome. If you turn off the XUL cache you don't even need to restart to see changes, simply open a new window.
    How can I backup some of the files before upgrade an extension and put them back afterward? Do I need to write an installation script to achieve this?
    You shouldn't store data there, so there's nothing to backup.
    Do not store files within the extension directory.
    The Profile directory is meant to do so.
    Storing files within the extension directory is a no-no because it might break the multi-user support of those Mozilla products, as it is possible to install extensions directly within the application directory.
    Inspector, Talkback and the default theme are nowadays installed like this.
    Does Firefox clean up the preferences set by extension? If not, how to proceed?
    When user chooses to uninstall an extension, a nsIObserverService notification is sent out. The problem is, while your extension is still active, user can cancel uninstallation, and when it is physically uninstalled, your code can't run.
    Right. And if you uninstall Firefox, the profile data is left behind.
    It would be nice to give the option of clearing extension's data, but it should be implemented at application level, not by each extension individually.
    It might be an option to stick with it and perform stuff when it comes to application shutdown.
    The Sanitize stuff does this (clean stuff on exit).
    http://lxr.mozilla.org/mozilla1.8/so...ents/nsBrowser...
    Firefox will clean all those preferences which are still "default", that is not changed by the user or the application/extension.
    To provide those default preferences to your extension see: http://kb.mozillazine.org/Dev_:_Usin...lt_preferences
    BTW: Resetting prefences to default will clear them in case no default prefence is (still) available.
    Those will be completely removed upon next application launch.
    Is it possible to create a sidebar on the top of the page?
    Not unless you make it a separate window. There's a bug in bugzilla about stacking other widgets on top of browser/iframe, which hopefully will be fixed for Gecko 1.9.
    Could someone write an extension that zaps the Google Analytics cookie, the Urchin cookie, switches Gmail and Google Calender to HTTPS?
    CustomizeGoogle extension already has support for switching Gmail to HTTPS (and calendar possibly, too).
    Does anyone know how write a bounce email extension?
    Are you aware of the "mailredirect" extension? It allows bouncing to arbitrary addresses. It seems what you want is a one button access to that extension with a prefilled bounce address, right?
    Is each window is essentially a separate JavaScript sandbox?
    It's best to define singletons as custom XPCOM services. You'll avoid problems like these.
    could someone make an extension for Thunderbird that preview upcoming events and number of new messages?
    In our company I write this extension that connects to our GroupWare server (HTTP). What server should search extension work against? Did you mean Exchange?
    How to attach information using the StringProperties of an IMAP message with out changing the properties?
    String properties are implemented as IMAP user flags. However not all servers support user flags, in which case you get reduced functionality as follows: all flags are stored in your local cache and are lost if your cache gets invalidated, and only "known" properties are copied when messages are copied. The list of "known" properties is: junkscore junkscoreorigin label priority keywords.
    Keywords - In the GUI they are called Tags. They replace the old Labels.
    Preserved properties source code - nsImapMailFolder::CopyMessages
    Why xbl thinks method is not a function?
    It's a common oversight when working with JavaScript callbacks. Both setTimeout( fn, ... ) and addEventListener(receiver, fn, .. ) have this problem. In the case of setTimeout fn is called with this equal to the window. In the case of addEventListener fn is called with this equal to the receiver that you added the event listener to. In your case that is also the window.
    It is possible to get events and timer notifications in an object-oriented manner. For events it is as simple as passing an object instead of a function. This object's handleEvent method will get called with this equal to the object itself. However you would need to add logic to distinguish multiple events, or create a separate object for each event, which would require you to track event objects to avoid leaking.
    If you want an object-oriented timer callback then currently the only way to do this is from an extension where you can use the timer service to register a callback object. This object's notify method will get called with this equal to the object itself. In this case it is even more vital that you track your objects to avoid leaking.

    UAQ

    (↑ top)

    Document Tags and Contributors

    Contributors to this page: Mckwan
    Last updated by: Mckwan,