示例#1
0
    def __init__(self):
        '''
        the constructor
        '''
        logger.debug('SearchView::__init__')
        super(SearchView, self).__init__()
        filename = os.path.join(paths.lib_dir(), 'bauble.glade')
        self.widgets = utils.load_widgets(filename)
        self.view = editor.GenericEditorView(filename,
                                             root_widget_name='main_window')

        self.create_gui()

        import pictures_view
        pictures_view.floating_window = pictures_view.PicturesView(
            parent=self.widgets.search_h2pane)

        # we only need this for the timeout version of populate_results
        self.populate_callback_id = None

        # the context menu cache holds the context menus by type in the results
        # view so that we don't have to rebuild them every time
        self.context_menu_cache = {}
        self.infobox_cache = {}
        self.infobox = None

        # keep all the search results in the same session, this should
        # be cleared when we do a new search
        self.session = db.Session()
        self.add_notes_page_to_bottom_notebook()
示例#2
0
 def start(cls):
     # the presenter uses the view to interact with user then
     # performs the export, if this is the case.
     s = db.Session()
     filename = os.path.join(
         paths.lib_dir(), 'plugins', 'imex', 'select_export.glade')
     presenter = JSONExporter(view=editor.GenericEditorView(
         filename, root_widget_name='select_export_dialog'))
     presenter.start()  # interact && run
     presenter.cleanup()
     s.close()
示例#3
0
 def start(cls):
     """
     Start the JSON importer.  This tool will also reinitialize the
     plugins after importing.
     """
     s = db.Session()
     filename = os.path.join(paths.lib_dir(), 'plugins', 'imex',
                             'select_export.glade')
     presenter = JSONImporter(view=editor.GenericEditorView(
         filename, root_widget_name='select_import_dialog'))
     presenter.start()  # interact && run
     s.close()
示例#4
0
def edit_callback():
    session = db.Session()
    view = editor.GenericEditorView(os.path.join(paths.lib_dir(), 'plugins',
                                                 'plants',
                                                 'stored_queries.glade'),
                                    parent=None,
                                    root_widget_name='stqr_dialog')
    stored_queries = StoredQueriesModel()
    presenter = StoredQueriesPresenter(stored_queries,
                                       view,
                                       session=session,
                                       refresh_view=True)
    error_state = presenter.start()
    if error_state > 0:
        stored_queries.save()
        bauble.gui.get_view().update()
    session.close()
    return error_state
示例#5
0
 def __init__(self, *args, **kwargs):
     """
     If a class extends this View and provides its own __init__ it *must*
     call its parent (this) __init__
     """
     filename = kwargs.get('filename')
     if filename is not None:
         del kwargs['filename']
         root_widget_name = kwargs.get('root_widget_name')
         del kwargs['root_widget_name']
     super(View, self).__init__(*args, **kwargs)
     if filename is not None:
         from bauble import utils, editor
         self.widgets = utils.load_widgets(filename)
         self.view = editor.GenericEditorView(
             filename, root_widget_name=root_widget_name)
         root_widget = getattr(self.view.widgets, root_widget_name)
         widget = root_widget.get_children()[0]
         self.view.widgets.remove_parent(widget)
         self.add(widget)
     self.running_threads = []