[gedit-latex/remove-tools: 1/4] Remove tools from preferences and UI



commit 59ae2683215fceb26c0de297fe5f700ba2f66660
Author: John Stowers <john stowers gmail com>
Date:   Sat Jun 25 01:29:13 2011 +1200

    Remove tools from preferences and UI

 latex/base/decorators.py      |  134 +--------------
 latex/preferences/__init__.py |  186 +--------------------
 latex/preferences/dialog.py   |  379 -----------------------------------------
 latex/tools.xml               |   30 ----
 4 files changed, 2 insertions(+), 727 deletions(-)
---
diff --git a/latex/base/decorators.py b/latex/base/decorators.py
index 16c427a..caa39e6 100644
--- a/latex/base/decorators.py
+++ b/latex/base/decorators.py
@@ -32,7 +32,6 @@ import string
 from config import UI, WINDOW_SCOPE_VIEWS, EDITOR_SCOPE_VIEWS, EDITORS, ACTIONS
 from ..tools.views import ToolView
 from . import File, SideView, BottomView, WindowContext
-from ..tools import ToolAction
 from ..preferences import Preferences, IPreferencesMonitor
 
 # TODO: maybe create ActionDelegate for GeditWindowDecorator
@@ -41,21 +40,12 @@ class GeditWindowDecorator(IPreferencesMonitor):
 	"""
 	This class
 	 - manages the GeditTabDecorators
-	 - hooks the plugin actions as menu items and tool items
+	 - hooks the plugin actions as menu items
 	 - installs side and bottom panel views
 	"""
 	
 	_log = getLogger("GeditWindowDecorator")
 	
-	# ui definition template for hooking tools in Gedit's ui
-	_tool_ui_template = string.Template("""<ui>
-			<menubar name="MenuBar">
-				<menu name="ToolsMenu" action="Tools">
-					<placeholder name="ToolsOps_1">$items</placeholder>
-				</menu>
-			</menubar>
-		</ui>""")
-	
 	def __init__(self, window):
 		self._window = window
 		
@@ -69,7 +59,6 @@ class GeditWindowDecorator(IPreferencesMonitor):
 		
 		# the order is important!
 		self._init_actions()
-		self._init_tool_actions()
 		self._init_views()
 		self._init_tab_decorators()
 		
@@ -179,74 +168,6 @@ class GeditWindowDecorator(IPreferencesMonitor):
 		if len(views) > 0 and not self._active_tab_decorator:
 			self._log.warning("_init_tab_decorators: no active decorator found")
 	
-	def _init_tool_actions(self):
-		"""
-		 - Load defined Tools
-		 - create and init ToolActions from them
-		 - hook them in the window UI
-		 - create a map from extensions to lists of ToolActions
-		"""
-		
-		# add a MenuToolButton with the tools menu to the toolbar afterwards
-		# FIXME: this is quite hacky
-		menu = Gtk.Menu()
-		
-		# this is used for enable/disable actions by name
-		# None stands for every extension
-		self._tool_action_extensions = { None : [] }
-		
-		self._tool_action_group = Gtk.ActionGroup("LaTeXPluginToolActions")
-			
-		items_ui = ""
-		
-		self._action_handlers = {}
-		
-		i = 1					# counting tool actions
-		accel_counter = 1		# counting tool actions without custom accel
-		for tool in self._preferences.tools:
-			# hopefully unique action name
-			name = "Tool%sAction" % i
-			
-			# update extension-tool mapping
-			for extension in tool.extensions:
-				try:
-					self._tool_action_extensions[extension].append(name)
-				except KeyError:
-					# extension not yet mapped
-					self._tool_action_extensions[extension] = [name]
-			
-			# create action
-			action = ToolAction(tool)
-			gtk_action = Gtk.Action(name, action.label, action.tooltip, action.stock_id)
-			self._action_handlers[gtk_action] = gtk_action.connect("activate", lambda gtk_action, action: action.activate(self._window_context), action)
-			
-			if not tool.accelerator is None and len(tool.accelerator) > 0:
-				# TODO: validate accelerator!
-				self._tool_action_group.add_action_with_accel(gtk_action, tool.accelerator)
-			else:
-				self._tool_action_group.add_action_with_accel(gtk_action, "<Ctrl><Alt>%s" % accel_counter)
-				accel_counter += 1
-			
-			# add to MenuToolBar menu
-			# FIXME: GtkWarning: gtk_accel_label_set_accel_closure: assertion `gtk_accel_group_from_accel_closure (accel_closure) != NULL' failed
-			menu.add(gtk_action.create_menu_item())
-			
-			# add UI definition
-			items_ui += """<menuitem action="%s" />""" % name
-			
-			i += 1
-		
-		tool_ui = self._tool_ui_template.substitute({"items" : items_ui})
-		
-		self._ui_manager.insert_action_group(self._tool_action_group, -1)
-		self._tool_ui_id = self._ui_manager.add_ui_from_string(tool_ui)
-		
-		# add a MenuToolButton with the tools menu to the toolbar
-		self._menu_tool_button = Gtk.MenuToolButton.new_from_stock(Gtk.STOCK_CONVERT)
-		self._menu_tool_button.set_menu(menu)
-		self._menu_tool_button.show_all()
-		self._toolbar.insert(self._menu_tool_button, -1)
-	
 	def save_file(self):
 		"""
 		Trigger the 'Save' action
@@ -255,29 +176,6 @@ class GeditWindowDecorator(IPreferencesMonitor):
 		"""
 		self._save_action.activate()
 	
