From 8873a130560767db9e429871d97f779ae7a9b3bf Mon Sep 17 00:00:00 2001
From: lovetox <philipp@hoerist.com>
Date: Wed, 28 Apr 2021 11:56:15 +0200
Subject: [PATCH] Move Controls to GTK folder

---
 gajim/gtk/chat_stack.py                            |  6 +++---
 gajim/gtk/controls/__init__.py                     |  0
 .../{chat_control_base.py => gtk/controls/base.py} |  4 ++--
 gajim/{chat_control.py => gtk/controls/chat.py}    | 14 +++++++-------
 .../controls/groupchat.py}                         | 14 +++++++-------
 .../controls/private.py}                           |  2 +-
 gajim/gtk/htmltextview.py                          |  2 +-
 gajim/gtk/message_input.py                         |  2 +-
 gajim/gtk/preferences.py                           |  4 ++--
 gajim/gui_interface.py                             |  6 +++---
 10 files changed, 27 insertions(+), 27 deletions(-)
 create mode 100644 gajim/gtk/controls/__init__.py
 rename gajim/{chat_control_base.py => gtk/controls/base.py} (99%)
 rename gajim/{chat_control.py => gtk/controls/chat.py} (99%)
 rename gajim/{groupchat_control.py => gtk/controls/groupchat.py} (99%)
 rename gajim/{privatechat_control.py => gtk/controls/private.py} (99%)

diff --git a/gajim/gtk/chat_stack.py b/gajim/gtk/chat_stack.py
index 3214c80439..6730277f30 100644
--- a/gajim/gtk/chat_stack.py
+++ b/gajim/gtk/chat_stack.py
@@ -16,9 +16,9 @@
 
 from gi.repository import Gtk
 
-from gajim.chat_control import ChatControl
-from gajim.groupchat_control import GroupchatControl
-from gajim.privatechat_control import PrivateChatControl
+from gajim.gui.controls.chat import ChatControl
+from gajim.gui.controls.groupchat import GroupchatControl
+from gajim.gui.controls.private import PrivateChatControl
 
 
 log = logging.getLogger('gajim.gui.chatstack')
diff --git a/gajim/gtk/controls/__init__.py b/gajim/gtk/controls/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gajim/chat_control_base.py b/gajim/gtk/controls/base.py
similarity index 99%
rename from gajim/chat_control_base.py
rename to gajim/gtk/controls/base.py
index 724e34ac41..520ecfabd0 100644
--- a/gajim/chat_control_base.py
+++ b/gajim/gtk/controls/base.py
@@ -91,7 +91,7 @@
 
 
 ################################################################################
-class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
+class BaseControl(ChatCommandProcessor, CommandTools, EventHelper):
     """
     A base class containing a banner, ConversationView, MessageInputTextView
     """
@@ -246,7 +246,7 @@ def __init__(self, widget_name, account, jid):
         self.encryption = self.get_encryption_state()
         self.conversation_view.encryption_enabled = self.encryption is not None
 
-        # PluginSystem: adding GUI extension point for ChatControlBase
+        # PluginSystem: adding GUI extension point for BaseControl
         # instance object (also subclasses, eg. ChatControl or GroupchatControl)
         app.plugin_manager.gui_extension_point('chat_control_base', self)
 
diff --git a/gajim/chat_control.py b/gajim/gtk/controls/chat.py
similarity index 99%
rename from gajim/chat_control.py
rename to gajim/gtk/controls/chat.py
index 9847cba1ec..7f6eda3765 100644
--- a/gajim/chat_control.py
+++ b/gajim/gtk/controls/chat.py
@@ -70,9 +70,9 @@
 
 from gajim.command_system.implementation.hosts import ChatCommands
 from gajim.command_system.framework import CommandHost  # pylint: disable=unused-import
-from gajim.chat_control_base import ChatControlBase
+from gajim.gui.controls.base import BaseControl
 
-log = logging.getLogger('gajim.chat_control')
+log = logging.getLogger('gajim.gui.controls.chat')
 
 
 class JingleObject:
