1# ARandR -- Another XRandR GUI
2# Copyright (C) 2008 -- 2011 chrysn <chrysn@fsfe.org>
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17"""Demo application, primarily used to make sure the screenlayout library can be used independent of ARandR.
18
19Run by calling the main() function."""
20
21# pylint: disable=wrong-import-position
22
23import gi
24gi.require_version('Gtk', '3.0')
25from gi.repository import Gtk
26
27from . import widget
28
29
30def main():
31    window = Gtk.Window()
32    window.connect('destroy', Gtk.main_quit)
33
34    arandr = widget.ARandRWidget(window=window)
35    arandr.load_from_x()
36
37    reload_button = Gtk.Button("Reload")
38    reload_button.connect('clicked', lambda *args: arandr.load_from_x())
39
40    apply_button = Gtk.Button("Apply")
41    apply_button.connect('clicked', lambda *args: arandr.save_to_x())
42
43    vbox = Gtk.VBox()
44    window.add(vbox)
45    vbox.add(arandr)
46    vbox.add(reload_button)
47    vbox.add(apply_button)
48    window.set_title('Simple ARandR Widget Demo')
49    window.show_all()
50    Gtk.main()
51