-	def _on_tools_changed(self):
-		# FIXME: tools reload doesn't work
-		# UPDATE: should work now
-		
-		# see IPreferencesMonitor._on_tools_changed
-		self._log.debug("_on_tools_changed")
-		
-		# remove tool actions and ui
-		self._ui_manager.remove_ui(self._tool_ui_id)
-		for gtk_action in self._action_handlers:
-			gtk_action.disconnect(self._action_handlers[gtk_action])
-			self._tool_action_group.remove_action(gtk_action)
-		self._ui_manager.remove_action_group(self._tool_action_group)
-
-		# remove MenuToolButton
-		self._toolbar.remove(self._menu_tool_button)
-		
-		# re-init tool actions
-		self._init_tool_actions()
-		
-		# re-adjust action states
-		self.adjust(self._active_tab_decorator)
-	
 	def activate_tab(self, file):
 		"""
 		Activate the GeditTab containing the given File or open a new
@@ -313,11 +211,6 @@ class GeditWindowDecorator(IPreferencesMonitor):
 		for name in self._action_objects.iterkeys():
 			self._action_group.get_action(name).set_visible(False)
 			
-		# disable all tool actions
-		for l in self._tool_action_extensions.values():
-			for name in l:
-				self._tool_action_group.get_action(name).set_sensitive(False)
-				
 		# remove all side views
 		side_views = self._window_side_views + self._side_views
 		for view in side_views:
@@ -371,12 +264,6 @@ class GeditWindowDecorator(IPreferencesMonitor):
 		for name in self._action_objects:
 			self._action_group.get_action(name).set_visible(False)
 		
-		# disable all tool actions
-		for l in self._tool_action_extensions.values():
-			for name in l:
-				self._tool_action_group.get_action(name).set_sensitive(False)
-		
-		
 		# enable the actions for all extensions
 		for name in self._action_extensions[None]:
 			self._action_group.get_action(name).set_visible(True)
@@ -390,18 +277,6 @@ class GeditWindowDecorator(IPreferencesMonitor):
 				pass
 		
 		
-		# enable the tool actions that apply for all extensions
-		for name in self._tool_action_extensions[None]:
-			self._tool_action_group.get_action(name).set_sensitive(True)
-		
-		# enable the tool actions that apply for this extension
-		if extension:
-			try:
-				for name in self._tool_action_extensions[extension]:
-					self._tool_action_group.get_action(name).set_sensitive(True)
-			except KeyError:
-				pass
-		
 		#
 		# save selection state
 		#
@@ -657,13 +532,6 @@ class GeditWindowDecorator(IPreferencesMonitor):
 		# remove toolbar
 		self._toolbar.destroy()
 		
-		# remove tool actions
-		self._ui_manager.remove_ui(self._tool_ui_id)
-		for gtk_action in self._action_handlers:
-			gtk_action.disconnect(self._action_handlers[gtk_action])
-			self._tool_action_group.remove_action(gtk_action)
-		self._ui_manager.remove_action_group(self._tool_action_group)
-		
 		# remove actions
 		self._ui_manager.remove_ui(self._ui_id)
 		for clazz in self._action_objects:
diff --git a/latex/preferences/__init__.py b/latex/preferences/__init__.py
index 12e1efb..29e63ea 100644
--- a/latex/preferences/__init__.py
+++ b/latex/preferences/__init__.py
@@ -25,8 +25,6 @@ preferences
 from logging import getLogger
 
 from ..base.resources import find_resource, MODE_READWRITE
-from ..tools import Tool, Job
-from ..tools.postprocess import GenericPostProcessor, RubberPostProcessor, LaTeXPostProcessor
 
 def str_to_bool(x):
 	"""
