Subversion Repositories basico

Rev

Rev 232 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#!/usr/bin/python
# -*- coding: utf-8 -*-
# File: listreview.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: ListReview widgets

from os.path import sep as SEP
from cgi import escape
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import Pango

from basico.core.env import ROOT, USER_DIR, APP, LPATH, GPATH, FILE
from basico.core.service import Service


class ListReview(Gtk.ScrolledWindow, Service):
    def __init__(self, app):
        Gtk.ScrolledWindow.__init__(self)
        self.app = app

        self.get_services()

        self.setup()


    def get_services(self):
        """Load services to be used in this class
        """

        self.gui = self.app.get_service("GUI")


    def setup(self):
        self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.set_shadow_type(Gtk.ShadowType.IN)
        viewport = Gtk.Viewport()
        self.treeview = Gtk.TreeView()
        viewport.add(self.treeview)
        self.add(viewport)

        # Setup model
        self.model = Gtk.ListStore(
            str,        # SAP Note ID
            str,        # Title
            str         # RC
        )
        self.treeview.set_model(self.model)

        # Setup columns
        # SAP Note Id
        self.renderer_sid = Gtk.CellRendererText()
        self.column_sid = Gtk.TreeViewColumn('SAP Note', self.renderer_sid, markup=0)
        self.column_sid.set_visible(True)
        self.column_sid.set_expand(False)
        self.column_sid.set_clickable(False)
        self.column_sid.set_sort_indicator(False)
        self.treeview.append_column(self.column_sid)

        # SAP Note Title
        self.renderer_title = Gtk.CellRendererText()
        self.column_title = Gtk.TreeViewColumn('Title', self.renderer_title, markup=1)
        self.column_title.set_visible(True)
        self.column_title.set_expand(True)
        self.column_title.set_clickable(False)
        self.column_title.set_sort_indicator(False)
        self.treeview.append_column(self.column_title)

        # SAP Note RC
        self.renderer_rc = Gtk.CellRendererText()
        self.column_rc = Gtk.TreeViewColumn('RC', self.renderer_rc, markup=2)
        self.column_rc.set_visible(False)
        self.column_rc.set_expand(False)
        self.column_rc.set_clickable(False)
        self.column_rc.set_sort_indicator(False)
        self.treeview.append_column(self.column_rc)

        # TreeView common
        self.treeview.set_can_focus(False)
        self.treeview.set_headers_visible(True)
        self.treeview.set_enable_search(False)
        self.treeview.set_hover_selection(False)
        self.treeview.set_grid_lines(Gtk.TreeViewGridLines.HORIZONTAL)
        self.treeview.modify_font(Pango.FontDescription('Monospace 10'))

        # Selection
        self.selection = self.treeview.get_selection()
        self.selection.set_mode(Gtk.SelectionMode.NONE)

        # ~ viewport.add(self.treeview)
        # ~ scrolledwindow.add(viewport)
        # ~ vbox.pack_start(scrolledwindow, True, True, 0)
        # ~ self.add(vbox)
        self.show_all()

    def update(self, sid, value):
        pass