def __init__(self, appid): ''' init docs ''' gtk.VBox.__init__(self) self.appid = appid self.socket = None self.socket_box = gtk.EventBox() self.socket_box.connect("realize", self._add_socket) self.screenshot_box = gtk.EventBox() self.screenshot_box.connect('expose-event', self.screenshot_box_expose) self.center_play_box = gtk.EventBox() self.center_play_box.connect('expose-event', self.center_play_box_expose) self.center_play_box.set_size_request(72, 72) center_align = gtk.Alignment(0.5, 0.5, 0, 0) #center_align.add(self.center_play_box) self.play_button = ImageButton( DynamicPixbuf(utils.get_common_image('pause/play_normal.png')), DynamicPixbuf(utils.get_common_image('pause/play_hover.png')), DynamicPixbuf(utils.get_common_image('pause/play_press.png')), ) center_align.add(self.play_button) self.screenshot_box.add(center_align) self.screenshot_pixbuf = None
def init_ui(self): self.application = PlayerApplication(destroy_func=self.quit, max_callback=self.max_callback) if self.width+12 < 642: width = 642 + 220 else: width = self.width + 12 + 220 self.application.set_default_size(width, self.height+73) self.application.set_skin_preview(get_common_image("frame.png")) self.application.set_icon(get_common_image("logo48.png")) self.application.add_titlebar( ["mode", "min", "max", "close"], ) player_title = _("Deepin Games - %s ") % self.game_name self.window = self.application.window self.window.set_title(player_title) self.application.titlebar.change_name(player_title) self.application.titlebar.mode_button.set_active(True) self.application.titlebar.mode_button.connect('toggled', self.change_view) self.application.titlebar.close_button.connect('clicked', self.quit) #self.application.window.connect('focus-out-event', self.window_out_focus_hander) self.application.window.set_position(gtk.WIN_POS_CENTER) self.application.window.connect('focus-in-event', self.window_in_focus_hander) self.application.window.connect('window-state-event', self.window_state_change_handler) self.application.window.connect('key-press-event', self.window_key_press_handler) self.page_box = gtk.HBox() self.content_page = ContentPage(self.appid) self.content_page.screenshot_box.connect('button-press-event', self.external_continue_action) self.content_page.play_button.connect('button-press-event', self.external_continue_action) self.guide_box = GuideBox() self.guide_box.set_size_request(220, -1) self.page_align = gtk.Alignment() self.page_align.set(0.5, 0.5, 1, 1) self.page_align.set_padding(0, 0, 2, 2) self.control_toolbar = self.create_toolbar(["star"]) self.page_box.pack_start(self.content_page) self.page_box.pack_start(self.guide_box, False) self.inner_top_titlebar = self.create_top_titlebar() self.inner_top_titlebar.change_name(player_title) inner_widgets = ControlToolbar.widgets_id[:] inner_widgets.remove("star") self.inner_control_toolbar = self.create_toolbar(inner_widgets) self.paned_box = PanedBox() self.paned_box.add_content_widget(self.page_box) self.paned_box.add_bottom_widget(self.inner_control_toolbar) self.paned_box.add_top_widget(self.inner_top_titlebar) self.page_align.add(self.paned_box) self.application.main_box.pack_start(self.page_align) self.application.window.add_move_event(self.control_toolbar) self.show_bottom = False self.display_normal()
def favorite_animation(window): # Add install animation. (screen, px, py, modifier_type) = window.get_display().get_pointer() ax, ay = px, py (wx, wy) = window.window.get_origin() offset_bx = 480 offset_by = 5 bx, by = wx + offset_bx, wy + offset_by offset_cx = 10 offset_cy = 10 if ax < bx: cx, cy = wx + offset_bx + offset_cx, wy + offset_by + offset_cy else: cx, cy = wx + offset_bx - offset_cx, wy + offset_by + offset_cy [[a], [b], [c]] = solve_parabola((ax, ay), (bx, by), (cx, cy)) icon_window = IconWindow(utils.get_common_image('heart/heartx2.png')) icon_window.move(ax, ay) icon_window.show_all() timeline = Timeline(500, CURVE_SINE) timeline.connect( "update", lambda source, status: update(source, status, icon_window, (ax, ay), (bx, by), (cx, cy), (a, b, c))) timeline.connect("completed", lambda source: finish(source, icon_window)) timeline.run()
def show_wizard_win(self, show_button=False, callback=None): self.wizard_win = Wizard( [get_common_locale_image('wizard', '%s.png' % i) for i in range(3)], ( get_common_image('wizard/dot_normal.png'), get_common_image('wizard/dot_active.png'), ), ( get_common_locale_image('wizard', 'start_normal.png'), get_common_locale_image('wizard', 'start_press.png'), ), show_button, callback ) self.wizard_win.show_all()
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 = gtk.gdk.pixbuf_new_from_file(get_common_image("network/failed_%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 favorite_animation(window): # Add install animation. (screen, px, py, modifier_type) = window.get_display().get_pointer() ax, ay = px, py (wx, wy) = window.window.get_origin() offset_bx = 480 offset_by = 5 bx, by = wx + offset_bx, wy + offset_by offset_cx = 10 offset_cy = 10 if ax < bx: cx, cy = wx + offset_bx + offset_cx, wy + offset_by + offset_cy else: cx, cy = wx + offset_bx - offset_cx, wy + offset_by + offset_cy [[a], [b], [c]] = solve_parabola((ax, ay), (bx, by), (cx, cy)) icon_window = IconWindow(utils.get_common_image('heart/heartx2.png')) icon_window.move(ax, ay) icon_window.show_all() timeline = Timeline(500, CURVE_SINE) timeline.connect("update", lambda source, status: update(source, status, icon_window, (ax, ay), (bx, by), (cx, cy), (a, b, c))) timeline.connect("completed", lambda source: finish(source, icon_window)) timeline.run()
def send_notify(self, body, summary): app_name = "deepin-software-center" replaces_id = 0 app_icon = utils.get_common_image("logo48.png") actions = ["_id_default_", "default", "_id_open_update_", _("Upgrade")] hints = {"image-path": app_icon} timeout = 3500 return self.notify_interface.Notify(app_name, replaces_id, app_icon, summary, body, actions, hints, timeout)
def __init__(self): super(LoadingBox, self).__init__() loading_pixbuf = gtk.gdk.PixbufAnimation(get_common_image("loading.gif")) loading_image = gtk.Image() loading_image.set_from_animation(loading_pixbuf) main_box = gtk.VBox(spacing=5) main_box.pack_start(loading_image) self.add(set_widget_vcenter(main_box))
def init_ui(self): self.application = PlayerApplication(destroy_func=self.quit, max_callback=self.max_callback) if self.width + 12 < 642: width = 642 + 220 else: width = self.width + 12 + 220 self.application.set_default_size(width, self.height + 73) self.application.set_skin_preview(get_common_image("frame.png")) self.application.set_icon(get_common_image("logo48.png")) self.application.add_titlebar(["mode", "min", "max", "close"], ) player_title = _("Deepin Game - %s ") % self.game_name self.window = self.application.window self.window.set_title(player_title) self.application.titlebar.change_name(player_title) self.application.titlebar.mode_button.set_active(True) self.application.titlebar.mode_button.connect('toggled', self.change_view) self.application.titlebar.close_button.connect('clicked', self.quit) #self.application.window.connect('focus-out-event', self.window_out_focus_hander) self.application.window.set_position(gtk.WIN_POS_CENTER) self.application.window.connect('focus-in-event', self.window_in_focus_hander) self.application.window.connect('window-state-event', self.window_state_change_handler) self.application.window.connect('key-press-event', self.window_key_press_handler) self.page_box = gtk.HBox() self.content_page = ContentPage(self.appid) self.content_page.screenshot_box.connect('button-press-event', self.external_continue_action) self.content_page.play_button.connect('button-press-event', self.external_continue_action) self.guide_box = GuideBox() self.guide_box.set_size_request(220, -1) self.page_align = gtk.Alignment() self.page_align.set(0.5, 0.5, 1, 1) self.page_align.set_padding(0, 0, 2, 2) self.control_toolbar = self.create_toolbar(["star"]) self.page_box.pack_start(self.content_page) self.page_box.pack_start(self.guide_box, False) self.inner_top_titlebar = self.create_top_titlebar() self.inner_top_titlebar.change_name(player_title) inner_widgets = ControlToolbar.widgets_id[:] inner_widgets.remove("star") self.inner_control_toolbar = self.create_toolbar(inner_widgets) self.paned_box = PanedBox() self.paned_box.add_content_widget(self.page_box) self.paned_box.add_bottom_widget(self.inner_control_toolbar) self.paned_box.add_top_widget(self.inner_top_titlebar) self.page_align.add(self.paned_box) self.application.main_box.pack_start(self.page_align) self.application.window.add_move_event(self.control_toolbar) self.show_bottom = False self.display_normal()
def init_ui(self): self.application = Application() self.application.set_default_size(1000, 660) self.application.set_skin_preview(get_common_image("frame.png")) self.application.set_icon(get_common_image("logo48.png")) self.application.add_titlebar( ["theme", "menu", "max","min", "close"], show_title=False ) self.application.window.set_title(_("Deepin Games")) # Init page box. self.page_box = gtk.VBox() self.page_box.connect('expose-event', self.page_box_render) # Init page align. self.page_align = gtk.Alignment() self.page_align.set(0.5, 0.5, 1, 1) self.page_align.set_padding(0, 0, 2, 2) # Append page to switcher. self.paned_box = PanedBox(24) self.paned_box.add_content_widget(self.page_box) self.bottom_tip_bar = BottomTipBar() self.bottom_tip_bar.close_button.connect('clicked', lambda w: self.paned_box.bottom_window.hide()) self.paned_box.add_bottom_widget(self.bottom_tip_bar) self.page_align.add(self.paned_box) self.application.main_box.pack_start(self.page_align, True, True) # Init status bar. self.statusbar = Statusbar(30) status_box = gtk.HBox() self.statusbar.status_box.pack_start(status_box, True, True) self.application.main_box.pack_start(self.statusbar, False, False) self.webview = WebView(COOKIE_FILE) webkit.set_web_database_directory_path(CACHE_DIR) web_settings = self.webview.get_settings() web_settings.set_property("enable-page-cache", True) web_settings.set_property("enable-offline-web-application-cache", True) #web_settings.set_property("enable-file-access-from-file-uris", True) web_settings.set_property("enable-xss-auditor", False) web_settings.set_property('enable-universal-access-from-file-uris', True) web_settings.set_property("enable-default-context-menu", False) self.webview.set_settings(web_settings) #self.webview.enable_inspector() self.webview.connect('new-window-policy-decision-requested', self.navigation_policy_decision_requested_cb) #self.webview.connect('notify::load-status', self.webview_load_status_handler) self.webview.connect('notify::title', self.webview_title_changed_handler) self.webview.connect('script-alert', self.webview_script_alert_handler) self.webview.connect('window-object-cleared', self.webview_window_object_cleared) #self.webview.connect('load-progress-changed', self.load_progress) self.home_url = urllib.basejoin(GAME_CENTER_SERVER_ADDRESS, 'game/?hl=%s' % LANGUAGE) self.network_failed_box = NetworkConnectFailed(self.check_network_connection) self.check_network_connection() #self.page_box.add(self.network_failed_box) self.navigatebar = Navigatebar( [ (None, _("Home"), self.show_home_page), (None, _("Topics"), self.show_subject_page), (None, _("My Games"), self.show_mygame_page), ], font_size = 11, padding_x = 5, padding_y = 16, vertical=False, item_normal_pixbuf=DynamicPixbuf(get_common_image('top/nav_normal.png')), item_hover_pixbuf=DynamicPixbuf(get_common_image('top/nav_hover.png')), item_press_pixbuf=DynamicPixbuf(get_common_image('top/nav_press.png')), ) self.navigatebar.set_size_request(-1, 56) self.navigatebar_align = gtk.Alignment(0, 0, 1, 1) self.navigatebar_align.set_padding(0, 0, 4, 0) self.navigatebar_align.add(self.navigatebar) self.application.titlebar.set_size_request(-1, 56) self.application.titlebar.left_box.pack_start(self.navigatebar_align, True, True) self.application.window.add_move_event(self.navigatebar) self.about_dialog = AboutDialog(_('About us')) self.about_dialog.set_transient_for(self.application.window) # Init menu. #if LANGUAGE == 'en_US': #menu_min_width = 185 #else: #menu_min_width = 150 menu = Menu( [ (None, _("Clear all cached data"), self.clean_download_cache), (None, _("See what's new"), lambda : self.show_wizard_win()), (None, _("About us"), self.show_about_dialog), (None, _("Quit"), lambda: gtk.main_quit()), ], is_root_menu=True, #menu_min_width=menu_min_width, ) self.application.set_menu_callback( lambda button: menu.show( get_widget_root_coordinate(button, WIDGET_POS_BOTTOM_LEFT), (button.get_allocation().width, 0))) self.no_favorite_html_path = os.path.join(static_dir, "error-no-favorite.html") self.no_recent_html_path = os.path.join(static_dir, "error-no-recent.html") self.mygame_frame_path = os.path.join(static_dir, "mygame-frame.html") self.gallery_html_path = os.path.join(static_dir, 'game-mygame.html') skin_config.connect('theme-changed', self.theme_changed_handler) global_event.register_event('show-message', self.update_message)
def init_ui(self): self.loginfo("Init ui") # Init application. self.application = Application( resizable=False, destroy_func=self.application_close_window, ) self.application.set_default_size(888, 634) self.application.set_skin_preview(utils.get_common_image("frame.png")) self.application.set_icon(utils.get_common_image("logo48.png")) self.application.add_titlebar( ["theme", "menu", "min", "close"], show_title=False ) self.application.window.set_title(_("Deepin Store")) self.application.window.connect("delete-event", self.application_close_window) # Init page box. self.page_box = gtk.VBox() # Init page switcher. self.page_switcher = HSlider(200) self.page_switcher.append_page(self.page_box) self.page_switcher.set_to_page(self.page_box) # Init page align. self.page_align = gtk.Alignment() self.page_align.set(0.5, 0.5, 1, 1) self.page_align.set_padding(0, 0, 2, 2) # Append page to switcher. self.paned_box = PanedBox(24) self.paned_box.add_content_widget(self.page_switcher) self.bottom_tip_bar = BottomTipBar() self.bottom_tip_bar.close_button.connect('clicked', lambda w: self.paned_box.bottom_window.hide()) self.paned_box.add_bottom_widget(self.bottom_tip_bar) self.page_align.add(self.paned_box) self.application.main_box.pack_start(self.page_align, True, True) # Init status bar. self.statusbar = Statusbar(24) status_box = gtk.HBox() self.message_box = gtk.HBox() self.message_label = Label("", enable_gaussian=True) label_align = gtk.Alignment() label_align.set(0.0, 0.5, 0, 0) label_align.set_padding(0, 0, 10, 0) label_align.add(self.message_label) self.message_box.pack_start(label_align) join_us_button = LinkButton(_("Join us"), "http://www.linuxdeepin.com/joinus/job") join_us_button_align = gtk.Alignment() join_us_button_align.set(0.5, 0.5, 0, 0) join_us_button_align.set_padding(0, 3, 0, 10) join_us_button_align.add(join_us_button) status_box.pack_start(self.message_box, True, True) status_box.pack_start(join_us_button_align, False, False) self.statusbar.status_box.pack_start(status_box, True, True) self.application.main_box.pack_start(self.statusbar, False, False) # Init navigatebar. self.detail_page = None self.home_page = None self.upgrade_page = None self.uninstall_page = None self.install_page = None self.navigatebar = Navigatebar( [ (DynamicPixbuf(utils.get_common_image("navigatebar/nav_home.png")), _("Home"), self.show_home_page), (DynamicPixbuf(utils.get_common_image("navigatebar/nav_update.png")), _("Upgrade"), self.show_upgrade_page), (DynamicPixbuf(utils.get_common_image("navigatebar/nav_uninstall.png")), _("Uninstall"), self.show_uninstall_page), (DynamicPixbuf(utils.get_common_image("navigatebar/nav_download.png")), _("Installation"), self.show_install_page), ], font_size = 11, padding_x = 2, padding_y = 2, vertical=False, item_hover_pixbuf=DynamicPixbuf(utils.get_common_image("navigatebar/nav_hover.png")), item_press_pixbuf=DynamicPixbuf(utils.get_common_image("navigatebar/nav_press.png")), ) self.navigatebar.set_size_request(-1, 56) self.navigatebar_align = gtk.Alignment(0, 0, 1, 1) self.navigatebar_align.set_padding(0, 0, 4, 0) self.navigatebar_align.add(self.navigatebar) self.application.titlebar.set_size_request(-1, 56) self.application.titlebar.left_box.pack_start(self.navigatebar_align, True, True) self.application.window.add_move_event(self.navigatebar) # Init menu. if LANGUAGE == 'en_US': menu_min_width = 185 else: menu_min_width = 150 menu = Menu( [ (None, _("Refresh package lists"), lambda:global_event.emit('start-update-list')), (None, _("Open download directory"), self.open_download_directory), (None, _("Clear up cached packages"), self.clean_download_cache), (None, _("View new features"), lambda : self.show_wizard_win()), (self.get_pixbuf_group("menu", "setting"), _("Preferences"), self.show_preference_dialog), (self.get_pixbuf_group("menu", "close"), _("Quit"), self.exit), ], is_root_menu=True, menu_min_width=menu_min_width, ) self.application.set_menu_callback( lambda button: menu.show( get_widget_root_coordinate(button, WIDGET_POS_BOTTOM_LEFT), (button.get_allocation().width, 0))) self.preference_dialog = DscPreferenceDialog() if hasattr(self, 'recommend_status'): self.init_home_page(self.recommend_status) else: self.init_home_page()