@@ -86,7 +86,7 @@ def __init__(self, state, update):
 
 
 ################################################################################
-class ChatControl(ChatControlBase):
+class ChatControl(BaseControl):
     """
     A control for standard 1-1 chat
     """
@@ -98,7 +98,7 @@ class ChatControl(ChatControlBase):
     COMMAND_HOST = ChatCommands  # type: ClassVar[Type[CommandHost]]
 
     def __init__(self, account, jid):
-        ChatControlBase.__init__(self,
+        BaseControl.__init__(self,
                                  'chat_control',
                                  account,
                                  jid)
@@ -852,7 +852,7 @@ def on_location_eventbox_enter_notify_event(self, _widget, _event):
 
     def update_ui(self):
         # The name banner is drawn here
-        ChatControlBase.update_ui(self)
+        BaseControl.update_ui(self)
         self.update_toolbar()
         self._update_avatar()
         self.update_actions()
@@ -916,7 +916,7 @@ def send_message(self,
         if message in ('', None, '\n'):
             return
 
-        ChatControlBase.send_message(self,
+        BaseControl.send_message(self,
                                      message,
                                      type_='chat',
                                      xhtml=xhtml,
@@ -945,7 +945,7 @@ def add_message(self,
         else:
             name = self.get_our_nick()
 
-        ChatControlBase.add_message(self,
+        BaseControl.add_message(self,
                                     text,
                                     kind,
                                     name,
diff --git a/gajim/groupchat_control.py b/gajim/gtk/controls/groupchat.py
similarity index 99%
rename from gajim/groupchat_control.py
rename to gajim/gtk/controls/groupchat.py
index b09476d53e..a66c70caa1 100644
--- a/gajim/groupchat_control.py
+++ b/gajim/gtk/controls/groupchat.py
@@ -54,7 +54,7 @@
 from gajim.common.const import MUCJoinedState
 from gajim.common.structs import OutgoingMessage
 
-from gajim.chat_control_base import ChatControlBase
+from gajim.gui.controls.base import BaseControl
 
 from gajim.command_system.implementation.hosts import GroupChatCommands
 
@@ -76,10 +76,10 @@
 from gajim.gui.util import open_window
 from gajim.gui.const import ControlType
 
-log = logging.getLogger('gajim.groupchat_control')
+log = logging.getLogger('gajim.gui.controls.groupchat')
 
 
-class GroupchatControl(ChatControlBase):
+class GroupchatControl(BaseControl):
 
     _type = ControlType.GROUPCHAT
 
@@ -88,7 +88,7 @@ class GroupchatControl(ChatControlBase):
     COMMAND_HOST = GroupChatCommands
 
     def __init__(self, account, jid):
-        ChatControlBase.__init__(self,
+        BaseControl.__init__(self,
                                  'groupchat_control',
                                  account,
                                  jid)
@@ -782,7 +782,7 @@ def add_message(self,
 
             # self.check_focus_out_line()
 
-        ChatControlBase.add_message(self,
+        BaseControl.add_message(self,
                                     text,
                                     kind,
                                     contact,
@@ -1397,7 +1397,7 @@ def _close_control(self, reason=None):
 
     def set_control_active(self, state):
         self.attention_flag = False
-        ChatControlBase.set_control_active(self, state)
+        BaseControl.set_control_active(self, state)
 
     def _on_drag_data_received(self, widget, context, x, y, selection,
                                target_type, timestamp):
@@ -1426,7 +1426,7 @@ def _jid_not_blocked(self, bare_jid: str) -> bool:
         return not helpers.jid_is_blocked(self.account, fjid)
 
     def _on_message_textview_key_press_event(self, widget, event):
-        res = ChatControlBase._on_message_textview_key_press_event(
+        res = BaseControl._on_message_textview_key_press_event(
             self, widget, event)
         if res:
             return True
diff --git a/gajim/privatechat_control.py b/gajim/gtk/controls/private.py
similarity index 99%
rename from gajim/privatechat_control.py
rename to gajim/gtk/controls/private.py
index 6193c8b308..a555e04806 100644
--- a/gajim/privatechat_control.py
+++ b/gajim/gtk/controls/private.py
@@ -27,7 +27,7 @@
 from gajim.common import helpers
 from gajim.common.i18n import _
 
-from gajim.chat_control import ChatControl
+from gajim.gui.controls.chat import ChatControl
 from gajim.command_system.implementation.hosts import PrivateChatCommands
 
 from gajim.gui.dialogs import ErrorDialog
diff --git a/gajim/gtk/htmltextview.py b/gajim/gtk/htmltextview.py
index 65cfe2d4f2..7dce5da0d1 100644
--- a/gajim/gtk/htmltextview.py
+++ b/gajim/gtk/htmltextview.py
@@ -727,7 +727,7 @@ def __init__(self, account, standalone=False):
 
     def _on_destroy(self, *args):
         # We restore the TextView’s drag destination to avoid a GTK warning
-        # when closing the control. ChatControlBase.shutdown() calls destroy()
+        # when closing the control. BaseControl.shutdown() calls destroy()
         # on the control’s main box, causing GTK to recursively destroy the
         # child widgets. GTK then tries to set a target list on the TextView,
         # resulting in a warning because the Widget has no drag destination.
diff --git a/gajim/gtk/message_input.py b/gajim/gtk/message_input.py
index a1f2a25957..4988addd59 100644
--- a/gajim/gtk/message_input.py
+++ b/gajim/gtk/message_input.py
@@ -98,7 +98,7 @@ def __init__(self):
 
     def _on_destroy(self, *args):
         # We restore the TextView’s drag destination to avoid a GTK warning
-        # when closing the control. ChatControlBase.shutdown() calls destroy()
+        # when closing the control. BaseControl.shutdown() calls destroy()
         # on the control’s main box, causing GTK to recursively destroy the
         # child widgets. GTK then tries to set a target list on the TextView,
         # resulting in a warning because the Widget has no drag destination.
diff --git a/gajim/gtk/preferences.py b/gajim/gtk/preferences.py
index b81a82b59c..c5f240bcc0 100644
--- a/gajim/gtk/preferences.py
+++ b/gajim/gtk/preferences.py
@@ -29,7 +29,7 @@
 from gajim.common.multimedia_helpers import AudioOutputManager
 from gajim.common.multimedia_helpers import VideoInputManager
 
-from gajim.chat_control_base import ChatControlBase
+from gajim.gui.controls.base import BaseControl
 
 from .const import Setting
 from .const import SettingKind
@@ -395,7 +395,7 @@ def _on_use_speller(value, *args):
             gspell_lang = Gspell.language_get_default()
         app.settings.set('speller_language', gspell_lang.get_code())
         for ctrl in get_app_window('Preferences').get_all_controls():
-            if isinstance(ctrl, ChatControlBase):
+            if isinstance(ctrl, BaseControl):
                 ctrl.set_speller()
 
 
diff --git a/gajim/gui_interface.py b/gajim/gui_interface.py
index b7b08db309..3eeda6f9dc 100644
--- a/gajim/gui_interface.py
+++ b/gajim/gui_interface.py
@@ -58,8 +58,8 @@
 from gajim import gui_menu_builder
 from gajim.dialog_messages import get_dialog
 
-from gajim.chat_control_base import ChatControlBase
-from gajim.groupchat_control import GroupchatControl
+from gajim.gui.controls.base import BaseControl
+from gajim.gui.controls.groupchat import GroupchatControl
 
 from gajim.common import idle
 from gajim.common.zeroconf import connection_zeroconf
@@ -1255,7 +1255,7 @@ def handle_event(self, account, fjid, type_):
             w.set_active_tab(ctrl)
             w.window.present()
             # Using isinstance here because we want to catch all derived types
-            if isinstance(ctrl, ChatControlBase):
+            if isinstance(ctrl, BaseControl):
                 ctrl.scroll_to_end()
 
     def show_groupchat(self, account, room_jid):
-- 
GitLab