Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 393 → Rev 394

/branches/BR-0.4/basico/widgets/wdg_annot.py
306,12 → 306,12
self.container_body.add(stack_annotation)
 
# Add Annotation preview stack
preview = self.annotation_preview()
preview = self.widget_annotation_preview()
stack_annotation.add_titled(preview, "preview", "Preview annotation")
stack_annotation.child_set_property (preview, "icon-name", "basico-preview")
 
# Add Annotation editor stack
editor = self.annotation_editor()
editor = self.widget_annotation_editor()
stack_annotation.add_titled(editor, "editor", "Edit annotation")
stack_annotation.child_set_property (editor, "icon-name", "basico-drafts")
 
322,7 → 322,7
 
 
 
def set_visible_stack(self, stack_name='preview'):
def set_visible_stack(self, stack_name='editor'):
self.srvuif.set_widget_visibility('stack_annotation', True)
stack = self.srvgui.get_widget('stack_annotation')
stack.set_visible_child_name(stack_name)
347,16 → 347,17
self.srvuif.set_widget_visibility('gtk_entry_annotation_scope', True)
 
 
def annotation_preview(self):
def widget_annotation_preview(self):
browser = self.srvgui.add_widget('annotation_browser', BasicoBrowser(self.app))
return browser
 
def annotation_properties(self):
 
def widget_annotation_properties(self):
properties = self.srvgui.add_widget('annotation_properties', Gtk.Label('Properties'))
return properties
 
 
def annotation_editor(self):
def widget_annotation_editor(self):
vbox = Gtk.VBox()
 
# Hidden metadata
407,8 → 408,6
 
# Scope entry
hbox_scope = Gtk.HBox()
# ~ vbox_scope = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
 
completion = Gtk.EntryCompletion()
completion.set_match_func(self.completion_match_func)
completion_model = Gtk.ListStore(str)
578,6 → 577,7
a_wdg_category = self.srvgui.get_widget('gtk_combobox_annotation_category')
a_wdg_priority = self.srvgui.get_widget('gtk_combobox_annotation_priority')
a_wdg_scope = self.srvgui.get_widget('gtk_entry_annotation_scope')
a_wdg_product = self.srvgui.get_widget('gtk_entry_annotation_product')
a_wdg_human_timestamp = self.srvgui.get_widget('gtk_label_human_timestamp')
a_wdg_timestamp_created = self.srvgui.get_widget('gtk_label_timestamp_created')
a_wdg_text = self.srvgui.get_widget('gtk_textview_annotation_text')
606,6 → 606,11
except:
a_wdg_scope.set_text('')
 
try:
a_wdg_product.set_text(annotation['Product'])
except:
a_wdg_product.set_text('')
 
self.srvuif.set_textview_text(a_wdg_text, open(ANNOTATION_FILE_CONTENT).read())
a_wdg_link.set_text(annotation['Link'])
a_wdg_link_button.set_uri(annotation['Link'])
630,6 → 635,7
a_wdg_category = self.srvgui.get_widget('gtk_combobox_annotation_category')
a_wdg_priority = self.srvgui.get_widget('gtk_combobox_annotation_priority')
a_wdg_scope = self.srvgui.get_widget('gtk_entry_annotation_scope')
a_wdg_product = self.srvgui.get_widget('gtk_entry_annotation_product')
a_wdg_text = self.srvgui.get_widget('gtk_textview_annotation_text')
a_wdg_link = self.srvgui.get_widget('gtk_entry_annotation_link')
a_wdg_link_type = self.srvgui.get_widget('gtk_combobox_annotation_link_type')
643,6 → 649,7
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()
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)
660,11 → 667,13
a_wdg_link_button = self.srvgui.get_widget('gtk_link_button_annotation_link')
a_wdg_link_type = self.srvgui.get_widget('gtk_combobox_annotation_link_type')
a_wdg_scope = self.srvgui.get_widget('gtk_entry_annotation_scope')
a_wdg_product = self.srvgui.get_widget('gtk_entry_annotation_scope')
 
