Skip to content

Commit

Permalink
Added tabs menu to group tab context menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
IIUJ-KrzysztofDawidowicz committed Dec 2, 2013
1 parent a69ed38 commit 9a4d8db
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 41 deletions.
Binary file modified TabGroupBar/[email protected]
Binary file not shown.
61 changes: 51 additions & 10 deletions TabGroupBar/chrome/content/tabgroupbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ objTabGroupBar.addTab = function(label){
tabsContainer.appendChild(tab);
}

/**
* @brief Brief
*
* @return Return_Description
*
* @details Details
*/
objTabGroupBar.getTabView = function() {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
Expand All @@ -66,29 +73,30 @@ objTabGroupBar.addGroupTabs = function(){
};

objTabGroupBar.addGroupTab = function(groupItem) {
var label = groupItem.getTitle();
if(!label) {
label = "(none)";
var title = groupItem.getTitle();
if(!title) {
title = "(none)";
}
if(this.debug) {label = label + ":" + groupItem.id;}
if(this.debug) {title = title + ":" + groupItem.id;}
var tab = document.createElement("tab");
tab.setAttribute("label", title);
tab.value = groupItem.id;
tab.setAttribute("id", "TabGroupBar-GroupTab-" + groupItem.id);
tab.setAttribute("label", label);
tab.setAttribute("groupid", groupItem.id);
tab.setAttribute("draggable", "true");
tab.setAttribute("droppable", "true");
tab.setAttribute("context", "TabGroupBar-TabContextMenu");
tab.setAttribute("flex", 1);


tab.setAttribute("oncommand", "objTabGroupBar.switchGroupTo(" + groupItem.id + ");");
tab.setAttribute("ondblclick", "objTabGroupBar.onDbClickTab(event);");
// tab.setAttribute("ondragstart", "objTabGroupBar.onTabDragStrart(event);");
tab.setAttribute("ondragend", "objTabGroupBar.addTab('drag end');objTabGroupBar.addTab(event.dataTransfer.dropEffect);");
/* tab.setAttribute("ondragend", "objTabGroupBar.addTab('drag end');objTabGroupBar.addTab(event.dataTransfer.dropEffect);");
tab.addEventListener("dragstart", function(e) {objTabGroupBar.addTab("dragstart");});
tab.addEventListener("dragend", function(e) {objTabGroupBar.addTab("dragend");});
tab.addEventListener("dragenter", this.onTabDragOver);
tab.addEventListener("dragover", this.onTabDragOver);

tab.addEventListener("dragover", this.onTabDragOver); */

tabsContainer.appendChild(tab);
};
Expand Down Expand Up @@ -140,7 +148,11 @@ objTabGroupBar.switchGroupTo = function(groupId){
};

objTabGroupBar.clearGroupTabs = function(){
var tabs = [];
while(tabsContainer.firstChild)
{
tabsContainer.removeChild(tabsContainer.firstChild);
}
/* var tabs = [];
var childNodes = tabsContainer.childNodes;
for(i=0;i<childNodes.length;i++)
{
Expand All @@ -151,10 +163,17 @@ objTabGroupBar.clearGroupTabs = function(){
}
tabs.forEach(function(tab){
tabsContainer.removeChild(tab);
});
}); */

};

objTabGroupBar.clearChildren = function(node){
while(node.firstChild)
{
node.removeChild(node.firstChild);
}
};

objTabGroupBar.getPopupSourceElement = function(event){
return event.target.parentNode.triggerNode;
};
Expand Down Expand Up @@ -241,6 +260,28 @@ objTabGroupBar.renameGroup = function(group, title){
group.setTitle(title);
};

objTabGroupBar.onTabListPopupShowing = function(event){
let popup = event.target;
let group = this.getGroupForTab(event.target.parentNode.parentNode.triggerNode);
let tabs = group.getChildren();
let tabContainer = this.window.gBrowser.tabContainer;

let selectTab = function(event) {
objTabGroupBar.window.gBrowser.tabContainer.selectedIndex = event.target.value;
};

for(i=0; i<tabs.length;i++)
{
let tab = tabs[i].tab;
let item = document.createElement("menuitem");
item.setAttribute("label", tab.label);
item.setAttribute("image", tab.image);
item.className = "menuitem-iconic";
item.value = tabContainer.getIndexOfItem(tab);
item.addEventListener("command", selectTab);
popup.appendChild(item);
}
};

window.addEventListener("load",
function(e)
Expand Down
61 changes: 31 additions & 30 deletions TabGroupBar/chrome/content/tabgroupbar.xul
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
<?xml version="1.0"?>

<overlay id="TabGroupBar-Overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript"
<script type="application/x-javascript"
src="chrome://TabGroupBar/content/tabgroupbar.js" />
<popupset>
<menupopup id="TabGroupBar-BarContextMenu">
<menuitem id="TabGroupBar-BarContextMenu-NewGroup" label="New Group" tooltiptext="Add new group"
<popupset>
<menupopup id="TabGroupBar-BarContextMenu">
<menuitem id="TabGroupBar-BarContextMenu-NewGroup" label="New Group" tooltiptext="Add new group"
oncommand="objTabGroupBar.createNewGroup()"/>
<menuitem id="TabGroupBar-BarContextMenu-Reload" label="Reload tabs"
<menuitem id="TabGroupBar-BarContextMenu-Reload" label="Reload tabs"
oncommand="objTabGroupBar.reloadGroupTabs();"/>
</menupopup>
<menupopup id="TabGroupBar-TabContextMenu">
<menuitem id="TabGroupBar-TabContextMenu-CloseGroup" label="Close Group"
</menupopup>
<menupopup id="TabGroupBar-TabContextMenu">
<menuitem id="TabGroupBar-TabContextMenu-CloseGroup" label="Close Group"
oncommand="objTabGroupBar.onCloseGroupContextMenuAction(event)"/>
<menuitem id="TabGroupBar-TabContextMenu-RenameGroup" label="Rename Group"
<menuitem id="TabGroupBar-TabContextMenu-RenameGroup" label="Rename Group"
oncommand="objTabGroupBar.renameGroupContextAction(event)"/>
</menupopup>
</popupset>
<menu id="TabGroupBar-TabContextMenu-TabMenu" label="Tabs">
<menupopup id="TabGroupBar-TabContextMenu-TabMenu-Popup"
onpopupshowing="objTabGroupBar.onTabListPopupShowing(event);"
onpopuphiding="objTabGroupBar.clearChildren(event.target)"/>
</menu>
</menupopup>

</popupset>



<toolbox id="navigator-toolbox"> <!-- Main Firefox toolbox where all the toolbars normally are -->
<toolbar id="TabGroupBar-Toolbar"
<toolbox id="navigator-toolbox"> <!-- Main Firefox toolbox where all the toolbars normally are -->
<toolbar id="TabGroupBar-Toolbar"
toolbarname="Tab Group Bar"
accesskey="G"
class="chromeclass-toolbar"
context="TabGroupBar-BarContextMenu"
hidden="false"
persist="hidden"
ondragover="objTabGroupBar.onTabDragOver (event);"
>
<tabbox id="TabGroupBar-TabBox" flex="1" ondragover="objTabGroupBar.onTabDragOver(event);">
<tabbox id="TabGroupBar-TabBox" flex="1" >
<arrowscrollbox orient="horizontal">
<tabs id="TabGroupBar-TabBox-Tabs">
<!--<button label="Load tabs" oncommand="objTabGroupBar.addGroupTabs(); "/>-->
<!--<tab label="First tab" oncommand="objTabGroupBar.addGroupTabs(); "/>-->
<!--<tab label="Second tab" oncommand=""/>-->
<!--<tab label="Last tab"/>-->
</tabs>
</arrowscrollbox>

<arrowscrollbox orient="horizontal">
<tabs id="TabGroupBar-TabBox-Tabs"
droppable="true"
ondragover="objTabGroupBar.onTabDragOver(event);"
ondrop="objTabGroupBar.onTabDragOver(event);">
<!--<button label="Load tabs" oncommand="objTabGroupBar.addGroupTabs(); "/>-->
<!--<tab label="First tab" oncommand="objTabGroupBar.addGroupTabs(); "/>-->
<!--<tab label="Second tab" oncommand=""/>-->
<!--<tab label="Last tab"/>-->
</tabs>
</arrowscrollbox>

</tabbox>
</toolbar>
</toolbox>
</tabbox>
</toolbar>
</toolbox>
</overlay>
2 changes: 1 addition & 1 deletion TabGroupBar/install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<em:id>[email protected]</em:id>
<em:name>Tab Group Bar</em:name>
<em:type>2</em:type>
<em:version>1.0</em:version>
<em:version>1.1</em:version>

<em:targetApplication>
<Description>
Expand Down

0 comments on commit 9a4d8db

Please sign in to comment.