Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits: e4a7b414 by wurstsalat at 2021-09-11T23:34:27+02:00 Helpers: Remove obsolete get_icon_name_to_show
- - - - - 6e6e69f8 by wurstsalat at 2021-09-11T23:46:40+02:00 Remove remnants of minimizable controls
- - - - - fc116545 by wurstsalat at 2021-09-12T00:09:52+02:00 Chat Controls: Remove contact drag and drop for now
- - - - - b69ebe31 by wurstsalat at 2021-09-12T00:25:07+02:00 Interface: Remove roster remnants
- - - - - 17950bf7 by wurstsalat at 2021-09-12T00:36:09+02:00 Helpers: Remove obsolete methods
- - - - -
10 changed files:
- gajim/application.py - gajim/common/config.py - gajim/common/helpers.py - gajim/common/modules/adhoc_commands.py - gajim/common/setting_values.py - gajim/gtk/const.py - gajim/gtk/controls/base.py - gajim/gtk/controls/chat.py - gajim/gtk/controls/groupchat.py - gajim/remote_control.py
Changes:
===================================== gajim/application.py ===================================== @@ -300,9 +300,6 @@ def _open_uris(self, uris):
def do_shutdown(self, *args): Gtk.Application.do_shutdown(self) - # Shutdown GUI and save config - if hasattr(self.interface, 'roster') and self.interface.roster: - self.interface.roster.prepare_quit()
# Commit any outstanding SQL transactions app.storage.cache.shutdown()
===================================== gajim/common/config.py ===================================== @@ -124,7 +124,7 @@ class Config: 'remote_control': [opt_bool, False, _('If checked, Gajim can be controlled remotely using gajim-remote.'), True], 'confirm_paste_image': [opt_bool, True, _('Ask before pasting an image.')], 'confirm_close_muc': [opt_bool, True, _('Ask before closing a group chat tab/window.')], - 'confirm_close_multiple_tabs': [opt_bool, True, _('Ask before closing tabbed chat window if there are chats that can lose data (chat, private chat, group chat that will not be minimized).')], + 'confirm_close_multiple_tabs': [opt_bool, True, _('Ask before closing tabbed chat window if there are chats that can lose data (chat, private chat).')], 'notify_on_file_complete': [opt_bool, True], 'file_transfers_port': [opt_int, 28011], 'ft_add_hosts_to_send': [opt_str, '', _('List of send hosts (comma separated) in addition to local interfaces for file transfers (in case of address translation/port forwarding).')],
===================================== gajim/common/helpers.py ===================================== @@ -78,7 +78,6 @@ from gajim.common.i18n import ngettext from gajim.common.i18n import get_rfc5646_lang from gajim.common.const import ShowConstant -from gajim.common.const import Display from gajim.common.const import URIType from gajim.common.const import URIAction from gajim.common.const import GIO_TLS_ERRORS @@ -90,11 +89,6 @@
log = logging.getLogger('gajim.c.helpers')
-special_groups = (_('Transports'), - _('Not in contact list'), - _('Observers'), - _('Group chats')) - URL_REGEX = re.compile( r"(www.(?!.)|[a-z][a-z0-9+.-]*://)[^\s<>'"]+[^!,.\s<>)'"]]")
@@ -438,10 +432,6 @@ def _cut_if_long(string_): reduced_text = '' return reduced_text
-def get_account_status(account): - status = reduce_chars_newlines(account['status_line'], 100, 1) - return status -
def get_contact_dict_for_account(account): """ @@ -598,30 +588,6 @@ def statuses_unified(): return False return True
-def get_icon_name_to_show(contact, account=None): - """ - Get the icon name to show in online, away, requested, etc - """ - if account and account in app.interface.minimized_controls and \ - contact.jid in app.interface.minimized_controls[account] and app.interface.\ - minimized_controls[account][contact.jid].get_nb_unread_pm() > 0: - return 'event' - if account and contact.jid in app.gc_connected[account]: - if app.gc_connected[account][contact.jid]: - return 'muc-active' - return 'muc-inactive' - if contact.jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent - return contact.show - if contact.sub in ('both', 'to'): - return contact.show - if contact.ask == 'subscribe': - return 'requested' - transport = app.get_transport_name_from_jid(contact.jid) - if transport: - return contact.show - if contact.show in SHOW_LIST: - return contact.show - return 'notinroster'
def get_full_jid_from_iq(iq_obj): """ @@ -736,11 +702,6 @@ def allow_sound_notification(account, sound_event): return False
-def get_current_show(account): - if account not in app.connections: - return 'offline' - return app.connections[account].status - def get_optional_features(account): features = []
===================================== gajim/common/modules/adhoc_commands.py ===================================== @@ -175,8 +175,8 @@ def second_step(self, request): now=presencetype == 'offline')
# send new status - app.interface.roster.send_status( - self.connection.name, presencetype, presencedesc) + app.get_client(self.connection.name).change_status( + presencetype, presencedesc)
return False # finish the session
===================================== gajim/common/setting_values.py ===================================== @@ -370,7 +370,7 @@ class _ACCOUNT_DEFAULT: 'remote_control': _('If checked, Gajim can be controlled remotely using gajim-remote.'), 'confirm_paste_image': _('Ask before pasting an image.'), 'confirm_close_muc': _('Ask before closing a group chat tab/window.'), - 'confirm_close_multiple_tabs': _('Ask before closing tabbed chat window if there are chats that can lose data (chat, private chat, group chat that will not be minimized).'), + 'confirm_close_multiple_tabs': _('Ask before closing tabbed chat window if there are chats that can lose data (chat, private chat).'), 'file_transfers_port': '', 'ft_add_hosts_to_send': _('List of send hosts (comma separated) in addition to local interfaces for file transfers (in case of address translation/port forwarding).'), 'use_kib_mib': _('IEC standard says KiB = 1024 bytes, KB = 1000 bytes.'),
===================================== gajim/gtk/const.py ===================================== @@ -28,6 +28,9 @@
DEFAULT_WORKSPACE_COLOR = 'rgb(191,15,167)'
+# Drag and drop target type URI list (for dropped files) +TARGET_TYPE_URI_LIST = 80 +
@unique class Theme(IntEnum):
===================================== gajim/gtk/controls/base.py ===================================== @@ -61,6 +61,7 @@ from gajim.gui.util import get_show_in_systray from gajim.gui.util import AccountBadge from gajim.gui.const import ControlType # pylint: disable=unused-import +from gajim.gui.const import TARGET_TYPE_URI_LIST from gajim.gui.emoji_chooser import emoji_chooser
from gajim.command_system.implementation.middleware import ChatCommandProcessor @@ -142,11 +143,10 @@ def __init__(self, widget_name, account, jid): self.xml.overlay.connect('drag-motion', self._on_drag_motion) self.xml.overlay.connect('drag-leave', self._on_drag_leave)
- self.TARGET_TYPE_URI_LIST = 80 uri_entry = Gtk.TargetEntry.new( 'text/uri-list', Gtk.TargetFlags.OTHER_APP, - self.TARGET_TYPE_URI_LIST) + TARGET_TYPE_URI_LIST) dst_targets = Gtk.TargetList.new([uri_entry]) dst_targets.add_text_targets(0) self._dnd_list = [uri_entry, @@ -338,14 +338,6 @@ def is_privatechat(self): def is_groupchat(self): return self._type.is_groupchat
- def minimizable(self): - """ - Called to check if control can be minimized - - Derived classes MAY implement this. - """ - return False - def safe_shutdown(self): """ Called to check if control can be closed without losing data. @@ -355,13 +347,11 @@ def safe_shutdown(self): """ return True
- def allow_shutdown(self, method, on_response_yes, on_response_no, - on_response_minimize): + def allow_shutdown(self, method, on_response_yes, on_response_no): """ Called to check is a control is allowed to shutdown. If a control is not in a suitable shutdown state this method should call on_response_no, else on_response_yes or - on_response_minimize
Derived classes MAY implement this. """
===================================== gajim/gtk/controls/chat.py ===================================== @@ -54,6 +54,8 @@
from gajim.gui.adhoc_muc import AdhocMUC from gajim.gui.call_widget import CallWidget +from gajim.gui.const import TARGET_TYPE_URI_LIST +from gajim.gui.const import ControlType from gajim.gui.dialogs import DialogButton from gajim.gui.dialogs import ConfirmationDialog from gajim.gui.util import get_cursor @@ -63,7 +65,6 @@ from gajim.gui.util import format_location from gajim.gui.util import get_activity_icon_name from gajim.gui.util import open_window -from gajim.gui.const import ControlType
from gajim.command_system.implementation.hosts import ChatCommands from gajim.command_system.framework import CommandHost # pylint: disable=unused-import @@ -657,7 +658,7 @@ def shutdown(self): super(ChatControl, self).shutdown() app.check_finalize(self)
- def allow_shutdown(self, _method, on_yes, on_no, _on_minimize): + def allow_shutdown(self, _method, on_yes, on_no): time_ = app.last_message_time[self.account][self.contact.jid] # 2 seconds if time.time() - time_ < 2: @@ -699,30 +700,12 @@ def _on_drag_data_received(self, _widget, _context, _x_coord, _y_coord, if not selection.get_data(): return
- if target_type == self.TARGET_TYPE_URI_LIST: + log.debug('Drop received: %s, %s', selection.get_data(), target_type) + + # TODO: Contact drag and drop for AdHocMUC + if target_type == TARGET_TYPE_URI_LIST: # File drag and drop (handled in chat_control_base) self.drag_data_file_transfer(selection) - else: - # Convert single chat to MUC - treeview = app.interface.roster.tree - model = treeview.get_model() - data = selection.get_data().decode() - tree_selection = treeview.get_selection() - if tree_selection.count_selected_rows() == 0: - return - path = tree_selection.get_selected_rows()[1][0] - iter_ = model.get_iter(path) - type_ = model[iter_][2] - if type_ != 'contact': # Source is not a contact - return - dropped_jid = data - - dropped_transport = app.get_transport_name_from_jid(dropped_jid) - c_transport = app.get_transport_name_from_jid(self.contact.jid) - if dropped_transport or c_transport: - return # transport contacts cannot be invited - - AdhocMUC(self.account, [self.contact.jid], [dropped_jid])
def _on_client_state_changed(self, _client, _signal_name, state): self.msg_textview.set_sensitive(state.is_connected)
===================================== gajim/gtk/controls/groupchat.py ===================================== @@ -56,6 +56,8 @@
from gajim.command_system.implementation.hosts import GroupChatCommands
+from gajim.gui.const import ControlType +from gajim.gui.const import TARGET_TYPE_URI_LIST from gajim.gui.dialogs import DialogButton from gajim.gui.dialogs import ConfirmationCheckDialog from gajim.gui.dialogs import ConfirmationDialog @@ -71,7 +73,6 @@ from gajim.gui.util import NickCompletionGenerator from gajim.gui.util import get_app_window from gajim.gui.util import open_window -from gajim.gui.const import ControlType
log = logging.getLogger('gajim.gui.controls.groupchat')
@@ -93,7 +94,6 @@ def __init__(self, account, jid): self._client.connect_signal('state-changed', self._on_client_state_changed)
- self.force_non_minimizable = False self.is_anonymous = True
self.toggle_emoticons() @@ -1232,22 +1232,12 @@ def _on_drag_data_received(self, _widget, _context, _x_coord, _y_coord, if not selection.get_data(): return
- if target_type == self.TARGET_TYPE_URI_LIST: + log.debug('Drop received: %s, %s', selection.get_data(), target_type) + + # TODO: Contact drag and drop for Invitations + if target_type == TARGET_TYPE_URI_LIST: # File drag and drop (handled in chat_control_base) self.drag_data_file_transfer(selection) - else: - # Invite contact to groupchat - treeview = app.interface.roster.tree - model = treeview.get_model() - data = selection.get_data().decode() - path = treeview.get_selection().get_selected_rows()[1][0] - iter_ = model.get_iter(path) - type_ = model[iter_][2] - if type_ != 'contact': # Source is not a contact - return - contact_jid = data - - self.invite(contact_jid)
def _jid_not_blocked(self, bare_jid: str) -> bool: fjid = self.room_jid + '/' + bare_jid
===================================== gajim/remote_control.py ===================================== @@ -566,7 +566,6 @@ def open_chat(self, jid, account, message): # Jid is not conform, ignore it return False
- minimized_control = None if account: accounts = [account] else: @@ -583,8 +582,6 @@ def open_chat(self, jid, account, message): break # jid is in roster if contact: - minimized_control = \ - jid in app.interface.minimized_controls[acct] connected_account = acct break # we send the message to jid not in roster, because account is @@ -598,10 +595,6 @@ def open_chat(self, jid, account, message): if connected_account is None and first_connected_acct: connected_account = first_connected_acct
- if minimized_control: - app.interface.roster.on_groupchat_maximized( - None, jid, connected_account) - if connected_account: app.interface.new_chat_from_jid(connected_account, jid, message) # preserve the 'steal focus preservation' @@ -624,7 +617,7 @@ def change_status(self, status, message, account): if account not in app.connections: return False status = app.connections[account].status - GLib.idle_add(app.interface.roster.send_status, account, status, + GLib.idle_add(app.connections[account].change_status, status, message) else: # account not specified, so change the status of all accounts @@ -638,7 +631,7 @@ def change_status(self, status, message, account): if acc not in app.connections: continue status_ = app.connections[acc].status - GLib.idle_add(app.interface.roster.send_status, acc, status_, + GLib.idle_add(app.connections[acc].change_status, status_, message) return False
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/af774b00e4e20ab224193dedffe94391...