summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
Diffstat (limited to 'grc')
-rw-r--r--grc/gui/ActionHandler.py2
-rw-r--r--grc/gui/Actions.py2
-rw-r--r--grc/gui/VariableEditor.py77
3 files changed, 53 insertions, 28 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index d0410e0e0a..13316af051 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -454,7 +454,7 @@ class ActionHandler:
main.update_panel_visibility(main.VARIABLES, True)
else:
main.update_panel_visibility(main.VARIABLES, False)
- Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR_SIDEBAR.set_sensitive(action.get_active())
+ #Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR_SIDEBAR.set_sensitive(action.get_active())
action.save_to_preferences()
elif action == Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR_SIDEBAR:
if self.init:
diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py
index d96e80cee3..1763ff6953 100644
--- a/grc/gui/Actions.py
+++ b/grc/gui/Actions.py
@@ -345,7 +345,7 @@ TOGGLE_FLOW_GRAPH_VAR_EDITOR = ToggleAction(
preference_name='variable_editor_visable',
)
TOGGLE_FLOW_GRAPH_VAR_EDITOR_SIDEBAR = ToggleAction(
- label='Move Variable Editor to the Sidebar',
+ label='Move the Variable Editor to the Sidebar',
tooltip='Move the variable editor to the sidebar',
default=False,
preference_name='variable_editor_sidebar',
diff --git a/grc/gui/VariableEditor.py b/grc/gui/VariableEditor.py
index 6d37a0f56c..7721f3bda6 100644
--- a/grc/gui/VariableEditor.py
+++ b/grc/gui/VariableEditor.py
@@ -17,7 +17,6 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-from itertools import chain
from operator import attrgetter
import pygtk
@@ -39,29 +38,29 @@ class VariableEditorContextMenu(gtk.Menu):
gtk.Menu.__init__(self)
self.imports = gtk.MenuItem("Add _Import")
- self.imports.connect('activate', var_edit._handle_action, var_edit.ADD_IMPORT)
+ self.imports.connect('activate', var_edit.handle_action, var_edit.ADD_IMPORT)
self.add(self.imports)
self.variables = gtk.MenuItem("Add _Variable")
- self.variables.connect('activate', var_edit._handle_action, var_edit.ADD_VARIABLE)
+ self.variables.connect('activate', var_edit.handle_action, var_edit.ADD_VARIABLE)
self.add(self.variables)
self.add(gtk.SeparatorMenuItem())
self.enable = gtk.MenuItem("_Enable")
- self.enable.connect('activate', var_edit._handle_action, var_edit.ENABLE_BLOCK)
+ self.enable.connect('activate', var_edit.handle_action, var_edit.ENABLE_BLOCK)
self.disable = gtk.MenuItem("_Disable")
- self.disable.connect('activate', var_edit._handle_action, var_edit.DISABLE_BLOCK)
+ self.disable.connect('activate', var_edit.handle_action, var_edit.DISABLE_BLOCK)
self.add(self.enable)
self.add(self.disable)
self.add(gtk.SeparatorMenuItem())
self.delete = gtk.MenuItem("_Delete")
- self.delete.connect('activate', var_edit._handle_action, var_edit.DELETE_BLOCK)
+ self.delete.connect('activate', var_edit.handle_action, var_edit.DELETE_BLOCK)
self.add(self.delete)
self.add(gtk.SeparatorMenuItem())
self.properties = gtk.MenuItem("_Properties...")
- self.properties.connect('activate', var_edit._handle_action, var_edit.OPEN_PROPERTIES)
+ self.properties.connect('activate', var_edit.handle_action, var_edit.OPEN_PROPERTIES)
self.add(self.properties)
self.show_all()
@@ -88,17 +87,22 @@ class VariableEditor(gtk.VBox):
self.platform = platform
self.get_flow_graph = get_flow_graph
self._block = None
+ self._mouse_button_pressed = False
# Only use the model to store the block reference and name.
# Generate everything else dynamically
self.treestore = gtk.TreeStore(gobject.TYPE_PYOBJECT, # Block reference
gobject.TYPE_STRING) # Category and block name
self.treeview = gtk.TreeView(self.treestore)
- self.treeview.set_enable_search(True)
- self.treeview.set_search_column(ID_INDEX)
+ self.treeview.set_enable_search(False)
+ self.treeview.set_search_column(-1)
+ #self.treeview.set_enable_search(True)
+ #self.treeview.set_search_column(ID_INDEX)
self.treeview.get_selection().set_mode('single')
self.treeview.set_headers_visible(True)
self.treeview.connect('button-press-event', self._handle_mouse_button_press)
+ self.treeview.connect('button-release-event', self._handle_mouse_button_release)
+ self.treeview.connect('motion-notify-event', self._handle_motion_notify)
self.treeview.connect('key-press-event', self._handle_key_button_press)
# Block Name or Category
@@ -112,8 +116,11 @@ class VariableEditor(gtk.VBox):
id_column.set_fixed_width(100)
id_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
id_column.set_cell_data_func(self.id_cell, self.set_properties)
+ self.id_column = id_column
self.treeview.append_column(id_column)
self.treestore.set_sort_column_id(ID_INDEX, gtk.SORT_ASCENDING)
+ # For forcing resize
+ self._col_width = 0
# Block Value
self.value_cell = gtk.CellRendererText()
@@ -125,6 +132,7 @@ class VariableEditor(gtk.VBox):
value_column.set_min_width(100)
value_column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
value_column.set_cell_data_func(self.value_cell, self.set_value)
+ self.value_column = value_column
self.treeview.append_column(value_column)
# Block Actions (Add, Remove)
@@ -162,19 +170,18 @@ class VariableEditor(gtk.VBox):
# Set defaults
value = None
- evaluated = None
self.set_tooltip_text(None)
# Block specific values
if block:
if block.get_key() == 'import':
value = block.get_param('import').get_value()
+ elif block.get_key() != "variable":
+ value = "<Open Properties>"
+ sp('editable', False)
+ sp('foreground', '#0D47A1')
else:
- if block.get_key() != "variable":
- value = "<Open Properties>"
- sp('editable', False)
- else:
- value = block.get_param('value').get_value()
+ value = block.get_param('value').get_value()
# Check if there are errors in the blocks.
# Show the block error as a tooltip
@@ -245,10 +252,10 @@ class VariableEditor(gtk.VBox):
block.get_param('value').set_value(new_text)
Actions.VARIABLE_EDITOR_UPDATE()
- def _handle_action(self, item, key, event=None):
+ def handle_action(self, item, key, event=None):
"""
Single handler for the different actions that can be triggered by the context menu,
- key presses or mouse clicks. Also triggers an update of the flowgraph and editor.
+ key presses or mouse clicks. Also triggers an update of the flow graph and editor.
"""
if key == self.ADD_IMPORT:
self.get_flow_graph().add_new_block('import')
@@ -264,12 +271,12 @@ class VariableEditor(gtk.VBox):
confirmation_menu = gtk.Menu()
block_id = self._block.get_param('id').get_value().replace("_", "__")
confirm = gtk.MenuItem("Delete {}".format(block_id))
- confirm.connect('activate', self._handle_action, self.DELETE_BLOCK)
+ confirm.connect('activate', self.handle_action, self.DELETE_BLOCK)
confirmation_menu.add(confirm)
confirmation_menu.show_all()
confirmation_menu.popup(None, None, None, event.button, event.time)
else:
- self._handle_action(None, self.DELETE_BLOCK, None)
+ self.handle_action(None, self.DELETE_BLOCK, None)
elif key == self.ENABLE_BLOCK:
self._block.set_enabled(True)
elif key == self.DISABLE_BLOCK:
@@ -279,9 +286,13 @@ class VariableEditor(gtk.VBox):
def _handle_mouse_button_press(self, widget, event):
"""
Handles mouse button for several different events:
- - Doublc Click to open properties for advanced blocks
+ - Double Click to open properties for advanced blocks
- Click to add/remove blocks
"""
+ # Save the column width to see if it changes on button_release
+ self._mouse_button_pressed = True
+ self._col_width = self.id_column.get_width()
+
path = widget.get_path_at_pos(int(event.x), int(event.y))
if path:
# If there is a valid path, then get the row, column and block selected.
@@ -294,7 +305,7 @@ class VariableEditor(gtk.VBox):
if self._block and event.type == gtk.gdk._2BUTTON_PRESS:
# Open the advanced dialog if it is a gui variable
if self._block.get_key() not in ("variable", "import"):
- self._handle_action(None, self.OPEN_PROPERTIES, event=event)
+ self.handle_action(None, self.OPEN_PROPERTIES, event=event)
return True
if event.type == gtk.gdk.BUTTON_PRESS:
# User is adding/removing blocks
@@ -302,12 +313,12 @@ class VariableEditor(gtk.VBox):
if path[2] > col.cell_get_position(self.action_cell)[0]:
if row[1] == "Imports":
# Add a new import block.
- self._handle_action(None, self.ADD_IMPORT, event=event)
+ self.handle_action(None, self.ADD_IMPORT, event=event)
elif row[1] == "Variables":
# Add a new variable block
- self._handle_action(None, self.ADD_VARIABLE, event=event)
+ self.handle_action(None, self.ADD_VARIABLE, event=event)
else:
- self._handle_action(None, self.DELETE_CONFIRM, event=event)
+ self.handle_action(None, self.DELETE_CONFIRM, event=event)
return True
elif event.button == 3 and event.type == gtk.gdk.BUTTON_PRESS:
if self._block:
@@ -315,15 +326,29 @@ class VariableEditor(gtk.VBox):
else:
self._context_menu.update_sensitive(False)
self._context_menu.popup(None, None, None, event.button, event.time)
+
+ # Null handler. Stops the treeview from handling double click events.
+ if event.type == gtk.gdk._2BUTTON_PRESS:
+ return True
+ return False
+
+ def _handle_mouse_button_release(self, widget, event):
+ self._mouse_button_pressed = False
+ return False
+
+ def _handle_motion_notify(self, widget, event):
+ # Check to see if the column size has changed
+ if self._mouse_button_pressed and self.id_column.get_width() != self._col_width:
+ self.value_column.queue_resize()
return False
def _handle_key_button_press(self, widget, event):
model, path = self.treeview.get_selection().get_selected_rows()
if path and self._block:
if self._block.get_enabled() and event.string == "d":
- self._handle_action(None, self.DISABLE_BLOCK, None)
+ self.handle_action(None, self.DISABLE_BLOCK, None)
return True
elif not self._block.get_enabled() and event.string == "e":
- self._handle_action(None, self.ENABLE_BLOCK, None)
+ self.handle_action(None, self.ENABLE_BLOCK, None)
return True
return False