def __init__(self): WebView.__init__(self) self.load_finish_flag = False self.set_property('can-focus', True) self.set_property('can-default', True) self.set_full_content_zoom(1) self.clipbord = gtk.Clipboard() settings = self.get_settings() try: settings.set_property('enable-universal-access-from-file-uris', True) settings.set_property('javascript-can-access-clipboard', True) settings.set_property('enable-default-context-menu', True) settings.set_property('enable-page-cache', True) settings.set_property('tab-key-cycles-through-elements', True) settings.set_property('enable-file-access-from-file-uris', True) settings.set_property('enable-spell-checking', False) settings.set_property('enable-caret-browsing', False) try: # Since 1.7.5 settings.set_property('enable-accelerated-compositing', True) except TypeError: pass except: print 'Error: settings property was not set.' webkit.set_web_database_directory_path(config.DB_DIR) webkit.set_default_web_database_quota(1024**3L) ## bind events self.connect('navigation-requested', self.on_navigation_requested) self.connect('new-window-policy-decision-requested', self.on_new_window_requested) self.connect('script-alert', self.on_script_alert) self.connect('load-finished', self.on_load_finish) self.connect("hovering-over-link", self.on_over_link) # self.connect('drag_data_received', self.on_drag_data_received) # self.connect('drag_motion', self.on_drag_motion) # self.connect('drag_drop', self.on_drag_drop) # self.drag_dest_set(gtk.DEST_DEFAULT_DROP, # dnd_list, gtk.gdk.ACTION_COPY) templatefile = utils.get_ui_object(config.TEMPLATE) template = open(templatefile, 'rb').read() self.load_html_string(template, 'file://' + templatefile)
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__(self): WebView.__init__(self) self.load_finish_flag = False self.set_property('can-focus', True) self.set_property('can-default', True) self.set_full_content_zoom(1) self.clipbord = gtk.Clipboard() settings = self.get_settings() try: settings.set_property('enable-universal-access-from-file-uris', True) settings.set_property('javascript-can-access-clipboard', True) settings.set_property('enable-default-context-menu', True) settings.set_property('enable-page-cache', True) settings.set_property('tab-key-cycles-through-elements', True) settings.set_property('enable-file-access-from-file-uris', True) settings.set_property('enable-spell-checking', True) settings.set_property('enable-caret-browsing', False) except: print 'Error: settings property was not set.' webkit.set_web_database_directory_path(config.DB_DIR) webkit.set_default_web_database_quota(1024**3L) ## bind events self.connect('navigation-requested', self.on_navigation_requested); self.connect('new-window-policy-decision-requested', self.on_new_window_requested); self.connect('script-alert', self.on_script_alert); self.connect('load-finished', self.on_load_finish); self.connect("hovering-over-link", self.on_over_link); templatefile = utils.get_ui_object(config.TEMPLATE) template = open(templatefile, 'rb').read() self.load_html_string(template, 'file://' + templatefile)