a_wdg_timestamp.set_text('')
a_wdg_timestamp_created.set_text('')
a_wdg_title.set_text('')
a_wdg_scope.set_text('')
a_wdg_product.set_text('')
textbuffer = a_wdg_text.get_buffer()
textbuffer.set_text('')
a_wdg_link.set_text('')
685,7 → 694,6
aid = self.get_aid_from_widget()
self.log.debug("Previewing aid: %s", aid)
if len(aid) == 0:
raise
return
 
atype = self.srvant.get_metadata_value(aid, 'Type')
/branches/BR-0.4/basico/widgets/wdg_visor_annotations.py
108,11 → 108,11
return button
 
# Separator
separator = Gtk.Separator()
vbox_main.pack_start(separator, False, False, 6)
# ~ separator = Gtk.Separator()
# ~ vbox_main.pack_start(separator, False, False, 6)
 
# Scope filter
hbox_scope = Gtk.HBox()
hbox_scope = Gtk.VBox()
label = Gtk.Label()
label.set_markup("<big><b>Scope </b></big>")
label.set_xalign(0.0)
124,21 → 124,26
renderer = Gtk.CellRendererText()
scope.pack_start(renderer, True)
scope.add_attribute(renderer, "markup", 0)
hbox_scope.pack_start(label, False, False, 0)
# ~ hbox_scope.pack_start(label, False, False, 0)
hbox_scope.pack_start(scope, True, True, 0)
vbox_main.pack_start(hbox_scope, False, False, 6)
 
# Product combobox
# Product filter
hbox_product = Gtk.VBox()
label = Gtk.Label()
label.set_markup("<big><b>Product </b></big>")
label.set_xalign(0.0)
model = Gtk.ListStore(str)
 
product = Gtk.ComboBox.new_with_model(model)
signal = product.connect('changed', self.product_changed)
self.srvgui.add_signal('gtk_combobox_filter_product', 'changed', signal)
self.srvgui.add_widget('gtk_combobox_filter_product', product)
renderer = Gtk.CellRendererText()
product.pack_start(renderer, True)
product.add_attribute(renderer, "markup", 0)
hbox = Gtk.HBox()
hbox.pack_start(product, True, True, 0)
vbox_main.pack_start(hbox, False, False, 6)
# ~ hbox_product.pack_start(label, False, False, 0)
hbox_product.pack_start(product, True, True, 0)
vbox_main.pack_start(hbox_product, False, False, 6)
 
hbox_main = Gtk.HBox()
hbox_main.set_homogeneous(True)
145,21 → 150,21
vbox_main.pack_start(hbox_main, False, False, 0)
 
# Separator
separator = Gtk.Separator()
vbox_main.pack_start(separator, False, False, 6)
# ~ separator = Gtk.Separator()
# ~ vbox_main.pack_start(separator, False, False, 6)
 
# Categories
button = self.srvgui.add_widget('gtk_togglebutton_categories', Gtk.ToggleButton())
button.set_relief(Gtk.ReliefStyle.NONE)
icon = self.srvicm.get_image_icon('basico-category', 48, 48)
button.set_relief(Gtk.ReliefStyle.NORMAL)
icon = self.srvicm.get_image_icon('basico-category', 24, 24)
label = Gtk.Label('')
label.set_markup('<big><b>Categories</b></big>')
hbox_cat = Gtk.HBox()
hbox_cat.set_hexpand(True)
hbox_cat.pack_start(icon, False, False, 3)
hbox_cat.set_hexpand(False)
# ~ hbox_cat.pack_start(icon, False, False, 3)
hbox_cat.pack_start(label, False, False, 3)
button.add(hbox_cat)
hbox_main.pack_start(button, True, True, 6)
vbox_main.pack_start(button, False, False, 6)
 
