Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits: da303a80 by wurstsalat at 2021-07-26T20:32:40+02:00 NotificationManager: Improvements
- - - - - 9bcc42ed by wurstsalat at 2021-07-26T21:17:22+02:00 Improve MUC highlight colors
- - - - - 5fd4e96b by wurstsalat at 2021-07-26T21:17:47+02:00 SearchView: Disable text selection for result rows
- - - - - 4a3dbf13 by wurstsalat at 2021-07-26T21:28:57+02:00 Temporarily disable update_text_tags
- - - - -
9 changed files:
- gajim/data/gui/account_page.ui - gajim/data/style/gajim-dark.css - gajim/data/style/gajim.css - gajim/gtk/conversation/message_widget.py - gajim/gtk/conversation/plain_widget.py - gajim/gtk/conversation/rows/base.py - gajim/gtk/notification_manager.py - gajim/gtk/search_view.py - gajim/gui_interface.py
Changes:
===================================== gajim/data/gui/account_page.ui ===================================== @@ -117,156 +117,168 @@ </packing> </child> <child> - <object class="GtkBox" id="account_box"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="hexpand">True</property> - <property name="orientation">vertical</property> - <property name="spacing">18</property> + <property name="can-focus">True</property> <child> - <object class="GtkBox"> + <object class="GtkViewport"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> <child> - <object class="GtkOverlay"> + <object class="GtkBox" id="account_box"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="halign">center</property> + <property name="hexpand">True</property> + <property name="orientation">vertical</property> + <property name="spacing">18</property> <child> - <object class="GtkImage" id="avatar_image"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="icon-name">missging-image</property> - <property name="icon_size">6</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkOverlay"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">center</property> + <child> + <object class="GtkImage" id="avatar_image"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">missging-image</property> + <property name="icon_size">6</property> + </object> + <packing> + <property name="index">-1</property> + </packing> + </child> + <child type="overlay"> + <object class="GtkButton"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="tooltip-text" translatable="yes">Edit Profile…</property> + <property name="halign">end</property> + <property name="valign">start</property> + <signal name="clicked" handler="_on_edit_profile" swapped="no"/> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">document-edit-symbolic</property> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="account_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label"><name></property> + <style> + <class name="large-header"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> </object> <packing> - <property name="index">-1</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> </packing> </child> - <child type="overlay"> - <object class="GtkButton"> + <child> + <object class="GtkBox" id="account_action_box"> <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <property name="tooltip-text" translatable="yes">Edit Profile…</property> - <property name="halign">end</property> - <property name="valign">start</property> - <signal name="clicked" handler="_on_edit_profile" swapped="no"/> + <property name="can-focus">False</property> + <property name="halign">center</property> + <property name="spacing">12</property> <child> - <object class="GtkImage"> + <object class="GtkButton" id="account_settings"> <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="icon-name">document-edit-symbolic</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="tooltip-text" translatable="yes">Account Settings…</property> + <property name="halign">end</property> + <signal name="clicked" handler="_on_account_settings" swapped="no"/> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">preferences-other-symbolic</property> + </object> + </child> </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> </child> </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="account_label"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label"><name></property> - <style> - <class name="large-header"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkBox" id="account_action_box"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">center</property> - <property name="spacing">12</property> - <child> - <object class="GtkButton" id="account_settings"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <property name="tooltip-text" translatable="yes">Account Settings…</property> - <property name="halign">end</property> - <signal name="clicked" handler="_on_account_settings" swapped="no"/> <child> - <object class="GtkImage"> + <object class="GtkBox" id="status_message_box"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="icon-name">preferences-other-symbolic</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-top">6</property> + <property name="label" translatable="yes">Notifications</property> + <style> + <class name="bold16"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <style> + <class name="account-page-box"/> + </style> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <placeholder/> </child> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkBox" id="status_message_box"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="orientation">vertical</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="margin-top">6</property> - <property name="label" translatable="yes">Notifications</property> - <style> - <class name="bold16"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <style> - <class name="account-page-box"/> - </style> </object> <packing> <property name="resize">True</property>
===================================== gajim/data/style/gajim-dark.css ===================================== @@ -20,11 +20,11 @@ infobar.error > revealer > box {
/* ConversationView */ .conversation-mention-highlight { - background-color: rgb(251, 151, 97); -} -.conversation-mention-highlight:hover { - background-color: rgb(251, 151, 97); + background-color: rgb(100, 50, 10); } .conversation-mention-highlight grid textview text { - background-color: rgb(251, 151, 97); + background-color: rgb(100, 50, 10); +} +.conversation-mention-highlight:hover { + background-color: rgb(110, 50, 10); }
===================================== gajim/data/style/gajim.css ===================================== @@ -59,6 +59,13 @@ .conversation-row grid textview:not(.sourceview) text { .conversation-mention-highlight { background-color: rgb(255, 215, 194); } +.conversation-mention-highlight grid textview text { + background-color: rgb(255, 215, 194); +} +.conversation-mention-highlight:hover { + background-color: rgb(255, 205, 184); +} + @keyframes highlight { from { background: rgb(194, 215, 255) } to { background: transparent } @@ -291,6 +298,10 @@ .notification-listbox { .notification-listbox row { padding: 12px; border: 1px solid @borders; + border-bottom: 0px; +} +.notification-listbox row:nth-last-child(2) { + border-bottom: 1px solid @borders; }
/*Middle Grid*/
===================================== gajim/gtk/conversation/message_widget.py ===================================== @@ -20,9 +20,10 @@
class MessageWidget(Gtk.Box): - def __init__(self, account): + def __init__(self, account, selectable=True): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) self._account = account + self._selectable = selectable
self._content = None
@@ -37,7 +38,7 @@ def add_content(self, content): self._content = content for block in content.blocks: if block.name == 'plain': - widget = PlainWidget(self._account) + widget = PlainWidget(self._account, self._selectable) widget.add_content(block) self.add(widget) continue @@ -49,7 +50,7 @@ def add_content(self, content): continue
if block.name == 'quote': - message_widget = MessageWidget(self._account) + message_widget = MessageWidget(self._account, self._selectable) message_widget.add_content(block) widget = QuoteWidget(self._account) widget.attach_message_widget(message_widget)
===================================== gajim/gtk/conversation/plain_widget.py ===================================== @@ -37,14 +37,14 @@
class PlainWidget(Gtk.Box): - def __init__(self, account): + def __init__(self, account, selectable): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) self.set_vexpand(True)
self._account = account
# self._text_widget = MessageTextview(self._account) - self._text_widget = MessageLabel(self._account) + self._text_widget = MessageLabel(self._account, selectable) self.add(self._text_widget)
def add_content(self, block): @@ -52,10 +52,10 @@ def add_content(self, block):
class MessageLabel(Gtk.Label): - def __init__(self, account): + def __init__(self, account, selectable): Gtk.Label.__init__(self) self.set_hexpand(True) - self.set_selectable(True) + self.set_selectable(selectable) self.set_line_wrap(True) self.set_xalign(0) self.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
===================================== gajim/gtk/conversation/rows/base.py ===================================== @@ -59,6 +59,8 @@ def is_merged(self): return self._merged
def update_text_tags(self): + return + # TODO if self.textview is not None: self.textview.update_text_tags()
===================================== gajim/gtk/notification_manager.py ===================================== @@ -21,27 +21,29 @@ from gajim.common.const import AvatarSize from gajim.common.i18n import _ from gajim.common.helpers import get_groupchat_name +from gajim.common.helpers import get_muc_context
from gajim.gui_menu_builder import get_subscription_menu
from .util import open_window
-class NotificationManager(Gtk.ScrolledWindow): +class NotificationManager(Gtk.ListBox): def __init__(self, account): - Gtk.ScrolledWindow.__init__(self) + Gtk.ListBox.__init__(self) self._account = account self._client = app.get_client(account)
- self.set_vexpand(True) + self.set_selection_mode(Gtk.SelectionMode.NONE) + self.set_halign(Gtk.Align.CENTER) + self.get_style_context().add_class('notification-listbox')
- self._listbox = Gtk.ListBox() - self._listbox.set_selection_mode(Gtk.SelectionMode.NONE) - self._listbox.set_halign(Gtk.Align.CENTER) - self._listbox.get_style_context().add_class('notification-listbox') - self._set_placeholder() + label = Gtk.Label(label=_('No Notifications')) + label.set_valign(Gtk.Align.START) + label.get_style_context().add_class('dim-label') + label.show() + self.set_placeholder(label)
- self.add(self._listbox) self.show_all()
self._add_actions() @@ -89,13 +91,6 @@ def _remove_actions(self): for action in actions: app.window.remove_action(f'{action}-{self._account}')
- def _set_placeholder(self): - label = Gtk.Label(label=_('No Notifications')) - label.set_valign(Gtk.Align.START) - label.get_style_context().add_class('dim-label') - label.show() - self._listbox.set_placeholder(label) - def _on_subscription_accept(self, _action, param): jid = param.get_string() row = self._get_notification_row(jid) @@ -104,7 +99,7 @@ def _on_subscription_accept(self, _action, param): if not contact.is_in_roster: open_window('AddContact', account=self._account, jid=jid, nick=contact.name) - self._listbox.remove(row) + self.remove(row)
def _on_subscription_block(self, _action, param): jid = param.get_string() @@ -112,7 +107,7 @@ def _on_subscription_block(self, _action, param): self._deny_request(jid) self._client.get_module('Blocking').block([jid]) row = self._get_notification_row(jid) - self._listbox.remove(row) + self.remove(row)
def _on_subscription_report(self, _action, param): jid = param.get_string() @@ -120,19 +115,19 @@ def _on_subscription_report(self, _action, param): self._deny_request(jid) self._client.get_module('Blocking').block([jid], report='spam') row = self._get_notification_row(jid) - self._listbox.remove(row) + self.remove(row)
def _on_subscription_deny(self, _action, param): jid = param.get_string() self._deny_request(jid) row = self._get_notification_row(jid) - self._listbox.remove(row) + self.remove(row)
def _deny_request(self, jid): self._client.get_module('Presence').unsubscribed(jid)
def _get_notification_row(self, jid): - for child in self._listbox.get_children(): + for child in self.get_children(): if child.jid == jid: return child return None @@ -140,27 +135,27 @@ def _get_notification_row(self, jid): def add_subscription_request(self, event): row = self._get_notification_row(event.jid) if row is None: - self._listbox.add(SubscriptionRequestRow( + self.add(SubscriptionRequestRow( self._account, event.jid, event.status, event.user_nick)) elif row.type == 'unsubscribed': - self._listbox.remove(row) + self.remove(row)
def add_unsubscribed(self, event): row = self._get_notification_row(event.jid) if row is None: - self._listbox.add(UnsubscribedRow(self._account, event.jid)) + self.add(UnsubscribedRow(self._account, event.jid)) elif row.type == 'subscribe': - self._listbox.remove(row) + self.remove(row)
def add_invitation_received(self, event): row = self._get_notification_row(event.muc) if row is None: - self._listbox.add(InvitationReceivedRow(self._account, event)) + self.add(InvitationReceivedRow(self._account, event))
def add_invitation_declined(self, event): row = self._get_notification_row(event.muc) if row is None: - self._listbox.add(InvitationDeclinedRow(self._account, event)) + self.add(InvitationDeclinedRow(self._account, event))
class NotificationRow(Gtk.ListBoxRow): @@ -177,6 +172,7 @@ def __init__(self, account, jid): def _generate_label(): label = Gtk.Label() label.set_halign(Gtk.Align.START) + label.set_hexpand(True) label.set_xalign(0) label.set_ellipsize(Pango.EllipsizeMode.END) label.set_max_width_chars(30) @@ -276,7 +272,7 @@ def __init__(self, account, jid): self.show_all()
def _on_dismiss(self, _button): - self.get_parent().remove(self) + self.destroy()
class InvitationReceivedRow(NotificationRow): @@ -286,7 +282,11 @@ def __init__(self, account, event):
self._event = event
- image = self._generate_avatar_image(event.from_.bare) + if get_muc_context(event.muc) == 'public': + jid = event.from_ + else: + jid = event.from_.bare + image = self._generate_avatar_image(jid) self.grid.attach(image, 1, 1, 1, 2)
title_label = self._generate_label() @@ -294,8 +294,7 @@ def __init__(self, account, event): title_label.get_style_context().add_class('bold') self.grid.attach(title_label, 2, 1, 1, 1)
- contact = self._client.get_module('Contacts').get_contact( - event.from_.bare) + contact = self._client.get_module('Contacts').get_contact(jid) invitation_text = _('%(contact)s invited you to %(chat)s') % { 'contact': contact.name, 'chat': event.info.muc_name} @@ -307,6 +306,7 @@ def __init__(self, account, event):
show_button = Gtk.Button.new_with_label(label=_('Show')) show_button.set_valign(Gtk.Align.CENTER) + show_button.set_halign(Gtk.Align.END) show_button.set_tooltip_text('Show Invitation') show_button.connect('clicked', self._on_show_invitation) self.grid.attach(show_button, 3, 1, 1, 2) @@ -323,12 +323,12 @@ def _on_show_invitation(self, _button): open_window('GroupChatInvitation', account=self._account, event=self._event) - self.get_parent().remove(self) + self.destroy()
def _on_decline_invitation(self, _button): self._client.get_module('MUC').decline( - self.jid, self._event.from_.bare) - self.get_parent().remove(self) + self.jid, self._event.from_) + self.destroy()
class InvitationDeclinedRow(NotificationRow): @@ -336,7 +336,9 @@ def __init__(self, account, event): NotificationRow.__init__(self, account, event.muc) self.type = 'invitation-declined'
- image = self._generate_avatar_image(event.from_.bare) + jid = event.from_.bare + + image = self._generate_avatar_image(jid) self.grid.attach(image, 1, 1, 1, 2)
title_label = self._generate_label() @@ -344,9 +346,8 @@ def __init__(self, account, event): title_label.get_style_context().add_class('bold') self.grid.attach(title_label, 2, 1, 1, 1)
- contact = self._client.get_module('Contacts').get_contact( - event.from_.bare) - muc_name = get_groupchat_name(self._client, event.from_.bare) + contact = self._client.get_module('Contacts').get_contact(jid) + muc_name = get_groupchat_name(self._client, event.muc) invitation_text = _('%(contact)s declined your invitation ' 'to %(chat)s') % { 'contact': contact.name, @@ -360,6 +361,7 @@ def __init__(self, account, event): dismiss_button = Gtk.Button.new_from_icon_name( 'window-close-symbolic', Gtk.IconSize.BUTTON) dismiss_button.set_valign(Gtk.Align.CENTER) + dismiss_button.set_halign(Gtk.Align.END) dismiss_button.set_tooltip_text(_('Remove Notification')) dismiss_button.connect('clicked', self._on_dismiss) self.grid.attach(dismiss_button, 3, 1, 1, 2) @@ -367,4 +369,4 @@ def __init__(self, account, event): self.show_all()
def _on_dismiss(self, _button): - self.get_parent().remove(self) + self.destroy()
===================================== gajim/gtk/search_view.py ===================================== @@ -261,7 +261,7 @@ def __init__(self, msg, account, jid): date = time.strftime('%H:%M', local_time) self._ui.row_time_label.set_label(date)
- message_widget = MessageWidget(account) + message_widget = MessageWidget(account, selectable=False) self._ui.result_row_grid.attach(message_widget, 1, 1, 2, 1) result = process(msg.message) message_widget.add_content(result)
===================================== gajim/gui_interface.py ===================================== @@ -68,6 +68,7 @@ from gajim.common import helpers from gajim.common import passwords from gajim.common.helpers import ask_for_status_message +from gajim.common.helpers import get_muc_context from gajim.common.helpers import get_group_chat_nick from gajim.common.structs import MUCData from gajim.common.structs import OutgoingMessage @@ -372,29 +373,26 @@ def handle_event_msgnotsent(obj): obj.session.roster_message(obj.jid, msg, obj.time_, obj.conn.name, msg_type='error')
- def handle_event_gc_invitation(self, event): + @staticmethod + def handle_event_gc_invitation(event): event = events.GcInvitationtEvent(event)
# TODO: show account page - # if (helpers.allow_popup_window(event.account) or - # not self.systray_enabled): - # open_window('GroupChatInvitation', - # account=event.account, - # event=event) - # return - - #self.add_event(event.account, str(event.from_), event) + # self.add_event(event.account, str(event.from_), event)
if helpers.allow_showing_notification(event.account): client = app.get_client(event.account) - contact = client.get_module('Contacts').get_contact( - event.from_.bare) + if get_muc_context(event.muc) == 'public': + jid = event.from_ + else: + jid = event.from_.bare + contact = client.get_module('Contacts').get_contact(jid) event_type = _('Group Chat Invitation') text = _('%(contact)s invited you to %(chat)s') % { 'contact': contact.name, 'chat': event.info.muc_name} app.notification.popup(event_type, - str(event.from_), + str(jid), event.account, 'gc-invitation', 'gajim-gc_invitation',
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/6dfb44d3ae10d9f12c52b22a868556fb...