Update look on GCTooltip and RosterTooltip

This commit is contained in:
Daniel Brötzmann 2018-11-07 23:07:26 +01:00 committed by Philipp Hörist
parent bd7e32187d
commit 13c82ae777
3 changed files with 148 additions and 217 deletions

View file

@ -1,59 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 --> <!-- Generated with glade 3.22.1 -->
<interface> <interface>
<requires lib="gtk+" version="3.12"/> <requires lib="gtk+" version="3.20"/>
<object class="GtkGrid" id="tooltip_grid"> <object class="GtkGrid" id="tooltip_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="column_spacing">5</property> <property name="column_spacing">6</property>
<child>
<object class="GtkLabel" id="nick">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="status">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<property name="max_width_chars">40</property>
<attributes>
<attribute name="style" value="italic"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="jid_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Jabber ID:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child> <child>
<object class="GtkImage" id="avatar"> <object class="GtkImage" id="avatar">
<property name="visible">True</property> <property name="visible">True</property>
@ -61,73 +13,9 @@
<property name="stock">gtk-missing-image</property> <property name="stock">gtk-missing-image</property>
</object> </object>
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">0</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="height">7</property> <property name="height">6</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="resource_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Resource:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="affiliation">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="user_show">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="fillelement">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="vexpand">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="resource">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -140,10 +28,84 @@
<attribute name="weight" value="bold"/> <attribute name="weight" value="bold"/>
</attributes> </attributes>
</object> </object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="nick">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="ellipsize">end</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
<style>
<class name="large-header"/>
</style>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="user_show">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
</object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">3</property> <property name="top_attach">3</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel" id="fillelement">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="vexpand">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="status">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<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="xalign">0</property>
<attributes>
<attribute name="style" value="italic"/>
</attributes>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="affiliation">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
</object> </object>
</interface> </interface>

View file

@ -1,56 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 --> <!-- Generated with glade 3.22.1 -->
<interface> <interface>
<requires lib="gtk+" version="3.12"/> <requires lib="gtk+" version="3.20"/>
<object class="GtkGrid" id="tooltip_grid"> <object class="GtkGrid" id="tooltip_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="column_spacing">5</property> <property name="border_width">6</property>
<child> <property name="row_spacing">3</property>
<object class="GtkLabel" id="name"> <property name="column_spacing">12</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="jid_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Jabber ID:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkImage" id="avatar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
<property name="height">13</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="resource_label"> <object class="GtkLabel" id="resource_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">end</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="label" translatable="yes">Resource:</property> <property name="label" translatable="yes">Resource:</property>
</object> </object>
@ -59,19 +22,6 @@
<property name="top_attach">5</property> <property name="top_attach">5</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel" id="user_show">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">2</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="resource"> <object class="GtkLabel" id="resource">
<property name="visible">True</property> <property name="visible">True</property>
@ -98,29 +48,14 @@
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">4</property> <property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="status_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Status:</property>
<property name="wrap">True</property>
<property name="max_width_chars">40</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="idle_since_label"> <object class="GtkLabel" id="idle_since_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">end</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="label" translatable="yes">Idle since:</property> <property name="label" translatable="yes">Idle since:</property>
</object> </object>
@ -146,7 +81,7 @@
<object class="GtkLabel" id="mood_label"> <object class="GtkLabel" id="mood_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">end</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="label" translatable="yes">Mood:</property> <property name="label" translatable="yes">Mood:</property>
</object> </object>
@ -159,7 +94,7 @@
<object class="GtkLabel" id="activity_label"> <object class="GtkLabel" id="activity_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">end</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="label" translatable="yes">Activity:</property> <property name="label" translatable="yes">Activity:</property>
<property name="lines">2</property> <property name="lines">2</property>
@ -173,7 +108,7 @@
<object class="GtkLabel" id="tune_label"> <object class="GtkLabel" id="tune_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">end</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="label" translatable="yes">Tune:</property> <property name="label" translatable="yes">Tune:</property>
</object> </object>
@ -186,7 +121,7 @@
<object class="GtkLabel" id="location_label"> <object class="GtkLabel" id="location_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">end</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="label" translatable="yes">Location:</property> <property name="label" translatable="yes">Location:</property>
</object> </object>
@ -212,6 +147,7 @@
<object class="GtkLabel" id="activity"> <object class="GtkLabel" id="activity">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
</object> </object>
@ -250,7 +186,7 @@
<object class="GtkLabel" id="pgp_label"> <object class="GtkLabel" id="pgp_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">end</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="label" translatable="yes">OpenPGP:</property> <property name="label" translatable="yes">OpenPGP:</property>
</object> </object>
@ -276,7 +212,7 @@
<object class="GtkLabel" id="sub_label"> <object class="GtkLabel" id="sub_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">end</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="label" translatable="yes">Subscription:</property> <property name="label" translatable="yes">Subscription:</property>
</object> </object>
@ -304,20 +240,62 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="hexpand">True</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="max_width_chars">30</property> <property name="wrap_mode">word-char</property>
<property name="max_width_chars">25</property>
<property name="xalign">0</property>
<attributes> <attributes>
<attribute name="style" value="italic"/> <attribute name="style" value="italic"/>
</attributes> </attributes>
</object> </object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="name">
<property name="visible">True</property>
<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>
<style>
<class name="large-header"/>
</style>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="user_show">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="vexpand">True</property>
</object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">2</property> <property name="top_attach">2</property>
</packing> </packing>
</child> </child>
<child> <child>
<placeholder/> <object class="GtkImage" id="avatar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="stock">gtk-missing-image</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="height">5</property>
</packing>
</child> </child>
<child> <child>
<placeholder/> <placeholder/>