revealer = self.srvgui.add_widget('gtk_revealer_annotations_categories', Gtk.Revealer())
vbox_revealer = Gtk.VBox()
171,21 → 176,21
vbox_revealer.pack_start(button, False, False, 2)
 
revealer.add(vbox_revealer)
vbox_main.pack_start(revealer, False, False, 6)
vbox_main.pack_start(revealer, False, False, 3)
 
# Types
button = self.srvgui.add_widget('gtk_togglebutton_types', Gtk.ToggleButton())
button.set_relief(Gtk.ReliefStyle.NONE)
icon = self.srvicm.get_image_icon('basico-type', 48, 48)
button.set_relief(Gtk.ReliefStyle.NORMAL)
icon = self.srvicm.get_image_icon('basico-type', 24, 24)
label = Gtk.Label('')
label.set_markup('<big><b>Types</b></big>')
hbox_type = Gtk.HBox()
hbox_type.set_hexpand(True)
hbox_type.set_hexpand(False)
 
hbox_type.pack_start(icon, False, False, 3)
hbox_type.pack_start(label, False, False, 3)
button.add(hbox_type)
hbox_main.pack_start(button, True, True, 0)
vbox_main.pack_start(button, False, False, 0)
 
revealer = self.srvgui.add_widget('gtk_revealer_annotations_types', Gtk.Revealer())
vbox_revealer = Gtk.VBox()
310,7 → 315,7
hbox.show_all()
return hbox
 
# SAP Note key
# Annotation key
self.renderer_key = Gtk.CellRendererText()
self.column_key = Gtk.TreeViewColumn('Key', self.renderer_key, text=0)
self.column_key.set_visible(False)
319,7 → 324,7
self.column_key.set_sort_indicator(True)
self.treeview.append_column(self.column_key)
 
# Icon
# Annotation Icon
self.renderer_icon = Gtk.CellRendererPixbuf()
self.renderer_icon.set_alignment(0.0, 0.5)
self.column_icon = Gtk.TreeViewColumn('', self.renderer_icon, pixbuf=1)
332,7 → 337,7
self.column_icon.set_sort_column_id(7)
self.treeview.append_column(self.column_icon)
 
# SAP Note Checkbox
# Annotation Checkbox
self.renderer_checkbox = Gtk.CellRendererToggle()
self.renderer_checkbox.connect("toggled", self.toggle_checkbox)
self.column_checkbox = Gtk.TreeViewColumn('', self.renderer_checkbox, active=2)
347,7 → 352,7
self.column_checkbox.set_property('spacing', 50)
self.treeview.append_column(self.column_checkbox)
 
# SAP Note Id
# Annotation Id
self.renderer_sid = Gtk.CellRendererText()
self.renderer_sid.set_property('xalign', 1.0)
self.renderer_sid.set_property('height', 36)
363,7 → 368,7
self.column_sid.set_sort_column_id(0)
self.treeview.append_column(self.column_sid)
 
# SAP Note title
# Annotation title
self.renderer_title = Gtk.CellRendererText()
self.renderer_title.set_property('background', '#FFFEEA')
self.renderer_title.set_property('ellipsize', Pango.EllipsizeMode.MIDDLE)
378,7 → 383,7
self.column_title.set_sort_column_id(4)
self.treeview.append_column(self.column_title)
 
# SAP Note Component
# Annotation Component
self.renderer_component = Gtk.CellRendererText()
self.renderer_component.set_property('background', '#E3E3F0')
self.column_component = Gtk.TreeViewColumn('Component', self.renderer_component, markup=5)
395,8 → 400,8
# Annotation Scope
self.renderer_scope = Gtk.CellRendererText()
self.renderer_scope.set_property('background', '#E3F1E3')
self.column_scope = Gtk.TreeViewColumn('Category', self.renderer_scope, markup=6)
widget = get_column_header_widget('Category', 'basico-category')
self.column_scope = Gtk.TreeViewColumn('Scope', self.renderer_scope, markup=6)
widget = get_column_header_widget('Category', 'basico-scope')
self.column_scope.set_widget(widget)
self.column_scope.set_visible(True)
self.column_scope.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
406,11 → 411,12
self.column_scope.set_sort_column_id(6)
self.treeview.append_column(self.column_scope)
 
