Subversion Repositories basico

Rev

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

Rev Author Line No. Line
232 t00m 1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
# File: import.py
4
# Author: Tomás Vírseda
5
# License: GPL v3
6
# Description: Import Widget
7
 
8
from os.path import sep as SEP
9
from cgi import escape
10
import gi
11
gi.require_version('Gtk', '3.0')
12
gi.require_version('Gdk', '3.0')
13
from gi.repository import Gtk
14
from gi.repository import Gdk
15
from gi.repository import Pango
16
 
233 t00m 17
from basico.core.env import ROOT, USER_DIR, APP, LPATH, GPATH, FILE
18
from basico.core.service import Service
232 t00m 19
 
20
 
21
class ImportWidget(Gtk.VBox, Service):
22
    def __init__(self, app):
23
        Gtk.VBox.__init__(self)
24
        Service.__init__(self)
25
        self.app = app
26
        self.log = app.log
27
        self.get_services()
28
        self.setup()
29
 
30
    def get_services(self):
31
        """Load services to be used in this class
32
        """
33
        self.gui = self.app.get_service("GUI")
34
        self.cb = self.app.get_service('Callbacks')
35
        self.im = self.app.get_service('IM')
36
 
37
    def setup(self):
38
        # Import Header
39
        header = Gtk.VBox()
40
        hbox = Gtk.HBox()
41
        icon = self.im.get_new_image_icon('basico-add')
42
        title = Gtk.Label()
43
        title.set_markup('<big><b>Import SAP Notes from Launchpad</b></big>')
44
        title.set_xalign(0.0)
45
        hbox.pack_start(icon, False, False, 6)
46
        hbox.pack_start(title, True, True, 0)
47
        separator = Gtk.Separator()
48
        header.pack_start(hbox, False, False, 0)
49
        header.pack_start(separator, False, False, 3)
50
        self.pack_start(header, False, False, 0)
51
 
52
        # Import body
53
        vbox = Gtk.VBox()
54
        vbox.set_size_request(400,320)
55
        label = Gtk.Label()
56
        message = "Write down the list of SAP Notes that you want to download.\nThey can be separated by a new line or by commas."
57
        label.set_markup('%s' % message)
58
        label.set_property('margin-top', 3)
59
        label.set_property('margin-bottom', 3)
60
        label.set_justify(Gtk.Justification.LEFT)
61
        label.set_xalign(0.0)
62
        vbox.pack_start(label, False, True, 0)
63
        custom_scroller = Gtk.ScrolledWindow()
64
        custom_scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
65
        custom_scroller.set_shadow_type(Gtk.ShadowType.IN)
66
        custom_scroller.set_vexpand(True)
67
        custom_text_view = self.gui.add_widget('gtk_textview_download_launchpad', Gtk.TextView())
68
        custom_text_view.set_vexpand(True)
69
        custom_text_buffer = Gtk.TextBuffer()
70
        custom_text_buffer.set_text('')
71
        custom_text_view.set_buffer(custom_text_buffer)
72
        custom_scroller.add(custom_text_view)
73
        vbox.pack_start(custom_scroller, True, True, 0)
74
        label = Gtk.Label()
75
        message = "<small>Please, be patient:  Firefox will be launched headless so you won't see any window.</small>"
76
        label.set_markup('%s' % message)
77
        label.set_justify(Gtk.Justification.LEFT)
78
        vbox.pack_end(label, False, False, 0)
79
        custom_button = Gtk.Button("Download")
80
        custom_button.connect('clicked', self.cb.sapnote_import_from_launchpad)
81
        vbox.pack_end(custom_button, False, False, 3)
82
        self.pack_start(vbox, True, True, 0)
83
        self.show_all()