librelist archives

« back to archive

Change main window attribute

Change main window attribute

From:
Tran Xuan Truong
Date:
2014-04-06 @ 15:57
Hello, I want to ask one question about the conkeror window

This is the code to define the conkeror window in *conkeror.xul*

    <window
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    onload="Components.classes['@conkeror.mozdev.org/application;1']
                 .getService()
                 .wrappedJSObject.window_initialize(this);"
         contenttitlesetting="false"
         title="Conkeror"
         id="main-window"
         width="640" height="480"
         persist="screenX screenY width height sizemode"
         windowtype="navigator:browser">


Is there anyway for changing/adding the window attribute from the 
*.conkerorrc* file. Basically, I want to add one more attribute 
*hidechrome="true"* but I don't know how to do this.

I have tried with this (some lines are taken from window.js file)

    var en = window_watcher.getWindowEnumerator();
    var w = en.getNext().QueryInterface(Ci.nsIDOMWindow);
    var a = w.document.createAttribute("hidechrome");
    a.nodeValue="true";
    w.document.querySelector("window").setAttributeNode(a);

And when I get the attribute using 
*w.document.querySelector("window").attributes["hidechrome"]*, it shows that

    [object Attr] - {localName: "hidechrome", value: "true", name:
    "hidechrome", namespaceURI: null, prefix: null, specified: true,
    ownerElement: {...}, ...}

Does that mean I have successfully set the attribute? The window remains 
unchanged, nothing happens.

Do you have any idea? Thanks!
-- 
*Tru+o+`ng TX*
Computer geek
Command line lover
Emacs addicted
me@truongtx.me <mailto:me@truongtx.me>
http://truongtx.me

Re: [conkeror] Change main window attribute

From:
John J. Foerch
Date:
2014-04-06 @ 17:28
On Sun, Apr 06, 2014 at 10:57:08PM +0700, Tran Xuan Truong wrote:
> Hello, I want to ask one question about the conkeror window
> 
> This is the code to define the conkeror window in conkeror.xul
> 
>     <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/
>     there.is.only.xul"
>         onload="Components.classes['@conkeror.mozdev.org/application;1']
>                 .getService()
>                 .wrappedJSObject.window_initialize(this);"
>         contenttitlesetting="false"
>         title="Conkeror"
>         id="main-window"
>         width="640" height="480"
>         persist="screenX screenY width height sizemode"
>         windowtype="navigator:browser">
> 
> 
> Is there anyway for changing/adding the window attribute from the .conkerorrc
> file. Basically, I want to add one more attribute hidechrome="true" but I don't
> know how to do this.
> 
> I have tried with this (some lines are taken from window.js file)
> 
>     var en = window_watcher.getWindowEnumerator();
>     var w = en.getNext().QueryInterface(Ci.nsIDOMWindow);
>     var a = w.document.createAttribute("hidechrome");
>     a.nodeValue="true";
>     w.document.querySelector("window").setAttributeNode(a);
> 
> And when I get the attribute using w.document.querySelector
> ("window").attributes["hidechrome"], it shows that
> 
>     [object Attr] - {localName: "hidechrome", value: "true", name:
>     "hidechrome", namespaceURI: null, prefix: null, specified: true,
>     ownerElement: {...}, ...}
> 
> Does that mean I have successfully set the attribute? The window remains
> unchanged, nothing happens.
> 
> Do you have any idea? Thanks!


To set an attribute on a given conkeror window (w):

    w.document.documentElement.setAttribute("hidechrome", "true");

Note however, that your .conkerorrc is evaluated before any windows exist,
so you will need to use one of the window creation hooks to get the window
reference.

Whether it will work the way that you hope, I can't say, as the window
manager I'm using does not display a title bar.

-- 
John Foerch