Thunderbird menu extention

Talk about add-ons and extension development.
Post Reply
TonyDennis
Posts: 15
Joined: December 6th, 2003, 4:55 pm
Contact:

Thunderbird menu extention

Post by TonyDennis »

I was trying to find where I need to go to edit the menu that appears when you right click on a message. I want to be able to click "View Message Source" instead of having to go up to the toolbar, click View, and then click Message Source. It seems counter-intuitive to move the mouse around all that much and I've never been a big fan of keyboard shortcuts (Ctrl+U).

I think the file I need to edit is messenger.dtd in chrome/en-US-mail.jar, but I can't tell where I'm supposed to edit it, much less what I'm supposed to edit. Any help in this matter would be greatly appreciated.
User avatar
!!!!cdn!
Posts: 250
Joined: December 7th, 2003, 2:58 pm
Location: Latitude 53ish
Contact:

[ 10 ]

Post by !!!!cdn! »

the dtd won't help you : ) - that merely specifies things like the shortcut key 'U', or the string on the menu "View Message Source"

what you need to do is add this code

Code: Select all

<menuitem id="pageSourceMenuItem" label="&pageSourceCmd.label;" key="key_viewPageSource" accesskey="&pageSourceCmd.accesskey;" observes="cmd_viewPageSource"/>


to mailWindowOverlay.xul under <popup id="messagePaneContext" ... >

[ it happens to be from further down the file : ) ]
TonyDennis
Posts: 15
Joined: December 6th, 2003, 4:55 pm
Contact:

Post by TonyDennis »

Image

For some reason the option to select it is greyed out and inaccessable. Thank you very much for your help thus far, I never would have touched mail.jar. Also, is there a similar file I should edit to include this feature in the message index?
TonyDennis
Posts: 15
Joined: December 6th, 2003, 4:55 pm
Contact:

Post by TonyDennis »

Odd, only when I click on the View menu bar, and then right click within the message body will it let me select that option from the menu. It seems as though it is not initialized or something. Does that mean I need to edit the accompanying .js file as well?
User avatar
!!!!cdn!
Posts: 250
Joined: December 7th, 2003, 2:58 pm
Location: Latitude 53ish
Contact:

[ 12 ]

Post by !!!!cdn! »

it's the "observes" part of the ui code - it was a quick 'off the top of my head' add-in

try replacing

Code: Select all

observes="cmd_viewPageSource"
with

Code: Select all

oncommand="goDoCommand('cmd_viewPageSource')"
TonyDennis
Posts: 15
Joined: December 6th, 2003, 4:55 pm
Contact:

Post by TonyDennis »

Sweet, that fixed it right up! Thanks.

I also added that snippet to <popup id="threadPaneContext"> and it added it to the message index. Thank you very much for your help! Now, is there any way I can turn this into an extention so I don't have to edit the source the next time I upgrade? ;)
User avatar
!!!!cdn!
Posts: 250
Joined: December 7th, 2003, 2:58 pm
Location: Latitude 53ish
Contact:

[ 18 ]

Post by !!!!cdn! »

yes

a two file extension should do it

contents.rdf and contextSourceLink.xul zipped up as contextSourceLink.jar
that plus install.js zipped up as contextSourceLink.xpi

contents.rdf

Code: Select all

<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:chrome="http://www.mozilla.org/rdf/chrome#">

  <!-- list all the packages being supplied by this jar -->
  <RDF:Seq about="urn:mozilla:package:root">
    <RDF:li resource="urn:mozilla:package:contextsrclnk"/>
  </RDF:Seq>

  <!-- package information -->
  <RDF:Description about="urn:mozilla:package:contextsrclnk"
        chrome:displayName="Context Source Link 0.0.1"
        chrome:author="Chris Neale, Tony Dennis"
        chrome:authorURL="http://cdn.mozdev.org/"
        chrome:name="contextsrclnk"
        chrome:description="Adds"
        chrome:extension="true"
        />

  <!-- overlay information -->
  <RDF:Seq about="urn:mozilla:overlays">
    <RDF:li resource="chrome://messenger/content/mailWindowOverlay.xul"/>
  </RDF:Seq>

  <RDF:Seq about="chrome://messenger/content/mailWindowOverlay.xul">
    <RDF:li>chrome://contextsrclnk/content/contextSourceLink.xul</RDF:li>
  </RDF:Seq>

</RDF:RDF>


contextSourceLink.xul

Code: Select all

<?xml version="1.0"?>

<!DOCTYPE overlay [
<!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd" >
%messengerDTD;
<!ENTITY % contentAreaCommandsDTD SYSTEM "chrome://communicator/locale/contentAreaCommands.dtd" >
%contentAreaCommandsDTD;
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
%brandDTD;
]>

<overlay id="contextSourceLinkOverlay"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<popup id="threadPaneContext">
<menuitem id="pageSourceMenuItem" label="&pageSourceCmd.label;" key="key_viewPageSource" accesskey="&pageSourceCmd.accesskey;" oncommand="goDoCommand('cmd_viewPageSource')"/>
</popup>

