This repository has been archived by the owner on Jan 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
shortcuts
executable file
·189 lines (172 loc) · 7.28 KB
/
shortcuts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/usr/bin/env python3
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
"""
WindowShuffler
Author: Jacob Vlijm
Copyright © 2017-2018 Ubuntu Budgie Developers
Website=https://ubuntubudgie.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 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 <https://www.gnu.org/licenses/>.
"""
css_data = """
.title {
font-weight: bold;
}
.window {
}
.header {
font-size: 30px;
}
.matrixmanagebutton {
border-width: 0px;
background-color: transparent;
}
.matrixmanagebutton:hover {
background-color: transparent;
border-width: 0px;
}
"""
usage_content = "Click a window and click the grid to place the " + \
"window in the corresponding position. Shift-click to " + \
"select multiple tiles, press [ a ] to arrange all " + \
"windows to grid." + \
"\n\nWindows cannot not be resized below their minimum " + \
"sizes, nor can fixed-size windows be resized. They will " + \
" however be positioned correctly in the grid."
singletiling = "WindowShuffler can also be used by cli " + \
"(e.g. to set window tiling shortcuts). To use, run:\n\n" + \
"/usr/share/budgie-desktop/windowshuffler/shuffler_nogui" + \
"\n\n...with as arguments the size of the matrix " + \
"(horizontally, vertically) + the targeted position of the " + \
" active window in the matrix (where 0 is the first). " + \
"An example:\n\n" + \
"/usr/share/budgie-desktop/windowshuffler/shuffler_nogui " + \
"2 2 0 1\n\n...will place the active window in the bottom " +\
"left cell in a grid of 2 x 2.\n\nNo need to say that the " + \
"path: /usr/share/budgie-desktop is the default path on " + \
"Ubuntu Budgie, might be different per distro or if " + \
"you possibly installed it manually."
arrange_all = "Similarly, all windows can be moved into a grid from " + \
"cli, by the command (as an example):\n\n" + \
"/usr/share/budgie-desktop/windowshuffler/" + \
"shuffler_nogui arrange_all 2 2" + \
"\n\n...to move all windows into a 2x2 grid."
class WindwoMatrix(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Usage & general shortcuts")
self.scrolled_window = Gtk.ScrolledWindow()
self.scrolled_window.set_policy(
Gtk.PolicyType.NEVER,
Gtk.PolicyType.AUTOMATIC
)
self.add(self.scrolled_window)
self.scrolled_window.set_border_width(10)
self.connect("destroy", Gtk.main_quit)
self.set_skip_taskbar_hint(True)
self.set_default_size(700, 700)
self.move(200, 100)
self.set_decorated(False)
self.maingrid = Gtk.Grid()
self.scrolled_window.add_with_viewport(self.maingrid)
# self.add(self.maingrid)
self.maingrid.set_border_width(30)
# styling
self.provider = Gtk.CssProvider.new()
self.provider.load_from_data(css_data.encode())
# icons
self.bigx_1 = Gtk.Image.new_from_icon_name(
"exit-splash-symbolic", Gtk.IconSize.MENU,
)
self.bigx_2 = Gtk.Image.new_from_icon_name(
"fat-exit-splash-symbolic", Gtk.IconSize.MENU,
)
icon = Gtk.Image.new_from_icon_name(
"windowshuffler-symbolic", Gtk.IconSize.DND,
)
# content
self.xbox = Gtk.Box()
self.maingrid.attach(self.xbox, 0, 0, 1, 1)
line_extra1 = Gtk.Label("\n")
self.maingrid.attach(line_extra1, 0, 1, 1, 1)
self.box = Gtk.Box()
self.box.pack_start(icon, False, False, 0)
self.maingrid.attach(self.box, 0, 2, 2, 1)
line_extra = Gtk.Label("\n")
self.maingrid.attach(line_extra, 0, 3, 1, 1)
sep = Gtk.Separator()
self.maingrid.attach(sep, 0, 4, 2, 1)
title = Gtk.Label(" WindowShuffler", xalign=0)
self.set_widgetstyle(title, "header")
self.box.pack_start(title, False, False, 0)
usage_title = Gtk.Label("\nUsage & shortcuts", xalign=0)
self.set_widgetstyle(usage_title, "title")
self.maingrid.attach(usage_title, 0, 5, 2, 1)
usage_text = Gtk.Label(usage_content, xalign=0)
usage_text.set_line_wrap(True)
self.maingrid.attach(usage_text, 0, 6, 2, 1)
ntitle = 0
for title in [
"\nAdd a column to the grid", "\nRemove a column from the grid",
"\nAdd a row to the grid", "\nremove a row from the grid",
"\nArrange windows on current workspace to current grid",
"\nTake a snapshot of the current layout",
"\nRestore layout to snapshot",
"\nDismiss the grid", "\nOpen (toggle) this window",
"\nWindowShuffler cli: single window tiling",
"\nWindowShuffler cli: arrange all windows",
]:
newtitle = Gtk.Label(title, xalign=0)
self.maingrid.attach(newtitle, 0, 10 + ntitle, 2, 1)
self.set_widgetstyle(newtitle, "title")
ntitle = ntitle + 2
ntext = 0
for text in [
"[ Right ] or [ + ]", "[ Left ] or [ - ]",
"[ Down ] or [ Ctrl ] + [ + ]", "[ Up ] or [ Ctrl ] + [ - ]",
"[ a ]", "[ s ]", "[ u ]", "[ Escape ] or [ . ] (period)", "[ i ]",
singletiling,
arrange_all,
]:
newtext = Gtk.Label(text, xalign=0)
newtext.set_line_wrap(True)
self.maingrid.attach(newtext, 0, 11 + ntext, 2, 1)
ntext = ntext + 2
self.set_widgetstyle(self, "window")
self.exitbutton()
self.maingrid.show_all()
self.show_all()
Gtk.main()
def set_widgetstyle(self, widget, style):
stylecontext = widget.get_style_context()
stylecontext.add_class(style)
Gtk.StyleContext.add_provider(
stylecontext, self.provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
)
def exitbutton(self):
exitbutton = Gtk.Button()
exitbutton.connect("enter-notify-event", self.change_icon)
exitbutton.connect("leave-notify-event", self.change_icon)
exitbutton.set_size_request(10, 10)
exitbutton.set_image(self.bigx_1)
exitbutton.connect("clicked", self.exit)
exitbutton.set_relief(Gtk.ReliefStyle.NONE)
self.set_widgetstyle(exitbutton, "matrixmanagebutton")
self.xbox.pack_start(exitbutton, False, False, 0)
def change_icon(self, button, event):
enter = True if "GDK_ENTER_NOTIFY" in str(event.type) else False
if enter:
button.set_image(self.bigx_2)
else:
button.set_image(self.bigx_1)
def exit(self, *args):
Gtk.main_quit()
WindwoMatrix()