Commit a40c6c74 authored by John Stowers's avatar John Stowers

generalise the ZipFileChooserButton a little

parent 4a7022f8
......@@ -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 ZipFileChooserButton, GSettingsComboTweak, GSettingsComboEnumTweak, GSettingsSwitchTweak, build_label_beside_widget, build_horizontal_sizegroup, build_combo_box_text, UI_BOX_SPACING
from gtweak.widgets import FileChooserButtonTweak, 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,10 @@ class ShellThemeTweak(Tweak):
self._combo = cb
#a filechooser to install new themes
chooser = ZipFileChooserButton(_("Select a theme"))
chooser = FileChooserButtonTweak(
_("Select a theme"),
True,
"application/zip")
chooser.connect("file-set", self._on_file_set)
self.widget = build_label_beside_widget(self.name, chooser, cb)
......
......@@ -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 ZipFileChooserButton, build_label_beside_widget, build_horizontal_sizegroup, build_tight_button, UI_BOX_SPACING
from gtweak.widgets import FileChooserButtonTweak, build_label_beside_widget, build_horizontal_sizegroup, build_tight_button, UI_BOX_SPACING
def N_(x): return x
......@@ -83,7 +83,10 @@ class _ShellExtensionInstallerTweak(Tweak):
self._shell = shell
chooser = ZipFileChooserButton(_("Select an extension"))
chooser = FileChooserButtonTweak(
_("Select an extension"),
True,
"application/zip")
chooser.connect("file-set", self._on_file_set)
hb = Gtk.HBox(spacing=UI_BOX_SPACING)
......
......@@ -302,16 +302,18 @@ class GConfFontButtonTweak(_GConfTweak):
def _on_fontbutton_changed(self, btn, param):
self.gconf.set_value(btn.props.font_name)
class ZipFileChooserButton(Gtk.FileChooserButton):
def __init__(self, title):
class FileChooserButtonTweak(Gtk.FileChooserButton):
def __init__(self, title, local_only, mimetypes=()):
Gtk.FileChooserButton.__init__(self, title=title)
f = Gtk.FileFilter()
f.add_mime_type("application/zip")
self.set_filter(f)
if mimetypes:
f = Gtk.FileFilter()
for m in mimetypes:
f.add_mime_type(m)
self.set_filter(f)
#self.set_width_chars(15)
self.set_local_only(True)
self.set_local_only(local_only)
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