Philipp Hörist pushed to branch master at gajim / gajim
Commits:
c08a2946 by Philipp Hörist at 2022-12-14T23:32:23+01:00
refactor: Move Singleton into util.classes
- - - - -
5651884d by Philipp Hörist at 2022-12-14T23:36:31+01:00
refactor: Move text_helpers into util module
- - - - -
14 changed files:
- gajim/common/helpers.py
- gajim/common/styling.py
- + gajim/common/util/__init__.py
- + gajim/common/util/classes.py
- gajim/common/text_helpers.py → gajim/common/util/text.py
- gajim/gtk/avatar.py
- gajim/gtk/chat_stack.py
- gajim/gtk/menus.py
- gajim/gtk/preview_audio.py
- gajim/gtk/vcard_grid.py
- gajim/plugins/pluginmanager.py
- pyproject.toml
- test/no_gui/test_styling.py
- test/no_gui/test_text_helpers.py → test/no_gui/test_text_util.py
Changes:
=====================================
gajim/common/helpers.py
=====================================
@@ -823,17 +823,6 @@ def copy(self) -> AdditionalDataDict:
return copy.deepcopy(self)
-class Singleton(type):
-
- _instances: dict[Any, Any] = {}
-
- def __call__(cls, *args: Any, **kwargs: Any):
- if cls not in cls._instances:
- cls._instances[cls] = super().__call__(
- *args, **kwargs)
- return cls._instances[cls]
-
-
def delay_execution(milliseconds):
# Delay the first call for `milliseconds`
# ignore all other calls while the delay is active
=====================================
gajim/common/styling.py
=====================================
@@ -30,7 +30,7 @@
from gajim.common.const import URIType
from gajim.common.helpers import parse_uri as analyze_uri
from gajim.common.helpers import validate_jid
-from gajim.common.text_helpers import escape_iri_query
+from gajim.common.util.text import escape_iri_query
PRE = '`'
STRONG = '*'
=====================================
gajim/common/util/__init__.py
=====================================
=====================================
gajim/common/util/classes.py
=====================================
@@ -0,0 +1,29 @@
+# This file is part of Gajim.
+#
+# Gajim is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published
+# by the Free Software Foundation; version 3 only.
+#
+# Gajim is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
+
+
+from __future__ import annotations
+
+from typing import Any
+
+
+class Singleton(type):
+
+ _instances: dict[Any, Any] = {}
+
+ def __call__(cls, *args: Any, **kwargs: Any):
+ if cls not in cls._instances:
+ cls._instances[cls] = super().__call__(
+ *args, **kwargs)
+ return cls._instances[cls]
=====================================
gajim/common/text_helpers.py → gajim/common/util/text.py
=====================================
=====================================
gajim/gtk/avatar.py
=====================================
@@ -34,10 +34,10 @@
from gajim.common import types
from gajim.common import app
from gajim.common import configpaths
-from gajim.common.helpers import Singleton
from gajim.common.helpers import get_groupchat_name
from gajim.common.const import AvatarSize
from gajim.common.const import StyleAttr
+from gajim.common.util.classes import Singleton
from .const import DEFAULT_WORKSPACE_COLOR
from .util import get_contact_color
=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -44,7 +44,7 @@
from gajim.common.preview_helpers import split_geo_uri
from gajim.common.preview_helpers import format_geo_coords
from gajim.common.structs import OutgoingMessage
-from gajim.common.text_helpers import remove_invalid_xml_chars
+from gajim.common.util.text import remove_invalid_xml_chars
from gajim.common.types import ChatContactT
from .chat_banner import ChatBanner
=====================================
gajim/gtk/menus.py
=====================================
@@ -45,7 +45,7 @@
from gajim.common.const import XmppUriQuery
from gajim.common.preview import Preview
from gajim.common.structs import URI
-from gajim.common.text_helpers import escape_iri_path_segment
+from gajim.common.util.text import escape_iri_path_segment
from gajim.common.modules.contacts import GroupchatContact
from gajim.common.modules.contacts import can_add_to_roster
=====================================
gajim/gtk/preview_audio.py
=====================================
@@ -30,7 +30,7 @@
from gajim.common import app
from gajim.common.i18n import _
-from gajim.common.text_helpers import format_duration
+from gajim.common.util.text import format_duration
from gajim.common.preview import AudioSampleT
from .builder import get_builder
=====================================
gajim/gtk/vcard_grid.py
=====================================
@@ -30,7 +30,7 @@
from gajim.common.helpers import open_uri
from gajim.common.helpers import parse_uri
from gajim.common.structs import URI
-from gajim.common.text_helpers import escape_iri_path_segment
+from gajim.common.util.text import escape_iri_path_segment
from gajim.gui.util import gtk_month
from gajim.gui.util import python_month
=====================================
gajim/plugins/pluginmanager.py
=====================================
@@ -42,7 +42,7 @@
from gajim.common.events import PluginRemoved
from gajim.common.i18n import _
from gajim.common.exceptions import PluginsystemError
-from gajim.common.helpers import Singleton
+from gajim.common.util.classes import Singleton
from gajim.plugins.plugins_i18n import _ as p_
from gajim.plugins.helpers import GajimPluginActivateException
=====================================
pyproject.toml
=====================================
@@ -57,7 +57,7 @@ include = [
"gajim/common/storage/*",
"gajim/common/styling.py",
"gajim/common/task_manager.py",
- "gajim/common/text_helpers.py",
+ "gajim/common/util/*",
"gajim/gajim.py",
"gajim/gajim_remote.py",
"gajim/gtk/about.py",
=====================================
test/no_gui/test_styling.py
=====================================
@@ -15,7 +15,7 @@
from gajim.common.styling import StrikeSpan
from gajim.common.styling import Hyperlink
from gajim.common.styling import process_uris
-from gajim.common.text_helpers import escape_iri_query
+from gajim.common.util.text import escape_iri_query
app.settings = MagicMock()
=====================================
test/no_gui/test_text_helpers.py → test/no_gui/test_text_util.py
=====================================
@@ -1,9 +1,9 @@
import unittest
-from gajim.common.text_helpers import escape_iri_path_segment
-from gajim.common.text_helpers import jid_to_iri
-from gajim.common.text_helpers import format_duration
-from gajim.common.text_helpers import remove_invalid_xml_chars
+from gajim.common.util.text import escape_iri_path_segment
+from gajim.common.util.text import jid_to_iri
+from gajim.common.util.text import format_duration
+from gajim.common.util.text import remove_invalid_xml_chars
class Test(unittest.TestCase):
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/834d4a31e59e426ee752503dd83e5f7…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/834d4a31e59e426ee752503dd83e5f7…
You're receiving this email because of your account on dev.gajim.org.
Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
26752631 by wurstsalat at 2022-12-14T20:13:22+01:00
fix: Notifications: Use correct nickname for /me messages
Fixes #11334
- - - - -
1 changed file:
- gajim/gtk/chat_stack.py
Changes:
=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -443,7 +443,7 @@ def _issue_notification(self, event: events.MessageReceived) -> None:
if text.startswith('/me') or text.startswith('/me\n'):
name = contact.name
if isinstance(contact, GroupchatContact):
- name = contact.nickname
+ name = event.properties.muc_nickname
text = f'* {name} {text[3:]}'
app.ged.raise_event(
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/267526313a02d7e74da8bb6065db78da…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/267526313a02d7e74da8bb6065db78da…
You're receiving this email because of your account on dev.gajim.org.