Philipp Hörist pushed to branch mainwindow at gajim / gajim
Commits: d281c428 by lovetox at 2021-01-18T22:27:53+01:00 Account Side Bar
- - - - -
4 changed files:
- gajim/common/const.py - gajim/data/gui/main.ui - + gajim/gtk/account_side_bar.py - gajim/gtk/main.py
Changes:
===================================== gajim/common/const.py ===================================== @@ -17,6 +17,7 @@ class AvatarSize(IntEnum): TAB = 16 ROSTER = 32 + ACCOUNT_SIDE_BAR = 32 CHAT = 48 NOTIFICATION = 48 GROUP_INFO = 100
===================================== gajim/data/gui/main.ui ===================================== @@ -8,7 +8,46 @@ <property name="hexpand">True</property> <property name="vexpand">True</property> <child> - <object class="GtkGrid" id="left_grid"> + <object class="GtkGrid" id="right_grid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkGrid" id="middle_grid"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="vexpand">True</property> @@ -56,22 +95,25 @@ </child> </object> <packing> - <property name="left_attach">0</property> + <property name="left_attach">1</property> <property name="top_attach">0</property> </packing> </child> <child> - <object class="GtkGrid" id="right_grid"> + <object class="GtkGrid" id="left_grid"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> + <property name="valign">end</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> <child> <placeholder/> </child> </object> <packing> - <property name="left_attach">1</property> + <property name="left_attach">0</property> <property name="top_attach">0</property> </packing> </child>
===================================== gajim/gtk/account_side_bar.py ===================================== @@ -0,0 +1,37 @@ + +from gi.repository import Gtk +from gajim.common.const import AvatarSize +from gajim.common import app + + +class AccountSideBar(Gtk.ListBox): + def __init__(self): + Gtk.ListBox.__init__(self) + self.set_vexpand(True) + + self._accounts = list(app.connections.keys()) + for account in self._accounts: + self.add_account(account) + + def add_account(self, account): + self.add(Account(account)) + + def remove_account(self, account): + pass + + +class Account(Gtk.ListBoxRow): + def __init__(self, account): + Gtk.ListBoxRow.__init__(self) + + self._account = account + self._jid = app.get_jid_from_account(account) + contact = app.contacts.create_contact(self._jid, account) + + scale = self.get_scale_factor() + surface = app.interface.get_avatar(contact, + AvatarSize.ACCOUNT_SIDE_BAR, + scale) + self._image = Gtk.Image.new_from_surface(surface) + self.add(self._image) + self.show_all()
===================================== gajim/gtk/main.py ===================================== @@ -5,6 +5,7 @@ from gajim.gui.util import get_builder from gajim.gui.chat_list_stack import ChatListStack from gajim.gui.chat_stack import ChatStack +from gajim.gui.account_side_bar import AccountSideBar
class MainWindow(Gtk.ApplicationWindow): @@ -28,8 +29,9 @@ def __init__(self):
self._chat_stack = ChatStack() self._chat_list_stack = ChatListStack(self._ui, self._chat_stack) - - self._ui.left_grid.add(self._chat_list_stack) + self._account_side_bar = AccountSideBar() + self._ui.left_grid.add(self._account_side_bar) + self._ui.middle_grid.add(self._chat_list_stack) self._ui.right_grid.add(self._chat_stack) self._ui.connect_signals(self)
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/d281c4282f5b4a6221baf84bd7c41e116...