[gedit] Bug 698592 - Add an "Always available" applicability to external tools
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Bug 698592 - Add an "Always available" applicability to external tools
- Date: Sat, 29 Jun 2013 19:43:26 +0000 (UTC)
commit b900092052d47ac2190b099c4877660963a87e9d
Author: Garrett Regier <garrettregier gmail com>
Date: Sat Jun 29 12:35:16 2013 -0700
Bug 698592 - Add an "Always available" applicability to external tools
This also fixes the tools menu so it does not display tools which are
inapplicabile when all documents are closed.
plugins/externaltools/tools/manager.py | 13 +++++++++++++
plugins/externaltools/tools/tools.ui | 5 +++++
plugins/externaltools/tools/windowactivatable.py | 16 +++++++++-------
3 files changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/plugins/externaltools/tools/manager.py b/plugins/externaltools/tools/manager.py
index dafbd25..a654172 100644
--- a/plugins/externaltools/tools/manager.py
+++ b/plugins/externaltools/tools/manager.py
@@ -308,6 +308,7 @@ class Manager(GObject.Object):
'on_accelerator_focus_in' : self.on_accelerator_focus_in,
'on_accelerator_focus_out' : self.on_accelerator_focus_out,
'on_accelerator_backspace' : self.on_accelerator_backspace,
+ 'on_applicability_changed' : self.on_applicability_changed,
'on_languages_button_clicked' : self.on_languages_button_clicked
}
@@ -892,6 +893,18 @@ class Manager(GObject.Object):
alloc = dialog.get_allocation()
self._size = (alloc.width, alloc.height)
+ def on_applicability_changed(self, combo):
+ applicability = combo.get_model().get_value(combo.get_active_iter(),
+ self.NAME_COLUMN)
+
+ if applicability == 'always':
+ if self.current_node is not None:
+ self.current_node.languages = []
+
+ self.fill_languages_button()
+
+ self['languages_button'].set_sensitive(applicability != 'always')
+
def get_cell_data_cb(self, column, cell, model, piter, user_data=None):
tool = model.get_value(piter, self.TOOL_COLUMN)
diff --git a/plugins/externaltools/tools/tools.ui b/plugins/externaltools/tools/tools.ui
index fd1ab56..8f6d57b 100644
--- a/plugins/externaltools/tools/tools.ui
+++ b/plugins/externaltools/tools/tools.ui
@@ -13,6 +13,10 @@
</columns>
<data>
<row>
+ <col id="0" translatable="yes">Always available</col>
+ <col id="1">always</col>
+ </row>
+ <row>
<col id="0" translatable="yes">All documents</col>
<col id="1">all</col>
</row>
@@ -407,6 +411,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">model_applicability</property>
+ <signal name="changed" handler="on_applicability_changed" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="applicability_renderer"/>
<attributes>
diff --git a/plugins/externaltools/tools/windowactivatable.py
b/plugins/externaltools/tools/windowactivatable.py
index 368cfd7..7795008 100644
--- a/plugins/externaltools/tools/windowactivatable.py
+++ b/plugins/externaltools/tools/windowactivatable.py
@@ -128,20 +128,22 @@ class ToolMenu(object):
def filter(self, document):
if document is None:
- return
-
- titled = document.get_location() is not None
- remote = not document.is_local()
+ titled = False
+ remote = False
+ language = None
+ else:
+ titled = document.get_location() is not None
+ remote = not document.is_local()
+ language = document.get_language()
states = {
- 'all' : True,
+ 'always': True,
+ 'all' : document is not None,
'local': titled and not remote,
'remote': titled and remote,
'titled': titled,
'untitled': not titled,
}
-
- language = document.get_language()
for action in self._action_group.list_actions():
if action._tool_item is not None:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]