Commit bbf94274 authored by John Stowers's avatar John Stowers

Add desktop background options (bug 689299)

parent a40c6c74
......@@ -20,7 +20,7 @@ from gi.repository import Gtk
import gtweak
from gtweak.utils import AutostartManager
from gtweak.tweakmodel import TWEAK_GROUP_DESKTOP, TWEAK_GROUP_FILES
from gtweak.widgets import GSettingsSwitchTweak
from gtweak.widgets import GSettingsSwitchTweak, GSettingsComboEnumTweak, GSettingsFileChooserButtonTweak
class DesktopIconTweak(GSettingsSwitchTweak):
def __init__(self, **options):
......@@ -52,4 +52,6 @@ TWEAKS = (
GSettingsSwitchTweak("org.gnome.nautilus.desktop", "volumes-visible", schema_filename="org.gnome.nautilus.gschema.xml",group_name=TWEAK_GROUP_DESKTOP),
GSettingsSwitchTweak("org.gnome.nautilus.preferences", "always-use-location-entry",
schema_filename="org.gnome.nautilus.gschema.xml",group_name=TWEAK_GROUP_FILES),
GSettingsComboEnumTweak("org.gnome.desktop.background", "picture-options", group_name=TWEAK_GROUP_DESKTOP),
GSettingsFileChooserButtonTweak("org.gnome.desktop.background", "picture-uri", local_only=True, mimetypes=["application/xml","image/png","image/jpeg"], group_name=TWEAK_GROUP_DESKTOP),
)
......@@ -28,7 +28,7 @@ from gtweak.utils import walk_directories, extract_zip_file, make_combo_list_wit
from gtweak.gsettings import GSettingsSetting, GSettingsMissingError, GSettingsFakeSetting
from gtweak.gshellwrapper import GnomeShellFactory
from gtweak.tweakmodel import Tweak, TweakGroup, TWEAK_GROUP_THEME, TWEAK_GROUP_SHELL, TWEAK_SORT_LAST
from gtweak.widgets import FileChooserButtonTweak, GSettingsComboTweak, GSettingsComboEnumTweak, GSettingsSwitchTweak, build_label_beside_widget, build_horizontal_sizegroup, build_combo_box_text, UI_BOX_SPACING
from gtweak.widgets import FileChooserButton, GSettingsComboTweak, GSettingsComboEnumTweak, GSettingsSwitchTweak, build_label_beside_widget, build_horizontal_sizegroup, build_combo_box_text, UI_BOX_SPACING
class ShowWindowButtons(GSettingsComboTweak):
def __init__(self, **options):
......@@ -125,7 +125,7 @@ class ShellThemeTweak(Tweak):
self._combo = cb
#a filechooser to install new themes
chooser = FileChooserButtonTweak(
chooser = FileChooserButton(
_("Select a theme"),
True,
"application/zip")
......
......@@ -10,7 +10,7 @@ from gi.repository import GLib
from gtweak.utils import extract_zip_file, execute_subprocess
from gtweak.gshellwrapper import GnomeShell, GnomeShellFactory
from gtweak.tweakmodel import Tweak, TweakGroup
from gtweak.widgets import FileChooserButtonTweak, build_label_beside_widget, build_horizontal_sizegroup, build_tight_button, UI_BOX_SPACING
from gtweak.widgets import FileChooserButton, build_label_beside_widget, build_horizontal_sizegroup, build_tight_button, UI_BOX_SPACING
def N_(x): return x
......@@ -83,7 +83,7 @@ class _ShellExtensionInstallerTweak(Tweak):
self._shell = shell
chooser = FileChooserButtonTweak(
chooser = FileChooserButton(
_("Select an extension"),
True,
"application/zip")
......
......@@ -302,8 +302,8 @@ class GConfFontButtonTweak(_GConfTweak):
def _on_fontbutton_changed(self, btn, param):
self.gconf.set_value(btn.props.font_name)
class FileChooserButtonTweak(Gtk.FileChooserButton):
def __init__(self, title, local_only, mimetypes=()):
class FileChooserButton(Gtk.FileChooserButton):
def __init__(self, title, local_only, mimetypes):
Gtk.FileChooserButton.__init__(self, title=title)
if mimetypes:
......@@ -314,6 +314,31 @@ class FileChooserButtonTweak(Gtk.FileChooserButton):
#self.set_width_chars(15)
self.set_local_only(local_only)
self.set_action(Gtk.FileChooserAction.OPEN)
class GSettingsFileChooserButtonTweak(_GSettingsTweak):
def __init__(self, schema_name, key_name, local_only, mimetypes, **options):
_GSettingsTweak.__init__(self, schema_name, key_name, **options)
self.settings.connect('changed::'+self.key_name, self._on_setting_changed)
self.filechooser = FileChooserButton(self.name,local_only,mimetypes)
self.filechooser.set_uri(self.settings.get_string(self.key_name))
self.filechooser.connect("file-set", self._on_file_set)
self.widget = build_label_beside_widget(self.name, self.filechooser)
self.widget_for_size_group = self.filechooser
def _values_are_different(self):
return self.settings.get_string(self.key_name) != self.filechooser.get_uri()
def _on_setting_changed(self, setting, key):
self.filechooser.set_uri(self.settings.get_string(key))
def _on_file_set(self, chooser):
uri = self.filechooser.get_uri()
if uri and self._values_are_different():
self.settings.set_string(self.key_name, uri)
class DarkThemeSwitcher(Tweak):
def __init__(self, **options):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment