Ejemplo n.º 1
0
    def on_btnInstall_clicked(self, widget):
        actionNr = self.pages[self.currentPage][0]
        if actionNr > 0:
            # Check if there is an internet connection
            if not hasInternetConnection():
                title = _("No internet connection")
                msg = _(
                    "You need an internet connection to install the additional software.\n"
                    "Please, connect to the internet and try again.")
                MessageDialogSafe(title, msg, Gtk.MessageType.WARNING,
                                  self.window).show()
                return

            self.set_buttons_state(False)

            # Check for installation script
            msg = _("Please enter your password")
            page = self.pages[self.currentPage][1]
            script = join(self.scriptDir, "scripts/{}".format(page))
            if exists(script):
                if actionNr == 1:
                    self.exec_command(
                        "gksudo -m \"{}\" \"/bin/sh -c {}\"".format(
                            msg, script))
                elif actionNr == 2:
                    os.system("/bin/sh -c \"{}\" &".format(script))
                    self.set_buttons_state(True)
            else:
                msg = _("Cannot install the requested software:\n"
                        "Script not found: {}".format(script))
                MessageDialogSafe(self.btnInstall.get_label(), msg,
                                  Gtk.MessageType.ERROR, self.window).show()
Ejemplo n.º 2
0
 def showUserFeedback(self, returnList, title, action, parent):
     msg = ""
     closeWin = False
     for line in returnList:
         msg += "%s\n" % line
     if msg != "":
         MessageDialogSafe(title, msg, Gtk.MessageType.ERROR, parent).show()
     else:
         shareExists = self.us.doesShareExist(self.shareName)
         if action == "removed" and shareExists:
             msg = _("Could not remove share: '%(share)s'") % {
                 "share": self.shareName
             }
         elif action == "created" and not shareExists:
             msg = _("Could not create share: '%(share)s'") % {
                 "share": self.shareName
             }
         else:
             msg = _(
                 "Share successfully %(action)s:\n\n'%(share)s' on %(path)s"
             ) % {
                 "action": action,
                 "share": self.shareName,
                 "path": self.sharePath
             }
             closeWin = True
         MessageDialogSafe(title, msg, Gtk.MessageType.INFO, parent).show()
     return closeWin
Ejemplo n.º 3
0
    def checkSaveThread(self):
        #print 'Thread count = ' + str(threading.active_count())
        # As long there's a thread active, keep spinning
        if threading.active_count() > 1:
            self.pbDPM.pulse()
            return True

        # Get the new data
        self.pbDPM.set_fraction(0)
        self.currentTheme = self.plymouth.getCurrentTheme()
        self.currentResolution = self.plymouth.getCurrentResolution()
        self.installedThemes = self.plymouth.getInstalledThemes()
        self.availableThemes = self.plymouth.getAvailableThemes()
        if self.selectedMenuItem == menuItems[0]:
            self.on_btnPlymouth_clicked(None, None, True)

        # Thread is done: make button sensitive again
        self.toggleGuiElements(False)
        self.log.write(
            _("Done saving settings: %(theme)s (%(res)s)") % {
                "theme": self.currentTheme,
                "res": self.currentResolution
            }, 'dpm.checkSaveThread', 'info')

        title = _("Save settings")
        msg = _("Theme: %(theme)s\nResolution: %(res)s\n\nDone") % {
            "theme": self.currentTheme,
            "res": str(self.currentResolution)
        }
        self.log.write(msg, 'dpm.checkSaveThread')
        MessageDialogSafe(title, msg, Gtk.MessageType.INFO, self.window).show()
        return False
Ejemplo n.º 4
0
 def show_message(self, cmdOutput, onlyOnError=False):
     try:
         msg = _("There was an error during the installation.\n"
                 "Please, run 'sudo apt-get -f install' in a terminal.\n"
                 "Visit our forum for support: http://forums.solydxk.com")
         if int(cmdOutput) != 255:
             if int(cmdOutput) > 0:
                 # There was an error
                 MessageDialogSafe(self.btnInstall.get_label(), msg,
                                   Gtk.MessageType.ERROR,
                                   self.window).show()
             elif not onlyOnError:
                 msg = _("The software has been successfully installed.")
                 MessageDialogSafe(self.btnInstall.get_label(), msg,
                                   Gtk.MessageType.INFO,
                                   self.window).show()
     except:
         MessageDialogSafe(self.btnInstall.get_label(), cmdOutput,
                           Gtk.MessageType.INFO, self.window).show()
