def handle_animation(self, widget, event, button_press=False): # Init. rect = widget.allocation start_x = rect.width + self.pointer_offset_x - self.pointer_radious start_y = rect.height + self.pointer_offset_y self.left_retangle = (0, 0, rect.width/3, rect.height - self.pointer_offset_y) self.right_retangle = (0 + 2*rect.width/3, 0, rect.width/3, rect.height - self.pointer_offset_y) if self.image_number > 1 and (start_y - 4 * self.pointer_radious < event.y < start_y + self.pointer_radious * 6 and start_x - 2 * self.pointer_radious < event.x < start_x + 4 * self.pointer_padding + 4 * self.pointer_radious): set_cursor(widget, gtk.gdk.HAND2) if self.hover_switch or button_press: self.motion_index = None for index in range(0, self.image_number): if start_x + index * self.pointer_padding < event.x < start_x + (index + 1) * self.pointer_padding: self.motion_index = index if self.active_index != index: self.start_animation(self.hover_animation_time, index) break elif self.image_number > 1 and is_in_rect((event.x, event.y), self.left_retangle) and self.navigate_switch: if not self.in_left_nav: self.in_left_nav = True self.queue_draw() #set_cursor(widget, gtk.gdk.SB_LEFT_ARROW) widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.display_get_default(), get_common_image_pixbuf('cursor/left_arrow.png'), 0, 0)) if button_press: self.to_left_animation() elif self.image_number > 1 and is_in_rect((event.x, event.y), self.right_retangle) and self.navigate_switch: if not self.in_right_nav: self.in_right_nav = True self.queue_draw() #set_cursor(widget, gtk.gdk.SB_RIGHT_ARROW) widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.display_get_default(), get_common_image_pixbuf('cursor/right_arrow.png'), 0, 0)) if button_press: self.to_right_animation() else: if self.in_left_nav or self.in_right_nav: self.in_left_nav = False self.in_right_nav = False self.queue_draw() set_cursor(widget, None) if button_press: self.emit("button-press-index", self.active_index) else: self.emit("motion-notify-index", self.active_index)
def is_in_icon_area(self, x, y): if self.pkg_picture_pixbuf == None: self.pkg_picture_pixbuf = get_common_image_pixbuf('recommend/default_cache.png') padding_x = (self.get_width() - self.pkg_picture_pixbuf.get_width()) / 2 padding_y = (self.get_height() - self.pkg_picture_pixbuf.get_height()) / 2 return is_in_rect((x, y), (padding_x, padding_y, self.pkg_picture_pixbuf.get_width(), self.pkg_picture_pixbuf.get_height()))
def __init__(self, callback=None): gtk.EventBox.__init__(self) self.set_visible_window(False) self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.ENTER_NOTIFY_MASK | gtk.gdk.LEAVE_NOTIFY_MASK ) self.connect("expose-event", self.on_expose_event) if LANGUAGE == "zh_CN": prefix = "cn" elif LANGUAGE in ["zh_HK", "zh_TW"]: prefix = "tw" else: prefix = "en" self.failed_dpixbuf = get_common_image_pixbuf("network/timeout_%s.png" % prefix) self.connect("motion-notify-event", self.on_motion_notify) self.connect("button-press-event", self.on_button_press) self.normal_text_dcolor = ui_theme.get_color("label_text") self.hover_text_dcolor = ui_theme.get_color("globalItemHighlight") self.prompt_text = _("Click here to refresh") self.text_padding_y = 5 self.text_padding_x = 5 self.text_rect = None self.is_hover = False self.press_callback = callback
def __init__(self, hide_callback=None): self.hide_callback = hide_callback self.dialog_width = 330 DialogBox.__init__( self, title="", default_width=self.dialog_width, default_height=145, mask_type=0, close_callback=self.close_action, modal=True, window_hint=gtk.gdk.WINDOW_TYPE_HINT_DIALOG, window_pos=None, skip_taskbar_hint=True, resizable=False, window_type=gtk.WINDOW_TOPLEVEL, ) self.waiting_animation = gtk.VBox() self.waiting_animation.set_size_request(36, 36) self.waiting_bg_pixbuf = utils.get_common_image_pixbuf( "waiting/waiting_bg.png") self.waiting_fg_pixbuf = utils.get_common_image_pixbuf( "waiting/waiting_fg.png") self.waiting_animation.connect("expose-event", self.expose_waiting) self.counter = 1 self.factor = math.pi / 10 gtk.timeout_add(50, self.on_timer) self.label = Label( _("Speed testing will finish only after one minute, please wait."), text_size=10, wrap_width=self.dialog_width - 36 - 60, ) self.waiting_hbox = gtk.HBox() self.waiting_hbox.pack_start(self.waiting_animation, False, False) self.waiting_hbox.pack_start(self.label, False, False) self.center_align = gtk.Alignment() self.center_align.set(0.5, 0.5, 0, 0) self.center_align.set_padding(0, 0, 8, 8) self.body_box.add(self.center_align) global_event.register_event("mirror-test-finished", self.show_result)
def center_play_box_expose(self, widget, event): rect = widget.allocation cr = widget.window.cairo_create() if widget.state == gtk.STATE_PRELIGHT: play_pixbuf = utils.get_common_image_pixbuf('pause/play_hover.png') else: play_pixbuf = utils.get_common_image_pixbuf('pause/play_normal.png') draw_pixbuf( cr, play_pixbuf, rect.x + (rect.width - play_pixbuf.get_width())/2, rect.y + (rect.height - play_pixbuf.get_height())/2, ) # Propagate expose to children. propagate_expose(widget, event) return True
def show_image_text(self, text, image_path): self.content = text self.text_size = get_content_size(self.content, self.font_size) self.pixbuf = utils.get_common_image_pixbuf(image_path) self.width, self.height = 140, 78 self.offset = (self.width - self.arrow_width) / 2 self.set_geometry_hints(None, self.width, self.height, self.width, self.height, \ -1, -1, -1, -1, -1, -1) self.queue_draw()
def get_star_pixbufs(self): star_paths = ["star_off.png"] * 5 for index in range(0, int(self.star_level / 2)): star_paths[index] = "star_on.png" if int(self.star_level % 2) == 1: star_paths[int(self.star_level / 2)] = "star_half.png" return map(lambda path: utils.get_common_image_pixbuf("star/%s" % path), star_paths)
def center_play_box_expose(self, widget, event): rect = widget.allocation cr = widget.window.cairo_create() if widget.state == gtk.STATE_PRELIGHT: play_pixbuf = utils.get_common_image_pixbuf('pause/play_hover.png') else: play_pixbuf = utils.get_common_image_pixbuf( 'pause/play_normal.png') draw_pixbuf( cr, play_pixbuf, rect.x + (rect.width - play_pixbuf.get_width()) / 2, rect.y + (rect.height - play_pixbuf.get_height()) / 2, ) # Propagate expose to children. propagate_expose(widget, event) return True
def render(self, cr, rect): if self.pkg_picture_pixbuf == None: self.pkg_picture_pixbuf = get_common_image_pixbuf('recommend/default_cache.png') padding_x = (rect.width - self.pkg_picture_pixbuf.get_width()) / 2 padding_y = (rect.height - self.pkg_picture_pixbuf.get_height()) / 2 draw_pixbuf(cr, self.pkg_picture_pixbuf, rect.x + padding_x, rect.y + padding_y)
def __init__(self, hide_callback=None): self.hide_callback = hide_callback self.dialog_width = 330 DialogBox.__init__( self, title="", default_width=self.dialog_width, default_height=145, mask_type=0, close_callback=self.close_action, modal=True, window_hint=gtk.gdk.WINDOW_TYPE_HINT_DIALOG, window_pos=None, skip_taskbar_hint=True, resizable=False, window_type=gtk.WINDOW_TOPLEVEL, ) self.waiting_animation = gtk.VBox() self.waiting_animation.set_size_request(36, 36) self.waiting_bg_pixbuf = utils.get_common_image_pixbuf("waiting/waiting_bg.png") self.waiting_fg_pixbuf = utils.get_common_image_pixbuf("waiting/waiting_fg.png") self.waiting_animation.connect("expose-event", self.expose_waiting) self.counter = 1 self.factor = math.pi/10 gtk.timeout_add(50, self.on_timer) self.label = Label( _("Speed testing will finish only after one minute, please wait."), text_size=10, wrap_width=self.dialog_width- 36 - 60, ) self.waiting_hbox = gtk.HBox() self.waiting_hbox.pack_start(self.waiting_animation, False, False) self.waiting_hbox.pack_start(self.label, False, False) self.center_align = gtk.Alignment() self.center_align.set(0.5, 0.5, 0, 0) self.center_align.set_padding(0, 0, 8, 8) self.body_box.add(self.center_align) global_event.register_event("mirror-test-finished", self.show_result)
def expose_info_image_box(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation msg_pixbuf = get_common_image_pixbuf("msg/msg1.png") pix_width = msg_pixbuf.get_width() pix_height = msg_pixbuf.get_height() draw_pixbuf(cr, msg_pixbuf, rect.x + (rect.width-pix_width)/2, rect.y + (rect.height-pix_height)/2, )
def __init__(self): super(GuideBox, self).__init__() self.scrolled_window = ScrolledWindow() self.backgroundbox = BackgroundBox() self.backgroundbox.draw_mask = self.draw_mask self.guide_pixbuf = utils.get_common_image_pixbuf('guide.png') self.top_title = gtk.HBox() self.top_left_icon = gtk.VBox() self.top_left_icon.set_size_request(self.guide_pixbuf.get_width(), self.guide_pixbuf.get_height()) self.top_left_icon.connect('expose-event', self.expose_top_left_icon) top_left_icon_align = gtk.Alignment(0.5, 0.5, 0, 0) top_left_icon_align.set_padding(15, 3, 13, 3) top_left_icon_align.add(self.top_left_icon) self.top_right_text = Label( _("Introduction"), ui_theme.get_color('label_select_background'), 14) top_right_text_align = gtk.Alignment(0.5, 0.5, 0, 0) top_right_text_align.set_padding(18, 3, 3, 3) top_right_text_align.add(self.top_right_text) self.top_title.pack_start(top_left_icon_align, False, False) self.top_title.pack_start(top_right_text_align, False, False) self.content_box = gtk.VBox() self.guide_label = Label('', enable_select=False, wrap_width=200, text_size=9, text_color=DynamicColor('#808080')) guide_label_align = gtk.Alignment(0.5, 0.5, 1, 1) guide_label_align.set_padding(5, 5, 10, 10) guide_label_align.add(self.guide_label) self.content_box.pack_start(guide_label_align, False, False) self.backgroundbox.pack_start(self.top_title, False, False) self.backgroundbox.pack_start(self.content_box) self.scrolled_window.add_child(self.backgroundbox) self.add(self.scrolled_window) global_event.register_event('download-app-info-finish', self.update_content)
def __init__(self): BaseBox.__init__(self) logo_image = gtk.image_new_from_icon_name("deepin-software-center", 16) if not logo_image: logo_image = utils.get_common_image_pixbuf("logo16.png") else: logo_image.set_pixel_size(16) logo_name = Label(_("Deepin Store"), text_size=10) logo_box = gtk.HBox(spacing=2) logo_box.pack_start(logo_image, False, False) logo_box.pack_start(logo_name, False, False) version_label = Label(_("Version:")) version_content = Label(PROGRAM_VERSION, DynamicColor('#4D5154')) info_box = gtk.HBox(spacing=5) info_box.pack_start(version_label, False, False) info_box.pack_start(version_content, False, False) align = gtk.Alignment() align.set(0, 0, 0, 1) title_box = gtk.HBox() title_box.pack_start(logo_box, False, False) title_box.pack_start(align, True, True) title_box.pack_start(info_box, False, False) describe = _("Deepin Store is a commonly used software center on Linux. " "We selected more than 2,600 excellent applications with many " "functions of installation and uninstalling, software repository " "and popular recommendations, which supports 1-click quick " "installation, multi-threaded download and clearing of cached " "packages. It provides topics for software introduction and " "shares good applications.\n" "\n" "Deepin Store is a free software licensed under GNU GPLv3.") describe_label = Label(describe, enable_select=False, wrap_width=400, text_size=10) self.main_box.pack_start(title_box, False, False) self.main_box.pack_start(create_separator_box(), False, True) self.main_box.pack_start(describe_label, False, False)
def show_wizard_win(self, show_button=False, callback=None): program_dir = get_parent_dir(__file__, 2) wizard_dir = os.path.join(program_dir, 'wizard', LANGUAGE) if not os.path.exists(wizard_dir): wizard_dir = os.path.join(program_dir, 'wizard', 'en_US') wizard_root_dir = os.path.dirname(wizard_dir) self.wizard = Wizard( [os.path.join(wizard_dir, "%d.png" % i) for i in range(3)], (os.path.join(wizard_root_dir, "dot_normal.png"), os.path.join(wizard_root_dir, "dot_active.png"), ), (os.path.join(wizard_dir, "start_normal.png"), os.path.join(wizard_dir, "start_press.png"), ), show_button, callback ) self.wizard.set_icon(utils.get_common_image_pixbuf("logo48.png")) if not self.init_hide: self.wizard.show_all()
def __init__(self): super(GuideBox, self).__init__() self.scrolled_window = ScrolledWindow() self.backgroundbox = BackgroundBox() self.backgroundbox.draw_mask = self.draw_mask self.guide_pixbuf = utils.get_common_image_pixbuf('guide.png') self.top_title = gtk.HBox() self.top_left_icon = gtk.VBox() self.top_left_icon.set_size_request(self.guide_pixbuf.get_width(), self.guide_pixbuf.get_height()) self.top_left_icon.connect('expose-event', self.expose_top_left_icon) top_left_icon_align = gtk.Alignment(0.5, 0.5, 0, 0) top_left_icon_align.set_padding(15, 3, 13, 3) top_left_icon_align.add(self.top_left_icon) self.top_right_text = Label(_("Introduction"), ui_theme.get_color('label_select_background'), 14) top_right_text_align = gtk.Alignment(0.5, 0.5, 0, 0) top_right_text_align.set_padding(18, 3, 3, 3) top_right_text_align.add(self.top_right_text) self.top_title.pack_start(top_left_icon_align, False, False) self.top_title.pack_start(top_right_text_align, False, False) self.content_box = gtk.VBox() self.guide_label = Label('', enable_select=False, wrap_width=200, text_size=9, text_color=DynamicColor('#808080')) guide_label_align = gtk.Alignment(0.5, 0.5, 1, 1) guide_label_align.set_padding(5, 5, 10, 10) guide_label_align.add(self.guide_label) self.content_box.pack_start(guide_label_align, False, False) self.backgroundbox.pack_start(self.top_title, False, False) self.backgroundbox.pack_start(self.content_box) self.scrolled_window.add_child(self.backgroundbox) self.add(self.scrolled_window) global_event.register_event('download-app-info-finish', self.update_content)
def __init__(self, slide_infos, pointer_offset_x=-130, pointer_offset_y=-20, pointer_padding=20, hover_animation_time=500, auto_animation_time=2000, auto_slide_timeout=5000, horizontal_align=ALIGN_START, vertical_align=ALIGN_START, height_offset=0, hover_switch=True, auto_switch=True, navigate_switch=False, active_dpixbuf=ui_theme.get_pixbuf("slide_switcher/active.png"), inactive_dpixbuf=ui_theme.get_pixbuf("slide_switcher/inactive.png"), ): ''' Initialize SlideSwitcher class. @param slide_infos: infos fetched from network api @param pointer_offset_x: The offset x of pointer relative to right edge of slider image, default is -130 pixels. @param pointer_offset_y: The offset y of pointer relative to bottom edge of slider image, default is -20 pixels. @param pointer_padding: The padding between pointers, default is 20 pixels. @param hover_animation_time: The animation time of hover operation, default is 500 milliseconds. @param auto_animation_time: The animation time of automatic play, default is 2000 milliseconds. @param auto_slide_timeout: The slide timeout of automatic play, default is 2000 milliseconds. @param horizontal_align: The horizontal alignment, default is ALIGN_START. @param vertical_align: The vertical alignment, default is ALIGN_START. @param height_offset: The height offset, default is 0 pixels. @param hover_switch: Set as True to make slider switch when hover operation active. @param auto_switch: Set as True to make slider play automatically. @param navigate_switch: Set as True to make slider switch navigate. @param active_dpixbuf: The dynamic pixbuf of active status. @param inactive_dpixbuf: The dynamic pixbuf of inactive status. ''' EventBox.__init__(self) self.add_events(gtk.gdk.ALL_EVENTS_MASK) self.slide_infos = slide_infos self.image_number = len(self.slide_infos) self.slide_images = [] for i in xrange(self.image_number): self.slide_images.append(get_common_image_pixbuf('slide/default_cache.png')) self.active_index = 0 self.motion_index = None self.target_index = None self.active_alpha = 1.0 self.target_alpha = 0.0 self.in_animiation = False self.hover_animation_time = hover_animation_time # animiation time of hover, in milliseconds self.auto_animation_time = auto_animation_time # animiation time automatically, in milliseconds self.auto_slide_timeout = auto_slide_timeout # slide timeout, in milliseconds self.auto_slide_timeout_id = None self.horizontal_align = horizontal_align self.vertical_align = vertical_align self.hover_switch = hover_switch self.auto_switch = auto_switch self.navigate_switch = navigate_switch self.in_right_nav = False self.in_left_nav = False self.active_dpixbuf = active_dpixbuf self.inactive_dpixbuf = inactive_dpixbuf size_pixbuf = self.slide_images[0] self.pointer_offset_x = pointer_offset_x self.pointer_offset_y = pointer_offset_y self.pointer_radious = self.active_dpixbuf.get_pixbuf().get_width() / 2 self.pointer_padding = pointer_padding self.set_size_request(-1, size_pixbuf.get_height() + height_offset) self.connect("expose-event", self.expose_slide_switcher) self.connect("motion-notify-event", self.motion_notify_slide_switcher) self.connect("leave-notify-event", self.leave_notify_slide_switcher) self.connect("enter-notify-event", self.enter_notify_slide_switcher) self.connect("button-press-event", lambda w, e: self.handle_animation(w, e, True)) self.start_auto_slide() self.fetch_image_id = 0 FetchImageFromUpyun(self.slide_infos[self.fetch_image_id][2], lambda local_path: self.update_images(local_path, self.fetch_image_id)).start()
import json from dtk.ui.statusbar import Statusbar from dtk.ui.threads import post_gui from dtk.ui.box import Markbox from star_view import StarView from dtk.ui.utils import get_event_coords from theme import app_theme from button import Button, ToggleButton from events import global_event from cookie_parser import get_cookie_star, set_cookie_star from download_manager import SetStarScore from nls import _, LANGUAGE import utils STAR_SIZE = utils.get_common_image_pixbuf('star/star_on.png').get_width() """ if "pause" in self.widg #if "mute" in #self.wid if "replay" i self.widg if "favorite" self.widg if "fullscree self.widg if "share" in self.widg if "star" in self.widg
import json from dtk.ui.statusbar import Statusbar from dtk.ui.threads import post_gui from dtk.ui.box import Markbox from star_view import StarView from dtk.ui.utils import get_event_coords from theme import app_theme from button import Button, ToggleButton from events import global_event from cookie_parser import get_cookie_star, set_cookie_star from download_manager import SetStarScore from nls import _, LANGUAGE import utils STAR_SIZE = utils.get_common_image_pixbuf('star/star_on.png').get_width() """ if "pause" in self.widg #if "mute" in #self.wid if "replay" i self.widg if "favorite" self.widg if "fullscree self.widg if "share" in self.widg
def handle_animation(self, widget, event, button_press=False): # Init. rect = widget.allocation start_x = rect.width + self.pointer_offset_x - self.pointer_radious start_y = rect.height + self.pointer_offset_y self.left_retangle = (0, 0, rect.width / 3, rect.height - self.pointer_offset_y) self.right_retangle = (0 + 2 * rect.width / 3, 0, rect.width / 3, rect.height - self.pointer_offset_y) if self.image_number > 1 and ( start_y - 4 * self.pointer_radious < event.y < start_y + self.pointer_radious * 6 and start_x - 2 * self.pointer_radious < event.x < start_x + 4 * self.pointer_padding + 4 * self.pointer_radious): set_cursor(widget, gtk.gdk.HAND2) if self.hover_switch or button_press: self.motion_index = None for index in range(0, self.image_number): if start_x + index * self.pointer_padding < event.x < start_x + ( index + 1) * self.pointer_padding: self.motion_index = index if self.active_index != index: self.start_animation(self.hover_animation_time, index) break elif self.image_number > 1 and is_in_rect( (event.x, event.y), self.left_retangle) and self.navigate_switch: if not self.in_left_nav: self.in_left_nav = True self.queue_draw() #set_cursor(widget, gtk.gdk.SB_LEFT_ARROW) widget.window.set_cursor( gtk.gdk.Cursor( gtk.gdk.display_get_default(), get_common_image_pixbuf('cursor/left_arrow.png'), 0, 0)) if button_press: self.to_left_animation() elif self.image_number > 1 and is_in_rect( (event.x, event.y), self.right_retangle) and self.navigate_switch: if not self.in_right_nav: self.in_right_nav = True self.queue_draw() #set_cursor(widget, gtk.gdk.SB_RIGHT_ARROW) widget.window.set_cursor( gtk.gdk.Cursor( gtk.gdk.display_get_default(), get_common_image_pixbuf('cursor/right_arrow.png'), 0, 0)) if button_press: self.to_right_animation() else: if self.in_left_nav or self.in_right_nav: self.in_left_nav = False self.in_right_nav = False self.queue_draw() set_cursor(widget, None) if button_press: self.emit("button-press-index", self.active_index) else: self.emit("motion-notify-index", self.active_index)
def __init__( self, slide_infos, pointer_offset_x=-130, pointer_offset_y=-20, pointer_padding=20, hover_animation_time=500, auto_animation_time=2000, auto_slide_timeout=5000, horizontal_align=ALIGN_START, vertical_align=ALIGN_START, height_offset=0, hover_switch=True, auto_switch=True, navigate_switch=False, active_dpixbuf=ui_theme.get_pixbuf("slide_switcher/active.png"), inactive_dpixbuf=ui_theme.get_pixbuf( "slide_switcher/inactive.png"), ): ''' Initialize SlideSwitcher class. @param slide_infos: infos fetched from network api @param pointer_offset_x: The offset x of pointer relative to right edge of slider image, default is -130 pixels. @param pointer_offset_y: The offset y of pointer relative to bottom edge of slider image, default is -20 pixels. @param pointer_padding: The padding between pointers, default is 20 pixels. @param hover_animation_time: The animation time of hover operation, default is 500 milliseconds. @param auto_animation_time: The animation time of automatic play, default is 2000 milliseconds. @param auto_slide_timeout: The slide timeout of automatic play, default is 2000 milliseconds. @param horizontal_align: The horizontal alignment, default is ALIGN_START. @param vertical_align: The vertical alignment, default is ALIGN_START. @param height_offset: The height offset, default is 0 pixels. @param hover_switch: Set as True to make slider switch when hover operation active. @param auto_switch: Set as True to make slider play automatically. @param navigate_switch: Set as True to make slider switch navigate. @param active_dpixbuf: The dynamic pixbuf of active status. @param inactive_dpixbuf: The dynamic pixbuf of inactive status. ''' EventBox.__init__(self) self.add_events(gtk.gdk.ALL_EVENTS_MASK) self.slide_infos = slide_infos self.image_number = len(self.slide_infos) self.slide_images = [] for i in xrange(self.image_number): self.slide_images.append( get_common_image_pixbuf('slide/default_cache.png')) self.active_index = 0 self.motion_index = None self.target_index = None self.active_alpha = 1.0 self.target_alpha = 0.0 self.in_animiation = False self.hover_animation_time = hover_animation_time # animiation time of hover, in milliseconds self.auto_animation_time = auto_animation_time # animiation time automatically, in milliseconds self.auto_slide_timeout = auto_slide_timeout # slide timeout, in milliseconds self.auto_slide_timeout_id = None self.horizontal_align = horizontal_align self.vertical_align = vertical_align self.hover_switch = hover_switch self.auto_switch = auto_switch self.navigate_switch = navigate_switch self.in_right_nav = False self.in_left_nav = False self.active_dpixbuf = active_dpixbuf self.inactive_dpixbuf = inactive_dpixbuf size_pixbuf = self.slide_images[0] self.pointer_offset_x = pointer_offset_x self.pointer_offset_y = pointer_offset_y self.pointer_radious = self.active_dpixbuf.get_pixbuf().get_width() / 2 self.pointer_padding = pointer_padding self.set_size_request(-1, size_pixbuf.get_height() + height_offset) self.connect("expose-event", self.expose_slide_switcher) self.connect("motion-notify-event", self.motion_notify_slide_switcher) self.connect("leave-notify-event", self.leave_notify_slide_switcher) self.connect("enter-notify-event", self.enter_notify_slide_switcher) self.connect("button-press-event", lambda w, e: self.handle_animation(w, e, True)) self.start_auto_slide() self.fetch_image_id = 0 FetchImageFromUpyun( self.slide_infos[self.fetch_image_id][2], lambda local_path: self. update_images(local_path, self.fetch_image_id)).start()
def __init__(self, title, cancel_callback=None): DialogBox.__init__(self, title, mask_type=2, close_callback=self.dialog_close_action) self.connect('delete-event', self.dialog_close_action) self.set_size_request(480, 350) self.set_position(gtk.WIN_POS_CENTER_ON_PARENT) main_box = gtk.VBox(spacing=15) logo_image = gtk.image_new_from_pixbuf(get_common_image_pixbuf('logo24.png')) logo_name = Label(_("Deepin Game"), text_size=10) logo_box = gtk.HBox(spacing=2) logo_box.pack_start(logo_image, False, False) logo_box.pack_start(logo_name, False, False) version_label = Label(_("Version: ")) version_content = Label(PROGRAM_VERSION, DynamicColor('#4D5154')) info_box = gtk.HBox(spacing=5) info_box.pack_start(version_label, False, False) info_box.pack_start(version_content, False, False) title_box = gtk.HBox() title_box.pack_start(logo_box, False, False) align = gtk.Alignment() align.set(0, 0, 0, 1) title_box.pack_start(align, True, True) title_box.pack_start(info_box, False, False) describe = _("Deepin Game is designed by Deepin for Linux users. Here " "you will elaborately find good and safe games selected by " "professionals. Click and play the best games you have ever " "met. Deepin Game just for happiness!") describe_label = Label(describe, enable_select=False, wrap_width=430, text_size=10) main_box.pack_start(title_box, False, False) main_box.pack_start(create_separator_box(), False, True) main_box.pack_start(describe_label, False, False) links_table = gtk.Table(4, 2) links = [ (_('Weibo: '), None, 'http://weibo.com/linuxdeepinnew'), (_('Forum: '), None, 'http://www.linuxdeepin.com/forum'), (_('Feedback: '), None, 'http://www.linuxdeepin.com/mantis'), (_('Game deliver: '), '*****@*****.**', 'mailto:[email protected]'), ] for (i, l) in enumerate(links): left_text = Label(l[0]) left_text_align = self.create_right_align() left_text_align.add(left_text) right_link = LinkButton(text=l[1], link=l[2]) links_table.attach(left_text_align, 0, 1, i, i+1, xoptions=gtk.FILL, xpadding=5, ypadding=4) links_table.attach(right_link, 1, 2, i, i+1, xoptions=gtk.FILL) #main_box.pack_start(self.create_link_box(l[0], l[1], l[2]), False, False) main_box.pack_start(links_table, False, False) main_align = gtk.Alignment() main_align.set_padding(20, 0, 20, 20) main_align.set(0, 0, 1, 1) main_align.add(main_box) self.body_box.pack_start(main_align) self.ok_button = Button(_('Close')) self.ok_button.connect('clicked', self.dialog_close_action) ok_button_align = gtk.Alignment(0.5, 0.5, 0, 0) ok_button_align.set_padding(9, 11, 0, 10) ok_button_align.add(self.ok_button) self.right_button_box.pack_start(ok_button_align, False, False)
def __init__(self, title, cancel_callback=None): DialogBox.__init__(self, title, mask_type=2, close_callback=self.dialog_close_action) self.connect('delete-event', self.dialog_close_action) self.set_size_request(480, 350) self.set_position(gtk.WIN_POS_CENTER_ON_PARENT) main_box = gtk.VBox(spacing=15) logo_image = gtk.image_new_from_pixbuf(get_common_image_pixbuf('logo24.png')) logo_name = Label(_("Deepin Games"), text_size=10) logo_box = gtk.HBox(spacing=2) logo_box.pack_start(logo_image, False, False) logo_box.pack_start(logo_name, False, False) version_label = Label(_("Version: ")) version_content = Label(PROGRAM_VERSION, DynamicColor('#4D5154')) info_box = gtk.HBox(spacing=5) info_box.pack_start(version_label, False, False) info_box.pack_start(version_content, False, False) title_box = gtk.HBox() title_box.pack_start(logo_box, False, False) align = gtk.Alignment() align.set(0, 0, 0, 1) title_box.pack_start(align, True, True) title_box.pack_start(info_box, False, False) describe = _("Deepin Games is designed by Linux Deepin for Linux users. Here you will find good and safe games elaborately selected by professionals. Click and play the best games you have ever met. Deepin Games - deeper into the world of game!") describe_label = Label(describe, enable_select=False, wrap_width=430, text_size=10) main_box.pack_start(title_box, False, False) main_box.pack_start(create_separator_box(), False, True) main_box.pack_start(describe_label, False, False) links_table = gtk.Table(4, 2) links = [ (_('Weibo: '), None, 'http://weibo.com/linuxdeepinnew'), (_('Forum: '), None, 'http://www.linuxdeepin.com/forum'), (_('Feedback: '), None, 'http://www.linuxdeepin.com/mantis'), (_('Game deliver: '), '*****@*****.**', 'mailto:[email protected]'), ] for (i, l) in enumerate(links): left_text = Label(l[0]) left_text_align = self.create_right_align() left_text_align.add(left_text) right_link = LinkButton(text=l[1], link=l[2]) links_table.attach(left_text_align, 0, 1, i, i+1, xoptions=gtk.FILL, xpadding=5, ypadding=4) links_table.attach(right_link, 1, 2, i, i+1, xoptions=gtk.FILL) #main_box.pack_start(self.create_link_box(l[0], l[1], l[2]), False, False) main_box.pack_start(links_table, False, False) main_align = gtk.Alignment() main_align.set_padding(20, 0, 20, 20) main_align.set(0, 0, 1, 1) main_align.add(main_box) self.body_box.pack_start(main_align) self.ok_button = Button(_('Close')) self.ok_button.connect('clicked', self.dialog_close_action) ok_button_align = gtk.Alignment(0.5, 0.5, 0, 0) ok_button_align.set_padding(9, 11, 0, 10) ok_button_align.add(self.ok_button) self.right_button_box.pack_start(ok_button_align, False, False)