本文整理匯總了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)
示例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)