Ejemplo n.º 5
0
 def preview(self):
     # Check if the selected have been saved
     if self.currentTheme == self.selectedTheme and self.currentResolution == self.selectedResolution:
         self.plymouth.previewPlymouth()
     else:
         title = _("Preview")
         msg = _(
             "You must save before you can preview:\n\nTheme: %(theme)s\nResolution: %(res)s"
         ) % {
             "theme": self.selectedTheme,
             "res": self.selectedResolution
         }
         MessageDialogSafe(title, msg, Gtk.MessageType.INFO,
                           self.window).show()
Ejemplo n.º 6
0
    def exec_command(self, command):
        try:
            # Run the command in a separate thread
            print(("Run command: {}".format(command)))
            name = 'aptcmd'
            t = ExecuteThreadedCommands([command], self.queue)
            self.threads[name] = t
            t.daemon = True
            t.start()
            self.queue.join()
            GObject.timeout_add(250, self.check_thread, name)

        except Exception as detail:
            MessageDialogSafe(self.btnInstall.get_label(), detail,
                              Gtk.MessageType.ERROR, self.window).show()
Ejemplo n.º 7
0
    def removeTheme(self):
        self.threadAction = _("remove")
        self.threadPackage = self.plymouth.getRemovablePackageName(
            self.selectedRemoveTheme)
        if self.threadPackage:
            dialog = QuestionDialog(
                _("Remove theme"),
                _("Continue removing theme:\n%(theme)s") %
                {"theme": self.threadPackage}, self.window)
            go = dialog.show()
            if (go):
                self.toggleGuiElements(True)

                # Start apt in a separate thread
                self.log.write(
                    _("Start removing theme: %(theme)s") %
                    {"theme": self.threadPackage}, 'dpm.removeTheme', 'info')
                cmd = 'apt-get purge -y %s %s' % (self.force,
                                                  self.threadPackage)
                t = ExecuteApt(self.log, cmd, self.queue)
                t.daemon = True
                t.start()
                self.queue.join()

                #self.log.write("Check every 250 miliseconds if thread is still active", 'dpm.removeTheme')
                GObject.timeout_add(250, self.checkAptThread)
            else:
                self.log.write(
                    _("User cancel remove theme: %(theme)s") %
                    {"theme": self.threadPackage}, 'dpm.removeTheme', 'info')
        else:
            title = _("%(act1)s%(act2)s theme") % {
                "act1": self.threadAction[0].capitalize(),
                "act2": self.threadAction[1:]
            }
            msg = _(
                "The package cannot be removed: %(pck)s\nIt is part of a meta package.\nTry apt instead"
            ) % {
                "pck": self.selectedRemoveTheme
            }
            self.log.write(msg, 'dpm.removeTheme')
            MessageDialogSafe(title, msg, Gtk.MessageType.INFO,
                              self.window).show()
Ejemplo n.º 8
0
    def checkGrubThread(self):
        # As long there's a thread active, keep spinning
        if threading.active_count() > 1:
            self.pbDPM.pulse()
            return True

        # Thread is done
        self.pbDPM.set_fraction(0)
        self.currentGrubResolution = self.grub.getCurrentResolution()
        if self.selectedMenuItem == menuItems[2]:
            self.on_btnGrub_clicked(None, None, True)

        self.toggleGuiElements(False)
        title = _("Grub resolution")
        msg = _("Grub resolution saved: %(res)s") % {
            "res": self.selectedGrubResolution
        }
        self.log.write(msg, 'dpm.setGrubResolution', 'info')
        MessageDialogSafe(title, msg, Gtk.MessageType.INFO, self.window).show()
        return False
Ejemplo n.º 9
0
    def checkAptThread(self):
        # As long there's a thread active, keep spinning
        if threading.active_count() > 1:
            self.pbDPM.pulse()
            return True

        # Thread is done
        self.pbDPM.set_fraction(0)

        # Get the error data from the queue
        aptError = self.queue.get()

        # Get the new data
        self.installedThemes = self.plymouth.getInstalledThemes()
        self.availableThemes = self.plymouth.getAvailableThemes()
        if self.selectedMenuItem == menuItems[1]:
            self.on_btnThemes_clicked(None, None, True)

        self.toggleGuiElements(False)
        title = _("%(act1)s%(act2)s theme") % {
            "act1": self.threadAction[0].capitalize(),
            "act2": self.threadAction[1:]
        }
        if aptError:
            msg = _(
                "Could not %(action)s theme:\n%(theme)s\nTry apt instead.\n\nError message:\n%(err)s"
            ) % {
                "action": self.threadAction,
                "theme": self.threadPackage,
                "err": aptError
            }
        else:
            msg = _("%(action)s successfully of:\n%(pck)s") % {
                "action":
                self.threadAction[0].capitalize() + self.threadAction[1:],
                "pck": self.threadPackage
            }

        self.log.write(msg, 'dpm.checkAptThread')
        MessageDialogSafe(title, msg, Gtk.MessageType.INFO, self.window).show()
        return False
