Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 144 → Rev 143

/branches/BR-0.3/basico/callbacks.py
474,13 → 474,25
self.debug("Nothing imported")
dialog.destroy()
 
def import_notes_from_sapnet(self, bag):
def import_notes_from_sapnet(self, lines):
db = self.get_service('DB')
driver = self.get_service('Driver')
 
#~ notebook = self.gui.get_widget('notebook')
winroot = self.gui.get_widget('mainwindow')
sapnotes = []
bag = set()
lines = lines.replace(' ', ',')
lines = lines.replace('\n', ',')
sapnotes.extend(lines.split(','))
 
for sapnote in sapnotes:
if len(sapnote.strip()) > 0:
bag.add(sapnote.strip())
 
self.debug("%d SAP Notes to be downloaded: %s" % (len(bag), ', '.join(list(bag))))
 
result = {}
resnotes = {}
 
self.sap.start_fetching(len(bag))
dlbag = []
495,7 → 507,7
for job in jobs:
rc, sapnote = job.result()
self.debug("\tRC SAP Note %s: %s" % (sapnote, rc))
result[sapnote] = rc
resnotes[sapnote] = rc
if rc:
sid = "0"*(10 - len(sapnote)) + sapnote
dlbag.append(sid)
505,15 → 517,13
self.sap.stop_fetching()
db.save_notes()
db.build_stats()
dlbag.sort()
package = self.db.get_package(dlbag)
menuview = self.gui.get_widget('viewmenu')
menuview.populate(package)
visor = self.gui.get_widget('visor')
visor.populate(dlbag)
self.debug("Task completed.")
return result
# ~ dlbag.sort()
# ~ package = self.db.get_package(dlbag)
# ~ menuview = self.gui.get_widget('viewmenu')
# ~ menuview.populate(package)
# ~ visor = self.gui.get_widget('visor')
# ~ visor.populate(dlbag)
 
#~ notebook.set_current_page(0)
#~ dialog = Gtk.MessageDialog(winroot, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Task completed")
#~ msgrc = ""
/branches/BR-0.3/basico/importdlg.py
14,36 → 14,33
from gi.repository import Gdk
from gi.repository import Pango
 
from .widgets import ListReview
from .service import Service
 
 
class LaunchpadDialog(Gtk.VBox, Service):
def __init__(self, app):
Gtk.VBox.__init__(self)
Gtk.VBox.__init__(self, app)
self.app = app
self.log = app.log
 
self.get_services()
self.setup()
 
 
def setup(self):
self.statusbar = self.gui.get_widget('statusbar')
menuview = self.gui.get_widget('tgbShowMenuView')
menuview.set_active(False)
self.set_property('margin', 6)
self.set_spacing(6)
 
self.vbox = Gtk.VBox()
self.vbox.set_vexpand(True)
self.vbox.set_hexpand(True)
self.pack_start(self.vbox, True, True, 0)
box = Gtk.VBox()
box.set_vexpand(True)
self.pack_end(box, True, True, 0)
 
# Label
title = Gtk.Label()
title.set_markup('<big><b>Import from Launchpad</b></big>')
title.modify_font(Pango.FontDescription('Arial 24'))
self.vbox.pack_start(title, False, True, 6)
box.pack_start(title, False, True, 6)
 
# Instructions
label = Gtk.Label()
51,13 → 48,8
label.set_markup('<big>%s</big>' % message)
label.set_justify(Gtk.Justification.CENTER)
label.modify_font(Pango.FontDescription('Arial 12'))
self.vbox.pack_start(label, False, True, 6)
box.pack_start(label, False, True, 6)
 
