当前位置: 首页>>代码示例>>Python>>正文


Python Popup.connect方法代码示例

本文整理汇总了Python中popup.Popup.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Popup.connect方法的具体用法?Python Popup.connect怎么用?Python Popup.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在popup.Popup的用法示例。


在下文中一共展示了Popup.connect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from popup import Popup [as 别名]
# 或者: from popup.Popup import connect [as 别名]
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 = []
#.........这里部分代码省略.........
开发者ID:cranes-bill,项目名称:cedit,代码行数:103,代码来源:windowhelper.py

示例2: QuickOpenPlugin

# 需要导入模块: from popup import Popup [as 别名]
# 或者: from popup.Popup import connect [as 别名]
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():
#.........这里部分代码省略.........
开发者ID:onia,项目名称:pygi,代码行数:103,代码来源:__init__.py

示例3: __init__

# 需要导入模块: from popup import Popup [as 别名]
# 或者: from popup.Popup import connect [as 别名]
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
开发者ID:nagaozen,项目名称:gedit-plugin-quickhighlightmode,代码行数:71,代码来源:windowhelper.py

示例4: __init__

# 需要导入模块: from popup import Popup [as 别名]
# 或者: from popup.Popup import connect [as 别名]
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
开发者ID:alexkv,项目名称:Gedit-PowerProject-Plugins,代码行数:70,代码来源:windowhelper.py


注:本文中的popup.Popup.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。