Subversion Repositories basico

Rev

Rev 142 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 144
Line 12... Line 12...
12
gi.require_version('Gtk', '3.0')
12
gi.require_version('Gtk', '3.0')
13
from gi.repository import Gtk
13
from gi.repository import Gtk
14
from gi.repository import Gdk
14
from gi.repository import Gdk
15
from gi.repository import Pango
15
from gi.repository import Pango
16
16
-
 
17
from .widgets import ListReview
17
from .service import Service
18
from .service import Service
18
19
19
20
20
class LaunchpadDialog(Gtk.VBox, Service):
21
class LaunchpadDialog(Gtk.VBox, Service):
21
    def __init__(self, app):
22
    def __init__(self, app):
22
        Gtk.VBox.__init__(self, app)
-
 
-
 
23
        Gtk.VBox.__init__(self)
23
        self.app = app
24
        self.app = app
24
-
 
-
 
25
        self.log = app.log
25
        self.get_services()
26
        self.get_services()
26
        self.setup()
27
        self.setup()
27
28
28
29
29
    def setup(self):
30
    def setup(self):
-
 
31
        self.statusbar = self.gui.get_widget('statusbar')
30
        menuview = self.gui.get_widget('tgbShowMenuView')
32
        menuview = self.gui.get_widget('tgbShowMenuView')
31
        menuview.set_active(False)
33
        menuview.set_active(False)
32
        self.set_property('margin', 6)
34
        self.set_property('margin', 6)
33
        self.set_spacing(6)
35
        self.set_spacing(6)
34
36
35
        box = Gtk.VBox()
-
 
36
        box.set_vexpand(True)
-
 
37
        self.pack_end(box, True, True, 0)
-
 
-
 
37
        self.vbox = Gtk.VBox()
-
 
38
        self.vbox.set_vexpand(True)
-
 
39
        self.vbox.set_hexpand(True)
-
 
40
        self.pack_start(self.vbox, True, True, 0)
38
41
39
        # Label
42
        # Label
40
        title = Gtk.Label()
43
        title = Gtk.Label()
41
        title.set_markup('<big><b>Import from Launchpad</b></big>')
44
        title.set_markup('<big><b>Import from Launchpad</b></big>')
42
        title.modify_font(Pango.FontDescription('Arial 24'))
45
        title.modify_font(Pango.FontDescription('Arial 24'))
43
        box.pack_start(title, False, True, 6)
-
 
-
 
46
        self.vbox.pack_start(title, False, True, 6)
44
47
45
        # Instructions
48
        # Instructions
46
        label = Gtk.Label()
49
        label = Gtk.Label()
47
        message =   "Write down the list of SAP Notes that you want to download\nThey can be separated by newline or by commas"
50
        message =   "Write down the list of SAP Notes that you want to download\nThey can be separated by newline or by commas"
48
        label.set_markup('<big>%s</big>' % message)
51
        label.set_markup('<big>%s</big>' % message)
49
        label.set_justify(Gtk.Justification.CENTER)
52
        label.set_justify(Gtk.Justification.CENTER)
50
        label.modify_font(Pango.FontDescription('Arial 12'))
53
        label.modify_font(Pango.FontDescription('Arial 12'))
51
        box.pack_start(label, False, True, 6)
-
 
-
 
54
        self.vbox.pack_start(label, False, True, 6)
52
55
-
 
56
        # Text Box
-
 
57
        # ~ self.revealer = Gtk.Revealer()
-
 
58
        self.textbox = Gtk.HBox()
-
 
59
        # ~ self.entry = Gtk.Entry()
-
 
60
        # ~ self.textbox.pack_start(self.entry, True, True, 6)
53
        scrolledwindow = Gtk.ScrolledWindow()
61
        scrolledwindow = Gtk.ScrolledWindow()
54
        scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
62
        scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
55
        scrolledwindow.set_shadow_type(Gtk.ShadowType.IN)
63
        scrolledwindow.set_shadow_type(Gtk.ShadowType.IN)
56
        scrolledwindow.set_hexpand(True)
64
        scrolledwindow.set_hexpand(True)
57
        scrolledwindow.set_vexpand(True)
65
        scrolledwindow.set_vexpand(True)
58
        textview = Gtk.TextView()
66
        textview = Gtk.TextView()
59
        self.textbuffer = textview.get_buffer()
67
        self.textbuffer = textview.get_buffer()
60
        self.textbuffer.set_text("")
68
        self.textbuffer.set_text("")
61
        scrolledwindow.add(textview)
69
        scrolledwindow.add(textview)
62
        box.pack_start(scrolledwindow, True, True, 0)
-
 
-
 
70
        self.textbox.add(scrolledwindow)
-
 
71
        self.vbox.pack_start(self.textbox, False, True, 0)
63
72
-
 
73
        # Review Box
-
 
74
        self.review = ListReview(self.app)
-
 
75
        self.debug(self.review)
-
 
