Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create Firefox plugin with single button (same like Echofon)?

I want to how to create Firefox plugin with custom compact menu same like Firefox window. Just now I saw in Echofon. Here is the image, and it looks awesome! Firefox Echofon with single button

So, Please tell me, how we can create like that in plugin window.

like image 642
Naga Harish M Avatar asked Feb 12 '26 06:02

Naga Harish M


1 Answers

I don't think that there is a simple solution. One has to remove the default window title bar (via chromemargin attribute) and replace it by his own (using <xul:titlebar>). And then it has to be styled to look right with all the operating systems and themes (Windows XP regular, Windows XP classic theme, Vista/7 with Aero, Vista/7 without Aero, ...). You can get an impression of the amount of code required by looking at chrome://browser/skin/browser.css, search for "appmenu-button" and "titlebar". Keep in mind that you only see the styles for one OS - Firefox uses different themes for different operating systems.

I got an example together that is mostly working on Windows 7 with Aero (dropdown arrow needs to be replaced by a different image and button position is still wrong when the window is maximized). The window itself (test.xul) looks like this:

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="test.css" type="text/css"?>

<window
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    title="Test window"
    width="800"
    height="500"
    chromemargin="0,-1,-1,-1">
  <titlebar id="titlebar" allowevents="true">
    <button id="appmenu-button" type="menu" label="Test">
      <menupopup/>
    </button>
    <spacer id="titlebar-spacer" flex="1"/>
    <hbox id="titlebar-buttonbox">
      <toolbarbutton class="titlebar-button" id="titlebar-min"
          oncommand="window.minimize();"/>
      <toolbarbutton class="titlebar-button" id="titlebar-max"
          oncommand="window.windowState == 1 ? window.restore() : window.maximize();"/>
      <toolbarbutton class="titlebar-button" id="titlebar-close"
          oncommand="window.close();"/>
    </hbox>
  </titlebar>


  <description flex="1">window content</description>
</window>

And the styles in test.css are the following (mostly copied from browser.css):

:root {
  -moz-appearance: -moz-win-borderless-glass;
  background-color: transparent;
}

#appmenu-button:hover:active,
#appmenu-button[open] {
  border-radius: 0;
}
#appmenu-button {
  -moz-appearance: none;
  -moz-user-focus: ignore;
  background-clip: padding-box;
  border-radius: 0 0 4px 4px;
  color: white;
  text-shadow: 0 0 1px rgba(0,0,0,.7),
               0 1px 1.5px rgba(0,0,0,.5);
  font-weight: bold;
  padding: 0 1.5em .05em;
  margin: 2px 0 2px;
  background-image: -moz-linear-gradient(rgb(247,182,82), rgb(215,98,10) 95%);
  border: 2px solid rgba(83,42,6,.9);
  border-top-style: none;
  -moz-border-left-colors: rgba(255,255,255,.5) rgba(83,42,6,.9);
  -moz-border-bottom-colors: rgba(255,255,255,.5) rgba(83,42,6,.9);
  -moz-border-right-colors: rgba(255,255,255,.5) rgba(83,42,6,.9);
  margin-bottom: -1px; /* compensate white outer border */
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset,
              0 0 2px 1px rgba(255,255,255,.25) inset;
}
#appmenu-button:hover:not(:active):not([open]) {
  background-image: -moz-radial-gradient(center bottom, farthest-side, rgba(252,240,89,.5) 10%, rgba(252,240,89,0) 70%),
                    -moz-radial-gradient(center bottom, farthest-side, rgb(236,133,0), rgba(255,229,172,0)),
                    -moz-linear-gradient(rgb(246,170,69), rgb(209,74,0) 95%);
  border-color: rgba(83,42,6,.9);
  box-shadow: 0 1px 0 rgba(255,255,255,.1) inset,
              0 0 2px 1px rgba(250,234,169,.7) inset,
              0 -1px 0 rgba(250,234,169,.5) inset;
}
#appmenu-button:hover:active,
#appmenu-button[open] {
  background-image: -moz-linear-gradient(rgb(246,170,69), rgb(209,74,0) 95%);
  box-shadow: 0 2px 3px rgba(0,0,0,.4) inset,
              0 1px 1px rgba(0,0,0,.2) inset;
}

#appmenu-button > .button-box {
  border-style: none;
  padding: 0px;
  margin: 0px;
}

#titlebar-spacer {
  pointer-events: none;
}

#titlebar-buttonbox {
  -moz-appearance: -moz-window-button-box;
  -moz-margin-end: 20px;
}
:root[sizemode="maximized"] #titlebar-buttonbox {
  -moz-appearance: -moz-window-button-box-maximized;
}

#titlebar-min {
  -moz-appearance: -moz-window-button-minimize;
}
#titlebar-max {
  -moz-appearance: -moz-window-button-maximize;
}
:root[sizemode=maximized] #titlebar-max {
  -moz-appearance: -moz-window-button-restore;
}
#titlebar-close {
  -moz-appearance: -moz-window-button-close;
}

I opened the window with the following command:

window.open("chrome://.../test.xul", "_blank", "chrome,all,centerscreen,resizable");

This is the end result:

screenshot


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!