示例#1
0
 def __setup_background_image(self):
     self.background_setting = UserGconfSetting(
         '/desktop/gnome/background/picture_filename')
     background_path = self.background_setting.get_value(user='******')
     log.debug("Setup the background file: %s" % background_path)
     try:
         pixbuf = gtk.gdk.pixbuf_new_from_file(background_path)
         pixbuf = pixbuf.scale_simple(160, 120, gtk.gdk.INTERP_NEAREST)
         self.background_image.set_from_pixbuf(pixbuf)
     except Exception, e:
         log.error("Loading background failed, message is %s" % e)
    def __init__(self):
        TweakModule.__init__(self, "loginsettings.ui")

        log.debug('Start to build "Session Options"')
        self.options_box = ListPack(
            _("Login Options"),
            (
                WidgetFactory.create(
                    "UserGconfCheckButton",
                    user="******",
                    label=_("Disable user list in gdm"),
                    key="/apps/gdm/simple-greeter/disable_user_list",
                ),
                WidgetFactory.create(
                    "UserGconfCheckButton",
                    user="******",
                    label=_("Play sound at login"),
                    key="/desktop/gnome/sound/event_sounds",
                ),
                WidgetFactory.create(
                    "UserGconfCheckButton",
                    user="******",
                    label=_("Disable showing the restart buttons"),
                    key="/apps/gdm/simple-greeter/disable_restart_buttons",
                ),
            ),
        )
        for item in self.options_box.items:
            log.debug("Set widget %s to sensitive False", item)
            item.set_sensitive(False)
        log.debug('Build "Session Options" finished')

        self.add_start(self.options_box, False, False, 0)

        self.icon_setting = UserGconfSetting("/apps/gdm/simple-greeter/logo_icon_name")
        self.icon_theme_setting = UserGconfSetting("/desktop/gnome/interface/icon_theme")
        self.__setup_logo_image()
        self.__setup_background_image()
        self.vbox1.unparent()
        self.vbox1.set_sensitive(False)

        box = ListPack(_("Login Theme"), (self.vbox1))
        self.add_start(box, False, False, 0)

        hbox = gtk.HBox(False, 12)
        polkit_button = PolkitButton()
        polkit_button.connect("changed", self.on_polkit_action)
        hbox.pack_end(polkit_button, False, False, 0)
        self.add_start(hbox, False, False, 0)
示例#3
0
    def __init__(self):
        TweakModule.__init__(self, 'loginsettings.ui')

        log.debug('Start to build "Session Options"')
        self.options_box = ListPack(_("Login Options"), (
            WidgetFactory.create(
                "UserGconfCheckButton",
                user='******',
                label=_("Disable user list in GDM"),
                enable_reset=True,
                key="/apps/gdm/simple-greeter/disable_user_list"),
            WidgetFactory.create("UserGconfCheckButton",
                                 user='******',
                                 label=_("Play sound at login"),
                                 enable_reset=True,
                                 key="/desktop/gnome/sound/event_sounds"),
            WidgetFactory.create(
                "UserGconfCheckButton",
                user='******',
                label=_("Disable showing the restart button"),
                enable_reset=True,
                key="/apps/gdm/simple-greeter/disable_restart_buttons"),
        ))
        for item in self.options_box.items:
            log.debug('Set widget %s to sensitive False', item)
            item.set_sensitive(False)
        log.debug('Build "Session Options" finished')

        self.add_start(self.options_box, False, False, 0)

        self.icon_setting = UserGconfSetting(
            '/apps/gdm/simple-greeter/logo_icon_name')
        self.icon_theme_setting = UserGconfSetting(
            '/desktop/gnome/interface/icon_theme')
        self.__setup_logo_image()
        self.__setup_background_image()
        self.vbox1.unparent()
        self.vbox1.set_sensitive(False)

        box = ListPack(_('Login Theme'), (self.vbox1))
        self.add_start(box, False, False, 0)

        hbox = gtk.HBox(False, 12)
        polkit_button = PolkitButton()
        polkit_button.connect('changed', self.on_polkit_action)
        hbox.pack_end(polkit_button, False, False, 0)
        self.add_start(hbox, False, False, 0)
 def __setup_background_image(self):
     self.background_setting = UserGconfSetting("/desktop/gnome/background/picture_filename")
     background_path = self.background_setting.get_value(user="******")
     try:
         pixbuf = gtk.gdk.pixbuf_new_from_file(background_path)
         pixbuf = pixbuf.scale_simple(160, 120, gtk.gdk.INTERP_NEAREST)
         self.background_image.set_from_pixbuf(pixbuf)
     except:
         pass
