Subversion Repositories basico

Rev

Rev 359 | Rev 362 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 359 Rev 361
Line 378... Line 378...
378
        self.selection.connect('changed', self.row_changed)
378
        self.selection.connect('changed', self.row_changed)
379
379
380
        # Set model (filtered and sorted)
380
        # Set model (filtered and sorted)
381
        self.sorted_model.set_sort_column_id(9, Gtk.SortType.ASCENDING)
381
        self.sorted_model.set_sort_column_id(9, Gtk.SortType.ASCENDING)
382
        self.treeview.set_model(self.sorted_model)
382
        self.treeview.set_model(self.sorted_model)
-
 
383
-
 
384
        # Other signals
-
 
385
        self.treeview.connect('row-activated', self.double_click)
383
386
384
        self.show_all()
387
        self.show_all()
385
388
386
389
387
    def sort_function(self, model, row1, row2, user_data):
390
    def sort_function(self, model, row1, row2, user_data):
Line 432... Line 435...
432
                component = model[treeiter][5]
435
                component = model[treeiter][5]
433
                if component == 'Annotation':
436
                if component == 'Annotation':
434
                    aid = model[treeiter][10]
437
                    aid = model[treeiter][10]
435
                    is_valid = self.srvant.is_valid(aid)
438
                    is_valid = self.srvant.is_valid(aid)
436
                    if is_valid:
439
                    if is_valid:
437
                        self.srvclb.action_annotation_edit(aid)
-
 
-
 
440
                        widget_annotation = self.srvgui.get_widget('widget_annotation')
-
 
441
                        widget_annotation.set_metadata_to_widget(aid)
-
 
442
                        # ~ self.srvclb.action_annotation_edit(aid)
438
                else:
443
                else:
439
                    aid = None
444
                    aid = None
440
                    self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
-
 
-
 
445
                    self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
441
        except Exception as error:
446
        except Exception as error:
442
            head = "Error reading annotation's contents"
-
 
443
            body = "<i>%s</i>\n\n" % error
-
 
444
            body += "As a workaround, a new file will be created"
-
 
445
            dialog = self.srvuif.message_dialog_error(head, body)
-
 
446
            self.log.debug(error)
-
 
447
            self.log.debug(self.get_traceback())
-
 
448
            dialog.run()
-
 
449
            dialog.destroy()
-
 
-
 
447
            pass
-
 
448
            # ~ head = "Error reading annotation's contents"
-
 
449
            # ~ body = "<i>%s</i>\n\n" % error
-
 
450
            # ~ body += "As a workaround, a new file will be created"
-
 
451
            # ~ dialog = self.srvuif.message_dialog_error(head, body)
-
 
452
            # ~ self.log.debug(error)
-
 
453
            # ~ self.log.debug(self.get_traceback())
-
 
454
            # ~ dialog.run()
-
 
455
            # ~ dialog.destroy()
450
            #FIXME: create an empty file for contents
456
            #FIXME: create an empty file for contents
451
457
452
458
453
    def toggle_checkbox(self, cell, path):
459
    def toggle_checkbox(self, cell, path):
454
        path = self.sorted_model.convert_path_to_child_path(Gtk.TreePath(path))
460
        path = self.sorted_model.convert_path_to_child_path(Gtk.TreePath(path))
Line 580... Line 586...
580
586
581
587
582
    def show_widgets(self):
588
    def show_widgets(self):
583
        self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
589
        self.srvuif.set_widget_visibility('gtk_label_total_notes', True)
584
590
-
 
591
-
 
592
    def double_click(self, treeview, row, col):
-
 
593
        try:
-
 
594
            selection = treeview.get_selection()
-
 
595
            model, treeiter = selection.get_selected()
-
 
596
            if treeiter is not None:
-
 
597
                component = model[treeiter][5]
-
 
598
                if component == 'Annotation':
-
 
599
                    aid = model[treeiter][10]
-
 
600
                    is_valid = self.srvant.is_valid(aid)
-
 
601
                    if is_valid:
-
 
602
                        fullscreen_annotation = self.srvgui.get_widget('gtk_togglebutton_maximize_annotation_widget')
-
 
603
                        fullscreen_annotation.set_active(True)
-
 
604
                        self.srvclb.action_annotation_edit(aid)
-
 
605
                else:
-
 
606
                    aid = None
-
 
607
                    self.srvuif.set_widget_visibility('gtk_vbox_container_annotations', False)
-
 
608
        except Exception as error:
-
 
609
            head = "Error reading annotation's contents"
-
 
610
            body = "<i>%s</i>\n\n" % error
-
 
611
            body += "As a workaround, a new file will be created"
-
 
612
            dialog = self.srvuif.message_dialog_error(head, body)
-
 
613
            self.log.debug(error)
-
 
614
            self.log.debug(self.get_traceback())
-
 
615
            dialog.run()
-
 
616
            dialog.destroy()
-
 
617
            # ~ #FIXME: create an empty file for contents
585
618
586
    def right_click(self, treeview, event, data=None):
619
    def right_click(self, treeview, event, data=None):
587
        if event.button == 3:
620
        if event.button == 3:
588
            rect = Gdk.Rectangle()
621
            rect = Gdk.Rectangle()
589
            rect.x = x = int(event.x)
622
            rect.x = x = int(event.x)
Line 599... Line 632...
599
                popover = self.srvgui.add_widget('gtk_popover_visor_row', Gtk.Popover.new(treeview))
632
                popover = self.srvgui.add_widget('gtk_popover_visor_row', Gtk.Popover.new(treeview))
600
                popover.set_position(Gtk.PositionType.TOP)
633
                popover.set_position(Gtk.PositionType.TOP)
601
                popover.set_pointing_to(rect)
634
                popover.set_pointing_to(rect)
602
                box = self.build_popover(aid, popover, component)
635
                box = self.build_popover(aid, popover, component)
603
                if box is not None:
636
                if box is not None:
-
 
637
                    vpaned = self.srvgui.get_widget('gtk_vpaned_visor')
-
 
638
                    visor_annotations = self.srvgui.get_widget('visor_annotations')
-
 
639
                    width, height = visor_annotations.get_size_request()
-
 
640
                    vpaned.set_position(1000)
604
                    popover.add(box)
641
                    popover.add(box)
605
                    self.srvclb.gui_show_popover(None, popover)
642
                    self.srvclb.gui_show_popover(None, popover)
-
 
643
                               
606
644
607
645
608
    def build_popover(self, aid, popover, component):
646
    def build_popover(self, aid, popover, component):
609
        sid = self.srvant.get_sid(aid)
647
        sid = self.srvant.get_sid(aid)
610
648