class WindowHelper:
    def __init__(self, window, plugin, search_func):
        self._window = window
        self._plugin = plugin

        self._search_func = search_func

        self._popup = None
        self._install_menu()

    def deactivate(self):
        self._uninstall_menu()
        self._window = None
        self._plugin = None

    def update_ui(self):
        pass

    def _uninstall_menu(self):
        manager = self._window.get_ui_manager()
        manager.remove_ui(self._ui_id)
        manager.remove_action_group(self._action_group)
        manager.ensure_update()

    def _install_menu(self):
        manager = self._window.get_ui_manager()
        self._action_group = gtk.ActionGroup("GeditAPQuickOpenPluginActions")
        self._action_group.add_actions([("APQuickOpen", gtk.STOCK_OPEN,
                                         _("Axy Quick open"), '<Ctrl><Alt>O',
                                         _("Axy Quickly open documents"),
                                         self.on_quick_open_activate)])

        manager.insert_action_group(self._action_group, -1)
        self._ui_id = manager.add_ui_from_string(ui_str)

    def _create_popup(self):
        self._popup = Popup(self._window, self.on_result, self._search_func)
        self._popup.set_default_size(*self._plugin.get_popup_size())
        self._popup.set_transient_for(self._window)
        self._popup.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        self._window.get_group().add_window(self._popup)
        self._popup.connect('destroy', self.on_popup_destroy)

    def on_quick_open_activate(self, action):
        if not self._popup:
            self._create_popup()

        self._popup.show()

    def on_popup_destroy(self, popup):
        alloc = popup.get_allocation()
        self._plugin.set_popup_size((alloc.width, alloc.height))
        self._popup = None

    def on_result(self, path):
        path = os.path.join(get_core(self._window).get_path(), path)
        uri = gio.File(path).get_uri()
        gedit.commands.load_uri(self._window, uri, None, -1)
        return True
    def __init__(self):
        if os.geteuid() != 0:
            root_popup = Popup('Error', 'You need to be root to run the VPN.')
            root_popup.set_icon_from_file("surfshark_linux_client.png")
            root_popup.connect('destroy', Gtk.main_quit)
            Gtk.main()
            return None

        self.debug_on = True  # set to False to disable debug infos

        # TODO : Make a loader
        # TODO : Find a way to have a popup to run the app as root

        self.folder_path = os.path.abspath(os.path.dirname(__file__)) + "/"

        self.servers = self.get_servers()
        self.unhash_pass = ""
        self.config_files = {}
        self.vpn_command = False
        self.thread = False
        self.ip = ""

        with open(self.folder_path + "config.json", "r") as file:
            self.config = json.load(file)

        style = Gtk.CssProvider()
        #Theme
        if (self.config['theme'] == 'light'):
            style.load_from_path(self.folder_path +
                                 "style/style_lightmode.css")
        else:
            style.load_from_path(self.folder_path + "style/style_darkmode.css")

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(), style,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        if (self.config['password_needed'] or not self.config['registered']):
            self.log_window = LogWindow(self)
            self.log_window.connect("destroy", Gtk.main_quit)
            self.log_window.show_all()

        self.main_window = MainWindow(self)
        self.main_window.connect("destroy", self.soft_quit_g)

        if (not self.config['password_needed'] and self.config['registered']):
            screen = self.main_window.get_display()
            monitor_size = screen.get_monitor_at_window(
                Gdk.get_default_root_window()).get_geometry()
            self.main_window.move(
                monitor_size.width / 2 - self.main_window.get_size().width / 2,
                monitor_size.height / 2 -
                self.main_window.get_size().height / 2)
            self.main_window.credentials_username.set_text(
                self.config['vpn_username'])
            self.main_window.credentials_password.set_text(
                self.config['vpn_password'])
            self.main_window.show_all()

        try:
            Gtk.main()
        except (KeyboardInterrupt, SystemExit):
            self.soft_quit()