示例#5
0
 def __setup_background_image(self):
     self.background_setting = UserGconfSetting('/desktop/gnome/background/picture_filename')
     background_path = self.background_setting.get_value(user='******')
     log.debug("Setup the background file: %s" % background_path)
     try:
         pixbuf = gtk.gdk.pixbuf_new_from_file(background_path)
         pixbuf = pixbuf.scale_simple(160, 120, gtk.gdk.INTERP_NEAREST)
         self.background_image.set_from_pixbuf(pixbuf)
     except Exception, e:
         log.error("Loading background failed, message is %s" % e)
示例#6
0
class LoginSettings(TweakModule):
    __title__ = _('Login Settings')
    __desc__ = _('Control the appearance and behaviour of your login screen')
    __icon__ = 'gdm-setup'
    __category__ = 'startup'
    __desktop__ = ['gnome', 'xfce', 'une']

    def __init__(self):
        TweakModule.__init__(self, 'loginsettings.ui')

        log.debug('Start to build "Session Options"')
        self.options_box = ListPack(_("Login Options"), (
                    WidgetFactory.create("UserGconfCheckButton",
                                         user='******',
                                         label=_("Disable user list in GDM"),
                                         enable_reset=True,
                                         key="/apps/gdm/simple-greeter/disable_user_list"),
                    WidgetFactory.create("UserGconfCheckButton",
                                         user='******',
                                         label=_("Play sound at login"),
                                         enable_reset=True,
                                         key="/desktop/gnome/sound/event_sounds"),
                    WidgetFactory.create("UserGconfCheckButton",
                                         user='******',
                                         label=_("Disable showing the restart button"),
                                         enable_reset=True,
                                         key="/apps/gdm/simple-greeter/disable_restart_buttons"),
            ))
        for item in self.options_box.items:
            log.debug('Set widget %s to sensitive False', item)
            item.set_sensitive(False)
        log.debug('Build "Session Options" finished')

        self.add_start(self.options_box, False, False, 0)

        self.icon_setting = UserGconfSetting('/apps/gdm/simple-greeter/logo_icon_name')
        self.icon_theme_setting = UserGconfSetting('/desktop/gnome/interface/icon_theme')
        self.__setup_logo_image()
        self.__setup_background_image()
        self.vbox1.unparent()
        self.vbox1.set_sensitive(False)

        box = ListPack(_('Login Theme'), (self.vbox1))
        self.add_start(box, False, False, 0)

        hbox = gtk.HBox(False, 12)
        polkit_button = PolkitButton()
        polkit_button.connect('changed', self.on_polkit_action)
        hbox.pack_end(polkit_button, False, False, 0)
        self.add_start(hbox, False, False, 0)

    def __setup_logo_image(self):
        icon_name = self.icon_setting.get_value(user='******')
        log.info('Get icon_name from user: gdm, icon name: %s' % icon_name)

        path = os.path.expanduser('~gdm/.icons/%s/apps/64/%s' % (
                                    self.icon_theme_setting.get_value(user='******'),
                                    self.icon_setting.get_value(user='******')))
        EXIST = False
        FORMAT = ''
        if proxy.is_exists(path + '.png'):
            path = path + '.png'
            EXIST = True
            FORMAT = '.png'
        elif proxy.is_exists(path + '.svg'):
            path = path + '.svg'
            EXIST = True
            FORMAT = '.svg'

        if EXIST:
            log.info("The icon path is: %s" % path)
            path = proxy.get_as_tempfile(path, os.getuid())
            log.debug('Custom log is exits, the tempfile is %s' % path)
            if FORMAT == '.svg':
                pixbuf = gtk.gdk.pixbuf_new_from_file(path)
                pixbuf = pixbuf.scale_simple(64, 64, gtk.gdk.INTERP_BILINEAR)
                self.logo_image.set_from_pixbuf(pixbuf)
            else:
                self.logo_image.set_from_file(path)
        else:
            icontheme = gtk.IconTheme()
            icontheme.set_custom_theme(self.icon_theme_setting.get_value(user='******'))
            try:
                self.logo_image.set_from_pixbuf(icontheme.load_icon(icon_name, 64, 0))
            except:
                pass

    def __setup_background_image(self):
        self.background_setting = UserGconfSetting('/desktop/gnome/background/picture_filename')
        background_path = self.background_setting.get_value(user='******')
        log.debug("Setup the background file: %s" % background_path)
        try:
            pixbuf = gtk.gdk.pixbuf_new_from_file(background_path)
            pixbuf = pixbuf.scale_simple(160, 120, gtk.gdk.INTERP_NEAREST)
            self.background_image.set_from_pixbuf(pixbuf)
        except Exception, e:
            log.error("Loading background failed, message is %s" % e)