@@ -53,12 +51,6 @@ class IPreferencesMonitor(object):
 		A simple key-value-pair has changed
 		"""
 
-	def _on_tools_changed(self):
-		"""
-		The Tools have changed
-		"""
-
-
 # ElementTree is part of Python 2.5
 # TODO: see http://effbot.org/zone/element-index.htm
 import xml.etree.ElementTree as ElementTree
@@ -96,11 +88,6 @@ class Preferences(object):
 	
 	_log = getLogger("Preferences")
 	
-	# maps names to classes
-	POST_PROCESSORS = {"GenericPostProcessor" : GenericPostProcessor, 
-					   "LaTeXPostProcessor" : LaTeXPostProcessor, 
-					   "RubberPostProcessor" : RubberPostProcessor}
-	
 	def __new__(cls):
 		if not '_instance' in cls.__dict__:
 			cls._instance = object.__new__(cls)
@@ -121,15 +108,9 @@ class Preferences(object):
 			self.__monitors = []
 			
 			self.__preferences_changed = False
-			self.__tools_changed = False
-			
-			# TODO: use some object cache mechanism instead of those fields
-			self.__tool_objects = None
-			self.__tool_ids = None
 			
 			# parse
 			self.__preferences = ElementTree.parse(find_resource("preferences.xml", MODE_READWRITE)).getroot()
-			self.__tools = ElementTree.parse(find_resource("tools.xml", MODE_READWRITE)).getroot()
 			
 			self._ready = True
 	
@@ -201,163 +182,6 @@ class Preferences(object):
 		for monitor in self.__monitors:
 			monitor._on_value_changed(key, value)
 	
-	def __notify_tools_changed(self):
-		"""
-		Notify monitors that the Tools have changed
-		"""
-		for monitor in self.__monitors:
-			monitor._on_tools_changed()
-	
-	@property
-	def tools(self):
-		"""
-		Return all Tools
-		"""
-		self.__tool_ids = {}
-		
-		tools = []
-		
-		for tool_element in self.__tools.findall("tool"):
-			jobs = []
-			for job_element in tool_element.findall("job"):
-				jobs.append(Job(job_element.text.strip(), str_to_bool(job_element.get("mustSucceed")), self.POST_PROCESSORS[job_element.get("postProcessor")]))
-			
-			assert not tool_element.get("extensions") is None
-			
-			extensions = tool_element.get("extensions").split()
-			accelerator = tool_element.get("accelerator")
-			id = tool_element.get("id")
-			tool = Tool(tool_element.get("label"), jobs, tool_element.get("description"), accelerator, extensions)
-			self.__tool_ids[tool] = id
-			
-			tools.append(tool)
-			
-		return tools
-	
-	def __find_tool_element(self, id):
-		"""
-		Find the tool element with the given id 
-		"""
-		for element in self.__tools.findall("tool"):
-			if element.get("id") == id:
-				return element
-		self._log.warning("<tool id='%s'> not found" % id)
-		return None
-	
-	def save_or_update_tool(self, tool):
-		"""
-		Save or update the XML subtree for the given Tool
-		
-		@param tool: a Tool object
-		"""
-		tool_element = None
-		if tool in self.__tool_ids:
-			# find tool tag
-			self._log.debug("Tool element found, updating...")
-			
-			id = self.__tool_ids[tool]
-			tool_element = self.__find_tool_element(id)
-		else:
-			# create new tool tag
-			self._log.debug("Creating new Tool...")
-			
-			id = str(uuid.uuid4())		# random UUID
-			self.__tool_ids[tool] = id
-			
-			tool_element = ElementTree.SubElement(self.__tools, "tool")
-			tool_element.set("id", id)
-		
-		tool_element.set("label", tool.label)
-		tool_element.set("description", tool.description)
-		tool_element.set("extensions", " ".join(tool.extensions))
-		if tool.accelerator is None:
-			if "accelerator" in tool_element.attrib.keys():
-				del tool_element.attrib["accelerator"]
-		else:
-			tool_element.set("accelerator", tool.accelerator)
-		
-		# remove all jobs
-		for job_element in tool_element.findall("job"):
-			tool_element.remove(job_element)
-			
-		# append new jobs
-		for job in tool.jobs:
-			job_element = ElementTree.SubElement(tool_element, "job")
-			job_element.set("mustSucceed", str(job.must_succeed))
-			job_element.set("postProcessor", job.post_processor.name)
-			job_element.text = job.command_template
-		
-		self.__tools_changed = True
-		self.__notify_tools_changed()
-	
-	def swap_tools(self, tool_1, tool_2):
-		"""
-		Swap the order of two Tools
-		"""
-		# grab their ids
-		id_1 = self.__tool_ids[tool_1]
-		id_2 = self.__tool_ids[tool_2]
-		
-		if id_1 == id_2:
-			self._log.warning("Two tools have the same id. Please modify tools.xml to have unique id's.")
-			return
-		
-		self._log.debug("Tool IDs are {%s: %s, %s, %s}" % (tool_1.label, id_1, tool_2.label, id_2))
-		
-		tool_element_1 = None
-		tool_element_2 = None
-		
-		# find the XML elements and current indexes of the tools
-		i = 0
-		for tool_element in self.__tools:
-			if tool_element.get("id") == id_1:
-				tool_element_1 = tool_element
-				index_1 = i
-			elif tool_element.get("id") == id_2:
-				tool_element_2 = tool_element
-				index_2 = i
-			
-			if not (tool_element_1 is None or tool_element_2 is None):
-				break
-			
-			i += 1
-		
-		self._log.debug("Found XML elements, indexes are {%s: %s, %s, %s}" % (tool_1.label, index_1, tool_2.label, index_2))
-		
-		# successively replace each of them by the other in the XML model
-		self.__tools.remove(tool_element_1)
-		self.__tools.insert(index_1, tool_element_2)
-		
-		self._log.debug("Replaced first tool by second in list")
-				
-		self.__tools.remove(tool_element_2)
-		self.__tools.insert(index_2, tool_element_1)
-		
-		self._log.debug("Replaced second tool by first in list")
-		
-		# notify changes
-		self.__tools_changed = True
-		self.__notify_tools_changed()
-	
-	def delete_tool(self, tool):
-		"""
-		Delete the given Tool
-		
-		@param tool: a Tool object
-		"""
-		try:
-			id = self.__tool_ids[tool]
-			tool_element = self.__find_tool_element(id)
-			self.__tools.remove(tool_element)
-			
-			del self.__tool_ids[tool]
-			
-			self.__tools_changed = True
-		except KeyError, e:
-			self._log.error("delete_tool: %s" % e)
-		
-		self.__notify_tools_changed()
-	
 	def save(self):
 		"""
 		Save the preferences to XML
