示例#1
0
    def on_module_selected(self):
        if not self.loaded:
            print("Loading Themes module")

            self.spices = Spice_Harvester('theme', self.window)

            self.sidePage.stack = SettingsStack()
            self.sidePage.add_widget(self.sidePage.stack)

            self.settings = Gio.Settings.new("org.cinnamon.desktop.interface")
            self.wm_settings = Gio.Settings.new(
                "org.cinnamon.desktop.wm.preferences")
            self.cinnamon_settings = Gio.Settings.new("org.cinnamon.theme")

            self.scale = self.window.get_scale_factor()

            self.icon_chooser = self.create_button_chooser(
                self.settings,
                'icon-theme',
                'icons',
                'icons',
                button_picture_size=ICON_SIZE,
                menu_pictures_size=ICON_SIZE,
                num_cols=4)
            self.cursor_chooser = self.create_button_chooser(
                self.settings,
                'cursor-theme',
                'icons',
                'cursors',
                button_picture_size=32,
                menu_pictures_size=32,
                num_cols=4)
            self.theme_chooser = self.create_button_chooser(
                self.settings,
                'gtk-theme',
                'themes',
                'gtk-3.0',
                button_picture_size=35,
                menu_pictures_size=35,
                num_cols=4)
            self.metacity_chooser = self.create_button_chooser(
                self.wm_settings,
                'theme',
                'themes',
                'metacity-1',
                button_picture_size=32,
                menu_pictures_size=32,
                num_cols=4)
            self.cinnamon_chooser = self.create_button_chooser(
                self.cinnamon_settings,
                'name',
                'themes',
                'cinnamon',
                button_picture_size=60,
                menu_pictures_size=60 * self.scale,
                num_cols=4)

            page = SettingsPage()
            self.sidePage.stack.add_titled(page, "themes", _("Themes"))

            settings = page.add_section(_("Themes"))

            widget = self.make_group(_("Window borders"),
                                     self.metacity_chooser)
            settings.add_row(widget)

            widget = self.make_group(_("Icons"), self.icon_chooser)
            settings.add_row(widget)

            widget = self.make_group(_("Controls"), self.theme_chooser)
            settings.add_row(widget)

            widget = self.make_group(_("Mouse Pointer"), self.cursor_chooser)
            settings.add_row(widget)

            widget = self.make_group(_("Desktop"), self.cinnamon_chooser)
            settings.add_row(widget)

            page = DownloadSpicesPage(self, 'theme', self.spices, self.window)
            self.sidePage.stack.add_titled(page, 'download', _("Add/Remove"))

            page = SettingsPage()
            self.sidePage.stack.add_titled(page, "options", _("Settings"))

            settings = page.add_section(_("Miscellaneous options"))

            widget = GSettingsSwitch(
                _("Show icons in menus"),
                "org.cinnamon.settings-daemon.plugins.xsettings",
                "menus-have-icons")
            settings.add_row(widget)

            widget = GSettingsSwitch(
                _("Show icons on buttons"),
                "org.cinnamon.settings-daemon.plugins.xsettings",
                "buttons-have-icons")
            settings.add_row(widget)

            settings = page.add_section(_("Scrollbar behavior"))

            # Translators: The 'trough' is the part of the scrollbar that the 'handle'
            # rides in.  This setting determines whether clicking in that trough somewhere
            # jumps directly to the new position, or if it only scrolls towards it.
            switch = GtkSettingsSwitch(
                _("Jump to position when clicking in a trough"),
                "gtk-primary-button-warps-slider")
            settings.add_row(switch)

            widget = GSettingsSwitch(_("Use overlay scroll bars"),
                                     "org.cinnamon.desktop.interface",
                                     "gtk-overlay-scrollbars")
            settings.add_row(widget)

            self.gtk2_scrollbar_editor = Gtk2ScrollbarSizeEditor(
                widget.get_scale_factor())

            switch = CssOverrideSwitch(
                _("Override the current theme's scrollbar width"))
            settings.add_row(switch)
            self.scrollbar_switch = switch.content_widget

            widget = CssRange(_("Scrollbar width"), "scrollbar slider",
                              ["min-width", "min-height"], 2, 40, "px", None,
                              switch)
            settings.add_reveal_row(widget)
            widget.sync_initial_switch_state()
            self.scrollbar_css_range = widget.content_widget
            self.scrollbar_css_range.get_adjustment().set_page_increment(2.0)

            switch.content_widget.connect("notify::active",
                                          self.on_css_override_active_changed)
            widget.content_widget.connect("value-changed",
                                          self.on_range_slider_value_changed)

            self.on_css_override_active_changed(switch)

            widget = PreviewWidget()
            settings.add_row(widget)

            label_widget = LabelRow(
                _("""Changes will take effect the next time you log in and may not affect all applications."""
                  ))
            settings.add_row(label_widget)

            self.builder = self.sidePage.builder

            for path in [
                    os.path.expanduser("~/.themes"),
                    os.path.expanduser("~/.icons")
            ]:
                try:
                    os.makedirs(path)
                except OSError:
                    pass

            self.monitors = []
            for path in [
                    os.path.expanduser("~/.themes"), "/usr/share/themes",
                    os.path.expanduser("~/.icons"), "/usr/share/icons"
            ]:
                if os.path.exists(path):
                    file_obj = Gio.File.new_for_path(path)
                    try:
                        file_monitor = file_obj.monitor_directory(
                            Gio.FileMonitorFlags.SEND_MOVED, None)
                        file_monitor.connect("changed", self.on_file_changed)
                        self.monitors.append(file_monitor)
                    except Exception as e:
                        # File monitors can fail when the OS runs out of file handles
                        print(e)

            self.refresh()