76
        self.vbox.pack_start(self.review, True, True, 6)
64
77
-
 
78
        # Button box
65
        buttonbox = Gtk.ButtonBox() #.new(Gtk.Orientation.HORIZONTAL)
79
        buttonbox = Gtk.ButtonBox() #.new(Gtk.Orientation.HORIZONTAL)
66
        buttonbox.set_hexpand(False)
80
        buttonbox.set_hexpand(False)
67
        buttonbox.set_vexpand(False)
81
        buttonbox.set_vexpand(False)
68
        buttonbox.set_layout(Gtk.ButtonBoxStyle.EDGE )
82
        buttonbox.set_layout(Gtk.ButtonBoxStyle.EDGE )
69
83
-
 
84
        ## Cancel Button
70
        button = Gtk.Button('Cancel')
85
        button = Gtk.Button('Cancel')
71
        button.set_can_focus(False)
86
        button.set_can_focus(False)
72
        icon = self.im.get_new_image_icon('gtk-cancel', 24, 24)
87
        icon = self.im.get_new_image_icon('gtk-cancel', 24, 24)
73
        button.set_image(icon)
88
        button.set_image(icon)
74
        button.set_always_show_image(True)
89
        button.set_always_show_image(True)
75
        button.set_relief(Gtk.ReliefStyle.NONE)
90
        button.set_relief(Gtk.ReliefStyle.NONE)
76
        button.connect("clicked", self.cancel)
91
        button.connect("clicked", self.cancel)
77
        buttonbox.pack_start(button, False, False, 0)
92
        buttonbox.pack_start(button, False, False, 0)
78
93
-
 
94
        ## Review Button
-
 
95
        button = Gtk.Button('Cancel')
-
 
96
        button.set_can_focus(False)
-
 
97
        icon = self.im.get_new_image_icon('gtk-cancel', 24, 24)
-
 
98
        button.set_image(icon)
-
 
99
        button.set_always_show_image(True)
-
 
100
        button.set_relief(Gtk.ReliefStyle.NONE)
-
 
101
        button.connect("clicked", self.cancel)
-
 
102
        buttonbox.pack_start(button, False, False, 0)
-
 
103
-
 
104
        ## Accept Button
79
        button = Gtk.Button('Accept')
105
        button = Gtk.Button('Accept')
80
        button.set_can_focus(False)
106
        button.set_can_focus(False)
81
        icon = self.im.get_new_image_icon('gtk-apply', 24, 24)
107
        icon = self.im.get_new_image_icon('gtk-apply', 24, 24)
82
        button.set_image(icon)
108
        button.set_image(icon)
83
        button.set_always_show_image(True)
109
        button.set_always_show_image(True)
84
        button.set_relief(Gtk.ReliefStyle.NONE)
110
        button.set_relief(Gtk.ReliefStyle.NONE)
85
        button.connect("clicked", self.accept)
111
        button.connect("clicked", self.accept)
86
        buttonbox.pack_start(button, True, True, 0)
112
        buttonbox.pack_start(button, True, True, 0)
87
        box.pack_start(buttonbox, False, True, 6)
-
 
-
 
113
        self.vbox.pack_start(buttonbox, False, True, 6)
88
114
89
        self.show_all()
115
        self.show_all()
90
116
91
117
92
    def get_services(self):
118
    def get_services(self):
Line 94... Line 120...
94
        self.gui = self.app.get_service('GUI')
120
        self.gui = self.app.get_service('GUI')
95
        self.cb = self.app.get_service('Callbacks')
121
        self.cb = self.app.get_service('Callbacks')
96
122
97
123
98
    def accept(self, *args):
124
    def accept(self, *args):
-
 
125
        bag = set()
-
 
126
        sapnotes = []
-
 
127
99
        lines = self.get_buffer()
128
        lines = self.get_buffer()
100
        self.cb.import_notes_from_sapnet(lines)
-
 
-
 
129
        lines = lines.replace(' ', ',')
-
 
130
        lines = lines.replace('\n', ',')
-
 
131
        sapnotes.extend(lines.split(','))
-
 
132
        for sapnote in sapnotes:
-
 
133
            if len(sapnote.strip()) > 0:
-
 
134
                bag.add(sapnote.strip())
-
 
135
        self.debug("Bag Set: %s" % bag)
-
 
136
        lbag = list(bag)
-
 
137
        lbag.sort()
-
 
138
        self.textbox.hide()
-
 
139
        self.vbox.set_vexpand(True)
-
 
140
        self.review.fill(lbag)
-
 
141
-
 
142
        for sid in lbag:
-
 
143
            result = self.cb.import_notes_from_sapnet([sid])
-
 
144
            if result[sid]:
-
 
145
                self.statusbar.message("SAP Note %s downloaded successfully" % sid)
-
 
146
            self.debug(result)
101
147
102
148
103
    def cancel(self, *args):
149
    def cancel(self, *args):
104
        self.cb.show_about()
150
        self.cb.show_about()
105
151