class WindowHelper:
    def __init__(self, window, plugin):
        self._window = window
        self._plugin = plugin

        self._popup = None
        self._install_menu()

    def deactivate(self):
        self._uninstall_menu()
        self._window = None
        self._plugin = None

    def update_ui(self):
        pass

    def _uninstall_menu(self):
        manager = self._window.get_ui_manager()

        manager.remove_ui(self._ui_id)
        manager.remove_action_group(self._action_group)

        manager.ensure_update()

    def _install_menu(self):
        manager = self._window.get_ui_manager()
        self._action_group = gtk.ActionGroup("PlumaQuickOpenPluginActions")
        self._action_group.add_actions([
            ("QuickOpen", gtk.STOCK_OPEN, _("Quick open"), '<Ctrl><Alt>O',
             _("Quickly open documents"), self.on_quick_open_activate)
        ])

        manager.insert_action_group(self._action_group, -1)
        self._ui_id = manager.add_ui_from_string(ui_str)

    def _create_popup(self):
        paths = []

        # Open documents
        paths.append(CurrentDocumentsDirectory(self._window))

        doc = self._window.get_active_document()

        # Current document directory
        if doc and doc.is_local():
            gfile = doc.get_location()
            paths.append(gfile.get_parent())

        # File browser root directory
        if pluma.version[0] > 2 or (
                pluma.version[0] == 2 and
            (pluma.version[1] > 26 or
             (pluma.version[1] == 26 and pluma.version[2] >= 2))):
            bus = self._window.get_message_bus()

            try:
                msg = bus.send_sync('/plugins/filebrowser', 'get_root')

                if msg:
                    uri = msg.get_value('uri')

                    if uri:
                        gfile = gio.File(uri)

                        if gfile.is_native():
                            paths.append(gfile)

            except StandardError:
                pass

        # Recent documents
        paths.append(
            RecentDocumentsDirectory(screen=self._window.get_screen()))

        # Local bookmarks
        for path in self._local_bookmarks():
            paths.append(path)

        # Desktop directory
        desktopdir = self._desktop_dir()

        if desktopdir:
            paths.append(gio.File(desktopdir))

        # Home directory
        paths.append(gio.File(os.path.expanduser('~')))

        self._popup = Popup(self._window, paths, self.on_activated)

        self._popup.set_default_size(*self._plugin.get_popup_size())
        self._popup.set_transient_for(self._window)
        self._popup.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        self._window.get_group().add_window(self._popup)

        self._popup.connect('destroy', self.on_popup_destroy)

    def _local_bookmarks(self):
        filename = os.path.expanduser('~/.gtk-bookmarks')

        if not os.path.isfile(filename):
            return []

        paths = []

        for line in file(filename, 'r').xreadlines():
            uri = line.strip().split(" ")[0]
            f = gio.File(uri)

            if f.is_native():
                try:
                    info = f.query_info("standard::type")

                    if info and info.get_file_type(
                    ) == gio.FILE_TYPE_DIRECTORY:
                        paths.append(f)
                except glib.GError:
                    pass

        return paths

    def _desktop_dir(self):
        config = os.getenv('XDG_CONFIG_HOME')

        if not config:
            config = os.path.expanduser('~/.config')

        config = os.path.join(config, 'user-dirs.dirs')
        desktopdir = None

        if os.path.isfile(config):
            for line in file(config, 'r').xreadlines():
                line = line.strip()

                if line.startswith('XDG_DESKTOP_DIR'):
                    parts = line.split('=', 1)
                    desktopdir = os.path.expandvars(
                        parts[1].strip('"').strip("'"))
                    break

        if not desktopdir:
            desktopdir = os.path.expanduser('~/Desktop')

        return desktopdir

    # Callbacks
    def on_quick_open_activate(self, action):
        if not self._popup:
            self._create_popup()

        self._popup.show()

    def on_popup_destroy(self, popup):
        alloc = popup.get_allocation()
        self._plugin.set_popup_size((alloc.width, alloc.height))

        self._popup = None

    def on_activated(self, gfile):
        pluma.commands.load_uri(self._window, gfile.get_uri(), None, -1)
        return True
