Commit 72680dbf authored by Paolo Borelli's avatar Paolo Borelli

tools plugin updates.

parent 8c21a9b6
2006-02-08 Paolo Borelli <pborelli@katamail.com>
* plugins/externaltools/tools/manager.py: properly clear the fields
and handle sensitivity when adding and removing tools.
2006-02-04 Paolo Borelli <pborelli@katamail.com> 2006-02-04 Paolo Borelli <pborelli@katamail.com>
* gedit/gedit-commands-search.c: fix cut&paste error. * gedit/gedit-commands-search.c: fix cut&paste error.
......
...@@ -100,7 +100,7 @@ class Manager: ...@@ -100,7 +100,7 @@ class Manager:
for item in self.tools: for item in self.tools:
self.model.append([item.get('label'), item]) self.model.append([item.get('label'), item])
self.model.connect('row-changed', self.on_tools_model_row_changed) self.row_changed_id = self.model.connect('row-changed', self.on_tools_model_row_changed)
def __init_tools_view(self): def __init_tools_view(self):
# Tools column # Tools column
...@@ -112,7 +112,7 @@ class Manager: ...@@ -112,7 +112,7 @@ class Manager:
self.view.append_column(column) self.view.append_column(column)
renderer.connect('edited', self.on_view_label_cell_edited) renderer.connect('edited', self.on_view_label_cell_edited)
self.view.get_selection().connect('changed', self.on_view_selection_changed, None) self.selection_changed_id = self.view.get_selection().connect('changed', self.on_view_selection_changed, None)
def __init_combobox(self, name): def __init_combobox(self, name):
combo = self[name] combo = self[name]
...@@ -163,7 +163,17 @@ class Manager: ...@@ -163,7 +163,17 @@ class Manager:
combo.get_model().get_value( combo.get_model().get_value(
combo.get_active_iter(), combo.get_active_iter(),
self.NAME_COLUMN)) self.NAME_COLUMN))
def clear_fields(self):
self['description'].set_text('')
self['accelerator'].set_text('')
self['commands'].get_buffer().set_text('')
self.set_active_by_name('input', Manager.combobox_items['input'][0][0])
self.set_active_by_name('output', Manager.combobox_items['output'][0][0])
self.set_active_by_name('applicability', Manager.combobox_items['applicability'][0][0])
self['title'].set_label(_('Edit tool <i>%s</i>:') % '') # a bit ugly, but we're string frozen
def fill_fields(self): def fill_fields(self):
node = self.current_node node = self.current_node
self['description'].set_text(default(node.get('description'), _('A Brand New Tool'))) self['description'].set_text(default(node.get('description'), _('A Brand New Tool')))
...@@ -181,25 +191,37 @@ class Manager: ...@@ -181,25 +191,37 @@ class Manager:
Manager.combobox_items['applicability'][0][0])) Manager.combobox_items['applicability'][0][0]))
self['title'].set_label(_('Edit tool <i>%s</i>:') % node.get('label')) self['title'].set_label(_('Edit tool <i>%s</i>:') % node.get('label'))
def on_new_tool_button_clicked(self, button): def on_new_tool_button_clicked(self, button):
self.save_current_tool() self.save_current_tool()
# block handlers while inserting a new item
self.model.handler_block(self.row_changed_id)
self.view.get_selection().handler_block(self.selection_changed_id)
self.current_node = et.Element('tool'); self.current_node = et.Element('tool');
self.current_node.set('label', _('New tool')) self.current_node.set('label', _('New tool'))
self.tools.root.append(self.current_node) self.tools.root.append(self.current_node)
piter = self.model.append([self.current_node.get('label'), piter = self.model.append([self.current_node.get('label'),
self.current_node]) self.current_node])
self.view.set_cursor(self.model.get_path(piter), self.view.set_cursor(self.model.get_path(piter),
self.view.get_column(self.LABEL_COLUMN), self.view.get_column(self.LABEL_COLUMN),
True) True)
self.fill_fields() self.fill_fields()
self['tool-table'].set_sensitive(True)
self.view.get_selection().handler_unblock(self.selection_changed_id)
self.model.handler_unblock(self.row_changed_id)
def on_remove_tool_button_clicked(self, button): def on_remove_tool_button_clicked(self, button):
piter, node = self.get_selected_tool() piter, node = self.get_selected_tool()
self.tools.root.remove(node) self.tools.root.remove(node)
self.current_node = None self.current_node = None
self.model.remove(piter) if self.model.remove(piter):
self.view.set_cursor(self.model.get_path(piter),
self.view.get_column(self.LABEL_COLUMN),
False)
self.view.grab_focus()
def on_view_label_cell_edited(self, cell, path, new_text): def on_view_label_cell_edited(self, cell, path, new_text):
if new_text != '': if new_text != '':
piter = self.model.get_iter(path) piter = self.model.get_iter(path)
...@@ -213,13 +235,14 @@ class Manager: ...@@ -213,13 +235,14 @@ class Manager:
piter, node = self.get_selected_tool() piter, node = self.get_selected_tool()
self['remove-tool-button'].set_sensitive(piter is not None) self['remove-tool-button'].set_sensitive(piter is not None)
if node is not None: if node is not None:
self.current_node = node self.current_node = node
self.fill_fields() self.fill_fields()
self['tool-table'].set_sensitive(True)
else: else:
# :TODO: Config panel should be grayed self.clear_fields()
pass self['tool-table'].set_sensitive(False)
def on_tools_model_row_changed(self, model, path, piter): def on_tools_model_row_changed(self, model, path, piter):
tool = model.get_value(piter, self.NODE_COLUMN) tool = model.get_value(piter, self.NODE_COLUMN)
......
...@@ -343,7 +343,7 @@ ...@@ -343,7 +343,7 @@
</child> </child>
<child> <child>
<widget class="GtkTable" id="table2"> <widget class="GtkTable" id="tool-table">
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_rows">7</property> <property name="n_rows">7</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment