本文整理匯總了Python中quodlibet.qltk.searchbar.SearchBarBox.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python SearchBarBox.connect方法的具體用法?Python SearchBarBox.connect怎麽用?Python SearchBarBox.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類quodlibet.qltk.searchbar.SearchBarBox
的用法示例。
在下文中一共展示了SearchBarBox.connect方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __create_searchbar
# 需要導入模塊: from quodlibet.qltk.searchbar import SearchBarBox [as 別名]
# 或者: from quodlibet.qltk.searchbar.SearchBarBox import connect [as 別名]
def __create_searchbar(self, library):
self.accelerators = Gtk.AccelGroup()
completion = LibraryTagCompletion(library.librarian)
sbb = SearchBarBox(completion=completion, accel_group=self.accelerators)
sbb.connect("query-changed", self.__text_parse)
sbb.connect("focus-out", self.__focus)
return sbb
示例2: SearchBar
# 需要導入模塊: from quodlibet.qltk.searchbar import SearchBarBox [as 別名]
# 或者: from quodlibet.qltk.searchbar.SearchBarBox import connect [as 別名]
class SearchBar(EmptyBar):
name = _("Search Library")
accelerated_name = _("_Search Library")
priority = 1
in_menu = True
def __init__(self, library, main, limit=True):
super(SearchBar, self).__init__(library, main)
self.set_spacing(6)
completion = LibraryTagCompletion(library.librarian)
self.accelerators = gtk.AccelGroup()
if limit:
self._search_bar = LimitSearchBar(completion=completion,
accel_group=self.accelerators)
else:
self._search_bar = SearchBarBox(completion=completion,
accel_group=self.accelerators)
self._search_bar.connect('query-changed', self.__text_parse)
def focus(widget, *args):
qltk.get_top_parent(widget).songlist.grab_focus()
self._search_bar.connect('focus-out', focus)
self.connect('destroy', self.__destroy)
if main:
align = Alignment(self._search_bar, left=3, right=3, top=3)
else:
align = Alignment(self._search_bar)
align.show()
self.pack_start(align, expand=False)
self.show()
def __destroy(self, *args):
self._search_bar = None
def activate(self):
songs = self._get_songs()
if songs is not None and self._search_bar:
songs = self._search_bar.limit(songs)
gobject.idle_add(self.emit, 'songs-selected', songs, None)
def __text_parse(self, bar, text):
self._text = text
self.activate()
def filter_text(self, text):
self._text = text
self._search_bar.set_text(text)
self.activate()
示例3: _create_searchbar
# 需要導入模塊: from quodlibet.qltk.searchbar import SearchBarBox [as 別名]
# 或者: from quodlibet.qltk.searchbar.SearchBarBox import connect [as 別名]
def _create_searchbar(self, library):
completion = LibraryTagCompletion(library)
self.accelerators = Gtk.AccelGroup()
search = SearchBarBox(completion=completion,
validator=SoundcloudQuery.validator,
accel_group=self.accelerators,
timeout=3000)
self.__searchbar = search
search.connect('query-changed', self.__query_changed)
def focus(widget, *args):
qltk.get_top_parent(widget).songlist.grab_focus()
search.connect('focus-out', focus)
self._searchbox = Align(search, left=0, right=6, top=6)
self._searchbox.show_all()
示例4: __init__
# 需要導入模塊: from quodlibet.qltk.searchbar import SearchBarBox [as 別名]
# 或者: from quodlibet.qltk.searchbar.SearchBarBox import connect [as 別名]
def __init__(self, library):
super(PanedBrowser, self).__init__()
self._register_instance()
self._filter = lambda s: False
self._library = library
self.set_spacing(6)
self.set_orientation(Gtk.Orientation.VERTICAL)
completion = LibraryTagCompletion(library.librarian)
self.accelerators = Gtk.AccelGroup()
sbb = SearchBarBox(completion=completion,
accel_group=self.accelerators)
sbb.connect('query-changed', self.__text_parse)
sbb.connect('focus-out', self.__focus)
self._sb_box = sbb
align = Align(sbb, left=6, right=6, top=6)
self.pack_start(align, False, True, 0)
keyval, mod = Gtk.accelerator_parse("<Primary>Home")
self.accelerators.connect(keyval, mod, 0, self.__select_all)
select = Gtk.Button(label=_("Select _All"), use_underline=True)
select.connect('clicked', self.__select_all)
sbb.pack_start(select, False, True, 0)
prefs = PreferencesButton(self)
sbb.pack_start(prefs, False, True, 0)
connect_destroy(library, 'changed', self.__changed)
connect_destroy(library, 'added', self.__added)
connect_destroy(library, 'removed', self.__removed)
self.connect('destroy', self.__destroy)
# contains the panes and the song list
self.main_box = qltk.ConfigRPaned("browsers", "panedbrowser_pos", 0.4)
self.pack_start(self.main_box, True, True, 0)
self.multi_paned = ConfigMultiRHPaned("browsers",
"panedbrowser_pane_widths")
self.refresh_panes()
for child in self.get_children():
child.show_all()
示例5: __init__
# 需要導入模塊: from quodlibet.qltk.searchbar import SearchBarBox [as 別名]
# 或者: from quodlibet.qltk.searchbar.SearchBarBox import connect [as 別名]
def __init__(self, library):
super(CollectionBrowser, self).__init__(spacing=6)
self.set_orientation(Gtk.Orientation.VERTICAL)
self._register_instance()
if self.__model is None:
self._init_model(library)
sw = ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
self.view = view = CollectionView()
view.set_headers_visible(False)
model_sort = CollectionSortModel(model=self.__model)
model_filter = CollectionFilterModel(child_model=model_sort)
self.__filter = None
self.__bg_filter = background_filter()
model_filter.set_visible_func(self.__parse_query)
view.set_model(model_filter)
def sort(model, i1, i2, data):
t1, t2 = model[i1][0], model[i2][0]
if t1 is None or t2 is None:
# FIXME: why?
return 0
# FIXME: order this deterministically
if t1 is MultiNode or t1 is UnknownNode or \
t2 is MultiNode or t2 is UnknownNode:
return -cmp(t1, t2)
if not isinstance(t1, Album):
return cmp(util.human_sort_key(t1), util.human_sort_key(t2))
a1, a2 = t1, t2
return (cmp(a1.peoplesort and a1.peoplesort[0],
a2.peoplesort and a2.peoplesort[0]) or
cmp(a1.date or "ZZZZ", a2.date or "ZZZZ") or
cmp((a1.sort, a1.key), (a2.sort, a2.key)))
model_sort.set_sort_func(0, sort)
model_sort.set_sort_column_id(0, Gtk.SortType.ASCENDING)
column = Gtk.TreeViewColumn("albums")
def cell_data(column, cell, model, iter_, data):
markup = model.get_markup(self.__model.tags, iter_)
cell.markup = markup
cell.set_property('markup', markup)
def get_scaled_cover(album):
# XXX: Cache this somewhere else
cover = None
if not hasattr(album, "_scaled_cover"):
scale_factor = self.get_scale_factor()
album.scan_cover(scale_factor=scale_factor)
if album.cover:
s = 25 * scale_factor
cover = scale(album.cover, (s, s))
album._scaled_cover = cover
else:
cover = album._scaled_cover
return cover
def cell_data_pb(column, cell, model, iter_, data):
album = model.get_album(iter_)
if album is None:
cell.set_property('icon-name', Icons.FOLDER)
else:
cover = get_scaled_cover(album)
if cover:
cover = add_border_widget(cover, view)
surface = get_surface_for_pixbuf(self, cover)
cell.set_property("surface", surface)
else:
cell.set_property('icon-name', Icons.MEDIA_OPTICAL)
imgrender = Gtk.CellRendererPixbuf()
render = Gtk.CellRendererText()
if view.supports_hints():
render.set_property('ellipsize', Pango.EllipsizeMode.END)
column.pack_start(imgrender, False)
column.pack_start(render, True)
column.set_cell_data_func(render, cell_data)
column.set_cell_data_func(imgrender, cell_data_pb)
view.append_column(column)
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(view)
hbox = Gtk.HBox(spacing=6)
prefs = Gtk.Button()
prefs.add(SymbolicIconImage(Icons.EMBLEM_SYSTEM, Gtk.IconSize.MENU))
prefs.connect('clicked', lambda *x: Preferences(self))
search = SearchBarBox(completion=AlbumTagCompletion(),
accel_group=self.accelerators)
search.connect('query-changed', self.__update_filter)
self.__search = search
#.........這裏部分代碼省略.........
示例6: __init__
# 需要導入模塊: from quodlibet.qltk.searchbar import SearchBarBox [as 別名]
# 或者: from quodlibet.qltk.searchbar.SearchBarBox import connect [as 別名]
def __init__(self, library):
super(AlbumList, self).__init__(spacing=6)
self.set_orientation(Gtk.Orientation.VERTICAL)
self._register_instance()
if self.__model is None:
self._init_model(library)
self._cover_cancel = Gio.Cancellable.new()
sw = ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
self.view = view = AllTreeView()
view.set_headers_visible(False)
model_sort = AlbumSortModel(model=self.__model)
model_filter = AlbumFilterModel(child_model=model_sort)
self.__bg_filter = background_filter()
self.__filter = None
model_filter.set_visible_func(self.__parse_query)
render = Gtk.CellRendererPixbuf()
self.__cover_column = column = Gtk.TreeViewColumn("covers", render)
column.set_visible(config.getboolean("browsers", "album_covers"))
column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
column.set_fixed_width(Album.COVER_SIZE + 12)
render.set_property('height', Album.COVER_SIZE + 8)
render.set_property('width', Album.COVER_SIZE + 8)
def cell_data_pb(column, cell, model, iter_, no_cover):
album = model.get_album(iter_)
if album is None:
pixbuf = None
elif album.cover:
pixbuf = album.cover
round_ = config.getboolean("albumart", "round")
pixbuf = add_border_widget(pixbuf, self.view, round_)
pixbuf = get_pbosf_for_pixbuf(self, pixbuf)
# don't cache, too much state has an effect on the result
self.__last_render_pb = None
else:
pixbuf = no_cover
if self.__last_render_pb == pixbuf:
return
self.__last_render_pb = pixbuf
set_renderer_from_pbosf(cell, pixbuf)
column.set_cell_data_func(render, cell_data_pb, self._no_cover)
view.append_column(column)
render = Gtk.CellRendererText()
column = Gtk.TreeViewColumn("albums", render)
column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
if view.supports_hints():
render.set_property('ellipsize', Pango.EllipsizeMode.END)
def cell_data(column, cell, model, iter_, data):
album = model.get_album(iter_)
if album is None:
text = "<b>%s</b>" % _("All Albums")
text += "\n" + ngettext("%d album", "%d albums",
len(model) - 1) % (len(model) - 1)
markup = text
else:
markup = self.display_pattern % album
if self.__last_render == markup:
return
self.__last_render = markup
cell.markup = markup
cell.set_property('markup', markup)
column.set_cell_data_func(render, cell_data)
view.append_column(column)
view.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
view.set_rules_hint(True)
view.set_search_equal_func(self.__search_func, None)
view.set_search_column(0)
view.set_model(model_filter)
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(view)
view.connect('row-activated', self.__play_selection)
self.__sig = view.connect('selection-changed',
util.DeferredSignal(self.__update_songs, owner=view))
targets = [("text/x-quodlibet-songs", Gtk.TargetFlags.SAME_APP, 1),
("text/uri-list", 0, 2)]
targets = [Gtk.TargetEntry.new(*t) for t in targets]
view.drag_source_set(
Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.COPY)
view.connect("drag-data-get", self.__drag_data_get)
connect_obj(view, 'popup-menu', self.__popup, view, library)
self.accelerators = Gtk.AccelGroup()
#.........這裏部分代碼省略.........
示例7: __init__
# 需要導入模塊: from quodlibet.qltk.searchbar import SearchBarBox [as 別名]
# 或者: from quodlibet.qltk.searchbar.SearchBarBox import connect [as 別名]
def __init__(self, library):
Browser.__init__(self, spacing=6)
self.set_orientation(Gtk.Orientation.VERTICAL)
self._register_instance()
if self.__model is None:
self._init_model(library)
self._cover_cancel = Gio.Cancellable.new()
self.scrollwin = sw = ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
model_sort = AlbumSortModel(model=self.__model)
model_filter = AlbumFilterModel(child_model=model_sort)
self.view = view = Gtk.IconView(model_filter)
#view.set_item_width(get_cover_size() + 12)
self.view.set_row_spacing(config.getint("browsers", "row_spacing", 6))
self.view.set_column_spacing(config.getint("browsers",
"column_spacing", 6))
self.view.set_item_padding(config.getint("browsers",
"item_padding", 6))
self.view.set_has_tooltip(True)
self.view.connect("query-tooltip", self._show_tooltip)
self.__bg_filter = background_filter()
self.__filter = None
model_filter.set_visible_func(self.__parse_query)
mag = config.getfloat("browsers", "covergrid_magnification", 3.)
self.view.set_item_width(get_cover_size() * mag + 8)
self.__cover = render = Gtk.CellRendererPixbuf()
render.set_property('width', get_cover_size() * mag + 8)
render.set_property('height', get_cover_size() * mag + 8)
view.pack_start(render, False)
def cell_data_pb(view, cell, model, iter_, no_cover):
item = model.get_value(iter_)
if item.album is None:
surface = None
elif item.cover:
pixbuf = item.cover
pixbuf = add_border_widget(pixbuf, self.view)
surface = get_surface_for_pixbuf(self, pixbuf)
# don't cache, too much state has an effect on the result
self.__last_render_surface = None
else:
surface = no_cover
if self.__last_render_surface == surface:
return
self.__last_render_surface = surface
cell.set_property("surface", surface)
view.set_cell_data_func(render, cell_data_pb, self._no_cover)
self.__text_cells = render = Gtk.CellRendererText()
render.set_visible(config.getboolean("browsers", "album_text", True))
render.set_property('alignment', Pango.Alignment.CENTER)
render.set_property('xalign', 0.5)
render.set_property('ellipsize', Pango.EllipsizeMode.END)
view.pack_start(render, False)
def cell_data(view, cell, model, iter_, data):
album = model.get_album(iter_)
if album is None:
text = "<b>%s</b>" % _("All Albums")
text += "\n" + ngettext("%d album", "%d albums",
len(model) - 1) % (len(model) - 1)
markup = text
else:
markup = self.display_pattern % album
if self.__last_render == markup:
return
self.__last_render = markup
cell.markup = markup
cell.set_property('markup', markup)
view.set_cell_data_func(render, cell_data, None)
view.set_selection_mode(Gtk.SelectionMode.MULTIPLE)
sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
sw.add(view)
view.connect('item-activated', self.__play_selection, None)
self.__sig = connect_destroy(
view, 'selection-changed',
util.DeferredSignal(self.__update_songs, owner=self))
targets = [("text/x-quodlibet-songs", Gtk.TargetFlags.SAME_APP, 1),
("text/uri-list", 0, 2)]
targets = [Gtk.TargetEntry.new(*t) for t in targets]
view.drag_source_set(
Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.COPY)
#.........這裏部分代碼省略.........
示例8: __init__
# 需要導入模塊: from quodlibet.qltk.searchbar import SearchBarBox [as 別名]
# 或者: from quodlibet.qltk.searchbar.SearchBarBox import connect [as 別名]
def __init__(self, library, main):
super(CollectionBrowser, self).__init__(spacing=6)
self._register_instance()
if self.__model is None:
self._init_model(library)
sw = ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_IN)
self.view = view = CollectionView()
view.set_headers_visible(False)
model_sort = gtk.TreeModelSort(self.__model)
model_filter = model_sort.filter_new()
self.__filter = None
self.__bg_filter = background_filter()
model_filter.set_visible_func(self.__parse_query)
view.set_model(model_filter)
def sort(model, i1, i2):
t1, t2 = model[i1][0], model[i2][0]
if t1 is None or t2 is None:
# FIXME: why?
return 0
# FIXME: order this deterministically
if t1 is MultiNode or t1 is UnknownNode or \
t2 is MultiNode or t2 is UnknownNode:
return -cmp(t1, t2)
if not isinstance(t1, Album):
return cmp(util.human_sort_key(t1), util.human_sort_key(t2))
a1, a2 = t1, t2
return (cmp(a1.peoplesort and a1.peoplesort[0],
a2.peoplesort and a2.peoplesort[0]) or
cmp(a1.date or "ZZZZ", a2.date or "ZZZZ") or
cmp((a1.sort, a1.key), (a2.sort, a2.key)))
model_sort.set_sort_func(0, sort)
model_sort.set_sort_column_id(0, gtk.SORT_ASCENDING)
column = gtk.TreeViewColumn("albums")
def cell_data(column, cell, model, iter_):
markup = StoreUtils.get_markup(model, self.__model.tags, iter_)
cell.markup = markup
cell.set_property('markup', markup)
def cell_data_pb(column, cell, model, iter_):
album = StoreUtils.get_album(model, iter_)
if album is None:
cell.set_property('stock_id', gtk.STOCK_DIRECTORY)
else:
album.scan_cover()
if album.cover:
cell.set_property('pixbuf', scale(album.cover, (25, 25)))
else:
cell.set_property('stock_id', gtk.STOCK_CDROM)
imgrender = gtk.CellRendererPixbuf()
render = gtk.CellRendererText()
render.set_property('ellipsize', pango.ELLIPSIZE_END)
column.pack_start(imgrender, False)
column.pack_start(render, True)
column.set_cell_data_func(render, cell_data)
column.set_cell_data_func(imgrender, cell_data_pb)
view.append_column(column)
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.add(view)
hbox = gtk.HBox(spacing=6)
prefs = gtk.Button()
prefs.add(gtk.image_new_from_stock(
gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU))
prefs.connect('clicked', Preferences)
search = SearchBarBox(button=False, completion=AlbumTagCompletion(),
accel_group=self.accelerators)
search.connect('query-changed', self.__update_filter)
hbox.pack_start(search)
hbox.pack_start(prefs, expand=False)
if main:
self.pack_start(Alignment(hbox, left=3, top=3), expand=False)
else:
self.pack_start(hbox, expand=False)
self.pack_start(sw, expand=True)
view.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
self.__sig = view.get_selection().connect('changed',
self.__selection_changed)
view.connect('row-activated', self.__play, main)
view.connect_object('popup-menu', self.__popup, view, library)
targets = [("text/x-quodlibet-songs", gtk.TARGET_SAME_APP, 1),
("text/uri-list", 0, 2)]
#.........這裏部分代碼省略.........
示例9: __init__
# 需要導入模塊: from quodlibet.qltk.searchbar import SearchBarBox [as 別名]
# 或者: from quodlibet.qltk.searchbar.SearchBarBox import connect [as 別名]
def __init__(self, library):
super(CollectionBrowser, self).__init__(spacing=6)
self.set_orientation(Gtk.Orientation.VERTICAL)
self._register_instance()
if self.__model is None:
self._init_model(library)
sw = ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
self.view = view = CollectionView()
view.set_headers_visible(False)
model_sort = CollectionSortModel(model=self.__model)
model_filter = CollectionFilterModel(child_model=model_sort)
self.__filter = None
self.__bg_filter = background_filter()
model_filter.set_visible_func(self.__parse_query)
view.set_model(model_filter)
def cmpa(a, b):
"""Like cmp but treats values that evaluate to false as inf"""
if not a and b:
return 1
if not b and a:
return -1
return cmp(a, b)
def cmp_rows(model, i1, i2, data):
t1, t2 = model[i1][0], model[i2][0]
pos1 = _ORDERING.get(t1, 0)
pos2 = _ORDERING.get(t2, 0)
if pos1 or pos2:
return cmp(pos1, pos2)
if not isinstance(t1, AlbumNode):
return cmp(util.human_sort_key(t1), util.human_sort_key(t2))
a1, a2 = t1.album, t2.album
return (cmpa(a1.peoplesort, a2.peoplesort) or
cmpa(a1.date, a2.date) or
cmpa(a1.sort, a2.sort) or
cmp(a1.key, a2.key))
model_sort.set_sort_func(0, cmp_rows)
model_sort.set_sort_column_id(0, Gtk.SortType.ASCENDING)
column = Gtk.TreeViewColumn("albums")
def cell_data(column, cell, model, iter_, data):
markup = model.get_markup(self.__model.tags, iter_)
cell.markup = markup
cell.set_property('markup', markup)
def get_scaled_cover(item):
if item.scanned:
return item.cover
scale_factor = self.get_scale_factor()
item.scan_cover(scale_factor=scale_factor)
return item.cover
def cell_data_pb(column, cell, model, iter_, data):
album = model.get_album(iter_)
if album is None:
cell.set_property('icon-name', Icons.FOLDER)
else:
item = model.get_value(iter_)
cover = get_scaled_cover(item)
if cover:
cover = add_border_widget(cover, view)
surface = get_surface_for_pixbuf(self, cover)
cell.set_property("surface", surface)
else:
cell.set_property('icon-name', Icons.MEDIA_OPTICAL)
imgrender = Gtk.CellRendererPixbuf()
render = Gtk.CellRendererText()
if view.supports_hints():
render.set_property('ellipsize', Pango.EllipsizeMode.END)
column.pack_start(imgrender, False)
column.pack_start(render, True)
column.set_cell_data_func(render, cell_data)
column.set_cell_data_func(imgrender, cell_data_pb)
view.append_column(column)
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(view)
hbox = Gtk.HBox(spacing=6)
prefs = Gtk.Button()
prefs.add(SymbolicIconImage(Icons.EMBLEM_SYSTEM, Gtk.IconSize.MENU))
prefs.connect('clicked', lambda *x: Preferences(self))
self.accelerators = Gtk.AccelGroup()
search = SearchBarBox(completion=AlbumTagCompletion(),
accel_group=self.accelerators)
search.connect('query-changed', self.__update_filter)
connect_obj(search, 'focus-out', lambda w: w.grab_focus(), view)
self.__search = search
#.........這裏部分代碼省略.........