2022-06-24 20:01:35 +02:00
|
|
|
# window.py
|
|
|
|
#
|
|
|
|
# Copyright (C) 2022 Libre en Communs <contact@a-lec.org>
|
|
|
|
# Copyright (C) 2022 Adrien Bourmault <neox@a-lec.org>
|
|
|
|
# Copyright (C) 2022 Jean Sirmai <jean@a-lec.org>
|
|
|
|
#
|
|
|
|
# This program 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, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2022-07-29 17:59:05 +02:00
|
|
|
from gi.repository import Gtk, Adw
|
2022-06-24 20:01:35 +02:00
|
|
|
|
|
|
|
|
2022-06-30 15:05:29 +02:00
|
|
|
@Gtk.Template(filename='ui/gemgraph.ui')
|
2022-06-24 20:01:35 +02:00
|
|
|
class GemGraphWindow(Gtk.ApplicationWindow):
|
2022-07-28 23:27:24 +02:00
|
|
|
"""
|
|
|
|
Window class
|
|
|
|
"""
|
2022-06-24 20:01:35 +02:00
|
|
|
__gtype_name__ = 'main'
|
|
|
|
|
2022-07-28 23:27:24 +02:00
|
|
|
main_stack = Gtk.Template.Child()
|
|
|
|
side_stack = Gtk.Template.Child()
|
|
|
|
main_paned = Gtk.Template.Child()
|
2022-07-29 10:59:57 +02:00
|
|
|
main_button_mode = Gtk.Template.Child()
|
2022-07-29 17:59:05 +02:00
|
|
|
toast_overlay = Gtk.Template.Child()
|
2022-08-02 10:29:48 +02:00
|
|
|
main_button_sidebar = Gtk.Template.Child()
|
2022-07-29 10:59:57 +02:00
|
|
|
|
|
|
|
__mode_icon = {
|
2022-08-02 10:29:48 +02:00
|
|
|
"mode_home":"user-home-symbolic" ,
|
2022-07-29 10:59:57 +02:00
|
|
|
"mode_edit":"document-edit-symbolic" ,
|
|
|
|
"mode_run":"system-run-symbolic" ,
|
2022-08-02 10:29:48 +02:00
|
|
|
"mode_presentation":"x-office-presentation-symbolic"
|
2022-07-29 10:59:57 +02:00
|
|
|
}
|
2022-06-24 20:01:35 +02:00
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
|
2022-07-28 23:27:24 +02:00
|
|
|
def toggle_sidebar(self):
|
|
|
|
"""
|
|
|
|
Sets the sidebar position to open or closed
|
|
|
|
"""
|
|
|
|
position = self.main_paned.get_position()
|
|
|
|
|
|
|
|
if position != 0:
|
|
|
|
self.main_paned.set_position(0)
|
|
|
|
else:
|
2022-07-29 17:59:05 +02:00
|
|
|
self.main_paned.set_position(300)
|
2022-07-28 23:27:24 +02:00
|
|
|
|
2022-08-02 10:29:48 +02:00
|
|
|
self.main_button_sidebar.toggled()
|
|
|
|
|
2022-07-28 23:27:24 +02:00
|
|
|
def stack_switch_mode(self, mode):
|
|
|
|
"""
|
|
|
|
Sets the active mode from stack. Mode is the name of the mode (string)
|
|
|
|
"""
|
2022-07-29 00:23:29 +02:00
|
|
|
self.main_stack.set_visible_child_full("main_"+mode, Gtk.StackTransitionType.CROSSFADE)
|
|
|
|
self.side_stack.set_visible_child_full("side_"+mode, Gtk.StackTransitionType.CROSSFADE)
|
2022-07-29 10:59:57 +02:00
|
|
|
self.main_button_mode.props.icon_name = self.__mode_icon["mode_"+mode]
|
2022-07-28 23:27:24 +02:00
|
|
|
|
2022-07-29 17:59:05 +02:00
|
|
|
def send_toast(self, message):
|
|
|
|
self.toast_overlay.add_toast(Adw.Toast(title=message))
|
|
|
|
|
2022-06-24 20:01:35 +02:00
|
|
|
class AboutDialog(Gtk.AboutDialog):
|
|
|
|
|
|
|
|
def __init__(self, parent):
|
|
|
|
Gtk.AboutDialog.__init__(self)
|
|
|
|
self.props.program_name = 'GemGraph'
|
2023-01-24 22:59:37 +01:00
|
|
|
self.props.version = "0.0.0"
|
2022-06-30 16:43:22 +02:00
|
|
|
self.props.authors = ['Adrien Bourmault', 'Jean Sirmai']
|
|
|
|
self.props.copyright = 'Copyright © 2022 Libre en Communs'
|
|
|
|
self.props.logo_icon_name = 'application-x-executable'
|
2022-06-24 20:01:35 +02:00
|
|
|
self.props.modal = True
|
|
|
|
self.set_transient_for(parent)
|
2022-07-28 01:55:44 +02:00
|
|
|
|