Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 394 → Rev 395

/branches/BR-0.4/basico/services/srv_annotations.py
39,14 → 39,15
 
for filename in self.get_all():
metadata = self.get_metadata_from_file(filename)
try:
ts = metadata['Created']
except Exception as error:
# Fix annotation metadata: add 'Created' field
metadata['Created'] = metadata['Timestamp']
with open(filename, 'w') as fa:
json.dump(metadata, fa)
self.log.debug("Fixed annotation with AID: %s", metadata['AID'])
if len(metadata) > 0:
try:
ts = metadata['Created']
except Exception as error:
# Fix annotation metadata: add 'Created' field
metadata['Created'] = metadata['Timestamp']
with open(filename, 'w') as fa:
json.dump(metadata, fa)
self.log.debug("Fixed annotation with AID: %s", metadata['AID'])
 
 
def gen_aid(self, sid='0000000000'):
172,12 → 173,17
 
 
def get_metadata_from_file(self, filename=None):
metadata = []
if filename is not None:
with open(filename, 'r') as fa:
annotation = json.load(fa)
return annotation
try:
metadata = json.load(fa)
except Exception as error:
self.log.debug("Annotation: %s", filename)
self.log.error(error)
return metadata
else:
return None
return metadata
 
 
def get_metadata_value(self, aid, key):
/branches/BR-0.4/basico/services/srv_callbacks.py
983,7 → 983,7
self.log.warning("No files selected to attach")
 
 
def gui_attachment_add(self, button):
def gui_attachment_add(self, *args):
visor_attachemnts = self.srvgui.get_widget('visor_attachments')
visor_annotations = self.srvgui.get_widget('visor_annotations')
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
1021,6 → 1021,7
else:
self.log.warning("No files selected to attach")
 
 
def gui_attachment_show_filechooser(self):
filenames = None
parentwin = self.srvgui.get_window()
/branches/BR-0.4/basico/services/srv_uif.py
220,7 → 220,8
try:
treeiter = combobox.get_active_iter()
model = combobox.get_model()
return model[treeiter][col]
text = model[treeiter][col]
return text.strip()
except:
return ''
 
/branches/BR-0.4/basico/widgets/wdg_annot.py
648,8 → 648,10
annotation['Type'] = self.srvuif.get_combobox_text(a_wdg_type, 1)
annotation['Category'] = self.srvuif.get_combobox_text(a_wdg_category, 1)
annotation['Priority'] = self.srvuif.get_combobox_text(a_wdg_priority, 1)
annotation['Scope'] = a_wdg_scope.get_text()
annotation['Product'] = a_wdg_product.get_text()
scope = a_wdg_scope.get_text()
annotation['Scope'] = scope.strip()
product = a_wdg_product.get_text()
annotation['Product'] = product.strip()
annotation['Content'] = self.srvuif.get_textview_text(a_wdg_text)
annotation['Link'] = a_wdg_link.get_text()
annotation['LinkType'] = self.srvuif.get_combobox_text(a_wdg_link_type, 0)
/branches/BR-0.4/basico/widgets/wdg_visor_annotations.py
118,7 → 118,7
label.set_xalign(0.0)
model = Gtk.ListStore(str)
scope = Gtk.ComboBox.new_with_model(model)
signal = scope.connect('changed', self.scope_changed)
signal = scope.connect('changed', self.clb_scope_changed)
self.srvgui.add_signal('gtk_combobox_filter_scope', 'changed', signal)
self.srvgui.add_widget('gtk_combobox_filter_scope', scope)
renderer = Gtk.CellRendererText()
187,7 → 187,7
hbox_type = Gtk.HBox()
hbox_type.set_hexpand(False)
 