Ejemplo n.º 10
0
    def on_btnSave_clicked(self, widget):
        saved = False
        saveHideUsers = False
        saveAutoUser = False
        saveFaces = False
        saveBackground = False
        saveTheme = False
        if self.chkHideUsers.get_active() != self.curHideUsers:
            saveHideUsers = True
        if self.curAutoUser != self.newAutoUser:
            saveAutoUser = True
        if self.newFaces:
            saveFaces = True
        if self.curBgPath != self.newbgImg:
            saveBackground = True
        self.newTheme = self.cmbHandlerThemes.getValue()
        if self.curTheme != self.newTheme:
            saveTheme = True

        if saveHideUsers or saveAutoUser or saveFaces or saveBackground or saveTheme:
            qd = QuestionDialog(
                _("LightDM settings"),
                _("Settings have changed\n\nDo you want to save the new settings?"
                  ), self.window)
            answer = qd.show()
            if answer:
                if saveAutoUser:
                    if self.newAutoUser is not None:
                        # Save the auto-login user
                        self.cfgLightdm.setValue('SeatDefaults',
                                                 'autologin-user',
                                                 self.newAutoUser)
                        self.cfgLightdm.setValue('SeatDefaults',
                                                 'autologin-user-timeout', '0')
                        self.curAutoUser = self.newAutoUser
                        self.log.write(
                            "New auto-login user: %(usr)s" %
                            {"usr": self.curAutoUser},
                            'LightDMManager.saveSettings', 'debug')
                    else:
                        self.cfgLightdm.removeOption('SeatDefaults',
                                                     'autologin-user')
                        self.cfgLightdm.removeOption('SeatDefaults',
                                                     'autologin-user-timeout')
                        self.curAutoUser = None
                        self.log.write("Auto-login disabled",
                                       'LightDMManager.saveSettings', 'debug')
                if saveHideUsers:
                    hideUsers = str(self.chkHideUsers.get_active()).lower()
                    self.cfgLightdm.setValue('SeatDefaults',
                                             'greeter-hide-users', hideUsers)
                    self.log.write(
                        "Hide users saved: %(users)s" % {"users": hideUsers},
                        'LightDMManager.saveSettings', 'debug')
                if saveFaces:
                    for face in self.newFaces:
                        if exists(face[0]):
                            copy(face[0], face[1])
                            if exists(face[1]):
                                os.system(
                                    "chown %(owner)s:%(group)s %(path)s" % {
                                        "owner": face[2],
                                        "group": face[3],
                                        "path": face[1]
                                    })
                    self.log.write("User icons saved",
                                   'LightDMManager.saveSettings', 'debug')
                if saveTheme:
                    self.cfgGreeter.setValue('greeter', 'theme-name',
                                             self.newTheme)
                    self.curTheme = self.newTheme
                    self.log.write(
                        "Theme saved: %(theme)s" % {"theme": self.curTheme},
                        'LightDMManager.saveSettings', 'debug')
                if saveBackground:
                    if os.path.exists(self.newbgImg):
                        self.cfgGreeter.setValue('greeter', 'background',
                                                 self.newbgImg)
                        self.curBgPath = self.newbgImg
                        self.log.write(
                            "Background saved: %(background)s" %
                            {"background": self.curBgPath},
                            'LightDMManager.saveSettings', 'debug')
                saved = True
            else:
                if os.path.exists(self.curBgPath):
                    self.setBackground(self.curBgPath)
                    self.log.write(
                        "Current background: %(background)s" %
                        {"background": self.curBgPath},
                        'LightDMManager.saveSettings', 'debug')
                else:
                    self.imgBackground.set_from_file(
                        join(self.scriptDir,
                             '../../share/lightdm-manager/select.png'))
                    self.log.write("No background set",
                                   'LightDMManager.saveSettings', 'debug')
                self.fillUsers()

        if saved:
            self.curHideUsers = self.chkHideUsers.get_active()
            self.curAutoUser = self.newAutoUser
            self.newFaces = []
            self.curBgPath = self.newbgImg
            self.curTheme = self.newTheme
            MessageDialogSafe(_("Saved"),
                              _("LightDM settings saved successfully."),
                              Gtk.MessageType.INFO, self.window).show()
Ejemplo n.º 11
0
 def showError(self, title, message, parent=None):
     MessageDialogSafe(title, message, Gtk.MessageType.ERROR, parent).show()
Ejemplo n.º 12
0
 def showInfo(self, title, message, parent=None):
     MessageDialogSafe(title, message, Gtk.MessageType.INFO, parent).show()