本文整理汇总了Python中foobnix.helpers.menu.Popup.clear方法的典型用法代码示例。如果您正苦于以下问题:Python Popup.clear方法的具体用法?Python Popup.clear怎么用?Python Popup.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类foobnix.helpers.menu.Popup
的用法示例。
在下文中一共展示了Popup.clear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LastFmIntegrationControls
# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import clear [as 别名]
class LastFmIntegrationControls(CommonTreeControl):
def __init__(self, controls):
CommonTreeControl.__init__(self, controls)
"""column config"""
column = Gtk.TreeViewColumn(_("Lasm.fm Integration ") + FCBase().lfm_login,
self.ellipsize_render, text=self.text[0], font=self.font[0])
column.set_resizable(True)
self.set_headers_visible(True)
self.append_column(column)
self.tree_menu = Popup()
self.configure_send_drag()
self.configure_recive_drag()
self.set_type_tree()
self.services = {_("My recommendations"): self.controls.lastfm_service.get_recommended_artists,
_("My loved tracks"): self.controls.lastfm_service.get_loved_tracks,
_("My top tracks"): self.controls.lastfm_service.get_top_tracks,
_("My recent tracks"): self.controls.lastfm_service.get_recent_tracks,
_("My top artists"): self.controls.lastfm_service.get_top_artists,
_("My events"): self.controls.lastfm_service.get_events,
_("My friends"): self.controls.lastfm_service.get_friends,
_("My neighbours"): self.controls.lastfm_service.get_neighbours
}
for name in self.services:
parent = FModel(name)
bean = FDModel(_("loading...")).parent(parent).add_is_file(True)
self.append(parent)
self.append(bean)
def on_button_press(self, w, e):
if is_empty_click(w, e):
w.get_selection().unselect_all()
if is_rigth_click(e):
right_click_optimization_for_trees(w, e)
active = self.get_selected_bean()
self.tree_menu.clear()
self.tree_menu.add_item(_('Play'), "media-playback-start", self.controls.play, active)
self.tree_menu.add_item(_('Copy to Search Line'), "edit-copy",
self.controls.searchPanel.set_search_text, active.text)
self.tree_menu.show(e)
def on_bean_expanded(self, parent):
logging.debug("expanded %s" % parent)
def task():
old_iters = self.get_child_iters_by_parent(self.model, self.get_iter_from_bean(parent))
childs = self.services[parent.text](FCBase().lfm_login, str(int(FC().search_limit)))
update_parent_for_beans(childs, parent)
self.append_all(childs)
GLib.idle_add(self.remove_iters, old_iters)
self.controls.in_thread.run_with_spinner(task)
示例2: PlaylistTreeControl
# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import clear [as 别名]
#.........这里部分代码省略.........
self.scroll_to_cell(path)
def append(self, paths):
for i, path in enumerate(paths):
if os.path.isdir(path):
listdir = filter(lambda x: get_file_extension(x) in FC().all_support_formats or os.path.isdir(x),
[os.path.join(path, f) for f in os.listdir(path)])
for k, p in enumerate(listdir):
paths.insert(i + k + 1, p)
rows = self.file_paths_to_rows(paths)
if not rows:
return
#rows = self.playlist_filter(rows)
for row in rows:
self.model.append(None, row)
thread.start_new_thread(self.safe_fill_treerows, ())
def is_empty(self):
return True if not self.model.get_iter_first() else False
def on_button_press(self, w, e):
if self.header_pressed:
self.header_pressed = False
return
if is_empty_click(w, e):
w.get_selection().unselect_all()
if is_double_left_click(e):
self.controls.play_selected_song()
if is_rigth_click(e):
right_click_optimization_for_trees(w, e)
beans = self.get_selected_beans()
if beans:
self.tree_menu.clear()
self.tree_menu.add_item(_('Play'), "media-playback-start", self.controls.play_selected_song, None)
self.tree_menu.add_item(_('Delete from playlist'), "edit-delete", self.delete_selected, None)
paths = []
inet_paths = []
local_paths = []
for bean in beans:
if bean.path in paths:
continue
paths.append(bean.path)
if not bean.path or bean.path.startswith("http://"):
inet_paths.append(bean.path)
else:
local_paths.append(bean.path)
if local_paths:
self.tree_menu.add_item(_('Copy To...'), "list-add", copy_to, local_paths)
self.tree_menu.add_item(_("Open in file manager"), None, open_in_filemanager, local_paths[0])
if inet_paths:
self.tree_menu.add_item(_('Download'), "list-add",
self.controls.dm.append_tasks, self.get_all_selected_beans())
self.tree_menu.add_item(_('Download To...'), "list-add",
self.controls.dm.append_tasks_with_dialog, self.get_all_selected_beans())
self.tree_menu.add_separator()
if local_paths:
self.tree_menu.add_item(_('Edit Tags'), "accessories-text-editor", edit_tags, (self.controls, local_paths))
self.tree_menu.add_item(_('Format Converter'), "applications-utilities", convert_files, local_paths)
text = self.get_selected_bean().text
self.tree_menu.add_item(_('Copy To Search Line'), "edit-copy",
self.controls.searchPanel.set_search_text, text)
示例3: NavigationTreeControl
# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import clear [as 别名]
class NavigationTreeControl(CommonTreeControl, LoadSave):
def __init__(self, controls):
CommonTreeControl.__init__(self, controls)
self.controls = controls
self.full_name = ""
self.label = Gtk.Label()
self.tree_menu = Popup()
self.set_headers_visible(True)
self.set_headers_clickable(True)
"""column config"""
self.column = Gtk.TreeViewColumn("File", Gtk.CellRendererText(), text=self.text[0], font=self.font[0])
self._append_column(self.column, _("File"))
def func(column, cell, model, iter, ext=False):
try:
data = model.get_value(iter, self.text[0])
except TypeError:
data = None
pass
if not model.get_value(iter, self.path[0]):
cell.set_property('text', '')
return
if os.path.isfile(model.get_value(iter, self.path[0])):
if data:
if ext:
cell.set_property('text', os.path.splitext(data)[1][1:])
else:
cell.set_property('text', os.path.splitext(data)[0])
else:
if ext:
cell.set_property('text', '')
self.name_column = Gtk.TreeViewColumn("Name", Gtk.CellRendererText(), text=self.text[0], font=self.font[0])
self.name_column.set_sizing(Gtk.TREE_VIEW_COLUMN_FIXED)
for rend in self.name_column.get_cells():
self.name_column.set_cell_data_func(rend, func, False)
self._append_column(self.name_column, _("Name"))
self.ext_column = Gtk.TreeViewColumn("Ext", Gtk.CellRendererText(), text=self.text[0], font=self.font[0])
for rend in self.ext_column.get_cells():
self.ext_column.set_cell_data_func(rend, func, True)
self._append_column(self.ext_column, _("Ext"))
self.configure_send_drag()
self.configure_recive_drag()
self.set_type_tree()
#self.is_empty = False
self.connect("button-release-event", self.on_button_release)
self.connect("drag-data-get", self.on_drag_data_get)
'''to force the ext_column to take the minimum size'''
self.name_column.set_fixed_width(2000)
def task(*a):
self.on_click_header(None, None, on_start=True)
GLib.idle_add(task)
self.scroll.get_vscrollbar().connect('show', task)
self.scroll.get_vscrollbar().connect('hide', task)
def on_button_release(self, w, e):
if is_middle_click_release(e):
# on left click add selected items to current tab
"""to select item under cursor"""
try:
path, col, cellx, celly = self.get_path_at_pos(int(e.x), int(e.y)) # @UnusedVariable
self.get_selection().select_path(path)
except TypeError:
pass
self.add_to_tab(True)
return
def on_button_press(self, w, e):
if is_empty_click(w, e):
w.get_selection().unselect_all()
if is_middle_click(e):
"""to avoid unselect all selected items"""
self.stop_emission('button-press-event')
if is_left_click(e):
# on left click expand selected folders
return
if is_double_left_click(e):
# on middle click play selected beans
self.add_to_tab()
return
if is_rigth_click(e):
right_click_optimization_for_trees(w, e)
tabhelper = self.controls.perspectives.get_perspective('fs').get_tabhelper()
# on right click, show pop-up menu
self.tree_menu.clear()
self.tree_menu.add_item(_("Append to playlist"), Gtk.STOCK_ADD, lambda: self.add_to_tab(True), None)
self.tree_menu.add_item(_("Open in new playlist"), Gtk.STOCK_MEDIA_PLAY, self.add_to_tab, None)
self.tree_menu.add_separator()
#.........这里部分代码省略.........
示例4: VKIntegrationControls
# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import clear [as 别名]
class VKIntegrationControls(CommonTreeControl):
def __init__(self, controls):
CommonTreeControl.__init__(self, controls)
"""column config"""
column = Gtk.TreeViewColumn(_("VK Integration "), self.ellipsize_render, text=self.text[0], font=self.font[0])
column.set_resizable(True)
self.set_headers_visible(True)
self.append_column(column)
self.tree_menu = Popup()
self.configure_send_drag()
self.configure_recive_drag()
self.set_type_tree()
self.lazy = False
self.cache = []
def lazy_load(self):
if not self.lazy:
self.controls.in_thread.run_with_spinner(self._lazy_load)
def _lazy_load(self):
def get_users_by_uuid(uuidd):
for user in self.controls.vk_service.get_result('getProfiles', 'uids=' + uuidd):
def task(user):
logging.debug(user)
name = user['first_name'] + " " + user['last_name']
parent = FModel(name)
parent.user_id = user['uid']
bean = FDModel(_("loading...")).parent(parent).add_is_file(True)
self.append(parent)
self.append(bean)
GLib.idle_add(task, user)
if not FC().user_id and not self.controls.vk_service.auth():
return
get_users_by_uuid(FC().user_id)
uids = self.controls.vk_service.get_result('friends.get', 'uid=' + FC().user_id)
if uids:
get_users_by_uuid(",".join(["%s" % i for i in uids]))
self.lazy = True
def on_button_press(self, w, e):
if is_empty_click(w, e):
w.get_selection().unselect_all()
if is_rigth_click(e):
right_click_optimization_for_trees(w, e)
active = self.get_selected_bean()
if active:
self.tree_menu.clear()
if isinstance(active, FModel) and active.path:
self.tree_menu.add_item(_('Play'), "media-playback-start", self.controls.play, active)
self.tree_menu.add_item(_('Copy to Search Line'), "edit-copy", self.controls.searchPanel.set_search_text, active.text)
self.tree_menu.show(e)
if is_double_left_click(e):
selected = self.get_selected_bean()
if not selected:
return
def task():
if (selected.user_id not in self.cache) and (not selected.is_file):
beans = self.get_user_tracks_as_beans(selected.user_id)
else:
beans = self.get_all_child_beans_by_selected()
self.controls.notetabs.append_tab(selected.text, [selected] + beans, optimization=True)
self.controls.play_first_file_in_playlist()
self.controls.in_thread.run_with_spinner(task)
def on_row_expanded(self, widget, iter, path):
self.on_bean_expanded(iter)
def get_user_tracks_as_beans(self, user_id):
beans = []
result = self.controls.vk_service.get_result('audio.get', "uid=" + user_id)
if not result:
beans = [FDModel(_("No results found")).add_is_file(True)]
else:
for line in result:
bean = FModel(line['artist'] + ' - ' + line['title'])
bean.aritst = line['artist']
bean.title = line['title']
bean.time = convert_seconds_to_text(line['duration'])
bean.path = line['url']
bean.aid = line['aid']
bean.oid = line['owner_id']
bean.is_file = True
bean.vk_audio_id = "%s_%s" % (line['owner_id'], line['aid'])
beans.append(bean)
return beans
def on_bean_expanded(self, parent_iter):
logging.debug("expanded %s" % parent_iter)
#.........这里部分代码省略.........
示例5: DownloadManagerTreeControl
# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import clear [as 别名]
class DownloadManagerTreeControl(CommonTreeControl):
def __init__(self, navigation):
self.navigation = navigation
CommonTreeControl.__init__(self, None)
self.set_reorderable(False)
self.set_headers_visible(True)
self.tree_menu = Popup()
"""column config"""
column = Gtk.TreeViewColumn(_("Name"), self.ellipsize_render, text=self.text[0])
column.set_resizable(True)
self.append_column(column)
"""column config"""
column = Gtk.TreeViewColumn(_("Progress"), Gtk.CellRendererProgress(), text=self.persent[0], value=self.persent[0])
column.set_resizable(True)
self.append_column(column)
"""column config"""
column = Gtk.TreeViewColumn(_("Size"), self.ellipsize_render, text=self.size[0])
column.set_resizable(True)
self.append_column(column)
"""status"""
column = Gtk.TreeViewColumn(_("Status"), self.ellipsize_render, text=self.status[0])
column.set_resizable(True)
self.append_column(column)
"""column config"""
column = Gtk.TreeViewColumn(_("Path"), self.ellipsize_render, text=self.save_to[0])
column.set_resizable(True)
column.set_expand(True)
self.append_column(column)
self.set_type_plain()
@idle_task
def delete_all(self):
self.clear()
@idle_task
def delete_all_selected(self):
self.delete_selected()
@idle_task
def update_status_for_selected(self, status):
beans = self.get_all_selected_beans()
for bean in beans:
self.set_bean_column_value(bean, FTreeModel().status[0], status)
@idle_task
def update_status_for_all(self, status):
beans = self.get_all_beans()
for bean in beans:
self.set_bean_column_value(bean, FTreeModel().status[0], status)
@idle_task
def update_status_for_beans(self, beans, status):
for bean in beans:
self.set_bean_column_value(bean, FTreeModel().status[0], status)
def get_next_bean_to_dowload(self):
all = self.get_all_beans()
if not all:
return None
for bean in all:
if bean.get_status() == DOWNLOAD_STATUS_ACTIVE:
self.set_bean_column_value(bean, FTreeModel().status[0], DOWNLOAD_STATUS_LOCK)
return bean
@idle_task
def update_bean_info(self, bean):
self.update_bean(bean)
self.navigation.update_statistics()
#self.navigation.use_filter()
def on_button_press(self, w, e):
logging.debug("on dm button press")
if is_empty_click(w, e):
w.get_selection().unselect_all()
if is_rigth_click(e):
right_click_optimization_for_trees(w, e)
try:
self.tree_menu.clear()
if self.get_selected_bean():
self.tree_menu.add_item(_("Open in file manager"), None, open_in_filemanager, self.get_selected_bean().path)
else:
self.tree_menu.add_item(_("Open in file manager"), None, open_in_filemanager, FC().online_save_to_folder)
self.tree_menu.show(e)
except Exception, e:
logging.error(e)
示例6: VirtualTreeControl
# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import clear [as 别名]
class VirtualTreeControl(CommonTreeControl, LoadSave):
def __init__(self, controls):
CommonTreeControl.__init__(self, controls)
"""column config"""
column = Gtk.TreeViewColumn(_("Storage"), self.ellipsize_render, text=self.text[0], font=self.font[0])
column.set_resizable(True)
self.set_headers_visible(True)
self.append_column(column)
self.tree_menu = Popup()
self.configure_send_drag()
self.configure_recive_drag()
self.set_type_tree()
def on_key_release(self, w, e):
if is_key(e, KEY_DELETE):
self.delete_selected()
def on_drag_drop_finish(self):
FCache().cache_virtual_tree_beans = self.get_all_beans()
FC().save()
def on_button_press(self, w, e):
if is_empty_click(w, e):
w.get_selection().unselect_all()
if is_double_left_click(e):
selected = self.get_selected_bean()
beans = self.get_all_child_beans_by_selected()
self.controls.notetabs._append_tab(selected.text, [selected] + beans, optimization=True)
self.controls.play_first_file_in_playlist()
if is_rigth_click(e):
right_click_optimization_for_trees(w, e)
self.tree_menu.clear()
self.tree_menu.add_item(_("Add playlist"), Gtk.STOCK_ADD, self.create_playlist, None)
bean = self.get_selected_bean()
if bean:
if bean.is_file:
self.tree_menu.add_item(_("Rename"), Gtk.STOCK_EDIT, self.rename_selected, None)
self.tree_menu.add_item(_("Delete"), Gtk.STOCK_DELETE, self.delete_selected, None)
else:
self.tree_menu.add_item(_("Rename playlist"), Gtk.STOCK_EDIT, self.rename_selected, None)
self.tree_menu.add_item(_("Delete playlist"), Gtk.STOCK_DELETE, self.delete_selected, None)
#menu.add_item(_("Save as"), Gtk.STOCK_SAVE_AS, None, None)
#menu.add_item(_("Open as"), Gtk.STOCK_OPEN, None, None)
self.tree_menu.show(e)
def create_playlist(self):
name = one_line_dialog(_("Create new playlist"), self.controls.main_window, message_text1=_("Enter playlist name"))
if not name:
return
bean = self.get_selected_bean()
folder_bean = FModel(name)
if bean:
if bean.is_file:
folder_bean.add_parent(bean.parent_level)
else:
folder_bean.add_parent(bean.level)
self.append(folder_bean)
def rename_selected(self):
bean = self.get_selected_bean()
name = one_line_dialog(_("Rename Dialog"), self.controls.main_window,
entry_text=bean.text, message_text1=_("Enter new name"))
if not name:
return
rows = self.find_rows_by_element(self.UUID, bean.UUID)
if rows:
rows[0][self.text[0]] = name
def on_load(self):
self.scroll.hide()
self.restore_rows(FCache().cache_virtual_tree_beans)
self.restore_expand(FC().virtual_expand_paths)
self.restore_selection(FC().virtual_selected_paths)
def set_expand_path(new_value):
FC().virtual_expand_paths = new_value
def set_selected_path(new_value):
FC().virtual_selected_paths = new_value
self.expand_updated(set_expand_path)
self.selection_changed(set_selected_path)
def on_quit(self):
self.save_rows_from_tree(FCache().cache_virtual_tree_beans)
def on_drag_data_received(self, treeview, context, x, y, selection, info, timestamp):
logging.debug('Storage on_drag_data_received')
model = self.get_model().get_model()
drop_info = self.get_dest_row_at_pos(x, y)
# ff - from_filter
ff_tree = Gtk.drag_get_source_widget(context)
ff_model, ff_paths = ff_tree.get_selection().get_selected_rows()
#.........这里部分代码省略.........
示例7: RadioTreeControl
# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import clear [as 别名]
class RadioTreeControl(CommonTreeControl):
def __init__(self, controls):
CommonTreeControl.__init__(self, controls)
self.set_reorderable(False)
self.switcher_label = _("My channels")
self.tree_menu = Popup()
"""column config"""
column = Gtk.TreeViewColumn(_("Radio Stations"), Gtk.CellRendererText(), text=self.text[0], font=self.font[0])
column.set_resizable(True)
self.set_headers_visible(True)
self.append_column(column)
self.configure_send_drag()
self.configure_recive_drag()
self.set_type_tree()
@idle_task
def on_load(self):
if FCache().cache_radio_tree_beans:
self.restore_rows(FCache().cache_radio_tree_beans)
else:
self.update_radio_tree()
def on_button_press(self, w, e):
if is_double_left_click(e):
selected = self.get_selected_bean()
beans = self.get_all_child_beans_by_selected()
self.controls.notetabs._append_tab(selected.text, [selected] + beans, optimization=True)
"run radio channel"
self.controls.play_first_file_in_playlist()
if is_rigth_click(e):
right_click_optimization_for_trees(w, e)
self.tree_menu.clear()
bean = self.get_selected_bean()
if bean:
if self.get_selected_bean().is_file:
self.tree_menu.add_item(_("Edit Station"), Gtk.STOCK_EDIT, self.on_edit_radio, None)
self.tree_menu.add_item(_("Delete Station"), Gtk.STOCK_DELETE, self.delete_selected, None)
else:
self.tree_menu.add_item(_("Rename Group"), Gtk.STOCK_EDIT, self.on_rename_group, None)
self.tree_menu.add_item(_("Delete Group"), Gtk.STOCK_DELETE, self.delete_selected, None)
self.tree_menu.add_separator()
self.tree_menu.add_item(_("Reload radio folder"), Gtk.STOCK_REFRESH, self.update_radio_tree, None)
self.tree_menu.show(e)
def on_edit_radio(self):
bean = self.get_selected_bean()
name, url = two_line_dialog(_("Edit Radio"),
parent = self.controls.main_window,
message_text1 = _("Enter new name and URL"),
message_text2 = None,
entry_text1=bean.text,
entry_text2 = bean.path)
if not name or not url:
return
bean.add_text(name)
bean.add_path(url)
rows = self.find_rows_by_element(self.UUID, bean.UUID)
if rows:
rows[0][self.text[0]] = name
rows[0][self.path[0]] = url
def on_rename_group(self):
bean = self.get_selected_bean()
name = one_line_dialog(_("Rename Group"), self.controls.main_window,
entry_text=bean.text, message_text1=_("Enter new group name"))
if not name:
return
rows = self.find_rows_by_element(self.UUID, bean.UUID)
if rows:
rows[0][self.text[0]] = name
def on_add_station(self):
name, url = two_line_dialog(_("Add New Radio Station"),
parent = self.controls.main_window,
message_text1 = _("Enter station name and URL"),
message_text2 = None,
entry_text1 = None,
entry_text2 = "http://")
if not name or not url:
return
bean = self.get_selected_bean()
new_bean = FModel(name, url).add_type(FTYPE_RADIO).add_is_file(True)
if bean:
if bean.is_file:
new_bean.add_parent(bean.parent_level)
else:
new_bean.add_parent(bean.level)
self.append(new_bean)
def on_save(self):
pass
#def update_radio_tree(self):
# self.controls.in_thread.run_with_progressbar(self._update_radio_tree)
@idle_task
#.........这里部分代码省略.........