示例#1
0
    def navigation_actions(self):
        """
        Define the navigation menu actions.
        """
        # add the Forward action group to handle the Forward button
        self.fwd_action = ActionGroup(name=self.title + '/Forward')
        self.fwd_action.add_actions([
            ('Forward', 'go-next', _("_Forward"),
             "%sRight" % mod_key(), _("Go to the next object in the history"),
             self.fwd_clicked)
            ])

        # add the Backward action group to handle the Forward button
        self.back_action = ActionGroup(name=self.title + '/Backward')
        self.back_action.add_actions([
            ('Back', 'go-previous', _("_Back"),
             "%sLeft" % mod_key(), _("Go to the previous object in the history"),
             self.back_clicked)
            ])

        self._add_action('HomePerson', 'go-home', _("_Home"),
                         accel="%sHome" % mod_key(),
                         tip=_("Go to the default person"), callback=self.home)

        self.other_action = ActionGroup(name=self.title + '/PersonOther')
        self.other_action.add_actions([
                ('SetActive', 'go-home', _("Set _Home Person"), None,
                 None, self.set_default_person),
                ])

        self._add_action_group(self.back_action)
        self._add_action_group(self.fwd_action)
        self._add_action_group(self.other_action)
示例#2
0
    def update_mru_menu(self, items, update_menu=True):
        """
        Builds the UI and action group for the MRU list.
        """
        menuitem = '''        <item>
              <attribute name="action">win.%s%02d</attribute>
              <attribute name="label" translatable="yes">%s</attribute>
            </item>
            '''
        menus = ''
        self.mru_disable()
        nav_type = self.navigation_type()
        hobj = self.get_history()
        menu_len = min(len(items) - 1, MRU_SIZE)

        for index in range(0, menu_len):
            name, obj = navigation_label(self.dbstate.db, nav_type,
                                         items[index])
            menus += menuitem % (nav_type, index, html.escape(name))
        self.mru_ui = [MRU_TOP + menus + MRU_BTM]

        mitems = items[-MRU_SIZE - 1:-1] # Ignore current handle
        mitems.reverse()
        data = []
        for index, handle in enumerate(mitems):
            data.append(('%s%02d'%(nav_type, index),
                         make_callback(hobj.push, handle),
                         "%s%d" % (mod_key(), index)))

        self.mru_action = ActionGroup(name=self.title + '/MRU')
        self.mru_action.add_actions(data)
        self.mru_enable(update_menu)
示例#3
0
    def update_mru_menu(self, items):
        """
        Builds the UI and action group for the MRU list.
        """
        self.mru_disable()
        nav_type = self.navigation_type()
        hobj = self.get_history()
        menu_len = min(len(items) - 1, MRU_SIZE)

        entry = '<menuitem action="%s%02d"/>'
        data = [entry % (nav_type, index) for index in range(0, menu_len)]
        self.mru_ui = "".join(MRU_TOP) + "".join(data) + "".join(MRU_BTM)

        mitems = items[-MRU_SIZE - 1:-1] # Ignore current handle
        mitems.reverse()
        data = []
        for index, handle in enumerate(mitems):
            name, obj = navigation_label(self.dbstate.db, nav_type, handle)
            data.append(('%s%02d'%(nav_type, index), None,  name,
                         "%s%d" % (mod_key(), index), None,
                         make_callback(hobj.push, handle)))

        self.mru_action = ActionGroup(name=self.title + '/MRU')
        self.mru_action.add_actions(data)
        self.mru_enable()
    def update_mru_menu(self, items, update_menu=True):
        """
        Builds the UI and action group for the MRU list.
        """
        menuitem = '''        <item>
              <attribute name="action">win.%s%02d</attribute>
              <attribute name="label">%s</attribute>
            </item>
            '''
        menus = ''
        self.mru_disable()
        nav_type = self.navigation_type()
        hobj = self.get_history()
        menu_len = min(len(items) - 1, MRU_SIZE)

        data = []
        for index in range(menu_len - 1, -1, -1):
            name, _obj = navigation_label(self.dbstate.db, items[index][0],
                                          items[index][1])
            menus += menuitem % (nav_type, index, html.escape(name))
            data.append(('%s%02d' % (nav_type, index),
                         make_callback(hobj.push, items[index]),
                         "%s%d" % (mod_key(), menu_len - 1 - index)))
        self.mru_ui = [MRU_TOP + menus + MRU_BTM]

        self.mru_action = ActionGroup(name=self.title + '/MRU')
        self.mru_action.add_actions(data)
        self.mru_enable(update_menu)
示例#5
0
    def update_mru_menu(self, items, update_menu=True):
        """
        Builds the UI and action group for the MRU list.
        """
        menuitem = '''        <item>
              <attribute name="action">win.%s%02d</attribute>
              <attribute name="label" translatable="yes">%s</attribute>
            </item>
            '''
        menus = ''
        self.mru_disable()
        nav_type = self.navigation_type()
        hobj = self.get_history()
        menu_len = min(len(items) - 1, MRU_SIZE)

        for index in range(0, menu_len):
            name, obj = navigation_label(self.dbstate.db, nav_type,
                                         items[index])
            menus += menuitem % (nav_type, index, html.escape(name))
        self.mru_ui = [MRU_TOP + menus + MRU_BTM]

        mitems = items[-MRU_SIZE - 1:-1]  # Ignore current handle
        mitems.reverse()
        data = []
        for index, handle in enumerate(mitems):
            data.append(('%s%02d' % (nav_type, index),
                         make_callback(hobj.push,
                                       handle), "%s%d" % (mod_key(), index)))

        self.mru_action = ActionGroup(name=self.title + '/MRU')
        self.mru_action.add_actions(data)
        self.mru_enable(update_menu)
    def navigation_actions(self):
        """
        Define the navigation menu actions.
        """
        # add the Forward action group to handle the Forward button
        self.fwd_action = ActionGroup(name=self.title + '/Forward')
        self.fwd_action.add_actions([('Forward', self.fwd_clicked,
                                      "%sRight" % mod_key())])

        # add the Backward action group to handle the Forward button
        self.back_action = ActionGroup(name=self.title + '/Backward')
        self.back_action.add_actions([('Back', self.back_clicked,
                                       "%sLeft" % mod_key())])

        self._add_action('HomePerson', self.home, "%sHome" % mod_key())

        self.other_action = ActionGroup(name=self.title + '/PersonOther')
        self.other_action.add_actions([('SetActive', self.set_default_person)])

        self._add_action_group(self.back_action)
        self._add_action_group(self.fwd_action)
        self._add_action_group(self.other_action)
示例#7
0
    def navigation_actions(self):
        """
        Define the navigation menu actions.
        """
        # add the Forward action group to handle the Forward button
        self.fwd_action = ActionGroup(name=self.title + '/Forward')
        self.fwd_action.add_actions([('Forward', self.fwd_clicked,
                                      "%sRight" % mod_key())])

        # add the Backward action group to handle the Forward button
        self.back_action = ActionGroup(name=self.title + '/Backward')
        self.back_action.add_actions([('Back', self.back_clicked,
                                       "%sLeft" % mod_key())])

        self._add_action('HomePerson', self.home, "%sHome" % mod_key())

        self.other_action = ActionGroup(name=self.title + '/PersonOther')
        self.other_action.add_actions([
            ('SetActive', self.set_default_person)])

        self._add_action_group(self.back_action)
        self._add_action_group(self.fwd_action)
        self._add_action_group(self.other_action)