PK!$ucotinga/__init__.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from . import gui from .core import env __all__ = ['gui'] __version__ = env.__version__ PK!Nycotinga/core/__init__.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from . import env from . import shared from . import prefs from . import constants from . import pmdoc __all__ = ['shared', 'prefs', 'env', 'constants', 'pmdoc'] PK!cotinga/core/constants.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA NUMERIC_STEPS = {0: '1', 1: '0.5', 2: '0.25', 3: '0.1', 4: '0.01'} INTERNAL_SEPARATOR = ';; ' PK!HHHcotinga/core/env.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os import sys from pathlib import Path import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk import toml __process_name = os.path.basename(__file__) __abspath = os.path.abspath(__file__) __l1 = len(__process_name) __l2 = len(__abspath) CORE_DIRNAME = 'core/' ROOTDIR = __abspath[:__l2 - __l1][:-(len(CORE_DIRNAME) + 1)] PROJECTDIR = ROOTDIR[:-(len(__process_name) + 1)] with open(os.path.join(PROJECTDIR, 'pyproject.toml'), 'r') as f: pp = toml.load(f) __myname__ = pp['tool']['poetry']['name'] __authors__ = pp['tool']['poetry']['authors'] __version__ = pp['tool']['poetry']['version'] DATADIR = os.path.join(ROOTDIR, 'data') DATARUNDIR = os.path.join(DATADIR, 'run') CONFIGDIR = os.path.join(DATADIR, 'default/') LOCALEDIR = os.path.join(DATADIR, 'locale/') GUIDIR = os.path.join(ROOTDIR, 'gui/') STYLEDIR = os.path.join(DATADIR, 'style/') PICSDIR = os.path.join(DATADIR, 'pics/') FLAGSDIR = os.path.join(PICSDIR, 'flags/') DEFAULTDATAPREFSDIR = os.path.join(CONFIGDIR, 'data', 'prefs') COTINGA_ICON = os.path.join(PICSDIR, 'cotinga_icon.svg') COTINGA_FADED_ICON = os.path.join(PICSDIR, 'cotinga_icon_faded.svg') COTINGA_BW_ICON = os.path.join(PICSDIR, 'cotinga_icon_black_and_white.svg') COTINGA_FADED_BW_ICON = os.path.join(PICSDIR, 'cotinga_icon_faded_black_and_white.svg') # PMDOC stands for Progression Manager DOCument PMDOC_DB_FILENAME = 'pupils.db' PMDOC_DB_MIMETYPE = 'application/x-sqlite3' PMDOC_DB_URI = 'sqlite:///{}/data/run/pmdoc/{}'\ .format(ROOTDIR, PMDOC_DB_FILENAME) PMDOC_DIR = os.path.join(DATADIR, 'run/pmdoc') PMDEFAULTSDIR = os.path.join(DATADIR, 'default/files/pmdocsettings') PMDOC_DB_PATH = os.path.join(PMDOC_DIR, PMDOC_DB_FILENAME) PMDOC_SETUP_FILENAME = 'setting.toml' PMDOC_SETUP_MIMETYPE = 'text/plain' PMDOC_SETUP_PATH = os.path.join(PMDOC_DIR, PMDOC_SETUP_FILENAME) RUN_DB_FILE = os.path.join(DATARUNDIR, PMDOC_DB_FILENAME) RUN_SETUP_FILE = os.path.join(DATARUNDIR, PMDOC_SETUP_FILENAME) CFG_EXTENSION = '.toml' USER_PREFS_DIR = os.path.join(str(Path.home()), '.config') USER_COTINGA_PREFS_DIR = os.path.join(USER_PREFS_DIR, __myname__) USER_PREFS_FILE = os.path.join(USER_COTINGA_PREFS_DIR, 'prefs' + CFG_EXTENSION) USER_PREFS_DEFAULT_FILE = os.path.join(CONFIGDIR, 'files', 'prefs' + CFG_EXTENSION) STATUS_FILE = os.path.join(DATARUNDIR, 'status' + CFG_EXTENSION) DEFAULT_STATUS_FILE = os.path.join(CONFIGDIR, 'files', 'status' + CFG_EXTENSION) REPORT_FILE = os.path.join(DATARUNDIR, 'report.pdf') REPORT_FILE_URI = 'file://{}'.format(REPORT_FILE) L10N_DOMAIN = __myname__ LOCALES = \ {'en_US': 'en-US' if sys.platform.startswith('win') else 'en_US.UTF-8', 'fr_FR': 'fr-FR' if sys.platform.startswith('win') else 'fr_FR.UTF-8'} SUPPORTED_LANGUAGES = list(LOCALES.keys()) PMDEFAULTS_FILES = {k: os.path.join(PMDEFAULTSDIR, '{}.toml'.format(k)) for k in list(LOCALES.keys())} USER_PREFS_LOCALIZED_DEFAULT_FILES = \ {k: os.path.join(DEFAULTDATAPREFSDIR, '{}.toml'.format(k)) for k in list(LOCALES.keys())} ICON_THEME = Gtk.IconTheme.get_default() def get_theme_name(): return Gtk.Settings.get_default().props.gtk_theme_name def get_icon_theme_name(): return Gtk.Settings.get_default().props.gtk_icon_theme_name def get_theme_provider(name=None): if name is None: name = get_theme_name() return Gtk.CssProvider.get_named(name, None) THEME_STYLE_CONTEXT = Gtk.StyleContext.new() def get_theme_colors(): THEME_STYLE_CONTEXT.add_provider(get_theme_provider(), Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK) _, fg_color = THEME_STYLE_CONTEXT.lookup_color('fg_color') _, bg_color = THEME_STYLE_CONTEXT.lookup_color('bg_color') _, sel_fg_color = THEME_STYLE_CONTEXT.lookup_color('selected_fg_color') _, sel_bg_color = THEME_STYLE_CONTEXT.lookup_color('selected_bg_color') return (fg_color, bg_color, sel_fg_color, sel_bg_color) def convert_gdk_rgba_to_hex(color): """ Converts Gdk.RGBA to hexadecimal value. :param color: the Gdk.RGBA object to convert :type color: gi.overrides.Gdk.RGBA """ return '#{}{}{}{}'\ .format(hex(int(255 * color.red)).replace('0x', ''), hex(int(255 * color.green)).replace('0x', ''), hex(int(255 * color.blue)).replace('0x', ''), hex(int(255 * color.alpha)).replace('0x', '')) PK!W  cotinga/core/errors.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gettext import translation from .env import LOCALEDIR, L10N_DOMAIN from . import shared class CotingaError(Exception): """Basic exception for errors raised by Cotinga.""" def __init__(self, msg=None): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext if msg is None: msg = tr('An error occured in Cotinga') super().__init__(msg) class FileError(CotingaError): """When a file cannot be loaded.""" def __init__(self, filename, msg=None): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext if msg is None: msg = tr('Cannot load file: {filename}.')\ .format(repr(filename)) super().__init__(msg=msg) class DuplicateContentError(CotingaError): """When finding a forbidden duplicate.""" def __init__(self, content, msg=None): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext if msg is None: msg = tr('Duplicate content: {content}.')\ .format(content=repr(content)) super().__init__(msg=msg) class EmptyContentError(CotingaError): """In case of forbidden empty content.""" def __init__(self, msg=None): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext if msg is None: msg = tr('Empty content.') super().__init__(msg=msg) class NoChangeError(CotingaError): """In case a change was expected.""" def __init__(self, msg=None): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext if msg is None: msg = tr('No change.') super().__init__(msg=msg) class ReservedCharsError(CotingaError): """When finding reserved characters.""" def __init__(self, text, msg=None): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext if msg is None: msg = tr('Found reserved characters in: {text}.')\ .format(text=repr(text)) super().__init__(msg=msg) PK!iicotinga/core/io.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import toml from .tools import ExtDict def load(filename): """Load the values from the toml file.""" with open(filename) as file_path: status = toml.load(file_path) return status def save(data, filename): """Save the given file, but updated with given data.""" with open(filename) as file_path: current_status = ExtDict(toml.load(file_path)) current_status.recursive_update(data) with open(filename, 'w') as file_path: toml.dump(current_status, file_path) PK!cotinga/core/pmdoc/__init__.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from . import database, document, report, setting __all__ = ['database', 'document', 'report', 'setting'] PK!:$cotinga/core/pmdoc/database.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os from gettext import translation from sqlalchemy import inspect from sqlalchemy.orm import sessionmaker, mapper, clear_mappers from sqlalchemy import create_engine, MetaData, Table from cotinga.models import TABLENAMES, COLNAMES from .. import shared from ..env import LOCALEDIR, L10N_DOMAIN from ..env import PMDOC_DB_URI, PMDOC_DB_PATH from ..tools import turn_to_capwords from ..errors import FileError def new_session(): """Create a new database session.""" engine = create_engine(PMDOC_DB_URI, echo=False) session = sessionmaker(bind=engine)() metadata = MetaData() return engine, session, metadata def close_session(): """Close the current session.""" if shared.session is not None: shared.session.close() if shared.engine is not None: shared.engine.dispose() shared.metadata = None shared.session = None shared.engine = None clear_mappers() def terminate_session(): """Close session and remove the file.""" close_session() if os.path.isfile(PMDOC_DB_PATH): os.remove(PMDOC_DB_PATH) def map_table(name): """Map a table.""" from cotinga import models model_class = getattr(models, turn_to_capwords(name)) columns = getattr(models, '{}_columns'.format(name))() tablename = getattr(models, '{}_tablename'.format(name)) table = Table(tablename, shared.metadata, *columns) mapper(model_class, table) def add_table(name): """Map and create a table in the database if it's not already here.""" map_table(name) shared.metadata.create_all(shared.engine) def load_session(init=False): """ Create a session for a loaded document or initialize it for a new document. :param init: whether the session is for a new document or a loaded one :type init: bool """ shared.engine, shared.session, shared.metadata = new_session() load = add_table if init else map_table for name in TABLENAMES: load(name) def check_db(doc_path): """Check database from a file (tables and columns are as expected).""" PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext doc_sqlite_uri = 'sqlite:///{}'.format(doc_path) test_engine = create_engine(doc_sqlite_uri, echo=False) inspector = inspect(test_engine) tested_tablenames = inspector.get_table_names() for name in TABLENAMES: if name not in tested_tablenames: raise FileError(doc_path, msg=tr('Missing table "{tablename}" in the file ' 'to load ({filename}).') .format(tablename=name, filename=doc_path)) for name in tested_tablenames: if name not in TABLENAMES: raise FileError(doc_path, msg=tr('Found extraneous table "{tablename}" in ' 'the file to load ({filename}).') .format(tablename=name, filename=doc_path)) # LATER: check the columns types too (use col['type'] # and add a COLTYPES to models/__init__.py) tested_colnames = [col['name'] for col in inspector.get_columns(name)] for column in COLNAMES[name]: if column not in tested_colnames: raise FileError(doc_path, msg=tr('Missing column "{column_name}" ' 'in table "{tablename}" of the ' 'file to load ({filename}).') .format(column_name=column, tablename=name, filename=doc_path)) for column in tested_colnames: if column not in COLNAMES[name]: raise FileError(doc_path, msg=tr('Found extraneous column ' '"{column_name}" ' 'in table "{tablename}" of the ' 'file to load ({filename}).') .format(column_name=column, tablename=name, filename=doc_path)) PK!Nzcotinga/core/pmdoc/document.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os import tarfile from tarfile import ReadError, CompressionError from shutil import move, copyfile from gettext import translation import magic import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga.gui.dialogs import run_message_dialog, OpenFileDialog from cotinga.gui.dialogs import SaveAsFileDialog, SaveBeforeDialog from . import database, setting from .. import shared from ..env import LOCALEDIR, L10N_DOMAIN from ..env import DATARUNDIR, RUN_DB_FILE from ..env import RUN_SETUP_FILE from ..env import PMDOC_DB_PATH, PMDOC_SETUP_PATH, PMDOC_DIR from ..env import PMDOC_DB_FILENAME, PMDOC_DB_MIMETYPE, PMDOC_SETUP_MIMETYPE from ..env import PMDOC_SETUP_FILENAME from ..env import PMDEFAULTS_FILES from ..env import __myname__ from ..errors import FileError from ..tools import is_cot_file def new(): """Create and load a new empty document.""" tr = translation(L10N_DOMAIN, LOCALEDIR, [shared.PREFS.language]).gettext cancel = save_before(tr('Save current document before creating a new ' 'one?')) if not cancel: database.terminate_session() copyfile(PMDEFAULTS_FILES[shared.PREFS.language], PMDOC_SETUP_PATH) database.load_session(init=True) # Also creates a new pupils.db shared.STATUS.document_loaded = True shared.STATUS.document_modified = False shared.STATUS.document_name = '' shared.STATUS.filters = [] def close(): """Close the current document.""" tr = translation(L10N_DOMAIN, LOCALEDIR, [shared.PREFS.language]).gettext cancel = save_before(tr('Save current document before closing it?')) if not cancel: database.terminate_session() if os.path.isfile(PMDOC_SETUP_PATH): os.remove(PMDOC_SETUP_PATH) shared.STATUS.document_loaded = False shared.STATUS.document_modified = False shared.STATUS.document_name = '' shared.STATUS.filters = [] def __copy_document_to(dest): with tarfile.open(dest, 'w:gz') as tar: tar.add(PMDOC_DIR, arcname=os.path.sep) def save(): """Save the current document without changing the file name.""" cancel = False if shared.STATUS.document_name == '': cancel = save_as() else: __copy_document_to(shared.STATUS.document_name) shared.STATUS.document_modified = False return cancel def save_as(): """Save the current document with a new name.""" cancel = False dialog = SaveAsFileDialog() response = dialog.run() if response == Gtk.ResponseType.OK: doc_name = dialog.get_filename() if not doc_name.endswith('.tgz'): doc_name += '.tgz' shared.STATUS.document_name = doc_name __copy_document_to(shared.STATUS.document_name) shared.STATUS.document_modified = False elif response == Gtk.ResponseType.CANCEL: cancel = True dialog.destroy() return cancel def save_before(message): """ If document is modified, ask if it should be saved. Return True if the current action should be cancelled instead. :param message: a string to specify the reason of the action :type message: str :rtype: bool """ cancel = False if shared.STATUS.document_modified: dialog = SaveBeforeDialog(message) response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.YES: cancel = save() elif response == Gtk.ResponseType.CANCEL: cancel = True return cancel def check_file(doc_name): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext if not is_cot_file(doc_name): raise FileError(doc_name, msg=tr('This file is not a readable ' 'compressed archive.')) try: with tarfile.open(doc_name, mode='r:gz') as archive: expected_names = {'', PMDOC_DB_FILENAME, PMDOC_SETUP_FILENAME} if set(archive.getnames()) != expected_names: raise FileError(doc_name, msg=tr('This archive file does not contain ' 'the expected parts (found {}).') .format(archive.getnames())) archive.extractall(path=DATARUNDIR) db_mimetype_found = \ magic.detect_from_filename(RUN_DB_FILE).mime_type if db_mimetype_found != PMDOC_DB_MIMETYPE: raise FileError(doc_name, msg=tr('The database is not correct ' '(found MIME type {}).') .format(db_mimetype_found)) setup_mimetype_found = \ magic.detect_from_filename(RUN_SETUP_FILE).mime_type if setup_mimetype_found != PMDOC_SETUP_MIMETYPE: raise FileError(doc_name, msg=tr('The setup part is not correct ' '(found MIME type {}).') .format(setup_mimetype_found)) database.check_db(RUN_DB_FILE) except (ReadError, CompressionError): raise FileError(doc_name, msg=tr('This file could not be read or uncompressed ' 'correctly.')) def open_(): tr = translation(L10N_DOMAIN, LOCALEDIR, [shared.PREFS.language]).gettext cancel = save_before(tr('Save current document before opening another ' 'one?')) if not cancel: dialog = OpenFileDialog() response = dialog.run() if response == Gtk.ResponseType.OK: doc_name = dialog.get_filename() try: check_file(doc_name) except FileError as excinfo: tr = translation(L10N_DOMAIN, LOCALEDIR, [shared.PREFS.language]).gettext run_message_dialog( tr('Cannot load file'), tr('{software_name} cannot use this file.\n' 'Details: {details}') .format(software_name=__myname__.capitalize(), details=str(excinfo)), 'dialog-error', parent=dialog) else: if shared.STATUS.document_loaded: database.terminate_session() shared.STATUS.document_loaded = False move(RUN_DB_FILE, PMDOC_DB_PATH) move(RUN_SETUP_FILE, PMDOC_SETUP_PATH) database.load_session() shared.STATUS.document_modified = False shared.STATUS.document_name = doc_name shared.STATUS.filters = setting.load()['classes'] shared.STATUS.document_loaded = True dialog.destroy() PK!׹jjcotinga/core/pmdoc/report.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from datetime import datetime from gettext import translation from reportlab.lib import colors from reportlab.lib.pagesizes import A4, landscape from reportlab.lib.units import cm from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph from reportlab.lib.styles import getSampleStyleSheet from ..env import REPORT_FILE, LOCALEDIR, L10N_DOMAIN from ..tools import grouper from .. import shared DARK_GRAY = colors.HexColor(0x333333) DIM_GRAY = colors.HexColor(0x808080) MAX_NB_PER_COL = 30 def rework_data(data): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext col_data = [] spans = [] classes = set() for col in data: title = tr('{level} ({nb})').format(level=col[0], nb=col[1]) names = sorted([pupil.fullname for pupil in col[2]]) classes |= set([pupil.classname for pupil in col[2]]) for i, lst in enumerate(grouper(names, MAX_NB_PER_COL, padvalue='')): if i: new_col = [''] spans.append(True) else: new_col = [title] # copy title in the first column spans.append(False) new_col += lst col_data.append(new_col) maxi = max([len(item) for item in col_data] + [0]) report_data = [] for i in range(maxi): new_row = [item[i:i + 1] or [''] for item in col_data] report_data.append([p[0] for p in new_row]) spans.append(False) return report_data, spans, classes def workout_spans(spans): result = [] start_span = None for i, span in enumerate(spans): if start_span is None: if span: start_span = i - 1 else: if not span: result.append(('SPAN', (start_span, 0), (i - 1, 0))) start_span = None return result def build(data): data, spans, classes = rework_data(data) PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext stylesheet = getSampleStyleSheet() title_style = stylesheet['Title'] title_style.spaceAfter = 0.5 * cm h2_style = stylesheet['Heading3'] h2_style.spaceAfter = 0.5 * cm doc = SimpleDocTemplate(REPORT_FILE, pagesize=landscape(A4), leftMargin=0 * cm, rightMargin=0 * cm, topMargin=0 * cm, bottomMargin=0 * cm) elements = [] last_sep = ' {} '.format(tr('and')) classes_list = last_sep.join(sorted(list(classes))) classes_list = classes_list.replace(last_sep, ', ', len(classes) - 2) header = Paragraph(tr('Next evaluation ({classes_list})') .format(classes_list=classes_list), title_style) elements.append(header) date_fmt = PREFS.pmreport['date_fmt'] date = datetime.now().strftime(date_fmt) subheader = Paragraph(tr('Following levels will be attempted ' '(update {date})').format(date=date), h2_style) elements.append(subheader) ncol = len(data[0]) nrow = len(data) # LATER: adapt col width and height t = Table(data, ncol * [5.5 * cm], nrow * [0.5 * cm]) col_separators = [('LINEAFTER', (i, 0), (i, nrow), 1, DIM_GRAY) for i in range(ncol - 1) if not spans[(i + 1)]] t.setStyle(TableStyle([('ALIGN', (0, 0), (-1, -1), 'CENTER'), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('TEXTCOLOR', (0, 0), (-1, -1), DARK_GRAY), ('LINEABOVE', (0, 1), (ncol, 1), 1, DIM_GRAY) ] + col_separators + workout_spans(spans))) elements.append(t) # write the document to disk doc.build(elements) PK!->cotinga/core/pmdoc/setting.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from .. import io from ..env import PMDOC_SETUP_PATH def load(): """Load the complete setup of current loaded file.""" try: data = io.load(PMDOC_SETUP_PATH) except KeyError: data = dict() return data def save(data): """Save the document setup updated with given data.""" io.save(data, PMDOC_SETUP_PATH) PK!c((cotinga/core/prefs.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os import sys import locale from shutil import copyfile from gettext import translation import toml import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from . import io from .tools import ExtDict from .env import LOCALEDIR from .env import USER_PREFS_DIR, USER_COTINGA_PREFS_DIR, USER_PREFS_FILE from .env import USER_PREFS_DEFAULT_FILE, USER_PREFS_LOCALIZED_DEFAULT_FILES from .env import SUPPORTED_LANGUAGES, L10N_DOMAIN from cotinga.gui.dialogs import PreferencesDialog if sys.platform.startswith('win'): import ctypes FILE_ATTRIBUTE_HIDDEN = 0x02 def _firstrun_dialog(): """Run when no ~/.config/cotinga/prefs.toml is found at start.""" preferences = ExtDict() if not os.path.isdir(USER_PREFS_DIR): os.mkdir(USER_PREFS_DIR) if sys.platform.startswith('win'): ctypes.windll.kernel32.SetFileAttributesW(USER_PREFS_DIR, FILE_ATTRIBUTE_HIDDEN) if not os.path.isdir(USER_COTINGA_PREFS_DIR): os.mkdir(USER_COTINGA_PREFS_DIR) copyfile(USER_PREFS_DEFAULT_FILE, USER_PREFS_FILE) window = Gtk.Window() try: language = locale.getdefaultlocale()[0] assert language in SUPPORTED_LANGUAGES except Exception: # We just want to guess the default locale, and check it # belongs to supported languages, so for any Exception # raised, we fall back to the default 'en_US' country code language = 'en_US' tr = translation(L10N_DOMAIN, LOCALEDIR, [language]).gettext pref_dialog = PreferencesDialog( tr('Cotinga - Preferences'), language, first_run=True, window=window) pref_dialog.run() chosen_language = pref_dialog.chosen_language \ if pref_dialog.chosen_language is not None \ else language preferences.recursive_update({'language': chosen_language}) preferences.recursive_update( toml.load(USER_PREFS_LOCALIZED_DEFAULT_FILES[chosen_language])) save(preferences) pref_dialog.destroy() return preferences def _from(filename, ioerror_handling=None): """ Try to get preferences from filename. IOError handling is either ignored (if left to default None) or runs the first run dialog (if set to 'firstrun_dialog') to retrieve information. """ preferences = ExtDict() try: with open(filename) as f: preferences = ExtDict(toml.load(f)) except (IOError, FileNotFoundError): if ioerror_handling == 'firstrun_dialog': preferences = _firstrun_dialog() return preferences def save(data): """Save the user prefs file updated with given data.""" io.save(data, USER_PREFS_FILE) def load(): """Will load the values from the toml prefs file.""" preferences = _from(USER_PREFS_DEFAULT_FILE) preferences.recursive_update( _from(USER_PREFS_FILE, ioerror_handling='firstrun_dialog')) return preferences PK!__cotinga/core/shared.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import toml from . import status, prefs from .pmdoc import database from cotinga import gui from .env import USER_PREFS_LOCALIZED_DEFAULT_FILES class Status(object): def __init__(self): loaded_status = status.load() for key in loaded_status.keys(): setattr(self, '_{}'.format(key), loaded_status[key]) @property def document_loaded(self): return self._document_loaded @document_loaded.setter def document_loaded(self, value): # LATER: maybe check the value is boolean self._document_loaded = value gui.app.window\ .pupils_progression_manager_page.toolbar\ .buttons['document-setup']\ .set_sensitive(value) gui.app.window\ .pupils_progression_manager_page.toolbar\ .buttons['document-close']\ .set_sensitive(value) gui.app.window\ .pupils_progression_manager_page.toolbar\ .buttons['document-save-as']\ .set_sensitive(value) gui.app.window\ .pupils_progression_manager_page.setup_pages() status.save({'document_loaded': value}) gui.app.window.refresh_progression_manager_tab_title() @property def document_modified(self): return self._document_modified @document_modified.setter def document_modified(self, value): # LATER: maybe check the value is boolean self._document_modified = value gui.app.window\ .pupils_progression_manager_page.toolbar\ .buttons['document-save']\ .set_sensitive(value) status.save({'document_modified': value}) gui.app.window.refresh_progression_manager_tab_title() @property def document_name(self): return self._document_name @document_name.setter def document_name(self, value): self._document_name = value status.save({'document_name': value}) gui.app.window.refresh_progression_manager_tab_title() @property def filters(self): return self._filters @filters.setter def filters(self, value): self._filters = value status.save({'filters': value}) @property def show_col_id(self): return self._show_col_id @show_col_id.setter def show_col_id(self, value): self._show_col_id = value status.save({'show_col_id': value}) gui.app.window.pupils_progression_manager_page.refresh_visible_cols() @property def show_col_incl(self): return self._show_col_incl @show_col_incl.setter def show_col_incl(self, value): self._show_col_incl = value status.save({'show_col_incl': value}) gui.app.window.pupils_progression_manager_page.refresh_visible_cols() @property def show_col_ilevel(self): return self._show_col_ilevel @show_col_ilevel.setter def show_col_ilevel(self, value): self._show_col_ilevel = value status.save({'show_col_ilevel': value}) gui.app.window.pupils_progression_manager_page.refresh_visible_cols() class Prefs(object): def __init__(self): loaded_prefs = prefs.load() self._language = loaded_prefs['language'] self._pmreport = loaded_prefs['pmreport'] self._enable_devtools = loaded_prefs['enable_devtools'] self._show_toolbar_labels = loaded_prefs['show_toolbar_labels'] @property def language(self): return self._language @language.setter def language(self, value): # We don't check the value (the only calls to set_language() must check # it belongs to SUPPORTED_LANGUAGES). self._language = value prefs.save({'language': value}) # LATER: do this only at first run, then let the user handle this # (when he'll be able to define the date_fmt value on his own, in the # prefs dialog) prefs.save(toml.load(USER_PREFS_LOCALIZED_DEFAULT_FILES[value])) @property def pmreport(self): loaded_prefs = prefs.load() return loaded_prefs['pmreport'] @property def enable_devtools(self): return self._enable_devtools @enable_devtools.setter def enable_devtools(self, value): self._enable_devtools = value prefs.save({'enable_devtools': value}) @property def show_toolbar_labels(self): return self._show_toolbar_labels @show_toolbar_labels.setter def show_toolbar_labels(self, value): self._show_toolbar_labels = value prefs.save({'show_toolbar_labels': value}) def init(): global STATUS, PREFS global engine, session, metadata STATUS = Status() PREFS = Prefs() engine = None session = None metadata = None if STATUS.document_loaded: database.load_session() PK!ǜpcotinga/core/status.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os from shutil import copyfile from . import io from .env import STATUS_FILE, DEFAULT_STATUS_FILE def load(): """Load the values from the toml status file.""" if not os.path.isfile(STATUS_FILE): # Should only happen at first run copyfile(DEFAULT_STATUS_FILE, STATUS_FILE) return io.load(STATUS_FILE) def save(data): """Save the status file updated with given data.""" io.save(data, STATUS_FILE) PK!DΙ " "cotinga/core/tools.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os from tarfile import is_tarfile from gettext import translation from itertools import zip_longest from decimal import InvalidOperation import gi try: gi.require_version('Gtk', '3.0') gi.require_version('Pango', '1.0') except ValueError: raise else: from gi.repository import Gtk, Pango from mathmakerlib.calculus import Number from . import shared, constants from .env import L10N_DOMAIN, LOCALEDIR STEPS = constants.NUMERIC_STEPS def turn_to_capwords(name): return ''.join(x.capitalize() for x in name.split('_')) def grouper(iterable, n, padvalue=None): """ grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x') """ # Taken from https://stackoverflow.com/a/312644/3926735 return zip_longest(*[iter(iterable)] * n, fillvalue=padvalue) def is_cot_file(path): return os.path.isfile(path) and is_tarfile(path) def cot_filter(filter_info, data): path = filter_info.filename return is_cot_file(path) and path.endswith('.tgz') def add_filter_any(dialog): tr = translation(L10N_DOMAIN, LOCALEDIR, [shared.PREFS.language]).gettext filter_any = Gtk.FileFilter() filter_any.set_name(tr('Any files')) filter_any.add_pattern('*') dialog.add_filter(filter_any) def add_cot_filters(dialog): tr = translation(L10N_DOMAIN, LOCALEDIR, [shared.PREFS.language]).gettext filter_cot = Gtk.FileFilter() filter_cot.set_name(tr('Cotinga files')) filter_cot.add_custom(Gtk.FileFilterFlags.FILENAME, cot_filter, None) dialog.add_filter(filter_cot) add_filter_any(dialog) def add_pdf_filters(dialog): tr = translation(L10N_DOMAIN, LOCALEDIR, [shared.PREFS.language]).gettext filter_pdf = Gtk.FileFilter() filter_pdf.set_name(tr('Any pdf file')) filter_pdf.add_mime_type('application/pdf') dialog.add_filter(filter_pdf) add_filter_any(dialog) def check_grade(cell_text, special_grades, grading): result = (True, True) if cell_text in special_grades: result = (True, False) else: if grading['choice'] == 'numeric': if cell_text in ['', None]: result = (False, False) else: try: nb = Number(cell_text.replace(',', '.')) except InvalidOperation: result = (False, False) else: if (nb < Number(grading['minimum']) or nb > Number(grading['maximum']) or nb % Number(STEPS[grading['step']])): result = (False, False) else: # grading['choice'] is 'literal' if cell_text not in grading['literal_grades']: result = (False, False) return result def cellfont_fmt(cell_text, special_grades, grading): # LATER: use theme foreground color instead of black paint_it = 'Black' weight = int(Pango.Weight.NORMAL) accepted, regular = check_grade(cell_text, special_grades, grading) if accepted: if not regular: paint_it = 'Grey' else: paint_it = 'Firebrick' weight = int(Pango.Weight.BOLD) return (paint_it, weight) def grade_ge_edge(grading, grade, special_grades): accepted, regular = check_grade(grade, special_grades, grading) if accepted and regular: if grading['choice'] == 'numeric': edge = grading['edge_numeric'] return Number(grade.replace(',', '.')) >= Number(edge) else: # grading['choice'] == 'literal' edge = grading['edge_literal'] return grading['literal_grades'].index(grade) \ >= grading['literal_grades'].index(edge) else: return False def calculate_attained_level(start_level, levels, grading, grades, special_grades): # LATER: check start_level belongs to levels? index = levels.index(start_level) for grade in grades: if grade_ge_edge(grading, grade, special_grades): index += 1 try: result = levels[index] except IndexError: result = levels[-1] return result def build_view(*cols, xalign=None, set_cell_func=None): """ Example: build_view(['Title1', 'data1', 'data2'], ['Title2', 'data3', 'data4']) :param cols: the columns contents, starting with title :type cols: list :rtype: Gtk.TreeView """ store = Gtk.ListStore(*([str] * len(cols))) for i, row in enumerate(zip(*cols)): if i: # we do not add the first data, being the title store.append(row) view = Gtk.TreeView(store) view.props.margin = 10 view.get_selection().set_mode(Gtk.SelectionMode.NONE) for i, col in enumerate(cols): rend = Gtk.CellRendererText() if xalign is not None: rend.props.xalign = xalign[i] view_col = Gtk.TreeViewColumn(col[0], rend, text=i) if set_cell_func is not None and set_cell_func[i] is not None: view_col.set_cell_data_func(rend, set_cell_func[i]) view.append_column(view_col) return view class ExtDict(dict): """A dict with more methods.""" def recursive_update(self, d2): """ Update self with d2 key/values, recursively update nested dicts. :Example: >>> d = ExtDict({'a': 1, 'b': {'a': 7, 'c': 10}}) >>> d.recursive_update({'a': 24, 'd': 13, 'b': {'c': 100}}) >>> print(d == {'a': 24, 'd': 13, 'b': {'a': 7, 'c': 100}}) True >>> d = ExtDict() >>> d.recursive_update({'d': {'f': 13}}) >>> d {'d': {'f': 13}} >>> d = ExtDict({'a': 1, 'b': {'a': 7, 'c': 10}}) >>> d.recursive_update({'h': {'z': 49}}) >>> print(d == {'a': 1, 'b': {'a': 7, 'c': 10}, 'h': {'z': 49}}) True """ nested1 = {key: ExtDict(val) for key, val in iter(self.items()) if isinstance(val, dict)} other1 = {key: val for key, val in iter(self.items()) if not isinstance(val, dict)} nested2 = {key: val for key, val in iter(d2.items()) if isinstance(val, dict)} other2 = {key: val for key, val in iter(d2.items()) if not isinstance(val, dict)} other1.update(other2) for key in nested1: if key in nested2: nested1[key].recursive_update(nested2[key]) for key in nested2: if key not in nested1: nested1[key] = nested2[key] other1.update(nested1) self.update(other1) class Listing(object): def __init__(self, data, data_row=None, position=None): """ data may be None or a list or any other type prepend must be None or a list """ if data_row is None: data_row = [] if not isinstance(data_row, list): raise TypeError('Argument data_row should be a list, found {} ' 'instead'.format(str(type(data_row)))) if data is None: data = [] if not isinstance(data, list): data = [data] self.cols = [item for item in data_row] if position is None: position = len(self.cols) for i, item in enumerate(data): retry = True while retry: try: self.cols[position + i] = item except IndexError: self.cols.append('') else: retry = False def __iter__(self): return iter(self.cols) def __str__(self): return str(self.cols) def __repr__(self): return 'Listing({})'.format(self.cols) PK!yO*cotinga/data/default/data/pmdoc/presets.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gettext import translation from cotinga.core.shared import PREFS from cotinga.core.env import LOCALEDIR, L10N_DOMAIN def GRADES_SCALES(): tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext return \ {'ABCDE': ('A, B, C, D, E', ['A', 'B', 'C', 'D', 'E']), 'ABCDF': (tr('A, B, C, D, F (US style)'), ['A', 'B', 'C', 'D', 'F']), 'ABCDE_signed': (tr('A, B, C, D, E with signs'), ['A+', 'A', 'A-', 'B+', 'B', 'B-', 'C+', 'C', 'C-', 'D+', 'D', 'D-', 'E+', 'E']), 'ABCDF_signed': (tr('A, B, C, D, F with signs (US style)'), ['A+', 'A', 'A-', 'B+', 'B', 'B-', 'C+', 'C', 'C-', 'D+', 'D', 'D-', 'F']) } def LEVELS_SCALES(): tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext return \ {'karate': (tr('Karate-like (7 belts: white, yellow, ...)'), [tr('White belt'), tr('Yellow belt'), tr('Orange belt'), tr('Green belt'), tr('Blue belt'), tr('Brown belt'), tr('Black belt')]), 'judo': (tr('Judo-like (12 belts: white, white & yellow, ...)'), [tr('White belt'), tr('White and yellow belt'), tr('Yellow belt'), tr('Yellow and orange belt'), tr('Orange belt'), tr('Orange and green belt'), tr('Green belt'), tr('Blue belt'), tr('Brown belt'), tr('Black belt'), tr('Red and white belt'), tr('Red belt')]), 'martial-arts-extended': (tr('Martial arts-like (22 belts: white, ' 'white 1st stripe, ...)'), [tr('White belt'), tr('White belt |'), tr('White belt ||'), tr('Yellow belt'), tr('Yellow belt |'), tr('Yellow belt ||'), tr('Orange belt'), tr('Orange belt |'), tr('Orange belt ||'), tr('Green belt'), tr('Green belt |'), tr('Green belt ||'), tr('Blue belt'), tr('Blue belt |'), tr('Blue belt ||'), tr('Brown belt'), tr('Brown belt |'), tr('Brown belt ||'), tr('Red belt'), tr('Red belt |'), tr('Red belt ||'), tr('Black belt'), ]) } PK!Mjy}!!*cotinga/data/default/data/prefs/en_US.toml[pmreport] date_fmt = '%Y/%m/%d' PK! ;!!*cotinga/data/default/data/prefs/fr_FR.toml[pmreport] date_fmt = '%d/%m/%Y' PK!'] # This file is distributed under the same license as the cotinga package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: cotinga 0.1.0\n" "Report-Msgid-Bugs-To: nh.techn@gmail.com\n" "POT-Creation-Date: 2018-07-10 07:57+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-SourceCharset: UTF-8\n" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:114 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:103 msgid "Class" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:121 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:114 msgid "Name" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:93 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:128 #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:126 msgid "Initial level" msgstr "" #: ../cotinga/cotinga/gui/application.py:64 #: ../cotinga/cotinga/gui/application.py:167 msgid "Preferences" msgstr "" #: ../cotinga/cotinga/gui/application.py:65 msgid "About" msgstr "" #: ../cotinga/cotinga/gui/application.py:66 msgid "Quit" msgstr "" #: ../cotinga/cotinga/gui/application.py:207 msgid "Cotinga helps teachers to manage their pupils' progression." msgstr "" #: ../cotinga/cotinga/gui/application.py:204 msgid "Cotinga website" msgstr "" #: ../cotinga/cotinga/gui/dialogs/preferences.py:66 msgid "Choose a language:" msgstr "" #: ../cotinga/cotinga/core/prefs.py:74 msgid "Cotinga - Preferences" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:87 msgid "Levels" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:133 msgid "" "You can create a new document\n" "or load an existing one." msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/grading_manager.py:61 msgid "Numeric" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/grading_manager.py:62 msgid "Literal" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:89 msgid "Grading" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/numeric_grading_panel.py:93 msgid "Minimum" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/numeric_grading_panel.py:99 msgid "Edge" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/numeric_grading_panel.py:105 msgid "Maximum" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/numeric_grading_panel.py:88 msgid "Precision" msgstr "" #: ../cotinga/cotinga/gui/panels/list_manager_base.py:295 msgid "" "Each label must be unique.\n" "Modification cancelled." msgstr "" #: ../cotinga/cotinga/gui/panels/list_manager_base.py:294 msgid "No duplicates!" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:33 msgid "A, B, C, D, F (US style)" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:34 msgid "A, B, C, D, E with signs" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:37 msgid "A, B, C, D, F with signs (US style)" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/literal_grading_panel.py:49 #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:60 msgid "Load a preset scale" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/literal_grading_panel.py:50 #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:61 msgid "Replace current scale by: " msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/literal_grading_panel.py:73 msgid "Edge:" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:59 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:51 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:47 msgid "White belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:52 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:62 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:47 msgid "Yellow belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:53 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:47 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:65 msgid "Orange belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:68 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:48 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:54 msgid "Green belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:71 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:48 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:54 msgid "Blue belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:74 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:48 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:54 msgid "Brown belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:49 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:80 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:55 msgid "Black belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:46 msgid "Karate-like (7 belts: white, yellow, ...)" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:50 msgid "Judo-like (12 belts: white, white & yellow, ...)" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:51 msgid "White and yellow belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:52 msgid "Yellow and orange belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:53 msgid "Orange and green belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:55 msgid "Red and white belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:77 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:56 msgid "Red belt" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:57 msgid "Martial arts-like (22 belts: white, white 1st stripe, ...)" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:91 msgid "Special grades" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:72 #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:64 #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/literal_grading_panel.py:47 #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:58 msgid "Labels" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:60 msgid "White belt |" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:61 msgid "White belt ||" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:63 msgid "Yellow belt |" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:64 msgid "Yellow belt ||" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:66 msgid "Orange belt |" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:67 msgid "Orange belt ||" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:69 msgid "Green belt |" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:70 msgid "Green belt ||" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:72 msgid "Blue belt |" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:73 msgid "Blue belt ||" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:75 msgid "Brown belt |" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:76 msgid "Brown belt ||" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:78 msgid "Red belt |" msgstr "" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:79 msgid "Red belt ||" msgstr "" #: ../cotinga/cotinga/core/tools.py:79 msgid "Cotinga files" msgstr "" #: ../cotinga/cotinga/gui/dialogs/file_save_as.py:52 #: ../cotinga/cotinga/gui/dialogs/file_open.py:46 msgid "Please choose a file" msgstr "" #: ../cotinga/cotinga/core/errors.py:35 msgid "An error occured in Cotinga" msgstr "" #: ../cotinga/cotinga/core/errors.py:45 #, python-brace-format msgid "Cannot load file: {filename}." msgstr "" #: ../cotinga/cotinga/core/pmdoc/database.py:105 #, python-brace-format msgid "Missing table \"{tablename}\" in the file to load ({filename})." msgstr "" #: ../cotinga/cotinga/core/pmdoc/database.py:111 #, python-brace-format msgid "Found extraneous table \"{tablename}\" in the file to load ({filename})." msgstr "" #: ../cotinga/cotinga/core/pmdoc/document.py:193 msgid "Cannot load file" msgstr "" #: ../cotinga/cotinga/core/pmdoc/document.py:194 #, python-brace-format msgid "" "{software_name} cannot use this file.\n" "Details: {details}" msgstr "" #: ../cotinga/cotinga/core/pmdoc/database.py:120 #, python-brace-format msgid "" "Missing column \"{column_name}\" in table \"{tablename}\" of the file to " "load ({filename})." msgstr "" #: ../cotinga/cotinga/core/pmdoc/database.py:128 #, python-brace-format msgid "" "Found extraneous column \"{column_name}\" in table \"{tablename}\" of the " "file to load ({filename})." msgstr "" #: ../cotinga/cotinga/gui/dialogs/save_before.py:45 msgid "Unsaved document" msgstr "" #: ../cotinga/cotinga/core/pmdoc/document.py:74 msgid "Save current document before closing it?" msgstr "" #: ../cotinga/cotinga/core/pmdoc/document.py:57 msgid "Save current document before creating a new one?" msgstr "" #: ../cotinga/cotinga/core/pmdoc/document.py:180 msgid "Save current document before opening another one?" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:134 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:136 msgid "Attained level" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:201 msgid "None" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:49 msgid "Document settings" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:85 msgid "Classes" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:175 msgid "You can start creating classes in the document settings." msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:664 msgid "Change initial level" msgstr "" #: ../cotinga/cotinga/gui/application.py:116 msgid "Progression manager" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:679 msgid "Move to another class" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:208 msgid "All" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:165 msgid "Global view" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:453 #: ../cotinga/cotinga/gui/panels/list_manager_base.py:300 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:595 msgid "Reserved group of characters" msgstr "" #: ../cotinga/cotinga/gui/panels/list_manager_base.py:301 msgid "" "The group of characters \"{}\" is reserved for internal use, you cannot use them here, sorry.\n" "Modification cancelled." msgstr "" #: ../cotinga/cotinga/gui/application.py:118 #, python-brace-format msgid "Progression manager – {doc_title}" msgstr "" #: ../cotinga/cotinga/gui/application.py:121 msgid "Progression manager – (New document)" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:195 msgid "Visible classes:" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:290 msgid "Pupils' number: {}" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:279 #, python-brace-format msgid "{level}: {number}" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:292 msgid "Next evaluation:" msgstr "" #: ../cotinga/cotinga/core/pmdoc/report.py:49 #, python-brace-format msgid "{level} ({nb})" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:391 msgid "Report preview" msgstr "" #: ../cotinga/cotinga/core/pmdoc/report.py:110 #, python-brace-format msgid "Following levels will be attempted (update {date})" msgstr "" #: ../cotinga/cotinga/gui/dialogs/file_save_as.py:62 #, python-brace-format msgid "Report {date}.pdf" msgstr "" #: ../cotinga/cotinga/core/tools.py:70 msgid "Any files" msgstr "" #: ../cotinga/cotinga/core/tools.py:90 msgid "Any pdf file" msgstr "" #: ../cotinga/cotinga/core/pmdoc/document.py:153 msgid "This archive file does not contain the expected parts (found {})." msgstr "" #: ../cotinga/cotinga/core/pmdoc/document.py:161 msgid "The database is not correct (found MIME type {})." msgstr "" #: ../cotinga/cotinga/core/pmdoc/document.py:168 msgid "The setup part is not correct (found MIME type {})." msgstr "" #: ../cotinga/cotinga/gui/dialogs/file_save_as.py:66 msgid "Untitled.tgz" msgstr "" #: ../cotinga/cotinga/core/pmdoc/document.py:174 msgid "This file could not be read or uncompressed correctly." msgstr "" #: ../cotinga/cotinga/core/pmdoc/document.py:146 msgid "This file is not a readable compressed archive." msgstr "" #: ../cotinga/cotinga/core/errors.py:56 #, python-brace-format msgid "Duplicate content: {content}." msgstr "" #: ../cotinga/cotinga/core/errors.py:67 msgid "Empty content." msgstr "" #: ../cotinga/cotinga/core/errors.py:77 msgid "No change." msgstr "" #: ../cotinga/cotinga/core/errors.py:87 #, python-brace-format msgid "Found reserved characters in: {text}." msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:596 msgid "" "The group of characters \"{}\" has been found in the data you're about to paste, but it is reserved for internal use.\n" "Please remove it from the data you want to paste before pasting again.\n" "Pasting pupils' names cancelled." msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:625 msgid "Empty lines" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:626 msgid "" "The empty lines that have been found in the data you want to paste\n" "have been automatically removed." msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:436 msgid "" "There are too few grades.\n" "It is required to paste as many grades as pupils." msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:439 msgid "" "There are too many grades.\n" "It is required to paste as many grades as pupils." msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:441 msgid "Number of pupils and grades mismatch" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:454 msgid "" "The group of characters \"{}\" has been found in the data you're about to paste, but it is reserved for internal use.\n" "Please remove it from the data you want to paste before pasting again.\n" "Pasting grades cancelled." msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:468 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:606 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:493 msgid "Names" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:503 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:608 msgid "Please confirm" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:609 msgid "Add following pupils?" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:469 msgid "Grades" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:471 msgid "Add following grades?" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:494 msgid "Grade #{}" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:497 msgid "Update" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:501 msgid "Modify following grades?" msgstr "" #: ../cotinga/cotinga/core/pmdoc/report.py:99 msgid "and" msgstr "" #: ../cotinga/cotinga/core/pmdoc/report.py:102 #, python-brace-format msgid "Next evaluation ({classes_list})" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:109 #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:89 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:98 msgid "Included" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:81 msgid "View columns:" msgstr "" #: ../cotinga/cotinga/gui/dialogs/preferences.py:115 msgid "Developer tools" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:125 msgid "New" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:126 msgid "Open" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:127 msgid "Save" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:128 msgid "Save as..." msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:129 msgid "Close" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:130 msgid "Settings" msgstr "" #: ../cotinga/cotinga/gui/panels/list_manager_base.py:117 msgid "Add" msgstr "" #: ../cotinga/cotinga/gui/panels/list_manager_base.py:118 msgid "Remove" msgstr "" #: ../cotinga/cotinga/gui/dialogs/preferences.py:103 msgid "Show toolbar buttons labels" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:253 msgid "Preview" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:320 msgid "Insert a pupil" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:323 msgid "Edit class" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:324 msgid "Paste pupils" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:325 msgid "Paste grades" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:326 msgid "Add new grade" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:321 msgid "Remove pupils" msgstr "" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:322 msgid "Edit initial level" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:125 msgid "Welcome in Cotinga" msgstr "" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:126 msgid "Version {}" msgstr "" PK!36}LdLd0cotinga/data/locale/fr_FR/LC_MESSAGES/cotinga.po# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR ['Nicolas Hainaux '] # This file is distributed under the same license as the cotinga package. # FIRST AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: cotinga 0.1.0\n" "Report-Msgid-Bugs-To: nh.techn@gmail.com\n" "POT-Creation-Date: 2018-07-10 07:57+0200\n" "PO-Revision-Date: 2018-09-25 18:18+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: fr_FR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 2.1.1\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:114 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:103 msgid "Class" msgstr "Classe" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:121 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:114 msgid "Name" msgstr "Nom" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:93 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:128 #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:126 msgid "Initial level" msgstr "Niveau initial" #: ../cotinga/cotinga/gui/application.py:64 #: ../cotinga/cotinga/gui/application.py:167 msgid "Preferences" msgstr "Préférences" #: ../cotinga/cotinga/gui/application.py:65 msgid "About" msgstr "À propos" #: ../cotinga/cotinga/gui/application.py:66 msgid "Quit" msgstr "Quitter" #: ../cotinga/cotinga/gui/application.py:207 msgid "Cotinga helps teachers to manage their pupils' progression." msgstr "Cotinga aide les professeurs à gérer la progression de leurs élèves." #: ../cotinga/cotinga/gui/application.py:204 msgid "Cotinga website" msgstr "Site web de Cotinga" #: ../cotinga/cotinga/gui/dialogs/preferences.py:66 msgid "Choose a language:" msgstr "Choisissez une langue :" #: ../cotinga/cotinga/core/prefs.py:74 msgid "Cotinga - Preferences" msgstr "Cotinga - Préférences" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:87 msgid "Levels" msgstr "Niveaux" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:133 msgid "" "You can create a new document\n" "or load an existing one." msgstr "" "Vous pouvez créer un nouveau document\n" "ou bien charger un document existant." #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/grading_manager.py:61 msgid "Numeric" msgstr "Numérique" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/grading_manager.py:62 msgid "Literal" msgstr "Littérale" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:89 msgid "Grading" msgstr "Notation" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/numeric_grading_panel.py:93 msgid "Minimum" msgstr "Minimum" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/numeric_grading_panel.py:99 msgid "Edge" msgstr "Seuil" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/numeric_grading_panel.py:105 msgid "Maximum" msgstr "Maximum" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/numeric_grading_panel.py:88 msgid "Precision" msgstr "Précision" #: ../cotinga/cotinga/gui/panels/list_manager_base.py:295 msgid "" "Each label must be unique.\n" "Modification cancelled." msgstr "" "Chaque étiquette doit être unique.\n" "Modification annulée." #: ../cotinga/cotinga/gui/panels/list_manager_base.py:294 msgid "No duplicates!" msgstr "Pas de doublons !" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:33 msgid "A, B, C, D, F (US style)" msgstr "A, B, C, D, F (style USA)" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:34 msgid "A, B, C, D, E with signs" msgstr "A, B, C, D, E avec signes" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:37 msgid "A, B, C, D, F with signs (US style)" msgstr "A, B, C, D, F avec signes (style USA)" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/literal_grading_panel.py:49 #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:60 msgid "Load a preset scale" msgstr "Charger une échelle préconfigurée" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/literal_grading_panel.py:50 #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:61 msgid "Replace current scale by: " msgstr "Remplacer l'échelle actuelle par :" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/literal_grading_panel.py:73 msgid "Edge:" msgstr "Seuil :" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:59 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:51 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:47 msgid "White belt" msgstr "Ceinture blanche" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:52 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:62 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:47 msgid "Yellow belt" msgstr "Ceinture jaune" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:53 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:47 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:65 msgid "Orange belt" msgstr "Ceinture orange" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:68 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:48 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:54 msgid "Green belt" msgstr "Ceinture verte" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:71 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:48 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:54 msgid "Blue belt" msgstr "Ceinture bleue" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:74 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:48 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:54 msgid "Brown belt" msgstr "Ceinture marron" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:49 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:80 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:55 msgid "Black belt" msgstr "Ceinture noire" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:46 msgid "Karate-like (7 belts: white, yellow, ...)" msgstr "Type karaté (7 ceintures : blanche, jaune, ...)" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:50 msgid "Judo-like (12 belts: white, white & yellow, ...)" msgstr "Type judo (12 ceintures : blanche, blanche et jaune, ...)" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:51 msgid "White and yellow belt" msgstr "Ceinture blanche et jaune" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:52 msgid "Yellow and orange belt" msgstr "Ceinture jaune et orange" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:53 msgid "Orange and green belt" msgstr "Ceinture orange et verte" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:55 msgid "Red and white belt" msgstr "Ceinture rouge et blanche" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:77 #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:56 msgid "Red belt" msgstr "Ceinture rouge" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:57 msgid "Martial arts-like (22 belts: white, white 1st stripe, ...)" msgstr "Type arts martiaux (22 ceintures : blanche, blanche 1er trait, ...)" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:91 msgid "Special grades" msgstr "Notes spéciales" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:72 #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:64 #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/pages/literal_grading_panel.py:47 #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:58 msgid "Labels" msgstr "Libellés" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:60 msgid "White belt |" msgstr "Ceinture blanche |" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:61 msgid "White belt ||" msgstr "Ceinture blanche ||" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:63 msgid "Yellow belt |" msgstr "Ceinture jaune |" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:64 msgid "Yellow belt ||" msgstr "Ceinture jaune ||" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:66 msgid "Orange belt |" msgstr "Ceinture orange |" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:67 msgid "Orange belt ||" msgstr "Ceinture orange ||" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:69 msgid "Green belt |" msgstr "Ceinture verte |" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:70 msgid "Green belt ||" msgstr "Ceinture verte ||" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:72 msgid "Blue belt |" msgstr "Ceinture bleue |" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:73 msgid "Blue belt ||" msgstr "Ceinture bleue ||" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:75 msgid "Brown belt |" msgstr "Ceinture marron |" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:76 msgid "Brown belt ||" msgstr "Ceinture marron ||" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:78 msgid "Red belt |" msgstr "Ceinture rouge |" #: ../cotinga/cotinga/data/default/data/pmdoc/presets.py:79 msgid "Red belt ||" msgstr "Ceinture rouge ||" #: ../cotinga/cotinga/core/tools.py:79 msgid "Cotinga files" msgstr "Fichiers Cotinga" #: ../cotinga/cotinga/gui/dialogs/file_save_as.py:52 #: ../cotinga/cotinga/gui/dialogs/file_open.py:46 msgid "Please choose a file" msgstr "Choisissez un fichier" #: ../cotinga/cotinga/core/errors.py:35 msgid "An error occured in Cotinga" msgstr "Une erreur s'est produite dans Cotinga" #: ../cotinga/cotinga/core/errors.py:45 #, python-brace-format msgid "Cannot load file: {filename}." msgstr "Impossible de charger le fichier {filename}." #: ../cotinga/cotinga/core/pmdoc/database.py:105 #, python-brace-format msgid "Missing table \"{tablename}\" in the file to load ({filename})." msgstr "" "Table manquante \"{tablename}\" dans le fichier à charger ({filename})." #: ../cotinga/cotinga/core/pmdoc/database.py:111 #, python-brace-format msgid "" "Found extraneous table \"{tablename}\" in the file to load ({filename})." msgstr "" "Table superflue \"{tablename}\" dans le fichier à charger ({filename})." #: ../cotinga/cotinga/core/pmdoc/document.py:193 msgid "Cannot load file" msgstr "Fichier impossible à charger" #: ../cotinga/cotinga/core/pmdoc/document.py:194 #, python-brace-format msgid "" "{software_name} cannot use this file.\n" "Details: {details}" msgstr "" "{software_name} ne peut pas utiliser ce fichier.\n" "Détails : {details}" #: ../cotinga/cotinga/core/pmdoc/database.py:120 #, python-brace-format msgid "" "Missing column \"{column_name}\" in table \"{tablename}\" of the file to " "load ({filename})." msgstr "" "Colonne manquante \"{column_name}\" dans la table\"{tablename}\" du fichier " "à charger ({filename})." #: ../cotinga/cotinga/core/pmdoc/database.py:128 #, python-brace-format msgid "" "Found extraneous column \"{column_name}\" in table \"{tablename}\" of the " "file to load ({filename})." msgstr "" "Colonne superflue \"{column_name}\" dans la table\"{tablename}\" du fichier " "à charger ({filename})." #: ../cotinga/cotinga/gui/dialogs/save_before.py:45 msgid "Unsaved document" msgstr "Document non sauvegardé" #: ../cotinga/cotinga/core/pmdoc/document.py:74 msgid "Save current document before closing it?" msgstr "Sauvegarder le document avant de le fermer ?" #: ../cotinga/cotinga/core/pmdoc/document.py:57 msgid "Save current document before creating a new one?" msgstr "Sauvegarder le document avant d'en créer un nouveau ?" #: ../cotinga/cotinga/core/pmdoc/document.py:180 msgid "Save current document before opening another one?" msgstr "Sauvegarder le document avant d'en ouvrir un autre ?" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:134 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:136 msgid "Attained level" msgstr "Niveau atteint" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:201 msgid "None" msgstr "Aucune" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:49 msgid "Document settings" msgstr "Paramètres du document" #: ../cotinga/cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py:85 msgid "Classes" msgstr "Classes" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:175 msgid "You can start creating classes in the document settings." msgstr "" "Vous pouvez commencer à créer des classes dans les paramètres du document." #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:664 msgid "Change initial level" msgstr "Modifier le niveau initial" #: ../cotinga/cotinga/gui/application.py:116 msgid "Progression manager" msgstr "Gestionnaire de progression" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:679 msgid "Move to another class" msgstr "Déplacer vers une autre classe" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:208 msgid "All" msgstr "Toutes" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:165 msgid "Global view" msgstr "Vue globale" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:453 #: ../cotinga/cotinga/gui/panels/list_manager_base.py:300 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:595 msgid "Reserved group of characters" msgstr "Groupe de caractères réservés" #: ../cotinga/cotinga/gui/panels/list_manager_base.py:301 msgid "" "The group of characters \"{}\" is reserved for internal use, you cannot use " "them here, sorry.\n" "Modification cancelled." msgstr "" "Le groupe de caractères \"{}\" est réservé à un usage interne, vous ne " "pouvez pas l'utiliser ici, désolé.\n" "Modification annulée." #: ../cotinga/cotinga/gui/application.py:118 #, python-brace-format msgid "Progression manager – {doc_title}" msgstr "Gestionnaire de progression – {doc_title}" #: ../cotinga/cotinga/gui/application.py:121 msgid "Progression manager – (New document)" msgstr "Gestionnaire de progression – (Nouveau document)" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:195 msgid "Visible classes:" msgstr "Classes visibles :" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:290 msgid "Pupils' number: {}" msgstr "Nombre d'élèves : {}" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:279 #, python-brace-format msgid "{level}: {number}" msgstr "{level} : {number}" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:292 msgid "Next evaluation:" msgstr "Prochaine évaluation :" #: ../cotinga/cotinga/core/pmdoc/report.py:49 #, python-brace-format msgid "{level} ({nb})" msgstr "{level} ({nb})" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:391 msgid "Report preview" msgstr "Aperçu du bilan" #: ../cotinga/cotinga/core/pmdoc/report.py:110 #, python-brace-format msgid "Following levels will be attempted (update {date})" msgstr "Les niveaux suivants vont être tentés (mise à jour du {date})" #: ../cotinga/cotinga/gui/dialogs/file_save_as.py:62 #, python-brace-format msgid "Report {date}.pdf" msgstr "Bilan {date}.pdf" #: ../cotinga/cotinga/core/tools.py:70 msgid "Any files" msgstr "Tous les fichiers" #: ../cotinga/cotinga/core/tools.py:90 msgid "Any pdf file" msgstr "Fichiers pdf" #: ../cotinga/cotinga/core/pmdoc/document.py:153 msgid "This archive file does not contain the expected parts (found {})." msgstr "Cette archive ne contient pas les parties attendues (trouvé {})." #: ../cotinga/cotinga/core/pmdoc/document.py:161 msgid "The database is not correct (found MIME type {})." msgstr "Cette base de données n'est pas correcte (trouvé le MIME type {})." #: ../cotinga/cotinga/core/pmdoc/document.py:168 msgid "The setup part is not correct (found MIME type {})." msgstr "Ce fichier de réglages n'est pas correct (trouvé le MIME type {})." #: ../cotinga/cotinga/gui/dialogs/file_save_as.py:66 msgid "Untitled.tgz" msgstr "Sans Titre.tgz" #: ../cotinga/cotinga/core/pmdoc/document.py:174 msgid "This file could not be read or uncompressed correctly." msgstr "Ce fichier n'a pas pu être lu ou décompressé correctement." #: ../cotinga/cotinga/core/pmdoc/document.py:146 msgid "This file is not a readable compressed archive." msgstr "Ce fichier n'est pas une archive compressée lisible." #: ../cotinga/cotinga/core/errors.py:56 #, python-brace-format msgid "Duplicate content: {content}." msgstr "Doublon : {content}." #: ../cotinga/cotinga/core/errors.py:67 msgid "Empty content." msgstr "Contenu vide." #: ../cotinga/cotinga/core/errors.py:77 msgid "No change." msgstr "Pas de changement." #: ../cotinga/cotinga/core/errors.py:87 #, python-brace-format msgid "Found reserved characters in: {text}." msgstr "Caractères réservés trouvés dans : {text}." #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:596 msgid "" "The group of characters \"{}\" has been found in the data you're about to " "paste, but it is reserved for internal use.\n" "Please remove it from the data you want to paste before pasting again.\n" "Pasting pupils' names cancelled." msgstr "" "Le groupe de caractères \"{}\" a été trouvé dans les données que vous vous " "apprêtez à coller, mais il est réservé à un usage interne.\n" "Veuillez s'il vous plaît le retirer des données que vous souhaiter coller " "avant de coller à nouveau.\n" "Collage des noms d'élèves annulé." #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:625 msgid "Empty lines" msgstr "Lignes vides" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:626 msgid "" "The empty lines that have been found in the data you want to paste\n" "have been automatically removed." msgstr "" "Des lignes vides ont été trouvées dans les données que vous voulez coller.\n" "Elles ont été retirées automatiquement." #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:436 msgid "" "There are too few grades.\n" "It is required to paste as many grades as pupils." msgstr "" "Il n'y a pas assez de notes.\n" "Il est requis de coller autant de notes qu'il y a d'élèves." #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:439 msgid "" "There are too many grades.\n" "It is required to paste as many grades as pupils." msgstr "" "Il y a trop de notes.\n" "Il est requis de coller autant de notes qu'il y a d'élèves." #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:441 msgid "Number of pupils and grades mismatch" msgstr "Les nombres d'élèves et de notes ne correspondent pas" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:454 msgid "" "The group of characters \"{}\" has been found in the data you're about to " "paste, but it is reserved for internal use.\n" "Please remove it from the data you want to paste before pasting again.\n" "Pasting grades cancelled." msgstr "" "Le groupe de caractères \"{}\" a été trouvé dans les données que vous vous " "apprêtez à coller, mais il est réservé à un usage interne.\n" "Veuillez s'il vous plaît le retirer des données que vous souhaiter coller " "avant de coller à nouveau.\n" "Collage des notes annulé." #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:468 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:606 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:493 msgid "Names" msgstr "Noms" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:503 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:608 msgid "Please confirm" msgstr "Veuillez confirmer" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:609 msgid "Add following pupils?" msgstr "Ajouter les élèves suivants?" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:469 msgid "Grades" msgstr "Notes" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:471 msgid "Add following grades?" msgstr "Ajouter les notes suivantes ?" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:494 msgid "Grade #{}" msgstr "Note #{}" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:497 msgid "Update" msgstr "Mise à jour" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:501 msgid "Modify following grades?" msgstr "Modifier les notes suivantes ?" #: ../cotinga/cotinga/core/pmdoc/report.py:99 msgid "and" msgstr "et" #: ../cotinga/cotinga/core/pmdoc/report.py:102 #, python-brace-format msgid "Next evaluation ({classes_list})" msgstr "Prochaine évaluation ({classes_list})" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:109 #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:89 #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:98 msgid "Included" msgstr "Inclus" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:81 msgid "View columns:" msgstr "Voir les colonnes :" #: ../cotinga/cotinga/gui/dialogs/preferences.py:115 msgid "Developer tools" msgstr "Outils développeur" #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:125 msgid "New" msgstr "Nouveau" #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:126 msgid "Open" msgstr "Ouvrir" #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:127 msgid "Save" msgstr "Enregistrer" #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:128 msgid "Save as..." msgstr "Enregistrer sous..." #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:129 msgid "Close" msgstr "Fermer" #: ../cotinga/cotinga/gui/pupils_progression_manager/toolbar.py:130 msgid "Settings" msgstr "Paramètres" #: ../cotinga/cotinga/gui/panels/list_manager_base.py:117 msgid "Add" msgstr "Ajouter" #: ../cotinga/cotinga/gui/panels/list_manager_base.py:118 msgid "Remove" msgstr "Enlever" #: ../cotinga/cotinga/gui/dialogs/preferences.py:103 msgid "Show toolbar buttons labels" msgstr "Montrer les noms des boutons" #: ../cotinga/cotinga/gui/panels/pupils_view_panel.py:253 msgid "Preview" msgstr "Aperçu" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:320 msgid "Insert a pupil" msgstr "Ajouter un élève" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:323 msgid "Edit class" msgstr "Changer de classe" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:324 msgid "Paste pupils" msgstr "Coller une liste d'élèves" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:325 msgid "Paste grades" msgstr "Coller une liste de notes" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:326 msgid "Add new grade" msgstr "Ajouter une nouvelle note" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:321 msgid "Remove pupils" msgstr "Enlever des élèves" #: ../cotinga/cotinga/gui/panels/pupils_manager_panel.py:322 msgid "Edit initial level" msgstr "Modifier le niveau initial" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:125 msgid "Welcome in Cotinga" msgstr "Bienvenue dans Cotinga" #: ../cotinga/cotinga/gui/pupils_progression_manager/page.py:126 msgid "Version {}" msgstr "Version {}" #~ msgid "Edit level" #~ msgstr "Modifier le niveau initial" #~ msgid "Any sqlite3 database" #~ msgstr "Bases de données sqlite3" #~ msgid "This file is not a gzipped tar file (found {} instead)." #~ msgstr "" #~ "Ce fichier n'est pas une archive compressée au format attendu (à la " #~ "place, on a trouvé {})." #~ msgid "Filters:" #~ msgstr "Filtres :" #~ msgid "No empty label!" #~ msgstr "Pas d'étiquette vide !" #~ msgid "" #~ "Each label must contain at least one symbol.\n" #~ "Modification cancelled." #~ msgstr "" #~ "Chaque étiquette doit contenir au moins un symbole.\n" #~ "Modification annulée." #~ msgid "Level" #~ msgstr "Niveau" #~ msgid "White belt, 1st stripe" #~ msgstr "Ceinture blanche, 1er trait" #~ msgid "Yellow belt, 1st stripe" #~ msgstr "Ceinture jaune, 1er trait" #~ msgid "Orange belt, 1st stripe" #~ msgstr "Ceinture orange, 1er trait" #~ msgid "Green belt, 1st stripe" #~ msgstr "Ceinture verte, 1er trait" #~ msgid "Blue belt, 1st stripe" #~ msgstr "Ceinture bleue, 1er trait" #~ msgid "Brown belt, 1st stripe" #~ msgstr "Ceinture marron, 1er trait" #~ msgid "Red belt, 1st stripe" #~ msgstr "Ceinture rouge, 1er trait" #~ msgid "White belt, 2d stripe" #~ msgstr "Ceinture blanche, 2e trait" #~ msgid "Yellow belt, 2d stripe" #~ msgstr "Ceinture jaune, 2e trait" #~ msgid "Orange belt, 2d stripe" #~ msgstr "Ceinture orange, 2e trait" #~ msgid "Green belt, 2d stripe" #~ msgstr "Ceinture verte, 2e trait" #~ msgid "Blue belt, 2d stripe" #~ msgstr "Ceinture bleue, 2e trait" #~ msgid "Brown belt, 2d stripe" #~ msgstr "Ceinture marron, 2e trait" #~ msgid "Red belt, 2d stripe" #~ msgstr "Ceinture rouge, 2e trait" #~ msgid "__GRADES_LABELS__" #~ msgstr "Libellés" #~ msgid "__LEVELS_LABELS__" #~ msgstr "Libellés" #~ msgid "__SPECIAL_GRADES_LABELS__" #~ msgstr "Libellés" #~ msgid "White, yellow, orange, green, blue, brown, black (karate like)" #~ msgstr "White, yellow, orange, green, blue, brown, black (karate like)" #~ msgid "" #~ "If you validate, your current grades will be replaced by the chosen scale." #~ msgstr "" #~ "Si vous validez, les notes actuelles seront remplacées par l'échelle " #~ "choisie." #~ msgid "Five letters (US style)" #~ msgstr "Cinq lettres (style USA)" #~ msgid "Five letters and signs" #~ msgstr "Cinq lettres, avec signes" #~ msgid "Five letters and signs (US style)" #~ msgstr "Cinq lettres, avec signes (style USA)" #~ msgid "Best grade: {grade}" #~ msgstr "Meilleure note : {grade}" #~ msgid "Worst grade: {grade}" #~ msgstr "Plus mauvaise note : {grade}" #~ msgid "" #~ "Grades list,\n" #~ "from highest to lowest:" #~ msgstr "" #~ "Liste des notes,\n" #~ "de la plus haute à la plus basse :" PK!eZIZI"cotinga/data/pics/cotinga_icon.svg image/svg+xml PK!fIfI2cotinga/data/pics/cotinga_icon_black_and_white.svg image/svg+xml PK!vIvI(cotinga/data/pics/cotinga_icon_faded.svg image/svg+xml PK!G=II8cotinga/data/pics/cotinga_icon_faded_black_and_white.svg image/svg+xml PK!-/cotinga/data/pics/flags/FR.svg PK!<ۯcotinga/data/pics/flags/US.svg PK!Dcotinga/gui/__init__.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from cotinga.core import shared shared.init() __all__ = ['run'] def run(): global app from .application import Application app = Application() app.run() PK!`JJcotinga/gui/app_menu.xml
LABEL_PREFERENCES app.preferences LABEL_ABOUT app.about LABEL_QUIT app.quit
PK!Ĭk"k"cotinga/gui/application.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os from gettext import translation import gi try: gi.require_version('Gtk', '3.0') gi.require_version('GdkPixbuf', '2.0') except ValueError: raise else: from gi.repository import Gtk, Gio, GdkPixbuf from cotinga.core.env import __myname__, __authors__, __version__ from cotinga.core.env import GUIDIR, COTINGA_ICON from cotinga.core.env import LOCALEDIR, L10N_DOMAIN from cotinga.core.shared import PREFS, STATUS from .pupils_progression_manager import PupilsProgressionManagerPage from .dialogs import PreferencesDialog # TODO: add keyboard shorcuts # examples: suppr to remove an entry (in any editable list), # ctrl-O to open file, ctrl-s to save, ctrl-S to save as etc. # TODO: add tooltips on buttons class AppWindow(Gtk.ApplicationWindow): def __init__(self, *args, **kwargs): tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext super().__init__(*args, **kwargs) self.set_icon_from_file(COTINGA_ICON) self.set_border_width(3) hb = Gtk.HeaderBar() hb.set_show_close_button(True) hb.props.title = __myname__.capitalize() self.set_titlebar(hb) with open(os.path.join(GUIDIR, 'app_menu.xml'), 'r') as f: menu_xml = f.read() menu_xml = menu_xml.replace('LABEL_PREFERENCES', tr('Preferences')) menu_xml = menu_xml.replace('LABEL_ABOUT', tr('About')) menu_xml = menu_xml.replace('LABEL_QUIT', tr('Quit')) builder = Gtk.Builder.new_from_string(menu_xml, -1) menu = builder.get_object('app-menu') button = Gtk.MenuButton.new() popover = Gtk.Popover.new_from_model(button, menu) button.set_popover(popover) button.show() button = Gtk.MenuButton.new() icon = Gtk.Image.new_from_icon_name('open-menu-symbolic', Gtk.IconSize.BUTTON) button.add(icon) popover = Gtk.Popover.new_from_model(button, menu) button.set_popover(popover) hb.pack_end(button) self.notebook = Gtk.Notebook() self.pupils_progression_manager_page = PupilsProgressionManagerPage() # TODO: maybe move the set_sensitive() calls below to # PupilsProgressionManagerPage.__init__() self.pupils_progression_manager_page.toolbar\ .buttons['document-save']\ .set_sensitive(STATUS.document_modified) self.pupils_progression_manager_page.toolbar\ .buttons['document-save-as']\ .set_sensitive(STATUS.document_loaded) self.pupils_progression_manager_page.toolbar\ .buttons['document-setup']\ .set_sensitive(STATUS.document_loaded) self.pupils_progression_manager_page.toolbar\ .buttons['document-close']\ .set_sensitive(STATUS.document_loaded) self.notebook.append_page(self.pupils_progression_manager_page, Gtk.Label('')) self.refresh_progression_manager_tab_title() outergrid = Gtk.Grid() outergrid.add(self.notebook) outergrid.show() self.add(outergrid) self.app = kwargs.get('application') self.connect('delete-event', self.do_quit) def do_quit(self, *args): self.app.on_quit(None, None) def refresh_progression_manager_tab_title(self): tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext title = tr('Progression manager') if STATUS.document_name: title = tr('Progression manager – {doc_title}')\ .format(doc_title=os.path.basename(STATUS.document_name)) elif STATUS.document_loaded: title = tr('Progression manager – (New document)') if STATUS.document_modified: title += ' *' self.notebook.set_tab_label(self.pupils_progression_manager_page, Gtk.Label(title)) class Application(Gtk.Application): def __init__(self, *args, **kwargs): super().__init__(*args, application_id='org.cotinga_app', **kwargs) self.window = None self.logo = GdkPixbuf.Pixbuf.new_from_file_at_scale(COTINGA_ICON, 128, -1, True) def do_startup(self): Gtk.Application.do_startup(self) action = Gio.SimpleAction.new('preferences', None) action.connect('activate', self.on_preferences) self.add_action(action) action = Gio.SimpleAction.new('about', None) action.connect('activate', self.on_about) self.add_action(action) action = Gio.SimpleAction.new('quit', None) action.connect('activate', self.on_quit) self.add_action(action) def do_activate(self): # We only allow a single window and raise any existing ones if not self.window: # Windows are associated with the application # when the last one is closed the application shuts down self.window = AppWindow(application=self, title=__myname__.capitalize()) self.window.set_size_request(700, 350) self.window.set_default_size(800, 500) self.window.present() self.window.show_all() if self.window.pupils_progression_manager_page.view_panel is not None: self.window.pupils_progression_manager_page\ .view_panel.setup_info_visibility() def on_preferences(self, action, param): tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext pref_dialog = PreferencesDialog(tr('Preferences'), PREFS.language) pref_dialog.set_transient_for(self.window) pref_dialog.set_modal(True) pref_dialog.run() chosen_language = pref_dialog.chosen_language chosen_devtools = pref_dialog.devtools_switch.get_active() chosen_show_toolbar_labels = pref_dialog\ .show_toolbar_labels_switch.get_active() pref_dialog.destroy() previous_language = PREFS.language previous_devtools = PREFS.enable_devtools previous_show_toolbar_labels = PREFS.show_toolbar_labels recreate_window = False if (chosen_language is not None and previous_language != chosen_language): PREFS.language = chosen_language recreate_window = True if previous_devtools != chosen_devtools: PREFS.enable_devtools = chosen_devtools recreate_window = True if previous_show_toolbar_labels != chosen_show_toolbar_labels: PREFS.show_toolbar_labels = chosen_show_toolbar_labels recreate_window = True if recreate_window: self.window.destroy() self.window = None self.do_activate() def on_about(self, action, param): tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext about_dialog = Gtk.AboutDialog(transient_for=self.window, modal=True) about_dialog.set_authors(__authors__) about_dialog.set_version(__version__) about_dialog.set_program_name(__myname__) # about_dialog.props.wrap_license = True about_dialog.set_website( 'https://gitlab.com/nicolas.hainaux/cotinga') about_dialog.set_website_label(tr('Cotinga website')) about_dialog.set_logo(self.logo) about_dialog.set_copyright('Copyright © 2018 Nicolas Hainaux') about_dialog.set_comments(tr('Cotinga helps teachers to manage ' "their pupils' progression.")) # with open('LICENSE', 'r') as f: # Either this or the licence type # about_dialog.set_license(f.read()) about_dialog.set_license_type(Gtk.License.GPL_3_0) about_dialog.run() about_dialog.destroy() def on_quit(self, action, param): self.quit() PK!&^cotinga/gui/core/__init__.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from .icons_themable import IconsThemable __all__ = ['IconsThemable'] PK!? _ "cotinga/gui/core/icons_themable.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from abc import ABCMeta, abstractmethod import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga.core.env import ICON_THEME from cotinga.core import shared __all__ = ['IconsThemable'] class IconsThemable(object, metaclass=ABCMeta): def __init__(self): ICON_THEME.connect('changed', self.on_icon_theme_changed) def setup_buttons_icons(self, icon_theme): """Set icon and label of all buttons in self.buttons_icons().""" for btn_name in self.buttons_icons(): for icon_name in self.buttons_icons()[btn_name]: if icon_theme.has_icon(icon_name): button = getattr(self, btn_name) if shared.PREFS.show_toolbar_labels: btn_lbl_widget = Gtk.Grid() pic = Gtk.Image.new_from_icon_name( icon_name, Gtk.IconSize.LARGE_TOOLBAR) btn_lbl_widget.attach(pic, 0, 0, 1, 1) txt = self.buttons_labels()[btn_name] lbl = Gtk.Label(txt) lbl.props.margin_left = 5 btn_lbl_widget.attach_next_to( lbl, pic, Gtk.PositionType.RIGHT, 1, 1) button.set_label_widget(btn_lbl_widget) else: button.set_icon_name(icon_name) break def on_icon_theme_changed(self, icon_theme): self.setup_buttons_icons(icon_theme) @abstractmethod def buttons_icons(self): """Defines icon names and fallback to standard icon name.""" # Last item of each list is the fallback, hence must be standard @abstractmethod def buttons_labels(self): """Define labels of buttons.""" # Must use the same names as in buttons_icons() PK!0Xcotinga/gui/dialogs/__init__.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from .preview import PreviewDialog from .preferences import PreferencesDialog from .message import run_message_dialog from .presets_combo import PresetsComboDialog from .combo import ComboDialog from .file_open import OpenFileDialog from .file_save_as import SaveAsFileDialog from .save_before import SaveBeforeDialog from .confirmation import ConfirmationDialog __all__ = ['PreferencesDialog', 'run_message_dialog', 'PresetsComboDialog', 'OpenFileDialog', 'SaveAsFileDialog', 'SaveBeforeDialog', 'ComboDialog', 'PreviewDialog', 'ConfirmationDialog'] PK!Acotinga/gui/dialogs/combo.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga import gui __all__ = ['ComboDialog'] # LATER: factorize code with PresetsComboDialog (only the source changes; take # care of on_choice_changed too, and keep this version for the message) class ComboDialog(Gtk.Dialog): def __init__(self, title, message, source): Gtk.Dialog.__init__(self, title, gui.app.window, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self.set_modal(True) self.set_size_request(450, 100) self.box = self.get_content_area() self.main_grid = Gtk.Grid() self.main_grid.set_border_width(5) self.main_grid.set_hexpand(True) # As Gtk.Box will get deprecated, one can expect that # get_content_area() will later return something else than a Box. # Note that then, box can be replaced by self.main_grid central_grid = Gtk.Grid() central_grid.set_hexpand(False) if message not in [None, '']: message_label = Gtk.Label(message) else: message_label = Gtk.Grid() central_grid.attach(message_label, 0, 0, 1, 1) store = Gtk.ListStore(str) for entry in source: store.append([entry]) self.source = source combo = Gtk.ComboBox.new_with_model(store) renderer = Gtk.CellRendererText() combo.pack_start(renderer, False) combo.add_attribute(renderer, 'text', 0) combo.set_active(0) combo.connect('changed', self.on_choice_changed) tree_iter = combo.get_active_iter() model = combo.get_model() self.choice = model[tree_iter][0] central_grid.attach_next_to(combo, message_label, Gtk.PositionType.BOTTOM, 1, 1) void1 = Gtk.Grid() void1.set_hexpand(True) void2 = Gtk.Grid() void2.set_hexpand(True) self.main_grid.attach(void1, 0, 0, 1, 1) self.main_grid.attach_next_to(central_grid, void1, Gtk.PositionType.RIGHT, 1, 1) self.main_grid.attach_next_to(void2, central_grid, Gtk.PositionType.RIGHT, 1, 1) self.box.add(self.main_grid) self.show_all() def on_choice_changed(self, combo): # TODO: simplify such callback functions: couldn't tree_iter be # returned by a property? tree_iter = combo.get_active_iter() if tree_iter is not None: model = combo.get_model() self.choice = model[tree_iter][0] else: entry = combo.get_child() print('Entered: %s' % entry.get_text()) PK!ϫٚ  #cotinga/gui/dialogs/confirmation.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga import gui __all__ = ['ConfirmationDialog'] # LATER: maybe use this code to factorize some other dialogs class ConfirmationDialog(Gtk.Dialog): def __init__(self, title, message=None, widget=None): Gtk.Dialog.__init__(self, title, gui.app.window, 0, (Gtk.STOCK_NO, Gtk.ResponseType.NO, Gtk.STOCK_YES, Gtk.ResponseType.YES)) self.set_modal(True) self.set_size_request(450, 100) self.box = self.get_content_area() self.main_grid = Gtk.Grid() self.main_grid.set_border_width(5) self.main_grid.set_hexpand(True) self.main_grid.set_halign(Gtk.Align.CENTER) self.main_grid.set_valign(Gtk.Align.CENTER) # As Gtk.Box will get deprecated, one can expect that # get_content_area() will later return something else than a Box. # Note that then, box can be replaced by self.main_grid if message is not None: message = Gtk.Label(message) else: message = Gtk.Grid() self.main_grid.attach(message, 0, 0, 1, 1) if widget is not None: self.main_grid.attach_next_to(widget, message, Gtk.PositionType.BOTTOM, 1, 1) self.box.add(self.main_grid) self.show_all() PK! 㢒WW cotinga/gui/dialogs/file_open.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gettext import translation import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga import gui from cotinga.core import shared from cotinga.core.env import L10N_DOMAIN, LOCALEDIR from cotinga.core.tools import add_cot_filters __all__ = ['OpenFileDialog'] class OpenFileDialog(Gtk.FileChooserDialog): def __init__(self): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext Gtk.FileChooserDialog.__init__(self, tr('Please choose a file'), gui.app.window, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) self.set_modal(True) add_cot_filters(self) PK!s/z z #cotinga/gui/dialogs/file_save_as.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from datetime import datetime from gettext import translation import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga import gui from cotinga.core import shared from cotinga.core.env import L10N_DOMAIN, LOCALEDIR from cotinga.core.tools import add_cot_filters, add_pdf_filters __all__ = ['SaveAsFileDialog'] class SaveAsFileDialog(Gtk.FileChooserDialog): def __init__(self, report=False): """ :param report: whether we're about to save a report rather than the current user file :type report: bool """ PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext Gtk.FileChooserDialog.__init__(self, tr('Please choose a file'), gui.app.window, Gtk.FileChooserAction.SAVE, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE_AS, Gtk.ResponseType.OK)) if report: date_fmt = shared.PREFS.pmreport['date_fmt'] date = datetime.now().strftime(date_fmt).replace('/', '-') self.set_current_name(tr('Report {date}.pdf') .format(date=date)) else: if shared.STATUS.document_name == '': self.set_current_name(tr('Untitled.tgz')) else: self.set_filename(shared.STATUS.document_name) self.set_modal(True) self.set_do_overwrite_confirmation(True) if report: add_pdf_filters(self) else: add_cot_filters(self) PK!I}}cotinga/gui/dialogs/message.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga import gui def run_message_dialog(title, info, icon_name, parent=None): if parent is None: parent = gui.app.window dialog = Gtk.Dialog(title, parent, 0, (Gtk.STOCK_OK, Gtk.ResponseType.OK), modal=True) dialog.set_default_size(150, 100) label = Gtk.Label(info) # REVIEW: Dialog icon set is ignored (bug?) # dialog.set_icon( # Gtk.Image.new_from_icon_name('dialog-information', # Gtk.IconSize.BUTTON) # .get_pixbuf()) bigger_icon = Gtk.Image.new_from_icon_name( icon_name, Gtk.IconSize.DIALOG) grid = Gtk.Grid() grid.attach(bigger_icon, 0, 0, 1, 1) grid.attach_next_to(label, bigger_icon, Gtk.PositionType.RIGHT, 1, 1) box = dialog.get_content_area() box.add(grid) dialog.show_all() dialog.run() dialog.destroy() PK!k"cotinga/gui/dialogs/preferences.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os from gettext import translation from babel import Locale import gi try: gi.require_version('Gtk', '3.0') gi.require_version('GdkPixbuf', '2.0') except ValueError: raise else: from gi.repository import Gtk, GdkPixbuf from cotinga import gui from cotinga.core.env import L10N_DOMAIN, SUPPORTED_LANGUAGES from cotinga.core.env import LOCALEDIR, FLAGSDIR from cotinga.core import shared __all__ = ['PreferencesDialog'] class PreferencesDialog(Gtk.Dialog): def __init__(self, title, default_language, first_run=False, window=None): # An optional window argument must be provided at first run if window is None: window = gui.app.window tr = translation(L10N_DOMAIN, LOCALEDIR, [default_language]).gettext buttons = {True: (Gtk.STOCK_OK, Gtk.ResponseType.OK), False: (Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)} Gtk.Dialog.__init__(self, title, window, 0, buttons[first_run]) self.set_default_size(250, 100) self.box = self.get_content_area() self.main_grid = Gtk.Grid() self.main_grid.set_border_width(5) # As Gtk.Box will get deprecated, one can expect that # get_content_area() will later return something else than a Box. # Note that then, box can be replaced by self.main_grid self.main_grid.set_column_spacing(25) language_label = Gtk.Label(tr('Choose a language:')) self.main_grid.attach(language_label, 0, 0, 1, 1) store = Gtk.ListStore(GdkPixbuf.Pixbuf, str) self.languages = {} currently_selected = -1 for i, lang_code in enumerate(SUPPORTED_LANGUAGES): loc = Locale.parse(lang_code) language_name = loc.get_display_name(default_language) flag_filename = '{}.svg'.format(lang_code.split('_')[1]) flag_icon = GdkPixbuf.Pixbuf.new_from_file_at_scale( os.path.join(FLAGSDIR, flag_filename), 24, -1, True) store.append([flag_icon, language_name]) self.languages[language_name] = lang_code if lang_code == default_language: currently_selected = i combo = Gtk.ComboBox.new_with_model(store) renderer = Gtk.CellRendererPixbuf() combo.pack_start(renderer, True) combo.add_attribute(renderer, 'pixbuf', 0) renderer = Gtk.CellRendererText() combo.pack_start(renderer, False) combo.add_attribute(renderer, 'text', 1) if currently_selected >= 0: combo.set_active(currently_selected) combo.connect('changed', self.on_language_changed) self.chosen_language = None self.main_grid.attach_next_to(combo, language_label, Gtk.PositionType.BOTTOM, 1, 1) if not first_run: show_toolbar_labels = Gtk.Label(tr('Show toolbar buttons labels')) show_toolbar_labels.props.margin_right = 10 self.show_toolbar_labels_switch = Gtk.Switch() self.show_toolbar_labels_switch.set_active( shared.PREFS.show_toolbar_labels) self.main_grid.attach_next_to(show_toolbar_labels, language_label, Gtk.PositionType.RIGHT, 1, 1) self.main_grid.attach_next_to(self.show_toolbar_labels_switch, combo, Gtk.PositionType.RIGHT, 1, 1) devtools_label = Gtk.Label(tr('Developer tools')) devtools_label.props.margin_right = 10 self.devtools_switch = Gtk.Switch() self.devtools_switch.set_active(shared.PREFS.enable_devtools) self.main_grid.attach_next_to(devtools_label, show_toolbar_labels, Gtk.PositionType.RIGHT, 1, 1) self.main_grid.attach_next_to(self.devtools_switch, self.show_toolbar_labels_switch, Gtk.PositionType.RIGHT, 1, 1) self.box.add(self.main_grid) self.show_all() def on_language_changed(self, combo): tree_iter = combo.get_active_iter() if tree_iter is not None: model = combo.get_model() language_name = model[tree_iter][1] print('Selected: language_name={}, country_code={}' .format(language_name, self.languages[language_name])) self.chosen_language = self.languages[language_name] else: entry = combo.get_child() print('Entered: %s' % entry.get_text()) PK!,͓  $cotinga/gui/dialogs/presets_combo.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga import gui __all__ = ['PresetsComboDialog'] class PresetsComboDialog(Gtk.Dialog): def __init__(self, title, message, source): Gtk.Dialog.__init__(self, title, gui.app.window, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self.set_modal(True) self.set_size_request(450, 100) self.box = self.get_content_area() self.main_grid = Gtk.Grid() self.main_grid.set_border_width(5) self.main_grid.set_hexpand(True) # As Gtk.Box will get deprecated, one can expect that # get_content_area() will later return something else than a Box. # Note that then, box can be replaced by self.main_grid central_grid = Gtk.Grid() central_grid.set_hexpand(False) message_label = Gtk.Label(message) central_grid.attach(message_label, 0, 0, 1, 1) entries = sorted([[source[k][0], k] for k in source], key=lambda k: k[0]) store = Gtk.ListStore(str, str) for entry in entries: store.append(entry) self.source = source combo = Gtk.ComboBox.new_with_model(store) renderer = Gtk.CellRendererText() combo.pack_start(renderer, False) combo.add_attribute(renderer, 'text', 0) combo.set_active(0) combo.connect('changed', self.on_choice_changed) tree_iter = combo.get_active_iter() self.choice = self.source[store[tree_iter][1]][1] central_grid.attach_next_to(combo, message_label, Gtk.PositionType.BOTTOM, 1, 1) void1 = Gtk.Grid() void1.set_hexpand(True) void2 = Gtk.Grid() void2.set_hexpand(True) self.main_grid.attach(void1, 0, 0, 1, 1) self.main_grid.attach_next_to(central_grid, void1, Gtk.PositionType.RIGHT, 1, 1) self.main_grid.attach_next_to(void2, central_grid, Gtk.PositionType.RIGHT, 1, 1) self.box.add(self.main_grid) self.show_all() def on_choice_changed(self, combo): # TODO: simplify such callback functions: couldn't tree_iter be # returned by a property? tree_iter = combo.get_active_iter() if tree_iter is not None: model = combo.get_model() self.choice = self.source[model[tree_iter][1]][1] else: entry = combo.get_child() print('Entered: %s' % entry.get_text()) PK! @@cotinga/gui/dialogs/preview.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import gi try: gi.require_version('Gtk', '3.0') gi.require_version('EvinceView', '3.0') gi.require_version('EvinceDocument', '3.0') except ValueError: raise else: from gi.repository import Gtk, EvinceDocument, EvinceView from cotinga import gui from cotinga.core.env import REPORT_FILE_URI __all__ = ['PreviewDialog'] class PreviewDialog(Gtk.Dialog): def __init__(self, title): Gtk.Dialog.__init__(self, title, gui.app.window, 0, (Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE, Gtk.STOCK_SAVE_AS, Gtk.ResponseType.YES, Gtk.STOCK_PRINT, Gtk.ResponseType.OK)) self.set_modal(True) self.set_size_request(480, 480) self.box = self.get_content_area() scroll = Gtk.ScrolledWindow() # self.add(scroll) EvinceDocument.init() doc = EvinceDocument.Document.factory_get_document(REPORT_FILE_URI) view = EvinceView.View() model = EvinceView.DocumentModel() model.set_document(doc) view.set_model(model) scroll.add(view) scroll.set_hexpand(True) scroll.set_vexpand(True) self.box.add(scroll) self.show_all() PK!  "cotinga/gui/dialogs/save_before.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gettext import translation import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga import gui from cotinga.core import shared from cotinga.core.env import L10N_DOMAIN, LOCALEDIR __all__ = ['SaveBeforeDialog'] class SaveBeforeDialog(Gtk.Dialog): def __init__(self, message): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext Gtk.Dialog.__init__(self, tr('Unsaved document'), gui.app.window, 0, (Gtk.STOCK_YES, Gtk.ResponseType.YES, Gtk.STOCK_NO, Gtk.ResponseType.NO, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) self.set_modal(True) self.set_size_request(450, 100) self.box = self.get_content_area() self.main_grid = Gtk.Grid() self.main_grid.set_border_width(5) self.main_grid.set_hexpand(True) # As Gtk.Box will get deprecated, one can expect that # get_content_area() will later return something else than a Box. # Note that then, box can be replaced by self.main_grid icon = Gtk.Image.new_from_icon_name('dialog-question', Gtk.IconSize.DIALOG) self.main_grid.attach(icon, 0, 0, 1, 1) message_label = Gtk.Label(message) self.main_grid.attach_next_to(message_label, icon, Gtk.PositionType.RIGHT, 1, 1) self.box.add(self.main_grid) self.show_all() PK!Q\cotinga/gui/panels/__init__.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # TODO: rename this module components instead of panels? from .list_manager_base import ListManagerBase from .list_manager_panel import ListManagerPanel from .pupils_manager_panel import PupilsManagerPanel from .pupils_view_panel import PupilsViewPanel __all__ = ['ListManagerBase', 'ListManagerPanel', 'PupilsManagerPanel', 'PupilsViewPanel'] PK!9>22'cotinga/gui/panels/list_manager_base.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import time from gettext import translation import gi try: gi.require_version('Gtk', '3.0') gi.require_version('Gdk', '3.0') except ValueError: raise else: from gi.repository import GLib, Gdk, Gtk, GObject from cotinga.core import shared, pmdoc from cotinga.core.env import LOCALEDIR, L10N_DOMAIN from cotinga.core.env import ICON_THEME from cotinga.core.errors import CotingaError, DuplicateContentError from cotinga.core.errors import EmptyContentError, ReservedCharsError from cotinga.core.errors import NoChangeError from cotinga.gui.dialogs import run_message_dialog from cotinga.gui.core import IconsThemable from cotinga.core import constants SEP = constants.INTERNAL_SEPARATOR class __MetaThemableGrid(type(Gtk.Grid), type(IconsThemable)): pass class ListManagerBase(Gtk.Grid, IconsThemable, metaclass=__MetaThemableGrid): @GObject.Signal def data_changed(self): """Notify that data stored in self.store have changed.""" def __init__(self, setup_buttons_icons=True, mini_items_nb=2, store_types=None, locked=None): Gtk.Grid.__init__(self) IconsThemable.__init__(self) self.set_column_spacing(10) self.set_vexpand(True) self.set_hexpand(True) self.mini_items_nb = mini_items_nb if store_types is None: store_types = [str] if locked is None: self.locked = [] else: self.locked = locked self.store = Gtk.ListStore(*store_types) self.treeview = Gtk.TreeView(self.store) self.treeview.props.margin = 10 self.selection.set_mode(Gtk.SelectionMode.MULTIPLE) self.insert_button = Gtk.ToolButton.new() self.remove_button = Gtk.ToolButton.new() self.selection.connect('changed', self.on_tree_selection_changed) self.new_row_position = None # Also helps to block repeated pushes on 'insert' (setting sensitive # to False does not work from inside on_insert_clicked()) self.started_insertion = False self.started_edition = False self.connect('key-release-event', self.on_key_release) docsetup = pmdoc.setting.load() self.levels = docsetup['levels'] self.classes = docsetup['classes'] self.special_grades = docsetup['special_grades'] self.grading = docsetup['grading'] if setup_buttons_icons: self.setup_buttons_icons(ICON_THEME) @property def selection(self): return self.treeview.get_selection() def buttons_icons(self): """Defines icon names and fallback to standard icon name.""" # Last item of each list is the fallback, hence must be standard buttons = {'insert_button': ['list-add'], 'remove_button': ['list-remove']} return buttons def buttons_labels(self): """Define labels of buttons.""" PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext buttons = {'insert_button': tr('Add'), 'remove_button': tr('Remove') } return buttons def set_buttons_sensitivity(self): selected = self.selection.get_selected_rows()[1] if selected: unlocked = self.store[selected][0] not in self.locked else: unlocked = False # nothing is selected, anyway editing = self.started_insertion or self.started_edition minimum_required = len(self.store) >= self.mini_items_nb + 1 self.remove_button.set_sensitive(selected and unlocked and minimum_required and not editing) self.insert_button.set_sensitive(not editing) def on_key_release(self, widget, ev, data=None): if ev.keyval == Gdk.KEY_Escape and self.started_insertion: self.cancel_insertion() self.post_edit_cleanup() def on_editing_started(self, cell_renderer, editable, path): if self.selection.count_selected_rows() >= 2: # This will trigger an edit canceled and select the current row # instead. GLib.timeout_add(50, self.selection.unselect_all) GLib.timeout_add(60, self.selection.select_path, path) self.started_edition = True self.set_buttons_sensitivity() def on_editing_canceled(self, cell_renderer): if self.started_insertion: self.cancel_insertion() self.post_edit_cleanup() self.set_buttons_sensitivity() def on_insert_clicked(self, widget, at='selection', col_nb=0, override_defaults=None, do_scroll=None): # In case of multiple rows selection, we only take the first one # into account model, treepath = self.selection.get_selected_rows() self.started_insertion = True fill_values = getattr(self, 'default_row_values', None) if override_defaults is not None: for i, value in enumerate(override_defaults): if value is not None: fill_values[i] = value if at == 'selection' and treepath: path = treepath[0] position = int(treepath[0].to_string()) else: # default (e.g. no selection available or at != 'selection') # => at top of the list position = 0 path = Gtk.TreePath(position) self.store.insert(position, fill_values) self.new_row_position = position GLib.timeout_add(50, self.treeview.set_cursor, path, self.treeview.get_column(col_nb), True) time.sleep(0.06) if do_scroll is not None: scrollable_window = do_scroll[0] scrollable_window.do_scroll_child(*do_scroll) self.set_buttons_sensitivity() def on_remove_clicked(self, widget, get_ids=None): model, paths = self.selection.get_selected_rows() refs = [] id_values = [] for path in paths: refs.append(Gtk.TreeRowReference.new(model, path)) for ref in refs: path = ref.get_path() treeiter = model.get_iter(path) value = model.get(treeiter, 0)[0] if hasattr(model, 'remove'): if isinstance(get_ids, int): id_values.append(model.get(treeiter, 0)[get_ids]) model.remove(treeiter) else: # Case of filtered or sortered models # => Usage of get_ids is mandatory if not isinstance(get_ids, int): raise CotingaError('For a TreeModel that does not ' 'implement remove(), it is mandatory ' 'to provide the column number that ' 'will be the key to find the row(s) to ' 'remove.') for i, row in enumerate(self.store): if row[get_ids] == value: rowpath = Gtk.TreePath(i) treeiter = self.store.get_iter(rowpath) if isinstance(get_ids, int): id_values.append( self.store.get_value(treeiter, get_ids)) self.store.remove(treeiter) self.started_insertion = False self.emit('data-changed') self.post_edit_cleanup() if isinstance(get_ids, int): return id_values def on_tree_selection_changed(self, selection): self.set_buttons_sensitivity() def cancel_insertion(self): if self.new_row_position is not None and self.started_insertion: path = Gtk.TreePath(self.new_row_position) treeiter = self.store.get_iter(path) self.store.remove(treeiter) def post_edit_cleanup(self, do_cleanup=True): if do_cleanup: self.started_insertion = False self.started_edition = False self.new_row_position = None self.set_buttons_sensitivity() def get_path_from_id(self, id_value, idcol=0): rowpath = None for i, row in enumerate(self.store): if row[idcol] == id_value: rowpath = Gtk.TreePath(i) break return (i, rowpath) def get_selection_info(self): model, paths = self.selection.get_selected_rows() ref = Gtk.TreeRowReference.new(model, paths[0]) path = ref.get_path() treeiter = model.get_iter(path) id_value = model.get(treeiter, 0)[0] return (id_value, model, treeiter, path) def check_user_entry(self, new_text, old_text=None, forbid_empty_cell=True, forbid_duplicate_content=True, forbid_internal_sep=True, change_is_required=True): if forbid_empty_cell and new_text == '': raise EmptyContentError elif change_is_required and new_text == old_text: raise NoChangeError elif (forbid_duplicate_content and any([row[0] == new_text for row in self.store])): raise DuplicateContentError(new_text) elif forbid_internal_sep and SEP in new_text: raise ReservedCharsError(new_text) def on_cell_edited(self, widget, path, new_text, col_nb=0, forbid_empty_cell=True, forbid_duplicate_content=True, forbid_internal_sep=True, change_is_required=True, do_cleanup=True, cell_store_type=None, cell_store_kwargs=None): id_value, model, treeiter, _ = self.get_selection_info() rowpath = None print('[on_cell_edited] start') accepted = False old_text = model.get(treeiter, col_nb)[0] PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext try: self.check_user_entry( new_text, old_text=old_text, forbid_empty_cell=forbid_empty_cell, forbid_duplicate_content=forbid_duplicate_content, forbid_internal_sep=forbid_internal_sep, change_is_required=change_is_required) except EmptyContentError: if self.started_insertion: self.cancel_insertion() except NoChangeError: pass # Will leave the new content not accepted except DuplicateContentError: run_message_dialog(tr('No duplicates!'), tr('Each label must be unique.\n' 'Modification cancelled.'), 'dialog-warning') self.cancel_insertion() except ReservedCharsError: run_message_dialog(tr('Reserved group of characters'), tr('The group of characters "{}" is ' 'reserved for internal use, you ' 'cannot use them here, sorry.\n' 'Modification cancelled.' ).format(SEP), 'dialog-warning') self.cancel_insertion() else: _, rowpath = self.get_path_from_id(id_value) if rowpath is not None: if cell_store_type is not None: new_text = cell_store_type(new_text, **(cell_store_kwargs or {})) self.store[rowpath][col_nb] = new_text print('\nSTORED {}'.format(new_text)) accepted = True self.emit('data-changed') self.post_edit_cleanup(do_cleanup) print('[on_cell_edited] return accepted={}'.format(accepted)) return (accepted, id_value) PK!SHpDD(cotinga/gui/panels/list_manager_panel.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga.gui.dialogs import PresetsComboDialog from .list_manager_base import ListManagerBase class ListManagerPanel(ListManagerBase): def __init__(self, data_list, data_title, mini_items_nb=2, presets=None, locked=None, store_types=None, reorderable=True, editable=None): """ presets is either None or (source, title, message, icon_name) where source is the presets dictionary (see data/presets.py), title and message are str that contain the title and the message of the combo dialog, icon_name is the name of the presets button to display. """ ListManagerBase.__init__(self, mini_items_nb=mini_items_nb, locked=locked, store_types=store_types) if store_types is None: store_types = [str] if editable is None: editable = [True] * len(store_types) self.data_list = data_list for item in self.data_list: if isinstance(item, tuple): self.store.append(list(item)) else: self.store.append([item]) for i in range(len(store_types)): rend = Gtk.CellRendererText() rend.props.editable = editable[i] rend.props.editable_set = editable[i] if editable[i]: rend.connect('edited', self.on_cell_edited) rend.connect('editing-started', self.on_editing_started) rend.connect('editing-canceled', self.on_editing_canceled) if isinstance(data_title, (list, tuple)): col_title = data_title[i] else: col_title = data_title column = Gtk.TreeViewColumn(col_title, rend, text=i) self.treeview.append_column(column) self.treeview.set_reorderable(reorderable) self.attach(self.treeview, 0, 0, 1, 1) self.buttons_grid = Gtk.Grid() self.buttons_grid.props.margin = 10 self.presets = presets if presets is not None: (self.presets_source, self.presets_title, self.presets_message, self.preset_icon_name) = \ presets self.load_presets_button = \ Gtk.Button.new_from_icon_name(self.preset_icon_name, Gtk.IconSize.BUTTON) self.load_presets_button.set_vexpand(False) self.load_presets_button.set_sensitive(True) self.load_presets_button.connect('clicked', self.on_load_presets_clicked) sep = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL) sep.set_margin_bottom(10) sep.set_margin_top(10) self.buttons_grid.attach(self.load_presets_button, 0, 0, 1, 1) self.buttons_grid.attach_next_to(sep, self.load_presets_button, Gtk.PositionType.BOTTOM, 1, 1) previous = sep else: void = Gtk.Grid() void.set_vexpand(False) void.set_margin_bottom(20) self.buttons_grid.attach(void, 0, 0, 1, 1) previous = void self.insert_button.set_vexpand(False) self.insert_button.connect('clicked', self.on_insert_clicked) self.insert_button.set_margin_bottom(10) self.buttons_grid.attach_next_to(self.insert_button, previous, Gtk.PositionType.BOTTOM, 1, 1) self.remove_button.set_vexpand(False) self.remove_button.set_sensitive(False) self.remove_button.connect('clicked', self.on_remove_clicked) self.buttons_grid.attach_next_to(self.remove_button, self.insert_button, Gtk.PositionType.BOTTOM, 1, 1) self.attach_next_to(self.buttons_grid, self.treeview, Gtk.PositionType.RIGHT, 1, 1) def on_load_presets_clicked(self, widget): dialog = PresetsComboDialog(self.presets_title, self.presets_message, self.presets_source) response = dialog.run() if response == Gtk.ResponseType.OK: self.store.clear() for item in dialog.choice: self.store.append([item]) dialog.destroy() self.emit('data-changed') PK!f`HH*cotinga/gui/panels/pupils_manager_panel.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import time from gettext import translation import gi try: gi.require_version('Gtk', '3.0') gi.require_version('Gdk', '3.0') gi.require_version('Pango', '1.0') except ValueError: raise else: from gi.repository import GLib, Gdk, Gtk, GObject, Pango from cotinga.core.env import LOCALEDIR, L10N_DOMAIN from cotinga.core.env import ICON_THEME, get_icon_theme_name, get_theme_colors from cotinga.core.env import convert_gdk_rgba_to_hex from cotinga.core.tools import Listing, cellfont_fmt, calculate_attained_level from cotinga.core.tools import build_view from cotinga.core import shared from cotinga.models import Pupils, PUPILS_COL_NBS from cotinga.gui.panels import ListManagerBase from cotinga.gui.dialogs import ComboDialog, run_message_dialog from cotinga.gui.dialogs import ConfirmationDialog from cotinga import gui from cotinga.core import constants from cotinga.core.errors import EmptyContentError, ReservedCharsError STEPS = constants.NUMERIC_STEPS SEP = constants.INTERNAL_SEPARATOR # Column numbers of the store ID, INCLUDED, CLASS, FULLNAME, ILEVEL, ALEVEL, GRADES = (0, 1, 2, 3, 4, 5, 6) class PupilsManagerPanel(ListManagerBase): def __init__(self, classname): # TODO: change mouse cursor when hovering editable columns self.classname = classname ListManagerBase.__init__(self, setup_buttons_icons=False, mini_items_nb=0, store_types=[str, bool, str, str, str, str, GObject.TYPE_PYOBJECT]) PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext for pupil in shared.session.query(Pupils)\ .filter_by(classname=classname): self.store.append([str(pupil.id), pupil.included, pupil.classname, pupil.fullname, pupil.initial_level, pupil.attained_level, Listing(pupil.grades)]) self.store.set_sort_column_id(FULLNAME, Gtk.SortType.ASCENDING) liststore_levels = Gtk.ListStore(str) for item in self.levels: liststore_levels.append([item]) def _set_cell_fgcolor(column, cell, model, it, ignored): """Turn not included pupils in grey.""" included = model.get_value(it, INCLUDED) if included: fgcolor, _, _, _ = get_theme_colors() cell.set_property('foreground_rgba', fgcolor) else: cell.set_property('foreground', 'Grey') self.renderer_id = Gtk.CellRendererText() self.col_id = Gtk.TreeViewColumn('id', self.renderer_id, text=0) self.col_id.set_cell_data_func(self.renderer_id, _set_cell_fgcolor, '') self.col_id.set_visible(shared.STATUS.show_col_id) self.renderer_incl = Gtk.CellRendererToggle() self.renderer_incl.connect('toggled', self.on_included_toggled) self.col_incl = Gtk.TreeViewColumn(tr('Included'), self.renderer_incl, active=1) self.col_incl.set_visible(shared.STATUS.show_col_incl) self.renderer_class = Gtk.CellRendererText() col_class = Gtk.TreeViewColumn(tr('Class'), self.renderer_class, text=2) col_class.set_visible(False) self.renderer_name = Gtk.CellRendererText() self.renderer_name.props.editable = True self.renderer_name.props.editable_set = True self.renderer_name.connect('editing-started', self.on_editing_started) self.renderer_name.connect('editing_canceled', self.on_editing_canceled) self.renderer_name.connect('edited', self.on_name_edited) col_name = Gtk.TreeViewColumn(tr('Name'), self.renderer_name, text=3) col_name.set_cell_data_func(self.renderer_name, _set_cell_fgcolor, '') # col_name.set_sort_column_id(2) self.renderer_ilevel = Gtk.CellRendererCombo() self.renderer_ilevel.set_property('editable', True) self.renderer_ilevel.set_property('model', liststore_levels) self.renderer_ilevel.set_property('text-column', 0) self.renderer_ilevel.set_property('has-entry', False) self.renderer_ilevel.connect('editing-started', self.on_editing_started) self.renderer_ilevel.connect('edited', self.on_initial_level_edited) self.renderer_ilevel.connect('editing_canceled', self.on_editing_canceled) self.col_ilevel = Gtk.TreeViewColumn(tr('Initial level'), self.renderer_ilevel, text=4) self.col_ilevel.set_cell_data_func(self.renderer_ilevel, _set_cell_fgcolor, '') self.col_ilevel.set_visible(shared.STATUS.show_col_ilevel) # self.col_ilevel.set_sort_column_id(3) self.renderer_alevel = Gtk.CellRendererText() col_alevel = Gtk.TreeViewColumn(tr('Attained level'), self.renderer_alevel, text=5) col_alevel.set_cell_data_func(self.renderer_alevel, _set_cell_fgcolor, '') # col_alevel.set_sort_column_id(4) for i, col in enumerate([self.col_id, self.col_incl, col_class, col_name, self.col_ilevel, col_alevel]): # TODO: do not set a minimum width (or not hardcoded at least) # instead, check properties of Gtk.TreeViewColumn objects and see # what's possible # col.set_min_width(100) self.treeview.append_column(col) # LATER: factorize following common code between pupils manager and # view panels (add an intermediate class between ListManagerBase and # Pupil*Panel, that will have the common code) if self.grading['choice'] == 'numeric': self.grades_cell_width = \ len(str(self.grading['maximum'])) \ + len(STEPS[self.grading['step']]) - 1 else: # self.grading['choice'] == 'literal' self.grades_cell_width = \ max([len(item) for item in self.grading['literal_grades']]) max_special_grades = max([len(item) for item in self.special_grades]) # 3 is the default minimal value in Gtk (could be omitted here) self.grades_cell_width = max(3, max_special_grades + 1, self.grades_cell_width + 1) for i in range(self.grades_nb): self.__add_grade_col(i) empty_right_grid = Gtk.Grid() empty_right_grid.set_hexpand(True) scrolled_grid = Gtk.Grid() scrolled_grid.attach(self.treeview, 0, 0, 1, 1) scrolled_grid.attach_next_to(empty_right_grid, self.treeview, Gtk.PositionType.RIGHT, 1, 1) self.scrollable_treelist = Gtk.ScrolledWindow() self.scrollable_treelist.add(scrolled_grid) self.scrollable_treelist.set_vexpand(True) self.attach(self.scrollable_treelist, 0, 0, 15, 10) # RIGHT TOOLS (add a grade...) self.right_tools = Gtk.Grid() self.right_tools.set_vexpand(False) self.add_grade_button = Gtk.ToolButton.new() self.add_grade_button.set_vexpand(False) self.add_grade_button.set_margin_bottom(5) self.add_grade_button.connect('clicked', self.on_add_grade_clicked) self.paste_grades_button = Gtk.ToolButton.new() self.paste_grades_button.set_vexpand(False) self.paste_grades_button.connect('clicked', self.on_paste_grades_clicked) self.paste_grades_button.set_sensitive(len(self.store) >= 1) self.add_grade_button.set_sensitive(len(self.store) >= 1) self.right_tools.attach(self.add_grade_button, 0, 0, 1, 1) self.right_tools.attach_next_to(self.paste_grades_button, self.add_grade_button, Gtk.PositionType.BOTTOM, 1, 1) self.attach_next_to(self.right_tools, self.scrollable_treelist, Gtk.PositionType.RIGHT, 1, 1) # BOTTOM TOOLS (add/remove pupil) self.bottom_buttons = Gtk.Grid() self.insert_button.set_vexpand(False) self.insert_button.set_halign(Gtk.Align.CENTER) self.insert_button.set_valign(Gtk.Align.CENTER) self.insert_button.props.margin_right = 10 self.insert_button.connect('clicked', self.on_insert_clicked) self.bottom_buttons.attach(self.insert_button, 0, 0, 1, 1) self.paste_pupils_button = Gtk.ToolButton.new() self.paste_pupils_button.set_vexpand(False) self.paste_pupils_button.set_hexpand(False) self.paste_pupils_button.set_halign(Gtk.Align.CENTER) self.paste_pupils_button.set_valign(Gtk.Align.CENTER) self.paste_pupils_button.props.margin_right = 10 self.paste_pupils_button.connect('clicked', self.on_paste_pupils_clicked) self.bottom_buttons.attach_next_to(self.paste_pupils_button, self.insert_button, Gtk.PositionType.RIGHT, 1, 1) self.remove_button.set_vexpand(False) self.remove_button.set_halign(Gtk.Align.CENTER) self.remove_button.set_valign(Gtk.Align.CENTER) self.remove_button.set_sensitive(False) self.remove_button.connect('clicked', self.on_remove_clicked) self.bottom_buttons.attach_next_to(self.remove_button, self.paste_pupils_button, Gtk.PositionType.RIGHT, 1, 1) self.edit_level_button = Gtk.ToolButton.new() self.edit_level_button.set_vexpand(False) self.edit_level_button.set_hexpand(False) self.edit_level_button.set_halign(Gtk.Align.CENTER) self.edit_level_button.set_valign(Gtk.Align.CENTER) self.edit_level_button.props.margin_right = 10 self.edit_level_button.set_sensitive(False) self.edit_level_button.connect('clicked', self.on_edit_level_clicked) self.bottom_buttons.attach_next_to(self.edit_level_button, self.remove_button, Gtk.PositionType.RIGHT, 1, 1) self.edit_class_button = Gtk.ToolButton.new() self.edit_class_button.set_vexpand(False) self.edit_class_button.set_hexpand(False) self.edit_class_button.set_halign(Gtk.Align.CENTER) self.edit_class_button.set_valign(Gtk.Align.CENTER) self.edit_class_button.props.margin_right = 10 self.edit_class_button.set_sensitive(False) self.edit_class_button.connect('clicked', self.on_edit_class_clicked) self.bottom_buttons.attach_next_to(self.edit_class_button, self.edit_level_button, Gtk.PositionType.RIGHT, 1, 1) self.bottom_tools = Gtk.Grid() self.bottom_tools.set_hexpand(False) self.bottom_tools.props.margin_bottom = 0 self.bottom_tools.props.margin_top = 3 self.bottom_tools.attach(self.bottom_buttons, 0, 0, 1, 1) self.attach_next_to(self.bottom_tools, self.scrollable_treelist, Gtk.PositionType.BOTTOM, 1, 1) bottomvoid_grid = Gtk.Grid() bottomvoid_grid.set_hexpand(True) self.attach_next_to(bottomvoid_grid, self.bottom_tools, Gtk.PositionType.RIGHT, 1, 1) self.clip = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) self.clip2 = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) # self.treeview.connect('set-focus-child', self.on_set_focus_child) self.started_edition = False self.setup_buttons_icons(ICON_THEME) # Only colgrades can be user selected self.user_selected_col = None self.unselected_rows = None @property def default_row_values(self): return [None, True, self.classname, None, self.levels[0], self.levels[0], Listing(None)] @property def grades_nb(self): class_pupils = shared.session.query(Pupils)\ .filter_by(classname=self.classname)\ .all() return max([len(pupil.grades or []) for pupil in class_pupils] or [0]) def buttons_icons(self): # Last item of each list is the fallback, hence must be standard buttons = {'insert_button': ['contact-new'], 'remove_button': ['list-remove-user', 'edit-delete'], 'edit_level_button': ['starred'], 'edit_class_button': ['go-next'], 'paste_pupils_button': ['user-group-new', 'stock_new-meeting', 'resource-group-new', 'stock_people', 'edit-paste'], 'paste_grades_button': ['edit-paste'], 'add_grade_button': ['list-add']} if any(get_icon_theme_name().startswith(name) for name in ['Numix-Circle', 'Paper']): buttons.update({'paste_grades_button': ['view-task', 'stock_task', 'edit-paste']}) return buttons def buttons_labels(self): """Define labels of buttons.""" PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext buttons = {'insert_button': tr('Insert a pupil'), 'remove_button': tr('Remove pupils'), 'edit_level_button': tr('Edit initial level'), 'edit_class_button': tr('Edit class'), 'paste_pupils_button': tr('Paste pupils'), 'paste_grades_button': tr('Paste grades'), 'add_grade_button': tr('Add new grade')} return buttons def set_buttons_sensitivity(self): ListManagerBase.set_buttons_sensitivity(self) editing = self.started_insertion or self.started_edition rows_nb = len(self.selection.get_selected_rows()[1]) lock_grades_btns = True colgrades_nb = self.treeview.get_n_columns() - GRADES no_colgrade_at_all = colgrades_nb == 0 for i in range(len(self.store)): pupil_grades = self.store[Gtk.TreePath(i)][GRADES].cols if (len(pupil_grades) and len(pupil_grades) == colgrades_nb and pupil_grades[-1] != ''): lock_grades_btns = False break self.insert_button.set_sensitive(not editing and rows_nb <= 1 and self.user_selected_col is None) self.paste_pupils_button.set_sensitive( not editing and rows_nb <= 1 and self.user_selected_col is None) self.paste_grades_button.set_sensitive(not editing and len(self.store) and rows_nb <= 1 and (no_colgrade_at_all or not lock_grades_btns)) self.add_grade_button.set_sensitive(not editing and len(self.store) and rows_nb <= 1 and (no_colgrade_at_all or not lock_grades_btns) and self.user_selected_col is None) self.edit_level_button.set_sensitive(rows_nb >= 2) self.edit_class_button.set_sensitive(rows_nb >= 1 and len(self.classes) >= 2 and not editing) def __add_grade_col(self, nth): """nth is the number of the grade (int starting from 0)""" grade = Gtk.CellRendererText() grade.props.editable = True grade.props.editable_set = True grade.props.max_width_chars = self.grades_cell_width grade.set_alignment(0.5, 0.5) grade.connect('editing-canceled', self.on_editing_canceled) grade.connect('editing-started', self.on_editing_started) grade.props.foreground_set = True def _set_cell_text(column, cell, model, it, index): obj = model.get_value(it, GRADES) if index < len(obj.cols): cell_text = obj.cols[index] cell.set_property('text', cell_text) color, weight = cellfont_fmt(cell_text, self.special_grades, self.grading) cell.set_property('foreground', color) cell.set_property('weight', weight) else: cell.set_property('text', '') col_grades = Gtk.TreeViewColumn('#{}'.format(nth + 1), grade) col_grades.grade_nb = nth col_grades.set_min_width(80) col_grades.set_alignment(0.5) col_grades.set_clickable(True) col_grades.connect('clicked', self.on_column_clicked) col_grades.set_cell_data_func(grade, _set_cell_text, nth) self.treeview.append_column(col_grades) setattr(self, 'gradecell{}'.format(nth), grade) getattr(self, 'gradecell{}'.format(nth)).connect( 'edited', self.on_grade_edited) def on_key_release(self, widget, ev, data=None): if ev.keyval == Gdk.KEY_Escape: if self.started_insertion: self.cancel_insertion() if self.started_edition or self.started_insertion: self.post_edit_cleanup() self.set_buttons_sensitivity() if self.user_selected_col is not None: self.unselect_col(self.get_selected_col()) def on_tree_selection_changed(self, selection): ListManagerBase.set_buttons_sensitivity(self) if self.user_selected_col is not None: self.unselect_col(self.get_selected_col()) self.unselected_rows = None self.set_buttons_sensitivity() def on_paste_grades_clicked(self, widget): # TODO: factorize at least parts of this method with # on_paste_pupils_clicked text = self.clip.wait_for_text() if text is None: text = self.clip2.wait_for_text() if text is not None: PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext if '\t' in text: sep = '\t' else: sep = '\n' lines = text.strip().split(sep) do_paste = True # LATER: (when showing data before pasting) MAYBE allow less grades # than pupils if len(self.store) != len(lines): do_paste = False if len(self.store) > len(lines): msg = tr('There are too few grades.\nIt is required to ' 'paste as many grades as pupils.') else: msg = tr('There are too many grades.\nIt is required to ' 'paste as many grades as pupils.') run_message_dialog(tr('Number of pupils and grades mismatch'), msg, 'dialog-warning') for grade in lines: try: self.check_user_entry( grade, forbid_empty_cell=False, forbid_duplicate_content=False, forbid_internal_sep=True, change_is_required=False) except ReservedCharsError: do_paste = False run_message_dialog(tr('Reserved group of characters'), tr('The group of characters "{}" has ' 'been found in the data you\'re ' 'about to paste, but it is reserved ' 'for internal use.\nPlease remove ' 'it from the data you want to paste ' 'before pasting again.\n' 'Pasting grades cancelled.' ).format(SEP), 'dialog-warning') if do_paste: names_list = [self.store[Gtk.TreePath(i)][FULLNAME] for i in range(len(self.store))] if self.user_selected_col is None: view = build_view([tr('Names')] + names_list, [tr('Grades')] + [L for L in lines], xalign=[0, 0.5]) msg = tr('Add following grades?') else: col_num = self.user_selected_col prev_grades_list = [ self.store[Gtk.TreePath(i)][GRADES] .cols[col_num:col_num + 1] or [''] for i in range(len(self.store))] prev_grades_list = [item[0] for item in prev_grades_list] def _set_cell_text(column, cell, model, it, ignored): current = model.get_value(it, 1) update = model.get_value(it, 2) weight = int(Pango.Weight.NORMAL) _, bgcolor, _, _ = get_theme_colors() # LATER: appearance is poor, improve it! if update != current: weight = int(Pango.Weight.BOLD) bgcolor = Gdk.RGBA() bgcolor.parse('rgba(255, 179, 218, 255)') cell.set_property('background_rgba', bgcolor) cell.set_property('weight', weight) view = build_view([tr('Names')] + names_list, [tr('Grade #{}') .format(self.user_selected_col + 1)] + prev_grades_list, [tr('Update')] + [L for L in lines], xalign=[0, 0.5, 0.5], set_cell_func=[None, None, _set_cell_text]) msg = tr('Modify following grades?') conf_dialog = ConfirmationDialog( tr('Please confirm'), message=msg, widget=view) response = conf_dialog.run() if response not in [Gtk.ResponseType.YES, Gtk.ResponseType.OK]: do_paste = False conf_dialog.destroy() if do_paste: if self.user_selected_col is None: self.__add_grade_col(self.grades_nb) # cannot use self.grades_nb in the loop as it's updated # at any commit col_num = self.grades_nb else: col_num = self.user_selected_col # Cursor change inspired by # https://stackoverflow.com/a/9881020/3926735 self.get_window().set_cursor( Gdk.Cursor.new_from_name(Gdk.Display.get_default(), 'wait')) def add_grades(lines): for i, grade in enumerate(lines): # TODO: add a progression bar too, at bottom path = Gtk.TreePath(i) id_value = self.store[path][ID] self.store[path][GRADES] = \ Listing(grade, data_row=self.store[path][GRADES].cols, position=col_num) self.store[path][ALEVEL] = calculate_attained_level( self.store[path][ILEVEL], self.levels, self.grading, self.store[path][GRADES], self.special_grades) self.commit_pupil( id_value, ['grades', 'attained_level']) self.emit('data-changed') self.get_window().set_cursor(None) return False GObject.idle_add(add_grades, lines) self.on_column_clicked( self.treeview.get_column(GRADES + self.user_selected_col)) def on_add_grade_clicked(self, widget): self.__add_grade_col(self.grades_nb) GLib.timeout_add(50, self.treeview.set_cursor, Gtk.TreePath(0), self.treeview.get_column(GRADES + self.grades_nb), True) def on_insert_clicked(self, widget): if not self.started_insertion: ListManagerBase.on_insert_clicked( self, widget, at='top', col_nb=2, do_scroll=(self.scrollable_treelist, Gtk.ScrollType.START, False)) self.set_buttons_sensitivity() def on_paste_pupils_clicked(self, widget): text = self.clip.wait_for_text() if text is None: text = self.clip2.wait_for_text() if text is not None: PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext if '\t' in text: sep = '\t' else: sep = '\n' lines = text.strip().split(sep) display_empty_lines_warning = False do_paste = True for name in lines: try: self.check_user_entry( name, forbid_empty_cell=True, forbid_duplicate_content=False, forbid_internal_sep=True, change_is_required=False) except EmptyContentError: display_empty_lines_warning = True except ReservedCharsError: do_paste = False run_message_dialog(tr('Reserved group of characters'), tr('The group of characters "{}" has ' 'been found in the data you\'re ' 'about to paste, but it is reserved ' 'for internal use.\nPlease remove ' 'it from the data you want to paste ' 'before pasting again.\n' 'Pasting pupils\' names cancelled.' ).format(SEP), 'dialog-warning') if do_paste: names_view = build_view([tr('Names')] + lines) conf_dialog = ConfirmationDialog( tr('Please confirm'), message=tr('Add following pupils?'), widget=names_view) response = conf_dialog.run() if response not in [Gtk.ResponseType.YES, Gtk.ResponseType.OK]: do_paste = False conf_dialog.destroy() if do_paste: # Cursor change inspired by # https://stackoverflow.com/a/9881020/3926735 self.get_window().set_cursor( Gdk.Cursor.new_from_name(Gdk.Display.get_default(), 'wait')) if display_empty_lines_warning: lines = [L for L in lines if L != ''] run_message_dialog(tr('Empty lines'), tr('The empty lines that have been ' 'found in the data you want to ' 'paste\nhave been automatically ' 'removed.'), 'dialog-warning') def add_pupils(lines): for name in lines: # TODO: add a progression bar too, at bottom fill_values = self.default_row_values fill_values[FULLNAME] = name self.store.insert(0, fill_values) self.commit_pupil(None, ['fullname']) self.emit('data-changed') self.get_window().set_cursor(None) return False GObject.idle_add(add_pupils, lines) def on_remove_clicked(self, widget): # TODO: ask before deleting a Pupil that already has grades p_ids = ListManagerBase.on_remove_clicked(self, widget, get_ids=0) removed = False for p_id in p_ids: if p_id not in ['', None]: shared.session.delete(shared.session.query(Pupils).get(p_id)) removed = True if removed: shared.session.commit() shared.STATUS.document_modified = True self.emit('data-changed') self.set_buttons_sensitivity() def on_edit_level_clicked(self, widget): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext dialog = ComboDialog(tr('Change initial level'), '', self.levels) response = dialog.run() if response == Gtk.ResponseType.OK: model, paths = self.selection.get_selected_rows() for path in paths: self.on_initial_level_edited(widget, path, dialog.choice) dialog.destroy() def on_edit_class_clicked(self, widget): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext other_classes = [label for label in self.classes if label != self.classname] dialog = ComboDialog(tr('Move to another class'), '', other_classes) response = dialog.run() if response == Gtk.ResponseType.OK: model, paths = self.selection.get_selected_rows() for ref in paths: path = Gtk.TreeRowReference.new(model, ref).get_path() self.store[path][CLASS] = dialog.choice self.commit_pupil(self.store[path][ID], ['classname']) print('DATA TO MOVE: {}' .format([str(self.store[path][ID]), *self.store[path][CLASS:]])) gui.app.window.pupils_progression_manager_page\ .panels[dialog.choice].store.append( [str(self.store[path][ID]), *self.store[path][CLASS:]]) self.store.remove(self.store.get_iter(path)) shared.STATUS.document_modified = True self.emit('data-changed') dialog.destroy() def get_selected_col(self): return self.treeview.get_column(GRADES + self.user_selected_col) def select_col(self, col): _, _, fg, bg = get_theme_colors() # only the "selected" colors fg = convert_gdk_rgba_to_hex(fg) bg = convert_gdk_rgba_to_hex(bg) self.user_selected_col = col.grade_nb selected_title = Gtk.Label() selected_title.set_markup( r'{}' .format(fg, bg, '#{}'.format(col.grade_nb + 1))) col.set_widget(selected_title) selected_title.show() self.renderer_name.props.editable = False def unselect_col(self, col): col.set_widget(None) col.set_title('#{}'.format(col.grade_nb + 1)) self.user_selected_col = None self.renderer_name.props.editable = True def on_column_clicked(self, col): if self.unselected_rows is None: self.unselected_rows = \ [t.to_string() for t in self.selection.get_selected_rows()[1]] self.selection.unselect_all() if self.user_selected_col is None: # no selected col yet self.select_col(col) else: if col.grade_nb == self.user_selected_col: # unselect col self.unselect_col(col) if self.unselected_rows is not None: # give selection back for i in self.unselected_rows: self.selection.select_path(Gtk.TreePath(int(i))) self.unselected_rows = None else: # change selected col prev_col = self.get_selected_col() new_col = col self.unselect_col(prev_col) self.select_col(new_col) self.set_buttons_sensitivity() # LATER: Also the col's cells should become selected. # Toggle the remove grade button to sensitive and use the current # selected col to remove a grade. def on_name_edited(self, widget, path, new_text): accepted, id_value = self.on_cell_edited( widget, path, new_text, forbid_empty_cell=True, col_nb=FULLNAME, forbid_duplicate_content=False, forbid_internal_sep=False) if accepted: self.commit_pupil(id_value, ['fullname']) self.emit('data-changed') self.set_buttons_sensitivity() def on_included_toggled(self, cell_renderer, path): self.store[path][INCLUDED] = not self.store[path][INCLUDED] self.commit_pupil(self.store[path][ID], ['included']) shared.STATUS.document_modified = True self.emit('data-changed') def on_initial_level_edited(self, widget, path, new_text): if new_text != self.store[path][ILEVEL]: ilevel = new_text self.store[path][ILEVEL] = ilevel grades = self.store[path][GRADES] shared.STATUS.document_modified = True self.store[path][ALEVEL] = calculate_attained_level( ilevel, self.levels, self.grading, grades, self.special_grades) self.commit_pupil(self.store[path][ID], ['initial_level', 'attained_level']) self.emit('data-changed') self.post_edit_cleanup() self.set_buttons_sensitivity() def on_grade_edited(self, widget, path, new_text): id_value, model, treeiter, row = self.get_selection_info() pupil = shared.session.query(Pupils).get(id_value) col = self.treeview.get_cursor()[1] if pupil.grades is None: kwargs = None else: kwargs = {'data_row': pupil.grades, 'position': col.grade_nb} last_row = None if self.treeview.get_visible_range() is not None: last_row = self.treeview.get_visible_range()[1] accepted, id_value = \ self.on_cell_edited(widget, path, new_text, col_nb=GRADES, forbid_empty_cell=False, forbid_duplicate_content=False, do_cleanup=False, cell_store_type=Listing, cell_store_kwargs=kwargs) if accepted: self.store[path][ALEVEL] = calculate_attained_level( pupil.initial_level, self.levels, self.grading, self.store[path][GRADES], self.special_grades) self.commit_pupil(id_value, ['grades', 'attained_level']) time.sleep(0.1) self.emit('data-changed') if col is not None and last_row is not None: position = int(row.to_string()) last_position = int(last_row.to_string()) next_val = 'undefined' # Could be any str except '' while position < last_position: next_row = Gtk.TreePath(position + 1) try: next_val = self.store[next_row][GRADES]\ .cols[col.grade_nb] except IndexError: next_val = '' if next_val in ['', None]: break else: position += 1 if next_val in ['', None]: GLib.timeout_add(50, self.treeview.set_cursor, next_row, col, True) else: self.on_editing_canceled(None) else: # Unaccepted text (e.g. internal separator was rejected) # Simply set cursor on the same cell again GLib.timeout_add(50, self.treeview.set_cursor, row, col, True) def commit_pupil(self, id_value, attrnames=None): # TODO: add a method that would do most of this job, but not commit # (like 'add_pupil'), that this method would re-use in order to # commit. This would be helpful in cases where a bunch of pupils is # added at once (then only one commit at the end). # Or maybe a unique method that would deal with a bunch of pupils? _, path = self.get_path_from_id(id_value) new = False if attrnames is None: attrnames = [] if id_value in ['', None]: new = True pupil = Pupils(classname=self.classname, included=self.store[path][INCLUDED], fullname=self.store[path][FULLNAME], initial_level=self.store[path][ILEVEL], attained_level=self.store[path][ALEVEL], grades=self.store[path][GRADES]) shared.session.add(pupil) else: pupil = shared.session.query(Pupils).get(id_value) for attrname in attrnames: col_nb = PUPILS_COL_NBS[attrname] setattr(pupil, attrname, self.store[path][col_nb]) shared.session.commit() shared.STATUS.document_modified = True if new: self.store[path][ID] = str(pupil.id) PK!fghsMsM'cotinga/gui/panels/pupils_view_panel.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from shutil import copyfile from gettext import translation from sqlalchemy.sql import false from sqlalchemy.sql.expression import or_, and_ import gi try: gi.require_version('Gtk', '3.0') gi.require_version('Poppler', '0.18') except ValueError: raise else: from gi.repository import Gtk, GObject, Poppler from cotinga.core.env import LOCALEDIR, L10N_DOMAIN from cotinga.core.env import REPORT_FILE, REPORT_FILE_URI from cotinga.core.env import ICON_THEME, get_theme_colors from cotinga.core.tools import Listing, cellfont_fmt from cotinga.core.pmdoc import report from cotinga.core import shared from cotinga.models import Pupils from cotinga.gui.panels import ListManagerBase from cotinga import gui from cotinga.core import constants from cotinga.gui.dialogs import PreviewDialog, SaveAsFileDialog STEPS = constants.NUMERIC_STEPS # Column numbers of the store ID, INCLUDED, CLASS, FULLNAME, ILEVEL, ALEVEL, GRADES = (0, 1, 2, 3, 4, 5, 6) class PupilsViewPanel(ListManagerBase): def __init__(self): ListManagerBase.__init__(self, setup_buttons_icons=False, mini_items_nb=0, store_types=[str, bool, str, str, str, str, GObject.TYPE_PYOBJECT]) PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext self.pupils_nb = 0 if self.grading['choice'] == 'numeric': self.grades_cell_width = \ len(str(self.grading['maximum'])) \ + len(STEPS[self.grading['step']]) - 1 else: # self.grading['choice'] == 'literal' self.grades_cell_width = \ max([len(item) for item in self.grading['literal_grades']]) max_special_grades = max([len(item) for item in self.special_grades]) # 3 is the default minimal value in Gtk (could be omitted here) self.grades_cell_width = max(3, max_special_grades + 1, self.grades_cell_width + 1) self.refresh_data() self.class_filter = self.store.filter_new() self.class_filter.set_visible_func(self.class_filter_func) self.sorted_and_filtered_model = \ Gtk.TreeModelSort(model=self.class_filter) self.sorted_and_filtered_model.set_sort_column_id( FULLNAME, Gtk.SortType.ASCENDING) self.treeview = Gtk.TreeView.new_with_model( self.sorted_and_filtered_model) # As original treeview is modified, it's necessary to reconnect it self.selection.connect('changed', self.on_tree_selection_changed) self.selection.set_mode(Gtk.SelectionMode.MULTIPLE) # TODO: remove this code duplication (see pupils manager panel) def _set_cell_fgcolor(column, cell, model, it, ignored): """Turn not included pupils in grey.""" included = model.get_value(it, INCLUDED) if included: fgcolor, _, _, _ = get_theme_colors() cell.set_property('foreground_rgba', fgcolor) else: cell.set_property('foreground', 'Grey') self.renderer_id = Gtk.CellRendererText() self.col_id = Gtk.TreeViewColumn('id', self.renderer_id, text=0) self.col_id.set_cell_data_func(self.renderer_id, _set_cell_fgcolor, '') self.col_id.set_visible(shared.STATUS.show_col_id) self.renderer_incl = Gtk.CellRendererToggle() self.col_incl = Gtk.TreeViewColumn(tr('Included'), self.renderer_incl, active=1) self.col_incl.set_visible(shared.STATUS.show_col_incl) self.renderer_class = Gtk.CellRendererText() col_class = Gtk.TreeViewColumn(tr('Class'), self.renderer_class, text=2) col_class.set_cell_data_func(self.renderer_class, _set_cell_fgcolor, '') col_class.set_sort_column_id(2) self.renderer_name = Gtk.CellRendererText() col_name = Gtk.TreeViewColumn(tr('Name'), self.renderer_name, text=3) col_name.set_cell_data_func(self.renderer_name, _set_cell_fgcolor, '') col_name.set_sort_column_id(3) self.renderer_ilevel = Gtk.CellRendererText() self.col_ilevel = Gtk.TreeViewColumn(tr('Initial level'), self.renderer_ilevel, text=4) self.col_ilevel.set_cell_data_func(self.renderer_ilevel, _set_cell_fgcolor, '') self.col_ilevel.set_visible(shared.STATUS.show_col_ilevel) self.col_ilevel.set_sort_column_id(4) self.renderer_alevel = Gtk.CellRendererText() col_alevel = Gtk.TreeViewColumn(tr('Attained level'), self.renderer_alevel, text=5) col_alevel.set_cell_data_func(self.renderer_alevel, _set_cell_fgcolor, '') col_alevel.set_sort_column_id(5) for i, col in enumerate([self.col_id, self.col_incl, col_class, col_name, self.col_ilevel, col_alevel]): # TODO: do not set a minimum width (or not hardcoded at least) # instead, check properties of Gtk.TreeViewColumn objects and see # what's possible # col.set_min_width(100) self.treeview.append_column(col) self.add_missing_cols() # LATER: remove this code duplication with pupils_manager_panel empty_right_grid = Gtk.Grid() empty_right_grid.set_hexpand(True) scrolled_grid = Gtk.Grid() scrolled_grid.attach(self.treeview, 0, 0, 1, 1) scrolled_grid.attach_next_to(empty_right_grid, self.treeview, Gtk.PositionType.RIGHT, 1, 1) self.scrollable_treelist = Gtk.ScrolledWindow() self.scrollable_treelist.add(scrolled_grid) self.scrollable_treelist.set_vexpand(True) self.attach(self.scrollable_treelist, 0, 0, 15, 10) info_frame = Gtk.Frame() frame_content = Gtk.Grid() self.info_pupils_nb = Gtk.Label() self.info_pupils_nb.props.margin = 5 self.info_pupils_nb.props.margin_bottom = 8 self.info_pupils_dist = Gtk.Label() self.info_pupils_dist.props.margin = 5 self.report_data = [] self.refresh_info() frame_content.attach(self.info_pupils_nb, 0, 0, 1, 1) frame_content.attach_next_to(self.info_pupils_dist, self.info_pupils_nb, Gtk.PositionType.BOTTOM, 1, 1) self.preview_button = Gtk.ToolButton.new() self.preview_button.set_vexpand(False) self.preview_button.set_halign(Gtk.Align.CENTER) self.preview_button.set_valign(Gtk.Align.CENTER) self.preview_button.connect('clicked', self.on_preview_clicked) frame_content.attach_next_to(self.preview_button, self.info_pupils_dist, Gtk.PositionType.BOTTOM, 1, 1) info_frame.add(frame_content) self.attach_next_to(info_frame, self.scrollable_treelist, Gtk.PositionType.RIGHT, 1, 1) # BOTTOM TOOLS (filters) self.bottom_tools = Gtk.Grid() self.bottom_tools.set_hexpand(False) self.bottom_tools.props.margin_bottom = 0 self.bottom_tools.props.margin_top = 3 self.filters_label = Gtk.Label(tr('Visible classes:')) self.filters_label.set_margin_left(5) self.filters_label.set_margin_right(10) self.bottom_tools.attach(self.filters_label, 0, 0, 1, 1) # LATER: make displaying no_filter and all_filters buttons be an option self.no_filter = Gtk.Button(tr('None')) self.no_filter.connect('clicked', self.on_no_filter_button_clicked) self.no_filter.set_margin_right(3) self.bottom_tools.attach_next_to(self.no_filter, self.filters_label, Gtk.PositionType.RIGHT, 1, 1) self.all_filters = Gtk.Button(tr('All')) self.all_filters.connect('clicked', self.on_all_filters_button_clicked) self.all_filters.set_margin_right(3) self.bottom_tools.attach_next_to(self.all_filters, self.no_filter, Gtk.PositionType.RIGHT, 1, 1) self.filter_buttons = Gtk.Grid() self.build_filter_buttons() self.bottom_tools.attach_next_to(self.filter_buttons, self.all_filters, Gtk.PositionType.RIGHT, 1, 1) self.attach_next_to(self.bottom_tools, self.scrollable_treelist, Gtk.PositionType.BOTTOM, 1, 1) bottomvoid_grid = Gtk.Grid() bottomvoid_grid.set_hexpand(True) self.attach_next_to(bottomvoid_grid, self.bottom_tools, Gtk.PositionType.RIGHT, 1, 1) self.pdf_report = None self.setup_buttons_icons(ICON_THEME) self.setup_info_visibility() @property def grades_nb(self): # TODO: looks like it could be partially factorized with # pupils_manager_panel.grades_nb() all_pupils = shared.session.query(Pupils).all() return max([len(pupil.grades or []) for pupil in all_pupils] or [0]) def buttons_icons(self): """Defines icon names and fallback to standard icon name.""" # Last item of each list is the fallback, hence must be standard buttons = ListManagerBase.buttons_icons(self) buttons.update({'preview_button': ['application-pdf', 'document-print-preview']}) return buttons def buttons_labels(self): """Defines icon names and fallback to standard icon name.""" # Last item of each list is the fallback, hence must be standard PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext buttons = ListManagerBase.buttons_labels(self) buttons.update({'preview_button': tr('Preview')}) return buttons def __build_report_data(self): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext constraints = [] for classname in shared.STATUS.filters: constraints.append(Pupils.classname == classname) if constraints: # Making use of Pupils.included is True makes the filtering fail pupils = shared.session.query(Pupils).filter( and_(Pupils.included == True, or_(*constraints))) # noqa else: pupils = shared.session.query(Pupils).filter(false()) report_data = [] for i, level in enumerate(self.levels): n = pupils.filter(Pupils.attained_level == level).count() if n: if i == len(self.levels) - 1: next_level = level else: next_level = self.levels[i + 1] pupils_list = pupils.filter( Pupils.attained_level == level).all() report_data.append((next_level, n, pupils_list)) pupils_dist = '\n'.join([tr('{level}: {number}') .format(level=item[0], number=item[1]) for item in report_data]) return (pupils.count(), pupils_dist, report_data) def refresh_info(self): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext self.pupils_nb, pupils_dist, self.report_data = \ self.__build_report_data() self.info_pupils_nb.set_text( tr('Pupils\' number: {}').format(self.pupils_nb)) self.info_pupils_dist.set_text( tr('Next evaluation:') + '\n' + pupils_dist) def setup_info_visibility(self): if self.pupils_nb: self.info_pupils_dist.show() self.preview_button.show() else: self.info_pupils_dist.hide() self.preview_button.hide() def refresh_data(self): # LATER: to avoid having to refresh data, use set_cell_func_data in # order to actually store "nothing" in the view's store, but have # permanent automatic refreshing instead self.store.clear() for pupil in shared.session.query(Pupils).all(): self.store.append([str(pupil.id), pupil.included, pupil.classname, pupil.fullname, pupil.initial_level, pupil.attained_level, Listing(pupil.grades)]) def add_missing_cols(self): current_nb = len(self.treeview.get_columns()) missing = GRADES + self.grades_nb - current_nb offset = current_nb - GRADES for i in range(missing): grade = Gtk.CellRendererText() grade.props.max_width_chars = self.grades_cell_width grade.set_alignment(0.5, 0.5) def _set_cell_text(column, cell, model, it, index): obj = model.get_value(it, GRADES) if index < len(obj.cols): cell_text = obj.cols[index] cell.set_property('text', cell_text) color, weight = cellfont_fmt(cell_text, self.special_grades, self.grading) cell.set_property('foreground', color) cell.set_property('weight', weight) else: cell.set_property('text', '') col_grades = Gtk.TreeViewColumn( '#{}'.format(i + offset + 1), grade) col_grades.set_cell_data_func(grade, _set_cell_text, i + offset) setattr(self, 'gradecell{}'.format(i + offset), grade) # LATER: add sorting by grade (line below does not work) # col_grades.set_sort_column_id(GRADES + i + offset) col_grades.set_min_width(80) col_grades.set_alignment(0.5) self.treeview.append_column(col_grades) def refresh(self): self.refresh_data() self.add_missing_cols() self.refresh_info() self.setup_info_visibility() def build_filter_buttons(self): """Build the filter buttons according to available classes.""" for btn in self.filter_buttons.get_children(): self.filter_buttons.remove(btn) for classname in self.classes: button = Gtk.ToggleButton(classname) button.set_margin_right(3) button.connect('toggled', self.on_filter_button_toggled) if classname in shared.STATUS.filters: button.set_active(True) else: button.set_active(False) self.filter_buttons.add(button) self.filter_buttons.show_all() def on_filter_button_toggled(self, widget): """Called on any of the filter button clicks""" classname = widget.get_label() if widget.get_active(): shared.STATUS.filters = \ list(set(shared.STATUS.filters + [classname])) else: shared.STATUS.filters = [label for label in shared.STATUS.filters if label != classname] self.class_filter.refilter() self.refresh_info() self.setup_info_visibility() def on_no_filter_button_clicked(self, widget): for btn in self.filter_buttons: btn.set_active(False) def on_all_filters_button_clicked(self, widget): for btn in self.filter_buttons: btn.set_active(True) def on_preview_clicked(self, widget): report.build(self.report_data) PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext dialog = PreviewDialog(tr('Report preview')) response = dialog.run() if response == Gtk.ResponseType.YES: # save as save_as_dialog = SaveAsFileDialog(report=True) save_as_response = save_as_dialog.run() if save_as_response == Gtk.ResponseType.OK: report_name = save_as_dialog.get_filename() copyfile(REPORT_FILE, report_name) save_as_dialog.destroy() dialog.destroy() self.on_preview_clicked(widget) elif response == Gtk.ResponseType.OK: # print operation = Gtk.PrintOperation() operation.connect('begin-print', self.begin_print, None) operation.connect('draw-page', self.draw_page, None) self.pdf_report = Poppler.Document.new_from_file(REPORT_FILE_URI) print_setup = Gtk.PageSetup() print_setup.set_orientation(Gtk.PageOrientation.LANDSCAPE) print_setup.set_left_margin(7, Gtk.Unit.MM) print_setup.set_right_margin(7, Gtk.Unit.MM) print_setup.set_top_margin(7, Gtk.Unit.MM) print_setup.set_bottom_margin(7, Gtk.Unit.MM) operation.set_default_page_setup(print_setup) # print_settings = Gtk.PrintSettings() # print_settings.set_orientation(Gtk.PageOrientation.LANDSCAPE) # operation.set_print_settings(print_settings) print_result = operation.run(Gtk.PrintOperationAction.PRINT_DIALOG, gui.app.window) if print_result == Gtk.PrintOperationResult.ERROR: message = self.operation.get_error() errdialog = Gtk.MessageDialog(gui.app.window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, message) errdialog.run() errdialog.destroy() dialog.destroy() self.on_preview_clicked(widget) else: # close or cancel, whatever dialog.destroy() def begin_print(self, operation, print_ctx, print_data): operation.set_n_pages(self.pdf_report.get_n_pages()) def draw_page(self, operation, print_ctx, page_num, print_data): cr = print_ctx.get_cairo_context() page = self.pdf_report.get_page(page_num) page.render_for_printing(cr) def class_filter_func(self, model, treeiter, data): """Test if the class in the row is the one in the filter""" return model[treeiter][CLASS] in shared.STATUS.filters PK!42cotinga/gui/pupils_progression_manager/__init__.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from .page import PupilsProgressionManagerPage __all__ = ['PupilsProgressionManagerPage'] PK! :cotinga/gui/pupils_progression_manager/dialogs/__init__.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from .doc_setting import DocumentSettingDialog __all__ = ['DocumentSettingDialog'] PK!s>~~=cotinga/gui/pupils_progression_manager/dialogs/doc_setting.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gettext import translation import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga.core.env import LOCALEDIR, L10N_DOMAIN from cotinga.core import shared, pmdoc from cotinga.core.shared import PREFS from cotinga.gui.panels import ListManagerPanel from cotinga import gui from cotinga.models import Pupils from cotinga.data.default.data.pmdoc.presets import LEVELS_SCALES from .pages import GradingManager __all__ = ['DocumentSettingDialog'] class DocumentSettingDialog(Gtk.Dialog): def __init__(self): tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext Gtk.Dialog.__init__(self, tr('Document settings'), gui.app.window, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self.set_size_request(350, 200) self.box = self.get_content_area() self.grading_manager = GradingManager() docsetup = pmdoc.setting.load() self.levels_panel = \ ListManagerPanel(docsetup['levels'], tr('Labels'), presets=(LEVELS_SCALES(), tr('Load a preset scale'), tr('Replace current scale by: '), 'document-import')) self.special_grades_panel = \ ListManagerPanel(docsetup['special_grades'], tr('Labels'), mini_items_nb=0) locked_classes = [ classname for classname in docsetup['classes'] if len(shared.session.query(Pupils) .filter_by(classname=classname).all()) >= 1] self.classes_panel = \ ListManagerPanel(docsetup['classes'], tr('Labels'), mini_items_nb=0, locked=locked_classes) # From: https://lazka.github.io/pgi-docs/Gtk-3.0/classes/ # Notebook.html#Gtk.Notebook.set_current_page # "it is recommended to show child widgets before adding them to a " # "notebook." # Hence it is not recommended to add pages first and use get_children() # to browse pages to show them... for page in [self.grading_manager, self.levels_panel, self.special_grades_panel, self.classes_panel]: page.show() self.notebook = Gtk.Notebook() self.notebook.append_page(self.classes_panel, Gtk.Label(tr('Classes'))) self.notebook.append_page(self.levels_panel, Gtk.Label(tr('Levels'))) self.notebook.append_page(self.grading_manager, Gtk.Label(tr('Grading'))) self.notebook.append_page(self.special_grades_panel, Gtk.Label(tr('Special grades'))) self.notebook.set_current_page(0) self.box.add(self.notebook) self.show_all() self.from_page_num = self.notebook.get_current_page() PK!-J@cotinga/gui/pupils_progression_manager/dialogs/pages/__init__.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from .grading_manager import GradingManager __all__ = ['GradingManager'] PK!vh h Gcotinga/gui/pupils_progression_manager/dialogs/pages/grading_manager.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gettext import translation import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga.core.env import LOCALEDIR, L10N_DOMAIN from cotinga.core import shared, pmdoc from .numeric_grading_panel import NumericGradingPanel, STEPS from .literal_grading_panel import LiteralGradingPanel class GradingManager(Gtk.Grid): def __init__(self): Gtk.Grid.__init__(self) self.set_border_width(10) self.set_vexpand(True) self.set_hexpand(True) PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext grading_setup = pmdoc.setting.load()['grading'] self.numeric_panel = NumericGradingPanel(grading_setup) self.literal_panel = LiteralGradingPanel(grading_setup) self.numeric_panel.show() self.literal_panel.show() self.stack = Gtk.Stack() self.stack.set_transition_type( Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) self.stack.set_transition_duration(300) self.stack.add_titled(self.numeric_panel, 'numeric', tr('Numeric')) self.stack.add_titled(self.literal_panel, 'literal', tr('Literal')) self.stack.set_visible_child_name(grading_setup['choice']) self.stack_switcher = Gtk.StackSwitcher() self.stack_switcher.props.margin_bottom = 10 self.stack_switcher.set_stack(self.stack) self.attach(self.stack_switcher, 0, 0, 1, 1) self.attach_next_to(self.stack, self.stack_switcher, Gtk.PositionType.BOTTOM, 1, 1) self.show_all() def get_grading(self): step = list(STEPS.keys())[list(STEPS.values()) .index(str(self.numeric_panel.step))] return {'choice': self.stack.get_visible_child_name(), 'step': step, 'minimum': self.numeric_panel.minimum, 'maximum': self.numeric_panel.maximum, 'edge_numeric': self.numeric_panel.edge, 'literal_grades': [row[0] for row in self.literal_panel.store if row[0] is not None], 'edge_literal': self.literal_panel.current_edge} PK!Mcotinga/gui/pupils_progression_manager/dialogs/pages/literal_grading_panel.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gettext import translation from mathmakerlib.calculus import Number import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga.core import shared from cotinga.core.env import LOCALEDIR, L10N_DOMAIN from cotinga.gui.panels import ListManagerPanel from cotinga.data.default.data.pmdoc.presets import GRADES_SCALES class LiteralGradingPanel(ListManagerPanel): def __init__(self, grading_setup): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext ListManagerPanel.__init__(self, grading_setup['literal_grades'], tr('Labels'), presets=(GRADES_SCALES(), tr('Load a preset scale'), tr('Replace current scale ' 'by: '), 'insert-text')) self.current_edge = grading_setup['edge_literal'] self.edges_store = Gtk.ListStore(str) self.len_edges_store = 0 self.currently_selected = 0 self.update_edges_store() self.combo = Gtk.ComboBox.new_with_model(self.edges_store) renderer = Gtk.CellRendererText() self.combo.pack_start(renderer, False) self.combo.add_attribute(renderer, 'text', 0) self.combo.set_active(self.currently_selected) self.combo.set_margin_top(7) self.combo.set_margin_left(10) # combo.connect('changed', self.on_choice_changed) combo_grid = Gtk.Grid() combo_label = Gtk.Label(tr('Edge:')) combo_label.set_margin_top(7) combo_grid.attach(combo_label, 0, 0, 1, 1) combo_grid.attach_next_to(self.combo, combo_label, Gtk.PositionType.RIGHT, 1, 1) self.attach_next_to(combo_grid, self.buttons_grid, Gtk.PositionType.RIGHT, 1, 1) self.combo.connect('changed', self.on_edge_choice_changed) self.connect('data_changed', self.on_data_changed) def update_edges_store(self): # Remove current edges list for i in range(len(self.edges_store)): treeiter = self.edges_store.get_iter(Gtk.TreePath(0)) self.edges_store.remove(treeiter) # Rebuild list from scratch entries = [row[0] for row in self.store] entries = entries[:-1] for entry in entries: self.edges_store.append([entry]) # Find out the best new selection: either we keep the previous value, # or try to stick close to it, or set to 0. new_selection = None for i, edge in enumerate(entries): if edge == self.current_edge: new_selection = i if new_selection is None: new_selection = int(Number((self.currently_selected / self.len_edges_store) * len(self.edges_store)) .rounded(Number(1))) if new_selection < 0: new_selection = 0 self.currently_selected = new_selection self.len_edges_store = len(self.edges_store) def on_data_changed(self, *args): self.update_edges_store() self.combo.set_active(self.currently_selected) def on_edge_choice_changed(self, combo): tree_iter = combo.get_active_iter() if tree_iter is not None: model = combo.get_model() self.current_edge = model[tree_iter][0] entries = [row[0] for row in self.edges_store] new_selection = None for i, edge in enumerate(entries): if edge == self.current_edge: new_selection = i if new_selection is not None: self.currently_selected = new_selection PK!|dMcotinga/gui/pupils_progression_manager/dialogs/pages/numeric_grading_panel.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import sys import locale from gettext import translation from mathmakerlib.calculus import Number import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga.core import shared from cotinga.core.env import LOCALEDIR, L10N_DOMAIN from cotinga.core import constants STEPS = constants.NUMERIC_STEPS class NumericGradingPanel(Gtk.Grid): def __init__(self, grading_setup): Gtk.Grid.__init__(self) self.set_column_spacing(10) self.set_vexpand(True) self.set_hexpand(True) PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext self.minimum = grading_setup['minimum'] self.maximum = grading_setup['maximum'] self.edge = grading_setup['edge_numeric'] self.step = Number(STEPS[grading_setup['step']]) self.steps_store = Gtk.ListStore(str, str) for i, s in enumerate(STEPS): self.steps_store.append([str(i), locale.str(Number(STEPS[s]))]) self.steps_combo = \ Gtk.ComboBox.new_with_model(self.steps_store) self.steps_combo.props.margin_bottom = 5 self.steps_combo.set_id_column(0) self.steps_combo.set_entry_text_column(1) renderer = Gtk.CellRendererText() self.steps_combo.pack_start(renderer, True) self.steps_combo.add_attribute(renderer, 'text', 1) self.steps_combo.set_active(grading_setup['step']) self.steps_combo.connect('changed', self.on_steps_combo_changed) self.minimum_button = Gtk.SpinButton() self.edge_button = Gtk.SpinButton() self.maximum_button = Gtk.SpinButton() for b in [self.minimum_button, self.edge_button, self.maximum_button]: b.set_numeric(True) b.set_snap_to_ticks(True) b.set_update_policy(Gtk.SpinButtonUpdatePolicy.IF_VALID) self.adjust(['minimum', 'edge', 'maximum']) self.minimum_button.set_value(Number(self.minimum)) self.edge_button.set_value(Number(self.edge)) self.maximum_button.set_value(Number(self.maximum)) self.minimum_button.connect('value-changed', self.on_minimum_changed) self.edge_button.connect('value-changed', self.on_edge_changed) self.maximum_button.connect('value-changed', self.on_maximum_changed) steps_label = Gtk.Label(tr('Precision')) self.attach(steps_label, 0, 0, 1, 1) self.attach_next_to(self.steps_combo, steps_label, Gtk.PositionType.RIGHT, 1, 1) mini_label = Gtk.Label(tr('Minimum')) self.attach_next_to(mini_label, steps_label, Gtk.PositionType.BOTTOM, 1, 1) self.attach_next_to(self.minimum_button, mini_label, Gtk.PositionType.RIGHT, 1, 1) edge_label = Gtk.Label(tr('Edge')) self.attach_next_to(edge_label, mini_label, Gtk.PositionType.BOTTOM, 1, 1) self.attach_next_to(self.edge_button, edge_label, Gtk.PositionType.RIGHT, 1, 1) maxi_label = Gtk.Label(tr('Maximum')) self.attach_next_to(maxi_label, edge_label, Gtk.PositionType.BOTTOM, 1, 1) self.attach_next_to(self.maximum_button, maxi_label, Gtk.PositionType.RIGHT, 1, 1) self.show_all() def on_steps_combo_changed(self, combo): self.step = Number(STEPS[int(combo.get_active_id())]) self.adjust(['minimum', 'edge', 'maximum']) def on_minimum_changed(self, button): self.minimum = button.get_value() self.adjust(['edge', 'maximum']) def on_edge_changed(self, button): self.edge = button.get_value() self.adjust(['minimum', 'maximum']) def on_maximum_changed(self, button): self.maximum = button.get_value() self.adjust(['minimum', 'edge']) def adjust(self, buttons_list): for button_name in buttons_list: button = getattr(self, '{}_button'.format(button_name)) button.set_digits(self.step.fracdigits_nb()) button.set_increments(self.step, 10 * self.step) if button_name == 'minimum': button.set_range(0, Number(self.edge) - self.step) elif button_name == 'edge': button.set_range(Number(self.minimum) + self.step, Number(self.maximum) - self.step) elif button_name == 'maximum': button.set_range(Number(self.edge) + self.step, sys.maxsize) PK!$$.cotinga/gui/pupils_progression_manager/page.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gettext import translation import gi try: gi.require_version('Gtk', '3.0') gi.require_version('GdkPixbuf', '2.0') except ValueError: raise else: from gi.repository import Gtk, GdkPixbuf from cotinga.core import shared, pmdoc from cotinga.gui.panels import PupilsManagerPanel, PupilsViewPanel from .toolbar import PupilsProgressionManagerToolbar from cotinga.core.env import LOCALEDIR, L10N_DOMAIN, COTINGA_FADED_ICON from cotinga.core.env import __version__ class PupilsProgressionManagerPage(Gtk.Grid): def __init__(self): Gtk.Grid.__init__(self) self.set_border_width(3) self.toolbar = PupilsProgressionManagerToolbar() self.toolbar.set_margin_top(6) self.attach(self.toolbar, 0, 0, 1, 1) self.classnames = None self.panels = {} self.classes_stack = None self.stack_switcher = None self.main_grid = None self.view_panel = None self.setup_pages() def new_switch_and_stack(self): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext if self.classes_stack is not None: self.classes_stack.destroy() self.classes_stack = Gtk.Stack() self.classes_stack.set_transition_type(Gtk.StackTransitionType.NONE) self.classes_stack.set_transition_duration(300) if self.stack_switcher is not None: self.stack_switcher.destroy() self.stack_switcher = Gtk.StackSwitcher() self.stack_switcher.props.margin_bottom = 10 self.stack_switcher.props.margin_top = 10 self.stack_switcher.set_stack(self.classes_stack) self.main_grid.attach(self.stack_switcher, 0, 0, 1, 1) self.view_cols_buttons = Gtk.Grid() self.view_cols_buttons.set_vexpand(False) self.view_cols_buttons.set_halign(Gtk.Align.END) self.view_cols_buttons.set_valign(Gtk.Align.END) self.view_cols_buttons.props.margin_right = 3 view_cols_label = Gtk.Label(tr('View columns:')) view_cols_label.props.margin_right = 10 self.view_cols_buttons.attach(view_cols_label, 0, 0, 1, 1) self.view_id_btn = Gtk.CheckButton('id') self.view_id_btn.set_active(shared.STATUS.show_col_id) self.view_id_btn.connect('toggled', self.on_view_id_toggled) self.view_incl_btn = Gtk.CheckButton(tr('Included')) self.view_incl_btn.set_active(shared.STATUS.show_col_incl) self.view_incl_btn.connect('toggled', self.on_view_incl_toggled) self.view_ilevel_btn = Gtk.CheckButton(tr('Initial level')) self.view_ilevel_btn.set_active(shared.STATUS.show_col_ilevel) self.view_ilevel_btn.connect('toggled', self.on_view_ilevel_toggled) if PREFS.enable_devtools: items = [view_cols_label, self.view_id_btn, self.view_incl_btn, self.view_ilevel_btn] else: items = [view_cols_label, self.view_incl_btn, self.view_ilevel_btn] for i, item in enumerate(items): if i: self.view_cols_buttons.attach_next_to( item, items[i - 1], Gtk.PositionType.RIGHT, 1, 1) self.main_grid.attach_next_to( self.view_cols_buttons, self.stack_switcher, Gtk.PositionType.BOTTOM, 1, 1) self.main_grid.attach_next_to(self.classes_stack, self.stack_switcher, Gtk.PositionType.BOTTOM, 1, 1) def setup_pages(self): PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext if self.main_grid is not None: self.main_grid.destroy() self.main_grid = Gtk.Grid() self.attach_next_to(self.main_grid, self.toolbar, Gtk.PositionType.BOTTOM, 1, 1) if shared.session is None: cot_icon = GdkPixbuf.Pixbuf.new_from_file_at_scale( COTINGA_FADED_ICON, 128, -1, True) cot_icon = Gtk.Image.new_from_pixbuf(cot_icon) # TODO: write the welcome line bigger and bold (Pango) welcome_label = Gtk.Label(tr('Welcome in Cotinga')) # TODO: write the version line smaller and faded (Pango) version_label = Gtk.Label(tr('Version {}').format(__version__)) version_label.props.margin_bottom = 15 icon1 = Gtk.Image.new_from_icon_name('document-new', Gtk.IconSize.DIALOG) icon1.props.margin = 10 icon2 = Gtk.Image.new_from_icon_name('document-open', Gtk.IconSize.DIALOG) icon2.props.margin = 10 label = Gtk.Label(tr('You can create a new document\nor ' 'load an existing one.')) inner_grid = Gtk.Grid() inner_grid.set_vexpand(True) inner_grid.set_hexpand(True) inner_grid.set_halign(Gtk.Align.CENTER) inner_grid.set_valign(Gtk.Align.CENTER) inner_grid.attach(cot_icon, 0, 0, 3, 1) inner_grid.attach_next_to(welcome_label, cot_icon, Gtk.PositionType.BOTTOM, 3, 1) inner_grid.attach_next_to(version_label, welcome_label, Gtk.PositionType.BOTTOM, 3, 1) inner_grid.attach_next_to(icon1, version_label, Gtk.PositionType.BOTTOM, 1, 1) inner_grid.attach_next_to(icon2, icon1, Gtk.PositionType.RIGHT, 1, 1) inner_grid.attach_next_to(label, icon2, Gtk.PositionType.RIGHT, 1, 1) inner_grid.show_all() self.main_grid.attach(inner_grid, 0, 0, 1, 1) else: classnames = pmdoc.setting.load()['classes'] if classnames: self.panels = {} self.classnames = classnames self.new_switch_and_stack() if self.view_panel is not None: self.view_panel.destroy() self.view_panel = PupilsViewPanel() self.classes_stack.add_titled(self.view_panel, 'pupils_view_panel', tr('Global view')) for label in classnames: panel = PupilsManagerPanel(label) panel.connect('data_changed', self.on_data_changed) self.classes_stack.add_titled(panel, label, label) self.panels[label] = panel else: icon = Gtk.Image.new_from_icon_name('gnome-settings', Gtk.IconSize.DIALOG) icon.props.margin = 10 label = Gtk.Label(tr('You can start creating classes in the ' 'document settings.')) inner_grid = Gtk.Grid() inner_grid.set_vexpand(True) inner_grid.set_hexpand(True) inner_grid.set_halign(Gtk.Align.CENTER) inner_grid.set_valign(Gtk.Align.CENTER) inner_grid.attach(icon, 0, 0, 1, 1) inner_grid.attach_next_to(label, icon, Gtk.PositionType.RIGHT, 1, 1) inner_grid.show_all() self.main_grid.attach(inner_grid, 0, 0, 1, 1) self.show_all() if self.view_panel is not None: self.view_panel.setup_info_visibility() def on_data_changed(self, *args): self.view_panel.refresh() def on_view_id_toggled(self, *args): shared.STATUS.show_col_id = not shared.STATUS.show_col_id def on_view_incl_toggled(self, *args): shared.STATUS.show_col_incl = not shared.STATUS.show_col_incl def on_view_ilevel_toggled(self, *args): shared.STATUS.show_col_ilevel = not shared.STATUS.show_col_ilevel def refresh_visible_cols(self, *args): panels = [self.panels[p] for p in self.panels] + [self.view_panel] for p in panels: p.col_id.set_visible(shared.STATUS.show_col_id and shared.PREFS.enable_devtools) p.col_incl.set_visible(shared.STATUS.show_col_incl) p.col_ilevel.set_visible(shared.STATUS.show_col_ilevel) PK!b۸RH"H"1cotinga/gui/pupils_progression_manager/toolbar.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gettext import translation import gi try: gi.require_version('Gtk', '3.0') except ValueError: raise else: from gi.repository import Gtk from cotinga import gui from cotinga.gui.core import IconsThemable from cotinga.core import shared from cotinga.core.env import ICON_THEME, L10N_DOMAIN, LOCALEDIR from cotinga.core import pmdoc from .dialogs import DocumentSettingDialog document = pmdoc.document class __MetaThemableToolbar(type(Gtk.Toolbar), type(IconsThemable)): pass class PupilsProgressionManagerToolbar(Gtk.Toolbar, IconsThemable, metaclass=__MetaThemableToolbar): def __init__(self): Gtk.Toolbar.__init__(self) IconsThemable.__init__(self) self.doc_new_button = Gtk.ToolButton.new() self.doc_new_button.set_vexpand(False) self.doc_new_button.set_halign(Gtk.Align.CENTER) self.doc_new_button.set_valign(Gtk.Align.CENTER) self.doc_new_button.connect('clicked', self.on_doc_new_clicked) self.add(self.doc_new_button) self.doc_open_button = Gtk.ToolButton.new() self.doc_open_button.set_vexpand(False) self.doc_open_button.set_halign(Gtk.Align.CENTER) self.doc_open_button.set_valign(Gtk.Align.CENTER) self.doc_open_button.connect('clicked', self.on_doc_open_clicked) self.add(self.doc_open_button) self.doc_save_button = Gtk.ToolButton.new() self.doc_save_button.set_vexpand(False) self.doc_save_button.set_halign(Gtk.Align.CENTER) self.doc_save_button.set_valign(Gtk.Align.CENTER) self.doc_save_button.connect('clicked', self.on_doc_save_clicked) self.add(self.doc_save_button) self.doc_save_as_button = Gtk.ToolButton.new() self.doc_save_as_button.props.icon_name = 'document-save-as' self.doc_save_as_button.set_vexpand(False) self.doc_save_as_button.set_halign(Gtk.Align.CENTER) self.doc_save_as_button.set_valign(Gtk.Align.CENTER) self.doc_save_as_button.connect('clicked', self.on_doc_save_as_clicked) self.add(self.doc_save_as_button) self.doc_close_button = Gtk.ToolButton.new() self.doc_close_button.set_vexpand(False) self.doc_close_button.set_halign(Gtk.Align.CENTER) self.doc_close_button.set_valign(Gtk.Align.CENTER) self.doc_close_button.connect('clicked', self.on_doc_close_clicked) self.add(self.doc_close_button) self.doc_setting_button = Gtk.ToolButton.new() self.doc_setting_button.set_vexpand(False) self.doc_setting_button.set_halign(Gtk.Align.CENTER) self.doc_setting_button.set_valign(Gtk.Align.CENTER) self.doc_setting_button.connect( 'clicked', self.on_doc_setting_clicked) self.add(self.doc_setting_button) # LATER: add a document-open-recent button self.buttons = {'document-new': self.doc_new_button, 'document-open': self.doc_open_button, 'document-close': self.doc_close_button, 'document-save': self.doc_save_button, 'document-save-as': self.doc_save_as_button, 'document-setup': self.doc_setting_button} self.setup_buttons_icons(ICON_THEME) def buttons_icons(self): """Define icon names and fallback to standard icon name.""" # Last item of each list is the fallback, hence must be standard buttons = {'doc_new_button': ['document-new'], 'doc_open_button': ['document-open'], 'doc_save_button': ['document-save'], 'doc_save_as_button': ['document-save-as'], 'doc_close_button': ['document-close', 'window-close'], 'doc_setting_button': ['gnome-settings', 'preferences-desktop'], } return buttons def buttons_labels(self): """Define labels of buttons.""" PREFS = shared.PREFS tr = translation(L10N_DOMAIN, LOCALEDIR, [PREFS.language]).gettext buttons = {'doc_new_button': tr('New'), 'doc_open_button': tr('Open'), 'doc_save_button': tr('Save'), 'doc_save_as_button': tr('Save as...'), 'doc_close_button': tr('Close'), 'doc_setting_button': tr('Settings'), } return buttons def on_doc_new_clicked(self, widget): """Called on "new file" clicks""" document.new() def on_doc_close_clicked(self, widget): """Called on "close file" clicks""" document.close() def on_doc_save_as_clicked(self, widget): """Called on "save as" clicks""" document.save_as() def on_doc_save_clicked(self, widget): """Called on "save as" clicks""" document.save() def on_doc_open_clicked(self, widget): """Called on "open file" clicks""" document.open_() def on_doc_setting_clicked(self, widget): """Called on "document setup" clicks""" dialog = DocumentSettingDialog() dialog.set_modal(True) response = dialog.run() if response == Gtk.ResponseType.OK: # LATER: when validating, if the user is inserting something that # he did not validate yet via return, then it's lost. Check if # there's a way to keep the entry if it's not # None (e.g. validate it or not via cell_edited(). # The 'editing-canceled' event from CellRendererText seems useless # unfortunately (the text is then already set to None) # Maybe a way is to disable the validate button when insert_button # is clicked and until the entry is validated by return. new_levels = [row[0] for row in dialog.levels_panel.store if row[0] is not None] new_special_grades = [row[0] for row in dialog.special_grades_panel.store if row[0] is not None] new_grading = dialog.grading_manager.get_grading() new_classes = [row[0] for row in dialog.classes_panel.store if row[0] is not None] docsetup = pmdoc.setting.load() previous_levels = docsetup['levels'] previous_special_grades = docsetup['special_grades'] previous_grading = docsetup['grading'] previous_classes = docsetup['classes'] if new_classes != previous_classes: # Remove filters of removed classes from filters ON, if any shared.STATUS.filters = [label for label in shared.STATUS.filters if label in new_classes] if any(new != previous for (new, previous) in zip([new_levels, new_special_grades, new_grading, new_classes], [previous_levels, previous_special_grades, previous_grading, previous_classes])): docsetup = pmdoc.setting.save( {'levels': new_levels, 'special_grades': new_special_grades, 'classes': new_classes, 'grading': new_grading}) shared.STATUS.document_modified = True gui.app.window.pupils_progression_manager_page.setup_pages() dialog.destroy() PK!=Kllcotinga/models/__init__.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import sys from .pupils import Pupils, pupils_columns, pupils_tablename, PUPILS_COL_NBS this = sys.modules[__name__] __all__ = ['Pupils', 'pupils_columns', 'pupils_tablename', 'PUPILS_COL_NBS'] TABLENAMES = [item[:-len('_tablename')] for item in __all__ if item.endswith('_tablename')] COLNAMES = {tablename: [col.name for col in getattr(this, '{}_columns'.format(tablename))()] for tablename in TABLENAMES} PK! cotinga/models/pupils.py# -*- coding: utf-8 -*- # Cotinga helps maths teachers creating worksheets # and managing pupils' progression. # Copyright 2018 Nicolas Hainaux # This file is part of Cotinga. # Cotinga 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 # any later version. # Cotinga 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 Cotinga; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from sqlalchemy import Column, Integer, String, Boolean from sqlalchemy_utils import ScalarListType from cotinga.core import constants SEP = constants.INTERNAL_SEPARATOR pupils_tablename = 'pupils' PUPILS_COL_NBS = {'id': 0, 'included': 1, 'classname': 2, 'fullname': 3, 'initial_level': 4, 'attained_level': 5, 'grades': 6} class Pupils(object): def __init__(self, included, classname, fullname, initial_level, attained_level, grades): self.included = included self.classname = classname self.fullname = fullname self.initial_level = initial_level self.attained_level = attained_level self.grades = grades def __repr__(self): return 'Pupils(included={}, classname={}, fullname={}, '\ 'initial_level={}, attained_level={}, grades={})'\ .format(repr(self.included), repr(self.classname), repr(self.fullname), repr(self.initial_level), repr(self.attained_level), repr(self.grades)) def pupils_columns(): return (Column('id', Integer, primary_key=True), Column('included', Boolean), Column('classname', String), Column('fullname', String), Column('initial_level', String), Column('attained_level', String), Column('grades', ScalarListType(separator=SEP)), ) PK!H##d'+(cotinga-0.1.0.dist-info/entry_points.txtN+I/N.,()J/KOz饙VEy\\PK!|wfKKcotinga-0.1.0.dist-info/LICENSE GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . PK!HlŃTTcotinga-0.1.0.dist-info/WHEEL A н#J@Z|Jmqvh&#hڭw!Ѭ"J˫( } %PK!HL8 cotinga-0.1.0.dist-info/METADATA]O  .5YI[9mb.Z4^X&ژsx8p^A $iTœpDSAД&c.'J+wPyT/E7B}ٺZk @4~|cT dN:usQrܷ 7h> $+ѕ|Rj}XXc=}'.'WP$'EB3[!1VP XBFNW+xG#Eth6;fpPl2^5.fy/['C2FYHɆ&;d84 PK!H:+# cotinga-0.1.0.dist-info/RECORDIX[( 2lxMYe5{)E8͘Չfu6 cc2%#thΰ,K'_f@UyH ~^P`U-^+JWN#|kk{@ M=^=Oĕ,}7h[wkv][hap30O(v>a.ҝ#s0!\bI㙮ky6$(M2\T\{kDžа=k$YDHJmH35O(BZgը챳A-# '*HBH3&x21 E 9qvNڴSxy; Pz{CDm)k5=6FGk]w2 $&S(;R2kn;sFBO6@8 Gm?C-Ӆ 0 @SYY)-0O5ð" W!ߞ=Q/-yݡq8t:㠃[&Tycg'F)\ Z.n:+='V)FRy­ B_|A(|I 5N8 y<ʄrHIVTΖ=  Ńcc?x!"2lTmvW蠛5/|K>6Da+\YY"R"n0Ka6> ؛營قY~hzNzCpE~PIDI[8|B-S[q TĄ Vy"X͈o݅-ǧ/.x[e@{x$ۺL);v)!pγۥhH'G<<@3Jj+j9ۍ,nd4рƱME.쩆ЮSꕠ!n3QYo]z/g$~Ȼ~Vi!cl4>W |4@DLx vxќhO]&: @O;l|;ޟh+dCɫ>8|E!Ne@ܶhH!]4jORJsu.ȟ|G\8r'\ ėk`vLɟ3Z[.%A+;B j*oK^h'.^P^sѳ&bn@Ϡ_dž\/)yq jOzߵb/ܺ瓂 rnvάih *5擹Qӛ ]~*=%VҮu[t!X%(bJKqm5sxZ=݀Q a9{`}Aax`{1K7KRu }<*a]R!-N+e<ݡ]yLx 1xTrB|3iTy~BO>_QJ c" d nF`JTeH8+.]ی$SĥBA}B߃_ K(W%ɴzKMx=RzNgQagSP]"_oRΟk,+hh2G~ρ6XyF;DAK۱QD+:#"`lڻqᚓ\Gv;~]?߸+cCwX@0 ~Ϣ ;P|7T/5RZSqE}AO :x Y}Uom#KAcVh]]]s^/ώ2Uo]]|I˪mW (kNҖ@^alʫ7k[]Yt\ պ&> s70_ ?{iLlSt7v[WqiI ޮ+vjrV"noƹi'iL\)eVq% kA@({_oMgNwN*D`ja&Wv if+#\Gm$݇[}U{=GE4GW*!hnk@qKV\.բ:=JDAdb<>a =Q $k^q_!OsWH`07.d1tdU>mLEԡF͵qk2(|& ^'nFtWfFgCRt M"}۰{o 5fEN0[t2? 2зy@IvUSY*l'AL~ZFK×]rҸ{^R,َǢ|^`{9U,L$Yrme&vR 6֖q){{PҸK?޷ݘC:5HOEmG>]PՄ>"l̴?v'Ҩrq!ss]֐`#`6RgpO`5[eucp&{{s;.^o!ˆRLYəؖq&|dԲy^4ˣXoc bܰ]="x0$R|Fc96@(-XVw"jaQ4*1,ˑw:>2$-Sbu@; 8:VS˥Ntvօ$Hÿ^ٽ|=PK!$ucotinga/__init__.pyPK!Nycotinga/core/__init__.pyPK!,cotinga/core/constants.pyPK!HHH& cotinga/core/env.pyPK!W  !cotinga/core/errors.pyPK!ii-cotinga/core/io.pyPK!~3cotinga/core/pmdoc/__init__.pyPK!:$7cotinga/core/pmdoc/database.pyPK!NzKcotinga/core/pmdoc/document.pyPK!׹jjjcotinga/core/pmdoc/report.pyPK!->B}cotinga/core/pmdoc/setting.pyPK!c((<cotinga/core/prefs.pyPK!__cotinga/core/shared.pyPK!ǜp*cotinga/core/status.pyPK!DΙ " "vcotinga/core/tools.pyPK!yO*cotinga/data/default/data/pmdoc/presets.pyPK!Mjy}!!*cotinga/data/default/data/prefs/en_US.tomlPK! ;!!*cotinga/data/default/data/prefs/fr_FR.tomlPK!22'Rlcotinga/gui/panels/list_manager_base.pyPK!SHpDD(%cotinga/gui/panels/list_manager_panel.pyPK!f`HH*cotinga/gui/panels/pupils_manager_panel.pyPK!fghsMsM'?Pcotinga/gui/panels/pupils_view_panel.pyPK!42cotinga/gui/pupils_progression_manager/__init__.pyPK! :cotinga/gui/pupils_progression_manager/dialogs/__init__.pyPK!s>~~=cotinga/gui/pupils_progression_manager/dialogs/doc_setting.pyPK!-J@cotinga/gui/pupils_progression_manager/dialogs/pages/__init__.pyPK!vh h Gcotinga/gui/pupils_progression_manager/dialogs/pages/grading_manager.pyPK!Mcotinga/gui/pupils_progression_manager/dialogs/pages/literal_grading_panel.pyPK!|dMcotinga/gui/pupils_progression_manager/dialogs/pages/numeric_grading_panel.pyPK!$$.1cotinga/gui/pupils_progression_manager/page.pyPK!b۸RH"H"1cotinga/gui/pupils_progression_manager/toolbar.pyPK!=Kll7cotinga/models/__init__.pyPK! T=cotinga/models/pupils.pyPK!H##d'+(uFcotinga-0.1.0.dist-info/entry_points.txtPK!|wfKKFcotinga-0.1.0.dist-info/LICENSEPK!HlŃTTjcotinga-0.1.0.dist-info/WHEELPK!HL8 cotinga-0.1.0.dist-info/METADATAPK!H:+# ocotinga-0.1.0.dist-info/RECORDPKBB9