Philipp Hörist pushed to branch mainwindow at gajim / gajim

Commits:

4 changed files:

Changes:

  • gajim/common/const.py
    ... ... @@ -17,6 +17,7 @@
    17 17
     class AvatarSize(IntEnum):
    
    18 18
         TAB = 16
    
    19 19
         ROSTER = 32
    
    20
    +    ACCOUNT_SIDE_BAR = 32
    
    20 21
         CHAT = 48
    
    21 22
         NOTIFICATION = 48
    
    22 23
         GROUP_INFO = 100
    

  • gajim/data/gui/main.ui
    ... ... @@ -8,7 +8,46 @@
    8 8
         <property name="hexpand">True</property>
    
    9 9
         <property name="vexpand">True</property>
    
    10 10
         <child>
    
    11
    -      <object class="GtkGrid" id="left_grid">
    
    11
    +      <object class="GtkGrid" id="right_grid">
    
    12
    +        <property name="visible">True</property>
    
    13
    +        <property name="can_focus">False</property>
    
    14
    +        <property name="hexpand">True</property>
    
    15
    +        <property name="vexpand">True</property>
    
    16
    +        <child>
    
    17
    +          <placeholder/>
    
    18
    +        </child>
    
    19
    +        <child>
    
    20
    +          <placeholder/>
    
    21
    +        </child>
    
    22
    +        <child>
    
    23
    +          <placeholder/>
    
    24
    +        </child>
    
    25
    +        <child>
    
    26
    +          <placeholder/>
    
    27
    +        </child>
    
    28
    +        <child>
    
    29
    +          <placeholder/>
    
    30
    +        </child>
    
    31
    +        <child>
    
    32
    +          <placeholder/>
    
    33
    +        </child>
    
    34
    +        <child>
    
    35
    +          <placeholder/>
    
    36
    +        </child>
    
    37
    +        <child>
    
    38
    +          <placeholder/>
    
    39
    +        </child>
    
    40
    +        <child>
    
    41
    +          <placeholder/>
    
    42
    +        </child>
    
    43
    +      </object>
    
    44
    +      <packing>
    
    45
    +        <property name="left_attach">2</property>
    
    46
    +        <property name="top_attach">0</property>
    
    47
    +      </packing>
    
    48
    +    </child>
    
    49
    +    <child>
    
    50
    +      <object class="GtkGrid" id="middle_grid">
    
    12 51
             <property name="visible">True</property>
    
    13 52
             <property name="can_focus">False</property>
    
    14 53
             <property name="vexpand">True</property>
    
    ... ... @@ -56,22 +95,25 @@
    56 95
             </child>
    
    57 96
           </object>
    
    58 97
           <packing>
    
    59
    -        <property name="left_attach">0</property>
    
    98
    +        <property name="left_attach">1</property>
    
    60 99
             <property name="top_attach">0</property>
    
    61 100
           </packing>
    
    62 101
         </child>
    
    63 102
         <child>
    
    64
    -      <object class="GtkGrid" id="right_grid">
    
    103
    +      <object class="GtkGrid" id="left_grid">
    
    65 104
             <property name="visible">True</property>
    
    66 105
             <property name="can_focus">False</property>
    
    67
    -        <property name="hexpand">True</property>
    
    68
    -        <property name="vexpand">True</property>
    
    106
    +        <property name="valign">end</property>
    
    107
    +        <property name="orientation">vertical</property>
    
    108
    +        <child>
    
    109
    +          <placeholder/>
    
    110
    +        </child>
    
    69 111
             <child>
    
    70 112
               <placeholder/>
    
    71 113
             </child>
    
    72 114
           </object>
    
    73 115
           <packing>
    
    74
    -        <property name="left_attach">1</property>
    
    116
    +        <property name="left_attach">0</property>
    
    75 117
             <property name="top_attach">0</property>
    
    76 118
           </packing>
    
    77 119
         </child>
    

  • gajim/gtk/account_side_bar.py
    1
    +
    
    2
    +from gi.repository import Gtk
    
    3
    +from gajim.common.const import AvatarSize
    
    4
    +from gajim.common import app
    
    5
    +
    
    6
    +
    
    7
    +class AccountSideBar(Gtk.ListBox):
    
    8
    +    def __init__(self):
    
    9
    +        Gtk.ListBox.__init__(self)
    
    10
    +        self.set_vexpand(True)
    
    11
    +
    
    12
    +        self._accounts = list(app.connections.keys())
    
    13
    +        for account in self._accounts:
    
    14
    +            self.add_account(account)
    
    15
    +
    
    16
    +    def add_account(self, account):
    
    17
    +        self.add(Account(account))
    
    18
    +
    
    19
    +    def remove_account(self, account):
    
    20
    +        pass
    
    21
    +
    
    22
    +
    
    23
    +class Account(Gtk.ListBoxRow):
    
    24
    +    def __init__(self, account):
    
    25
    +        Gtk.ListBoxRow.__init__(self)
    
    26
    +
    
    27
    +        self._account = account
    
    28
    +        self._jid = app.get_jid_from_account(account)
    
    29
    +        contact = app.contacts.create_contact(self._jid, account)
    
    30
    +
    
    31
    +        scale = self.get_scale_factor()
    
    32
    +        surface = app.interface.get_avatar(contact,
    
    33
    +                                           AvatarSize.ACCOUNT_SIDE_BAR,
    
    34
    +                                           scale)
    
    35
    +        self._image = Gtk.Image.new_from_surface(surface)
    
    36
    +        self.add(self._image)
    
    37
    +        self.show_all()

  • gajim/gtk/main.py
    ... ... @@ -5,6 +5,7 @@
    5 5
     from gajim.gui.util import get_builder
    
    6 6
     from gajim.gui.chat_list_stack import ChatListStack
    
    7 7
     from gajim.gui.chat_stack import ChatStack
    
    8
    +from gajim.gui.account_side_bar import AccountSideBar
    
    8 9
     
    
    9 10
     
    
    10 11
     class MainWindow(Gtk.ApplicationWindow):
    
    ... ... @@ -28,8 +29,9 @@ def __init__(self):
    28 29
     
    
    29 30
             self._chat_stack = ChatStack()
    
    30 31
             self._chat_list_stack = ChatListStack(self._ui, self._chat_stack)
    
    31
    -
    
    32
    -        self._ui.left_grid.add(self._chat_list_stack)
    
    32
    +        self._account_side_bar = AccountSideBar()
    
    33
    +        self._ui.left_grid.add(self._account_side_bar)
    
    34
    +        self._ui.middle_grid.add(self._chat_list_stack)
    
    33 35
             self._ui.right_grid.add(self._chat_stack)
    
    34 36
             self._ui.connect_signals(self)
    
    35 37