Commit 9bb8ca8c authored by Nico Alt's avatar Nico Alt

Show back button in chats

parent cd2d44cc
......@@ -6,5 +6,6 @@
<file compressed="true" preprocess="xml-stripblanks">ui/login.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/main.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/setup.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/toolbar_start.ui</file>
</gresource>
</gresources>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<!-- Based on https://gitlab.gnome.org/World/lollypop/blob/1.0.12/data/ToolbarPlayback.ui -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkImage" id="back_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-previous-symbolic</property>
</object>
<object class="GtkBox" id="toolbar_start">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton" id="back_button">
<property name="visible">False</property>
<property name="valign">center</property>
<property name="image">back_image</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</interface>
# Copyright (c) 2019 Nico Alt
# Copyright (c) 2014-2019 Cedric Bellegarde <cedric.bellegarde@adishatz.org>
# SPDX-License-Identifier: AGPL-3.0-only
# License-Filename: LICENSE.md
#
# Initial version based on GNOME Lollypop
# https://gitlab.gnome.org/World/lollypop/blob/1.0.12/lollypop/toolbar.py
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class Toolbar(Gtk.HeaderBar):
def __init__(self):
super().__init__()
self._builder = Gtk.Builder()
self._builder.add_from_resource("/app/briar/gtk/ui/toolbar_start.ui")
toolbar_start = self._builder.get_object("toolbar_start")
self.set_title("Briar")
self.pack_start(toolbar_start)
def show_back_button(self, show, callback=None):
back_button = self._builder.get_object("back_button")
if not show:
back_button.hide()
return
if callback is None:
raise Exception("Callback needed when showing back button")
back_button.show()
back_button.connect("clicked", callback)
......@@ -6,6 +6,7 @@ from briar.gtk.containers.chat import ChatContainer
from briar.gtk.containers.main import MainContainer
from briar.gtk.containers.startup import StartupContainer
from briar.gtk.define import App
from briar.gtk.toolbar import Toolbar
import gi
gi.require_version('Gtk', '3.0')
......@@ -23,8 +24,13 @@ class Window(Gtk.ApplicationWindow):
def container(self):
return self.__container
@property
def toolbar(self):
return self.__toolbar
def __setup_content(self):
self.__setup_size((600, 400)) # TODO: do properly (constants, save)
self.__setup_toolbar()
self.__setup_grid()
self.__setup_startup_container()
......@@ -34,6 +40,12 @@ class Window(Gtk.ApplicationWindow):
isinstance(size[1], int):
self.resize(size[0], size[1])
def __setup_toolbar(self):
self.__toolbar = Toolbar()
self.__toolbar.show()
self.__toolbar.set_show_close_button(True)
self.set_titlebar(self.__toolbar)
def __setup_grid(self):
self.__grid = Gtk.Grid()
self.__grid.set_orientation(Gtk.Orientation.HORIZONTAL)
......@@ -66,4 +78,10 @@ class Window(Gtk.ApplicationWindow):
self.__container = ChatContainer(contact_id)
self.__container.show()
self.__grid.add(self.__container)
self.__toolbar.show_back_button(True, self.__back_to_main)
def __back_to_main(self, widget):
self.__grid.destroy()
self.__setup_grid()
self.__toolbar.show_back_button(False)
self.__setup_main_container()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment