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


Python GenericList.get_conditional方法代码示例

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


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

示例1: PluginDialog

# 需要导入模块: from blueman.gui.GenericList import GenericList [as 别名]
# 或者: from blueman.gui.GenericList.GenericList import get_conditional [as 别名]

#.........这里部分代码省略.........
        self.update_config_widget(cls)

    def update_config_widget(self, cls):
        if self.b_prefs.props.active:
            if not cls.is_configurable():
                self.b_prefs.props.active = False
                return

            if not cls.__instance__:
                self.b_prefs.props.active = False
            else:
                c = self.main_container.get_child()
                self.main_container.remove(c)
                if isinstance(c, SettingsWidget):
                    c.destroy()

                self.main_container.add(SettingsWidget(cls.__instance__))

        else:
            c = self.main_container.get_child()
            self.main_container.remove(c)
            if isinstance(c, SettingsWidget):
                c.destroy()
            self.main_container.add(self.content_grid)

    def populate(self):
        classes = self.applet.Plugins.get_classes()
        loaded = self.applet.Plugins.get_loaded()
        for name, cls in classes.items():
            if cls.is_configurable():
                desc = "<span weight=\"bold\">%s</span>" % name
            else:
                desc = name
            self.list.append(active=(name in loaded), icon=cls.__icon__, activatable=cls.__unloadable__, name=name,
                             desc=desc)

    def plugin_state_changed(self, plugins, name, loaded):
        row = self.list.get_conditional(name=name)
        self.list.set(row[0], active=loaded)

        cls = self.applet.Plugins.get_classes()[name]
        if not loaded:
            self.update_config_widget(cls)
            self.b_prefs.props.sensitive = False
        elif cls.is_configurable():
            self.b_prefs.props.sensitive = True

    def on_toggled(self, cellrenderer, path):
        name = self.list.get(path, "name")["name"]

        deps = self.applet.Plugins.get_dependencies()[name]
        loaded = self.applet.Plugins.get_loaded()
        to_unload = []
        for dep in deps:
            if dep in loaded:
                to_unload.append(dep)

        if to_unload:
            dialog = Gtk.MessageDialog(self, type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO)
            dialog.props.secondary_use_markup = True
            dialog.props.icon_name = "blueman"
            dialog.props.text = _("Dependency issue")
            dialog.props.secondary_text = \
                _("Plugin <b>\"%(0)s\"</b> depends on <b>%(1)s</b>. Unloading <b>%(1)s</b> will also unload <b>"
                  "\"%(0)s\"</b>.\nProceed?") % {"0": ", ".join(to_unload), "1": name}

            resp = dialog.run()
            if resp != Gtk.ResponseType.YES:
                dialog.destroy()
                return

            dialog.destroy()

        conflicts = self.applet.Plugins.get_conflicts()[name]
        to_unload = []
        for conf in conflicts:
            if conf in loaded:
                to_unload.append(conf)

        if to_unload:
            dialog = Gtk.MessageDialog(self, type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO)
            dialog.props.secondary_use_markup = True
            dialog.props.icon_name = "blueman"
            dialog.props.text = _("Dependency issue")
            dialog.props.secondary_text = \
                _("Plugin <b>%(0)s</b> conflicts with <b>%(1)s</b>. Loading <b>%(1)s</b> will unload <b>%(0)s</b>."
                  "\nProceed?") % {"0": ", ".join(to_unload), "1": name}

            resp = dialog.run()
            if resp != Gtk.ResponseType.YES:
                dialog.destroy()
                return

            dialog.destroy()

            for p in to_unload:
                self.applet.Plugins.set_config(p, False)

        loaded = name in self.applet.Plugins.get_loaded()
        self.applet.Plugins.set_config(name, not loaded)
开发者ID:blueman-project,项目名称:blueman,代码行数:104,代码来源:PluginDialog.py

示例2: PluginDialog

# 需要导入模块: from blueman.gui.GenericList import GenericList [as 别名]
# 或者: from blueman.gui.GenericList.GenericList import get_conditional [as 别名]

#.........这里部分代码省略.........
        self.update_config_widget(cls)

    def update_config_widget(self, cls):
        if self.b_prefs.props.active:
            if not cls.is_configurable():
                self.b_prefs.props.active = False
                return

            if not cls.__instance__:
                self.b_prefs.props.active = False
            else:
                c = self.main_container.get_child()
                self.main_container.remove(c)
                if isinstance(c, SettingsWidget):
                    c.destroy()

                self.main_container.add(SettingsWidget(cls.__instance__))

        else:
            c = self.main_container.get_child()
            self.main_container.remove(c)
            if isinstance(c, SettingsWidget):
                c.destroy()
            self.main_container.add(self.content_grid)

    def populate(self):
        classes = self.applet.Plugins.GetClasses()
        loaded = self.applet.Plugins.GetLoaded()
        for name, cls in classes.items():
            if cls.is_configurable():
                desc = "<span weight=\"bold\">%s</span>" % name
            else:
                desc = name
            self.list.append(active=(name in loaded), icon=cls.__icon__, activatable=(cls.__unloadable__), name=name,
                             desc=desc)

    def plugin_state_changed(self, plugins, name, loaded):
        row = self.list.get_conditional(name=name)
        self.list.set(row[0], active=loaded)

        cls = self.applet.Plugins.GetClasses()[name]
        if not loaded:
            self.update_config_widget(cls)
            self.b_prefs.props.sensitive = False
        elif cls.is_configurable():
            self.b_prefs.props.sensitive = True

    def on_toggled(self, cellrenderer, path):
        name = self.list.get(path, "name")["name"]

        deps = self.applet.Plugins.GetDependencies()[name]
        loaded = self.applet.Plugins.GetLoaded()
        to_unload = []
        for dep in deps:
            if dep in loaded:
                to_unload.append(dep)

        if to_unload != []:
            dialog = Gtk.MessageDialog(self, type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO)
            dialog.props.secondary_use_markup = True
            dialog.props.icon_name = "blueman"
            dialog.props.text = _("Dependency issue")
            dialog.props.secondary_text = _(
                "Plugin <b>\"%(0)s\"</b> depends on <b>%(1)s</b>. Unloading <b>%(1)s</b> will also unload <b>\"%(0)s\"</b>.\nProceed?") % {
                                          "0": ", ".join(to_unload), "1": name}

            resp = dialog.run()
            if resp != Gtk.ResponseType.YES:
                dialog.destroy()
                return

            dialog.destroy()

        conflicts = self.applet.Plugins.GetConflicts()[name]
        to_unload = []
        for conf in conflicts:
            if conf in loaded:
                to_unload.append(conf)

        if to_unload != []:
            dialog = Gtk.MessageDialog(self, type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO)
            dialog.props.secondary_use_markup = True
            dialog.props.icon_name = "blueman"
            dialog.props.text = _("Dependency issue")
            dialog.props.secondary_text = _(
                "Plugin <b>%(0)s</b> conflicts with <b>%(1)s</b>. Loading <b>%(1)s</b> will unload <b>%(0)s</b>.\nProceed?") % {
                                          "0": ", ".join(to_unload), "1": name}

            resp = dialog.run()
            if resp != Gtk.ResponseType.YES:
                dialog.destroy()
                return

            dialog.destroy()

            for p in to_unload:
                self.applet.Plugins.SetConfig(p, False)

        loaded = name in self.applet.Plugins.GetLoaded()
        cls = self.applet.Plugins.SetConfig(name, not loaded)
开发者ID:KunLiu1210,项目名称:blueman,代码行数:104,代码来源:PluginDialog.py


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