# SAP Note Type
# Annotation Product
self.renderer_type = Gtk.CellRendererText()
self.renderer_type.set_property('background', '#DADAFF')
self.renderer_type.set_property('ellipsize', Pango.EllipsizeMode.MIDDLE)
self.column_type = Gtk.TreeViewColumn('Type', self.renderer_type, markup=7)
widget = get_column_header_widget('Type', 'basico-type')
widget = get_column_header_widget('Product', 'basico-type')
self.column_type.set_widget(widget)
self.column_type.set_visible(True)
self.column_type.set_expand(False)
420,7 → 426,7
self.column_type.set_sort_column_id(7)
self.treeview.append_column(self.column_type)
 
# SAP Note Priority
# Annotation Priority
self.renderer_priority = Gtk.CellRendererText()
self.renderer_priority.set_property('background', '#e4f1f1')
self.column_priority = Gtk.TreeViewColumn('Priority', self.renderer_priority, markup=8)
551,19 → 557,32
text = self.srvutl.clean_html(entry.get_text())
title = model.get(itr, 4)[0]
scope = model.get(itr, 6)[0]
product = model.get(itr, 7)[0]
match = text.upper() in title.upper()
 
cmb_scope = self.srvgui.get_widget('gtk_combobox_filter_scope')
scope_filter = self.srvuif.get_combobox_text(cmb_scope, 0)
if scope_filter == scope or scope_filter == 'All' or scope_filter == '':
scope_filter = self.srvutl.clean_html(self.srvuif.get_combobox_text(cmb_scope, 0))
cmb_product = self.srvgui.get_widget('gtk_combobox_filter_product')
product_filter = self.srvutl.clean_html(self.srvuif.get_combobox_text(cmb_product, 0))
 
 
if scope_filter in [scope, 'All', '', 'Scope']:
match = match and True
elif scope_filter == 'None' and scope == '':
match = True
else:
match = match and False
 
if product_filter in [product, 'All', '', 'Product']:
match = match and True
elif product_filter == 'None' and product == '':
match = True
else:
match = match and False
 
return match
 
 
 
def update_total_annotations_count(self):
statusbar = self.srvgui.get_widget('widget_statusbar')
lblnotescount = self.srvgui.get_widget('gtk_label_total_notes')
613,10 → 632,8
checked = self.sorted_model.get(itr, 2)[0]
if checked:
selected.append(str(aid))
self.sorted_model.foreach(get_selected_sapnotes)
 
self.sorted_model.foreach(get_selected_sapnotes)
for aid in selected:
self.log.debug(self.srvant.get_title(aid))
return selected
 
 
631,7 → 648,7
if is_valid:
widget_annotation = self.srvgui.get_widget('widget_annotation')
widget_annotation.set_metadata_to_widget(aid)
widget_annotation.preview()
# ~ widget_annotation.preview()
else:
aid = None
# ~ self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
724,11 → 741,18
with open(fname, 'r') as fa:
try:
annotation = json.load(fa)
# Get Scopes
# Get Scope
try:
scope = annotation['Scope']
except:
scope = ''
 
# Get Product
try:
product = annotation['Product']
except:
product = ''
 
# ~ self.log.debug("Annotation: %s", annotation['Title'])
category = annotation['Category']
atype = annotation['Type']
765,7 → 789,7
title,
annotation['Component'],
scope,
annotation['Type'],
product,
annotation['Priority'],
self.srvutl.fuzzy_date_from_timestamp(annotation['Timestamp']),
annotation['Timestamp'],
987,29 → 1011,119
category.set_active(True)
 
 
# ~ def update_panel_values(self):
# ~ scopes = set()
# ~ products = set()
 
