Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
97dfbb01 by Daniel Brötzmann at 2021-02-02T19:42:06+01:00
ChatList: Add group chat nicks
- - - - -
1 changed file:
- gajim/gtk/chat_list.py
Changes:
=====================================
gajim/gtk/chat_list.py
=====================================
@@ -9,6 +9,7 @@
from gajim.common.const import KindConstant
from gajim.common.i18n import _
from gajim.common.helpers import get_groupchat_name
+from gajim.common.helpers import get_group_chat_nick
from gajim.common.helpers import get_uf_relative_time
log = logging.getLogger('gajim.gtk.chatlist')
@@ -167,14 +168,23 @@ def __init__(self, workspace_id, account, jid, type_):
if line is not None and line.message is not None:
one_line = ' '.join(line.message.splitlines())
last_message_label.set_text(one_line)
- nick_label = Gtk.Label(label=_('Me:'))
+ nick_label = Gtk.Label()
nick_label.set_halign(Gtk.Align.START)
nick_label.get_style_context().add_class('small-label')
nick_label.get_style_context().add_class('dim-label')
if line.kind in (KindConstant.CHAT_MSG_SENT,
KindConstant.SINGLE_MSG_SENT):
+ nick_label.set_text(_('Me:'))
last_message_box.add(nick_label)
- # TODO: MUC nick
+ if line.kind == KindConstant.GC_MSG:
+ our_nick = get_group_chat_nick(account, jid)
+ if line.contact_name == our_nick:
+ nick_label.set_text(_('Me:'))
+ else:
+ nick_label.set_text(_('%(muc_nick)s: ') % {
+ 'muc_nick': line.contact_name})
+ last_message_box.add(nick_label)
+
# TODO: file transfers have to be displayed differently
self._timestamp = line.time
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/97dfbb01b552f37cbb1444759e907ce7…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/97dfbb01b552f37cbb1444759e907ce7…
You're receiving this email because of your account on dev.gajim.org.
Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
3b4d96a9 by Daniel Brötzmann at 2021-02-01T20:29:45+01:00
ChatList: Group chat avatars and message lines
- - - - -
1 changed file:
- gajim/gtk/chat_list.py
Changes:
=====================================
gajim/gtk/chat_list.py
=====================================
@@ -118,7 +118,7 @@ def __init__(self, workspace_id, account, jid, type_):
contact = app.contacts.get_contact(account, jid)
- if contact:
+ if contact and not contact.is_groupchat:
avatar = app.contacts.get_avatar(account,
contact.jid,
AvatarSize.ROSTER,
@@ -157,7 +157,8 @@ def __init__(self, workspace_id, account, jid, type_):
line = app.storage.archive.get_last_conversation_line(account, jid)
last_message_box = Gtk.Box(spacing=3)
if line is not None and line.message is not None:
- last_message_label.set_text(line.message)
+ one_line = ' '.join(line.message.splitlines())
+ last_message_label.set_text(one_line)
nick_label = Gtk.Label(label=_('Me:'))
nick_label.set_halign(Gtk.Align.START)
nick_label.get_style_context().add_class('small-label')
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/3b4d96a92acfa73fafa512656ba4a06c…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/3b4d96a92acfa73fafa512656ba4a06c…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch mainwindow at gajim / gajim
Commits:
2e264d42 by lovetox at 2021-01-31T22:25:45+01:00
Make quit work
- - - - -
4 changed files:
- gajim/app_actions.py
- gajim/application.py
- gajim/gtk/main.py
- gajim/roster_window.py
Changes:
=====================================
gajim/app_actions.py
=====================================
@@ -66,7 +66,7 @@ def on_bookmarks(_action, param):
def on_quit(_action, _param):
- interface.roster.on_quit_request()
+ app.window.quit()
def on_new_chat(_action, param):
=====================================
gajim/application.py
=====================================
@@ -590,3 +590,27 @@ def _on_feature_discovered(self, event):
elif event.feature == Namespace.BLOCKING:
action = '%s-blocking' % event.account
self.lookup_action(action).set_enabled(True)
+
+ def start_shutdown(self, *args, **kwargs):
+ accounts_to_disconnect = {}
+
+ for account, client in app.connections.items():
+ if app.account_is_available(account):
+ accounts_to_disconnect[account] = client
+
+ if not accounts_to_disconnect:
+ self.quit()
+ return
+
+ def _on_disconnect(event):
+ accounts_to_disconnect.pop(event.account)
+ if not accounts_to_disconnect:
+ self.quit()
+ return
+
+ app.ged.register_event_handler('account-disconnected',
+ ged.CORE,
+ _on_disconnect)
+
+ for client in accounts_to_disconnect.values():
+ client.change_status('offline', kwargs.get('message', ''))
=====================================
gajim/gtk/main.py
=====================================
@@ -4,6 +4,7 @@
from gi.repository import Gio
from gajim.common import app
+from gajim.common.i18n import _
from gajim.gui.util import get_builder
from gajim.gui.util import load_icon
from gajim.gui.account_page import AccountPage
@@ -12,6 +13,10 @@
from gajim.gui.account_side_bar import AccountSideBar
from gajim.gui.workspace_side_bar import WorkspaceSideBar
+from gajim.common.helpers import ask_for_status_message
+from gajim.gui.dialogs import DialogButton
+from gajim.gui.dialogs import ConfirmationDialog
+
from .util import open_window
@@ -215,3 +220,77 @@ def _on_start_chat_clicked(self, _button):
def _on_edit_workspace_clicked(self, _button):
open_window('WorkspaceDialog',
workspace_id=self.get_active_workspace())
+
+ def quit(self):
+ accounts = list(app.connections.keys())
+ get_msg = False
+ for acct in accounts:
+ if app.account_is_available(acct):
+ get_msg = True
+ break
+
+ def on_continue2(message):
+ if 'file_transfers' not in app.interface.instances:
+ app.app.start_shutdown(message=message)
+ return
+ # check if there is an active file transfer
+ from gajim.common.modules.bytestream import is_transfer_active
+ files_props = app.interface.instances['file_transfers'].\
+ files_props
+ transfer_active = False
+ for x in files_props:
+ for y in files_props[x]:
+ if is_transfer_active(files_props[x][y]):
+ transfer_active = True
+ break
+
+ if transfer_active:
+ ConfirmationDialog(
+ _('Stop File Transfers'),
+ _('You still have running file transfers'),
+ _('If you quit now, the file(s) being transferred will '
+ 'be lost.\n'
+ 'Do you still want to quit?'),
+ [DialogButton.make('Cancel'),
+ DialogButton.make('Remove',
+ text=_('_Quit'),
+ callback=app.app.start_shutdown,
+ kwargs={'message': message})]).show()
+ return
+ app.app.start_shutdown(message=message)
+
+ def on_continue(message):
+ if message is None:
+ # user pressed Cancel to change status message dialog
+ return
+ # check if we have unread messages
+ unread = app.events.get_nb_events()
+
+ for event in app.events.get_all_events(['printed_gc_msg']):
+ contact = app.contacts.get_groupchat_contact(event.account,
+ event.jid)
+ if contact is None or not contact.can_notify():
+ unread -= 1
+
+ if unread:
+ ConfirmationDialog(
+ _('Unread Messages'),
+ _('You still have unread messages'),
+ _('Messages will only be available for reading them later '
+ 'if storing chat history is enabled and if the contact '
+ 'is in your contact list.'),
+ [DialogButton.make('Cancel'),
+ DialogButton.make('Remove',
+ text=_('_Quit'),
+ callback=on_continue2,
+ args=[message])]).show()
+ return
+ on_continue2(message)
+
+ if get_msg and ask_for_status_message('offline'):
+ open_window('StatusChange',
+ status='offline',
+ callback=on_continue,
+ show_pep=False)
+ else:
+ on_continue('')
=====================================
gajim/roster_window.py
=====================================
@@ -2235,121 +2235,6 @@ def prepare_quit(self):
app.interface.hide_systray()
self.save_done = True
- def quit_gtkgui_interface(self):
- """
- When we quit the gtk interface - exit gtk
- """
- self.prepare_quit()
- self.application.quit()
-
- def on_quit_request(self, widget=None):
- """
- User wants to quit. Check if he should be warned about messages pending.
- Terminate all sessions and send offline to all connected account. We do
- NOT really quit gajim here
- """
- accounts = list(app.connections.keys())
- get_msg = False
- for acct in accounts:
- if app.account_is_available(acct):
- get_msg = True
- break
-
- def on_continue3(message):
- self.quit_on_next_offline = 0
- accounts_to_disconnect = []
- for acct in accounts:
- if app.account_is_available(acct):
- self.quit_on_next_offline += 1
- accounts_to_disconnect.append(acct)
-
- if not self.quit_on_next_offline:
- # all accounts offline, quit
- self.quit_gtkgui_interface()
- return
-
- for acct in accounts_to_disconnect:
- self.send_status(acct, 'offline', message)
-
- def on_continue2(message):
- if 'file_transfers' not in app.interface.instances:
- on_continue3(message)
- return
- # check if there is an active file transfer
- from gajim.common.modules.bytestream import is_transfer_active
- files_props = app.interface.instances['file_transfers'].\
- files_props
- transfer_active = False
- for x in files_props:
- for y in files_props[x]:
- if is_transfer_active(files_props[x][y]):
- transfer_active = True
- break
-
- if transfer_active:
- ConfirmationDialog(
- _('Stop File Transfers'),
- _('You still have running file transfers'),
- _('If you quit now, the file(s) being transferred will '
- 'be lost.\n'
- 'Do you still want to quit?'),
- [DialogButton.make('Cancel'),
- DialogButton.make('Remove',
- text=_('_Quit'),
- callback=on_continue3,
- args=[message])]).show()
- return
- on_continue3(message)
-
- def on_continue(message):
- if message is None:
- # user pressed Cancel to change status message dialog
- return
- # check if we have unread messages
- unread = app.events.get_nb_events()
-
- for event in app.events.get_all_events(['printed_gc_msg']):
- contact = app.contacts.get_groupchat_contact(event.account,
- event.jid)
- if contact is None or not contact.can_notify():
- unread -= 1
-
- # check if we have recent messages
- # recent = False
- # for win in app.interface.msg_win_mgr.windows():
- # for ctrl in win.controls():
- # fjid = ctrl.get_full_jid()
- # if fjid in app.last_message_time[ctrl.account]:
- # if time.time() - app.last_message_time[ctrl.account][
- # fjid] < 2:
- # recent = True
- # break
- # if recent:
- # break
-
- if unread:
- ConfirmationDialog(
- _('Unread Messages'),
- _('You still have unread messages'),
- _('Messages will only be available for reading them later '
- 'if storing chat history is enabled and if the contact '
- 'is in your contact list.'),
- [DialogButton.make('Cancel'),
- DialogButton.make('Remove',
- text=_('_Quit'),
- callback=on_continue2,
- args=[message])]).show()
- return
- on_continue2(message)
-
- if get_msg and ask_for_status_message('offline'):
- open_window('StatusChange',
- status='offline',
- callback=on_continue,
- show_pep=False)
- else:
- on_continue('')
-
def _nec_presence_received(self, obj):
account = obj.conn.name
jid = obj.jid
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/2e264d42e51ee4b652f6d0487a186b94…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/2e264d42e51ee4b652f6d0487a186b94…
You're receiving this email because of your account on dev.gajim.org.