示例#1
0
 def get_menu_items(self, event=None):
     actions = super(VerseCompareFrame, self).get_menu_items(event)
     actions = (
         (MenuItem(_("Set books to compare"),
                   self.set_versions,
                   doc=_("Set the books this version comparison will use")),
          IN_POPUP), ) + actions
     return actions
示例#2
0
    def get_menu_items(self, event=None):
        href = event.GetHref() if event else u""

        search_menu_item = ()
        if self.allow_search:
            search_menu_item = ((self.make_search_text(href), IN_POPUP), )

        menu_items = search_menu_item + (
            (self.make_lookup_text(href), IN_POPUP),
            (Separator, IN_POPUP),
            (MenuItem(_("Select all"), self.SelectAll,
                      _("Select all the text in the frame")), IN_BOTH),
            (MenuItem(_("Copy selection"),
                      self.CopySelection,
                      enabled=self.CanCopySelection,
                      doc=_("Copy the selected text with links")), IN_BOTH),
        )
        return menu_items
示例#3
0
    def get_menu_items(self, event=None):
        def set_text():
            pane = self.aui_pane
            if not pane.IsShown():
                return _("Show the %s pane") % self.title
            else:
                return _("Hide the %s pane") % self.title

        extras = ()
        if self.is_hidable():
            extras += (
                (
                    MenuItem(
                        "Show this frame",  # this is a dummy waiting for set_text
                        self.toggle_frame,
                        update_text=set_text,
                        doc=_("Shows or hides the pane")),
                    IN_BOTH),
                (Separator, IN_BOTH),
            )

        extras += (
            (MenuItem(_("Search"), self.search,
                      doc=_("Search in this book")), IN_MENU),
            (Separator, IN_MENU),
        )

        items = extras + super(BookFrame, self).get_menu_items(event)
        if self.shows_info:
            items += (
                (Separator, IN_BOTH),
                (MenuItem(_("Information..."),
                          self.show_module_information,
                          enabled=self.has_module,
                          doc=_("Show information on the current book")),
                 IN_BOTH),
            )

        return items
示例#4
0
	def make_lookup_text(self, href):
		update_ui = self._get_text(_("Look up %s in the dictionary"), href)

		def on_lookup_click():
			"""Lookup the selected text in the dictionary"""
			text = self.SelectionToText()
			if not text:
				text = self.get_clicked_cell_text()

			text = self.strip_text(text)
			guiconfig.mainfrm.dictionarytext.UpdateUI(text)

		assert hasattr(self, "mod"), self
		font = fonts.get_module_gui_font(self.mod, default_to_None=True)
		
		return MenuItem("Dictionary lookup", on_lookup_click, 
			update_ui=update_ui, font=font)
示例#5
0
    def make_search_text(self, href):
        frame = self.get_frame_for_search()
        if frame.book == biblemgr.bible:
            search_text = _("Search for %s in the Bible")
        else:
            search_text = _("Search for %s in this book")
        update_ui = self._get_text(search_text, href, is_search=True)

        def on_search_click():
            """Search for the selected word in the Bible"""
            strongs_number = None
            text = None
            if href:
                match = re.match(u'strongs://(Greek|Hebrew)/(\d+)(!\w+)?',
                                 href)
                if match:
                    prefix, number, extra = match.group(1, 2, 3)
                    strongs_number = "HG"[prefix == "Greek"] + number
                    if extra:
                        strongs_number += extra[1:]

                    text = "strongs:" + strongs_number

                if not text:
                    match = re.match(u'morph://(\w*)((:|%3A)[^/]+)/([\w-]+)',
                                     href)
                    if match:
                        module, value = match.group(1, 4)
                        if module == "Greek": module = "Robinson"
                        text = "morph:%s:%s" % (module, value)

                ref = None
                if not text:
                    match = (re.match(
                        u'n?bible:([^#]*)(#.*)?', href) or re.match(
                            u'passagestudy.jsp\?action=showRef&type=scripRef&'
                            'value=([^&]*)&module=.*', href))
                    if match:
                        ref = match.group(1)

                if ref:
                    ref = SW.URL.decode(str(ref)).c_str()
                    vl = VerseList(ref)
                    first_ref = VerseList([vl[0]
                                           ]).GetBestRange(userOutput=True)

                    # only search on the first item or range
                    text = 'ref:"%s"' % first_ref

            if not text:
                text = self.SelectionToText()
                if not text:
                    text = self.get_clicked_cell_text()

                text = self.strip_text(text)

                # get rid of a few special characters
                text = re.sub(r'[\()"/:\-]', '', text)

                # if this is a phrase, put quotes around it.
                if " " in text:
                    text = '"%s"' % text

            search_panel = frame.get_search_panel_for_frame()
            assert search_panel, "Search panel not found for %s" % self
            search_panel.search_and_show(text)

        assert hasattr(self, "mod"), self
        font = fonts.get_module_gui_font(self.mod, default_to_None=True)
        return MenuItem("Search on word",
                        on_search_click,
                        update_ui=update_ui,
                        font=font)
示例#6
0
    def get_menu_items(self, event=None):
        items = super(BibleFrame, self).get_menu_items(event)

        for item, scope in items:
            if item != Separator and item.text == _("Search"):
                item.accelerator = "Ctrl-F"

        items = (
            (MenuItem(
                _("Go to Reference"),
                self.focus_reference_textbox,
                accelerator="Ctrl-L",
                doc=_("Go to a reference"),
            ), IN_MENU),
            (MenuItem(
                _("Guess the Verse"),
                self.show_guess_verse,
                accelerator="Ctrl-Shift-G",
                doc=_("Play Guess the Verse"),
                enabled=self.has_module,
            ), IN_MENU),
            (MenuItem(_("Random verse"),
                      self.random_verse,
                      accelerator="Ctrl-R",
                      enabled=self.has_module,
                      doc=_("Go to a random verse")), IN_BOTH),
            (MenuItem(_("Copy verses"),
                      guiconfig.mainfrm.on_copy_button,
                      enabled=self.has_module,
                      accelerator="Ctrl-Alt-C",
                      doc=_("Copy verses to other applications")), IN_BOTH),
            (MenuItem(_("Open sticky tooltip"),
                      self.open_sticky_tooltip,
                      enabled=self.has_module,
                      doc=_("Open a sticky tooltip with the selected verses")),
             IN_POPUP),
            (MenuItem(
                _("Compare verses"),
                self.compare_verses,
                enabled=self.has_module,
                doc=_("Open the verse comparison pane to the selected verses"
                      )), IN_POPUP),
            (Separator, IN_MENU),
            (MenuItem(
                _("Manage Topics"),
                self.manage_topics,
                accelerator="Ctrl+Shift+T",
                enabled=self.has_module,
                doc=_("Manages all of the topics and the passages in them.")),
             IN_MENU),
            (MenuItem(_("Tag verses"),
                      self.tag_verses,
                      accelerator="Ctrl+T",
                      enabled=self.has_module,
                      doc=_("Tags the currently selected verses.")), IN_BOTH),
            (MenuItem(
                _("Add comment to verses"),
                self.comment_on_verses,
                enabled=self.has_module,
                doc=_("Makes a comment on the currently selected verses."),
            ), IN_BOTH),
            (Separator, IN_BOTH),
        ) + items

        return items