# Path: sunflower/gui/input_dialog.py
# class CreateToolbarWidgetDialog:
# 	"""Create widget persisten dialog."""
# 
# 	def __init__(self, application):
# 		self._dialog = Gtk.Dialog(parent=application, use_header_bar=True)
# 		self._application = application
# 
# 		# configure dialog
# 		self._dialog.set_title(_('Add toolbar widget'))
# 		self._dialog.set_default_size(450, 10)
# 		self._dialog.set_resizable(True)
# 		self._dialog.set_skip_taskbar_hint(True)
# 		self._dialog.set_modal(True)
# 		self._dialog.set_transient_for(application)
# 		self._dialog.set_wmclass('Sunflower', 'Sunflower')
# 
# 		# create component container
# 		vbox = Gtk.VBox(False, 5)
# 		vbox.set_border_width(5)
# 
# 		# create interfacce
# 		vbox_name = Gtk.VBox(False, 0)
# 
# 		label_name = Gtk.Label(label=_('Name:'))
# 		label_name.set_alignment(0, 0.5)
# 
# 		self._entry_name = Gtk.Entry()
# 		self._entry_name.set_max_width_chars(30)
# 
# 		vbox_type = Gtk.VBox(False, 0)
# 
# 		label_type = Gtk.Label(label=_('Type:'))
# 		label_type.set_alignment(0, 0.5)
# 
# 		cell_renderer_icon = Gtk.CellRendererPixbuf()
# 		cell_renderer_text = Gtk.CellRendererText()
# 		cell_renderer_text.set_property('xalign', 0)
# 		self._type_list = Gtk.ListStore(str, str, str)
# 
# 		self._combobox_type = Gtk.ComboBox.new_with_model(self._type_list)
# 		self._combobox_type.pack_start(cell_renderer_icon, False)
# 		self._combobox_type.pack_start(cell_renderer_text, True)
# 		self._combobox_type.add_attribute(cell_renderer_icon, 'icon-name', 2)
# 		self._combobox_type.add_attribute(cell_renderer_text, 'text', 1)
# 
# 		# create controls
# 		button_add = Gtk.Button(stock=Gtk.STOCK_ADD)
# 		button_add.set_can_default(True)
# 		button_cancel = Gtk.Button(stock=Gtk.STOCK_CANCEL)
# 
# 		self._dialog.add_action_widget(button_cancel, Gtk.ResponseType.CANCEL)
# 		self._dialog.add_action_widget(button_add, Gtk.ResponseType.ACCEPT)
# 
# 		self._dialog.set_default_response(Gtk.ResponseType.ACCEPT)
# 
# 		# pack interface
# 		vbox_name.pack_start(label_name, False, False, 0)
# 		vbox_name.pack_start(self._entry_name, False, False, 0)
# 
# 		vbox_type.pack_start(label_type, False, False, 0)
# 		vbox_type.pack_start(self._combobox_type, False, False, 0)
# 
# 		vbox.pack_start(vbox_name, False, False, 0)
# 		vbox.pack_start(vbox_type, False, False, 0)
# 
# 		self._dialog.get_content_area().pack_start(vbox, False, False, 0)
# 
# 		# show all widgets
# 		self._dialog.show_all()
# 
# 	def update_type_list(self, widgets):
# 		"""Update type list store"""
# 		self._type_list.clear()
# 
# 		for key in widgets.keys():
# 			# get data
# 			data = widgets[key]
# 
# 			# extract data from tuple
# 			text = data[0]
# 			icon = data[1]
# 
# 			# add new item to the list
# 			self._type_list.append((key, text, icon))
# 
# 	def get_response(self):
# 		"""Return dialog response and self-destruct"""
# 		name = None
# 		widget_type = None
# 
# 		# clear text entry before showing
# 		self._entry_name.set_text('')
# 
# 		# show dialog
# 		code = self._dialog.run()
# 
# 		# get name and type
# 		if code == Gtk.ResponseType.ACCEPT and len(self._type_list) > 0:
# 			name = self._entry_name.get_text()
# 			widget_type = self._type_list[self._combobox_type.get_active()][0]
# 
# 		self._dialog.destroy()
# 
# 		return code, name, widget_type
# 
# 	def set_transient_for(self, window):
# 		"""Set dialog window transistency"""
# 		self._dialog.set_transient_for(window)


from gi.repository import Gtk
from sunflower.gui.input_dialog import CreateToolbarWidgetDialog
			factory = self._factory_cache[widget_type]

			# get config
			config = item['config']
			widget = factory.get_widget(widget_name, widget_type, config)

			if widget is not None:
				widget.show()
				self._toolbar.add(widget)

	def register_factory(self, FactoryClass):
		"""Register and create new factory"""
		factory = FactoryClass(self._application)

		# add factory to local storage
		self._factories.append(factory)

		# get widget list
		widgets = factory.get_types()

		# update types and factory cache
		if widgets is not None:
			self._widget_types.update(widgets)

			for widget_type in widgets.keys():
				self._factory_cache[widget_type] = factory

	def show_create_widget_dialog(self, window=None):
		"""Show dialog with type selection and name input"""
		result = False