Пример #4
0
class WindowHelper:
        def __init__(self, window, plugin):
                self._window = window
                self._plugin = plugin

                self._popup = None
                self._install_menu()

        def deactivate(self):
                self._uninstall_menu()
                self._window = None
                self._plugin = None

        def update_ui(self):
                pass

        def _uninstall_menu(self):
                manager = self._window.get_ui_manager()

                manager.remove_ui(self._ui_id)
                manager.remove_action_group(self._action_group)

                manager.ensure_update()

        def _install_menu(self):
                manager = self._window.get_ui_manager()
                self._action_group = gtk.ActionGroup("CeditQuickOpenPluginActions")
                self._action_group.add_actions([
                        ("QuickOpen", gtk.STOCK_OPEN, _("Quick open"),
                         '<Ctrl><Alt>O', _("Quickly open documents"),
                         self.on_quick_open_activate)
                ])

                manager.insert_action_group(self._action_group, -1)
                self._ui_id = manager.add_ui_from_string(ui_str)

        def _create_popup(self):
                paths = []

                # Open documents
                paths.append(CurrentDocumentsDirectory(self._window))

                doc = self._window.get_active_document()

                # Current document directory
                if doc and doc.is_local():
                        gfile = doc.get_location()
                        paths.append(gfile.get_parent())

                # File browser root directory
                bus = self._window.get_message_bus()

                try:
                        msg = bus.send_sync('/plugins/filebrowser', 'get_root')

                        if msg:
                                uri = msg.get_value('uri')

                                if uri:
                                        gfile = gio.File(uri)

                                        if gfile.is_native():
                                                paths.append(gfile)

                except StandardError:
                        pass

                # Recent documents
                paths.append(RecentDocumentsDirectory(screen=self._window.get_screen()))

                # Local bookmarks
                for path in self._local_bookmarks():
                        paths.append(path)

                # Desktop directory
                desktopdir = self._desktop_dir()

                if desktopdir:
                        paths.append(gio.File(desktopdir))

                # Home directory
                paths.append(gio.File(os.path.expanduser('~')))

                self._popup = Popup(self._window, paths, self.on_activated)

                self._popup.set_default_size(*self._plugin.get_popup_size())
                self._popup.set_transient_for(self._window)
                self._popup.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

                self._window.get_group().add_window(self._popup)

                self._popup.connect('destroy', self.on_popup_destroy)

        def _local_bookmarks(self):
                filename = os.path.expanduser('~/.gtk-bookmarks')

                if not os.path.isfile(filename):
                        return []

                paths = []

                for line in file(filename, 'r').xreadlines():
                        uri = line.strip().split(" ")[0]
                        f = gio.File(uri)

                        if f.is_native():
                                try:
                                        info = f.query_info("standard::type")

                                        if info and info.get_file_type() == gio.FILE_TYPE_DIRECTORY:
                                                paths.append(f)
                                except glib.GError:
                                        pass

                return paths

        def _desktop_dir(self):
                config = os.getenv('XDG_CONFIG_HOME')

                if not config:
                        config = os.path.expanduser('~/.config')

                config = os.path.join(config, 'user-dirs.dirs')
                desktopdir = None

                if os.path.isfile(config):
                        for line in file(config, 'r').xreadlines():
                                line = line.strip()

                                if line.startswith('XDG_DESKTOP_DIR'):
                                        parts = line.split('=', 1)
                                        desktopdir = os.path.expandvars(parts[1].strip('"').strip("'"))
                                        break

                if not desktopdir:
                        desktopdir = os.path.expanduser('~/Desktop')

                return desktopdir

        # Callbacks
        def on_quick_open_activate(self, action):
                if not self._popup:
                        self._create_popup()

                self._popup.show()

        def on_popup_destroy(self, popup):
                alloc = popup.get_allocation()
                self._plugin.set_popup_size((alloc.width, alloc.height))

                self._popup = None

        def on_activated(self, gfile):
                cedit.commands.load_uri(self._window, gfile.get_uri(), None, -1)
                return True
Пример #5
0
class WindowHelper:
    def __init__(self, window, plugin):
        self._window = window
        self._plugin = plugin
        self._popup = None

        self._install_menu()

    def deactivate(self):
        self._uninstall_menu()

        self._window = None
        self._plugin = None

    def update_ui(self):
        pass

    def _install_menu(self):
        manager = self._window.get_ui_manager()
        self._action_group = gtk.ActionGroup(
            "GeditQuickHighlightModePluginActions")
        self._action_group.add_actions([
            ("QuickHighlightMode", gtk.STOCK_OPEN, _("Quick Highlight Mode"),
             "<Ctrl><Shift>H",
             _("Quickly switch between document syntax highlight modes"),
             self.on_lang_switcher_activate)
        ])

        manager.insert_action_group(self._action_group, -1)
        self._ui_id = manager.add_ui_from_string(ui_str)

    def _uninstall_menu(self):
        manager = self._window.get_ui_manager()

        manager.remove_ui(self._ui_id)
        manager.remove_action_group(self._action_group)

        manager.ensure_update()

    def _create_popup(self):
        self._popup = Popup(self._window, self.on_selected)

        self._popup.set_default_size(*self._plugin.get_popup_size())
        self._popup.set_transient_for(self._window)
        self._popup.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        self._window.get_group().add_window(self._popup)

        self._popup.connect("destroy", self._destroy_popup)

    def _destroy_popup(self, popup):
        alloc = popup.get_allocation()
        self._plugin.set_popup_size((alloc.width, alloc.height))

        self._popup = None

    # Events
    def on_lang_switcher_activate(self, action):
        if not self._popup:
            self._create_popup()

        self._popup.show()

    def on_selected(self, lang):
        doc = self._window.get_active_document()
        doc.set_language(lang)
        return True
class WindowHelper:
    
    def __init__(self, window, plugin):
        self._window = window
        self._plugin = plugin
        self._popup = None
        
        self._install_menu()

    def deactivate(self):
        self._uninstall_menu()
        
        self._window = None
        self._plugin = None

    def update_ui(self):
        pass
    
    def _install_menu(self):
        manager = self._window.get_ui_manager()
        self._action_group = gtk.ActionGroup("GeditQuickHighlightModePluginActions")
        self._action_group.add_actions([(
            "QuickHighlightMode",
            gtk.STOCK_OPEN,
            _("Quick Highlight Mode"),
            "<Ctrl><Shift>H",
            _("Quickly switch between document syntax highlight modes"),
            self.on_lang_switcher_activate
        )])
        
        manager.insert_action_group(self._action_group, -1)
        self._ui_id = manager.add_ui_from_string(ui_str)
    
    def _uninstall_menu(self):
        manager = self._window.get_ui_manager()
        
        manager.remove_ui(self._ui_id)
        manager.remove_action_group(self._action_group)
        
        manager.ensure_update()
    
    def _create_popup(self):
        self._popup = Popup(self._window, self.on_selected)
        
        self._popup.set_default_size(*self._plugin.get_popup_size())
        self._popup.set_transient_for(self._window)
        self._popup.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        
        self._window.get_group().add_window(self._popup)
        
        self._popup.connect("destroy", self._destroy_popup)
    
    def _destroy_popup(self, popup):
        alloc = popup.get_allocation()
        self._plugin.set_popup_size((alloc.width, alloc.height))
        
        self._popup = None
    
    # Events
    def on_lang_switcher_activate(self, action):
        if not self._popup:
            self._create_popup()
        
        self._popup.show()
    
    def on_selected(self, lang):
        doc = self._window.get_active_document()
        doc.set_language(lang)
        return True
