Beispiel #1
0
 def start_gui(self, db):
     from calibre.gui2.ui import Main
     main = Main(self.opts, gui_debug=self.gui_debug)
     if self.splash_screen is not None:
         self.splash_screen.showMessage(_('Initializing user interface...'))
     with gprefs:  # Only write gui.json after initialization is complete
         main.initialize(self.library_path, db, self.listener, self.actions)
     if self.splash_screen is not None:
         self.splash_screen.finish(main)
     if DEBUG:
         prints('Started up in %.2f seconds'%(time.time() -
             self.startup_time), 'with', len(db.data), 'books')
     add_filesystem_book = partial(main.iactions['Add Books'].add_filesystem_book, allow_device=False)
     sys.excepthook = main.unhandled_exception
     if len(self.args) > 1:
         files = [os.path.abspath(p) for p in self.args[1:] if not
                 os.path.isdir(p)]
         if len(files) < len(sys.argv[1:]):
             prints('Ignoring directories passed as command line arguments')
         if files:
             add_filesystem_book(files)
     for event in self.app.file_event_hook.events:
         add_filesystem_book(event)
     self.app.file_event_hook = add_filesystem_book
     self.main = main
Beispiel #2
0
 def start_gui(self, db):
     from calibre.gui2.ui import Main
     main = Main(self.opts, gui_debug=self.gui_debug)
     if self.splash_screen is not None:
         self.splash_screen.showMessage(_('Initializing user interface...'))
     with gprefs:  # Only write gui.json after initialization is complete
         main.initialize(self.library_path, db, self.listener, self.actions)
     if self.splash_screen is not None:
         self.splash_screen.finish(main)
     if DEBUG:
         prints(
             'Started up in %.2f seconds' %
             (time.time() - self.startup_time), 'with', len(db.data),
             'books')
     add_filesystem_book = partial(
         main.iactions['Add Books'].add_filesystem_book, allow_device=False)
     sys.excepthook = main.unhandled_exception
     if len(self.args) > 1:
         files = [
             os.path.abspath(p) for p in self.args[1:]
             if not os.path.isdir(p)
         ]
         if len(files) < len(sys.argv[1:]):
             prints('Ignoring directories passed as command line arguments')
         if files:
             add_filesystem_book(files)
     for event in self.app.file_event_hook.events:
         add_filesystem_book(event)
     self.app.file_event_hook = add_filesystem_book
     self.main = main
Beispiel #3
0
def init_gui():
    from calibre.gui2.ui import Main
    from calibre.gui2.main import option_parser
    from calibre.library import db
    parser = option_parser()
    opts, args = parser.parse_args([])
    actions = tuple(Main.create_application_menubar())
    db = db()
    gui = Main(opts)
    gui.initialize(db.library_path, db, actions, show_gui=False)
    return gui
Beispiel #4
0
def init_gui():
    from calibre.gui2.ui import Main
    from calibre.gui2.main import option_parser
    from calibre.library import db
    parser = option_parser()
    opts, args = parser.parse_args([])
    actions = tuple(Main.create_application_menubar())
    db = db()
    gui = Main(opts)
    gui.initialize(db.library_path, db, None, actions, show_gui=False)
    return gui