Philipp Hörist pushed to branch master at gajim / gajim
Commits: 1b4a1f08 by lovetox at 2020-04-28T21:40:03+02:00 Rework chat tabs
- Always show new avatars with status - Remove tabs advanced config options - Increase tabs width
- - - - -
9 changed files:
- gajim/chat_control.py - gajim/chat_control_base.py - gajim/common/config.py - gajim/data/gui/message_window.ui - gajim/data/gui/preferences_window.ui - gajim/groupchat_control.py - gajim/gtk/preferences.py - gajim/message_window.py - gajim/privatechat_control.py
Changes:
===================================== gajim/chat_control.py ===================================== @@ -60,7 +60,6 @@ from gajim import dialogs from gajim.gtk.dialogs import DialogButton from gajim.gtk.dialogs import NewConfirmationDialog from gajim.gtk.add_contact import AddNewContactWindow -from gajim.gtk.util import get_icon_name from gajim.gtk.util import get_cursor from gajim.gtk.util import format_mood from gajim.gtk.util import format_activity @@ -1025,7 +1024,7 @@ class ChatControl(ChatControlBase): jid = self.contact.jid num_unread = len(app.events.get_events( self.account, jid, ['printed_%s' % self._type, str(self._type)])) - if num_unread == 1 and not app.config.get('show_unread_tab_icon'): + if num_unread == 1: unread = '*' elif num_unread > 1: unread = '[' + str(num_unread) + ']' @@ -1038,42 +1037,13 @@ class ChatControl(ChatControlBase): label_str = '<b>' + unread + label_str + '</b>' return label_str
- def get_tab_image(self, count_unread=True): - if self.resource: - jid = self.contact.get_full_jid() - else: - jid = self.contact.jid - - if app.config.get('show_avatar_in_tabs'): - scale = self.parent_win.window.get_scale_factor() - surface = app.contacts.get_avatar( - self.account, jid, AvatarSize.TAB, scale) - if surface is not None: - return surface - - if count_unread: - num_unread = len(app.events.get_events( - self.account, - jid, - ['printed_%s' % self._type, str(self._type)])) - else: - num_unread = 0 - - transport = None - if app.jid_is_transport(jid): - transport = app.get_transport_name_from_jid(jid) - - if num_unread and app.config.get('show_unread_tab_icon'): - icon_name = get_icon_name('event', transport=transport) - else: - contact = app.contacts.get_contact_with_highest_priority( - self.account, self.contact.jid) - if not contact or self.resource: - # For transient contacts - contact = self.contact - icon_name = get_icon_name(contact.show, transport=transport) - - return icon_name + def get_tab_image(self): + scale = self.parent_win.window.get_scale_factor() + return app.contacts.get_avatar(self.account, + self.contact.jid, + AvatarSize.ROSTER, + scale, + self.contact.show)
def prepare_context_menu(self, hide_buttonbar_items=False): """
===================================== gajim/chat_control_base.py ===================================== @@ -401,9 +401,8 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper): # Return a markup'd label and optional Gtk.Color in a tuple like: # return (label_str, None)
- def get_tab_image(self, count_unread=True): + def get_tab_image(self): # Return a suitable tab image for display. - # None clears any current label. return None
def prepare_context_menu(self, hide_buttonbar_items=False):
===================================== gajim/common/config.py ===================================== @@ -180,7 +180,6 @@ class Config: 'muc_highlight_words': [opt_str, '', _('A list of words (semicolon separated) that will be highlighted in group chats.')], 'quit_on_roster_x_button': [opt_bool, False, _('If enabled, Gajim quits when clicking the X button of your Window Manager. This setting is taken into account only if the notification area icon is used.')], 'hide_on_roster_x_button': [opt_bool, False, _('If enabled, Gajim hides the contact list window when pressing the X button instead of minimizing into the notification area.')], - 'show_unread_tab_icon': [opt_bool, False, _('If enabled, Gajim will display an icon on each tab containing unread messages. Depending on the theme, this icon may be animated.')], 'show_status_msgs_in_roster': [opt_bool, True, _('If enabled, Gajim will display the status message (if not empty) underneath the contact name in the contact list window.'), True], 'show_avatars_in_roster': [opt_bool, True, '', True], 'show_mood_in_roster': [opt_bool, True, '', True], @@ -232,7 +231,6 @@ class Config: 'ignore_incoming_attention': [opt_bool, False, _('If enabled, Gajim will ignore incoming attention requests ('wizz').')], 'remember_opened_chat_controls': [opt_bool, True, _('If enabled, Gajim will reopen chat windows that were opened last time Gajim was closed.')], 'positive_184_ack': [opt_bool, False, _('If enabled, Gajim will display an icon to show that sent messages have been received by your contact.')], - 'show_avatar_in_tabs': [opt_bool, False, _('Show a mini avatar in chat window tabs and as the window's icon.')], 'use_keyring': [opt_bool, True, _('If enabled, Gajim will use the System's Keyring to store account passwords.')], 'remote_commands': [opt_bool, False, _('If enabled, Gajim will execute XEP-0146 Commands.')], 'dark_theme': [opt_int, 2, _('2: System, 1: Enabled, 0: Disabled')],
===================================== gajim/data/gui/message_window.ui ===================================== @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.21.0 --> +<!-- Generated with glade 3.22.1 --> <interface> <requires lib="gtk+" version="3.12"/> <object class="GtkEventBox" id="chat_tab_ebox"> @@ -8,6 +8,7 @@ <property name="visible_window">False</property> <child> <object class="GtkBox" id="tab_hbox"> + <property name="width_request">170</property> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">4</property> @@ -15,6 +16,7 @@ <object class="GtkImage" id="tab_image"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="halign">start</property> <property name="stock">gtk-missing-image</property> </object> <packing> @@ -25,9 +27,11 @@ </child> <child> <object class="GtkLabel" id="tab_label"> - <property name="width_request">70</property> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="margin_left">3</property> + <property name="hexpand">True</property> <property name="use_markup">True</property> <property name="ellipsize">end</property> <property name="single_line_mode">True</property> @@ -37,8 +41,8 @@ </style> </object> <packing> - <property name="expand">False</property> - <property name="fill">False</property> + <property name="expand">True</property> + <property name="fill">True</property> <property name="position">1</property> </packing> </child> @@ -48,6 +52,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> + <property name="halign">end</property> <property name="relief">none</property> <child> <object class="GtkImage" id="image1329"> @@ -73,6 +78,9 @@ <property name="default_width">480</property> <property name="default_height">440</property> <property name="show_menubar">False</property> + <child type="titlebar"> + <placeholder/> + </child> <child> <object class="GtkNotebook" id="notebook"> <property name="visible">True</property> @@ -80,8 +88,5 @@ <property name="scrollable">True</property> </object> </child> - <child type="titlebar"> - <placeholder/> - </child> </object> </interface>
===================================== gajim/data/gui/preferences_window.ui ===================================== @@ -306,23 +306,6 @@ <property name="top_attach">1</property> </packing> </child> - <child> - <object class="GtkCheckButton" id="show_avatar_in_tabs_checkbutton"> - <property name="label" translatable="yes">Show _avatar in chat tabs</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">If checked, the contact's avatar will be shown in chat tabs</property> - <property name="halign">start</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="on_show_avatar_in_tabs_checkbutton_toggled" swapped="no"/> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">4</property> - </packing> - </child> <child> <object class="GtkComboBox" id="tabs_placement"> <property name="visible">True</property>
===================================== gajim/groupchat_control.py ===================================== @@ -74,7 +74,6 @@ from gajim.gtk.groupchat_info import GroupChatInfoScrolled from gajim.gtk.groupchat_invite import GroupChatInvite from gajim.gtk.groupchat_roster import GroupchatRoster from gajim.gtk.util import NickCompletionGenerator -from gajim.gtk.util import get_icon_name from gajim.gtk.util import get_app_window from gajim.gtk.const import ControlType
@@ -786,13 +785,12 @@ class GroupchatControl(ChatControlBase): label_str = unread + label_str return (label_str, color)
- def get_tab_image(self, count_unread=True): - tab_image = None - if self.is_connected: - tab_image = get_icon_name('muc-active') - else: - tab_image = get_icon_name('muc-inactive') - return tab_image + def get_tab_image(self): + return app.interface.avatar_storage.get_muc_surface( + self.account, + self.contact.jid, + AvatarSize.ROSTER, + self.scale_factor)
def _update_banner_state_image(self): surface = app.interface.avatar_storage.get_muc_surface(
===================================== gajim/gtk/preferences.py ===================================== @@ -99,10 +99,6 @@ class Preferences(Gtk.ApplicationWindow): else: # right self._ui.tabs_placement.set_active(3)
- # Show avatar in tabs - st = app.config.get('show_avatar_in_tabs') - self._ui.show_avatar_in_tabs_checkbutton.set_active(st) - ## Contact List Appearance # Display avatars in roster st = app.config.get('show_avatars_in_roster') @@ -594,9 +590,6 @@ class Preferences(Gtk.ApplicationWindow): else: # right app.config.set('tabs_position', 'right')
- def on_show_avatar_in_tabs_checkbutton_toggled(self, widget): - self.on_checkbutton_toggled(widget, 'show_avatar_in_tabs') - def on_show_avatars_in_roster_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'show_avatars_in_roster') app.interface.roster.setup_and_draw_roster()
===================================== gajim/message_window.py ===================================== @@ -647,7 +647,6 @@ class MessageWindow(EventHelper): close_button.hide()
# Update nick - nick_label.set_max_width_chars(10) if isinstance(ctrl, ChatControl): tab_label_str = ctrl.get_tab_label() # Set Label Color
===================================== gajim/privatechat_control.py ===================================== @@ -35,7 +35,6 @@ from gajim.chat_control import ChatControl from gajim.command_system.implementation.hosts import PrivateChatCommands
from gajim.gtk.dialogs import ErrorDialog -from gajim.gtk.util import get_icon_name from gajim.gtk.const import ControlType
@@ -225,38 +224,15 @@ class PrivateChatControl(ChatControl):
self.xml.avatar_image.set_from_surface(surface)
- def get_tab_image(self, count_unread=True): - jid = self.gc_contact.get_full_jid() - if app.config.get('show_avatar_in_tabs'): - scale = self.parent_win.window.get_scale_factor() - surface = app.contacts.get_avatar( - self.account, jid, AvatarSize.TAB, scale) - if surface is not None: - return surface - - if count_unread: - num_unread = len(app.events.get_events( - self.account, - jid, - ['printed_%s' % self._type, str(self._type)])) - else: - num_unread = 0 - - transport = None - if app.jid_is_transport(jid): - transport = app.get_transport_name_from_jid(jid) - + def get_tab_image(self): if self.gc_contact.presence.is_unavailable: show = 'offline' else: show = self.gc_contact.show.value - - if num_unread and app.config.get('show_unread_tab_icon'): - icon_name = get_icon_name('event', transport=transport) - else: - icon_name = get_icon_name(show, transport=transport) - - return icon_name + scale = self.parent_win.window.get_scale_factor() + return self.gc_contact.get_avatar(AvatarSize.ROSTER, + scale, + show)
def update_contact(self): self.contact = self.gc_contact.as_contact()
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/1b4a1f089f2bb90b1b0501acd10936fde...