Commit c7365532 authored by Actionless Loveless's avatar Actionless Loveless Committed by chrysn

style: autopep8

parent 549550a7
# ARandR -- Another XRandR GUI
# Copyright (C) 2008 -- 2011 chrysn <chrysn@fsfe.org>
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
......
# ARandR -- Another XRandR GUI
# Copyright (C) 2008 -- 2011 chrysn <chrysn@fsfe.org>
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
......@@ -21,9 +21,10 @@ Run by calling the main() function."""
import gtk
from . import widget
def main():
w = gtk.Window()
w.connect('destroy',gtk.main_quit)
w.connect('destroy', gtk.main_quit)
r = widget.ARandRWidget()
r.load_from_x()
......
......@@ -130,7 +130,8 @@ class Application(object):
("SaveAs", Gtk.STOCK_SAVE_AS, None, None, None, self.do_save_as),
("Apply", Gtk.STOCK_APPLY, None, '<Control>Return', None, self.do_apply),
("LayoutSettings", Gtk.STOCK_PROPERTIES, None, '<Alt>Return', None, self.do_open_properties),
("LayoutSettings", Gtk.STOCK_PROPERTIES, None,
'<Alt>Return', None, self.do_open_properties),
("Quit", Gtk.STOCK_QUIT, None, None, None, Gtk.main_quit),
......@@ -141,16 +142,17 @@ class Application(object):
("OutputsDummy", None, _("Dummy")),
("System", None, _("_System")),
("Metacity", None, _("_Keybindings (Metacity)"), None, None, self.do_open_metacity),
("Metacity", None, _("_Keybindings (Metacity)"),
None, None, self.do_open_metacity),
("Help", None, _("_Help")),
("About", Gtk.STOCK_ABOUT, None, None, None, self.about),
])
])
actiongroup.add_radio_actions([
("Zoom4", None, _("1:4"), None, None, 4),
("Zoom8", None, _("1:8"), None, None, 8),
("Zoom16", None, _("1:16"), None, None, 16),
], 8, self.set_zoom)
], 8, self.set_zoom)
window.connect('destroy', Gtk.main_quit)
......@@ -193,14 +195,16 @@ class Application(object):
#################### actions ####################
@actioncallback
def set_zoom(self, value): # don't use directly: state is not pushed back to action group.
# don't use directly: state is not pushed back to action group.
def set_zoom(self, value):
self.widget.factor = value
self.window.resize(1,1)
self.window.resize(1, 1)
@actioncallback
def do_open_properties(self):
d = Gtk.Dialog(_("Script Properties"), None, Gtk.DialogFlags.MODAL, (Gtk.STOCK_CLOSE, Gtk.RESPONSE_ACCEPT))
d.set_default_size(300,400)
d = Gtk.Dialog(_("Script Properties"), None,
Gtk.DialogFlags.MODAL, (Gtk.STOCK_CLOSE, Gtk.RESPONSE_ACCEPT))
d.set_default_size(300, 400)
script_editor = Gtk.TextView()
script_buffer = script_editor.get_buffer()
......@@ -227,7 +231,8 @@ class Application(object):
try:
self.widget.save_to_x()
except Exception as e:
d = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.BUTTONS_OK, _("XRandR failed:\n%s")%e)
d = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.BUTTONS_OK, _(
"XRandR failed:\n%s") % e)
d.run()
d.destroy()
......@@ -237,7 +242,8 @@ class Application(object):
@actioncallback
def do_open(self):
d = self._new_file_dialog(_("Open Layout"), Gtk.FILE_CHOOSER_ACTION_OPEN, Gtk.STOCK_OPEN)
d = self._new_file_dialog(
_("Open Layout"), Gtk.FILE_CHOOSER_ACTION_OPEN, Gtk.STOCK_OPEN)
result = d.run()
filenames = d.get_filenames()
......@@ -249,7 +255,8 @@ class Application(object):
@actioncallback
def do_save_as(self):
d = self._new_file_dialog(_("Save Layout"), Gtk.FILE_CHOOSER_ACTION_SAVE, Gtk.STOCK_SAVE)
d = self._new_file_dialog(
_("Save Layout"), Gtk.FILE_CHOOSER_ACTION_SAVE, Gtk.STOCK_SAVE)
d.props.do_overwrite_confirmation = True
result = d.run()
......@@ -258,7 +265,8 @@ class Application(object):
if result == Gtk.RESPONSE_ACCEPT:
assert len(filenames) == 1
f = filenames[0]
if not f.endswith('.sh'): f = f + '.sh'
if not f.endswith('.sh'):
f = f + '.sh'
self.widget.save_to_file(f, self.filetemplate)
def _new_file_dialog(self, title, type, buttontype):
......@@ -304,8 +312,10 @@ class Application(object):
d.props.translator_credits = "\n".join(TRANSLATORS)
d.props.copyright = COPYRIGHT
d.props.comments = PROGRAMDESCRIPTION
licensetext = open(os.path.join(os.path.dirname(__file__), 'data', 'gpl-3.txt')).read()
d.props.license = licensetext.replace('<', u'\u2329 ').replace('>', u' \u232a')
licensetext = open(os.path.join(os.path.dirname(
__file__), 'data', 'gpl-3.txt')).read()
d.props.license = licensetext.replace(
'<', u'\u2329 ').replace('>', u' \u232a')
d.props.logo_icon_name = 'video-display'
d.run()
d.destroy()
......@@ -313,10 +323,13 @@ class Application(object):
def run(self):
Gtk.main()
def main():
p = optparse.OptionParser(usage="%prog [savedfile]", description="Another XRandrR GUI", version="%%prog %s"%__version__)
p = optparse.OptionParser(
usage="%prog [savedfile]", description="Another XRandrR GUI", version="%%prog %s" % __version__)
p.add_option('--randr-display', help='Use D as display for xrandr (but still show the GUI on the display from the environment; e.g. `localhost:10.0`)', metavar='D')
p.add_option('--force-version', help='Even run with untested XRandR versions', action='store_true')
p.add_option('--force-version',
help='Even run with untested XRandR versions', action='store_true')
(options, args) = p.parse_args()
if len(args) == 0:
......@@ -327,8 +340,8 @@ def main():
p.usage()
a = Application(
file=file_to_open,
randr_display=options.randr_display,
force_version=options.force_version
)
file=file_to_open,
randr_display=options.randr_display,
force_version=options.force_version
)
a.run()
......@@ -2,17 +2,17 @@
# ARandR -- Another XRandR GUI
# Copyright (C) 2008 -- 2011 chrysn <chrysn@fsfe.org>
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
......@@ -21,9 +21,9 @@ gettext.install('arandr')
__version__ = '0.1.9'
PROGRAMNAME = _(u'ARandR Screen Layout Editor')
## translators, please translate in the style of "Another XRandR GUI
## (ein weiteres GUI für XRandR)" so users get both the explanation of
## the acronym and a localized version.
# translators, please translate in the style of "Another XRandR GUI
# (ein weiteres GUI für XRandR)" so users get both the explanation of
# the acronym and a localized version.
PROGRAMDESCRIPTION = _(u'Another XRandR GUI')
COPYRIGHT = u'© chrysn 2008 – 2016, Себастьян Gli ţa Κατινα 2011, Johannes Holmberg 2015'
......@@ -31,83 +31,83 @@ COPYRIGHT = u'© chrysn 2008 – 2016, Себастьян Gli ţa Κατινα 2
# git-shortlog(1)) won't cut it, because some contributors don't have any email
# address at all (or might want to be attributed without address).
COMMITTER_ALIASES = {
'chrysn <chrysn@84c1553d-868a-485e-9ebb-c7de0e225ff1>': 'chrysn <chrysn@fsfe.org>',
'Rax <r-a-x@launchpad>': 'Rax Garfield',
'o-157 <Unknown>': 'o-157',
'cdemoulins <clement@archivel.fr>': 'Clément Démoulins <clement@archivel.fr>',
'sjb <gseba@users.sourceforge.net>': 'Себастьян Gli ţa Κατινα <gseba@users.sourceforge.net>',
'Chandru <gundachandru@gmail.com>': 'gundachandru <gundachandru@gmail.com>',
'Dimitris Giouroukis <digitalbckp@launchpad>': 'Dimitris Giouroukis',
'Alir3z4 <agahia.com@gmail.com>': 'Alireza Savand <agahia.com@gmail.com>',
'el_libre como el chaval <el.libre@gmail.com>': 'el_libre <el.libre@gmail.com>',
'phantomx <megaphantomx@bol.com.br>': 'Phantom X <megaphantomx@bol.com.br>',
}
'chrysn <chrysn@84c1553d-868a-485e-9ebb-c7de0e225ff1>': 'chrysn <chrysn@fsfe.org>',
'Rax <r-a-x@launchpad>': 'Rax Garfield',
'o-157 <Unknown>': 'o-157',
'cdemoulins <clement@archivel.fr>': 'Clément Démoulins <clement@archivel.fr>',
'sjb <gseba@users.sourceforge.net>': 'Себастьян Gli ţa Κατινα <gseba@users.sourceforge.net>',
'Chandru <gundachandru@gmail.com>': 'gundachandru <gundachandru@gmail.com>',
'Dimitris Giouroukis <digitalbckp@launchpad>': 'Dimitris Giouroukis',
'Alir3z4 <agahia.com@gmail.com>': 'Alireza Savand <agahia.com@gmail.com>',
'el_libre como el chaval <el.libre@gmail.com>': 'el_libre <el.libre@gmail.com>',
'phantomx <megaphantomx@bol.com.br>': 'Phantom X <megaphantomx@bol.com.br>',
}
TRANSLATORS_OVERRIDES = {
# fixing stuff all over the place
'chrysn <chrysn@fsfe.org>': ['de', 'en'],
'Michal Čihař <michal@cihar.com>': ['cs'],
# see 3b0b47b3665 / c1a7b7edad34
'Mohammad Alhargan <malham1@gmail.com>': ['ar'],
}
# fixing stuff all over the place
'chrysn <chrysn@fsfe.org>': ['de', 'en'],
'Michal Čihař <michal@cihar.com>': ['cs'],
# see 3b0b47b3665 / c1a7b7edad34
'Mohammad Alhargan <malham1@gmail.com>': ['ar'],
}
# everything below this line is updated semi-manually using `./setup.py update_translator_credits`
TRANSLATORS = [
'Algimantas Margevičius <margevicius.algimantas@gmail.com>',
'Alireza Savand <agahia.com@gmail.com>',
'Bakr Al-Tamimi <Bakr.Tamimi@gmail.com>',
'Balázs Úr <urbalazs@gmail.com>',
'Belvar <glasbarg@gmail.com>',
'Bruno_Patri <bruno.patri@gmail.com>',
'Carezero <carezero@qq.com>',
'ChuChangMing <82724824@qq.com>',
'Clément Démoulins <clement@archivel.fr>',
'Denis Jukni <deblenden8@gmail.com>',
'Dimitris Giouroukis',
'Efstathios Iosifidis <iefstathios@gmail.com>',
'Fred Maranhão <fred.maranhao@gmail.com>',
'Guilherme Souza Silva <g.szsilva@gmail.com>',
'HsH <hsh@runtu.org>',
'Igor <vmta@yahoo.com>',
'Ingemar Karlsson <ingemar@ingk.se>',
'Ivan Vantu5z <vantu5z@mail.ru>',
'Joe Hansen <joedalton2@yahoo.dk>',
'Kristjan Räts <kristjanrats@gmail.com>',
'Lu Ca <lmelonimamo@yahoo.it>',
'Luca Vetturi <io@lucavettu.com>',
'Luis García Sevillano <floss.dev@gmail.com>',
'Mantas Kriaučiūnas <mantas@akl.lt>',
'Mehmet Gülmen <memetgulmen@gmail.com>',
'Michal Čihař <michal@cihar.com>',
'Miguel Anxo Bouzada <mbouzada@gmail.com>',
'Mohammad Alhargan <malham1@gmail.com>',
'Olexandr Nesterenko <olexn@ukr.net>',
'ParkJS <HeavensBus@gmail.com>',
'Phantom X <megaphantomx@bol.com.br>',
'Piotr Strebski <strebski@o2.pl>',
'Quizzlo <paolone.marco@gmail.com>',
'Rax Garfield',
'Ricardo A. Hermosilla Carrillo <ra.hermosillac@gmail.com>',
'RooTer <rooter@kyberian.net>',
'Sebastian Wahl <swahl11@student.aau.dk>',
'Semsudin Abdic <abdic88@gmail.com>',
'Slavko <linux@slavino.sk>',
'Slobodan Simić <slsimic@gmail.com>',
'Tamás Nagy <kisagy@gmail.com>',
'Tuux <tuxa@galaxie.eu.org>',
'Vladimir <vladimir-csp@yandex.ru>',
'aboodilankaboot <shiningmoon25@gmail.com>',
'agilob <weblate@agilob.net>',
'cho bkwon <chobkwon@gmail.com>',
'chrysn <chrysn@fsfe.org>',
'el_libre <el.libre@gmail.com>',
'gundachandru <gundachandru@gmail.com>',
'ikmaak <info@ikmaak.nl>',
'josep constanti <jconstanti@yahoo.es>',
'o-157',
'pCsOrI <pcsori@gmail.com>',
'reza khan <reza_khn@yahoo.com>',
'wimfeijen <wimfeijen@gmail.com>',
'Себастьян Gli ţa Κατινα <gseba@users.sourceforge.net>'
]
'Algimantas Margevičius <margevicius.algimantas@gmail.com>',
'Alireza Savand <agahia.com@gmail.com>',
'Bakr Al-Tamimi <Bakr.Tamimi@gmail.com>',
'Balázs Úr <urbalazs@gmail.com>',
'Belvar <glasbarg@gmail.com>',
'Bruno_Patri <bruno.patri@gmail.com>',
'Carezero <carezero@qq.com>',
'ChuChangMing <82724824@qq.com>',
'Clément Démoulins <clement@archivel.fr>',
'Denis Jukni <deblenden8@gmail.com>',
'Dimitris Giouroukis',
'Efstathios Iosifidis <iefstathios@gmail.com>',
'Fred Maranhão <fred.maranhao@gmail.com>',
'Guilherme Souza Silva <g.szsilva@gmail.com>',
'HsH <hsh@runtu.org>',
'Igor <vmta@yahoo.com>',
'Ingemar Karlsson <ingemar@ingk.se>',
'Ivan Vantu5z <vantu5z@mail.ru>',
'Joe Hansen <joedalton2@yahoo.dk>',
'Kristjan Räts <kristjanrats@gmail.com>',
'Lu Ca <lmelonimamo@yahoo.it>',
'Luca Vetturi <io@lucavettu.com>',
'Luis García Sevillano <floss.dev@gmail.com>',
'Mantas Kriaučiūnas <mantas@akl.lt>',
'Mehmet Gülmen <memetgulmen@gmail.com>',
'Michal Čihař <michal@cihar.com>',
'Miguel Anxo Bouzada <mbouzada@gmail.com>',
'Mohammad Alhargan <malham1@gmail.com>',
'Olexandr Nesterenko <olexn@ukr.net>',
'ParkJS <HeavensBus@gmail.com>',
'Phantom X <megaphantomx@bol.com.br>',
'Piotr Strebski <strebski@o2.pl>',
'Quizzlo <paolone.marco@gmail.com>',
'Rax Garfield',
'Ricardo A. Hermosilla Carrillo <ra.hermosillac@gmail.com>',
'RooTer <rooter@kyberian.net>',
'Sebastian Wahl <swahl11@student.aau.dk>',
'Semsudin Abdic <abdic88@gmail.com>',
'Slavko <linux@slavino.sk>',
'Slobodan Simić <slsimic@gmail.com>',
'Tamás Nagy <kisagy@gmail.com>',
'Tuux <tuxa@galaxie.eu.org>',
'Vladimir <vladimir-csp@yandex.ru>',
'aboodilankaboot <shiningmoon25@gmail.com>',
'agilob <weblate@agilob.net>',
'cho bkwon <chobkwon@gmail.com>',
'chrysn <chrysn@fsfe.org>',
'el_libre <el.libre@gmail.com>',
'gundachandru <gundachandru@gmail.com>',
'ikmaak <info@ikmaak.nl>',
'josep constanti <jconstanti@yahoo.es>',
'o-157',
'pCsOrI <pcsori@gmail.com>',
'reza khan <reza_khn@yahoo.com>',
'wimfeijen <wimfeijen@gmail.com>',
'Себастьян Gli ţa Κατινα <gseba@users.sourceforge.net>'
]
This diff is collapsed.
# ARandR -- Another XRandR GUI
# Copyright (C) 2008 -- 2011 chrysn <chrysn@fsfe.org>
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from .auxiliary import Position
class Snap(object):
"""Snap-to-edges manager"""
def __init__(self, size, tolerance, list):
self.tolerance = tolerance
......@@ -38,8 +40,10 @@ class Snap(object):
self.horizontal.add((i[0].top + i[1].height/2)-size.height/2)
def suggest(self, position):
vertical = [x for x in self.vertical if abs(x-position[0])<self.tolerance]
horizontal = [y for y in self.horizontal if abs(y-position[1])<self.tolerance]
vertical = [x for x in self.vertical if abs(
x-position[0]) < self.tolerance]
horizontal = [y for y in self.horizontal if abs(
y-position[1]) < self.tolerance]
if vertical:
position = Position((vertical[0], position[1]))
......
from .auxiliary import Position, NORMAL, ROTATIONS, InadequateConfiguration
from .xrandr import XRandR, Feature
from .snap import Snap
from gi.repository import GObject, Gtk, Pango, PangoCairo, Gdk
"""
ARandR -- Another XRandR GUI
Copyright (C) 2008 -- 2011 chrysn <chrysn@fsfe.org>
......@@ -26,11 +30,6 @@ import gettext
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('PangoCairo', '1.0')
from gi.repository import GObject, Gtk, Pango, PangoCairo, Gdk
from .snap import Snap
from .xrandr import XRandR, Feature
from .auxiliary import Position, NORMAL, ROTATIONS, InadequateConfiguration
gettext.install('arandr')
......
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