Example #1
0
    def __init__(self, session_bus, appid, dbus_name, dbus_path):
        dbus.service.Object.__init__(self, session_bus, dbus_path)

        self.appid = appid
        self.dbus_name = dbus_name
        self.dbus_path = dbus_path
        
        # WARING: only use once in one process
        DBusGMainLoop(set_as_default=True) 
        
        self.plug = gtk.Plug(0)

        self.webview = WebView(COOKIE_FILE)
        self.webview.connect('title-changed', self.webview_message_handler)
        self.webview.connect('script-alert', self.webview_message_handler)
        #self.webview.enable_inspector()
        self.paned_box = PanedBox(2, True, 2, True)
        self.paned_box.enter_bottom_win_callback = self.enter_bottom_notify
        self.paned_box.enter_top_win_callback = self.enter_top_notify
        self.paned_box.add_content_widget(self.webview)
        self.plug.add(self.paned_box)
        self.plug.connect('delete-event', self.plug_delete_event)
        
        # Handle signals.
        self.plug.connect("realize", self.flash_frame_realize)
        self.plug.connect("destroy", self.flash_frame_exit)

        glib.timeout_add(1000, self.is_exist)
        glib.timeout_add(200, self.connect_signal)

        def message_receiver(self, *message):
            message_type, contents = message
            if message_type == 'exit':
                self.exit()
            elif message_type == 'load_uri':
                self.load_flash(contents)
            elif message_type == 'load_loading_uri':
                self.webview.load_uri(contents)
                self.send_message('loading_uri_finish', '')
            elif message_type == 'load_string':
                self.webview.load_string(contents)
            elif message_type == 'get_plug_id':
                self.send_flash_info()
            elif message_type == 'app_info_download_finish':
                self.webview.execute_script("app_info=%s" %
                        json.dumps(str(contents), encoding="UTF-8", ensure_ascii=False))

        setattr(FlashFrame, 
                'message_receiver', 
                dbus.service.method(dbus_name)(message_receiver))
Example #2
0
    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()