RealRaven2000 / quickFilters

Thunderbird Add-on: quickFilters
http://quickfilters.quickfolders.org/
Other
51 stars 11 forks source link

Message Filters Toolbar Implementation - insert above filterHeader (not any 1st hbox) #265

Open WoofGrrrr opened 1 month ago

WoofGrrrr commented 1 month ago

I am using the userChromeJS extension to run my userChrome.js script. The userChromeJS extension causes this script to run when one of a selected list of windows is opened. I have modified the extension to add the "Message Filters" window to this list.

One of the things my userChrome.js script does to is replace the System Title Bar on the Message Filters window with my own title bar implementation, much the same as how "Tools -> Settings -> General -> Language & Appearance -> Hide system window titlebar" works.

In my script, I use code like the following to place a XUL <vbox> element as the first element of the <body> element

  const body = document.body
  const titleBarVbox = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
  titleBarVbox.style.appearance = "none";
  body.insertBefore(titleBarVbox, body.firstChild);

It then adds other elements as descendants of this <vbox>

The quickFilters tool bar is appearing ABOVE what my code is adding. I want my title bar to be at the very top.

In fact, the quickFilters tool bar is added as the FIRST CHILD of my <vbox>.

From the Thunderbird Developer Toolbox:

  <html:body xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    <vbox style="appearance: none;">
      <toolbox id="quickfilters-toolbox" insertbefore="status-bar" tooltip="quickFiltersToolTip" wlapi_autoinjected="AddOnNS15">
      .
      .
      .
    <//vbox>
    <hbox id="filterHeader" align="center">

Could you please add it BEFORE this element instead:

  <hbox id="filterHeader" align="center">

I would do it in my userChrome.js script, but the script is not finding an element with ID "quickfilters-toolbox". It looks like userChrome.js is being called before the quickFilters code is invoked???

RealRaven2000 commented 1 month ago

Let's first explain how my list modifications are implemented.

Initially, the element is initially injected using WindowListener.injectElements(..) into the window (FilterListDialog.xhtml), before #status-bar element. I think that element actually doesn't exist anymore, but it's immaterial because I relocated it using javascript code. See qFi-filterlist.js.

WL.injectElements(`

<window id="filterListDialog">
   (2 popup sets first)
  <toolbox id="quickfilters-toolbox" insertbefore="status-bar" tooltip="quickFiltersToolTip">
  ...
</window>
  `);

I then lift it up before the first <hbox> element in qFilters-list.js in the setupToolbar() function:

  setupToolbar: function() {
    const prefs = quickFilters.Preferences,
          getElement = document.getElementById.bind(document);
    // Toolbar
    const toolbox = getElement("quickfilters-toolbox"),
          hbs = document.getElementsByTagName('hbox'),
          hbox = hbs ? hbs[0] : null ;
    let isToolbar = false;
    if (!prefs.getBoolPref("toolbar")) {
      toolbox.collapsed = true;
    } else if (hbox && toolbar) { // move toolbox up
      hbox.parentNode.insertBefore(toolbox, hbox);
      isToolbar = true;
      if (quickFilters.Util.AssistantActive) {  // needs to bve asked from background script!
        let button = getElement('quickFiltersBtnStart');
        button.checked = true;          
      }
      toolbox.collapsed = false;
    }
    //...
  } ,

So my code just assumes that the first <hbox> would be of the unmodified window:

<hbox id="filterHeader" align="center">

sometimes Thunderbird elements didn't have ids, but I checked back to Tb v60 it was always called #filterHeader so I guess it should be easy (and safe) enough to modify. We have to bear in mind that at some stage all xhtml dialogs will be rewritten in html so a lot of stuff will change in the future anyway.

RealRaven2000 commented 1 month ago

Try the version below, it works for me in Tb 131.0b4.

image

quickFilters-wx-6.5.4pre2.zip


To install version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)

WoofGrrrr commented 1 month ago

Much better.  Thanks!

(You might notice that I also add a "Done" button)

RealRaven2000 commented 1 month ago

Much better.  Thanks! (You might notice that I also add a "Done" button)

Sorry I haven't tried your script (yet) - could you post a screenshot here? (You can add images from clipboard directly if you reply on the github site and not with email)

In any case I will add this change to the next release if it works for you, I don't see any downside right now. Will close the issue once I release.

WoofGrrrr commented 1 month ago

Tried my script? I didn't post it. I'm doing a lot with userChrome.css, userContent.css, and userChrome.js just as a way to keep myself from getting bored on days when I can't be outside :-) And to keep some of my skills intact during retirement...

Here is a screen shot of my Filters List Dialog:

Message_Filters

RealRaven2000 commented 1 month ago

Ah ok, so it's more like you are dabbling in theming here... not bad. You should probably exclude the button #quickFilters-SearchOptions from the border rules you added, it looks a little wonky. What happens when you hover on the toolbar buttons I added?

It looks like this here (the zooming effect is animated):

image

WoofGrrrr commented 1 month ago

The animation is working just fine for all the buttons.

Thanks for your suggestion about the Search Options Button. Is there any way you could give visual feedback on hover?

RealRaven2000 commented 1 month ago

The animation is working just fine for all the buttons.

Thanks for your suggestion about the Search Options Button. Is there any way you could give visual feedback on hover?

yeah, can do! Good idea. I might add it in the next release, might upload a test version here.

WoofGrrrr commented 1 month ago

question: When the final version 6.5.4 gets released, will it automatically replace this pre-release version?

RealRaven2000 commented 1 month ago

question: When the final version 6.5.4 gets released, will it automatically replace this pre-release version?

yes! I always increase my version numbers in a linear fashion - see build.bat. in the version comparator these are the rules:

6.5.4 > 6.5.4pre10 > 6.5.4pre0 >6.5.3 > 6.5.3pre7

And usually the higher version has all changes from the previous version (I rarely roll back code)