Пример #7
0
class QuickOpenPlugin(GObject.Object, Gedit.WindowActivatable):
    __gtype_name__ = "QuickOpenPlugin"

    window = GObject.property(type=Gedit.Window)

    def __init__(self):
        GObject.Object.__init__(self)

    def do_activate(self):
        self._popup_size = (450, 300)
        self._popup = None
        self._install_menu()

    def do_deactivate(self):
        self._uninstall_menu()

    def get_popup_size(self):
        return self._popup_size

    def set_popup_size(self, size):
        self._popup_size = size

    def _uninstall_menu(self):
        manager = self.window.get_ui_manager()

        manager.remove_ui(self._ui_id)
        manager.remove_action_group(self._action_group)

        manager.ensure_update()

    def _install_menu(self):
        manager = self.window.get_ui_manager()
        self._action_group = Gtk.ActionGroup(name="GeditQuickOpenPluginActions")
        self._action_group.add_actions([
            ("QuickOpen", Gtk.STOCK_OPEN, _("Quick open"),
             '<Primary><Alt>o', _("Quickly open documents"),
             self.on_quick_open_activate)
        ])

        manager.insert_action_group(self._action_group)
        self._ui_id = manager.add_ui_from_string(ui_str)

    def _create_popup(self):
        paths = []

        # Open documents
        paths.append(CurrentDocumentsDirectory(self.window))

        doc = self.window.get_active_document()

        # Current document directory
        if doc and doc.is_local():
            gfile = doc.get_location()
            paths.append(gfile.get_parent())

        # File browser root directory
        bus = self.window.get_message_bus()

        if bus.is_registered('/plugins/filebrowser', 'get_root'):
            msg = bus.send_sync('/plugins/filebrowser', 'get_root')

            if msg:
                gfile = msg.props.location

                if gfile and gfile.is_native():
                    paths.append(gfile)

        # Recent documents
        paths.append(RecentDocumentsDirectory())

        # Local bookmarks
        for path in self._local_bookmarks():
            paths.append(path)

        # Desktop directory
        desktopdir = self._desktop_dir()

        if desktopdir:
            paths.append(Gio.file_new_for_path(desktopdir))

        # Home directory
        paths.append(Gio.file_new_for_path(os.path.expanduser('~')))

        self._popup = Popup(self.window, paths, self.on_activated)
        self.window.get_group().add_window(self._popup)

        self._popup.set_default_size(*self.get_popup_size())
        self._popup.set_transient_for(self.window)
        self._popup.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
        self._popup.connect('destroy', self.on_popup_destroy)

    def _local_bookmarks(self):
        filename = os.path.expanduser('~/.gtk-bookmarks')

        if not os.path.isfile(filename):
            return []

        paths = []

        for line in file(filename, 'r').xreadlines():
            uri = line.strip().split(" ")[0]
            f = Gio.file_new_for_uri(uri)

            if f.is_native():
                try:
                    info = f.query_info(Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
                                        Gio.FileQueryInfoFlags.NONE,
                                        None)

                    if info and info.get_file_type() == Gio.FileType.DIRECTORY:
                        paths.append(f)
                except:
                    pass

        return paths

    def _desktop_dir(self):
        config = os.getenv('XDG_CONFIG_HOME')

        if not config:
            config = os.path.expanduser('~/.config')

        config = os.path.join(config, 'user-dirs.dirs')
        desktopdir = None

        if os.path.isfile(config):
            for line in file(config, 'r').xreadlines():
                line = line.strip()

                if line.startswith('XDG_DESKTOP_DIR'):
                    parts = line.split('=', 1)
                    desktopdir = os.path.expandvars(parts[1].strip('"').strip("'"))
                    break

        if not desktopdir:
            desktopdir = os.path.expanduser('~/Desktop')

        return desktopdir

    # Callbacks
    def on_quick_open_activate(self, action, user_data=None):
        if not self._popup:
            self._create_popup()

        self._popup.show()

    def on_popup_destroy(self, popup, user_data=None):
        alloc = popup.get_allocation()
        self.set_popup_size((alloc.width, alloc.height))

        self._popup = None

    def on_activated(self, gfile, user_data=None):
        Gedit.commands_load_location(self.window, gfile, None, -1, -1)
        return True