# Text Box
# ~ self.revealer = Gtk.Revealer()
self.textbox = Gtk.HBox()
# ~ self.entry = Gtk.Entry()
# ~ self.textbox.pack_start(self.entry, True, True, 6)
scrolledwindow = Gtk.ScrolledWindow()
scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scrolledwindow.set_shadow_type(Gtk.ShadowType.IN)
67,21 → 59,14
self.textbuffer = textview.get_buffer()
self.textbuffer.set_text("")
scrolledwindow.add(textview)
self.textbox.add(scrolledwindow)
self.vbox.pack_start(self.textbox, False, True, 0)
box.pack_start(scrolledwindow, True, True, 0)
 
# Review Box
self.review = ListReview(self.app)
self.debug(self.review)
self.vbox.pack_start(self.review, True, True, 6)
 
# Button box
buttonbox = Gtk.ButtonBox() #.new(Gtk.Orientation.HORIZONTAL)
buttonbox.set_hexpand(False)
buttonbox.set_vexpand(False)
buttonbox.set_layout(Gtk.ButtonBoxStyle.EDGE )
 
## Cancel Button
button = Gtk.Button('Cancel')
button.set_can_focus(False)
icon = self.im.get_new_image_icon('gtk-cancel', 24, 24)
91,17 → 76,6
button.connect("clicked", self.cancel)
buttonbox.pack_start(button, False, False, 0)
 
## Review Button
button = Gtk.Button('Cancel')
button.set_can_focus(False)
icon = self.im.get_new_image_icon('gtk-cancel', 24, 24)
button.set_image(icon)
button.set_always_show_image(True)
button.set_relief(Gtk.ReliefStyle.NONE)
button.connect("clicked", self.cancel)
buttonbox.pack_start(button, False, False, 0)
 
## Accept Button
button = Gtk.Button('Accept')
button.set_can_focus(False)
icon = self.im.get_new_image_icon('gtk-apply', 24, 24)
110,7 → 84,7
button.set_relief(Gtk.ReliefStyle.NONE)
button.connect("clicked", self.accept)
buttonbox.pack_start(button, True, True, 0)
self.vbox.pack_start(buttonbox, False, True, 6)
box.pack_start(buttonbox, False, True, 6)
 
self.show_all()
 
122,30 → 96,10
 
 
def accept(self, *args):
bag = set()
sapnotes = []
 
lines = self.get_buffer()
lines = lines.replace(' ', ',')
lines = lines.replace('\n', ',')
sapnotes.extend(lines.split(','))
for sapnote in sapnotes:
if len(sapnote.strip()) > 0:
bag.add(sapnote.strip())
self.debug("Bag Set: %s" % bag)
lbag = list(bag)
lbag.sort()
self.textbox.hide()
self.vbox.set_vexpand(True)
self.review.fill(lbag)
self.cb.import_notes_from_sapnet(lines)
 
for sid in lbag:
result = self.cb.import_notes_from_sapnet([sid])
if result[sid]:
self.statusbar.message("SAP Note %s downloaded successfully" % sid)
self.debug(result)
 
 
def cancel(self, *args):
self.cb.show_about()
 
/branches/BR-0.3/basico/widgets.py
6,7 → 6,6
# Description: Custom widgets
 
from gi.repository import Gtk
from gi.repository import Pango
from .service import Service
 
 
52,93 → 51,3
 
def message(self, message):
self.statusbar.set_markup(message)
 
 
 
class ListReview(Gtk.ScrolledWindow, Service):
def __init__(self, app):
Gtk.VBox.__init__(self)
self.app = app
self.log = self.app.log
self.get_services()
 
self.setup()
# ~ self.fill()
 
 
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(True)
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()
self.debug("Hello")
 
 
def fill(self, bag):
iterdict = {}
for sid in bag:
riter = self.model.append([sid, 'Download not started yet', ''])
iterdict[sid] = riter
self.debug(iterdict)
/branches/BR-0.3/basico/gui.py
75,8 → 75,8
try:
child = parent.get_children()[0]
parent.remove(child)
parent.add(widget)
del (child)
parent.add(widget)
except IndexError:
parent.add(widget)
except Exception as error: