示例#1
0
 def view_media(self, obj):
     """
     Launch external viewers for the selected objects.
     """
     for handle in self.selected_handles():
         ref_obj = self.dbstate.db.get_object_from_handle(handle)
         mpath = Utils.media_path_full(self.dbstate.db, ref_obj.get_path())
         open_file_with_default_application(mpath)
示例#2
0
 def open_containing_folder(self, obj):
     """
     Launch external viewers for the selected objects.
     """
     for handle in self.selected_handles():
         ref_obj = self.dbstate.db.get_object_from_handle(handle)
         mpath = Utils.media_path_full(self.dbstate.db, ref_obj.get_path())
         if mpath:
             mfolder, mfile = os.path.split(mpath)
             open_file_with_default_application(mfolder)
示例#3
0
 def __edit(self, obj, list_obj, id_col):
     """ Callback function from the "Load" button
     """
     selection = list_obj.get_selection()
     model, node = selection.get_selected()
     if not node:
         return
     id = model.get_value(node, id_col)
     pdata = self.__preg.get_plugin(id)
     if pdata.fpath and pdata.fname:
         open_file_with_default_application(
             os.path.join(pdata.fpath, pdata.fname))
示例#4
0
 def display_image(self, widget, event):
     """
     Display the image with the default external viewer.
     """
     if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
         open_file_with_default_application(self.full_path)
示例#5
0
def report(dbstate, uistate, person, report_class, options_class,
           trans_name, name, category, require_active):
    """
    report - task starts the report. The plugin system requires that the
    task be in the format of task that takes a database and a person as
    its arguments.
    """

    if require_active and not person:
        ErrorDialog(
            _('Active person has not been set'),
            _('You must select an active person for this report to work '
              'properly.'))
        return

    if category == CATEGORY_TEXT:
        from _textreportdialog import TextReportDialog
        dialog_class = TextReportDialog
    elif category == CATEGORY_DRAW:
        from _drawreportdialog import DrawReportDialog
        dialog_class = DrawReportDialog
    elif category == CATEGORY_GRAPHVIZ:
        from _graphvizreportdialog import GraphvizReportDialog
        dialog_class = GraphvizReportDialog
    elif category == CATEGORY_WEB:
        from _webreportdialog import WebReportDialog
        dialog_class = WebReportDialog
    elif category in (CATEGORY_BOOK, CATEGORY_CODE):
        try:
            report_class(dbstate, uistate)
        except Errors.WindowActiveError:
            pass
        return        
    else:
        dialog_class = ReportDialog

    dialog = dialog_class(dbstate, uistate, options_class, name, trans_name)

    while True:
        response = dialog.window.run()
        if response == gtk.RESPONSE_OK:
            dialog.close()
            try:
                user = User()
                MyReport = report_class(dialog.db, dialog.options, user)
                MyReport.doc.init()
                MyReport.begin_report()
                MyReport.write_report()
                MyReport.end_report()

                # Web reports do not have a target frame      
                # The GtkPrint generator can not be "opened"
                if hasattr(dialog, "open_with_app")                        and \
                   dialog.open_with_app.get_property('sensitive') == True  and \
                   dialog.open_with_app.get_active():
                    out_file = dialog.options.get_output()
                    open_file_with_default_application(out_file)
                
            except Errors.FilterError, msg:
                (m1, m2) = msg.messages()
                ErrorDialog(m1, m2)
            except IOError, msg:
                ErrorDialog(_("Report could not be created"), str(msg))
            except Errors.ReportError, msg:
                (m1, m2) = msg.messages()
                ErrorDialog(m1, m2)
示例#6
0
 def button_press_event(self, obj, event):
     if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
         photo_path = Utils.media_path_full(self.db, self.source.get_path())
         open_file_with_default_application(photo_path)