本文整理汇总了Python中dtk.ui.treeview.TreeView.set_size_request方法的典型用法代码示例。如果您正苦于以下问题:Python TreeView.set_size_request方法的具体用法?Python TreeView.set_size_request怎么用?Python TreeView.set_size_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtk.ui.treeview.TreeView
的用法示例。
在下文中一共展示了TreeView.set_size_request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plugin_widget
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
def plugin_widget(self):
self.__get_devices()
plugin_box = gtk.VBox()
adapter_box = gtk.HBox(spacing = 5)
adapter_image = ImageBox(app_theme.get_pixbuf("bluetooth/enable_open.png"))
adapter_label = self.__setup_label(_("Adapter"))
adapter_toggle = self.__setup_toggle()
if self.my_bluetooth.adapter:
adapter_toggle.set_active(self.my_bluetooth.adapter.get_powered())
if self.my_bluetooth.adapter.get_powered():
self.tray_icon.set_icon_theme("enable")
else:
self.tray_icon.set_icon_theme("enable_disconnect")
adapter_toggle.connect("toggled", self.__adapter_toggled)
separator_align = self.__setup_align(padding_bottom = 0)
separator = self.__setup_separator()
separator_align.add(separator)
'''
devices treeview
'''
device_treeview = TreeView()
device_separator_align = self.__setup_align()
device_separator = self.__setup_separator()
device_separator_align.add(device_separator)
device_count = len(self.device_items)
if device_count:
device_treeview.delete_all_items()
device_treeview.add_items(self.device_items)
device_treeview.set_size_request(self.width, device_count * DeviceItem.ITEM_HEIGHT)
else:
device_treeview.set_child_visible(False)
device_separator_align.set_size_request(-1, 0)
device_separator_align.set_child_visible(False)
'''
select button
'''
select_button_align = self.__setup_align()
select_button = SelectButton(_("Advanced options..."),
font_size = 10,
ali_padding = 5)
select_button.set_size_request(self.width, 25)
select_button.connect("clicked", self.__bluetooth_selected) # I don't know why, but replacing "button-press-event" with
select_button_align.add(select_button) # clicked really works...
adapter_box.pack_start(adapter_image, False, False)
adapter_box.pack_start(adapter_label, False, False)
adapter_box.pack_start(adapter_toggle, False, False)
plugin_box.pack_start(adapter_box, False, False)
plugin_box.pack_start(separator_align, False, False)
plugin_box.pack_start(device_treeview, False, False)
plugin_box.pack_start(device_separator_align, False, False)
plugin_box.pack_start(select_button_align, False, False)
return plugin_box
示例2: RadioBrowser
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class RadioBrowser(gtk.VBox):
def __init__(self):
gtk.VBox.__init__(self)
# Init radiobar.
self.__init_radiobar()
# is loaded.
self.homepage_load_flag = False
self.home_page = HomePage()
self.hot_page_view, self.hot_page_sw = self.get_radio_icon_view(TAG_HOT, 20)
self.fast_page_view, self.fast_page_sw = self.get_radio_icon_view(TAG_FAST, 20)
# Genres page
self.genre_page = GenrePage()
self.page_box = gtk.VBox()
self.page_box.add(self.home_page)
self.body_paned = HPaned(handle_color=app_theme.get_color("panedHandler"))
self.body_paned.add1(self.radiobar)
self.body_paned.add2(self.page_box)
self.network_failed_box = NetworkConnectFailed(self.check_network_connection)
self.check_network_connection(auto=True)
def check_network_connection(self, auto=False):
if is_network_connected():
switch_tab(self, self.body_paned)
if not auto:
self.start_fetch_channels()
else:
switch_tab(self, self.network_failed_box)
def __init_radiobar(self):
self.radiobar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
items = []
items.append(CategroyTreeItem(_("Home"), "home", lambda : switch_tab(self.page_box, self.home_page)))
items.append(CategroyTreeItem(_("Hot MHz"), "hot", lambda : switch_tab(self.page_box, self.hot_page_sw)))
items.append(CategroyTreeItem(_("Genres MHz"), "genre", lambda : switch_tab(self.page_box, self.genre_page)))
items.append(CategroyTreeItem(_("Pop MHz"), "up", lambda : switch_tab(self.page_box, self.fast_page_sw)))
self.radiobar.add_items(items)
self.radiobar.select_items([self.radiobar.visible_items[0]])
self.radiobar.set_size_request(121, -1)
self.radiobar.draw_mask = self.on_radiobar_draw_mask
def on_radiobar_draw_mask(self, cr, x, y, w, h):
draw_alpha_mask(cr, x, y, w, h ,"layoutRight")
def get_radio_icon_view(self, tag, limit=10, padding_x=0, padding_y=10):
icon_view = RadioIconView(tag=tag, limit=limit, padding_x=padding_x, padding_y=padding_y)
scrolled_window = icon_view.get_scrolled_window()
return icon_view, scrolled_window
def start_fetch_channels(self):
self.fast_page_view.clear_items()
self.hot_page_view.clear_items()
self.home_page.start_fetch_channels()
self.hot_page_view.start_fetch_channels()
self.fast_page_view.start_fetch_channels()
self.genre_page.start_fetch_channels()
示例3: WebcastsBrowser
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
#.........这里部分代码省略.........
self.__on_db_loaded()
else:
WebcastDB.connect("loaded", lambda obj: self.__on_db_loaded())
def __on_db_loaded(self):
self.autoconnect(self.__db_query, "added", self.__on_added_songs)
self.autoconnect(self.__db_query, "removed", self.__on_removed_songs)
self.autoconnect(self.__db_query, "update-songs", self.__on_update_songs)
self.autoconnect(self.__db_query, "full-update", self.__on_full_update)
self.__db_query.set_query()
def __on_added_songs(self, db_query, songs):
self.reload_flag = True
def __on_removed_songs(self, db_query, songs):
self.reload_flag = True
def __on_update_songs(self, db_query, songs):
self.reload_flag = True
def __on_full_update(self, db_query):
self.load_view_data()
self.load_collect_data()
def __init_webcastbar(self):
self.webcastbar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
self.webcastbar.connect("single-click-item", self.on_webcastbar_single_click_item)
items = []
for category in self.__categorys:
items.append(CategoryTreeItem(self.__category_gettexts[category], category=category))
items.append(CollectTreeItem(_("Favorites")))
self.webcastbar.add_items(items)
self.webcastbar.select_items([self.webcastbar.visible_items[0]])
self.webcastbar.set_size_request(121, -1)
self.webcastbar.draw_mask = self.on_webcastbar_draw_mask
def on_webcastbar_draw_mask(self, cr, x, y, w, h):
draw_alpha_mask(cr, x, y, w, h ,"layoutRight")
def on_webcastbar_single_click_item(self, widget, item, column, x, y):
if hasattr(item, "collect_flag"):
switch_tab(self.page_box, self.collected_view_sw)
else:
widget = self.page_box.get_children()[0]
if widget != self.metro_view_sw:
switch_tab(self.page_box, self.metro_view_sw)
if self.current_category != item.category:
self.current_category = item.category
self.load_view_data()
def init_listview_page(self):
self.listview_page = gtk.VBox()
self.text_prompt = TextPrompt("Default")
prompt_align = set_widget_gravity(self.text_prompt,
paddings=(10, 10, 0, 0))
prompt_box = gtk.HBox()
back_button = BackButton()
back_button.connect("clicked", self.on_backbutton_clicked)
back_button_align = set_widget_gravity(back_button, gravity=(0.5, 0.5, 0, 0),
paddings=(0, 0, 10, 5))
prompt_box.pack_start(back_button_align, False, True)
prompt_box.pack_start(prompt_align, False, False)
self.listview_page.pack_start(prompt_box, False, True)
self.listview_page.pack_start(self.webcast_view_sw, True, True)
示例4: PreferenceDialog
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class PreferenceDialog(DialogBox):
def __init__(self):
super(PreferenceDialog, self).__init__(_("Preferences"), 575, 495,
mask_type=DIALOG_MASK_MULTIPLE_PAGE,
close_callback=self.hide_all)
self.set_position(gtk.WIN_POS_CENTER)
self.main_box = gtk.VBox()
close_button = Button(_("Close"))
close_button.connect("clicked", lambda w: self.hide_all())
# Init widget.
self.general_setting = GeneralSetting()
self.hotkey_setting = HotKeySetting()
self.desktop_lyrics_setting = DesktopLyricsSetting()
self.scroll_lyrics_setting = ScrollLyricsSetting()
self.plugins_manager = PluginsManager()
# Category bar
self.category_bar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
self.category_bar.set_expand_column(0)
self.category_bar.draw_mask = self.draw_treeview_mask
self.category_bar.set_size_request(132, 516)
self.category_bar.connect("single-click-item", self.on_categorybar_single_click)
# Init catagory bar.
self.__init_category_bar()
category_box = gtk.VBox()
background_box = BackgroundBox()
background_box.set_size_request(132, 11)
background_box.draw_mask = self.draw_treeview_mask
category_box.pack_start(background_box, False, False)
category_bar_align = gtk.Alignment()
category_bar_align.set(0, 0, 1, 1,)
category_bar_align.set_padding(0, 1, 0, 0)
category_bar_align.add(self.category_bar)
category_box.pack_start(category_bar_align, True, True)
# Pack widget.
left_box = gtk.VBox()
self.right_box = gtk.VBox()
left_box.add(category_box)
self.right_box.add(self.general_setting)
right_align = gtk.Alignment()
right_align.set_padding(0, 0, 10, 0)
right_align.add(self.right_box)
body_box = gtk.HBox()
body_box.pack_start(left_box, False, False)
body_box.pack_start(right_align, False, False)
self.main_box.add(body_box)
# DialogBox code.
self.body_box.pack_start(self.main_box, True, True)
self.right_button_box.set_buttons([close_button])
def __init_category_bar(self):
general_normal_item = NormalItem(_("General"), self.general_setting)
hotkey_normal_item = NormalItem(_("Hotkeys"), self.hotkey_setting)
self.lyrics_expand_item = ExpandItem(_("Lyrics"), None)
self.lyrics_expand_item.add_childs([(_("Desktop"), self.desktop_lyrics_setting),
(_("Window"), self.scroll_lyrics_setting)])
self.plugins_expand_item = NormalItem(_("Plugins"), self.plugins_manager)
about_normal_item = NormalItem(_("About"), AboutBox())
items = [general_normal_item,
hotkey_normal_item,
self.lyrics_expand_item,
self.plugins_expand_item,
about_normal_item]
self.category_bar.add_items(items)
self.category_bar.select_items([general_normal_item])
def switch_lyrics_page(self, index=3):
self.lyrics_expand_item.try_to_expand()
show_item = self.category_bar.visible_items[index]
self.category_bar.select_items([show_item])
self.on_categorybar_single_click(self.category_bar, show_item, None, None, None)
def show_scroll_lyrics_page(self):
self.switch_lyrics_page(4)
self.show_all()
def show_desktop_lyrics_page(self):
self.switch_lyrics_page(3)
self.show_all()
def draw_treeview_mask(self, cr, x, y, width, height):
draw_alpha_mask(cr, x, y, width, height, ("#FFFFFF", 0.9))
def on_categorybar_single_click(self, widget, item, column, x, y):
if item.allocate_widget:
switch_tab(self.right_box, item.allocate_widget)
def load_plugins(self):
self.plugins_manager.flush_plugins()
示例5: MirrorsBox
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class MirrorsBox(BaseBox):
def __init__(self):
BaseBox.__init__(self)
self.current_mirror_item = None
self.select_best_mirror_button_texts = {
"normal": _("Select the best mirror"),
"wait": _("Waiting"),
"success": _("Successfully")
}
self.main_box.pack_start(self.create_mirror_select_table(), True, True)
self.main_box.pack_start(self.create_source_update_frequency_table(), False, True)
self.mirror_test_obj = None
global_event.register_event("mirror-test-finished", self.finish_mirror_test)
global_event.register_event("cancel-mirror-test", self.cancel_mirror_test)
global_event.register_event("mirror-backend-changed", self.mirror_changed_handler)
def create_source_update_frequency_table(self):
main_table = gtk.Table(3, 2)
main_table.set_row_spacings(CONTENT_ROW_SPACING)
dir_title_label = Label(_("Refresh package lists"))
# auto update check button
self.is_auto_update_button = CheckButton(label_text=_('Upgrade automatically'))
self.is_auto_update_button.connect('released', self.change_auto_update)
self.is_auto_update_button.set_active(utils.is_auto_update())
self.update_label = Label(_("Time interval: "))
self.update_spin = SpinBox(int(get_update_interval()), 0, 168, 1)
self.update_spin.connect("value-changed", lambda w, v: set_update_interval(v))
self.hour_lablel = Label(_(" hour"))
self.hour_lablel.set_size_request(50, 12)
spin_hbox = gtk.HBox(spacing=3)
spin_hbox.pack_start(self.update_label, False, False)
spin_hbox.pack_start(self.update_spin, False, False)
spin_hbox.pack_start(self.hour_lablel, False, False)
main_table.attach(dir_title_label, 0, 2, 0, 1, yoptions=gtk.FILL)
main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
main_table.attach(self.is_auto_update_button, 0, 1, 2, 3, xoptions=gtk.FILL)
main_table.attach(spin_hbox, 1, 2, 2, 3, xpadding=10, xoptions=gtk.FILL)
return main_table
def change_auto_update(self, widget, data=None):
widget_active = widget.get_active()
self.update_spin.set_sensitive(widget_active)
self.update_label.set_sensitive(widget_active)
self.hour_lablel.set_sensitive(widget_active)
utils.set_auto_update(widget_active)
daemon_running = is_dbus_name_exists(DSC_UPDATE_DAEMON_NAME)
if widget_active and not daemon_running:
dsc_daemon_path = os.path.join(get_parent_dir(__file__, 2), 'update_data/apt/dsc-daemon.py')
subprocess.Popen(['python', dsc_daemon_path], stderr=subprocess.STDOUT, shell=False)
elif not widget_active and daemon_running:
session = dbus.SessionBus()
dbus_obj = session.get_object(DSC_UPDATE_DAEMON_NAME, DSC_UPDATE_DAEMON_PATH)
iface = dbus.Interface(dbus_obj, DSC_UPDATE_DAEMON_NAME)
iface.quit()
def select_best_mirror(self, widget):
widget.set_label(self.select_best_mirror_button_texts["wait"])
widget.set_sensitive(False)
global_event.emit("toggle-waiting-dialog", True)
utils.ThreadMethod(self.change_to_nearest_mirror_thread, (widget, )).start()
def cancel_mirror_test(self):
if self.mirror_test_obj:
self.mirror_test_obj.cancel()
self.mirror_test_obj = None
self.finish_mirror_test("")
def change_to_nearest_mirror_thread(self, widget):
from mirror_speed.ip_detect import get_nearest_mirrors
hostnames = get_nearest_mirrors()
self.mirror_test_obj = MirrorTest(hostnames)
hostname = self.mirror_test_obj.run()
for mirror in self.mirrors_list:
if mirror.hostname == hostname:
global_event.emit("mirror-test-finished", mirror)
break
def finish_mirror_test(self, mirror):
for item in self.mirror_view.visible_items:
if item.mirror == mirror:
self.mirror_view.visible_item(item)
self.select_best_mirror_button.set_sensitive(True)
self.select_best_mirror_button.set_label(self.select_best_mirror_button_texts["normal"])
def create_mirror_select_table(self):
main_table = gtk.Table(3, 2)
main_table.set_row_spacings(CONTENT_ROW_SPACING)
mirror_select_title = Label(_("Select mirror"))
self.select_best_mirror_button = Button(self.select_best_mirror_button_texts["normal"])
#.........这里部分代码省略.........
示例6: HomePage
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class HomePage(gtk.HBox):
'''
class docs
'''
def __init__(self, data_manager, recommend_status):
'''
init docs
'''
# Init.
gtk.HBox.__init__(self)
self.data_manager = data_manager
self.recommend_status = recommend_status
self.background_box = BackgroundBox()
self.background_box.draw_mask = self.draw_mask
self.sidebar_box = gtk.VBox()
self.page_box = gtk.VBox()
self.sidebar_box.set_size_request(CATEGORY_VIEW_WIDTH, -1)
self.canopy = gtk.VBox()
self.canopy.set_size_request(-1, 19)
self.search_align = gtk.Alignment()
self.search_align.set(0.5, 0.5, 0, 0)
self.search_align.set_padding(15, 5, 13, 13)
self.search_align.add(search_entry)
self.in_press = False
self.press_return = False
self.press_id = 0
self.show_timeout_id = None
self.entry_changed = False
search_entry.entry.connect("changed", self.search_entry_changed)
search_entry.entry.connect("key-press-event", self.search_entry_key_press)
search_entry.entry.connect("key-release-event", self.search_entry_key_release)
search_entry.connect("action-active", lambda entry, search_string: self.show_search_page(search_string))
search_entry.entry.connect("press-return", lambda entry: self.show_search_page(entry.get_text(), True))
self.recommend_item = RecommendItem(data_manager, self.recommend_status)
category_items = []
for (index, first_category_name) in enumerate(data_manager.get_first_category()):
category_items.append(CategoryItem(index+1, first_category_name, data_manager))
self.category_view = TreeView(
[self.recommend_item] + category_items,
enable_drag_drop=False,
enable_multiple_select=False,
expand_column=0,
)
self.category_view.draw_mask = self.draw_mask
self.category_view.set_size_request(-1, 470)
self.category_view_align = gtk.Alignment()
self.category_view_align.set(0.5, 0.5, 1, 1)
self.category_view_align.set_padding(10, 10, 0, 0)
self.category_view_align.add(self.category_view)
self.background_box.pack_start(self.canopy, False, False)
self.background_box.pack_start(self.search_align, True, True)
self.background_box.pack_end(self.category_view_align, False, False)
self.sidebar_box.pack_start(self.background_box, False, False)
self.split_line = gtk.VBox()
self.split_line.set_size_request(1, -1)
self.pack_start(self.sidebar_box, False, False)
self.pack_start(self.split_line, False, False)
self.pack_start(self.page_box, True, True)
self.canopy.connect("expose-event", self.expose_canopy)
self.split_line.connect("expose-event", self.expose_split_line)
global_event.register_event("show-pkg-view", self.show_pkg_view)
global_event.register_event("category-expand", self.category_expand_handler)
def category_expand_handler(self, item):
self.category_view.visible_item(item.child_items[-1])
def jump_to_category(self, first_category_name, second_category_name):
for item in self.category_view.visible_items:
if isinstance(item, CategoryItem) and item.is_expand:
item.unexpand()
for item in self.category_view.visible_items:
if isinstance(item, CategoryItem) and item.first_category_name == first_category_name:
item.expand()
break
for item in self.category_view.visible_items:
if isinstance(item, SecondCategoryItem) and item.second_category_name == second_category_name:
self.category_view.select_items([item])
self.category_view.visible_item(item)
item.button_press(0, 0, 0)
break
def draw_mask(self, cr, x, y, w, h):
#.........这里部分代码省略.........
示例7: DscPreferenceDialog
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class DscPreferenceDialog(PreferenceDialog):
def __init__(self):
PreferenceDialog.__init__(self, 566, 488)
self.current_mirror_item = None
self.normal_settings = gtk.VBox()
self.normal_settings.set_spacing(TABLE_ROW_SPACING)
self.normal_settings.pack_start(self.create_uninstall_box(), False, True)
self.normal_settings.pack_start(self.create_download_dir_table(), False, True)
self.normal_settings_align = gtk.Alignment(0, 0, 1, 1)
self.normal_settings_align.set_padding(padding_left=5, padding_right=5, padding_top=25, padding_bottom=10)
self.normal_settings_align.add(self.normal_settings)
self.mirror_settings = gtk.VBox()
self.mirror_settings.set_app_paintable(True)
self.mirror_settings.connect("expose-event", self.mirror_settings_align_expose)
self.mirror_settings.set_spacing(TABLE_ROW_SPACING)
self.mirror_settings.pack_start(self.create_mirror_select_table(), False, True)
self.mirror_settings.pack_start(self.create_source_update_frequency_table(), False, True)
self.mirror_settings_inner_align = gtk.Alignment(0.5, 0.5, 1, 1)
self.mirror_settings_inner_align.set_padding(padding_top=25, padding_bottom=10, padding_left=0, padding_right=0)
self.mirror_settings_inner_align.add(self.mirror_settings)
self.mirror_settings_scrolled_win = ScrolledWindow()
self.mirror_settings_scrolled_win.add_child(self.mirror_settings_inner_align)
self.mirror_settings_align = gtk.Alignment(0, 0, 1, 1)
self.mirror_settings_align.set_padding(padding_left=0, padding_right=0, padding_top=0, padding_bottom=3)
self.mirror_settings_align.add(self.mirror_settings_scrolled_win)
self.set_preference_items([
(_("General"), self.normal_settings_align),
(_("Mirrors"), self.mirror_settings_align),
(_("About"), AboutBox()),
])
def mirror_settings_align_expose(self, widget, event=None):
cr = widget.window.cairo_create()
rect = widget.allocation
# draw backgound
cr.rectangle(*rect)
#cr.set_source_rgb(*color_hex_to_cairo("#ff0000"))
cr.set_source_rgba(1, 1, 1, 0)
cr.fill()
def mirror_select_action(self, repo_urls):
self.data_manager.change_source_list(repo_urls, reply_handler=handle_dbus_reply, error_handler=handle_dbus_error)
def create_mirror_select_table(self):
vbox = gtk.VBox()
vbox.set_size_request(423, -1)
main_table = gtk.Table(2, 2)
main_table.set_row_spacings(CONTENT_ROW_SPACING)
dir_title_label = Label(_("Select mirror"))
dir_title_label.set_size_request(423, 12)
label_align = gtk.Alignment()
label_align.set_padding(0, 0, 10, 0)
label_align.add(dir_title_label)
self.mirrors_dir = os.path.join(get_parent_dir(__file__, 2), 'mirrors')
self.current_mirror_hostname = utils.get_current_mirror_hostname()
self.mirror_items = self.get_mirror_items()
self.mirror_view = TreeView(self.mirror_items,
enable_drag_drop=False,
enable_multiple_select=False,
#mask_bound_height=0,
)
self.mirror_view.set_expand_column(1)
self.mirror_view.set_size_request(-1, len(self.mirror_view.visible_items) * self.mirror_view.visible_items[0].get_height())
self.mirror_view.draw_mask = self.mirror_treeview_draw_mask
#self.display_current_mirror()
self.mirror_test_progressbar = ProgressBar()
main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
title = _("Select best mirror")
info_message = _("Please wait. The process will take 30 seconds or more depending on your network connection")
self.select_best_mirror_dialog = WaitingDialog(title, info_message, self.cancel_mirror_test)
global_event.register_event("mirror-changed", self.mirror_changed_handler)
global_event.register_event("update-list-finish", self.update_list_finish_handler)
vbox.pack_start(main_table, False, False)
vbox.pack_start(self.mirror_view, False, False)
return vbox
def cancel_mirror_test(self, widget):
try:
self.mirror_test.terminated = True
gobject.source_remove(self.update_status_id)
except:
pass
self.select_best_mirror_dialog.hide_all()
#.........这里部分代码省略.........
示例8: DetailWindow
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class DetailWindow(Window):
'''
class docs
'''
def __init__(self):
'''
init docs
'''
Window.__init__(self, enable_resize=True)
self.set_size_request(WINDOW_WIDTH, WINDOW_HEIGHT)
self.set_position(gtk.WIN_POS_CENTER)
self.set_skip_taskbar_hint(True)
self.set_skip_pager_hint(True)
self.resizable = True
self.classified_items = None
self.__init_pixbuf()
self.main_box = gtk.VBox()
self.titlebar_box = gtk.HBox()
self.toolbar_box = gtk.HBox()
self.toolbar_box.set_size_request(-1, TOOLBAR_HEIGHT)
self.main_view_box = gtk.HBox()
self.main_view_box.set_size_request(WINDOW_WIDTH,
WINDOW_HEIGHT - TITLEBAR_HEIGHT - TOOLBAR_HEIGHT - 23)
self.add_titlebar()
self.treeview_box = gtk.VBox()
self.main_view_box.pack_start(self.treeview_box, False, False)
self.listview_box = gtk.VBox()
self.main_view_box.pack_start(self.listview_box, True, True)
self.refresh_view() #add treeview and listview
self.main_box.pack_start(self.toolbar_box, False, False)
# self.main_box.pack_start(self.main_view_box, False, False)
self.main_box.pack_start(self.main_view_box, True, True)
# self.main_box.connect("expose-event", self.on_main_box_expose_event)
main_box_align = gtk.Alignment(0.5, 0.5, 1, 1)
main_box_align.set_padding(2, 2, 2, 2)
main_box_align.add(self.main_box)
self.window_frame.pack_start(self.titlebar_box, False, False)
self.window_frame.pack_start(main_box_align)
@property
def is_empty(self):
return not bool(len(self.classified_items))
def __init_pixbuf(self):
self.import_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_import.png"))
self.export_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_export.png"))
self.delete_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_delete.png"))
self.refresh_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_refresh.png"))
self.skin_preview_pixbuf = app_theme.get_pixbuf("frame.png")
def _init_data(self):
self.__init_data()
def __init_data(self):
self.classified_items = {}
rows = db.get_all()
for row in rows:
app_name = row[MESSAGE].app_name
self.classified_items.setdefault(app_name, []).append(row)
def add_to_view(self):
row = db.get_last()
# add to data
app_name = row[MESSAGE].app_name
if app_name in self.classified_items.keys():
self.classified_items[app_name].insert(0, row)
else:
self.classified_items.setdefault(app_name, []).insert(0, row)
self.treeview_add_item(app_name)
# add to view
if app_name == self.treeview.get_highlight_item().get_title():
self.factory.prepend_item(row)
def refresh_view(self):
self.__init_data()
if len(self.classified_items):
self.add_treeview()
self.current_showed_items = self.get_items_from_treeview_highlight()
self.add_listview(self.current_showed_items)
else:
align = gtk.Alignment(0.5, 0.5, 0, 0)
align.add(Label(_("(Empty)")))
container_remove_all(self.treeview_box)
container_remove_all(self.listview_box)
self.listview_box.pack_start(align, True, True)
self.main_view_box.show_all()
container_remove_all(self.toolbar_box)
#.........这里部分代码省略.........
示例9: WebcastsBrowser
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class WebcastsBrowser(gtk.VBox):
def __init__(self):
gtk.VBox.__init__(self)
# Init data.
self.source_data = OrderedDict()
self.source_data["internal"] = "国内广播"
self.source_data["foreign"] = "国外广播"
self.source_data["network"] = "网络广播"
self.source_data["genres"] = "流派广播"
self.source_data["music"] = "音乐广播"
self.source_data["finance"] = "财经广播"
self.source_data["sports"] = "体育广播"
# Init sourcebar
self.__init_sourcebar()
# Init webcasts view.
self.source_view, self.source_sw = self.get_webcasts_view()
self.collect_view, self.collect_sw = self.get_webcasts_view()
# self.custom_view, custom_view_sw = self.get_webcasts_view()
self.source_view.connect("single-click-item", self.on_source_view_single_click_item)
if WebcastsDB.isloaded():
self.on_webcastsdb_loaded()
else:
self.connect_to_webcastsdb()
# Dispatcher
Dispatcher.connect("webcast-info", self.on_dispatcher_webcast_info)
Dispatcher.connect("clear-sourcebar-status", lambda obj: self.clear_sourcebar_status())
# Used to switch categroy view.
self.switch_view_box = gtk.VBox()
self.switch_view_box.add(self.source_sw)
body_paned = HPaned(handle_color=app_theme.get_color("panedHandler"), enable_drag=True)
body_paned.add1(self.sourcebar)
body_paned.add2(self.switch_view_box)
self.add(body_paned)
self.show_all()
def on_dispatcher_webcast_info(self, obj, parent, key):
items = WebcastsDB.get_items(parent, key)
self.source_view.clear()
if items:
self.source_view.add_items([WebcastListItem(tag) for tag in items])
switch_tab(self.switch_view_box, self.source_sw)
def connect_to_webcastsdb(self):
WebcastsDB.connect("loaded", self.on_webcastsdb_loaded)
def on_webcastsdb_loaded(self, *args):
items = WebcastsDB.get_items("internal", "中央电台")
self.source_view.add_items([WebcastListItem(tag) for tag in items])
# load collect webcasts.
collect_taglist = WebcastsDB.get_favorite_items()
if collect_taglist:
self.collect_view.add_items([WebcastListItem(tag) for tag in collect_taglist])
def __init_sourcebar(self):
self.sourcebar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
items = []
for index, (key, value) in enumerate(self.source_data.items()):
if index == 0: show_icon = True
else: show_icon = False
items.append(CategroyItem(value, key, self.sourcebar, index, show_icon))
items.append(CustomItem("我的收藏", lambda : switch_tab(self.switch_view_box, self.collect_sw)))
self.sourcebar.add_items(items)
self.sourcebar.set_size_request(121, -1)
self.sourcebar.draw_mask = self.on_sourcebar_draw_mask
self.sourcebar.draw_area.tag_by_poup_panel_grab_window = True
popup_grab_window.focus_out_callback = self.handle_focus_out
def handle_focus_out(self):
self.sourcebar.unhover_row()
self.sourcebar.left_button_press = False
def get_webcasts_view(self):
webcast_view = MultiDragWebcastView()
scrolled_window = ScrolledWindow(0, 0)
scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scrolled_window.add_child(webcast_view)
return webcast_view, scrolled_window
def on_sourcebar_draw_mask(self, cr, x, y, w, h):
draw_alpha_mask(cr, x, y, w, h ,"layoutRight")
return False
def on_source_view_single_click_item(self, widget, item, column, x, y):
if column == 2:
item.toggle_is_collected()
if item.is_collected:
tags = item.webcast.get_dict()
#.........这里部分代码省略.........
示例10: PluginsManager
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class PluginsManager(gtk.VBox):
def __init__(self):
gtk.VBox.__init__(self)
self.set_spacing(5)
self.plugins = utils.get_main_window().plugins
self.plugins_view = TreeView()
self.plugins_view.set_expand_column(0)
self.plugins_view.draw_mask = self.plugins_view_draw_mask
self.plugins_view.set_size_request(420, 330)
self.plugins_view.connect("single-click-item", self.on_plugins_view_single_click)
self.plugins_view.set_column_titles([_("Add-on"), _("Version"), _("Enable"), ""],
(self.sort_by_title, self.sort_by_title,
self.sort_by_title, self.sort_by_title))
plugins_view_align = set_widget_gravity(self.plugins_view, gravity=(1, 1, 1, 1),
paddings=(10, 0, 0, 0))
self.plugin_infos = PluginInfos()
self.plugin_infos.set_size_request(420, 90)
# plugin info
self.pack_start(plugins_view_align, False, True)
self.pack_start(self.plugin_infos, False, True)
def sort_by_title(self, items, reverse):
return sorted(items, key=lambda item: item.plugin, reverse=reverse)
def plugins_view_draw_mask(self, cr, x, y, width, height):
draw_alpha_mask(cr, x, y, width, height, "layoutLeft")
def flush_plugins(self):
self.__load_plugin_list()
def __load_plugin_list(self):
# clear plugins_view items.
self.plugins_view.clear()
plugins = self.plugins.list_installed_plugins()
plugins_list = []
failed_list = []
for plugin in plugins:
try:
info = self.plugins.get_plugin_info(plugin)
except Exception:
failed_list.append(plugin)
continue
enabled = plugin in self.plugins.enabled_plugins
plugins_list.append((plugin, info, enabled))
plugins_list.sort(key=lambda x: locale.strxfrm(x[1]["Name"]))
plugins_items = [PluginItem(*args) for args in plugins_list]
self.plugins_view.add_items(plugins_items)
def on_plugins_view_single_click(self, widget, item, column, x, y):
if column == 2:
plugin = item.plugin
will_enable = not item.enabled
if will_enable:
try:
self.plugins.enable_plugin(plugin)
except Exception, e:
print e
return
else:
try:
self.plugins.disable_plugin(plugin)
except Exception, e:
print e
return
item.toggle_enabled()
示例11: MainBox
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class MainBox(gtk.HBox):
def __init__(self):
gtk.HBox.__init__(self)
self.connect("expose-event", self.on_page_expose_event)
self.aibizhi_cache_page = CachePage(Aibizhi())
self.bizhi360_cache_page = CachePage(Bizhi360())
self.aibizhi_cache_page.cache_view.try_to_fetch()
self.bizhi360_cache_page.cache_view.try_to_fetch()
self.favorites_page = FavoritePage(get_favorite_dir())
self.pictures_page = LocalPicturePage(get_download_wallpaper_dir())
self.add_item = AddItem()
self.pictures_page.select_view.add_items([self.add_item])
self.task_page = TaskPage()
self.switch_page = gtk.VBox()
self.__init_navigatebar()
self.pack_start(self.navigatebar, False, True)
self.pack_start(self.switch_page, True, True)
event_manager.add_callback("switch-to-local-pictures", self.switch_to_local_pictures)
def switch_to_local_pictures(self, name, obj, data=None):
item = self.navigatebar.get_items()[2]
self.on_navigatebar_single_click(self.navigatebar, item, 0, 0, 0)
def __init_navigatebar(self):
self.navigatebar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
self.navigatebar.connect("single-click-item", self.on_navigatebar_single_click)
self.navigatebar.set_size_request(132, -1)
self.navigatebar.draw_mask = self.on_navigatebar_draw_mask
local_expand_item = ExpandItem(_("Library"))
network_expand_item = ExpandItem(_("Internet"))
self.navigatebar.add_items([local_expand_item,
network_expand_item,
])
local_expand_item.add_childs([
(FavoritesTitle, self.favorites_page),
(LocalWallpapersTitle, self.pictures_page),
],
expand=True)
network_expand_item.add_childs([(_("360 Wallpaper"), self.bizhi360_cache_page),
(_("LoveWallpaper"), self.aibizhi_cache_page),
], expand=True)
if get_favorite_number() == 0:
self.navigatebar.set_highlight_item(self.navigatebar.get_items()[2])
self.switch_page.add(self.pictures_page)
else:
self.navigatebar.set_highlight_item(self.navigatebar.get_items()[1])
self.switch_page.add(self.favorites_page)
def draw_mask(self, cr, x, y, w, h):
cr.set_source_rgb(1, 1, 1)
cr.rectangle(x, y, w, h)
cr.fill()
def on_page_expose_event(self, widget, event):
cr = widget.window.cairo_create()
width, height= widget.size_request()
self.draw_mask(cr, 0, 0, width, height)
def on_navigatebar_draw_mask(self, cr, x, y, w, h):
self.draw_mask(cr, x, y, w, h)
draw_line(cr, (x + w, y), (0, h), "#d6d6d6")
def on_navigatebar_single_click(self, widget, item, column, x, y):
if item.widget:
widget.set_highlight_item(item)
switch_box(self.switch_page, item.widget)
示例12: Region
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class Region(gtk.Alignment):
def __init__(self, connection=None):
gtk.Alignment.__init__(self, 0, 0, 0, 0)
#################
self.provider_select = None
self.connect('expose-event', self.expose_event)
self.prop_dict = {}
main_table = gtk.Table(2, 2, False)
main_table.set_row_spacing(1, 10)
main_table.set_col_spacings(4)
self.add(main_table)
self.country_tree = TreeView(enable_multiple_select=False,
enable_drag_drop=False,
)
self.country_tree.set_expand_column(1)
self.country_tree.set_size_request(365, 380)
self.country_tree.draw_mask = self.draw_mask
self.country_tree.connect("button-press-item", self.country_selected)
left_box_align = gtk.Alignment(0, 0, 0, 0)
left_box_align.set_padding(1,1,1,1)
left_box_align.add(self.country_tree)
left_box_align.show_all()
left_box = gtk.VBox()
# wrap title
country_title = TitleBar(app_theme.get_pixbuf("network/globe-green.png"),
_("Country or Region:"),
has_separator=False)
left_box.pack_start(country_title, False, False)
left_box.pack_start(left_box_align, False, False)
self.provider_tree = TreeView(enable_multiple_select=False,
enable_drag_drop=False,
)
self.provider_tree.set_expand_column(0)
self.provider_tree.set_size_request(365, 380)
self.provider_tree.draw_mask = self.draw_mask
self.provider_tree.connect("button-press-item", self.provider_selected)
right_box_align = gtk.Alignment(0, 0, 0, 0)
right_box_align.set_padding(1,1,1,1)
right_box_align.add(self.provider_tree)
right_box = gtk.VBox()
# wrap title
provider_title = TitleBar(app_theme.get_pixbuf("network/building.png"),
_("Provider:"),
has_separator=False)
right_box.pack_start(provider_title, False, False)
right_box.pack_start(right_box_align, False, False)
main_left_align = gtk.Alignment(0, 0, 0, 0)
main_left_align.set_padding(15, 0, 20, 0)
main_left_align.add(left_box)
main_table.attach(main_left_align, 0, 1, 0, 1)
main_right_align = gtk.Alignment(0, 0, 0, 0)
main_right_align.set_padding(15, 0, 0, 20)
main_right_align.add(right_box)
main_table.attach(main_right_align, 1, 2, 0, 1)
hints = _("Tips:This assistant helps you easily set up a mobile broadband connection to a cellular network.")
left_box_align.connect("expose-event", self.expose_outline)
right_box_align.connect("expose-event", self.expose_outline)
next_button = Button("Next")
next_button.connect("clicked", self.next_button_clicked)
self.foot_box = FootBox()
self.foot_box.set_buttons([next_button])
self.foot_box.set_tip(hints)
main_table.attach(self.foot_box, 0, 2, 1, 2)
self.show_all()
#self.init()
def expose_outline(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
with cairo_disable_antialias(cr):
cr.set_line_width(1)
cr.set_source_rgb(*BORDER_COLOR)
cr.rectangle(rect.x, rect.y, rect.width , rect.height )
cr.stroke()
def draw_mask(self, cr, x, y, w, h):
cr.set_source_rgb(1, 1, 1)
cr.rectangle(x, y, w, h)
cr.fill()
def expose_event(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
cr.set_source_rgb( 1, 1, 1)
cr.rectangle(rect.x, rect.y, rect.width, rect.height)
cr.fill()
#.........这里部分代码省略.........
示例13: SessionView
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class SessionView(gtk.VBox):
def __init__(self):
gtk.VBox.__init__(self)
self.open_dialog = False
self.tmp_editing_session = None
# UI style
style.draw_background_color(self)
self.tree = TreeView([],enable_drag_drop=False,
enable_hover=True,
enable_multiple_select=False,
)
self.tree.set_expand_column(3)
self.tree.set_column_titles((_("Active"), _("Application"), _("Description"), _("Exec")),)
self.tree.set_size_request(800, -1)
self.tree.connect("right-press-items", self.right_press_item)
self.tree.draw_mask = self.draw_mask
self.tree.add_items(self.get_list())
align = gtk.Alignment(0, 0, 0, 1)
align.set_padding(15, 0, 20, 20)
align.add(self.tree)
align.connect("expose-event", self.expose_line)
add_button = Button(_("New"))
self.delete_button = Button(_("Delete"))
add_button.connect("clicked", self.add_autostart)
self.delete_button.connect("clicked", self.delete_autostart)
self.delete_button.set_sensitive(False)
foot_box = FootBox(adjustment=15)
foot_box.set_buttons([add_button, self.delete_button])
self.pack_start(align, True, True)
self.pack_end(foot_box, False, False)
#self.pack_end(self.new_box, False, False)
self.show_all()
self._init_monitor()
def disable_delete_button(self, value):
self.delete_button.set_sensitive(not value)
def _init_monitor(self):
self.library_monitor = LibraryMonitor(get_user_config_dir())
self.library_monitor.set_property("monitored", True)
self.library_monitor.connect("file-added", self.refresh_list)
self.library_monitor.connect("location-removed", self.refresh_list)
def right_press_item(self, widget, x_root, y_root, current_item, select_items):
self.tmp_editing_session = current_item.item
for item in select_items:
item.unselect()
if current_item != None:
current_item.select()
if self.open_dialog == False:
dialog = NewSessionDialog(confirm_callback = self.edit_done, cancel_callback = self.cancel_callback)
dialog.name_entry.set_text(current_item.item.name)
dialog.exec_entry.set_text(current_item.item.exec_)
dialog.desc_entry.set_text(current_item.item.comment)
dialog.place_center()
dialog.show_all()
self.open_dialog = True
def create_session_item(self, dialog):
name = dialog.name_entry.get_text()
exec_ = dialog.exec_entry.get_text()
comment = dialog.desc_entry.get_text()
session_manager.add(name, exec_, comment)
self.open_dialog = False
def expose_line(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
style.draw_out_line(cr, rect, exclude=["left", "right", "top"])
def sort_method(self):
pass
def add_autostart(self, widget):
if self.open_dialog == False:
dialog = NewSessionDialog(confirm_callback= self.create_session_item, cancel_callback = self.cancel_callback)
dialog.show_all()
self.open_dialog = True
def delete_autostart(self, widget):
items = map(lambda row: self.tree.visible_items[row], self.tree.select_rows)
item = items[0].item
item.delete()
self.tree.delete_select_items()
if self.tree.visible_items == []:
self.tree.add_items([NothingItem()])
def edit_done(self, dialog):
self.tmp_editing_session.set_name(dialog.name_entry.get_text())
self.tmp_editing_session.set_exec(dialog.exec_entry.get_text())
self.tmp_editing_session.set_comment(dialog.desc_entry.get_text())
#.........这里部分代码省略.........
示例14: AddPage
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class AddPage(gtk.HBox):
def __init__(self):
gtk.HBox.__init__(self)
self.aibizhi_cache_page = CachePage(Aibizhi())
self.bizhi360_cache_page = CachePage(Bizhi360())
self.aibizhi_cache_page.cache_view.try_to_fetch()
self.bizhi360_cache_page.cache_view.try_to_fetch()
self.system_wallpapers_page = SystemPage(get_system_wallpaper_dirs()[0])
self.picture_wallpapers_page = PicturePage(get_images_dir())
self.download_wallpapaers_page = UserPage(get_download_wallpaper_dir())
self.task_page = TaskPage()
self.__init_navigatebar()
self.switch_page = gtk.VBox()
self.pack_start(self.navigatebar, False, True)
self.pack_start(self.switch_page, True, True)
self.switch_page.add(self.system_wallpapers_page)
event_manager.add_callback("downloading-tasks-number", self.on_download_item_changed)
self.connect("expose-event", self.on_addpage_expose_event)
def set_theme(self, theme):
self.system_wallpapers_page.set_theme(theme)
self.picture_wallpapers_page.set_theme(theme)
self.download_wallpapaers_page.set_theme(theme)
self.aibizhi_cache_page.set_theme(theme)
self.bizhi360_cache_page.set_theme(theme)
def on_download_item_changed(self, name, obj, data):
pass
def __init_navigatebar(self):
self.navigatebar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
self.navigatebar.connect("single-click-item", self.on_navigatebar_single_click)
self.navigatebar.set_size_request(132, -1)
self.navigatebar.draw_mask = self.on_navigatebar_draw_mask
local_expand_item = ExpandItem(_("Library"))
network_expand_item = ExpandItem(_("Internet"))
self.navigatebar.add_items([local_expand_item,
network_expand_item,
])
local_expand_item.add_childs([(_("System"), self.system_wallpapers_page),
(_("Pictures"), self.picture_wallpapers_page),
(_("Favorites"), self.download_wallpapaers_page)], expand=True)
network_expand_item.add_childs([(_("360 Wallpaper"), self.bizhi360_cache_page),
(_("LoveWallpaper"), self.aibizhi_cache_page),
], expand=True)
self.navigatebar.set_highlight_item(self.navigatebar.get_items()[1])
def on_addpage_expose_event(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
self.draw_mask(cr, *rect)
def on_navigatebar_draw_mask(self, cr, x, y, w, h):
self.draw_mask(cr, x, y, w, h)
draw_line(cr, (x + w, y), (0, h), "#d6d6d6")
def draw_mask(self, cr, x, y, w, h):
'''
Draw mask interface.
@param cr: Cairo context.
@param x: X coordiante of draw area.
@param y: Y coordiante of draw area.
@param w: Width of draw area.
@param h: Height of draw area.
'''
cr.set_source_rgb(1, 1, 1)
cr.rectangle(x, y, w, h)
cr.fill()
def on_navigatebar_single_click(self, widget, item, column, x, y):
if item.widget:
widget.set_highlight_item(item)
switch_box(self.switch_page, item.widget)
示例15: PlaylistUI
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_size_request [as 别名]
class PlaylistUI(gtk.VBox):
'''Playlist UI.'''
def __init__(self):
'''Init.'''
gtk.VBox.__init__(self)
# Init catagory list.
self.category_list = TreeView()
self.category_list.draw_mask = self.draw_category_list_mask
self.category_list.connect("single-click-item", self.on_category_single_click)
self.category_list.connect("right-press-items", self.on_category_right_press)
self.category_list.set_size_request(CATEGROYLIST_WIDTH, -1)
# Init SearchEntry.
self.entry_box = SearchEntry("")
self.entry_box.entry.connect("changed", self.search_cb)
self.entry_box.set_no_show_all(True)
entry_align = gtk.Alignment()
entry_align.set(0, 0, 1, 1)
entry_align.set_padding(2, 0, 10, 10)
entry_align.add(self.entry_box)
entry_align.connect("expose-event", self.expose_entry_mask)
# Init toolbar.
self.toolbar_box = gtk.HBox(spacing=45)
self.search_button = self.__create_simple_toggle_button("search", self.show_text_entry,
_("Search in Current Playlist"))
self.__create_simple_button("list", self.popup_list_menu, _("Playlist Operations"))
self.__create_simple_button("add", self.popup_add_menu, _("Add"))
self.playmode_button = PlaymodeButton(config.get("setting", "loop_mode", "list_mode").split("_")[0])
Tooltip.text(self.playmode_button, _("Playback Order"))
self.playmode_button.connect("button-press-event", self.popup_sort_menu)
self.toolbar_box.pack_start(self.playmode_button, False, False)
self.__create_simple_button("delete", self.popup_delete_menu, _("Delete"))
toolbar_align = gtk.Alignment()
toolbar_align.set_padding(6, 6, 28, 0)
toolbar_align.add(self.toolbar_box)
toolbar_align.connect("expose-event", self.expose_toolbar_mask)
self.right_box = gtk.VBox()
self.right_box.connect("size-allocate", self.on_right_box_size_allocate)
self.list_paned = HPaned(handle_color=app_theme.get_color("panedHandler"), enable_drag=True)
self.list_paned.pack1(self.category_list, True, True)
self.list_paned.pack2(self.right_box, True, False)
bottom_box = gtk.VBox()
bottom_box.set_size_request(-1, 22)
self.pack_start(self.list_paned, True, True)
self.pack_start(entry_align, False, False)
self.pack_start(toolbar_align, False, True)
# Current
self.current_playlist = None
self.search_time_source = 0
self.current_item = None
self.search_flag = False
self.cache_items = None
self.delete_source_id = None
self.drag_source_id = None
self.menu_source_id = None
self.song_notify_id = None
self.detail_menu = None
if MediaDB.isloaded():
self.__on_db_loaded(MediaDB)
else:
MediaDB.connect("loaded", self.__on_db_loaded)
Player.connect("loaded", self.__on_player_loaded)
Dispatcher.connect("play-song", self.__play_and_add)
Dispatcher.connect("add-songs", self.__add_songs_to_list)
Dispatcher.connect("new-cd-playlist", self.__new_audiocd_playlist)
Dispatcher.connect("del-cd-playlist", self.delete_audiocd_list)
Dispatcher.connect("save-current-list", self.save_current_playlist)
config.connect("config-changed", self.on_config_changed)
def on_config_changed(self, config, section, option, value):
if section == "setting" and option == "loop_mode":
icon_name = value.split("_")[0]
self.playmode_button.update_dpixbufs(icon_name, True)
def on_right_box_size_allocate(self, widget, rect):
if self.current_item:
if rect.width > HIDE_PLAYLIST_WIDTH:
self.current_item.song_view.set_hide_columns(None)
else:
self.current_item.song_view.set_hide_columns([1])
def expose_toolbar_mask(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
cr.set_source_rgba(1, 1, 1, 0.95)
cr.rectangle(rect.x, rect.y, rect.width, rect.height)
cr.fill()
draw_line(cr, (rect.x, rect.y + 1),
(rect.x + rect.width, rect.y + 1), "#b0b0b0")
return False
#.........这里部分代码省略.........