#!/usr/bin/python
# -*- coding: utf-8 -*-

import gtk, detailstables

class details(gtk.ScrolledWindow):
	""" Objet contenant les propriétés d'un élément """
	def __init__(self, config, callback):
		self.config = config
		gtk.ScrolledWindow.__init__(self)
		self.set_shadow_type(gtk.SHADOW_NONE)
		self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		
		self.notebook = gtk.Notebook()
		self.notebook.set_show_border(False)
		self.notebook.set_show_tabs(False)
		self.notebook.set_border_width(5)
		self.add_with_viewport(self.notebook)

		self.default = self.notebook.append_page(detailstables.default(self.config, callback))
		self.index = self.notebook.append_page(detailstables.index(self.config, callback))
		self.cat = self.notebook.append_page(detailstables.cat(self.config, callback))
		self.subpage = self.notebook.append_page(detailstables.subpage(self.config, callback))
		self.separator = self.notebook.append_page(detailstables.separator(self.config, callback))
		self.app = self.notebook.append_page(detailstables.app(self.config, callback))
		self.panel_icon = self.notebook.append_page(detailstables.panel_icon(self.config, callback))
	
	def open(self, element):
		type = element.get("type")
		if type == "index":
			self.notebook.get_nth_page(self.index).open(element)
			self.notebook.set_current_page(self.index)
		elif type in ["cat", "cat-apps", "cat-subpages"]:
			self.notebook.get_nth_page(self.cat).open(element)
			self.notebook.set_current_page(self.cat)
		elif type == "subpage":
			self.notebook.get_nth_page(self.subpage).open(element)
			self.notebook.set_current_page(self.subpage)
		elif type == "separator":
			self.notebook.get_nth_page(self.separator).open(element)
			self.notebook.set_current_page(self.separator)
		elif type == "app":
			self.notebook.get_nth_page(self.app).open(element)
			self.notebook.set_current_page(self.app)
		elif type == "panel_icon":
			self.notebook.get_nth_page(self.panel_icon).open(element)
			self.notebook.set_current_page(self.panel_icon)
		else:
			self.notebook.set_current_page(self.default)
