本文整理汇总了Python中blueman.gui.GenericList.GenericList.get方法的典型用法代码示例。如果您正苦于以下问题:Python GenericList.get方法的具体用法?Python GenericList.get怎么用?Python GenericList.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blueman.gui.GenericList.GenericList
的用法示例。
在下文中一共展示了GenericList.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PluginDialog
# 需要导入模块: from blueman.gui.GenericList import GenericList [as 别名]
# 或者: from blueman.gui.GenericList.GenericList import get [as 别名]
class PluginDialog(Gtk.Window):
def __init__(self, applet):
super().__init__(
title=_("Plugins"),
icon_name="blueman",
name="PluginDialog",
border_width=6,
default_width=490,
default_height=380,
resizable=False,
visible=False
)
self.applet = applet
self.Builder = Gtk.Builder(translation_domain="blueman")
bind_textdomain_codeset("blueman", "UTF-8")
self.Builder.add_from_file(UI_PATH + "/applet-plugins-widget.ui")
self.description = self.Builder.get_object("description")
self.icon = self.Builder.get_object("icon")
self.author_txt = self.Builder.get_object("author_txt")
self.depends_hdr = self.Builder.get_object("depends_hdr")
self.depends_txt = self.Builder.get_object("depends_txt")
self.conflicts_hdr = self.Builder.get_object("conflicts_hdr")
self.conflicts_txt = self.Builder.get_object("conflicts_txt")
self.plugin_name = self.Builder.get_object("name")
self.main_container = self.Builder.get_object("main_container")
self.content_grid = self.Builder.get_object("content")
self.b_prefs = self.Builder.get_object("b_prefs")
self.b_prefs.connect("toggled", self.on_prefs_toggled)
ref = weakref.ref(self)
self.add(self.Builder.get_object("all"))
cr = Gtk.CellRendererToggle()
cr.connect("toggled", lambda *args: ref() and ref().on_toggled(*args))
data = [
{"id": "active", "type": bool, "renderer": cr, "render_attrs": {"active": 0, "activatable": 1,
"visible": 1}},
{"id": "activatable", "type": bool},
{"id": "icon", "type": str, "renderer": Gtk.CellRendererPixbuf(), "render_attrs": {"icon-name": 2}},
# device caption
{"id": "desc", "type": str, "renderer": Gtk.CellRendererText(), "render_attrs": {"markup": 3},
"view_props": {"expand": True}},
{"id": "name", "type": str},
]
self.list = GenericList(data, headers_visible=False, visible=True)
self.list.liststore.set_sort_column_id(3, Gtk.SortType.ASCENDING)
self.list.liststore.set_sort_func(3, self.list_compare_func)
self.list.selection.connect("changed", lambda *args: ref() and ref().on_selection_changed(*args))
plugin_list = self.Builder.get_object("plugin_list")
plugin_info = self.Builder.get_object("main_scrolled_window")
plugin_list.add(self.list)
# Disable overlay scrolling
if Gtk.get_minor_version() >= 16:
plugin_list.props.overlay_scrolling = False
plugin_info.props.overlay_scrolling = False
self.populate()
self.sig_a = self.applet.Plugins.connect("plugin-loaded", self.plugin_state_changed, True)
self.sig_b = self.applet.Plugins.connect("plugin-unloaded", self.plugin_state_changed, False)
self.connect("delete-event", self._on_close)
self.list.set_cursor(0)
def list_compare_func(self, treemodel, iter1, iter2, user_data):
a = self.list.get(iter1, "activatable", "name")
b = self.list.get(iter2, "activatable", "name")
if (a["activatable"] and b["activatable"]) or (not a["activatable"] and not b["activatable"]):
if a["name"] == b["name"]:
return 0
if a["name"] < b["name"]:
return -1
else:
return 1
else:
if a["activatable"] and not b["activatable"]:
return -1
elif not a["activatable"] and b["activatable"]:
return 1
def _on_close(self, *args, **kwargs):
self.applet.Plugins.disconnect(self.sig_a)
self.applet.Plugins.disconnect(self.sig_b)
def on_selection_changed(self, selection):
model, tree_iter = selection.get_selected()
#.........这里部分代码省略.........
示例2: PluginDialog
# 需要导入模块: from blueman.gui.GenericList import GenericList [as 别名]
# 或者: from blueman.gui.GenericList.GenericList import get [as 别名]
class PluginDialog(Gtk.Dialog):
def __init__(self, applet):
Gtk.Dialog.__init__(self, buttons=("_Close", Gtk.ResponseType.CLOSE))
self.set_name("PluginDialog")
self.applet = applet
self.Builder = Gtk.Builder()
self.Builder.set_translation_domain("blueman")
bind_textdomain_codeset("blueman", "UTF-8")
self.Builder.add_from_file(UI_PATH + "/applet-plugins-widget.ui")
self.set_title(_("Plugins"))
self.props.icon_name = "blueman"
self.description = self.Builder.get_object("description")
self.description.props.wrap = True
self.icon = self.Builder.get_object("icon")
self.author_txt = self.Builder.get_object("author_txt")
self.depends_hdr = self.Builder.get_object("depends_hdr")
self.depends_txt = self.Builder.get_object("depends_txt")
self.conflicts_hdr = self.Builder.get_object("conflicts_hdr")
self.conflicts_txt = self.Builder.get_object("conflicts_txt")
self.plugin_name = self.Builder.get_object("name")
self.main_container = self.Builder.get_object("main_container")
self.content_grid = self.Builder.get_object("content")
self.b_prefs = self.Builder.get_object("b_prefs")
self.b_prefs.connect("toggled", self.on_prefs_toggled)
widget = self.Builder.get_object("all")
ref = weakref.ref(self)
self.vbox.pack_start(widget, True, True, 0)
cr = Gtk.CellRendererToggle()
cr.connect("toggled", lambda *args: ref() and ref().on_toggled(*args))
data = [
["active", bool, cr, {"active": 0, "activatable": 1, "visible": 1}, None],
["activatable", bool],
["icon", str, Gtk.CellRendererPixbuf(), {"icon-name": 2}, None],
# device caption
["desc", str, Gtk.CellRendererText(), {"markup": 3}, None, {"expand": True}],
["name", str]
]
self.list = GenericList(data)
# self.sorted = Gtk.TreeModelSort(self.list.liststore)
self.list.liststore.set_sort_column_id(3, Gtk.SortType.ASCENDING)
self.list.liststore.set_sort_func(3, self.list_compare_func)
self.list.selection.connect("changed", lambda *args: ref() and ref().on_selection_changed(*args))
self.list.props.headers_visible = False
self.list.show()
self.props.border_width = 6
self.resize(490, 380)
self.Builder.get_object("viewport").add(self.list)
self.populate()
self.sig_a = self.applet.Plugins.connect("plugin-loaded", self.plugin_state_changed, True)
self.sig_b = self.applet.Plugins.connect("plugin-unloaded", self.plugin_state_changed, False)
self.connect("response", self.on_response)
self.list.set_cursor(0)
def list_compare_func(self, treemodel, iter1, iter2, user_data):
a = self.list.get(iter1, "activatable", "name")
b = self.list.get(iter2, "activatable", "name")
if (a["activatable"] and b["activatable"]) or (not a["activatable"] and not b["activatable"]):
if a["name"] == b["name"]:
return 0
if a["name"] < b["name"]:
return -1
else:
return 1
else:
if a["activatable"] and not b["activatable"]:
return -1
elif not a["activatable"] and b["activatable"]:
return 1
def on_response(self, dialog, resp):
self.applet.Plugins.disconnect(self.sig_a)
self.applet.Plugins.disconnect(self.sig_b)
def on_selection_changed(self, selection):
model, iter = selection.get_selected()
name = self.list.get(iter, "name")["name"]
#.........这里部分代码省略.........