示例#2
0
    def on_module_selected(self):
        if not self.loaded:
            print "Loading Themes module"

            self.sidePage.stack = SettingsStack()
            self.sidePage.add_widget(self.sidePage.stack)

            self.settings = Gio.Settings.new("org.cinnamon.desktop.interface")
            self.wm_settings = Gio.Settings.new("org.cinnamon.desktop.wm.preferences")
            self.cinnamon_settings = Gio.Settings.new("org.cinnamon.theme")

            self.icon_chooser = self.create_button_chooser(self.settings, 'icon-theme', 'icons', 'icons', button_picture_size=ICON_SIZE, menu_pictures_size=ICON_SIZE, num_cols=4)
            self.cursor_chooser = self.create_button_chooser(self.settings, 'cursor-theme', 'icons', 'cursors', button_picture_size=32, menu_pictures_size=32, num_cols=4)
            self.theme_chooser = self.create_button_chooser(self.settings, 'gtk-theme', 'themes', 'gtk-3.0', button_picture_size=35, menu_pictures_size=35, num_cols=4)
            self.metacity_chooser = self.create_button_chooser(self.wm_settings, 'theme', 'themes', 'metacity-1', button_picture_size=32, menu_pictures_size=32, num_cols=4)
            self.cinnamon_chooser = self.create_button_chooser(self.cinnamon_settings, 'name', 'themes', 'cinnamon', button_picture_size=60, menu_pictures_size=60, num_cols=4)

            page = SettingsPage()
            self.sidePage.stack.add_titled(page, "themes", _("Themes"))

            settings = page.add_section(_("Themes"))

            widget = self.make_group(_("Window borders"), self.metacity_chooser)
            settings.add_row(widget)

            widget = self.make_group(_("Icons"), self.icon_chooser)
            settings.add_row(widget)

            widget = self.make_group(_("Controls"), self.theme_chooser)
            settings.add_row(widget)

            widget = self.make_group(_("Mouse Pointer"), self.cursor_chooser)
            settings.add_row(widget)

            widget = self.make_group(_("Desktop"), self.cinnamon_chooser)
            center_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
            button = Gtk.LinkButton()
            button.set_label(_("Add/remove desktop themes..."))
            button.connect("activate-link", self.add_remove_cinnamon_themes)
            center_box.pack_end(button, False, False, 0)
            widget.pack_start(center_box, False, False, 0)
            settings.add_row(widget)

            page = SettingsPage()
            self.sidePage.stack.add_titled(page, "options", _("Settings"))

            settings = page.add_section(_("Miscellaneous options"))

            widget = GSettingsSwitch(_("Show icons in menus"), "org.cinnamon.settings-daemon.plugins.xsettings", "menus-have-icons")
            settings.add_row(widget)

            widget = GSettingsSwitch(_("Show icons on buttons"), "org.cinnamon.settings-daemon.plugins.xsettings", "buttons-have-icons")
            settings.add_row(widget)

            dark_text = _("Use a dark theme variant when available in certain applications")
            dark_italic = _("(Applications must be restarted for this change to take effect)")

            widget = GtkSettingsSwitch("%s\n<i><small>%s</small></i>" % (dark_text, dark_italic),
                                       "gtk-application-prefer-dark-theme")
            settings.add_row(widget)

            self.builder = self.sidePage.builder

            for path in [os.path.expanduser("~/.themes"), os.path.expanduser("~/.icons")]:
                try:
                    os.makedirs(path)
                except OSError:
                    pass

            self.monitors = []
            for path in [os.path.expanduser("~/.themes"), "/usr/share/themes", os.path.expanduser("~/.icons"), "/usr/share/icons"]:
                if os.path.exists(path):
                    file_obj = Gio.File.new_for_path(path)
                    file_monitor = file_obj.monitor_directory(Gio.FileMonitorFlags.SEND_MOVED, None)
                    file_monitor.connect("changed", self.on_file_changed)
                    self.monitors.append(file_monitor)

            self.refresh()