@@ -369,12 +193,4 @@ class Preferences(object):
 			tree.write(find_resource("preferences.xml", MODE_READWRITE), encoding="utf-8")
 			
 			self.__preferences_changed = False
-		
-		if self.__tools_changed:
-			self._log.debug("Saving tools...")
-		
-			tree = ElementTree.ElementTree(self.__tools)
-			tree.write(find_resource("tools.xml", MODE_READWRITE), encoding="utf-8")
-			
-			self.__tools_changed = False
-	
\ No newline at end of file
+
diff --git a/latex/preferences/dialog.py b/latex/preferences/dialog.py
index cc58b3b..3280e53 100644
--- a/latex/preferences/dialog.py
+++ b/latex/preferences/dialog.py
@@ -95,260 +95,6 @@ class PreferencesColorProxy(object):
 		
 		return "#%02x%02x%02x" % (r, g, b)
 
-
-from ..tools import Tool, Job
-
-
-class ConfigureToolDialog(GladeInterface):
-	"""
-	Wraps the dialog for setting up a Tool
-	"""
-	
-	filename = find_resource("ui/configure_tool.ui")
-	
-	_dialog = None
-	
-	def run(self, tool):
-		"""
-		Runs the dialog and returns the updated Tool or None on abort
-		"""
-		dialog = self._get_dialog()
-		
-		self._tool = tool
-		
-		# load Tool
-		self._entry_label.set_text(tool.label)
-		self._entry_description.set_text(tool.description)
-		
-		self._store_job.clear()
-		for job in tool.jobs:
-			self._store_job.append([job.command_template, job.must_succeed, job.post_processor.name])
-		
-		self._store_extension.clear()
-		for ext in tool.extensions:
-			self._store_extension.append([ext])
-		
-		if tool.accelerator is None:
-			self._radio_user_accel.set_active(False)
-			self._entry_accel.set_text("")
-		else:
-			self._radio_user_accel.set_active(True)
-			self._entry_accel.set_text(tool.accelerator)
-		
-		if dialog.run() == 1:
-			#
-			# okay clicked - update the Tool object
-			#
-			tool.label = self._entry_label.get_text()
-			tool.description = self._entry_description.get_text()
-			
-			tool.jobs = []
-			for row in self._store_job:
-				pp_class = self._preferences.POST_PROCESSORS[row[2]]
-				tool.jobs.append(Job(row[0], row[1], pp_class))
-				
-			tool.extensions = []
-			for row in self._store_extension:
-				tool.extensions.append(row[0])
-			
-			# TODO: validate accelerator!
-			if self._radio_user_accel.get_active():
-				tool.accelerator = self._entry_accel.get_text()
-			else:
-				tool.accelerator = None
-			
-			return tool
-		else:
-			return None
-	
-	def _get_dialog(self):
-		if not self._dialog:
-			# 
-			# build the dialog
-			#
-			self._preferences = Preferences()
-			
-			self._dialog = self.find_widget("dialogConfigureTool")
-			self._button_okay = self.find_widget("buttonOkay")
-			self._labelProfileValidate = self.find_widget("labelHint")
-			
-			#
-			# label
-			#
-			self._entry_label = self.find_widget("entryLabel")
-			
-			#
-			# jobs
-			#
-			self._entry_new_job = self.find_widget("entryNewJob")
-			self._button_add_job = self.find_widget("buttonAddJob")
-			self._button_remove_job = self.find_widget("buttonRemoveJob")
-			self._button_job_up = self.find_widget("buttonMoveUpJob")
-			self._view_job = self.find_widget("treeviewJob")
-			
-			self._store_job = Gtk.ListStore(str, bool, str)   # command, mustSucceed, postProcessor
-			
-			self._view_job.set_model(self._store_job)
-			
-			mustSucceedRenderer = Gtk.CellRendererToggle()
-			mustSucceedRenderer.connect("toggled", self._on_must_succeed_toggled)
-			
-			commandRenderer = Gtk.CellRendererText()
-			commandRenderer.connect("edited", self._on_job_command_edited)
-
-			self._store_pp = Gtk.ListStore(str)
-			for p in self._preferences.POST_PROCESSORS.iterkeys():
-				self._store_pp.append([p])
-			
-			ppRenderer = Gtk.CellRendererCombo()
-			ppRenderer.set_property("editable", True)
-			ppRenderer.set_property("model", self._store_pp)
-			ppRenderer.set_property("text_column", 0)
-			ppRenderer.set_property("has_entry", False)
-			
-			ppRenderer.connect("edited", self._on_job_pp_edited)
-			
-			_insert_column_with_attributes(self._view_job, -1, "Command", commandRenderer, text=0, editable=True)
-			_insert_column_with_attributes(self._view_job, -1, "Must Succeed", mustSucceedRenderer, active=1)
-			_insert_column_with_attributes(self._view_job, -1, "Post-Processor", ppRenderer, text=2)
-			
-			#
-			# description
-			#
-			self._entry_description = self.find_widget("entryDescription")
-			
-			#
-			# extensions
-			#
-			self._entry_new_extension = self.find_widget("entryNewExtension")
-			
-			self._store_extension = Gtk.ListStore(str)
-			
-			self._view_extension = self.find_widget("treeviewExtension")
-			self._view_extension.set_model(self._store_extension)
-			_insert_column_with_attributes(self._view_extension, -1, "", Gtk.CellRendererText(), text=0)
-			self._view_extension.set_headers_visible(False)
-			
-			self._button_add_extension = self.find_widget("buttonAddExtension")
-			self._button_remove_extension = self.find_widget("buttonRemoveExtension")
-			
-			self._radio_user_accel = self.find_widget("radioAccelUser")
-			self._entry_accel = self.find_widget("entryAccel")
-			
-			self.connect_signals({ "on_entryNewJob_changed" : self._on_new_job_changed,
-								   "on_entryNewExtension_changed" : self._on_new_extension_changed,
-								   "on_buttonAddJob_clicked" : self._on_add_job_clicked,
-								   "on_buttonRemoveJob_clicked" : self._on_remove_job_clicked,
-								   "on_treeviewJob_cursor_changed" : self._on_job_cursor_changed,
-								   "on_treeviewExtension_cursor_changed" : self._on_extension_cursor_changed,
-								   "on_buttonAbort_clicked" : self._on_abort_clicked,
-								   "on_buttonOkay_clicked" : self._on_okay_clicked,
-								   "on_buttonRemoveExtension_clicked" : self._on_remove_extension_clicked,
-								   "on_buttonAddExtension_clicked" : self._on_add_extension_clicked,
-								   "on_buttonMoveUpJob_clicked" : self._on_move_up_job_clicked,
-								   "on_radioAccelUser_toggled" : self._on_accel_user_toggled })
-		
-		return self._dialog
-	
-	def _on_accel_user_toggled(self, togglebutton):
-		enabled = togglebutton.get_active()
-		self._entry_accel.set_sensitive(enabled)
-	
-	def _on_move_up_job_clicked(self, button):
-		store, iter = self._view_job.get_selection().get_selected()
-		store.swap(iter)
-	
-	def _on_add_extension_clicked(self, button):
-		extension = self._entry_new_extension.get_text()
-		self._store_extension.append([extension])
-	
-	def _on_remove_extension_clicked(self, button):
-		store, it = self._view_extension.get_selection().get_selected()
-		store.remove(it)
-	
-	def _on_job_command_edited(self, renderer, path, text):
-		"""
-		The command template has been edited
-		"""
-		self._store_job.set(self._store_job.get_iter_from_string(path), 0, text)
-	
-	def _on_job_pp_edited(self, renderer, path, text):
-		"""
-		Another post processor has been selected
-		"""
-		self._store_job.set(self._store_job.get_iter_from_string(path), 2, text)
-	
-	def _on_must_succeed_toggled(self, renderer, path):
-		"""
-		The 'must succeed' flag has been toggled
-		"""
-		value = self._store_job.get(self._store_job.get_iter_from_string(path), 1)[0]
-		self._store_job.set(self._store_job.get_iter_from_string(path), 1, not value)
-	
-	def _on_add_job_clicked(self, button):
-		"""
-		Add a new job
-		"""
-		command = self._entry_new_job.get_text()
-		self._store_job.append([command, True, "GenericPostProcessor"])
-	
-	def _on_remove_job_clicked(self, button):
-		store, it = self._view_job.get_selection().get_selected()
-		store.remove(it)
-	
-	def _on_new_job_changed(self, widget):
-		"""
-		The entry for a new command template has changed
-		"""
-		self._button_add_job.set_sensitive(len(self._entry_new_job.get_text()) > 0)
-	
-	def _on_new_extension_changed(self, widget):
-		self._button_add_extension.set_sensitive(len(self._entry_new_extension.get_text()) > 0)
-	
-	def _on_job_cursor_changed(self, tree_view):
-		store, iter = tree_view.get_selection().get_selected()
-		if not iter: 
-			return
-		self._button_remove_job.set_sensitive(True)
-		
-		first_row_selected = (store.get_string_from_iter(iter) == "0")
-		self._button_job_up.set_sensitive(not first_row_selected)
-	
-	def _on_extension_cursor_changed(self, tree_view):
-		store, it = tree_view.get_selection().get_selected()
-		if not it: 
-			return
-		self._button_remove_extension.set_sensitive(True)
-	
-	def _on_abort_clicked(self, button):
-		self._dialog.hide()
-	
-	def _on_okay_clicked(self, button):
-		self._dialog.hide()
-	
-	def _validate_tool(self):
-		"""
-		Validate the dialog contents
-		"""
-		errors = []
-		
-		if len(self._store_job) == 0:
-			errors.append("You have not specified any jobs.")
-		
-		if len(errors):
-			self._buttonApply.set_sensitive(False)
-		else:
-			self._buttonApply.set_sensitive(True)
-		
-		if len(errors) == 1:
-			self._labelProfileValidate.set_markup(errors[0])
-		elif len(errors) > 1:
-			self._labelProfileValidate.set_markup("\n".join([" * %s" % e for e in errors]))
-		else:
-			self._labelProfileValidate.set_markup("Remember to run all commands in batch mode (e.g. append <tt>-interaction batchmode</tt> to <tt>latex</tt>)")
-	
-
-
 class PreferencesDialog(GladeInterface, IPreferencesMonitor):
 	"""
 	This controls the configure dialog
@@ -378,25 +124,6 @@ class PreferencesDialog(GladeInterface, IPreferencesMonitor):
 			self._viewBibs.set_model(self._storeBibs)
 			_insert_column_with_attributes(self._viewBibs, -1, "Filename", Gtk.CellRendererText(), text=0)
 			
-			#
-			# tools
-			#
-			
-			# grab widgets
-
-			self._button_delete_tool = self.find_widget("buttonDeleteTool")
-			self._button_move_up_tool = self.find_widget("buttonMoveUpTool")
-			self._button_configure_tool = self.find_widget("buttonConfigureTool")
-			
-			self._store_tool = Gtk.ListStore(str, str, object)     # label markup, extensions, Tool instance
-				
-			self._view_tool = self.find_widget("treeviewProfiles")
-			self._view_tool.set_model(self._store_tool)
-			_insert_column_with_attributes(self._view_tool, -1, "Label", Gtk.CellRendererText(), markup=0)
-			_insert_column_with_attributes(self._view_tool, -1, "File Extensions", Gtk.CellRendererText(), text=1)
-			
-			# init tool and listen to tool changes
-			self.__load_tools()
 			self._preferences.register_monitor(self)
 			
 			# misc
@@ -427,14 +154,8 @@ class PreferencesDialog(GladeInterface, IPreferencesMonitor):
 			# signals
 			#
 			self.connect_signals({ "on_buttonClose_clicked" : self._on_close_clicked,
-								   "on_treeviewProfiles_cursor_changed" : self._on_tool_cursor_changed,
 								   "on_buttonAddBib_clicked" : self._on_add_bib_clicked,
 								   "on_buttonRemoveBib_clicked" : self._on_delete_bib_clicked,
-								   "on_buttonNewProfile_clicked" : self._on_new_tool_clicked,
-								   "on_buttonMoveUpTool_clicked" : self._on_tool_up_clicked,
-								   "on_buttonMoveDownTool_clicked" : self._on_tool_down_clicked,
-								   "on_buttonConfigureTool_clicked" : self._on_configure_tool_clicked,
-								   "on_buttonDeleteTool_clicked" : self._on_delete_tool_clicked,
 								   "on_checkHideBox_toggled" : self._on_hide_box_toggled,
 								   "on_filechooserTemplates_selection_changed" : self._on_templates_dir_changed,
 								   "on_checkShowToolbar_toggled" : self._on_show_toolbar_toggled })
@@ -456,88 +177,6 @@ class PreferencesDialog(GladeInterface, IPreferencesMonitor):
 		value = togglebutton.get_active()
 		self._preferences.set("HideBoxWarnings", value)
 	
-	def _on_tools_changed(self):
-		# see IPreferencesMonitor._on_tools_changed
-		self.__load_tools()
-	
-	def __load_tools(self):
-		# save cursor
-		store, iter = self._view_tool.get_selection().get_selected()
-		if iter is None:
-			restore_cursor = False
-		else:
-			path = store.get_string_from_iter(iter)
-			restore_cursor = True
-		
-		# reload tools
-		self._store_tool.clear()
-		for tool in self._preferences.tools:
-			self._store_tool.append(["<b>%s</b>" % tool.label, ", ".join(tool.extensions), tool])
-		
-		# restore cursor
-		if restore_cursor:
-			self._view_tool.set_cursor(path)
-	
-	def _on_configure_tool_clicked(self, button):
-		store, it = self._view_tool.get_selection().get_selected()
-		tool = store.get_value(it, 2)
-		
-		dialog = ConfigureToolDialog()
-		
-		if not dialog.run(tool) is None:
-			self._preferences.save_or_update_tool(tool)
-	
-	def _on_delete_tool_clicked(self, button):
-		store, it = self._view_tool.get_selection().get_selected()
-		tool = store.get_value(it, 2)
-		
-		self._preferences.delete_tool(tool)
-	
-	def _on_tool_up_clicked(self, button):
-		"""
-		Move up the selected tool
-		"""
-		store, iter = self._view_tool.get_selection().get_selected()
-		tool_1 = store.get_value(iter, 2)
-		
-		index_previous = int(store.get_string_from_iter(iter)) - 1
-		assert index_previous >= 0
-		
-		iter_previous = store.get_iter_from_string(str(index_previous))
-		tool_2 = store.get_value(iter_previous, 2)
-		
-		self._preferences.swap_tools(tool_1, tool_2)
-	
-		# adjust selection
-		self._view_tool.get_selection().select_path(str(index_previous))
-	
-	def _on_tool_down_clicked(self, button):
-		"""
-		Move down the selected tool
-		"""
-		store, iter = self._view_tool.get_selection().get_selected()
-		tool_1 = store.get_value(iter, 2)
-	
-		index_next = int(store.get_string_from_iter(iter)) + 1
-		assert index_next < len(store)
-		
-		iter_next = store.get_iter_from_string(str(index_next))
-		tool_2 = store.get_value(iter_next, 2)
-		
-		# swap tools in preferences
-		self._preferences.swap_tools(tool_1, tool_2)
-		
-		# adjust selection
-		self._view_tool.get_selection().select_path(str(index_next))
-	
-	def _on_new_tool_clicked(self, button):
-		dialog = ConfigureToolDialog()
-		
-		tool = Tool("New Tool", [], "", [".tex"])
-		
-		if not dialog.run(tool) is None:
-			self._preferences.save_or_update_tool(tool)
-	
 	def _on_delete_bib_clicked(self, button):
 		pass
 
@@ -547,21 +186,3 @@ class PreferencesDialog(GladeInterface, IPreferencesMonitor):
 	def _on_close_clicked(self, button):
 		self._dialog.hide()
 	
-	def _on_tool_cursor_changed(self, treeView):
-		"""
-		The cursor in the tools view has changed
-		"""
-		store, it = treeView.get_selection().get_selected()
-		if not it: 
-			return
-		
-		self._profile = store.get_value(it, 1)
-		
-		self._button_delete_tool.set_sensitive(True)
-		self._button_move_up_tool.set_sensitive(True)
-		self._button_configure_tool.set_sensitive(True)
-		
-			
-	
-	
-	



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]