Subversion Repositories basico

Rev

Rev 142 | Rev 148 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
142 t00mlabs 1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
# File: widgets.py
4
# Author: Tomás Vírseda
5
# License: GPL v3
6
# Description: Custom widgets
7
 
8
from gi.repository import Gtk
144 t00mlabs 9
from gi.repository import Pango
142 t00mlabs 10
from .service import Service
11
 
12
 
13
class Statusbar(Gtk.HBox, Service):
14
    def __init__(self, app):
15
        Gtk.HBox.__init__(self)
16
        self.app = app
17
        self.get_services()
18
        self.setup()
19
 
20
    def setup(self):
21
        vbox = Gtk.VBox()
22
        hbox = Gtk.HBox()
23
 
24
        # Status bar
25
        #~ separator = Gtk.Separator(orientation = Gtk.Orientation.HORIZONTAL)
26
        #~ vbox.pack_start(separator, True, False, 3)
27
        viewport = Gtk.Viewport()
28
        viewport.set_shadow_type(Gtk.ShadowType.IN)
29
        self.statusbar = self.gui.add_widget('statusbar', Gtk.Label())
30
        self.statusbar.set_property('margin-left', 6)
31
        self.statusbar.set_property('margin-right', 6)
32
        self.statusbar.set_property('margin-top', 6)
33
        self.statusbar.set_property('margin-bottom', 6)
34
        self.statusbar.set_xalign(0.0)
35
        self.message("<b>Welcome to Basico</b>")
36
        viewport.add(self.statusbar)
37
        hbox.pack_start(viewport, True, True, 0)
38
 
39
        # Progressbar
40
        #~ self.progressbar = Gtk.ProgressBar()
41
        #~ hbox.pack_start(self.progressbar, False, False, 0)
42
 
43
        vbox.pack_start(hbox, True, False, 0)
44
        self.add(vbox)
45
 
46
 
47
    def get_services(self):
48
        """Load services to be used in this class
49
        """
50
        self.gui = self.app.get_service("GUI")
51
 
52
 
53
    def message(self, message):
54
        self.statusbar.set_markup(message)
144 t00mlabs 55
 
56
 
57
 
58
class ListReview(Gtk.ScrolledWindow, Service):
59
    def __init__(self, app):
60
        Gtk.VBox.__init__(self)
61
        self.app = app
62
        self.log = self.app.log
63
        self.get_services()
64
 
65
        self.setup()
66
        # ~ self.fill()
67
 
68
 
69
    def get_services(self):
70
        """Load services to be used in this class
71
        """
72
        self.gui = self.app.get_service("GUI")
73
 
74
 
75
    def setup(self):
76
        self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
77
        self.set_shadow_type(Gtk.ShadowType.IN)
78
        viewport = Gtk.Viewport()
79
        self.treeview = Gtk.TreeView()
80
        viewport.add(self.treeview)
81
        self.add(viewport)
82
 
83
        # Setup model
84
        self.model = Gtk.ListStore(
85
            str,        # SAP Note ID
86
            str,        # Title
87
            str         # RC
88
        )
89
        self.treeview.set_model(self.model)
90
 
91
        # Setup columns
92
        # SAP Note Id
93
        self.renderer_sid = Gtk.CellRendererText()
94
        self.column_sid = Gtk.TreeViewColumn('SAP Note', self.renderer_sid, markup=0)
95
        self.column_sid.set_visible(True)
96
        self.column_sid.set_expand(False)
97
        self.column_sid.set_clickable(False)
98
        self.column_sid.set_sort_indicator(False)
99
        self.treeview.append_column(self.column_sid)
100
 
101
        # SAP Note Title
102
        self.renderer_title = Gtk.CellRendererText()
103
        self.column_title = Gtk.TreeViewColumn('Title', self.renderer_title, markup=1)
104
        self.column_title.set_visible(True)
105
        self.column_title.set_expand(True)
106
        self.column_title.set_clickable(False)
107
        self.column_title.set_sort_indicator(False)
108
        self.treeview.append_column(self.column_title)
109
 
110
        # SAP Note RC
111
        self.renderer_rc = Gtk.CellRendererText()
112
        self.column_rc = Gtk.TreeViewColumn('RC', self.renderer_rc, markup=2)
113
        self.column_rc.set_visible(True)
114
        self.column_rc.set_expand(False)
115
        self.column_rc.set_clickable(False)
116
        self.column_rc.set_sort_indicator(False)
117
        self.treeview.append_column(self.column_rc)
118
 
119
        # TreeView common
120
        self.treeview.set_can_focus(False)
121
        self.treeview.set_headers_visible(True)
122
        self.treeview.set_enable_search(False)
123
        self.treeview.set_hover_selection(False)
124
        self.treeview.set_grid_lines(Gtk.TreeViewGridLines.HORIZONTAL)
125
        self.treeview.modify_font(Pango.FontDescription('Monospace 10'))
126
 
127
        # Selection
128
        self.selection = self.treeview.get_selection()
129
        self.selection.set_mode(Gtk.SelectionMode.NONE)
130
 
131
        # ~ viewport.add(self.treeview)
132
        # ~ scrolledwindow.add(viewport)
133
        # ~ vbox.pack_start(scrolledwindow, True, True, 0)
134
        # ~ self.add(vbox)
135
        self.show_all()
136
        self.debug("Hello")
137
 
138
 
139
    def fill(self, bag):
140
        iterdict = {}
141
        for sid in bag:
142
            riter = self.model.append([sid, 'Download not started yet', ''])
143
            iterdict[sid] = riter
144
        self.debug(iterdict)