# Path: sunflower/gui/input_dialog.py
# class CreateToolbarWidgetDialog:
# 	"""Create widget persisten dialog."""
# 
# 	def __init__(self, application):
# 		self._dialog = Gtk.Dialog(parent=application, use_header_bar=True)
# 		self._application = application
# 
# 		# configure dialog
# 		self._dialog.set_title(_('Add toolbar widget'))
# 		self._dialog.set_default_size(450, 10)
# 		self._dialog.set_resizable(True)
# 		self._dialog.set_skip_taskbar_hint(True)
# 		self._dialog.set_modal(True)
# 		self._dialog.set_transient_for(application)
# 		self._dialog.set_wmclass('Sunflower', 'Sunflower')
# 
# 		# create component container
# 		vbox = Gtk.VBox(False, 5)
# 		vbox.set_border_width(5)
# 
# 		# create interfacce
# 		vbox_name = Gtk.VBox(False, 0)
# 
# 		label_name = Gtk.Label(label=_('Name:'))
# 		label_name.set_alignment(0, 0.5)
# 
# 		self._entry_name = Gtk.Entry()
# 		self._entry_name.set_max_width_chars(30)
# 
# 		vbox_type = Gtk.VBox(False, 0)
# 
# 		label_type = Gtk.Label(label=_('Type:'))
# 		label_type.set_alignment(0, 0.5)
# 
# 		cell_renderer_icon = Gtk.CellRendererPixbuf()
# 		cell_renderer_text = Gtk.CellRendererText()
# 		cell_renderer_text.set_property('xalign', 0)
# 		self._type_list = Gtk.ListStore(str, str, str)
# 
# 		self._combobox_type = Gtk.ComboBox.new_with_model(self._type_list)
# 		self._combobox_type.pack_start(cell_renderer_icon, False)
# 		self._combobox_type.pack_start(cell_renderer_text, True)
# 		self._combobox_type.add_attribute(cell_renderer_icon, 'icon-name', 2)
# 		self._combobox_type.add_attribute(cell_renderer_text, 'text', 1)
# 
# 		# create controls
# 		button_add = Gtk.Button(stock=Gtk.STOCK_ADD)
# 		button_add.set_can_default(True)
# 		button_cancel = Gtk.Button(stock=Gtk.STOCK_CANCEL)
# 
# 		self._dialog.add_action_widget(button_cancel, Gtk.ResponseType.CANCEL)
# 		self._dialog.add_action_widget(button_add, Gtk.ResponseType.ACCEPT)
# 
# 		self._dialog.set_default_response(Gtk.ResponseType.ACCEPT)
# 
# 		# pack interface
# 		vbox_name.pack_start(label_name, False, False, 0)
# 		vbox_name.pack_start(self._entry_name, False, False, 0)
# 
# 		vbox_type.pack_start(label_type, False, False, 0)
# 		vbox_type.pack_start(self._combobox_type, False, False, 0)
# 
# 		vbox.pack_start(vbox_name, False, False, 0)
# 		vbox.pack_start(vbox_type, False, False, 0)
# 
# 		self._dialog.get_content_area().pack_start(vbox, False, False, 0)
# 
# 		# show all widgets
# 		self._dialog.show_all()
# 
# 	def update_type_list(self, widgets):
# 		"""Update type list store"""
# 		self._type_list.clear()
# 
# 		for key in widgets.keys():
# 			# get data
# 			data = widgets[key]
# 
# 			# extract data from tuple
# 			text = data[0]
# 			icon = data[1]
# 
# 			# add new item to the list
# 			self._type_list.append((key, text, icon))
# 
# 	def get_response(self):
# 		"""Return dialog response and self-destruct"""
# 		name = None
# 		widget_type = None
# 
# 		# clear text entry before showing
# 		self._entry_name.set_text('')
# 
# 		# show dialog
# 		code = self._dialog.run()
# 
# 		# get name and type
# 		if code == Gtk.ResponseType.ACCEPT and len(self._type_list) > 0:
# 			name = self._entry_name.get_text()
# 			widget_type = self._type_list[self._combobox_type.get_active()][0]
# 
# 		self._dialog.destroy()
# 
# 		return code, name, widget_type
# 
# 	def set_transient_for(self, window):
# 		"""Set dialog window transistency"""
# 		self._dialog.set_transient_for(window)


# Path: sunflower/toolbar.py
from gi.repository import Gtk
from sunflower.gui.input_dialog import CreateToolbarWidgetDialog

			factory = self._factory_cache[widget_type]

			# get config
			config = item['config']
			widget = factory.get_widget(widget_name, widget_type, config)

			if widget is not None:
				widget.show()
				self._toolbar.add(widget)

	def register_factory(self, FactoryClass):
		"""Register and create new factory"""
		factory = FactoryClass(self._application)

		# add factory to local storage
		self._factories.append(factory)

		# get widget list
		widgets = factory.get_types()

		# update types and factory cache
		if widgets is not None:
			self._widget_types.update(widgets)

			for widget_type in widgets.keys():
				self._factory_cache[widget_type] = factory

	def show_create_widget_dialog(self, window=None):
		"""Show dialog with type selection and name input"""
		result = False

		dialog = CreateToolbarWidgetDialog(self._application)