class LoginSettings(TweakModule):
    __title__ = _("Login Settings")
    __desc__ = _("Control the appearance and behaviour of your login screen")
    __icon__ = "gdm-setup"
    __category__ = "startup"
    __desktop__ = ["gnome", "xfce"]

    def __init__(self):
        TweakModule.__init__(self, "loginsettings.ui")

        log.debug('Start to build "Session Options"')
        self.options_box = ListPack(
            _("Login Options"),
            (
                WidgetFactory.create(
                    "UserGconfCheckButton",
                    user="******",
                    label=_("Disable user list in gdm"),
                    key="/apps/gdm/simple-greeter/disable_user_list",
                ),
                WidgetFactory.create(
                    "UserGconfCheckButton",
                    user="******",
                    label=_("Play sound at login"),
                    key="/desktop/gnome/sound/event_sounds",
                ),
                WidgetFactory.create(
                    "UserGconfCheckButton",
                    user="******",
                    label=_("Disable showing the restart buttons"),
                    key="/apps/gdm/simple-greeter/disable_restart_buttons",
                ),
            ),
        )
        for item in self.options_box.items:
            log.debug("Set widget %s to sensitive False", item)
            item.set_sensitive(False)
        log.debug('Build "Session Options" finished')

        self.add_start(self.options_box, False, False, 0)

        self.icon_setting = UserGconfSetting("/apps/gdm/simple-greeter/logo_icon_name")
        self.icon_theme_setting = UserGconfSetting("/desktop/gnome/interface/icon_theme")
        self.__setup_logo_image()
        self.__setup_background_image()
        self.vbox1.unparent()
        self.vbox1.set_sensitive(False)

        box = ListPack(_("Login Theme"), (self.vbox1))
        self.add_start(box, False, False, 0)

        hbox = gtk.HBox(False, 12)
        polkit_button = PolkitButton()
        polkit_button.connect("changed", self.on_polkit_action)
        hbox.pack_end(polkit_button, False, False, 0)
        self.add_start(hbox, False, False, 0)

    def __setup_logo_image(self):
        icon_name = self.icon_setting.get_value(user="******")
        log.debug("Get icon_name from user: gdm, icon name: %s" % icon_name)

        path = os.path.expanduser(
            "~gdm/.icons/%s/apps/64/%s.png"
            % (self.icon_theme_setting.get_value(user="******"), self.icon_setting.get_value(user="******"))
        )

        if proxy.is_exists(path):
            path = proxy.get_as_tempfile(path)
            log.debug("Custom log is exits, the tempfile is %s" % path)
            self.logo_image.set_from_file(path)
        else:
            icontheme = gtk.IconTheme()
            icontheme.set_custom_theme(self.icon_theme_setting.get_value(user="******"))
            try:
                self.logo_image.set_from_pixbuf(icontheme.load_icon(icon_name, 64, 0))
            except:
                pass

    def __setup_background_image(self):
        self.background_setting = UserGconfSetting("/desktop/gnome/background/picture_filename")
        background_path = self.background_setting.get_value(user="******")
        try:
            pixbuf = gtk.gdk.pixbuf_new_from_file(background_path)
            pixbuf = pixbuf.scale_simple(160, 120, gtk.gdk.INTERP_NEAREST)
            self.background_image.set_from_pixbuf(pixbuf)
        except:
            pass

    def on_polkit_action(self, widget, action):
        if action:
            if proxy.get_proxy():
                for item in self.options_box.items:
                    item.set_sensitive(True)
                self.vbox1.set_sensitive(True)
            else:
                ServerErrorDialog().launch()
        else:
            AuthenticateFailDialog().launch()

    def on_logo_button_clicked(self, widget):
        dialog = gtk.FileChooserDialog(
            _("Choose a new logo image"),
            action=gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(
                gtk.STOCK_REVERT_TO_SAVED,
                gtk.RESPONSE_DELETE_EVENT,
                gtk.STOCK_CANCEL,
                gtk.RESPONSE_CANCEL,
                gtk.STOCK_OPEN,
                gtk.RESPONSE_ACCEPT,
            ),
        )
        filter = gtk.FileFilter()
        filter.set_name(_("PNG image with 64x64 size (*.png)"))
        filter.add_mime_type("image/png")
        dialog.set_current_folder(os.path.expanduser("~"))
        dialog.add_filter(filter)

        dest = os.path.expanduser(
            "~gdm/.icons/%s/apps/64/%s.png"
            % (self.icon_theme_setting.get_value(user="******"), self.icon_setting.get_value(user="******"))
        )

        revert_button = dialog.action_area.get_children()[-1]

        filename = ""
        response = dialog.run()

        if response == gtk.RESPONSE_ACCEPT:
            filename = dialog.get_filename()
            dialog.destroy()

            if filename:
                pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
                w, h = pixbuf.get_width(), pixbuf.get_height()
                if w != 64 or h != 64:
                    ErrorDialog(_("This image size isn't suitable for the logo.\nIt should be 64x64.")).launch()
                    return
                else:
                    proxy.exec_command("mkdir -p %s" % os.path.dirname(dest))
                    log.debug("Copy %s to %s" % (filename, dest))
                    proxy.exec_command('cp "%s" "%s"' % (filename, dest))

                    self.logo_image.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(filename))
        elif response == gtk.RESPONSE_DELETE_EVENT:
            dialog.destroy()
            proxy.exec_command("rm -rf %s" % dest)
            self.__setup_logo_image()
        else:
            dialog.destroy()
            return

    def on_background_button_clicked(self, widget):
        dialog = gtk.FileChooserDialog(
            _("Choose a new background image"),
            action=gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(
                gtk.STOCK_REVERT_TO_SAVED,
                gtk.RESPONSE_DELETE_EVENT,
                gtk.STOCK_CANCEL,
                gtk.RESPONSE_CANCEL,
                gtk.STOCK_OPEN,
                gtk.RESPONSE_ACCEPT,
            ),
        )
        filter = gtk.FileFilter()
        filter.set_name(_("All images"))
        filter.add_pattern("*.jpg")
        filter.add_pattern("*.png")
        dialog.set_current_folder("/usr/share/backgrounds")
        dialog.add_filter(filter)

        if module_check.get_codename() == "karmic":
            orignal_background = "/usr/share/images/xsplash/bg_2560x1600.jpg"
        else:
            orignal_background = "/usr/share/backgrounds/warty-final-ubuntu.png"

        revert_button = dialog.action_area.get_children()[-1]

        filename = ""
        response = dialog.run()

        if response == gtk.RESPONSE_ACCEPT:
            filename = dialog.get_filename()
            dialog.destroy()

            if filename:
                self.background_setting.set_value(user="******", value=filename)
                self.__setup_background_image()
        elif response == gtk.RESPONSE_DELETE_EVENT:
            dialog.destroy()
            self.background_setting.set_value(user="******", value=orignal_background)
            self.__setup_background_image()
        else:
            dialog.destroy()
            return
