def activate_tab(self, file):
        """
        Activate the GeditTab containing the given File or open a new
        tab for it (this is called by the WindowContext)

        @param file: a File object
        """
        for tab, tab_decorator in self._tab_decorators.items():
            if tab_decorator.file and tab_decorator.file == file:
                self.window.set_active_tab(tab)
                return

        # not found, open file in a new tab...

        uri = file.uri
        gfile = Gio.file_new_for_uri(uri)

        if Gedit.utils_is_valid_location(gfile):
            LOG.debug("GeditWindow.create_tab_from_uri(%s)" % uri)
            try:
                view = self.window.get_active_view()
                encoding = view.get_buffer().get_encoding()
            except AttributeError:
                # No document open
                encoding = None
            self.window.create_tab_from_location(gfile, encoding, 1, 1, False,
                                                 True)
        else:
            LOG.error("Gedit.utils.uri_is_valid(%s) = False" % uri)
示例#2
0
    def activate_tab(self, file):
        """
        Activate the GeditTab containing the given File or open a new
        tab for it (this is called by the WindowContext)

        @param file: a File object
        """
        for tab, tab_decorator in self._tab_decorators.items():
            if tab_decorator.file and tab_decorator.file == file:
                self.window.set_active_tab(tab)
                return

        # not found, open file in a new tab...

        uri = file.uri
        gfile = Gio.file_new_for_uri(uri)

        if Gedit.utils_is_valid_location(gfile):
            LOG.debug("GeditWindow.create_tab_from_uri(%s)" % uri)
            try:
                view = self.window.get_active_view()
                encoding = view.get_buffer().get_encoding()
            except AttributeError:
                # No document open
                encoding = None
            self.window.create_tab_from_location(
                            gfile, encoding,
                            1, 1, False, True)
        else:
            LOG.error("Gedit.utils.uri_is_valid(%s) = False" % uri)
示例#3
0
文件: popup.py 项目: Gibran1994/gedit
    def _direct_file(self):
        uri = self._entry.get_text()
        gfile = Gio.file_new_for_uri(uri)

        if Gedit.utils_is_valid_location(gfile) or (os.path.isabs(uri) and gfile.query_exists()):
            return gfile
        else:
            return None
示例#4
0
    def _direct_file(self):
        uri = self._entry.get_text()
        gfile = Gio.file_new_for_uri(uri)

        if Gedit.utils_is_valid_location(gfile) or \
           (os.path.isabs(uri) and gfile.query_exists()):
            return gfile
        else:
            return None
示例#5
0
    def activate_tab(self, file):
        """
        Activate the GeditTab containing the given File or open a new
        tab for it (this is called by the WindowContext)

        @param file: a File object
        """
        for tab, tab_decorator in self._tab_decorators.iteritems():
            if tab_decorator.file and tab_decorator.file == file:
                self.window.set_active_tab(tab)
                return

        # not found, open file in a new tab...

        uri = file.uri
        gfile = Gio.file_new_for_uri(uri)

        if Gedit.utils_is_valid_location(gfile):
            LOG.debug("GeditWindow.create_tab_from_uri(%s)" % uri)
            self.window.create_tab_from_location(gfile,
                                                 Gedit.encoding_get_current(),
                                                 1, 1, False, True)
        else:
            LOG.error("Gedit.utils.uri_is_valid(%s) = False" % uri)
示例#6
0
    def activate_tab(self, file):
        """
        Activate the GeditTab containing the given File or open a new
        tab for it (this is called by the WindowContext)

        @param file: a File object
        """
        for tab, tab_decorator in self._tab_decorators.iteritems():
            if tab_decorator.file and tab_decorator.file == file:
                self.window.set_active_tab(tab)
                return

        # not found, open file in a new tab...

        uri = file.uri
        gfile = Gio.file_new_for_uri(uri)

        if Gedit.utils_is_valid_location(gfile):
            LOG.debug("GeditWindow.create_tab_from_uri(%s)" % uri)
            self.window.create_tab_from_location(
                            gfile, Gedit.encoding_get_current(),
                            1, 1, False, True)
        else:
            LOG.error("Gedit.utils.uri_is_valid(%s) = False" % uri)