diff options
Diffstat (limited to 'grc/gui/Param.py')
-rw-r--r-- | grc/gui/Param.py | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/grc/gui/Param.py b/grc/gui/Param.py index c71e1c0aa5..7f90a7bea1 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -23,7 +23,7 @@ import pygtk pygtk.require('2.0') import gtk -from . import Colors, Utils, Constants +from . import Colors, Constants from .Element import Element from . import Utils @@ -34,9 +34,10 @@ 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, parent, changed_callback=None, editing_callback=None): gtk.HBox.__init__(self) self.param = param + self._parent = parent self._changed_callback = changed_callback self._editing_callback = editing_callback self.label = gtk.Label() #no label, markup is added by set_markup @@ -132,17 +133,18 @@ class EntryParam(InputParam): def set_color(self, color): need_status_color = self.label not in self.get_children() text_color = ( - Colors.PARAM_ENTRY_TEXT_COLOR if not need_status_color else + None if not need_status_color else gtk.gdk.color_parse('blue') if self._have_pending_changes else gtk.gdk.color_parse('red') if not self.param.is_valid() else - Colors.PARAM_ENTRY_TEXT_COLOR) + None) base_color = ( Colors.BLOCK_DISABLED_COLOR if need_status_color and not self.param.get_parent().get_enabled() else gtk.gdk.color_parse(color) ) self._input.modify_base(gtk.STATE_NORMAL, base_color) - self._input.modify_text(gtk.STATE_NORMAL, text_color) + if text_color: + self._input.modify_text(gtk.STATE_NORMAL, text_color) def set_tooltip_text(self, text): try: @@ -178,7 +180,6 @@ class MultiLineEntryParam(InputParam): def set_color(self, color): self._view.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) - self._view.modify_text(gtk.STATE_NORMAL, Colors.PARAM_ENTRY_TEXT_COLOR) def set_tooltip_text(self, text): try: @@ -236,14 +237,13 @@ class PythonEditorParam(InputParam): def open_editor(self, widget=None): flowgraph = self.param.get_parent().get_parent() - flowgraph.install_external_editor(self.param) + flowgraph.install_external_editor(self.param, self._parent) def get_text(self): pass # we never update the value from here def set_color(self, color): - # self._button.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) - self._button.modify_text(gtk.STATE_NORMAL, Colors.PARAM_ENTRY_TEXT_COLOR) + pass def _apply_change(self, *args): pass @@ -304,10 +304,8 @@ class EnumEntryParam(InputParam): def set_color(self, color): if self._input.get_active() == -1: #custom entry, use color self._input.get_child().modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) - self._input.get_child().modify_text(gtk.STATE_NORMAL, Colors.PARAM_ENTRY_TEXT_COLOR) else: #from enum, make pale background self._input.get_child().modify_base(gtk.STATE_NORMAL, Colors.ENTRYENUM_CUSTOM_COLOR) - self._input.get_child().modify_text(gtk.STATE_NORMAL, Colors.PARAM_ENTRY_TEXT_COLOR) class FileParam(EntryParam): @@ -339,10 +337,10 @@ class FileParam(EntryParam): #build the dialog if self.param.get_type() == 'file_open': - file_dialog = gtk.FileChooserDialog('Open a Data File...', None, + file_dialog = gtk.FileChooserDialog('Open a Data File...', self._parent, gtk.FILE_CHOOSER_ACTION_OPEN, ('gtk-cancel',gtk.RESPONSE_CANCEL,'gtk-open',gtk.RESPONSE_OK)) elif self.param.get_type() == 'file_save': - file_dialog = gtk.FileChooserDialog('Save a Data File...', None, + file_dialog = gtk.FileChooserDialog('Save a Data File...', self._parent, gtk.FILE_CHOOSER_ACTION_SAVE, ('gtk-cancel',gtk.RESPONSE_CANCEL, 'gtk-save',gtk.RESPONSE_OK)) file_dialog.set_do_overwrite_confirmation(True) file_dialog.set_current_name(basename) #show the current filename @@ -364,9 +362,9 @@ PARAM_MARKUP_TMPL="""\ <span foreground="$foreground" font_desc="$font"><b>$encode($param.get_name()): </b>$encode(repr($param).replace('\\n',' '))</span>""" PARAM_LABEL_MARKUP_TMPL="""\ -#set $foreground = $modified and 'blue' or $param.is_valid() and 'black' or 'red' +#set $foreground = $modified and 'foreground="blue"' or not $param.is_valid() and 'foreground="red"' or '' #set $underline = $has_cb and 'low' or 'none' -<span underline="$underline" foreground="$foreground" font_desc="Sans 9">$encode($param.get_name())</span>""" +<span underline="$underline" $foreground font_desc="Sans 9">$encode($param.get_name())</span>""" TIP_MARKUP_TMPL="""\ ######################################## |