Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 395 → Rev 396

/branches/BR-0.4/basico/services/srv_annotations.py
151,6 → 151,15
return glob.glob(LPATH['ANNOTATIONS'] + '*.json')
 
 
def get_all_aids(self):
aids = []
fnames = self.get_all()
for fname in fnames:
aid = os.path.basename(fname)[:-5]
aids.append(aid)
return aids
 
 
def get_total(self):
return len(self.get_all())
 
252,6 → 261,16
return matches
 
 
def get_annotations_by_type(self, atype):
selected = set()
aids = self.get_all_aids()
for aid in aids:
this_type = self.get_metadata_value(aid, 'Type')
if this_type == atype:
selected.add(aid)
return selected
 
 
def finalize(self):
pass
 
/branches/BR-0.4/basico/services/srv_callbacks.py
441,12 → 441,13
bag = []
all_notes = []
sapnotes = []
 
dlbuffer = textview.get_buffer()
istart, iend = dlbuffer.get_bounds()
text = dlbuffer.get_text(istart, iend, False)
self.log.debug(text)
lines = text.replace(' ', ',')
lines = lines.replace('\n', ',')
self.log.debug(lines)
for sid in lines.split(','):
sid = sid.strip()
if len(sid) > 0:
493,7 → 494,7
 
dlbuffer.set_text('')
popover = self.srvgui.get_widget('gtk_popover_toolbutton_import')
self.gui_hide_popover(popover)
# ~ self.gui_hide_popover(popover)
if len(bag) > 0:
webdriver.close(driver)
 
/branches/BR-0.4/basico/widgets/wdg_visor_toolbar.py
188,7 → 188,7
# Import Annotation button
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
button.connect('clicked', self.clb_create_annotation)
# ~ button.connect('clicked', self.clb_create_annotation)
hbox = Gtk.HBox()
icon = self.srvicm.get_image_icon('basico-annotation')
label = Gtk.Label()
199,8 → 199,31
button.add(hbox)
box.pack_start(button, False, False, 3)
 
popoveran = self.srvgui.add_widget('gtk_popover_button_create_annotation', Gtk.Popover.new(button))
popoveran.set_position(Gtk.PositionType.LEFT)
button.connect('clicked', self.srvclb.gui_show_popover, popoveran)
 
# Import Annotation button
boxan = Gtk.VBox(spacing = 0, orientation="vertical")
boxan.set_property('margin', 3)
popoveran.add(boxan)
 
combobox = self.combobox_templates()
# ~ button = Gtk.Button()
# ~ button.set_relief(Gtk.ReliefStyle.NONE)
# ~ hboxtp = Gtk.HBox()
# ~ icontpl = self.srvicm.get_new_image_icon('basico-annotation-type-template', 24, 24)
# ~ label = Gtk.Label()
# ~ label.set_markup('<b>From template</b>')
# ~ label.set_xalign(0.0)
# ~ hboxtp.pack_start(icontpl, False, False, 3)
# ~ hboxtp.pack_start(label, True, True, 0)
# ~ button.add(hboxtp)
boxan.pack_start(combobox, False, False, 3)
 
# ~ widget_import = self.srvgui.add_widget('widget_import', ImportWidget(self.app))
# ~ boxan.pack_start(widget_import, False, False, 3)
 
# Import Attachment button
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
button.connect('clicked', self.clb_create_attachment)
236,6 → 259,7
self.srvstg = self.get_service('Settings')
self.srvdtb = self.get_service('DB')
self.srvuif = self.get_service("UIF")
self.srvant = self.get_service('Annotation')
 
 
def completion_match_func(self, completion, key, iter):
252,3 → 276,35
 
def clb_create_attachment(self, *args):
self.srvclb.gui_attachment_add()
 
 
def clb_template_changed(self, *args):
self.log.debug(args)
 
 
def combobox_templates(self, *args):
tpl_aids = self.srvant.get_annotations_by_type('Template')
self.log.debug(tpl_aids)
 
model = Gtk.ListStore(str, str)
first = model.append(['', '<b>Templates</b>'])
for aid in tpl_aids:
title = self.srvant.get_title(aid)
self.log.debug("AID(%s) - Title(%s)", aid, title)
model.append([aid, title])
 
templates = Gtk.ComboBox.new_with_model(model)
templates.set_active_iter(first)
templates.connect('changed', self.clb_template_changed)
 
renderer = Gtk.CellRendererText()
renderer.set_visible(False)
templates.pack_start(renderer, True)
templates.add_attribute(renderer, "text", 0)
 
renderer = Gtk.CellRendererText()
templates.pack_start(renderer, True)
templates.add_attribute(renderer, "markup", 1)
 
templates.show_all()
return templates