Subversion Repositories basico

Rev

Rev 142 | Rev 148 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 144
Line 4... Line 4...
4
# Author: Tomás Vírseda
4
# Author: Tomás Vírseda
5
# License: GPL v3
5
# License: GPL v3
6
# Description: Custom widgets
6
# Description: Custom widgets
7
7
8
from gi.repository import Gtk
8
from gi.repository import Gtk
-
 
9
from gi.repository import Pango
9
from .service import Service
10
from .service import Service
10
11
11
12
12
class Statusbar(Gtk.HBox, Service):
13
class Statusbar(Gtk.HBox, Service):
13
    def __init__(self, app):
14
    def __init__(self, app):
Line 49... Line 50...
49
        self.gui = self.app.get_service("GUI")
50
        self.gui = self.app.get_service("GUI")
50
51
51
52
52
    def message(self, message):
53
    def message(self, message):
53
        self.statusbar.set_markup(message)
54
        self.statusbar.set_markup(message)
-
 
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)