Skip to content
Snippets Groups Projects
Commit dd28c7d3 authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist
Browse files

Accounts: Add basic account page

parent 311c96cf
No related branches found
No related tags found
No related merge requests found
......@@ -131,230 +131,239 @@
</packing>
</child>
<child>
<object class="GtkPaned" id="paned">
<object class="GtkStack" id="main_stack">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="position">250</property>
<property name="position-set">True</property>
<property name="can-focus">False</property>
<child>
<!-- n-columns=3 n-rows=3 -->
<object class="GtkGrid" id="middle_grid">
<object class="GtkPaned" id="paned">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="can-focus">True</property>
<property name="position">250</property>
<property name="position-set">True</property>
<child>
<!-- n-columns=1 n-rows=3 -->
<object class="GtkGrid">
<!-- n-columns=3 n-rows=3 -->
<object class="GtkGrid" id="middle_grid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="row-spacing">3</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<!-- n-columns=1 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">12</property>
<property name="row-spacing">3</property>
<child>
<object class="GtkLabel" id="workspace_label">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label">Workspace Label</property>
<property name="ellipsize">end</property>
<style>
<class name="large-header"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="edit_workspace_button">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Edit Workspace</property>
<property name="relief">none</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage">
<object class="GtkLabel" id="workspace_label">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">document-edit-symbolic</property>
<property name="label">Workspace Label</property>
<property name="ellipsize">end</property>
<style>
<class name="large-header"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="edit_workspace_button">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Edit Workspace</property>
<property name="relief">none</property>
<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>
<style>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">1</property>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<property name="margin-top">12</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkSearchEntry" id="search_entry">
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="primary-icon-name">edit-find-symbolic</property>
<property name="primary-icon-activatable">False</property>
<property name="primary-icon-sensitive">False</property>
<property name="placeholder-text" translatable="yes">Search…</property>
<property name="can-focus">False</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<property name="margin-top">12</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="start_chat_button">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Start Chat</property>
<property name="can-focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage">
<object class="GtkSearchEntry" id="search_entry">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">list-add-symbolic</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="primary-icon-name">edit-find-symbolic</property>
<property name="primary-icon-activatable">False</property>
<property name="primary-icon-sensitive">False</property>
<property name="placeholder-text" translatable="yes">Search…</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="start_chat_button">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Start Chat</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">list-add-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<style>
<class name="chatlist-top-bar"/>
</style>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="chat_list_scrolled">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<placeholder/>
</child>
<style>
<class name="no-border"/>
</style>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<style>
<class name="chatlist-top-bar"/>
<class name="middle-grid"/>
</style>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="chat_list_scrolled">
<!-- n-columns=3 n-rows=3 -->
<object class="GtkGrid" id="right_grid">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</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>
<style>
<class name="no-border"/>
</style>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<style>
<class name="middle-grid"/>
</style>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<!-- n-columns=3 n-rows=3 -->
<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="resize">True</property>
<property name="shrink">True</property>
<property name="name">chats</property>
</packing>
</child>
</object>
......
......@@ -117,6 +117,10 @@ .account-box > separator {
background-color: darker(@theme_bg_color);
margin: 0px 12px 0px 12px;
}
/* Account Page */
.account-page {
background: @theme_bg_color;
}
/*Middle Grid*/
.middle-grid > scrolledwindow { background: transparent; }
......
# This file is part of Gajim.
#
# Gajim is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; version 3 only.
#
# Gajim is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
from gi.repository import Gtk
from gajim.common import app
from gajim.common.i18n import _
from .status_selector import StatusSelector
from .util import open_window
class AccountPage(Gtk.Box):
def __init__(self, account):
Gtk.Box.__init__(self)
self.get_style_context().add_class('account-page')
self._account = account
self._account_label = Gtk.Label()
self._account_label.get_style_context().add_class('large-header')
self._status_selector = StatusSelector()
self._status_selector.set_halign(Gtk.Align.CENTER)
settings_button = Gtk.Button(label=_('Settings'))
settings_button.set_halign(Gtk.Align.CENTER)
settings_button.connect('clicked', self._on_settings)
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=18)
box.set_halign(Gtk.Align.CENTER)
box.set_valign(Gtk.Align.CENTER)
box.set_hexpand(True)
box.add(self._account_label)
box.add(settings_button)
box.add(self._status_selector)
self.add(box)
self.show_all()
self.update()
def _on_settings(self, _button):
window = open_window('AccountsWindow')
window.select_account(self._account)
def update(self):
account_label = app.settings.get_account_setting(
self._account, 'account_label')
self._account_label.set_text(account_label)
self._status_selector.update()
from gi.repository import GLib
from gi.repository import Gtk
from gajim.common.const import AvatarSize
from gajim.common import app
from gajim.common.i18n import _
......@@ -11,6 +13,7 @@ def __init__(self):
self.set_vexpand(True)
self.set_valign(Gtk.Align.END)
self.get_style_context().add_class('account-sidebar')
self.connect('row-activated', self._on_row_activated)
self._accounts = list(app.connections.keys())
for account in self._accounts:
......@@ -22,41 +25,71 @@ def add_account(self, account):
def remove_account(self, account):
pass
def _on_row_activated(self, _listbox, row):
main_window = self.get_toplevel()
main_window.activate_action(
'activate-account-page', GLib.Variant('s', row.account))
def activate_account_page(self, account):
row = self.get_selected_row()
if row is not None and row.account == account:
return
self.select_row(row)
class Account(Gtk.ListBoxRow):
def __init__(self, account):
Gtk.ListBoxRow.__init__(self)
self.get_style_context().add_class('account-sidebar-item')
self.set_selectable(False)
image = AccountAvatar(account)
account_color_bar = Gtk.Box()
account_color_bar.set_size_request(6, -1)
account_class = app.css_config.get_dynamic_class(account)
account_color_bar.get_style_context().add_class(account_class)
account_color_bar.get_style_context().add_class(
self.account = account
self._account_class = None
self._image = AccountAvatar(account)
self._account_color_bar = Gtk.Box()
self._account_color_bar.set_size_request(6, -1)
self._account_color_bar.get_style_context().add_class(
'account-identifier-bar')
account_box = Gtk.Box(spacing=6)
account_box.set_tooltip_text(
_('Account: %s') % app.get_account_label(account))
account_box.add(account_color_bar)
account_box.add(image)
account_box.add(self._account_color_bar)
account_box.add(self._image)
self._update_account_color()
self.add(account_box)
self.show_all()
def _update_account_color(self):
context = self._account_color_bar.get_style_context()
if self._account_class is not None:
context.remove_class(self._account_class)
self._account_class = app.css_config.get_dynamic_class(self.account)
context.add_class(self._account_class)
def update(self):
self._update_account_color()
self._image.update()
class AccountAvatar(Gtk.Image):
def __init__(self, account):
Gtk.Image.__init__(self)
self._account = account
self.update()
jid = app.get_jid_from_account(account)
contact = app.contacts.create_contact(jid, account)
def update(self):
jid = app.get_jid_from_account(self._account)
contact = app.contacts.create_contact(jid, self._account)
client = app.get_client(self._account)
scale = self.get_scale_factor()
surface = app.interface.get_avatar(contact,
AvatarSize.ACCOUNT_SIDE_BAR,
scale,
style='round-corners')
self.get_scale_factor(),
style='round-corners',
show=client.status)
self.set_from_surface(surface)
......@@ -6,6 +6,7 @@
from gajim.common import app
from gajim.gui.util import get_builder
from gajim.gui.util import load_icon
from gajim.gui.account_page import AccountPage
from gajim.gui.chat_list_stack import ChatListStack
from gajim.gui.chat_stack import ChatStack
from gajim.gui.account_side_bar import AccountSideBar
......@@ -58,6 +59,7 @@ def __init__(self):
self.show_all()
self._load_chats()
self._add_accounts()
self._add_actions()
def _add_actions(self):
......@@ -67,6 +69,7 @@ def _add_actions(self):
('activate-workspace', 's', self.activate_workspace),
('add-chat', 'as', self.add_chat),
('remove-chat', 'as', self.remove_chat),
('activate-account-page', 's', self.activate_account_page),
]
for action in actions:
......@@ -91,6 +94,11 @@ def show_title(self, *args):
def get_active_jid(self, *args):
pass
def activate_account_page(self, _action, param):
account = param.get_string()
self._account_side_bar.activate_account_page(account)
self._ui.main_stack.set_visible_child_name(account)
def get_workspace_bar(self):
return self._workspace_side_bar
......@@ -121,8 +129,8 @@ def remove_workspace(self, _action, param):
self._chat_list_stack.remove_chat_list(workspace_id)
app.settings.remove_workspace(workspace_id)
def activate_workspace(self, _action, param):
self._ui.main_stack.set_visible_child_name('chats')
workspace_id = param.get_string()
self._workspace_side_bar.activate_workspace(workspace_id)
self._chat_list_stack.show_chat_list(workspace_id)
......@@ -147,6 +155,11 @@ def remove_chat(self, _action, param):
def get_control(self, account, jid):
return self._chat_stack.get_control(account, jid)
def _add_accounts(self):
for account in list(app.connections.keys()):
self._ui.main_stack.add_named(
AccountPage(account), account)
def _load_chats(self):
for workspace_id in app.settings.get_workspaces():
self._workspace_side_bar.add_workspace(workspace_id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment