コード例 #1
0
ファイル: workarounds.py プロジェクト: Thongor/ubuntu-tweak
 def on_fix_theme_btn_taggled(self, widget):
     if widget.get_active():
         proxy.link_file(os.path.expanduser('~/.themes'), self.ROOT_THEMES)
         proxy.link_file(os.path.expanduser('~/.icons'), self.ROOT_ICONS)
     else:
         proxy.unlink_file(self.ROOT_THEMES)
         proxy.unlink_file(self.ROOT_ICONS)
         if proxy.is_exists(self.ROOT_THEMES) and proxy.is_exists(self.ROOT_ICONS):
             widget.set_active(True)
コード例 #2
0
ファイル: workarounds.py プロジェクト: Thongor/ubuntu-tweak
    def __init__(self):
        TweakModule.__init__(self)

        self.fix_theme_button = Gtk.CheckButton(_('Fix the appearance of themes when granted root privileges'))
        if proxy.is_exists(self.ROOT_THEMES) and proxy.is_exists(self.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)

        hbox = Gtk.HBox(spacing=12)
        self.add_end(hbox, False ,False, 0)

        un_lock = PolkitButton(PK_ACTION_TWEAK)
        un_lock.connect('authenticated', self.on_polkit_action)
        hbox.pack_end(un_lock, False, False, 0)
コード例 #3
0
ファイル: loginsettings.py プロジェクト: Thongor/ubuntu-tweak
    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 = GdkPixbuf.Pixbuf.new_from_file(path)
                pixbuf = pixbuf.scale_simple(64, 64, GdkPixbuf.InterpType.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
コード例 #4
0
ファイル: loginsettings.py プロジェクト: Thongor/ubuntu-tweak
    def on_logo_button_clicked(self, widget):
        dialog = Gtk.FileChooserDialog(
            _("Choose a new logo image"),
            action=Gtk.FileChooserAction.OPEN,
            buttons=(
                Gtk.STOCK_REVERT_TO_SAVED,
                Gtk.ResponseType.DELETE_EVENT,
                Gtk.STOCK_CANCEL,
                Gtk.ResponseType.CANCEL,
                Gtk.STOCK_OPEN,
                Gtk.ResponseType.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)
        self._set_preview_widget_for_dialog(dialog)

        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.get_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.ResponseType.ACCEPT:
            filename = dialog.get_filename()
            dialog.destroy()

            if filename:
                ext = os.path.splitext(filename)[1]
                pixbuf = GdkPixbuf.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:
                    dest = dest + ext
                    log.debug("Copy %s to %s" % (filename, dest))
                    proxy.set_login_logo(filename, dest)

                    if ext == ".svg":
                        pixbuf = pixbuf.scale_simple(64, 64, GdkPixbuf.InterpType.BILINEAR)

                    self.logo_image.set_from_pixbuf(GdkPixbuf.Pixbuf.new_from_file(filename))
        elif response == Gtk.ResponseType.DELETE_EVENT:
            dialog.destroy()
            proxy.unset_login_logo(dest)
            self._setup_logo_image()
        else:
            dialog.destroy()
            return
コード例 #5
0
 def set_fix_theme_button_status(self):
     if proxy.is_exists(self.ROOT_THEMES) and proxy.is_exists(
             self.ROOT_ICONS):
         self.fix_theme_button.set_active(True)
     else:
         self.fix_theme_button.set_active(False)
コード例 #6
0
ファイル: workarounds.py プロジェクト: GBeckerRS/ubuntu-tweak
 def set_fix_theme_button_status(self):
     if proxy.is_exists(self.ROOT_THEMES) and proxy.is_exists(self.ROOT_ICONS):
         self.fix_theme_button.set_active(True)
     else:
         self.fix_theme_button.set_active(False)