<popup id="messagePaneContext">
<menuitem id="pageSourceMenuItem" label="&pageSourceCmd.label;" key="key_viewPageSource" accesskey="&pageSourceCmd.accesskey;" oncommand="goDoCommand('cmd_viewPageSource')"/>
</popup>

</overlay>


-=-=-=-

install.js

Code: Select all

const APP_DISPLAY_NAME = "Context Source Link";
const APP_NAME = "contextsrclnk";
const APP_PACKAGE = "/contextSourceLink";
const APP_VERSION = "0.0.1";

const APP_JAR_FILE = "contextSourceLink.jar";
const APP_CONTENT_FOLDER = "/";

const APP_SUCCESS_MESSAGE = "You may need to restart your browser before the bookmarks will be shown.";

const INST_TO_PROFILE = "Do you wish to install "+APP_DISPLAY_NAME+" to your profile?\nThis will mean it does not need reinstalling when you update your browser.\n(Click Cancel if you want "+APP_DISPLAY_NAME+" installing to the browser directory.)";

initInstall(APP_NAME, APP_PACKAGE, APP_VERSION);

// profile installs only work since 2003-03-06
var instToProfile = (buildID>2003030600 && confirm(INST_TO_PROFILE));

var chromef = instToProfile ? getFolder("Profile", "chrome") : getFolder("chrome");
var err = addFile(APP_PACKAGE, APP_VERSION, APP_JAR_FILE, chromef, null)
if(err == SUCCESS) {
   var jar = getFolder(chromef, APP_JAR_FILE);
  if(instToProfile) registerChrome(CONTENT | PROFILE_CHROME, jar, APP_CONTENT_FOLDER);
  else registerChrome(CONTENT | DELAYED_CHROME, jar, APP_CONTENT_FOLDER);

   err = performInstall();
   if(err == SUCCESS || err == 999) {
      alert(APP_DISPLAY_NAME+" "+APP_VERSION+" has been succesfully installed.\n"+APP_SUCCESS_MESSAGE);
   } else {
      alert("Install failed. Error code:" + err);
      cancelInstall(err);
   }
} else {
   alert("Failed to create " +APP_JAR_FILE +"\n"
      +"You probably don't have appropriate permissions \n"
      +"(write access to your profile or chrome directory). \n"
      +"_____________________________\nError code:" + err);
   cancelInstall(err);
}
TonyDennis
Posts: 15
Joined: December 6th, 2003, 4:55 pm
Contact:

Post by TonyDennis »

You are truly a god among men.
tiljes
Posts: 4
Joined: January 14th, 2016, 11:58 am

Re: Thunderbird menu extention

Post by tiljes »

I am very sorry to dig out (well, actually google did) this really, really, really, REALLY (really?) old thread, but I am looking to add the same feature to thunderbird. Unfortunately, the files and file-structure have changed. Any idea which file inside the (I assmune) chrome.jar I'd have to change now?
tiljes
Posts: 4
Joined: January 14th, 2016, 11:58 am

Re: Thunderbird menu extention

Post by tiljes »

ok, so I decided I'll take my chances and dive a bit into making mozilla extensions. In the end, I managed to adjust everything:

content/contextSourceLink.xul

Code: Select all

<?xml version="1.0"?>

<!DOCTYPE overlay [
<!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd" >
%messengerDTD;
<!ENTITY % contentAreaCommandsDTD SYSTEM "chrome://communicator/locale/contentAreaCommands.dtd" >
%contentAreaCommandsDTD;
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
%brandDTD;
]>

<overlay id="contextSourceLinkOverlay"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <menupopup id="mailContext">		 
    <!-- <menuseparator id="mailContext-ViewSource"/> -->	  
	<menuitem id="pageSourceMenuItem"
			  label="&pageSourceCmd.label;"

			  accesskey="&pageSourceCmd.accesskey;"
			  oncommand="goDoCommand('cmd_viewPageSource');"/>
  </menupopup>

</overlay>

<!--		  key="key_viewPageSource"  <- if you want to have the hotkey displayed-->
chrome.manifest

Code: Select all

content   contextsrclnk                content/

overlay chrome://messenger/content/mailWindowOverlay.xul  chrome://contextsrclnk/content/contextSourceLink.xul
install.rdf

Code: Select all

<?xml version="1.0"?>

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:em="http://www.mozilla.org/2004/em-rdf#">

  <Description about="urn:mozilla:install-manifest">
    <em:id>contextsrclnk@tiljes</em:id>
    <em:name>Context View Source</em:name>
    <em:description>Adds View Source option to context menu</em:description>
    <em:version>0.2</em:version>
    <em:creator>Chris Neale, Tony Dennis, tiljes</em:creator>
    <em:type>2</em:type>

    <!-- Mozilla Thunderbird -->
    <em:targetApplication>
      <Description>
        <em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
        <em:minVersion>3.0</em:minVersion>
        <em:maxVersion>44.*</em:maxVersion>
      </Description>
    </em:targetApplication>
  </Description>
</RDF>
Zip up all together as contextSourceLink.xpi and you're good to go!

One thing that bugs me though: this context menu also shows if I right-click in the add-ons page. I guess there needs to be some modification in some .js to trigger which menu-items to disable/enable when switching between tabs. Can anyone point me in the direction?

Cheers,
T
Post Reply