<?xml version="1.0"?>
<?xml-stylesheet href="chrome://unplug/content/ui/unplug_result_skin.css" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>

<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

	
	<!--
		a result to display in searchpage.xul
		these are created as we find the search results
	-->	
	<binding id="unplug_result">




		<!--
		<handlers>
			<handler event="event-name" action="script"/>
		</handlers>
		-->


		<!-- example .doAlert("foo")
		https://developer.mozilla.org/en/XUL_Tutorial/Adding_Methods_to_XBL-defined_Elements
		on accessing annonymous nodes -->
		<implementation>
			<constructor>
				// pass
			</constructor>
			<method name="setOpeners">
				<parameter name="caps"/>
				<body>
					// set this to be the default menu item (the element)
					var default_open = document.getAnonymousElementByAttribute(this, "id", "open_tab");
					
					switch (caps['opener']) {
						case "tab":
							default_open = document.getAnonymousElementByAttribute(this, "id", "open_tab");
							break;
						case "new":
							default_open = document.getAnonymousElementByAttribute(this, "id", "open_new");
							break;
						case "over":
							default_open = document.getAnonymousElementByAttribute(this, "id", "open_over");
							break;
					}
					
					// set the button
					var open_btn = document.getAnonymousElementByAttribute(this, "id", "open")
					open_btn.setAttribute("oncommand", default_open.getAttribute("oncommand"));
					open_btn.setAttribute("tooltiptext", default_open.getAttribute("tooltiptext"));
					default_open.style.fontWeight = "bold";
				</body>
			</method>
			<method name="setDownloaders">
				<parameter name="caps"/>
				<body>
					// set this to be the default menu item (the element)
					var default_dl = document.getAnonymousElementByAttribute(this, "id", "dl_saveas")
					
					if (caps['downthemall']) {
						var el = document.getAnonymousElementByAttribute(this, "id", "dl_dta")
						el.style.display = "block";
						default_dl = el;
					}
					
					// set the button
					var dl_btn = document.getAnonymousElementByAttribute(this, "id", "dl")
					dl_btn.setAttribute("oncommand", default_dl.getAttribute("oncommand"));
					dl_btn.setAttribute("tooltiptext", default_dl.getAttribute("tooltiptext"));
					default_dl.style.fontWeight = "bold";
				</body>
			</method>
		</implementation>





		<content>
			<xul:vbox flex="1" style="border: 1px black solid" xbl:inherits="tooltiptext=url">
				<xul:toolbar id="test-toolbar" flex="1">
					<xul:image xbl:inherits="src=thumbnail" id="thumbnail" />
					<xul:vbox flex="1" style="overflow: hidden;">
						<xul:hbox>
							<xul:label id="host" xbl:inherits="value=url_host" />
							<xul:label id="name" xbl:inherits="value=title" />
						</xul:hbox>
						<xul:hbox>
							<xul:label id="protocol" class="unplug-sub-heading" xbl:inherits="value=url_protocol" />
							<xul:label id="description" class="unplug-sub-heading" xbl:inherits="value=description" />
						</xul:hbox>
					</xul:vbox>
					<!--
						we want these to be drop-down buttons
						ie Open / Open in a new window
						and Download / Dowload with dTa / download with XXX
						and Play / Play in vlc / Play in totem / Look for media players
					-->
					<!-- aternative is type="menu" -->
					<xul:toolbarbutton
						id="open"
						accesskey="o"
						label="Open"
						type="menu-button"
						>
						<xul:menupopup>
							<xul:menuitem
								id="open_tab"
								accesskey="t"
								label="Open in a new tab"
								oncommand="UnPlug2SearchPage.open_new_tab(document.getBindingParent(this)); event.stopPropagation();"
								/>
							<xul:menuitem
								id="open_new"
								accesskey="n"
								label="Open in a new window"
								oncommand="UnPlug2SearchPage.open_new_window(document.getBindingParent(this)); event.stopPropagation();"
								/>
							<xul:menuitem
								id="open_over"
								accesskey="v"
								label="Open in over window"
								oncommand="UnPlug2SearchPage.open_over_window(document.getBindingParent(this)); event.stopPropagation();"
								/>
							<xul:menuseperator />
							<xul:menuitem
								accesskey="c"
								label="Configure"
								class="menuitem-iconic config"
								disabled="true"
								/>
						</xul:menupopup>
					</xul:toolbarbutton>
					<xul:toolbarbutton
						id="dl"
						accesskey="d"
						label="Download"
						type="menu-button"
						>
						<xul:menupopup>
							<xul:menuitem
								id="dl_saveas"
								accesskey="s"
								label="Save file"
								class="menuitem-iconic saveas"
								oncommand="UnPlug2SearchPage.download_saveas(document.getBindingParent(this)); event.stopPropagation();"
								tooltiptext="Use Firefox's default download manager"
								/>
							<xul:menuitem
								id="dl_dta"
								style="display : none;"
								accesskey="a"
								label="DownThemAll"
								class="menuitem-iconic dta"
								oncommand="UnPlug2SearchPage.download_dta(document.getBindingParent(this)); event.stopPropagation();"
								tooltiptext="Download with the DownThemAll extension."
								/>
							<xul:menuseperator />
							<xul:menuitem
								accesskey="c"
								label="Configure"
								class="menuitem-iconic config"
								disabled="true"
								/>
						</xul:menupopup>
					</xul:toolbarbutton>
				</xul:toolbar>

			
				<!-- this is some sort of hidden drop-down box with more information -->
				<!--
				<xul:vbox>
					<xul:label xul:class="unplug-text" xbl:inherits="value=url"/>
				</xul:vbox>
				-->
			</xul:vbox>
		</content>
	</binding>

</bindings>

