@@ -13,6 +13,11 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
from typing import cast
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
from gajim.gui.settings import SettingsDialog
|
from gajim.gui.settings import SettingsDialog
|
||||||
@@ -26,14 +31,14 @@ from gajim.plugins.plugins_i18n import _
|
|||||||
class AntiSpamConfigDialog(SettingsDialog):
|
class AntiSpamConfigDialog(SettingsDialog):
|
||||||
def __init__(self, plugin, parent):
|
def __init__(self, plugin, parent):
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
msgtxt_limit = self.plugin.config['msgtxt_limit']
|
msgtxt_limit = cast(int, self.plugin.config['msgtxt_limit'])
|
||||||
max_length = '' if msgtxt_limit == 0 else msgtxt_limit
|
max_length = '' if msgtxt_limit == 0 else msgtxt_limit
|
||||||
|
|
||||||
settings = [
|
settings = [
|
||||||
Setting(SettingKind.ENTRY,
|
Setting(SettingKind.ENTRY,
|
||||||
_('Limit Message Length'),
|
_('Limit Message Length'),
|
||||||
SettingType.VALUE,
|
SettingType.VALUE,
|
||||||
max_length,
|
str(max_length),
|
||||||
callback=self._on_length_setting,
|
callback=self._on_length_setting,
|
||||||
data='msgtxt_limit',
|
data='msgtxt_limit',
|
||||||
desc=_('Limits maximum message length (leave empty to '
|
desc=_('Limits maximum message length (leave empty to '
|
||||||
@@ -89,11 +94,11 @@ class AntiSpamConfigDialog(SettingsDialog):
|
|||||||
SettingsDialog.__init__(self, parent, _('Anti Spam Configuration'),
|
SettingsDialog.__init__(self, parent, _('Anti Spam Configuration'),
|
||||||
Gtk.DialogFlags.MODAL, settings, None)
|
Gtk.DialogFlags.MODAL, settings, None)
|
||||||
|
|
||||||
def _on_setting(self, value, data):
|
def _on_setting(self, value: Any, data: Any) -> None:
|
||||||
self.plugin.config[data] = value
|
self.plugin.config[data] = value
|
||||||
|
|
||||||
def _on_length_setting(self, value, data):
|
def _on_length_setting(self, value: str, data: str) -> None:
|
||||||
try:
|
try:
|
||||||
self.plugin.config[data] = int(value)
|
self.plugin.config[data] = int(value)
|
||||||
except Exception:
|
except ValueError:
|
||||||
self.plugin.config[data] = 0
|
self.plugin.config[data] = 0
|
||||||
|
|||||||
@@ -17,5 +17,5 @@
|
|||||||
"gajim>=1.4.0"
|
"gajim>=1.4.0"
|
||||||
],
|
],
|
||||||
"short_name": "anti_spam",
|
"short_name": "anti_spam",
|
||||||
"version": "1.6.4"
|
"version": "1.6.5"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user