3

I am working on a Firefox extension in which I have made various changes in browser.xul to customize Firefox's UI. By default Firefox has its menu-bar disabled/invisible. I want it to always display menu-bar toolbar. FYI, I have disabled right-click on toolbar which usually shows a context menu where-in one can make menu-bar visible or gone.

Is there any way by which one can make this setting?

Sagar Pilkhwal
  • 3,998
  • 2
  • 25
  • 77

3 Answers3

2

I found this entry because I was looking for a solution to display the toolbar which was always "minimized" so I had to click on "more tools" and then on the tool (e.g. ublock).

The solution for me was to go to about:config and change the value browser.chrome.toolbar_style (which was "2") to "1". After restarting firefox all tools are visible again. Changing it back to "2" and restarting firefox still shows all tools .. odd behaviour.

Werner Henze
  • 16,404
  • 12
  • 44
  • 69
Guenther Schmitz
  • 1,955
  • 1
  • 9
  • 23
  • While this isn't the answer to the question as asked, this question does appear when you search stackoverflow for "how to enable menu bar in firefox", which is answered also at https://support.mozilla.org/en-US/kb/customize-firefox-controls-buttons-and-toolbars#w_turn-on-the-menu-bar-or-bookmarks-toolbar . – SomeoneElse May 28 '18 at 13:35
1

This isnt a solution but start of one.

Option 1

Figure out how to set a style sheet with more importance then this one here:

It looks like when the inactive=true attribute is set on it chrome://global/content/xul.css line 289 it gets a css important of height is 0. I tried registering a style sheet with my own height

This is whats applied when `inactive=true` attribute is on it:

toolbar[type="menubar"][autohide="true"][inactive="true"]:not([customizing="true"]) {
  min-height: 0 !important;
  height: 0 !important;
  -moz-appearance: none !important;
  border-style: none !important;
}

I tried this but my importance is not overriding this, this page is probably worth a read, its about css order priority i think it can be done with this: http://hungred.com/useful-information/css-priority-order-tips-tricks/

I tried this code but it wouldnt take more importance:

// globals
Cu.import('resource://gre/modules/Services.jsm');
var sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService);

try {
    sss.unregisterSheet(cssUri, sss.AUTHOR_SHEET);
} catch (ignore) {}

var cssUri;
var css = 'toolbar[type="menubar"][autohide="true"][inactive="true"]:not([customizing="true"]) { height: 50px !important; min-height: 50px !important;';
var newURIParam = {
    aURL: 'data:text/css,' + encodeURIComponent(css),
    aOriginCharset: null,
    aBaseURI: null
};
var cssUri = Services.io.newURI(newURIParam.aURL, newURIParam.aOriginCharset, newURIParam.aBaseURI);
sss.loadAndRegisterSheet(cssUri, sss.AUTHOR_SHEET);

I also tried var css = '#toolbar-menubar[type="menubar"][autohide="true"][inactive="true"]:not([customizing="true"]) { height: 50px !important; min-height: 50px !important;'; notoice how i used #toolbar-menubar id instead of tag selector, id has highest importance, but it didnt work even though i kept the selectivity after it.

Option 2

Mutation observer, whenever inactive=true gets attached, remove it. This is sure fire without thinking guranteed. However I think the CSS option would be preferred as it gives better for performance.

Noitidart
  • 35,443
  • 37
  • 154
  • 323
  • Hi, I will try the css approach, I have also tried something which I have posted as an answer below, It would be great if you add some comments on that approach. – Sagar Pilkhwal Jun 04 '15 at 12:12
1

I tried this and its working fine,

I have edited browser.js and inside gBrowserInit functions onLoad function I have added the following code snippet after the whole UI is done loading.

let toolbar = window.document.getElementById("toolbar-menubar");
if (toolbar) {
    window.setToolbarVisibility(toolbar, true, true);
}
Sagar Pilkhwal
  • 3,998
  • 2
  • 25
  • 77