本文整理汇总了Python中dtk.ui.scrolled_window.ScrolledWindow.set_size_request方法的典型用法代码示例。如果您正苦于以下问题:Python ScrolledWindow.set_size_request方法的具体用法?Python ScrolledWindow.set_size_request怎么用?Python ScrolledWindow.set_size_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtk.ui.scrolled_window.ScrolledWindow
的用法示例。
在下文中一共展示了ScrolledWindow.set_size_request方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SearchPage
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import set_size_request [as 别名]
class SearchPage(gtk.VBox):
'''
class docs
'''
def __init__(self, module_infos):
'''
init docs
'''
gtk.VBox.__init__(self)
self.scrolled_window = ScrolledWindow()
self.scrolled_window.set_size_request(800, 425)
self.result_align = self.__setup_align(padding_top = TEXT_WINDOW_TOP_PADDING,
padding_left = TEXT_WINDOW_LEFT_PADDING)
self.result_box = gtk.VBox()
self.result_box.connect("expose-event", self.__expose)
self.result_align.add(self.result_box)
'''
struct keywords {
module_id,
module_name,
module_keywords {
uid,
keyword
}
}
'''
self.__keywords = []
self.__module_infos = module_infos
'''
TODO: from EACH MODULE import keywords
'''
for module_info_list in self.__module_infos:
for module_info in module_info_list:
if module_info.search_keyword != "None":
try:
module = __import__("%s.%s" % (module_info.id, module_info.search_keyword), fromlist=["keywords"])
self.__keywords.append((module_info.id, module_info.name, module.keywords, module_info.menu_icon_pixbuf))
except Exception, e:
print "Error %s %s" % (module_info.id, e)
continue
self.__keyword_search = KeywordSearch(self.__keywords)
self.scrolled_window.add_child(self.result_align)
self.pack_start(self.scrolled_window)
示例2: ShareToWeibo
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import set_size_request [as 别名]
class ShareToWeibo(object):
'''share picture to weibo'''
def __init__(self, filename=""):
'''
init share
@param filename: the file to share
'''
self.upload_image = filename
self.thumb_width = 188
self.thumb_height = 168
self.MAX_CHAR = 140
#self.__text_frame_color = (0.76, 0.76, 0.76)
self.__win_width = 602
open(COOKIE_FILE,'wb').close()
self.window = DialogBox(_("Share to social networks"), close_callback=gtk.main_quit)
self.window.set_keep_above(True)
self.window.set_size_request(self.__win_width+20, 288)
self.window.set_resizable(False)
self.window.titlebar.connect("expose-event", self.__expose_top_and_bottome)
self.window.button_box.connect("expose-event", self.__expose_top_and_bottome)
# create slider
self.slider = HSlider()
self.slider_list = []
self.share_box = gtk.VBox(False, 2) # first page, input context
self.web_box = gtk.VBox(False, 10) # second page, login
self.result_box = gtk.VBox(False, 10) # third page, share result
share_align = gtk.Alignment()
share_align.set(0.5, 0.5, 0, 0)
share_align.add(self.share_box)
share_align.connect("expose-event", self.__slider_expose)
# go back button
web_left_button = ImageButton(
app_theme.get_pixbuf("share/back_normal.png"),
app_theme.get_pixbuf("share/back_hover.png"),
app_theme.get_pixbuf("share/back_press.png"))
web_left_button.connect("clicked", lambda w: self.set_slide_index(0))
web_left_button.set_can_focus(False)
utils.set_clickable_cursor(web_left_button)
# show url entry
self.web_url_entry = InputEntry()
self.web_url_entry.set_editable(False)
self.web_url_entry.set_size(555, 20)
self.web_url_entry.entry.right_menu_visible_flag = False
# alig url entry
web_navigate_vbox = gtk.VBox(False)
web_navigate_vbox.pack_start(self.web_url_entry)
web_navigate_t_align = gtk.Alignment()
web_navigate_t_align.set(0.0, 0.5, 0, 0)
web_navigate_t_align.add(web_navigate_vbox)
# pack back button and url entry
web_navigate_box = gtk.HBox(False, 7)
web_navigate_box.pack_start(web_left_button, False, False)
web_navigate_box.pack_start(web_navigate_t_align)
web_navigate_align = gtk.Alignment()
web_navigate_align.set(0.5, 0.5, 0, 0)
web_navigate_align.set_padding(4, 0, 11, 13)
web_navigate_align.add(web_navigate_box)
# create a webkit
self.web_view = WebView(COOKIE_FILE)
self.web_view.connect("notify::load-status", self.web_view_load_status)
self.web_view.connect("load-error", self.web_view_load_error)
self.web_scrolled_window = ScrolledWindow()
self.web_scrolled_window.add(self.web_view)
self.web_scrolled_window.set_size_request(590, 228)
self.web_box.pack_start(web_navigate_align, False, False)
self.web_box.pack_start(self.web_scrolled_window)
#self.web_box.set_size_request(-1, 258)
web_align = gtk.Alignment()
web_align.set(0.5, 0.0, 0, 1)
web_align.add(self.web_box)
web_align.connect("expose-event", self.__slider_expose)
res_align = gtk.Alignment()
res_align.set(0.5, 0.5, 0, 0)
res_align.add(self.result_box)
res_align.connect("expose-event", self.__slider_expose)
self.slider.set_to_page(share_align)
self.slider_list.append(share_align)
self.slider_list.append(web_align)
self.slider_list.append(res_align)
self.__weibo_list = []
self.sina = weibo.Sina(self.web_view)
self.qq = weibo.Tencent(self.web_view)
self.twitter = weibo.Twitter(self.web_view)
self.__weibo_list.append(self.sina)
self.__weibo_list.append(self.qq)
self.__weibo_list.append(self.twitter)
self.__current_weibo = None
self.window.body_box.pack_start(self.slider, True, True)
#.........这里部分代码省略.........
示例3: init_share_box
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import set_size_request [as 别名]
def init_share_box(self):
'''get weibo info, and create button'''
self.to_share_weibo = {}
self.to_share_weibo_res = {}
self.deepin_info = {}
self.is_get_user_info = {}
self.__weibo_check_button_list = []
self.__weibo_image_button_list = []
# create Thumbnail
if exists(self.upload_image):
pixbuf = gtk.gdk.pixbuf_new_from_file(self.upload_image)
pix_w = pixbuf.get_width()
pix_h = pixbuf.get_height()
if pix_w > pix_h:
pix_s_w = self.thumb_width
pix_s_h = int(pix_h / (float(pix_w) / self.thumb_width))
else:
pix_s_h = self.thumb_height
pix_s_w = int(pix_w / (float(pix_h) / self.thumb_height))
pixbuf = pixbuf.scale_simple(pix_s_w, pix_s_h, gtk.gdk.INTERP_TILES)
thumb = gtk.image_new_from_pixbuf(pixbuf)
else:
thumb = gtk.Image()
thumb.set_size_request(self.thumb_width, self.thumb_height)
# weibo context input
text_box = gtk.HBox(False, 2)
text_vbox = gtk.VBox(False, 2)
text_bg_vbox = gtk.VBox(False)
text_bg_align = gtk.Alignment()
text_bg_align.set(0.5, 0.5, 0, 0)
text_bg_align.set_padding(5, 5, 16, 5)
text_bg_align.connect("expose-event", self.text_view_bg_expose)
text_scrolled_win = ScrolledWindow()
text_scrolled_win.set_size_request(340, 157)
text_view = gtk.TextView()
text_view.set_left_margin(10)
text_view.set_right_margin(10)
text_view.set_pixels_above_lines(5)
text_view.set_pixels_below_lines(5)
text_view.set_wrap_mode(gtk.WRAP_WORD| gtk.WRAP_CHAR)
text_view.connect("expose-event", self.text_view_expose)
buf = text_view.get_buffer()
text_scrolled_win.add(text_view)
text_bg_vbox.pack_start(text_scrolled_win)
text_bg_align.add(text_bg_vbox)
text_align = gtk.Alignment()
text_align.set(0.5, 0.5, 0, 0)
text_align.set_padding(25, 30, 10, 10)
text_box.pack_start(thumb, False, False, 10)
text_box.pack_start(text_bg_align)
text_vbox.pack_start(text_box, False, False, 10)
text_align.add(text_vbox)
#tmp_align = gtk.Alignment()
#tmp_align.set(0.5, 0, 0, 1)
#self.share_box.pack_start(tmp_align, False, False)
self.share_box.pack_start(text_align, False, False)
# dialog button box
left_box = self.window.left_button_box
right_box = self.window.right_button_box
# input tip label
self.input_num_label = Label("%d" % self.MAX_CHAR,
text_size=16, text_x_align=pango.ALIGN_CENTER, label_width=50, enable_select=False)
self.input_num_label.text_color = app_theme.get_color("left_char_num")
# login box
#weibo_box = gtk.HBox(False, 1)
#weibo_box.set_size_request(-1, 50)
weibo_box_list = []
self.loading_label = Label("%s..." % _("Loading"), text_size=12,
label_width=70, enable_select=False)
weibo_box_list.append(self.loading_label)
for weibo in self.__weibo_list:
box = gtk.HBox(False, 2)
weibo.set_box(box)
weibo_box_list.append(box)
left_box.set_buttons(weibo_box_list)
# share button
button = Button(_("Share"))
#button.set_size_request(75, 25)
button.connect("clicked", self.share_button_clicked, text_view)
buf.connect("changed", self.text_view_changed, button) # check char num
tmp_vbox = gtk.VBox(False)
tmp_align = gtk.Alignment()
tmp_align.set(0.5, 0.5, 0, 0)
tmp_vbox.pack_start(button, False, False)
#tmp_vbox.pack_start(tmp_align)
tmp_align.add(tmp_vbox)
right_box.set_buttons([self.input_num_label, tmp_align])
#.........这里部分代码省略.........
示例4: SettingUI
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import set_size_request [as 别名]
class SettingUI(gtk.Alignment):
def __init__(self, slide_back_cb, change_crumb_cb):
gtk.Alignment.__init__(self, 0, 0, 0, 0)
self.slide_back = slide_back_cb
self.change_crumb = change_crumb_cb
self.scroll_win = ScrolledWindow()
self.scroll_win.set_can_focus(False)
self.scroll_win.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
main_vbox = gtk.VBox()
self.foot_box = FootBox()
self.hbox = gtk.HBox()
self.scroll_win.add_with_viewport(self.hbox)
self.scroll_align = gtk.Alignment()
self.scroll_win.set_size_request(800, 435)
self.scroll_align.set(0, 0, 0, 0)
self.scroll_align.set_padding(0, 0, 30, 0)
self.scroll_align.add(self.scroll_win)
padding_align = gtk.Alignment(0, 0, 0, 0)
padding_align.set_padding(15, 0, 0, 0)
self.sidebar = SideBar( None)
padding_align.add(self.sidebar)
self.hpaned = MyPaned()
self.hpaned.set_size_request(800, -1)
self.hpaned.connect("expose-event",self.expose_line)
#self.hpaned.do_enter_notify_event = self.enter_notify_event
self.hpaned.add1(padding_align)
self.hpaned.add2(self.scroll_align)
self.connect_after("show", self.__init_paned)
main_vbox.pack_start(self.hpaned, True, True)
main_vbox.pack_start(self.foot_box, False, False)
self.add(main_vbox)
self.__init_signals()
def enter_notify_event(self, e):
pass
def __init_paned(self, widget):
log.debug("")
self.hpaned.saved_position = 160
self.hpaned.set_position(1)
self.hpaned.animation_position_frames = [0]
self.hpaned.update_position()
def __init_signals(self):
Dispatcher.connect("connection-change", self.switch_content)
Dispatcher.connect("setting-saved", self.save_connection_setting)
Dispatcher.connect("setting-appled", self.apply_connection_setting)
Dispatcher.connect("request_redraw", lambda w: self.scroll_win.show_all())
def load_module(self, module_obj, hide_left):
# create a reference
self.setting_group = module_obj
# init paned
self.__init_paned(None)
log.info("dss start load module", module_obj)
self.hpaned.set_button_show(hide_left)
# init foot_box
self.foot_box.set_setting(module_obj)
# init sidebar
self.sidebar.load_list(module_obj)
self.apply_method = module_obj.apply_changes
self.save_method = module_obj.save_changes
def switch_content(self, widget, connection):
container_remove_all(self.hbox)
self.set_tab_content(connection)
self.set_foot_bar_button(connection)
self.focus_connection = connection
def set_foot_bar_button(self, connection):
if type(connection) == NMRemoteConnection:
self.foot_box.show_delete(connection)
else:
self.foot_box.hide_delete()
states = self.setting_group.get_button_state(connection)
if states:
Dispatcher.set_button(*states)
def set_tab_content(self, connection):
log.debug("set tab content", connection)
setting = self.setting_group.init_items(connection)
self.hbox.add(setting)
self.hbox.show_all()
self.foot_box.set_lock(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"])
#.........这里部分代码省略.........
示例5: DisplayView
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import set_size_request [as 别名]
class DisplayView(gtk.VBox):
'''
class docs
'''
def __init__(self):
'''
init docs
'''
gtk.VBox.__init__(self)
self.brightness_id = None
self.display_manager = DisplayManager()
self.__xrandr_settings = self.display_manager.get_xrandr_settings()
self.__xrandr_settings.connect("changed", self.__xrandr_changed)
self.resize_width = 790
self.resize_height = 200
self.monitor_items = []
self.__output_names = []
self.__current_output_name = self.display_manager.get_primary_output_name()
self.__setup_monitor_items()
self.sizes_items = []
self.monitor_combo = None
if len(self.monitor_items) > 1 and self.display_manager.is_copy_monitors():
self.__set_same_sizes()
else:
self.__setup_sizes_items()
self.multi_monitors_items = [(_("Copy Display"), 1),
(_("Extend Display"), 2),
(_("Only shown in display 1"), 3),
(_("Only shown in display 2"), 4)]
self.rotation_items = [(_("Normal"), 1),
(_("Right"), 2),
(_("Left"), 3),
(_("Inverted"), 4)]
self.duration_items = [("1 %s" % _("Minute"), 1),
("2 %s" % _("Minutes"), 2),
("3 %s" % _("Minutes"), 3),
("5 %s" % _("Minutes"), 5),
("10 %s" % _("Minutes"), 10),
("30 %s" % _("Minutes"), 30),
("1 %s" % _("Hour"), 60),
(_("Never"), DisplayManager.BIG_NUM / 60)]
'''
scrolled_window
'''
self.scrolled_window = ScrolledWindow()
self.scrolled_window.set_size_request(-1, 425)
self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
self.main_box = gtk.VBox()
self.main_box.set_size_request(600, -1)
self.body_box = gtk.HBox()
'''
left, right align
'''
self.left_align = self.__setup_align(padding_top = FRAME_TOP_PADDING,
padding_left = TEXT_WINDOW_LEFT_PADDING)
self.right_align = self.__setup_align(padding_top = FRAME_TOP_PADDING,
padding_left = 0)
'''
left, right box
'''
self.left_box = gtk.VBox(spacing = WIDGET_SPACING)
self.right_box = gtk.VBox(spacing = WIDGET_SPACING)
'''
monitor operation && detect
'''
self.monitor_resize_align = self.__setup_align(padding_top = 11,
padding_left = int(TEXT_WINDOW_LEFT_PADDING / 2))
self.monitor_resize_box = MonitorResizableBox(self.display_manager)
self.monitor_resize_box.select_output(self.__current_output_name)
self.monitor_resize_box.connect("select-output", self.__select_output)
self.monitor_resize_box.connect("resize", self.__resize_box)
self.monitor_resize_align.add(self.monitor_resize_box)
'''
monitor display
'''
self.monitor_display_align = self.__setup_title_align(
app_theme.get_pixbuf("display/monitor_display.png"),
_("Display"),
0)
'''
monitor
'''
self.monitor_align = self.__setup_align()
self.monitor_box = gtk.HBox(spacing = WIDGET_SPACING)
self.monitor_label = self.__setup_label(_("Monitor"))
self.monitor_combo = self.__setup_combo(self.monitor_items)
self.monitor_combo.set_select_index(self.display_manager.get_primary_output_name_index(self.monitor_items))
self.monitor_combo.connect("item-selected", self.__combo_item_selected, "monitor_combo")
self.__widget_pack_start(self.monitor_box,
[self.monitor_label,
self.monitor_combo])
self.monitor_align.add(self.monitor_box)
'''
goto individuation or power setting
'''
self.goto_align = self.__setup_align()
#.........这里部分代码省略.........
示例6: __init__
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import set_size_request [as 别名]
def __init__(self):
super(PreferenceDialog, self).__init__(_("Preference"), 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()
# Category bar
self.category_bar = TreeView(font_x_padding=20)
self.category_bar.draw_mask = self.draw_treeview_mask
self.general_category_item = CategoryItem(_("General"), self.general_setting)
self.category_bar.add_item(None, self.general_category_item)
self.category_bar.add_item(None, CategoryItem(_("Hotkeys"), self.hotkey_setting))
lyrics_node = self.category_bar.add_item(None, CategoryItem(_("Lyrics")))
self.category_bar.add_item(lyrics_node, CategoryItem(_("Desktop"), self.desktop_lyrics_setting))
self.category_bar.add_item(lyrics_node, CategoryItem(_("Window"), self.scroll_lyrics_setting))
self.category_bar.add_item(None, CategoryItem(_("About us"), AboutBox()))
self.category_bar.connect("single-click-item", self.category_single_click_cb)
self.category_bar.set_highlight_index(0)
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_scrolled_window = ScrolledWindow()
category_scrolled_window.add_child(self.category_bar)
category_scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
category_scrolled_window.set_size_request(132, 516)
category_scrolled_window_align = gtk.Alignment()
category_scrolled_window_align.set(0, 0, 1, 1,)
category_scrolled_window_align.set_padding(0, 1, 0, 0)
category_scrolled_window_align.add(category_scrolled_window)
category_box.pack_start(category_scrolled_window_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_category_item.get_allocated_widget())
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])
示例7: icon_item_release_resource
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import set_size_request [as 别名]
'''
pass
def icon_item_release_resource(self):
# Return True to tell IconView call gc.collect() to release memory resource.
if self.pixbuf:
del self.pixbuf
self.pixbuf = None
return True
if __name__ == '__main__':
gtk.gdk.threads_init()
module_frame = ModuleFrame(os.path.join(get_parent_dir(__file__, 2), "config.ini"))
scrolled_window = ScrolledWindow()
scrolled_window.set_size_request(788, 467)
wallpaper_view = WallpaperView()
scrolled_window.add_child(wallpaper_view)
module_frame.add(scrolled_window)
scrolled_window.connect("vscrollbar-state-changed", wallpaper_view.load_more_background)
download_pool = MissionThreadPool(5)
download_pool.start()
def message_handler(*message):
(message_type, message_content) = message
if message_type == "show_again":
module_frame.send_module_info()
elif message_type == "exit":
module_frame.exit()
示例8: ThemePage
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import set_size_request [as 别名]
class ThemePage(gtk.VBox):
'''
class docs
'''
def __init__(self):
'''
init docs
'''
gtk.VBox.__init__(self)
self.status_box = StatusBox()
self.scroll = ScrolledWindow()
self.scroll.set_size_request(800, 432)
self.scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
self.label_padding_x = 10
self.label_padding_y = 10
self.theme_box = gtk.VBox()
self.user_theme_label = Label(_("My Themes"), text_size=TITLE_FONT_SIZE,
text_color=app_theme.get_color("globalTitleForeground"))
self.user_theme_view = UserThemeView(status_box = self.status_box)
self.user_theme_scrolledwindow = self.user_theme_view.get_scrolled_window()
self.system_theme_label = Label(_("System Themes"), text_size=TITLE_FONT_SIZE,
text_color=app_theme.get_color("globalTitleForeground"))
self.system_theme_view = SystemThemeView(status_box = self.status_box)
self.system_theme_scrolledwindow = self.system_theme_view.get_scrolled_window()
self.theme_box.pack_start(self.user_theme_label, False, False)
self.theme_box.pack_start(get_separator(), False, False)
self.theme_box.pack_start(self.user_theme_scrolledwindow, False, False)
self.theme_box.pack_start(self.system_theme_label, False, False)
self.theme_box.pack_start(get_separator(), False, False)
self.theme_box.pack_start(self.system_theme_scrolledwindow, True, True)
main_align = gtk.Alignment()
main_align.set_padding(15, 0, 20, 20)
main_align.set(1, 1, 1, 1)
main_align.add(self.theme_box)
self.scroll.add_child(main_align)
main_align.connect("expose-event", self.expose_label_align)
self.pack_start(self.scroll, False, False)
self.pack_start(self.status_box)
def expose_label_align(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
self.draw_mask(cr, rect.x, rect.y, rect.width, rect.height)
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()
示例9: PlaylistItem
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import set_size_request [as 别名]
class PlaylistItem(gobject.GObject):
def __init__(self, playlist):
'''Init song item.'''
self.item_id = None
self.main_box = gtk.VBox()
self.update(playlist)
self.create_jobs_box()
def draw_mask(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
draw_alpha_mask(cr, rect.x, rect.y, rect.width, rect.height, "layoutMiddle")
def create_jobs_box(self):
self.file_job_button = self.create_job_button("plus", _("Add Music"), self.song_view.recursion_add_dir)
# self.file_job_button.connect("clicked", self.open_file_or_dir)
self.job_box = gtk.EventBox()
self.job_box.set_size_request(220, -1)
targets = [("text/deepin-songs", gtk.TARGET_SAME_APP, 1), ("text/uri-list", 0, 2), ("text/plain", 0, 3)]
self.job_box.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_DROP,
targets, gtk.gdk.ACTION_COPY)
self.job_box.set_visible_window(False)
self.job_box.connect("drag-data-received", self.song_view.on_drag_data_received)
# Content box.
content_box = gtk.VBox()
content_box.pack_start(create_bottom_align(), True, True)
# content_box.pack_start(ImageBox(app_theme.get_pixbuf("jobs/scan_tip.png")), False, False)
content_box.pack_start(self.file_job_button, False, False)
content_box.pack_start(create_upper_align(), True, True)
# Rind box.
rind_box = gtk.HBox()
rind_box.pack_start(create_right_align(), True, True)
rind_box.pack_start(content_box, False, False)
rind_box.pack_start(create_left_align(), True, True)
self.job_box.add(rind_box)
self.jobs_align = gtk.Alignment()
self.jobs_align.set(0.5, 0.5, 1, 1)
self.jobs_align.add(self.job_box)
self.jobs_align.connect("expose-event", self.draw_mask)
def create_job_button(self, icon_name, content, callback=None):
button = ComplexButton(
[app_theme.get_pixbuf("jobs/complex_normal.png"),
app_theme.get_pixbuf("jobs/complex_hover.png"),
app_theme.get_pixbuf("jobs/complex_press.png")],
app_theme.get_pixbuf("jobs/%s.png" % icon_name),
content
)
if callback:
button.connect("clicked", lambda w : callback())
return button
def set_title(self, value):
self.title = value
def get_title(self):
return self.title
def get_left_image(self):
return None
def get_has_arrow(self):
return None
def set_item_id(self, index):
self.item_id = index
def get_item_id(self):
return self.item_id
def update(self, playlist):
'''update'''
self.playlist = playlist
songs = self.playlist.get_songs()
self.song_view = SongView()
self.song_view.add_songs(songs)
self.song_view.connect("begin-add-items", lambda w: self.switch_it())
self.song_view.connect("empty-items", lambda w: self.switch_it(False))
self.scrolled_window = ScrolledWindow(0, 0)
self.scrolled_window.add_child(self.song_view)
self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
self.scrolled_window.set_size_request(220, -1)
self.title = playlist.get_name()
def get_list_widget(self):
if self.get_songs():
switch_box(self.main_box, self.scrolled_window)
else:
switch_box(self.main_box, self.jobs_align)
return self.main_box
def switch_it(self, scrolled_window=True):
#.........这里部分代码省略.........