示例#8
0
class LoginSettings(TweakModule):
    __title__ = _('Login Settings')
    __desc__ = _('Control the appearance and behaviour of your login screen')
    __icon__ = 'gdm-setup'
    __category__ = 'startup'
    __desktop__ = ['gnome', 'xfce', 'une']

    def __init__(self):
        TweakModule.__init__(self, 'loginsettings.ui')

        log.debug('Start to build "Session Options"')
        self.options_box = ListPack(_("Login Options"), (
            WidgetFactory.create(
                "UserGconfCheckButton",
                user='******',
                label=_("Disable user list in GDM"),
                enable_reset=True,
                key="/apps/gdm/simple-greeter/disable_user_list"),
            WidgetFactory.create("UserGconfCheckButton",
                                 user='******',
                                 label=_("Play sound at login"),
                                 enable_reset=True,
                                 key="/desktop/gnome/sound/event_sounds"),
            WidgetFactory.create(
                "UserGconfCheckButton",
                user='******',
                label=_("Disable showing the restart button"),
                enable_reset=True,
                key="/apps/gdm/simple-greeter/disable_restart_buttons"),
        ))
        for item in self.options_box.items:
            log.debug('Set widget %s to sensitive False', item)
            item.set_sensitive(False)
        log.debug('Build "Session Options" finished')

        self.add_start(self.options_box, False, False, 0)

        self.icon_setting = UserGconfSetting(
            '/apps/gdm/simple-greeter/logo_icon_name')
        self.icon_theme_setting = UserGconfSetting(
            '/desktop/gnome/interface/icon_theme')
        self.__setup_logo_image()
        self.__setup_background_image()
        self.vbox1.unparent()
        self.vbox1.set_sensitive(False)

        box = ListPack(_('Login Theme'), (self.vbox1))
        self.add_start(box, False, False, 0)

        hbox = gtk.HBox(False, 12)
        polkit_button = PolkitButton()
        polkit_button.connect('changed', self.on_polkit_action)
        hbox.pack_end(polkit_button, False, False, 0)
        self.add_start(hbox, False, False, 0)

    def __setup_logo_image(self):
        icon_name = self.icon_setting.get_value(user='******')
        log.info('Get icon_name from user: gdm, icon name: %s' % icon_name)

        path = os.path.expanduser(
            '~gdm/.icons/%s/apps/64/%s' %
            (self.icon_theme_setting.get_value(user='******'),
             self.icon_setting.get_value(user='******')))
        EXIST = False
        FORMAT = ''
        if proxy.is_exists(path + '.png'):
            path = path + '.png'
            EXIST = True
            FORMAT = '.png'
        elif proxy.is_exists(path + '.svg'):
            path = path + '.svg'
            EXIST = True
            FORMAT = '.svg'

        if EXIST:
            log.info("The icon path is: %s" % path)
            path = proxy.get_as_tempfile(path, os.getuid())
            log.debug('Custom log is exits, the tempfile is %s' % path)
            if FORMAT == '.svg':
                pixbuf = gtk.gdk.pixbuf_new_from_file(path)
                pixbuf = pixbuf.scale_simple(64, 64, gtk.gdk.INTERP_BILINEAR)
                self.logo_image.set_from_pixbuf(pixbuf)
            else:
                self.logo_image.set_from_file(path)
        else:
            icontheme = gtk.IconTheme()
            icontheme.set_custom_theme(
                self.icon_theme_setting.get_value(user='******'))
            try:
                self.logo_image.set_from_pixbuf(
                    icontheme.load_icon(icon_name, 64, 0))
            except:
                pass

    def __setup_background_image(self):
        self.background_setting = UserGconfSetting(
            '/desktop/gnome/background/picture_filename')
        background_path = self.background_setting.get_value(user='******')
        log.debug("Setup the background file: %s" % background_path)
        try:
            pixbuf = gtk.gdk.pixbuf_new_from_file(background_path)
            pixbuf = pixbuf.scale_simple(160, 120, gtk.gdk.INTERP_NEAREST)
            self.background_image.set_from_pixbuf(pixbuf)
        except Exception, e:
            log.error("Loading background failed, message is %s" % e)