hbox_type.pack_start(icon, False, False, 3)
# ~ hbox_type.pack_start(icon, False, False, 3)
hbox_type.pack_start(label, False, False, 3)
button.add(hbox_type)
vbox_main.pack_start(button, False, False, 0)
401,7 → 401,7
self.renderer_scope = Gtk.CellRendererText()
self.renderer_scope.set_property('background', '#E3F1E3')
self.column_scope = Gtk.TreeViewColumn('Scope', self.renderer_scope, markup=6)
widget = get_column_header_widget('Category', 'basico-scope')
widget = get_column_header_widget('Scope', 'basico-scope')
self.column_scope.set_widget(widget)
self.column_scope.set_visible(True)
self.column_scope.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
610,6 → 610,8
iter_previous = model.iter_previous(iter_current)
if iter_previous:
selection.select_iter(iter_previous)
widget_annotation = self.srvgui.get_widget('widget_annotation')
widget_annotation.preview()
 
 
def row_next(self, *args):
622,6 → 624,8
path, col = self.treeview.get_cursor()
row = self.srvuif.tree_path_to_row(path)
self.treeview.scroll_to_cell(row, column=None, use_align=False, row_align=0.5, col_align=0)
widget_annotation = self.srvgui.get_widget('widget_annotation')
widget_annotation.preview()
 
 
def rows_toggled(self):
740,7 → 744,11
try:
with open(fname, 'r') as fa:
try:
annotation = json.load(fa)
try:
annotation = json.load(fa)
except Exception as error:
self.log.error("Annotation: %s", fname)
self.log.error(error)
# Get Scope
try:
scope = annotation['Scope']
1113,7 → 1121,7
GObject.signal_handler_unblock(cmb_product, signal)
 
 
def scope_changed(self, *args):
def clb_scope_changed(self, *args):
visible_filter = self.get_visible_filter()
visible_filter.refilter()
self.update_total_annotations_count()
/branches/BR-0.4/basico/widgets/wdg_visor_toolbar.py
29,36 → 29,35
self.toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
self.toolbar.set_property('margin-bottom', 0)
 
## Import button
tool = Gtk.ToolButton()
tool.set_icon_name('basico-add')
tool.set_tooltip_markup('<b>Download or find SAP Notes (if they were already downloaded)</b>')
popover = self.srvgui.add_widget('gtk_popover_toolbutton_import', Gtk.Popover.new(tool))
tool.connect('clicked', self.srvclb.gui_show_popover, popover)
self.toolbar.insert(tool, -1)
# ~ tool = Gtk.ToolButton()
# ~ tool.set_icon_name('basico-add')
# ~ tool.set_tooltip_markup('<b>Download or find SAP Notes (if they were already downloaded)</b>')
# ~ popover = self.srvgui.add_widget('gtk_popover_toolbutton_import', Gtk.Popover.new(tool))
# ~ tool.connect('clicked', self.srvclb.gui_show_popover, popover)
# ~ self.toolbar.insert(tool, -1)
 
## Popover body
box = Gtk.VBox(spacing = 0, orientation="vertical")
box.set_property('margin', 3)
widget_import = self.srvgui.add_widget('widget_import', ImportWidget(self.app))
box.pack_start(widget_import, True, True, 6)
popover.add(box)
# ~ ## Popover body
# ~ box = Gtk.VBox(spacing = 0, orientation="vertical")
# ~ box.set_property('margin', 3)
# ~ widget_import = self.srvgui.add_widget('widget_import', ImportWidget(self.app))
# ~ box.pack_start(widget_import, True, True, 6)
# ~ popover.add(box)
 
# Annotation button
tool = Gtk.ToolButton()
tool.set_icon_name('basico-annotation')
tool.set_tooltip_markup('<b>Create a new annotation (not linked to any SAP Note)</b>')
popover = self.srvgui.add_widget('gtk_popover_annotation', Gtk.Popover.new(tool))
tool.connect('clicked', self.clb_create_annotation)
self.toolbar.insert(tool, -1)
# ~ # Annotation button
# ~ tool = Gtk.ToolButton()
# ~ tool.set_icon_name('basico-annotation')
# ~ tool.set_tooltip_markup('<b>Create a new annotation (not linked to any SAP Note)</b>')
# ~ popover = self.srvgui.add_widget('gtk_popover_annotation', Gtk.Popover.new(tool))
# ~ tool.connect('clicked', self.clb_create_annotation)
# ~ self.toolbar.insert(tool, -1)
 
## Attachment button
tool = Gtk.ToolButton()
tool.set_icon_name('basico-attachment')
tool.set_tooltip_markup('<b>Attach any document to this annotation</b>')
popover = self.srvgui.add_widget('gtk_button_main_toolbar_attachment', Gtk.Popover.new(tool))
tool.connect('clicked', self.srvclb.gui_attachment_add)
self.toolbar.insert(tool, -1)
# ~ ## Attachment button
# ~ tool = Gtk.ToolButton()
# ~ tool.set_icon_name('basico-attachment')
# ~ tool.set_tooltip_markup('<b>Attach any document to this annotation</b>')
# ~ popover = self.srvgui.add_widget('gtk_button_main_toolbar_attachment', Gtk.Popover.new(tool))
# ~ tool.connect('clicked', self.srvclb.gui_attachment_add)
# ~ self.toolbar.insert(tool, -1)
 
## Filter entry
 
130,9 → 129,11
tool.add(hbox)
self.toolbar.insert(tool, -1)
 
# Separator
# ~ separator = Gtk.Separator(orientation = Gtk.Orientation.HORIZONTAL)
# ~ self.pack_start(separator, False, False, 3)
## Separator
tool = Gtk.SeparatorToolItem.new()
tool.set_draw(True)
tool.set_expand(False)
self.toolbar.insert(tool, -1)
 
# Fullscreen toggle button
# ~ tool = Gtk.ToolItem()
148,6 → 149,79
# ~ tool.set_tooltip_markup('<b>Fullscreen/Window mode</b>')
# ~ self.toolbar.insert(tool, -1)
 
## Import button
tool = Gtk.ToolButton()
tool.set_icon_name('basico-add')
tool.set_tooltip_markup('<b>Add new SAP Notes, annotations or attachments</b>')
popover = self.srvgui.add_widget('gtk_popover_toolbutton_add', Gtk.Popover.new(tool))
tool.connect('clicked', self.srvclb.gui_show_popover, popover)
self.toolbar.insert(tool, -1)
 
## Popover body
box = Gtk.VBox(spacing = 0, orientation="vertical")
box.set_property('margin', 3)
popover.add(box)
 
 
# Import SAP Notes button
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
hbox = Gtk.HBox()
icon = self.srvicm.get_image_icon('basico-sapnote')
label = Gtk.Label()
label.set_markup('<b>New SAP Note(s)</b>')
label.set_xalign(0.0)
hbox.pack_start(icon, False, False, 3)
hbox.pack_start(label, True, True, 0)
button.add(hbox)
box.pack_start(button, False, False, 3)
popoversn = self.srvgui.add_widget('gtk_popover_button_import_notes', Gtk.Popover.new(button))
popoversn.set_position(Gtk.PositionType.LEFT)
button.connect('clicked', self.srvclb.gui_show_popover, popoversn)
 
boxsn = Gtk.VBox(spacing = 0, orientation="vertical")
boxsn.set_property('margin', 3)
popoversn.add(boxsn)
widget_import = self.srvgui.add_widget('widget_import', ImportWidget(self.app))
boxsn.pack_start(widget_import, False, False, 3)
 
# Import Annotation button
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
button.connect('clicked', self.clb_create_annotation)
hbox = Gtk.HBox()
icon = self.srvicm.get_image_icon('basico-annotation')
label = Gtk.Label()
label.set_markup('<b>New annotation</b>')
label.set_xalign(0.0)
hbox.pack_start(icon, False, False, 3)
hbox.pack_start(label, True, True, 0)
button.add(hbox)
box.pack_start(button, False, False, 3)
 
 
# Import Annotation button
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
button.connect('clicked', self.clb_create_attachment)
hbox = Gtk.HBox()
icon = self.srvicm.get_image_icon('basico-attachment')
label = Gtk.Label()
label.set_markup('<b>New attachment(s)</b>')
label.set_xalign(0.0)
hbox.pack_start(icon, False, False, 3)
hbox.pack_start(label, True, True, 0)
button.add(hbox)
box.pack_start(button, False, False, 3)
# ~ ## Attachment button
# ~ tool = Gtk.ToolButton()
# ~ tool.set_icon_name('basico-attachment')
# ~ tool.set_tooltip_markup('<b>Attach any document to this annotation</b>')
# ~ popover = self.srvgui.add_widget('gtk_button_main_toolbar_attachment', Gtk.Popover.new(tool))
# ~ tool.connect('clicked', self.srvclb.gui_attachment_add)
# ~ self.toolbar.insert(tool, -1)
 
 
# Toolbar initial settings
self.set_visible(True)
self.set_no_show_all(False)
172,5 → 246,9
return False
 
 
def clb_create_annotation(self, button):
def clb_create_annotation(self, *args):
self.srvclb.action_annotation_create()
 
 
def clb_create_attachment(self, *args):
self.srvclb.gui_attachment_add()