View file

@ -61,14 +61,14 @@ class StatusTable:
def create_table(self): def create_table(self):
self.table = Gtk.Grid() self.table = Gtk.Grid()
self.table.insert_column(0) self.table.insert_column(0)
self.table.set_property('column-spacing', 2) self.table.set_property('column-spacing', 3)
def add_text_row(self, text, col_inc=0): def add_text_row(self, text, col_inc=0):
self.table.insert_row(self.current_row) self.table.insert_row(self.current_row)
self.text_label = Gtk.Label() self.text_label = Gtk.Label()
self.text_label.set_line_wrap(True) self.text_label.set_line_wrap(True)
self.text_label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR) self.text_label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
self.text_label.set_max_width_chars(35) self.text_label.set_max_width_chars(25)
self.text_label.set_halign(Gtk.Align.START) self.text_label.set_halign(Gtk.Align.START)
self.text_label.set_valign(Gtk.Align.START) self.text_label.set_valign(Gtk.Align.START)
self.text_label.set_selectable(False) self.text_label.set_selectable(False)
@ -212,12 +212,6 @@ class GCTooltip():
if contact.jid.strip(): if contact.jid.strip():
self._ui.jid.set_text(contact.jid) self._ui.jid.set_text(contact.jid)
self._ui.jid.show() self._ui.jid.show()
self._ui.jid_label.show()
# Resource
if hasattr(contact, 'resource') and contact.resource.strip():
self._ui.resource.set_text(contact.resource)
self._ui.resource.show()
self._ui.resource_label.show()
# Affiliation # Affiliation
if contact.affiliation != 'none': if contact.affiliation != 'none':
@ -292,7 +286,7 @@ class RosterTooltip(Gtk.Window, StatusTable):
""" """
for child in self._ui.tooltip_grid.get_children(): for child in self._ui.tooltip_grid.get_children():
child.hide() child.hide()
status_table = self._ui.tooltip_grid.get_child_at(0, 3) status_table = self._ui.tooltip_grid.get_child_at(1, 3)
if status_table: if status_table:
status_table.destroy() status_table.destroy()
self.create_table() self.create_table()
@ -313,7 +307,7 @@ class RosterTooltip(Gtk.Window, StatusTable):
accounts = helpers.get_notification_icon_tooltip_dict() accounts = helpers.get_notification_icon_tooltip_dict()
self.spacer_label = '' self.spacer_label = ''
self.fill_table_with_accounts(accounts) self.fill_table_with_accounts(accounts)
self._ui.tooltip_grid.attach(self.table, 0, 3, 2, 1) self._ui.tooltip_grid.attach(self.table, 1, 3, 2, 1)
self.table.show_all() self.table.show_all()
return return
@ -381,7 +375,6 @@ class RosterTooltip(Gtk.Window, StatusTable):
else: else:
contacts_dict[priority] = [contact] contacts_dict[priority] = [contact]
if self.num_resources > 1: if self.num_resources > 1:
self._ui.status_label.show()
transport = app.get_transport_name_from_jid(self.prim_contact.jid) transport = app.get_transport_name_from_jid(self.prim_contact.jid)
if transport == 'jabber': if transport == 'jabber':
transport = None transport = None
@ -406,7 +399,7 @@ class RosterTooltip(Gtk.Window, StatusTable):
if add_text: if add_text:
self.add_text_row(acontact.status, 2) self.add_text_row(acontact.status, 2)
self._ui.tooltip_grid.attach(self.table, 0, 3, 2, 1) self._ui.tooltip_grid.attach(self.table, 1, 3, 2, 1)
self.table.show_all() self.table.show_all()
else: # only one resource else: # only one resource
@ -415,7 +408,6 @@ class RosterTooltip(Gtk.Window, StatusTable):
if status: if status:
self._ui.status.set_text(status) self._ui.status.set_text(status)
self._ui.status.show() self._ui.status.show()
self._ui.status_label.show()
# PEP Info # PEP Info
self._append_pep_info(contact) self._append_pep_info(contact)
@ -423,7 +415,6 @@ class RosterTooltip(Gtk.Window, StatusTable):
# JID # JID
self._ui.jid.set_text(self.prim_contact.jid) self._ui.jid.set_text(self.prim_contact.jid)
self._ui.jid.show() self._ui.jid.show()
self._ui.jid_label.show()
# contact has only one resource # contact has only one resource
if self.num_resources == 1 and contact.resource: if self.num_resources == 1 and contact.resource:
@ -468,12 +459,12 @@ class RosterTooltip(Gtk.Window, StatusTable):
'roster_tooltip_populate', self, contacts, self._ui.tooltip_grid) 'roster_tooltip_populate', self, contacts, self._ui.tooltip_grid)
# Sets the Widget that is at the bottom to expand. # Sets the Widget that is at the bottom to expand.
# This is needed in case the Picture takes more Space then the Labels # This is needed in case the Picture takes more Space than the Labels
i = 1 i = 1
while i < 15: while i < 15:
if self._ui.tooltip_grid.get_child_at(0, i): if self._ui.tooltip_grid.get_child_at(1, i):
if self._ui.tooltip_grid.get_child_at(0, i).get_visible(): if self._ui.tooltip_grid.get_child_at(1, i).get_visible():
self.last_widget = self._ui.tooltip_grid.get_child_at(0, i) self.last_widget = self._ui.tooltip_grid.get_child_at(1, i)
i += 1 i += 1
self.last_widget.set_vexpand(True) self.last_widget.set_vexpand(True)