Exemple #1
0
    def rebuild_menus(self):
        ''' Builds the UI menus '''
        print('Rebuilding menus')
        m = self.menu
        m.clear()
        self.actions_unique_map = {}

        if False and prefs['username']=='guest' and prefs['password']=='guest':
            foo = True
        else:
            self.add_new_menu_item = create_menu_action_unique(self, m, _('&Add to Casanova') + '...', None, shortcut=False, triggered=self.add_book)
            self.casanova_book_submenu = m.addMenu(get_icon('images/link.png'), 'Linked text')
            self.create_menu_item_ex(self.casanova_book_submenu, 'Refresh metadata',
                    'images/update.png', 'Gets any updates to the metadata for this text from the server',
                    triggered=self.refresh_metadata)
            self.create_menu_item_ex(self.casanova_book_submenu, 'Upload metadata',
                    'images/commit.png', 'Send your metadata changes for this text to the server',
                    triggered=self.upload_metadata)
            self.casanova_book_submenu.addSeparator()
            self.create_menu_item_ex(self.casanova_book_submenu, 'Download',
                    'images/download.png', 'Download a file format from the Casanova server',
                    triggered=self.download_format)
            m.addSeparator()
            self.casanova_issue_submenu = m.addMenu(get_icon('images/link.png'), 'Get metadata')
            self.create_menu_item_ex(self.casanova_issue_submenu, 'Update issues',
                    'images/refresh.png', 'Get updates to issues from the Casanova server',
                    triggered=self.update_issues)
            self.author_menu_item = self.create_menu_item_ex(self.casanova_issue_submenu, 'Get all by author',
                    'images/download.png', 'Get metadata for all texts by this author',
                    triggered=self.update_author)
            self.create_menu_item_ex(self.casanova_issue_submenu, 'Search',
                    'images/download.png', 'Search Casanova titles and authors',
                    triggered=self.search)

        m.addSeparator()
        create_menu_action_unique(self, m, _('&Settings') + '...', None, shortcut=False, triggered=self.show_configuration)
        # Before we finalize, make sure we delete any actions for menus that are no longer displayed
        for menu_id, unique_name in self.old_actions_unique_map.iteritems():
            if menu_id not in self.actions_unique_map:
                self.gui.keyboard.unregister_shortcut(unique_name)
        self.old_actions_unique_map = self.actions_unique_map
        self.gui.keyboard.finalize()

        from calibre.gui2 import gprefs
        
        if self.name not in gprefs['action-layout-context-menu']:
            gprefs['action-layout-context-menu'] += (self.name, )
        if self.name not in gprefs['action-layout-toolbar']:
            gprefs['action-layout-toolbar'] += (self.name, )
        
        #gprefs['action-layout-context-menu'] += ('AAAARG', )
        #gprefs['action-layout-toolbar'] += ('AAAARG', )
        #print(gprefs['action-layout-toolbar'])
        # force add our menu into the gui toolbar
        #print(self.gui.tags_view.context_menu)
        #print(gprefs['action-layout-context-menu'])
        for x in (self.gui.preferences_action, self.qaction):
            x.triggered.connect(self.show_configuration)
Exemple #2
0
 def create_menu_item_ex(self, parent_menu, menu_text, image=None, tooltip=None,
                        shortcut=None, triggered=None, is_checked=None, shortcut_name=None,
                        unique_name=None):
     ac = create_menu_action_unique(self, parent_menu, menu_text, image, tooltip,
                                    shortcut, triggered, is_checked, shortcut_name, unique_name)
     self.actions_unique_map[ac.calibre_shortcut_unique_name] = ac.calibre_shortcut_unique_name
     return ac