Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits: 04d02dc3 by Daniel Brötzmann at 2021-03-10T17:05:04+01:00 AccountPage: Add avatar and profile button
- - - - -
3 changed files:
- gajim/common/const.py - gajim/data/gui/account_page.ui - gajim/gtk/account_page.py
Changes:
===================================== gajim/common/const.py ===================================== @@ -33,6 +33,7 @@ class AvatarSize(IntEnum): NOTIFICATION = 48 GROUP_INFO = 100 TOOLTIP = 100 + ACCOUNT_PAGE = 150 VCARD = 200 PUBLISH = 200
===================================== gajim/data/gui/account_page.ui ===================================== @@ -128,11 +128,54 @@ <object class="GtkBox"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="spacing">12</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> @@ -140,15 +183,29 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">0</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"> @@ -161,19 +218,19 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</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">0</property> + <property name="position">1</property> </packing> </child> - <child> - <placeholder/> - </child> <style> <class name="account-page-box"/> </style>
===================================== gajim/gtk/account_page.py ===================================== @@ -16,6 +16,7 @@ from gi.repository import Gtk
from gajim.common import app +from gajim.common.const import AvatarSize from gajim.common.i18n import _
from .roster import Roster @@ -32,13 +33,16 @@ class AccountPage(Gtk.Box): def __init__(self, account): Gtk.Box.__init__(self) self._account = account + self._jid = app.get_jid_from_account(account) + client = app.get_client(account) + self._contact = client.get_module('Contacts').get_contact(self._jid)
self._ui = get_builder('account_page.ui') self.add(self._ui.paned)
self._status_selector = StatusSelector() self._status_selector.set_halign(Gtk.Align.CENTER) - self._ui.account_box.add(self._status_selector) + self._ui.account_action_box.add(self._status_selector)
self._roster = Roster(account) self._ui.roster_box.add(self._roster) @@ -56,6 +60,9 @@ def __init__(self, account):
self.update()
+ def _on_edit_profile(self, _button): + open_window('ProfileWindow', account=self._account) + def _on_account_settings(self, _button): window = open_window('AccountsWindow') window.select_account(self._account) @@ -78,6 +85,12 @@ def update(self): account_label = app.settings.get_account_setting( self._account, 'account_label') self._ui.account_label.set_text(account_label) + + surface = self._contact.get_avatar(AvatarSize.ACCOUNT_PAGE, + self.get_scale_factor(), + add_show=False) + self._ui.avatar_image.set_from_surface(surface) + self._status_selector.update()
def process_event(self, event):
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/04d02dc3e0b1ab867c1a7fa56fcaa393e...