summaryrefslogtreecommitdiff
path: root/grc/gui
diff options
context:
space:
mode:
authorAndrej Rode <mail@andrejro.de>2018-06-23 17:44:58 +0200
committerAndrej Rode <mail@andrejro.de>2018-06-23 17:44:58 +0200
commit5e07e65fe9350a51cd45f8f21cfa6bf144e42e1c (patch)
treeb88dde44a0ba1f2ce1b382bbca02e80050f77a17 /grc/gui
parent9f7e39ee5141791f93dbc1c842b1d1a49e33b068 (diff)
parente82e337d0c74fa7ea5e8b8429de29bec43818552 (diff)
Merge branch 'python3_fix' into python3_merge
Diffstat (limited to 'grc/gui')
-rw-r--r--grc/gui/Actions.py1
-rw-r--r--grc/gui/Application.py2
-rw-r--r--grc/gui/ParamWidgets.py31
-rw-r--r--grc/gui/Platform.py4
-rw-r--r--grc/gui/PropsDialog.py7
-rw-r--r--grc/gui/Utils.py4
-rw-r--r--grc/gui/canvas/flowgraph.py4
-rw-r--r--grc/gui/canvas/param.py8
8 files changed, 36 insertions, 25 deletions
diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py
index d214f28049..14b0422764 100644
--- a/grc/gui/Actions.py
+++ b/grc/gui/Actions.py
@@ -302,6 +302,7 @@ ELEMENT_DELETE = actions.register("win.delete",
label='_Delete',
tooltip='Delete the selected blocks',
icon_name='edit-delete',
+ keypresses=["Delete"],
)
BLOCK_MOVE = actions.register("win.block_move")
BLOCK_ROTATE_CCW = actions.register("win.block_rotate_ccw",
diff --git a/grc/gui/Application.py b/grc/gui/Application.py
index ea7ad5cd80..70cf9b78b2 100644
--- a/grc/gui/Application.py
+++ b/grc/gui/Application.py
@@ -663,7 +663,7 @@ class Application(Gtk.Application):
flow_graph_update(new_flow_graph)
page.saved = False
elif action == Actions.FLOW_GRAPH_SCREEN_CAPTURE:
- file_path, background_transparent = FileDialogs.SaveScreenShot(main, page.file_path).run()
+ file_path, background_transparent = SaveScreenShotDialog(main, page.get_file_path()).run()
if file_path is not None:
try:
Utils.make_screenshot(flow_graph, file_path, background_transparent)
diff --git a/grc/gui/ParamWidgets.py b/grc/gui/ParamWidgets.py
index 18d1da736b..747c3ffec5 100644
--- a/grc/gui/ParamWidgets.py
+++ b/grc/gui/ParamWidgets.py
@@ -57,12 +57,13 @@ class InputParam(Gtk.HBox):
"""The base class for an input parameter inside the input parameters dialog."""
expand = False
- def __init__(self, param, changed_callback=None, editing_callback=None):
+ def __init__(self, param, changed_callback=None, editing_callback=None, transient_for=None):
Gtk.HBox.__init__(self)
self.param = param
self._changed_callback = changed_callback
self._editing_callback = editing_callback
+ self._transient_for = transient_for
self.label = Gtk.Label()
self.label.set_size_request(Utils.scale_scalar(150), -1)
@@ -199,7 +200,7 @@ class PythonEditorParam(InputParam):
self.pack_start(button, True, True, True)
def open_editor(self, widget=None):
- self.param.parent_flowgraph.install_external_editor(self.param)
+ self.param.parent_flowgraph.install_external_editor(self.param, parent=self._transient_for)
def get_text(self):
pass # we never update the value from here
@@ -289,7 +290,7 @@ class FileParam(EntryParam):
If the button was clicked, open a file dialog in open/save format.
Replace the text in the entry with the new filename from the file dialog.
"""
- #get the paths
+ # get the paths
file_path = self.param.is_valid() and self.param.get_evaluated() or ''
(dirname, basename) = os.path.isfile(file_path) and os.path.split(file_path) or (file_path, '')
# check for qss theme default directory
@@ -301,22 +302,28 @@ class FileParam(EntryParam):
if not os.path.exists(dirname):
dirname = os.getcwd() # fix bad paths
- #build the dialog
+ # build the dialog
if self.param.dtype == 'file_open':
- file_dialog = Gtk.FileChooserDialog('Open a Data File...', None,
- Gtk.FileChooserAction.OPEN, ('gtk-cancel',Gtk.ResponseType.CANCEL,'gtk-open',Gtk.ResponseType.OK))
+ file_dialog = Gtk.FileChooserDialog(
+ 'Open a Data File...', None, Gtk.FileChooserAction.OPEN,
+ ('gtk-cancel', Gtk.ResponseType.CANCEL, 'gtk-open', Gtk.ResponseType.OK),
+ transient_for=self._transient_for,
+ )
elif self.param.dtype == 'file_save':
- file_dialog = Gtk.FileChooserDialog('Save a Data File...', None,
- Gtk.FileChooserAction.SAVE, ('gtk-cancel',Gtk.ResponseType.CANCEL, 'gtk-save',Gtk.ResponseType.OK))
+ file_dialog = Gtk.FileChooserDialog(
+ 'Save a Data File...', None, Gtk.FileChooserAction.SAVE,
+ ('gtk-cancel', Gtk.ResponseType.CANCEL, 'gtk-save', Gtk.ResponseType.OK),
+ transient_for=self._transient_for,
+ )
file_dialog.set_do_overwrite_confirmation(True)
- file_dialog.set_current_name(basename) #show the current filename
+ file_dialog.set_current_name(basename) # show the current filename
else:
raise ValueError("Can't open file chooser dialog for type " + repr(self.param.dtype))
- file_dialog.set_current_folder(dirname) #current directory
+ file_dialog.set_current_folder(dirname) # current directory
file_dialog.set_select_multiple(False)
file_dialog.set_local_only(True)
- if Gtk.ResponseType.OK == file_dialog.run(): #run the dialog
- file_path = file_dialog.get_filename() #get the file path
+ if Gtk.ResponseType.OK == file_dialog.run(): # run the dialog
+ file_path = file_dialog.get_filename() # get the file path
self._input.set_text(file_path)
self._editing_callback()
self._apply_change()
diff --git a/grc/gui/Platform.py b/grc/gui/Platform.py
index 2a38bc619e..8eb79f3459 100644
--- a/grc/gui/Platform.py
+++ b/grc/gui/Platform.py
@@ -63,8 +63,8 @@ class Platform(CorePlatform):
FlowGraph = canvas.FlowGraph
Connection = canvas.Connection
- def new_block_class(self, block_id, **data):
- cls = CorePlatform.new_block_class(self, block_id, **data)
+ def new_block_class(self, **data):
+ cls = CorePlatform.new_block_class(self, **data)
return canvas.Block.make_cls_with_base(cls)
block_classes_build_in = {key: canvas.Block.make_cls_with_base(cls)
diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py
index 9ce9bf2701..ac4506a3d8 100644
--- a/grc/gui/PropsDialog.py
+++ b/grc/gui/PropsDialog.py
@@ -185,12 +185,13 @@ class PropsDialog(Gtk.Dialog):
continue
box_all_valid = box_all_valid and param.is_valid()
- input_widget = param.get_input(self._handle_changed, self._activate_apply)
+ input_widget = param.get_input(self._handle_changed, self._activate_apply,
+ transient_for=self.get_transient_for())
input_widget.show_all()
vbox.pack_start(input_widget, input_widget.expand, True, 1)
- label.set_markup('<span foreground="{color}">{name}</span>'.format(
- color='black' if box_all_valid else 'red', name=Utils.encode(category)
+ label.set_markup('<span {color}>{name}</span>'.format(
+ color='foreground="red"' if not box_all_valid else '', name=Utils.encode(category)
))
vbox.show() # show params box with new params
diff --git a/grc/gui/Utils.py b/grc/gui/Utils.py
index f47c2e6b97..1b32e91439 100644
--- a/grc/gui/Utils.py
+++ b/grc/gui/Utils.py
@@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from __future__ import absolute_import
+import numbers
+
from gi.repository import GLib
import cairo
import six
@@ -91,7 +93,7 @@ def num_to_str(num):
return template.format(value / factor, symbol.strip())
return template.format(value, '')
- if isinstance(num, Constants.COMPLEX_TYPES):
+ if isinstance(num, numbers.Complex):
num = complex(num) # Cast to python complex
if num == 0:
return '0'
diff --git a/grc/gui/canvas/flowgraph.py b/grc/gui/canvas/flowgraph.py
index 79af5d5931..3e0fd83dad 100644
--- a/grc/gui/canvas/flowgraph.py
+++ b/grc/gui/canvas/flowgraph.py
@@ -88,7 +88,7 @@ class FlowGraph(CoreFlowgraph, Drawable):
break
return block_id
- def install_external_editor(self, param):
+ def install_external_editor(self, param, parent=None):
target = (param.parent_block.name, param.key)
if target in self._external_updaters:
@@ -96,7 +96,7 @@ class FlowGraph(CoreFlowgraph, Drawable):
else:
config = self.parent_platform.config
editor = (find_executable(config.editor) or
- Dialogs.choose_editor(None, config)) # todo: pass in parent
+ Dialogs.choose_editor(parent, config)) # todo: pass in parent
if not editor:
return
updater = functools.partial(
diff --git a/grc/gui/canvas/param.py b/grc/gui/canvas/param.py
index e2c335d9cf..5777423c68 100644
--- a/grc/gui/canvas/param.py
+++ b/grc/gui/canvas/param.py
@@ -17,11 +17,11 @@
from __future__ import absolute_import
-from .drawable import Drawable
+import numbers
+from .drawable import Drawable
from .. import ParamWidgets, Utils, Constants
-
-from ...core.Param import Param as CoreParam
+from ...core.params import Param as CoreParam
class Param(CoreParam):
@@ -128,7 +128,7 @@ class Param(CoreParam):
t = self.dtype
if isinstance(e, bool):
return str(e)
- elif isinstance(e, Constants.COMPLEX_TYPES):
+ elif isinstance(e, numbers.Complex):
dt_str = Utils.num_to_str(e)
elif isinstance(e, Constants.VECTOR_TYPES):
# Vector types