diff --git a/frontends/src/primitivus/xmlui.py b/frontends/src/primitivus/xmlui.py index 9febdaa8..86095e77 100644 --- a/frontends/src/primitivus/xmlui.py +++ b/frontends/src/primitivus/xmlui.py @@ -102,13 +102,13 @@ class PrimitivusTextBoxWidget(xmlui.TextBoxWidget, sat_widgets.AdvancedEdit, Pri sat_widgets.AdvancedEdit.__init__(self, edit_text=value, multiline=True) def _xmluiGetValue(self): - return self.getValue() + return self.get_edit_text() class PrimitivusBoolWidget(xmlui.BoolWidget, urwid.CheckBox, PrimitivusEvents): def __init__(self, parent, state): - urwid.CheckBox.__init__(self, '', state = state) + urwid.CheckBox.__init__(self, '', state=state) def _xmluiGetValue(self): return "true" if self.get_state() else "false" @@ -122,12 +122,16 @@ class PrimitivusButtonWidget(xmlui.ButtonWidget, sat_widgets.CustomButton, Primi class PrimitivusListWidget(xmlui.ListWidget, sat_widgets.List, PrimitivusEvents): - def __init__(self, parent, options, flags): + def __init__(self, parent, options, selected, flags): sat_widgets.List.__init__(self, options=options, style=flags) + self._xmluiSelectValues(selected) def _xmluiSelectValue(self, value): return self.selectValue(value) + def _xmluiSelectValues(self, values): + return self.selectValues(values) + def _xmluiGetSelectedValues(self): return [option.value for option in self.getSelectedValues()] diff --git a/frontends/src/tools/xmlui.py b/frontends/src/tools/xmlui.py index 16fe9df2..70be874f 100644 --- a/frontends/src/tools/xmlui.py +++ b/frontends/src/tools/xmlui.py @@ -301,16 +301,16 @@ class XMLUI(object): elif type_=="bool": ctrl = self.widget_factory.createBoolWidget(parent, value=='true') self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) - elif type_=="list": - style=[] if node.getAttribute("multi")=='yes' else ['single'] + elif type_ == "list": + style = [] if node.getAttribute("multi") == 'yes' else ['single'] _options = [(option.getAttribute("value"), option.getAttribute("label")) for option in node.getElementsByTagName("option")] - ctrl = self.widget_factory.createListWidget(parent, _options, style) - ctrl._xmluiSelectValue(node.getAttribute("value")) - self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) + _selected = [option.getAttribute("value") for option in node.getElementsByTagName("option") if option.getAttribute('selected') == 'true'] + ctrl = self.widget_factory.createListWidget(parent, _options, _selected, style) + self.ctrl_list[name] = ({'type': type_, 'control': ctrl}) elif type_=="button": callback_id = node.getAttribute("callback") ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress) - ctrl._xmlui_param_id = (callback_id,[field.getAttribute('name') for field in node.getElementsByTagName("field_back")]) + ctrl._xmlui_param_id = (callback_id, [field.getAttribute('name') for field in node.getElementsByTagName("field_back")]) else: print(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_) raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_) @@ -408,7 +408,7 @@ class XMLUI(object): escaped = self.escape(field) ctrl = self.ctrl_list[field] if isinstance(ctrl['control'], ListWidget): - data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelected()) + data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelectedValues()) else: data[escaped] = ctrl['control']._xmluiGetValue() self._xmluiLaunchAction(callback_id, data) diff --git a/frontends/src/wix/xmlui.py b/frontends/src/wix/xmlui.py index d035661c..5590b6f4 100644 --- a/frontends/src/wix/xmlui.py +++ b/frontends/src/wix/xmlui.py @@ -122,14 +122,16 @@ class ButtonWidget(EventWidget, WixWidget, xmlui.ButtonWidget, wx.Button): self._xmlui_click_callback(event.GetEventObject()) event.Skip() + class ListWidget(EventWidget, WixWidget, xmlui.ListWidget, wx.ListBox): _xmlui_change_event = wx.EVT_LISTBOX - def __init__(self, parent, options, flags): + def __init__(self, parent, options, selected, flags): styles = wx.LB_MULTIPLE if not 'single' in flags else wx.LB_SINGLE wx.ListBox.__init__(self, parent, -1, choices=[option[1] for option in options], style=styles) self._xmlui_attr_map = {label: value for value, label in options} self._xmlui_proportion = 1 + self._xmluiSelectValues(selected) def _xmluiSelectValue(self, value): try: @@ -140,6 +142,10 @@ class ListWidget(EventWidget, WixWidget, xmlui.ListWidget, wx.ListBox): for idx in xrange(self.GetCount()): self.SetSelection(idx, self.GetString(idx) == label) + def _xmluiSelectValues(self, values): + for value in values: + self._xmluiSelectValue(value) + def _xmluiGetSelectedValues(self): ret = [] labels = [self.GetString(idx) for idx in self.GetSelections()] diff --git a/src/memory/params.py b/src/memory/params.py index 743883e2..e0ce122e 100644 --- a/src/memory/params.py +++ b/src/memory/params.py @@ -21,7 +21,7 @@ from sat.core.i18n import _ from sat.core import exceptions from sat.core.constants import Const as C -from xml.dom import minidom +from xml.dom import minidom, NotFoundErr from logging import debug, info, warning, error from twisted.internet import defer from twisted.python.failure import Failure @@ -494,7 +494,17 @@ class Params(object): cache=profile_cache, profile=profile) if profile_value is not None: # there is a value for this profile, we must change the default - dest_params[name].setAttribute('value', profile_value) + if dest_params[name].getAttribute('type') == 'list': + for option in dest_params[name].getElementsByTagName("option"): + if option.getAttribute('value') == profile_value: + option.setAttribute('selected', 'true') + else: + try: + option.removeAttribute('selected') + except NotFoundErr: + pass + else: + dest_params[name].setAttribute('value', profile_value) if new_node: prof_xml.documentElement.appendChild(dest_cat) diff --git a/src/plugins/deprecated_misc_cs.py b/src/plugins/deprecated_misc_cs.py index b4d79405..0baff699 100755 --- a/src/plugins/deprecated_misc_cs.py +++ b/src/plugins/deprecated_misc_cs.py @@ -163,7 +163,7 @@ class CS_Plugin(object): interface.addText(_("G'day %(name)s, you have %(nb_message)i unread message%(plural_mess)s and %(unread_CR_mess)s unread couch request message%(plural_CR)s\nIf you want to send a message, select the recipient(s) in the list below") % {'name': user_name, 'nb_message': unread_mess, 'plural_mess': 's' if unread_mess > 1 else '', 'unread_CR_mess': unread_CR_mess, 'plural_CR': 's' if unread_CR_mess > 1 else ''}) if unread_mess: interface.addButton('plugin_CS_showUnreadMessages', 'showUnreadMessages', _('Show unread message%(plural)s in external web browser') % {'plural': 's' if unread_mess > 1 else ''}) - interface.addList(friends_list, 'friends', style=['multi']) + interface.addList(friends_list, 'friends', None, style=['multi']) interface.changeLayout('pairs') interface.addLabel(_("Subject")) interface.addString('subject') diff --git a/src/plugins/plugin_misc_text_syntaxes.py b/src/plugins/plugin_misc_text_syntaxes.py index f6ff1e0b..12f21e2d 100755 --- a/src/plugins/plugin_misc_text_syntaxes.py +++ b/src/plugins/plugin_misc_text_syntaxes.py @@ -77,8 +77,7 @@ class TextSyntaxes(object): - + %(options)s @@ -91,7 +90,6 @@ class TextSyntaxes(object): 'category_label': _(CATEGORY), 'name': NAME, 'label': _(NAME), - 'default': _SYNTAX_XHTML, 'syntaxes': {}, } @@ -128,7 +126,8 @@ class TextSyntaxes(object): options = [] for syntax in syntaxes: - options.append(u'