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 on_fix_theme_btn_taggled(self, widget): if widget.get_active(): proxy.link_file(os.path.expanduser('~/.themes'), ROOT_THEMES) proxy.link_file(os.path.expanduser('~/.icons'), ROOT_ICONS) else: proxy.unlink_file(ROOT_THEMES) proxy.unlink_file(ROOT_ICONS) if proxy.is_exists(ROOT_THEMES) and proxy.is_exists(ROOT_ICONS): widget.set_active(True)
def on_fix_theme_btn_taggled(self, widget): if widget.get_active(): proxy.link_file(os.path.expanduser('~/.themes'), ROOT_THEMES) proxy.link_file(os.path.expanduser('~/.icons'), ROOT_ICONS) else: proxy.unlink_file(ROOT_THEMES) proxy.unlink_file(ROOT_ICONS) if proxy.is_exists(ROOT_THEMES) and proxy.is_exists(ROOT_ICONS): widget.set_active(True)
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 images with 64x64 size or SVG images")) filter.add_pattern('*.png') filter.add_pattern('*.svg') dialog.set_current_folder(os.path.expanduser('~')) dialog.add_filter(filter) dest = os.path.expanduser('~gdm/.icons/%s/apps/64/%s' % ( self.icon_theme_setting.get_value(user='******'), self.icon_setting.get_value(user='******'))) revert_button = dialog.action_area.get_children()[-1] HAVE_ICON = proxy.is_exists(dest + '.png') or proxy.is_exists(dest + '.svg') if not HAVE_ICON: revert_button.set_sensitive(False) filename = '' response = dialog.run() if response == gtk.RESPONSE_ACCEPT: filename = dialog.get_filename() dialog.destroy() if filename: ext = os.path.splitext(filename)[1] pixbuf = gtk.gdk.pixbuf_new_from_file(filename) w, h = pixbuf.get_width(), pixbuf.get_height() if ext == '.png' and (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)) proxy.exec_command('rm -rf %s.*' % dest) dest = dest + ext log.debug('Copy %s to %s' % (filename, dest)) proxy.exec_command('cp "%s" "%s"' % (filename, dest)) if ext == '.svg': pixbuf = pixbuf.scale_simple(64, 64, gtk.gdk.INTERP_BILINEAR) 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 __init__(self): TweakModule.__init__(self) box = ListPack(_("System Security options"), ( WidgetFactory.create( "GconfCheckButton", label=_("Disable \"Run Application\" dialog (Alt+F2)"), key="disable_command_line", enable_reset=True), WidgetFactory.create("GconfCheckButton", label=_('Disable "Lock Screen"'), key="disable_lock_screen", enable_reset=True), WidgetFactory.create("GconfCheckButton", label=_("Disable printing"), key="disable_printing", enable_reset=True), WidgetFactory.create("GconfCheckButton", label=_("Disable printer settings"), key="disable_print_setup", enable_reset=True), WidgetFactory.create("GconfCheckButton", label=_("Disable save to disk"), key="disable_save_to_disk", enable_reset=True), WidgetFactory.create("GconfCheckButton", label=_('Disable "Fast User Switching"'), key="disable_user_switching", enable_reset=True), ), padding=2) self.add_start(box, False, False, 0) self.fix_theme_button = gtk.CheckButton( _('Fix the appearance of themes when granted root privileges')) if proxy.is_exists(ROOT_THEMES) and proxy.is_exists(ROOT_ICONS): self.fix_theme_button.set_active(True) self.fix_theme_button.connect('toggled', self.on_fix_theme_btn_taggled) self.fix_theme_button.set_sensitive(False) box = ListPack(_('Miscellaneous Options'), (self.fix_theme_button, )) self.add_start(box, False, False, 0) # button hbox = gtk.HBox(False, 0) self.pack_end(hbox, False, False, 5) un_lock = PolkitButton() un_lock.connect('changed', self.on_polkit_action) hbox.pack_end(un_lock, False, False, 5)
def __init__(self): TweakModule.__init__(self) box = ListPack(_("System Security options"), ( WidgetFactory.create("GconfCheckButton", label=_("Disable \"Run Application\" dialog (Alt+F2)"), key="disable_command_line", enable_reset=True), WidgetFactory.create("GconfCheckButton", label=_('Disable "Lock Screen"'), key="disable_lock_screen", enable_reset=True), WidgetFactory.create("GconfCheckButton", label=_("Disable printing"), key="disable_printing", enable_reset=True), WidgetFactory.create("GconfCheckButton", label=_("Disable printer settings"), key="disable_print_setup", enable_reset=True), WidgetFactory.create("GconfCheckButton", label=_("Disable save to disk"), key="disable_save_to_disk", enable_reset=True), WidgetFactory.create("GconfCheckButton", label=_('Disable "Fast User Switching"'), key="disable_user_switching", enable_reset=True), ), padding=2) self.add_start(box, False, False, 0) self.fix_theme_button = gtk.CheckButton(_('Fix the appearance of themes when granted root privileges')) if proxy.is_exists(ROOT_THEMES) and proxy.is_exists(ROOT_ICONS): self.fix_theme_button.set_active(True) self.fix_theme_button.connect('toggled', self.on_fix_theme_btn_taggled) self.fix_theme_button.set_sensitive(False) box = ListPack(_('Miscellaneous Options'), (self.fix_theme_button,)) self.add_start(box, False, False, 0) # button hbox = gtk.HBox(False, 0) self.pack_end(hbox, False ,False, 5) un_lock = PolkitButton() un_lock.connect('changed', self.on_polkit_action) hbox.pack_end(un_lock, False, False, 5)
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_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 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 images with 64x64 size or SVG images")) filter.add_pattern('*.png') filter.add_pattern('*.svg') dialog.set_current_folder(os.path.expanduser('~')) dialog.add_filter(filter) dest = os.path.expanduser( '~gdm/.icons/%s/apps/64/%s' % (self.icon_theme_setting.get_value(user='******'), self.icon_setting.get_value(user='******'))) revert_button = dialog.action_area.get_children()[-1] HAVE_ICON = proxy.is_exists(dest + '.png') or proxy.is_exists(dest + '.svg') if not HAVE_ICON: revert_button.set_sensitive(False) filename = '' response = dialog.run() if response == gtk.RESPONSE_ACCEPT: filename = dialog.get_filename() dialog.destroy() if filename: ext = os.path.splitext(filename)[1] pixbuf = gtk.gdk.pixbuf_new_from_file(filename) w, h = pixbuf.get_width(), pixbuf.get_height() if ext == '.png' and (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)) proxy.exec_command('rm -rf %s.*' % dest) dest = dest + ext log.debug('Copy %s to %s' % (filename, dest)) proxy.exec_command('cp "%s" "%s"' % (filename, dest)) if ext == '.svg': pixbuf = pixbuf.scale_simple(64, 64, gtk.gdk.INTERP_BILINEAR) 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