Пример #8
0
class QuickOpenPlugin(GObject.Object, Gedit.WindowActivatable):
    __gtype_name__ = "QuickOpenPlugin"

    window = GObject.property(type=Gedit.Window)

    def __init__(self):
        GObject.Object.__init__(self)

    def do_activate(self):
        self._popup_size = (450, 300)
        self._popup = None
        self._install_menu()

    def do_deactivate(self):
        self._uninstall_menu()

    def get_popup_size(self):
        return self._popup_size

    def set_popup_size(self, size):
        self._popup_size = size

    def _uninstall_menu(self):
        manager = self.window.get_ui_manager()

        manager.remove_ui(self._ui_id)
        manager.remove_action_group(self._action_group)

        manager.ensure_update()

    def _install_menu(self):
        manager = self.window.get_ui_manager()
        self._action_group = Gtk.ActionGroup(
            name="GeditQuickOpenPluginActions")
        self._action_group.add_actions([
            ("QuickOpen", Gtk.STOCK_OPEN, _("Quick open"), '<Primary><Alt>o',
             _("Quickly open documents"), self.on_quick_open_activate)
        ])

        manager.insert_action_group(self._action_group)
        self._ui_id = manager.add_ui_from_string(ui_str)

    def _create_popup(self):
        paths = []

        # Open documents
        paths.append(CurrentDocumentsDirectory(self.window))

        doc = self.window.get_active_document()

        # Current document directory
        if doc and doc.is_local():
            gfile = doc.get_location()
            paths.append(gfile.get_parent())

        # File browser root directory
        bus = self.window.get_message_bus()

        if bus.is_registered('/plugins/filebrowser', 'get_root'):
            msg = bus.send_sync('/plugins/filebrowser', 'get_root')

            if msg:
                gfile = msg.props.location

                if gfile and gfile.is_native():
                    paths.append(gfile)

        # Recent documents
        paths.append(RecentDocumentsDirectory())

        # Local bookmarks
        for path in self._local_bookmarks():
            paths.append(path)

        # Desktop directory
        desktopdir = self._desktop_dir()

        if desktopdir:
            paths.append(Gio.file_new_for_path(desktopdir))

        # Home directory
        paths.append(Gio.file_new_for_path(os.path.expanduser('~')))

        self._popup = Popup(self.window, paths, self.on_activated)
        self.window.get_group().add_window(self._popup)

        self._popup.set_default_size(*self.get_popup_size())
        self._popup.set_transient_for(self.window)
        self._popup.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
        self._popup.connect('destroy', self.on_popup_destroy)

    def _local_bookmarks(self):
        filename = os.path.expanduser('~/.gtk-bookmarks')

        if not os.path.isfile(filename):
            return []

        paths = []

        for line in file(filename, 'r').xreadlines():
            uri = line.strip().split(" ")[0]
            f = Gio.file_new_for_uri(uri)

            if f.is_native():
                try:
                    info = f.query_info(Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
                                        Gio.FileQueryInfoFlags.NONE, None)

                    if info and info.get_file_type() == Gio.FileType.DIRECTORY:
                        paths.append(f)
                except:
                    pass

        return paths

    def _desktop_dir(self):
        config = os.getenv('XDG_CONFIG_HOME')

        if not config:
            config = os.path.expanduser('~/.config')

        config = os.path.join(config, 'user-dirs.dirs')
        desktopdir = None

        if os.path.isfile(config):
            for line in file(config, 'r').xreadlines():
                line = line.strip()

                if line.startswith('XDG_DESKTOP_DIR'):
                    parts = line.split('=', 1)
                    desktopdir = os.path.expandvars(
                        parts[1].strip('"').strip("'"))
                    break

        if not desktopdir:
            desktopdir = os.path.expanduser('~/Desktop')

        return desktopdir

    # Callbacks
    def on_quick_open_activate(self, action, user_data=None):
        if not self._popup:
            self._create_popup()

        self._popup.show()

    def on_popup_destroy(self, popup, user_data=None):
        alloc = popup.get_allocation()
        self.set_popup_size((alloc.width, alloc.height))

        self._popup = None

    def on_activated(self, gfile, user_data=None):
        Gedit.commands_load_location(self.window, gfile, None, -1, -1)
        return True
class WindowHelper:
    def __init__(self, window, plugin, search_func):
        self._window = window
        self._plugin = plugin

        self._search_func = search_func

        self._popup = None
        self._install_menu()

    def deactivate(self):
        self._uninstall_menu()
        self._window = None
        self._plugin = None

    def update_ui(self):
        pass

    def _uninstall_menu(self):
        manager = self._window.get_ui_manager()
        manager.remove_ui(self._ui_id)
        manager.remove_action_group(self._action_group)
        manager.ensure_update()

    def _install_menu(self):
        manager = self._window.get_ui_manager()
        self._action_group = gtk.ActionGroup("GeditAPQuickOpenPluginActions")
        self._action_group.add_actions(
            [
                (
                    "APQuickOpen",
                    gtk.STOCK_OPEN,
                    _("Axy Quick open"),
                    "<Ctrl><Alt>O",
                    _("Axy Quickly open documents"),
                    self.on_quick_open_activate,
                )
            ]
        )

        manager.insert_action_group(self._action_group, -1)
        self._ui_id = manager.add_ui_from_string(ui_str)

    def _create_popup(self):
        self._popup = Popup(self._window, self.on_result, self._search_func)
        self._popup.set_default_size(*self._plugin.get_popup_size())
        self._popup.set_transient_for(self._window)
        self._popup.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        self._window.get_group().add_window(self._popup)
        self._popup.connect("destroy", self.on_popup_destroy)

    def on_quick_open_activate(self, action):
        if not self._popup:
            self._create_popup()

        self._popup.show()

    def on_popup_destroy(self, popup):
        alloc = popup.get_allocation()
        self._plugin.set_popup_size((alloc.width, alloc.height))
        self._popup = None

    def on_result(self, path):
        path = os.path.join(get_core(self._window).get_path(), path)
        uri = gio.File(path).get_uri()
        gedit.commands.load_uri(self._window, uri, None, -1)
        return True