Beispiel #1
0
    def finish_initializing(self, builder):   # pylint: disable=E1002

        self.sm = SessionManager('gecos-firstart')
        self.sm.start()

        iconfile = config.get_data_file('media', '%s' % ('wizard1.png',))
        self.set_icon_from_file(iconfile)

        screen = Gdk.Screen.get_default()
        sw = math.floor(screen.width() - screen.width() / 8)
        sh = math.floor(screen.height() - screen.height() / 9)
        self.resize(sw, sh)

        self.ui.btnTest.set_visible(False)
        self.ui.btnTest.set_sensitive(False)

        self.show_browser()
        self.block()

        self.dbusclient = DBusClient()
        self.dbusclient.connect('state-changed', self.on_dbusclient_state_changed)

        try:
            self.dbusclient.start()
            self.dbusclient.user_login()
            state = self.dbusclient.get_state(reply_handler=self.reply_handler, error_handler=self.error_handler)

        except Exception as e:
            self.unblock()
Beispiel #2
0
class FirstartWindow(Window):

    __gtype_name__ = "FirstartWindow"

    def finish_initializing(self, builder):   # pylint: disable=E1002

        self.sm = SessionManager('gecos-firstart')
        self.sm.start()

        iconfile = config.get_data_file('media', '%s' % ('wizard1.png',))
        self.set_icon_from_file(iconfile)

        screen = Gdk.Screen.get_default()
        sw = math.floor(screen.width() - screen.width() / 8)
        sh = math.floor(screen.height() - screen.height() / 9)
        self.resize(sw, sh)

        self.ui.btnTest.set_visible(False)
        self.ui.btnTest.set_sensitive(False)

        self.show_browser()
        self.block()

        self.dbusclient = DBusClient()
        self.dbusclient.connect('state-changed', self.on_dbusclient_state_changed)

        try:
            self.dbusclient.start()
            self.dbusclient.user_login()
            state = self.dbusclient.get_state(reply_handler=self.reply_handler, error_handler=self.error_handler)

        except Exception as e:
            self.unblock()

    def show_browser(self):
        self.webview = webkit.WebView()
        self.ui.scContent.add(self.webview)
        self.webview.show()

    def reply_handler(self, state):
        if state == DBC_STATE_FINISHED:
            self.unblock()

    def error_handler(self, e):
        self.unblock()

    def translate(self):
        self.set_title(_('Guadalinex GECOS Guide'))
        self.ui.btnTest.set_label(_('Test'))
        self.ui.btnClose.set_label(_('Close'))

    def on_delete_event(self, widget, data=None):
        self.ungrab()
        return False

    def on_btnTest_clicked(self, widget):
        self.block()
        self.dbusclient.user_login()

    def on_btnClose_clicked(self, widget):
        self.sm.stop()
        self.ungrab()
        self.destroy()

    def on_show(self, widget):
        self.grab()

    def on_grab_broken_event(self, widget, event, user_data):
        self.grab()

    def on_dbusclient_state_changed(self, sender, state):
        if state == DBC_STATE_STOPPED:
            #print 'stopped...'
            pass

        elif state == DBC_STATE_RUNNING:
            #print 'running...'
            pass

        elif state == DBC_STATE_FINISHED:
            self.unblock()

    def block(self):
        self.webview.load_uri(GECOS_BLOCKED_URI)
        self.ui.btnClose.set_sensitive(False)
        self.ui.lblInfo.set_label(_('Please, wait while your system is being configured ...'))

    def unblock(self):
        self.webview.load_uri(GECOS_UNBLOCKED_URI)
        self.ui.btnClose.set_sensitive(True)
        self.ui.lblInfo.set_label(_('Your system has been configured.'))

    def grab(self):
        #return
        w = self.get_window()
        i = 0
        while i < 10:
            i = i + 1
            r = Gdk.keyboard_grab(w, False, 0L)
            #print r
            if r == Gdk.GrabStatus.SUCCESS:
                break
            time.sleep(1)
        r = Gdk.pointer_grab(w, True, 0, w, None, 0L)
        #print r

    def ungrab(self):
        r = Gdk.keyboard_ungrab(0L)
        r = Gdk.pointer_ungrab(0L)