use Gtk.Grid instead of deprecated Gtk.Table in tooltips
This commit is contained in:
parent
b70d08a513
commit
0ee35f0395
1 changed files with 63 additions and 68 deletions
101
src/tooltips.py
101
src/tooltips.py
|
@ -222,7 +222,10 @@ class StatusTable:
|
||||||
self.spacer_label = ' '
|
self.spacer_label = ' '
|
||||||
|
|
||||||
def create_table(self):
|
def create_table(self):
|
||||||
self.table = Gtk.Table(4, 1)
|
self.table = Gtk.Grid()
|
||||||
|
self.table.insert_row(0)
|
||||||
|
self.table.insert_row(0)
|
||||||
|
self.table.insert_column(0)
|
||||||
self.table.set_property('column-spacing', 2)
|
self.table.set_property('column-spacing', 2)
|
||||||
|
|
||||||
def add_text_row(self, text, col_inc = 0):
|
def add_text_row(self, text, col_inc = 0):
|
||||||
|
@ -232,8 +235,8 @@ class StatusTable:
|
||||||
self.text_label.set_alignment(0, 0)
|
self.text_label.set_alignment(0, 0)
|
||||||
self.text_label.set_selectable(False)
|
self.text_label.set_selectable(False)
|
||||||
self.text_label.set_markup(text)
|
self.text_label.set_markup(text)
|
||||||
self.table.attach(self.text_label, 1 + col_inc, 4, self.current_row,
|
self.table.attach(self.text_label, 1 + col_inc, self.current_row,
|
||||||
self.current_row + 1)
|
3 - col_inc, 1)
|
||||||
|
|
||||||
def get_status_info(self, resource, priority, show, status):
|
def get_status_info(self, resource, priority, show, status):
|
||||||
str_status = resource + ' (' + str(priority) + ')'
|
str_status = resource + ' (' + str(priority) + ')'
|
||||||
|
@ -252,6 +255,8 @@ class StatusTable:
|
||||||
"""
|
"""
|
||||||
Append a new row with status icon to the table
|
Append a new row with status icon to the table
|
||||||
"""
|
"""
|
||||||
|
self.table.insert_row(0)
|
||||||
|
self.table.insert_row(0)
|
||||||
self.current_row += 1
|
self.current_row += 1
|
||||||
state_file = show.replace(' ', '_')
|
state_file = show.replace(' ', '_')
|
||||||
files = []
|
files = []
|
||||||
|
@ -266,22 +271,18 @@ class StatusTable:
|
||||||
spacer = Gtk.Label(label=self.spacer_label)
|
spacer = Gtk.Label(label=self.spacer_label)
|
||||||
image.set_alignment(1, 0.5)
|
image.set_alignment(1, 0.5)
|
||||||
if indent:
|
if indent:
|
||||||
self.table.attach(spacer, 1, 2, self.current_row,
|
self.table.attach(spacer, 1, self.current_row, 1, 1)
|
||||||
self.current_row + 1, 0, 0, 0, 0)
|
self.table.attach(image, 2, self.current_row, 1, 1)
|
||||||
self.table.attach(image, 2, 3, self.current_row,
|
|
||||||
self.current_row + 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL, 2, 0)
|
|
||||||
status_label = Gtk.Label()
|
status_label = Gtk.Label()
|
||||||
status_label.set_markup(str_status)
|
status_label.set_markup(str_status)
|
||||||
status_label.set_alignment(0, 0)
|
status_label.set_alignment(0, 0)
|
||||||
status_label.set_line_wrap(True)
|
status_label.set_line_wrap(True)
|
||||||
self.table.attach(status_label, 3, 4, self.current_row,
|
self.table.attach(status_label, 3, self.current_row, 1, 1)
|
||||||
self.current_row + 1, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 0, 0, 0)
|
|
||||||
if show_lock:
|
if show_lock:
|
||||||
lock_image = Gtk.Image()
|
lock_image = Gtk.Image()
|
||||||
lock_image.set_from_stock(Gtk.STOCK_DIALOG_AUTHENTICATION,
|
lock_image.set_from_stock(Gtk.STOCK_DIALOG_AUTHENTICATION,
|
||||||
Gtk.IconSize.MENU)
|
Gtk.IconSize.MENU)
|
||||||
self.table.attach(lock_image, 4, 5, self.current_row,
|
self.table.attach(lock_image, 4, self.current_row, 1, 1)
|
||||||
self.current_row + 1, 0, 0, 0, 0)
|
|
||||||
|
|
||||||
class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
||||||
"""
|
"""
|
||||||
|
@ -322,7 +323,6 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
||||||
self.create_table()
|
self.create_table()
|
||||||
|
|
||||||
accounts = helpers.get_notification_icon_tooltip_dict()
|
accounts = helpers.get_notification_icon_tooltip_dict()
|
||||||
self.table.resize(2, 1)
|
|
||||||
self.fill_table_with_accounts(accounts)
|
self.fill_table_with_accounts(accounts)
|
||||||
self.hbox = Gtk.HBox()
|
self.hbox = Gtk.HBox()
|
||||||
self.table.set_property('column-spacing', 1)
|
self.table.set_property('column-spacing', 1)
|
||||||
|
@ -349,9 +349,12 @@ class GCTooltip(BaseTooltip):
|
||||||
if not contact:
|
if not contact:
|
||||||
return
|
return
|
||||||
self.create_window()
|
self.create_window()
|
||||||
vcard_table = Gtk.Table(3, 1)
|
vcard_table = Gtk.Grid()
|
||||||
|
vcard_table.insert_row(0)
|
||||||
|
vcard_table.insert_row(0)
|
||||||
|
vcard_table.insert_row(0)
|
||||||
|
vcard_table.insert_column(0)
|
||||||
vcard_table.set_property('column-spacing', 2)
|
vcard_table.set_property('column-spacing', 2)
|
||||||
vcard_table.set_homogeneous(False)
|
|
||||||
vcard_current_row = 1
|
vcard_current_row = 1
|
||||||
properties = []
|
properties = []
|
||||||
|
|
||||||
|
@ -389,8 +392,8 @@ class GCTooltip(BaseTooltip):
|
||||||
# Add avatar
|
# Add avatar
|
||||||
puny_name = helpers.sanitize_filename(contact.name)
|
puny_name = helpers.sanitize_filename(contact.name)
|
||||||
puny_room = helpers.sanitize_filename(contact.room_jid)
|
puny_room = helpers.sanitize_filename(contact.room_jid)
|
||||||
file_ = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_room,
|
file_ = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH,
|
||||||
puny_name))
|
puny_room, puny_name))
|
||||||
if file_:
|
if file_:
|
||||||
self.avatar_image.set_from_file(file_)
|
self.avatar_image.set_from_file(file_)
|
||||||
pix = self.avatar_image.get_pixbuf()
|
pix = self.avatar_image.get_pixbuf()
|
||||||
|
@ -401,31 +404,27 @@ class GCTooltip(BaseTooltip):
|
||||||
while properties:
|
while properties:
|
||||||
property_ = properties.pop(0)
|
property_ = properties.pop(0)
|
||||||
vcard_current_row += 1
|
vcard_current_row += 1
|
||||||
vertical_fill = Gtk.AttachOptions.FILL
|
|
||||||
if not properties:
|
|
||||||
vertical_fill |= Gtk.AttachOptions.EXPAND
|
|
||||||
label = Gtk.Label()
|
label = Gtk.Label()
|
||||||
|
if not properties:
|
||||||
|
label.set_vexpand(True)
|
||||||
label.set_alignment(0, 0)
|
label.set_alignment(0, 0)
|
||||||
if property_[1]:
|
if property_[1]:
|
||||||
label.set_markup(property_[0])
|
label.set_markup(property_[0])
|
||||||
vcard_table.attach(label, 1, 2, vcard_current_row,
|
vcard_table.attach(label, 1, vcard_current_row, 1, 1)
|
||||||
vcard_current_row + 1, Gtk.AttachOptions.FILL, vertical_fill, 0, 0)
|
|
||||||
label = Gtk.Label()
|
label = Gtk.Label()
|
||||||
|
if not properties:
|
||||||
|
label.set_vexpand(True)
|
||||||
label.set_alignment(0, 0)
|
label.set_alignment(0, 0)
|
||||||
label.set_markup(property_[1])
|
label.set_markup(property_[1])
|
||||||
label.set_line_wrap(True)
|
label.set_line_wrap(True)
|
||||||
vcard_table.attach(label, 2, 3, vcard_current_row,
|
vcard_table.attach(label, 2, vcard_current_row, 1, 1)
|
||||||
vcard_current_row + 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
|
|
||||||
vertical_fill, 0, 0)
|
|
||||||
else:
|
else:
|
||||||
label.set_markup(property_[0])
|
label.set_markup(property_[0])
|
||||||
label.set_line_wrap(True)
|
label.set_line_wrap(True)
|
||||||
vcard_table.attach(label, 1, 3, vcard_current_row,
|
vcard_table.attach(label, 1, vcard_current_row, 2, 1)
|
||||||
vcard_current_row + 1, Gtk.AttachOptions.FILL, vertical_fill, 0)
|
|
||||||
|
|
||||||
self.avatar_image.set_alignment(0, 0)
|
self.avatar_image.set_alignment(0, 0)
|
||||||
vcard_table.attach(self.avatar_image, 3, 4, 2, vcard_current_row + 1,
|
vcard_table.attach(self.avatar_image, 3, 2, 1, vcard_current_row - 1)
|
||||||
Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 3, 3)
|
|
||||||
gajim.plugin_manager.gui_extension_point('gc_tooltip_populate',
|
gajim.plugin_manager.gui_extension_point('gc_tooltip_populate',
|
||||||
self, contact, vcard_table)
|
self, contact, vcard_table)
|
||||||
self.win.add(vcard_table)
|
self.win.add(vcard_table)
|
||||||
|
@ -451,7 +450,6 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
if not contacts or len(contacts) == 0:
|
if not contacts or len(contacts) == 0:
|
||||||
# Tooltip for merged accounts row
|
# Tooltip for merged accounts row
|
||||||
accounts = helpers.get_notification_icon_tooltip_dict()
|
accounts = helpers.get_notification_icon_tooltip_dict()
|
||||||
self.table.resize(2, 1)
|
|
||||||
self.spacer_label = ''
|
self.spacer_label = ''
|
||||||
self.fill_table_with_accounts(accounts)
|
self.fill_table_with_accounts(accounts)
|
||||||
self.win.add(self.table)
|
self.win.add(self.table)
|
||||||
|
@ -464,7 +462,8 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
puny_jid = helpers.sanitize_filename(prim_contact.jid)
|
puny_jid = helpers.sanitize_filename(prim_contact.jid)
|
||||||
table_size = 3
|
table_size = 3
|
||||||
|
|
||||||
file_ = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_jid))
|
file_ = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH,
|
||||||
|
puny_jid))
|
||||||
if file_:
|
if file_:
|
||||||
self.avatar_image.set_from_file(file_)
|
self.avatar_image.set_from_file(file_)
|
||||||
pix = self.avatar_image.get_pixbuf()
|
pix = self.avatar_image.get_pixbuf()
|
||||||
|
@ -473,9 +472,11 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
table_size = 4
|
table_size = 4
|
||||||
else:
|
else:
|
||||||
self.avatar_image.set_from_pixbuf(None)
|
self.avatar_image.set_from_pixbuf(None)
|
||||||
vcard_table = Gtk.Table(1,table_size)
|
vcard_table = Gtk.Grid()
|
||||||
|
vcard_table.insert_row(0)
|
||||||
|
for i in range(0, table_size):
|
||||||
|
vcard_table.insert_column(0)
|
||||||
vcard_table.set_property('column-spacing', 2)
|
vcard_table.set_property('column-spacing', 2)
|
||||||
vcard_table.set_homogeneous(False)
|
|
||||||
vcard_current_row = 1
|
vcard_current_row = 1
|
||||||
properties = []
|
properties = []
|
||||||
|
|
||||||
|
@ -508,8 +509,7 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
|
|
||||||
if num_resources > 1:
|
if num_resources > 1:
|
||||||
properties.append((_('Status: '), ' '))
|
properties.append((_('Status: '), ' '))
|
||||||
transport = gajim.get_transport_name_from_jid(
|
transport = gajim.get_transport_name_from_jid(prim_contact.jid)
|
||||||
prim_contact.jid)
|
|
||||||
if transport:
|
if transport:
|
||||||
file_path = os.path.join(helpers.get_transport_path(transport),
|
file_path = os.path.join(helpers.get_transport_path(transport),
|
||||||
'16x16')
|
'16x16')
|
||||||
|
@ -538,12 +538,13 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
if not self.check_last_time and self.account:
|
if not self.check_last_time and self.account:
|
||||||
if contact.show == 'offline':
|
if contact.show == 'offline':
|
||||||
if not contact.last_status_time:
|
if not contact.last_status_time:
|
||||||
gajim.connections[self.account].request_last_status_time(
|
gajim.connections[self.account].\
|
||||||
contact.jid, '')
|
request_last_status_time(contact.jid, '')
|
||||||
else:
|
else:
|
||||||
self.check_last_time = contact.last_status_time
|
self.check_last_time = contact.last_status_time
|
||||||
elif contact.resource:
|
elif contact.resource:
|
||||||
gajim.connections[self.account].request_last_status_time(
|
gajim.connections[self.account].\
|
||||||
|
request_last_status_time(
|
||||||
contact.jid, contact.resource)
|
contact.jid, contact.resource)
|
||||||
if contact.last_activity_time:
|
if contact.last_activity_time:
|
||||||
self.check_last_time = contact.last_activity_time
|
self.check_last_time = contact.last_activity_time
|
||||||
|
@ -580,7 +581,8 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
status = contact.status.strip()
|
status = contact.status.strip()
|
||||||
if status:
|
if status:
|
||||||
# reduce long status
|
# reduce long status
|
||||||
# (no more than 300 chars on line and no more than 5 lines)
|
# (no more than 300 chars on line and no more than
|
||||||
|
# 5 lines)
|
||||||
# status is wrapped
|
# status is wrapped
|
||||||
status = helpers.reduce_chars_newlines(status, 300, 5)
|
status = helpers.reduce_chars_newlines(status, 300, 5)
|
||||||
# escape markup entities.
|
# escape markup entities.
|
||||||
|
@ -641,37 +643,30 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
while properties:
|
while properties:
|
||||||
property_ = properties.pop(0)
|
property_ = properties.pop(0)
|
||||||
vcard_current_row += 1
|
vcard_current_row += 1
|
||||||
vertical_fill = Gtk.AttachOptions.FILL
|
|
||||||
if not properties and table_size == 4:
|
|
||||||
vertical_fill |= Gtk.AttachOptions.EXPAND
|
|
||||||
label = Gtk.Label()
|
label = Gtk.Label()
|
||||||
|
if not properties and table_size == 4:
|
||||||
|
label.set_vexpand(True)
|
||||||
label.set_alignment(0, 0)
|
label.set_alignment(0, 0)
|
||||||
if property_[1]:
|
if property_[1]:
|
||||||
label.set_markup(property_[0])
|
label.set_markup(property_[0])
|
||||||
vcard_table.attach(label, 1, 2, vcard_current_row,
|
vcard_table.attach(label, 1, vcard_current_row, 1, 1)
|
||||||
vcard_current_row + 1, Gtk.AttachOptions.FILL,
|
|
||||||
vertical_fill, 0, 0)
|
|
||||||
label = Gtk.Label()
|
label = Gtk.Label()
|
||||||
|
if not properties and table_size == 4:
|
||||||
|
label.set_vexpand(True)
|
||||||
label.set_alignment(0, 0)
|
label.set_alignment(0, 0)
|
||||||
label.set_markup(property_[1])
|
label.set_markup(property_[1])
|
||||||
label.set_line_wrap(True)
|
label.set_line_wrap(True)
|
||||||
vcard_table.attach(label, 2, 3, vcard_current_row,
|
vcard_table.attach(label, 2, vcard_current_row, 1, 1)
|
||||||
vcard_current_row + 1, Gtk.AttachOptions.EXPAND | \
|
|
||||||
Gtk.AttachOptions.FILL, vertical_fill, 0, 0)
|
|
||||||
else:
|
else:
|
||||||
if isinstance(property_[0], str):
|
if isinstance(property_[0], str):
|
||||||
label.set_markup(property_[0])
|
label.set_markup(property_[0])
|
||||||
label.set_line_wrap(True)
|
label.set_line_wrap(True)
|
||||||
else:
|
else:
|
||||||
label = property_[0]
|
label = property_[0]
|
||||||
vcard_table.attach(label, 1, 3, vcard_current_row,
|
vcard_table.attach(label, 1, vcard_current_row, 2, 1)
|
||||||
vcard_current_row + 1, Gtk.AttachOptions.FILL,
|
|
||||||
vertical_fill, 0)
|
|
||||||
self.avatar_image.set_alignment(0, 0)
|
self.avatar_image.set_alignment(0, 0)
|
||||||
if table_size == 4:
|
if table_size == 4:
|
||||||
vcard_table.attach(self.avatar_image, 3, 4, 2,
|
vcard_table.attach(self.avatar_image, 3, 2, 1, vcard_current_row - 1)
|
||||||
vcard_current_row + 1, Gtk.AttachOptions.FILL,
|
|
||||||
Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 3, 3)
|
|
||||||
|
|
||||||
gajim.plugin_manager.gui_extension_point('roster_tooltip_populate',
|
gajim.plugin_manager.gui_extension_point('roster_tooltip_populate',
|
||||||
self, contacts, vcard_table)
|
self, contacts, vcard_table)
|
||||||
|
|
Loading…
Add table
Reference in a new issue