Philipp Hörist pushed to branch master at gajim / gajim
Commits: ae4276a3 by Daniel Brötzmann at 2019-12-13T13:43:41Z RosterTooltip: Improve string length for name, jid, and status
Applies ellipsizing on strings for name, jid, and status messages. Overly long group chat topics will be shortened as well.
- - - - - ee3860e0 by Daniel Brötzmann at 2019-12-13T13:43:41Z RosterTooltip: Shorten contact status messages for multiple resources
This shortens status messages correctly if there is more than one resource. Additionally, this always adds a new line for status messages to keep the tooltip's width small.
- - - - - a378b6b7 by Daniel Brötzmann at 2019-12-13T13:43:42Z GCTooltip: Improve name, jid, and status formatting
- - - - - 98f2e2f6 by Daniel Brötzmann at 2019-12-13T13:43:42Z RosterTooltip: Add hint for Observers group
- - - - - 8adb6ce3 by Daniel Brötzmann at 2019-12-13T13:43:42Z RosterTooltip: Use group chat description for status
- - - - -
4 changed files:
- gajim/data/gui/tooltip_gc_contact.ui - gajim/data/gui/tooltip_roster_contact.ui - gajim/gtk/tooltips.py - gajim/roster_window.py
Changes:
===================================== gajim/data/gui/tooltip_gc_contact.ui ===================================== @@ -24,6 +24,9 @@ <property name="can_focus">False</property> <property name="halign">start</property> <property name="hexpand">True</property> + <property name="ellipsize">end</property> + <property name="single_line_mode">True</property> + <property name="max_width_chars">36</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -40,6 +43,8 @@ <property name="halign">start</property> <property name="valign">start</property> <property name="ellipsize">end</property> + <property name="single_line_mode">True</property> + <property name="max_width_chars">25</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -84,7 +89,9 @@ <property name="valign">start</property> <property name="wrap">True</property> <property name="wrap_mode">word-char</property> - <property name="max_width_chars">25</property> + <property name="ellipsize">end</property> + <property name="max_width_chars">40</property> + <property name="lines">3</property> <property name="xalign">0</property> <attributes> <attribute name="style" value="italic"/>
===================================== gajim/data/gui/tooltip_roster_contact.ui ===================================== @@ -42,6 +42,8 @@ <property name="halign">start</property> <property name="valign">start</property> <property name="hexpand">True</property> + <property name="ellipsize">end</property> + <property name="max_width_chars">36</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -216,7 +218,9 @@ <property name="valign">start</property> <property name="wrap">True</property> <property name="wrap_mode">word-char</property> - <property name="max_width_chars">25</property> + <property name="ellipsize">end</property> + <property name="max_width_chars">40</property> + <property name="lines">3</property> <property name="xalign">0</property> <attributes> <attribute name="style" value="italic"/> @@ -233,8 +237,9 @@ <property name="can_focus">False</property> <property name="halign">start</property> <property name="valign">start</property> - <property name="use_markup">True</property> <property name="ellipsize">end</property> + <property name="single_line_mode">True</property> + <property name="max_width_chars">25</property> <style> <class name="large-header"/> </style>
===================================== gajim/gtk/tooltips.py ===================================== @@ -73,30 +73,21 @@ class StatusTable: self.text_label = Gtk.Label() self.text_label.set_line_wrap(True) self.text_label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR) - self.text_label.set_max_width_chars(25) + self.text_label.set_lines(3) + self.text_label.set_ellipsize(Pango.EllipsizeMode.END) + self.text_label.set_max_width_chars(30) self.text_label.set_halign(Gtk.Align.START) self.text_label.set_valign(Gtk.Align.START) + self.text_label.set_xalign(0) self.text_label.set_selectable(False) - self.text_label.set_markup(text) + + self.text_label.set_text(text) self.table.attach(self.text_label, 1 + col_inc, self.current_row, 3 - col_inc, 1) self.current_row += 1
- @staticmethod - def get_status_info(resource, priority, _show, status): - str_status = resource + ' (' + str(priority) + ')' - if status: - status = status.strip() - if status != '': - # reduce to 100 chars, 1 line - status = helpers.reduce_chars_newlines(status, 100, 1) - str_status = GLib.markup_escape_text(str_status) - status = GLib.markup_escape_text(status) - str_status += ' - <i>' + status + '</i>' - return str_status - def add_status_row(self, show, str_status, show_lock=False, indent=True, transport=None): """ @@ -113,10 +104,15 @@ class StatusTable: self.table.attach(spacer, 1, self.current_row, 1, 1) self.table.attach(image, 2, self.current_row, 1, 1) status_label = Gtk.Label() - status_label.set_markup(str_status) + status_label.set_text(str_status) status_label.set_halign(Gtk.Align.START) status_label.set_valign(Gtk.Align.START) + status_label.set_xalign(0) status_label.set_line_wrap(True) + status_label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR) + status_label.set_lines(3) + status_label.set_ellipsize(Pango.EllipsizeMode.END) + status_label.set_max_width_chars(30) self.table.attach(status_label, 3, self.current_row, 1, 1) if show_lock: lock_image = Gtk.Image() @@ -346,25 +342,15 @@ class RosterTooltip(StatusTable): return self.contact_jid = self.prim_contact.jid name = GLib.markup_escape_text(self.prim_contact.get_shown_name()) - name_markup = '<b>{}</b>'.format(name) + if app.config.get('mergeaccounts'): color = app.config.get('tooltip_account_name_color') account_name = GLib.markup_escape_text( self.prim_contact.account.name) - name_markup += " <span foreground='{}'>({})</span>".format( + name += " <span foreground='{}'>({})</span>".format( color, account_name)
- if account and helpers.jid_is_blocked(account, self.prim_contact.jid): - name_markup += _(' [blocked]') - - try: - controls = app.interface.minimized_controls[account] - if self.prim_contact.jid in controls: - name_markup += _(' [minimized]') - except KeyError: - pass - - self._ui.name.set_markup(name_markup) + self._ui.name.set_markup(name) self._ui.name.show()
self.num_resources = 0 @@ -387,27 +373,26 @@ class RosterTooltip(StatusTable): for priority in contact_keys: for acontact in contacts_dict[priority]: show = self._get_icon_name_for_tooltip(acontact) - if acontact.status and len(acontact.status) > 25: - status = '' - add_text = True - else: - status = acontact.status - add_text = False - - status_line = self.get_status_info( - acontact.resource, - acontact.priority, - acontact.show, - status) - self.add_status_row(show, status_line, transport=transport) - if add_text: - self.add_text_row(acontact.status, 2) + status = acontact.status + resource_line = '%s (%s)' % (acontact.resource, + str(acontact.priority)) + self.add_status_row( + show, resource_line, transport=transport) + if status: + self.add_text_row(status, 2)
self._ui.tooltip_grid.attach(self.table, 1, 3, 2, 1) self.table.show_all()
else: # only one resource - if contact.show and contact.status: + if contact.is_groupchat: + disco_info = app.logger.get_last_disco_info(contact.jid) + if disco_info is not None: + description = disco_info.muc_description + if description: + self._ui.status.set_text(description) + self._ui.status.show() + elif contact.show and contact.status: status = contact.status.strip() if status: self._ui.status.set_text(status)
===================================== gajim/roster_window.py ===================================== @@ -5357,7 +5357,9 @@ class RosterWindow:
def query_tooltip(self, widget, x_pos, y_pos, _keyboard_mode, tooltip): try: - row = widget.get_path_at_pos(x_pos, y_pos)[0] + path = widget.get_path_at_pos(x_pos, y_pos) + row = path[0] + col = path[1] except TypeError: self._roster_tooltip.clear_tooltip() return False @@ -5378,6 +5380,15 @@ class RosterWindow: jid = model[iter_][Column.JID] connected_contacts = []
+ if typ == 'group': + if jid == _('Observers'): + widget.set_tooltip_cell(tooltip, row, col, None) + tooltip.set_text( + _('Observers can see your status, but you ' + 'are not allowed to see theirs')) + return True + return False + if typ in ('contact', 'self_contact'): contacts = app.contacts.get_contacts(account, jid)
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/2b98092681fe46451afad821d8039c8bec...