602
624
#Position to render text
603
625
cairo_drawing_context.move_to(75,45)
604
626
PangoCairo.show_layout(cairo_drawing_context,pango_text_layout)
629
def show_report(self, text, results):
631
Display results report
634
self._notebook.set_current_page(1)
636
# Create treeview to display test cases results
637
# in a tree hierarchy
638
COLUMN_NAME, COLUMN_RESULT, RESULT_COLOR = range(3)
639
treestore = Gtk.TreeStore(str, str, str)
640
treeview = Gtk.TreeView()
641
treeview.set_model(treestore)
642
treeview.set_headers_visible(False)
645
cell = Gtk.CellRendererText()
646
col = Gtk.TreeViewColumn(None, cell, text=COLUMN_NAME)
647
treeview.append_column(col)
649
col = Gtk.TreeViewColumn(None, cell,
651
foreground=RESULT_COLOR)
652
treeview.append_column(col)
654
status_color_table = {'pass': 'green',
658
def set_results(results, parent=None):
659
for name, data in sorted(results.iteritems(),
661
is_suite = all(issubclass(type(value), dict)
662
for value in data.itervalues())
665
iterator = treestore.append(parent, [name, '', None])
666
set_results(data, iterator)
668
status = data['status']
669
status_color = status_color_table.get(status)
670
treestore.append(parent, [name, status, status_color])
674
vbox = self._get_widget("vbox_options_list")
675
vbox.pack_start(treeview, False, False, 0)
677
self._set_hyper_text_view("hyper_text_view_options", text)
680
def create_button(label, callback):
681
button = Gtk.Button(label)
682
button.connect("clicked", callback)
685
button_data = ((_("Expand All"),
686
lambda button: treeview.expand_all()),
688
lambda button: treeview.collapse_all()),
690
buttons = [create_button(label, callback)
691
for label, callback in button_data]
693
with self._add_temporary_buttons(buttons):
696
vbox.remove(treeview)
699
def show_bugs(self, reactor, interface):
703
# Create a new page to handle the bug report
704
vbox_additional_bugs = Gtk.VBox()
706
frame1 = Gtk.Frame(label=None)
707
frame1.set_shadow_type(Gtk.ShadowType.NONE)
708
label1 = Gtk.Label("The following bugs have been recorded:")
709
label1.set_alignment(0, 0)
711
vbox_additional_bugs.pack_start(frame1, False, False, 0)
715
sc1 = Gtk.ScrolledWindow()
716
sc1.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS)
718
vbox_additional_bugs.pack_start(sc1, True, True, 0)
720
frame2 = Gtk.Frame(label=None)
721
frame2.set_shadow_type(Gtk.ShadowType.NONE)
722
label2 = Gtk.Label("Enter below additional bugs id you want"
723
" to link to this report then Refresh")
724
label2.set_alignment(0, 0)
726
vbox_additional_bugs.pack_start(frame2, False, False, 0)
730
textview = Gtk.TextView()
733
sc2 = Gtk.ScrolledWindow()
734
sc2.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS)
736
sc2.add_with_viewport(textview)
737
vbox_additional_bugs.pack_end(sc2, False, False, 0)
739
vbox_additional_bugs.show()
741
# Create a liststore with string columns
742
liststore = Gtk.ListStore(str, str, str)
744
# Create a view for the liststore
745
listview = Gtk.TreeView()
746
listview.set_model(liststore)
749
# Create CellRenderers to render Text cells
750
cell1 = Gtk.CellRendererText()
751
cell2 = Gtk.CellRendererText()
752
cell3 = Gtk.CellRendererText()
755
tvcolumn1 = Gtk.TreeViewColumn('Id')
756
tvcolumn2 = Gtk.TreeViewColumn('Headline')
757
tvcolumn3 = Gtk.TreeViewColumn('Test')
760
def liststore_update():
762
for id, data in self.bugs.iteritems():
763
test_name_pattern = re.compile(
764
r'CheckboxTest:\s+(?P<test_name>.*?)\n')
765
match = test_name_pattern.search(data['messages'])
766
impacted_test = match.group('test_name') if match else ''
767
liststore.append([id, data['title'], impacted_test])
769
# Fill the liststore with recorded bugs
772
# Add columns to the Treeview
773
listview.append_column(tvcolumn1)
774
listview.append_column(tvcolumn2)
775
listview.append_column(tvcolumn3)
777
tvcolumn1.pack_start(cell1, False)
778
tvcolumn2.pack_start(cell2, False)
779
tvcolumn3.pack_start(cell3, False)
780
tvcolumn1.add_attribute(cell1, "text", 0)
781
tvcolumn2.add_attribute(cell2, "text", 1)
782
tvcolumn3.add_attribute(cell3, "text", 2)
784
# Allow sorting for each column
785
tvcolumn1.set_sort_column_id(0)
786
tvcolumn2.set_sort_column_id(1)
787
tvcolumn3.set_sort_column_id(2)
789
sc1.add_with_viewport(listview)
790
self._notebook.append_page(vbox_additional_bugs, None)
791
self._notebook.set_current_page(4)
794
def create_button(label, callback):
795
button = Gtk.Button(label)
796
button.connect("clicked", callback)
799
# Callback to enter a new bug
801
from checkbox_oem import bug
802
factory = bug.GTKBugReportingAssistant
803
assistant = factory()
805
if hasattr(assistant, 'bug'):
807
reactor.fire("query-bugs", interface, [bug.id])
810
# Callback to refresh the bug list
811
def refresh_bug_list():
812
textbuffer = textview.get_buffer()
813
(start, end) = textbuffer.get_bounds()
814
text = textbuffer.get_text(start, end, False)
815
bug_pattern = re.compile(r'\b\d+\b')
816
bugs_id = bug_pattern.findall(text)
818
reactor.fire("query-bugs", interface, bugs_id)
821
button_data = ((_("New Bug"),
822
lambda button: new_bug()),
824
lambda button: refresh_bug_list()),
827
buttons = [create_button(label, callback)
828
for label, callback in button_data]
830
with self._add_temporary_buttons(buttons):