Commit 84c573ce authored by Jeremy Bicha's avatar Jeremy Bicha 🎹

cleanup: Drop trailing spaces

parent 1ae226a2
......@@ -21,14 +21,14 @@ from gi.repository import Gtk
from gi.repository import Gio
from gi.repository import GLib
import gtweak
import gtweak
from gtweak.defs import VERSION
from gtweak.tweakmodel import TweakModel
from gtweak.tweakview import Window
from gtweak.utils import SchemaList
from gtweak.gshellwrapper import GnomeShellFactory
from gtweak.utils import DisableExtension
class GnomeTweakTool(Gtk.Application):
def __init__(self):
......@@ -38,29 +38,29 @@ class GnomeTweakTool(Gtk.Application):
def do_activate(self):
if not self.win:
model = TweakModel()
model = TweakModel()
self.win = Window(self, model)
self.win.show_all()
self.win.present()
def do_startup(self):
Gtk.Application.do_startup(self)
self.builder = Gtk.Builder()
assert(os.path.exists(gtweak.PKG_DATA_DIR))
assert(os.path.exists(gtweak.PKG_DATA_DIR))
filename = os.path.join(gtweak.PKG_DATA_DIR, 'shell.ui')
self.builder.add_from_file(filename)
appmenu = self.builder.get_object('appmenu')
self.set_app_menu(appmenu)
reset_action = Gio.SimpleAction.new("reset", None)
reset_action.connect("activate", self.reset_cb)
self.add_action(reset_action)
self.add_action(reset_action)
disable_extension_action = Gio.SimpleAction.new("disable_extension", None)
disable_extension_action.connect("activate", self.disable_cb)
self.add_action(disable_extension_action)
self.add_action(disable_extension_action)
help_action = Gio.SimpleAction.new("help", None)
help_action.connect("activate", self.help_cb)
......@@ -80,10 +80,10 @@ class GnomeTweakTool(Gtk.Application):
dialog.format_secondary_text(_("Reset all tweak settings to the original default state?"))
response = dialog.run()
if response == Gtk.ResponseType.OK:
s = SchemaList()
s = SchemaList()
s.reset()
dialog.destroy()
def help_cb(self, action, parameter):
print("This does nothing. It is only a demonstration.")
......@@ -112,12 +112,12 @@ class GnomeTweakTool(Gtk.Application):
aboutdialog.set_website("https://wiki.gnome.org/Apps/GnomeTweakTool")
aboutdialog.set_website_label(_("Homepage"))
aboutdialog.set_license_type(Gtk.License.GPL_3_0)
AUTHORS = [
"John Stowers <john.stowers@gmail.com>"
]
aboutdialog.set_authors(AUTHORS)
aboutdialog.set_authors(AUTHORS)
aboutdialog.connect("response", lambda w, r: aboutdialog.destroy())
aboutdialog.show()
......
......@@ -88,7 +88,7 @@ class ExtensionsDotGnomeDotOrg(GObject.GObject):
def get_download_url(self, extinfo):
url = "https://extensions.gnome.org/download-extension/%s.shell-extension.zip?version_tag=%d"
#version tag is the pk in the shell_version_map
#url = url % (extinfo["uuid"],
#url = url % (extinfo["uuid"],
if __name__ == "__main__":
......
......@@ -154,7 +154,7 @@ class GSettingsSetting(Gio.Settings):
def schema_get_summary(self, key):
return self._schema._schema[key]["summary"]
def schema_get_description(self, key):
return self._schema._schema[key]["description"]
......
......@@ -31,7 +31,7 @@ class MainWindow:
filename = os.path.join(gtweak.PKG_DATA_DIR, 'shell.ui')
builder.add_from_file(filename)
model = TweakModel()
view = TweakView(
builder,
......
......@@ -110,16 +110,16 @@ class TweakModel(Gtk.ListStore):
tweak_files.remove("tweak_group_test")
except ValueError:
pass
groups = []
tweaks = []
mods = __import__("gtweak.tweaks", globals(), locals(), tweak_files, 0)
for mod in [getattr(mods, file_name) for file_name in tweak_files]:
groups.extend( getattr(mod, "TWEAK_GROUPS", []) )
schemas = SchemaList()
schemas = SchemaList()
for g in groups:
g.main_window = main_window
if g.tweaks:
......@@ -141,17 +141,17 @@ class TweakModel(Gtk.ListStore):
self._tweak_group_iters[tweakgroup.name] = _iter
def search_matches(self, txt):
tweaks = []
groups = []
tweaks = []
groups = []
for g in self.tweak_groups:
for t in g.tweaks:
if t.search_matches(txt):
for t in g.tweaks:
if t.search_matches(txt):
tweaks.append(t)
if not g.name in groups:
if not g.name in groups:
groups.append(g.name)
return tweaks, groups
return tweaks, groups
def get_tweakgroup_iter(self, name):
return self._tweak_group_iters[name]
......@@ -185,7 +185,7 @@ class ShellThemeTweak(Gtk.Box, Tweak):
build_label_beside_widget(self.name, chooser, cb, hbox=self)
self.widget_for_size_group = cb
def _on_file_set(self, chooser):
f = chooser.get_filename()
......
......@@ -60,5 +60,6 @@ TWEAK_GROUPS = [
ListBoxTweakGroup(_("Power"),
IgnoreLidSwitchTweak(),
GSettingsComboEnumTweak(_("Power Button Behavior"), "org.gnome.settings-daemon.plugins.power", "power-button-action", size_group=sg),
GSettingsSwitchTweak(_("Show Battery percentage in Top Bar"),"org.gnome.desktop.interface", "show-battery-percentage"),
),
]
......@@ -227,11 +227,11 @@ class ShellExtensionTweakGroup(ListBoxTweakGroup):
logging.warning("Error listing extensions", exc_info=True)
except:
logging.warning("Error detecting shell", exc_info=True)
ListBoxTweakGroup.__init__(self,
_("Extensions"),
*extension_tweaks)
self.props.valign = Gtk.Align.FILL
self.titlebar_widget = Gtk.Switch(visible=True)
......
......@@ -39,22 +39,22 @@ class Window(Gtk.ApplicationWindow):
self.set_size_request(950, 700)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_icon_name("gnome-tweak-tool")
self.hsize_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
main_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
left_box = self.sidebar()
right_box = self.main_content()
separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
titlebar = self.titlebar()
self.set_titlebar(titlebar)
main_box.pack_start(left_box, False, False, 0)
main_box.pack_start(separator, False, False, 0)
main_box.pack_start(right_box, True, True, 0)
self.load_css()
self.load_css()
self._model = model
self._model.load_tweaks(self)
self.load_model_data()
......@@ -65,7 +65,7 @@ class Window(Gtk.ApplicationWindow):
self.connect("key-press-event", self._on_key_press)
self.connect_after("key-press-event", self._after_key_press)
self.add(main_box)
def titlebar(self):
header = Gtk.Box()
......@@ -107,22 +107,22 @@ class Window(Gtk.ApplicationWindow):
header.pack_start(left_header, False, False, 0)
header.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), False, False, 0)
header.pack_start(right_header, True, True, 0)
self.hsize_group.add_widget(left_header)
return header
def sidebar(self):
left_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.entry = Gtk.SearchEntry(placeholder_text=_("Search Tweaks…"))
self.entry.connect("search-changed", self._on_search)
self.searchbar = Gtk.SearchBar()
self.searchbar.add(self.entry)
self.searchbar.props.hexpand = False
self.listbox = Gtk.ListBox()
self.listbox.get_style_context().add_class("tweak-categories")
self.listbox.set_size_request(200,-1)
......@@ -132,24 +132,24 @@ class Window(Gtk.ApplicationWindow):
scroll.set_policy(Gtk.PolicyType.NEVER,
Gtk.PolicyType.AUTOMATIC)
scroll.add(self.listbox)
left_box.pack_start(self.searchbar, False, False, 0)
left_box.pack_start(scroll, True, True, 0)
self.hsize_group.add_widget(left_box)
return left_box
def main_content(self):
def main_content(self):
right_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
#GRR why can I not put margin in the CSS of a GtkStack
self.stack = Gtk.Stack()
self.stack.get_style_context().add_class("main-container")
self.stack.props.margin = 20
right_box.pack_start(self.stack, True, True, 0)
return right_box
def load_css(self):
......@@ -178,7 +178,7 @@ class Window(Gtk.ApplicationWindow):
row = _make_items_listbox(g)
self.listbox.add(row)
tweakgroup = self._model.get_value(
self._model.get_tweakgroup_iter(g),
self._model.get_tweakgroup_iter(g),
self._model.COLUMN_TWEAK)
scroll = Gtk.ScrolledWindow()
scroll.add(tweakgroup)
......@@ -191,7 +191,7 @@ class Window(Gtk.ApplicationWindow):
lbl = row.get_child()
if lbl.get_text() in user_data:
return row
def _list_header_func(self, row, before, user_data):
if before and not row.get_header():
row.set_header (Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL))
......@@ -247,9 +247,9 @@ class Window(Gtk.ApplicationWindow):
def _on_search(self, entry):
txt = string_for_search(entry.get_text())
tweaks, group = self._model.search_matches(txt)
self.show_only_tweaks(tweaks)
self.show_only_tweaks(tweaks)
self._on_list_changed(group)
def _on_select_row(self, listbox, row):
if row:
group = row.get_child().get_text()
......
......@@ -128,7 +128,7 @@ class AutostartManager:
def get_user_autostart_files():
return glob.glob(
os.path.join(
GLib.get_user_config_dir(), "autostart", "*.desktop"))
GLib.get_user_config_dir(), "autostart", "*.desktop"))
@staticmethod
def get_system_autostart_files():
......@@ -204,7 +204,7 @@ class AutostartFile:
old = open(self._desktop_file, "r")
new = open(self._user_autostart_file, "w")
for l in old.readlines():
for l in old.readlines():
if l.startswith("Exec="):
if self._exec_cmd:
new.write("Exec=%s\n" % self._exec_cmd)
......@@ -225,28 +225,28 @@ class SchemaList:
if SchemaList.__list == None:
SchemaList.__list = []
def get(self):
return SchemaList.__list
def insert(self, key_name, schema_name):
v = [key_name, schema_name]
SchemaList.__list.append(v)
def reset(self):
for i in SchemaList.__list:
s = Gio.Settings(i[1])
s.reset(i[0])
@singleton
class DisableExtension(GObject.GObject):
__gsignals__ = {
"disable-extension": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE,()),
}
}
def __init__(self):
GObject.GObject.__init__(self)
def disable(self):
self.emit("disable-extension")
......@@ -344,8 +344,8 @@ class LogoutNotification:
d = Gio.bus_get_sync(Gio.BusType.SESSION, None)
proxy = Gio.DBusProxy.new_sync(
d,Gio.DBusProxyFlags.NONE, None,
'org.gnome.SessionManager',
'/org/gnome/SessionManager',
'org.gnome.SessionManager',
'/org/gnome/SessionManager',
'org.gnome.SessionManager',
None)
proxy.Logout('(u)', 0)
......
......@@ -79,7 +79,7 @@ def build_label_beside_widget(txt, *widget, **kwargs):
#label. By convention this is true in the great majority of cases. Settings that
#construct their own widgets will need to set this themselves
lbl.set_mnemonic_widget(widget[-1])
return hbox
def build_combo_box_text(selected, *values):
......@@ -126,7 +126,7 @@ def build_tight_button(stock_id):
provider = Gtk.CssProvider()
provider.load_from_data(data)
# 600 = GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
button.get_style_context().add_provider(provider, 600)
button.get_style_context().add_provider(provider, 600)
return button
def adjust_schema_for_overrides(originalSchema, key, options):
......@@ -348,7 +348,7 @@ class GSettingsSpinButtonTweak(Gtk.Box, _GSettingsTweak, _DependableMixin):
build_label_beside_widget(name, w, hbox=self)
self.widget_for_size_group = w
self.add_dependency_on_tweak(
options.get("depends_on"),
options.get("depends_how")
......@@ -506,11 +506,11 @@ class DarkThemeSwitcher(Gtk.Box, Tweak):
w = Gtk.Switch()
w.set_active(self._gtksettings3.get_integer("gtk-application-prefer-dark-theme"))
title = _("Global Dark Theme")
description = _("Applications need to be restarted for this change to take place.")
w.connect("notify::active", self._on_switch_changed)
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
hbox.props.spacing = UI_BOX_SPACING
lbl = Gtk.Label(label=title)
......@@ -518,12 +518,12 @@ class DarkThemeSwitcher(Gtk.Box, Tweak):
lbl.props.xalign = 0.0
hbox.pack_start(lbl, True, True, 0)
hbox.pack_start(w, False, False, 0)
lbl_des = Gtk.Label()
lbl_des.props.xalign = 0.0
lbl_des.get_style_context().add_class("dim-label")
lbl_des.set_markup("<span size='small'>"+GLib.markup_escape_text(description)+"</span>")
self.pack_start(hbox, False, False, 0)
self.pack_start(lbl_des, False, False,0)
self.widget_for_size_group = None
......@@ -549,7 +549,7 @@ class Title(Gtk.Box, Tweak):
self.add(widget)
class GSettingsSwitchTweakValue(Gtk.Box, _GSettingsTweak):
def __init__(self, name, schema_name, key_name, **options):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
_GSettingsTweak.__init__(self, name, schema_name, key_name, **options)
......@@ -561,9 +561,9 @@ class GSettingsSwitchTweakValue(Gtk.Box, _GSettingsTweak):
def _on_toggled(self, sw, pspec):
self.set_active(sw.get_active())
def set_active(self, v):
raise NotImplementedError()
def get_active(self):
raise NotImplementedError()
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