# ~ def get_values(model, path, itr):
# ~ scope = self.sorted_model.get(itr, 6)[0]
# ~ product = self.sorted_model.get(itr, 7)[0]
# ~ scopes.add(scope)
# ~ products.add(product)
# ~ self.sorted_model.foreach(get_values)
 
# ~ # Update scope combo
# ~ cmb_scope = self.srvgui.get_widget('gtk_combobox_filter_scope')
# ~ signal = self.srvgui.get_signal('gtk_combobox_filter_scope', 'changed')
# ~ GObject.signal_handler_block(cmb_scope, signal)
# ~ model = cmb_scope.get_model()
# ~ model.clear()
# ~ first = model.append(['<big><b>Scope</b></big>'])
# ~ model.append(['All'])
# ~ model.append(['None'])
# ~ cmb_scope.set_active_iter(first)
# ~ lscopes = list(scopes)
# ~ lscopes.sort()
# ~ for item in lscopes:
# ~ if len(item) > 0:
# ~ model.append([item])
# ~ GObject.signal_handler_unblock(cmb_scope, signal)
 
# ~ # Update product combo
# ~ cmb_product = self.srvgui.get_widget('gtk_combobox_filter_product')
# ~ signal = self.srvgui.get_signal('gtk_combobox_filter_product', 'changed')
# ~ GObject.signal_handler_block(cmb_product, signal)
# ~ model = cmb_product.get_model()
# ~ model.clear()
# ~ first = model.append(['<big><b>Product</b></big>'])
# ~ model.append(['All'])
# ~ model.append(['None'])
# ~ cmb_product.set_active_iter(first)
# ~ lproducts = list(products)
# ~ lproducts.sort()
# ~ for item in lproducts:
# ~ if len(item) > 0:
# ~ model.append([item])
# ~ GObject.signal_handler_unblock(cmb_product, signal)
 
 
def update_panel_values(self):
self.update_scopes()
self.update_products()
 
def update_scopes(self):
scopes = set()
 
def get_values(model, path, itr):
scope = self.sorted_model.get(itr, 6)[0]
scopes.add(scope)
self.sorted_model.foreach(get_values)
 
# Update scope combo
cmb_scope = self.srvgui.get_widget('gtk_combobox_filter_scope')
signal = self.srvgui.get_signal('gtk_combobox_filter_scope', 'changed')
GObject.signal_handler_block(cmb_scope, signal)
model = cmb_scope.get_model()
model.clear()
first = model.append(['All'])
first = model.append(['<big><b>Scope</b></big>'])
model.append(['All'])
model.append(['None'])
cmb_scope.set_active_iter(first)
lscopes = list(scopes)
lscopes.sort()
for item in lscopes:
if len(item) > 0:
model.append([item])
cmb_scope.set_active_iter(first)
GObject.signal_handler_unblock(cmb_scope, signal)
 
 
def update_products(self):
products = set()
 
def get_values(model, path, itr):
product = self.sorted_model.get(itr, 7)[0]
products.add(product)
self.sorted_model.foreach(get_values)
 
# Update product combo
cmb_product = self.srvgui.get_widget('gtk_combobox_filter_product')
signal = self.srvgui.get_signal('gtk_combobox_filter_product', 'changed')
GObject.signal_handler_block(cmb_product, signal)
model = cmb_product.get_model()
model.clear()
first = model.append(['<big><b>Product</b></big>'])
model.append(['All'])
model.append(['None'])
cmb_product.set_active_iter(first)
lproducts = list(products)
lproducts.sort()
for item in lproducts:
if len(item) > 0:
model.append([item])
GObject.signal_handler_unblock(cmb_product, signal)
 
 
def scope_changed(self, *args):
visible_filter = self.get_visible_filter()
visible_filter.refilter()
self.update_total_annotations_count()
self.update_products()
 
 
def product_changed(self, *args):
visible_filter = self.get_visible_filter()
visible_filter.refilter()
self.update_total_annotations_count()
self.update_scopes()