Skip to content

Commit fae9ebf

Browse files
danirabbitJeremy Wootten
andauthored
Multitasking: redesign (#310)
* Multitasking: redesign * Custom command per corner * remove debug code Co-authored-by: Jeremy Wootten <jeremy@elementaryos.org>
1 parent a9a0dcd commit fae9ebf

3 files changed

Lines changed: 171 additions & 114 deletions

File tree

data/plug.css

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,40 @@
1717
* Boston, MA 02110-1301 USA.
1818
*/
1919

20-
.hotcorner-display {
20+
.hotcorner {
2121
background-image:
2222
radial-gradient(
2323
circle,
24-
alpha(@accent_color_500, 0.6) 70%,
25-
alpha(@accent_color_500, 0) 1%
26-
),
27-
radial-gradient(
28-
circle,
29-
alpha(@accent_color_500, 0.6) 70%,
30-
alpha(@accent_color_500, 0) 1%
31-
),
32-
radial-gradient(
33-
circle,
34-
alpha(@accent_color_500, 0.6) 70%,
35-
alpha(@accent_color_500, 0) 1%
36-
),
37-
radial-gradient(
38-
circle,
39-
alpha(@accent_color_500, 0.6) 70%,
40-
alpha(@accent_color_500, 0) 1%
24+
alpha(@accent_color, 0.4) 70%,
25+
alpha(@accent_color, 0) 1px
4126
),
4227
linear-gradient(
4328
to bottom,
4429
alpha (@accent_color_500, 0.1),
4530
alpha (@accent_color_500, 0.1)
4631
);
4732
background-repeat: no-repeat;
48-
background-position: -32px -32px, -32px calc(100% + 32px), calc(100% + 32px) -32px, calc(100% + 32px) calc(100% + 32px), 0;
49-
background-size: 64px 64px, 64px 64px, 64px 64px, 64px 64px, cover;
33+
background-size: 48px 48px, cover;
34+
color: @selected_fg_color;
35+
font-weight: 600;
36+
min-height: 3.5em;
37+
padding: 12px;
38+
}
39+
40+
.hotcorner.topleft {
41+
background-position: -24px -24px, 0;
42+
}
43+
44+
.hotcorner.topright {
45+
background-position: calc(100% + 24px) -24px, 0;
46+
}
47+
48+
.hotcorner.bottomleft {
49+
background-position: -24px calc(100% + 24px), 0;
50+
}
51+
52+
.hotcorner.bottomright {
53+
background-position: calc(100% + 24px) calc(100% + 24px), 0;
5054
}
5155

5256
.wallpaper-container {

data/screenshot-multitasking.png

23.2 KB
Loading

src/Views/Multitasking.vala

Lines changed: 147 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -19,83 +19,27 @@
1919
* Authored by: Tom Beckmann
2020
*/
2121

22-
public class PantheonShell.Multitasking : Gtk.Grid {
22+
public class PantheonShell.Multitasking : Gtk.Box {
2323
private GLib.Settings behavior_settings;
24-
private Gtk.Revealer custom_command_revealer;
25-
private Gee.HashSet<string> keys_using_custom_command = new Gee.HashSet<string> ();
26-
27-
private const string CUSTOM_COMMAND_ID = "5";
2824
private const string ANIMATIONS_SCHEMA = "org.pantheon.desktop.gala.animations";
2925
private const string ANIMATIONS_KEY = "enable-animations";
3026

3127
construct {
32-
margin_start = margin_end = 12;
33-
margin_bottom = 24;
34-
column_spacing = 12;
35-
row_spacing = 6;
36-
halign = Gtk.Align.CENTER;
37-
38-
behavior_settings = new GLib.Settings ("org.pantheon.desktop.gala.behavior");
39-
40-
custom_command_revealer = new Gtk.Revealer ();
41-
4228
var hotcorner_title = new Gtk.Label (_("When the cursor enters the corner of the display:")) {
4329
halign = Gtk.Align.START,
4430
margin_bottom = 6,
4531
margin_top = 6
4632
};
4733
hotcorner_title.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL);
4834

49-
var topleft = create_hotcorner ();
50-
topleft.changed.connect (() => hotcorner_changed ("hotcorner-topleft", topleft));
51-
topleft.active_id = behavior_settings.get_enum ("hotcorner-topleft").to_string ();
52-
topleft.valign = Gtk.Align.START;
53-
54-
var topright = create_hotcorner ();
55-
topright.changed.connect (() => hotcorner_changed ("hotcorner-topright", topright));
56-
topright.active_id = behavior_settings.get_enum ("hotcorner-topright").to_string ();
57-
topright.valign = Gtk.Align.START;
58-
59-
var bottomleft = create_hotcorner ();
60-
bottomleft.changed.connect (() => hotcorner_changed ("hotcorner-bottomleft", bottomleft));
61-
bottomleft.active_id = behavior_settings.get_enum ("hotcorner-bottomleft").to_string ();
62-
bottomleft.valign = Gtk.Align.END;
63-
64-
var bottomright = create_hotcorner ();
65-
bottomright.changed.connect (() => hotcorner_changed ("hotcorner-bottomright", bottomright));
66-
bottomright.active_id = behavior_settings.get_enum ("hotcorner-bottomright").to_string ();
67-
bottomright.valign = Gtk.Align.END;
68-
69-
var icon = new Gtk.Grid ();
70-
icon.height_request = 198;
71-
icon.width_request = 292;
72-
73-
unowned Gtk.StyleContext icon_style_context = icon.get_style_context ();
74-
icon_style_context.add_class (Granite.STYLE_CLASS_CARD);
75-
icon_style_context.add_class ("hotcorner-display");
76-
icon_style_context.add_class (Granite.STYLE_CLASS_ROUNDED);
77-
78-
var custom_command = new Gtk.Entry ();
79-
custom_command.primary_icon_name = "utilities-terminal-symbolic";
80-
81-
var cc_label = new Gtk.Label (_("Custom command:"));
82-
83-
var cc_grid = new Gtk.Grid ();
84-
cc_grid.column_spacing = column_spacing;
85-
cc_grid.halign = Gtk.Align.END;
86-
cc_grid.margin_top = 24;
87-
cc_grid.add (cc_label);
88-
cc_grid.add (custom_command);
89-
90-
var cc_sizegroup = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
91-
cc_sizegroup.add_widget (icon);
92-
cc_sizegroup.add_widget (custom_command);
93-
94-
custom_command_revealer.add (cc_grid);
35+
var topleft = new HotcornerControl (_("Top Left"), "topleft");
36+
var topright = new HotcornerControl (_("Top Right"), "topright");
37+
var bottomleft = new HotcornerControl (_("Bottom Left"), "bottomleft");
38+
var bottomright = new HotcornerControl (_("Bottom Right"), "bottomright");
9539

9640
var workspaces_label = new Gtk.Label (_("Move windows to a new workspace:")) {
9741
halign = Gtk.Align.END,
98-
margin_top = 36,
42+
margin_top = 12,
9943
margin_bottom = 12
10044
};
10145

@@ -104,7 +48,7 @@ public class PantheonShell.Multitasking : Gtk.Grid {
10448

10549
var checkbutton_grid = new Gtk.Grid () {
10650
column_spacing = 12,
107-
margin_top = 36,
51+
margin_top = 12,
10852
margin_bottom = 12
10953
};
11054
checkbutton_grid.add (fullscreen_checkbutton);
@@ -118,47 +62,156 @@ public class PantheonShell.Multitasking : Gtk.Grid {
11862
halign = Gtk.Align.START
11963
};
12064

121-
attach (hotcorner_title, 0, 0, 3);
122-
attach (icon, 1, 1, 1, 3);
123-
attach (topleft, 0, 1, 1, 1);
124-
attach (topright, 2, 1, 1, 1);
125-
attach (bottomleft, 0, 3, 1, 1);
126-
attach (bottomright, 2, 3, 1, 1);
127-
attach (custom_command_revealer, 0, 4, 2, 1);
128-
attach (workspaces_label, 0, 5);
129-
attach (checkbutton_grid, 1, 5, 2);
130-
attach (animations_label, 0, 9);
131-
attach (animations_switch, 1, 9);
65+
var grid = new Gtk.Grid () {
66+
column_spacing = 12,
67+
row_spacing = 6,
68+
halign = Gtk.Align.CENTER,
69+
margin_start = 12,
70+
margin_end = 12,
71+
margin_bottom = 12
72+
};
73+
grid.attach (hotcorner_title, 0, 0, 2);
74+
grid.attach (topleft, 0, 1, 2);
75+
grid.attach (topright, 0, 2, 2);
76+
grid.attach (bottomleft, 0, 3, 2);
77+
grid.attach (bottomright, 0, 4, 2);
78+
grid.attach (workspaces_label, 0, 6);
79+
grid.attach (checkbutton_grid, 1, 6);
80+
grid.attach (animations_label, 0, 7);
81+
grid.attach (animations_switch, 1, 7);
82+
83+
var scrolled = new Gtk.ScrolledWindow (null, null) {
84+
hscrollbar_policy = Gtk.PolicyType.NEVER
85+
};
86+
scrolled.add (grid);
87+
88+
add (scrolled);
13289

13390
var animations_settings = new GLib.Settings (ANIMATIONS_SCHEMA);
13491
animations_settings.bind (ANIMATIONS_KEY, animations_switch, "active", SettingsBindFlags.DEFAULT);
13592

136-
behavior_settings.bind ("hotcorner-custom-command", custom_command, "text", GLib.SettingsBindFlags.DEFAULT);
93+
behavior_settings = new GLib.Settings ("org.pantheon.desktop.gala.behavior");
13794
behavior_settings.bind ("move-fullscreened-workspace", fullscreen_checkbutton, "active", GLib.SettingsBindFlags.DEFAULT);
13895
behavior_settings.bind ("move-maximized-workspace", maximize_checkbutton, "active", GLib.SettingsBindFlags.DEFAULT);
13996
}
14097

141-
private void hotcorner_changed (string settings_key, Gtk.ComboBoxText combo) {
142-
behavior_settings.set_enum (settings_key, int.parse (combo.active_id));
143-
if (combo.active_id == CUSTOM_COMMAND_ID) {
144-
keys_using_custom_command.add (settings_key);
145-
} else {
146-
keys_using_custom_command.remove (settings_key);
98+
private class HotcornerControl : Gtk.Grid {
99+
public string label { get; construct; }
100+
public string position { get; construct; }
101+
102+
private Gtk.Entry command_entry;
103+
private static Settings settings;
104+
private static Gtk.SizeGroup size_group;
105+
106+
public HotcornerControl (string label, string position) {
107+
Object (
108+
label: label,
109+
position: position
110+
);
147111
}
148112

149-
custom_command_revealer.reveal_child = keys_using_custom_command.size > 0;
150-
}
113+
static construct {
114+
settings = new Settings ("org.pantheon.desktop.gala.behavior");
115+
size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.BOTH);
116+
}
117+
118+
construct {
119+
var label = new Gtk.Label (label) {
120+
max_width_chars = 12,
121+
wrap = true,
122+
wrap_mode = Pango.WrapMode.WORD_CHAR
123+
};
124+
125+
unowned var label_style_context = label.get_style_context ();
126+
label_style_context.add_class (Granite.STYLE_CLASS_CARD);
127+
label_style_context.add_class (Granite.STYLE_CLASS_ROUNDED);
128+
label_style_context.add_class ("hotcorner");
129+
label_style_context.add_class (position);
130+
131+
var combo = new Gtk.ComboBoxText () {
132+
hexpand = true,
133+
valign = Gtk.Align.END
134+
};
135+
combo.append ("none", _("Do nothing"));
136+
combo.append ("show-workspace-view", _("Multitasking View"));
137+
combo.append ("maximize-current", _("Maximize current window"));
138+
combo.append ("open-launcher", _("Show Applications Menu"));
139+
combo.append ("window-overview-all", _("Show all windows"));
140+
combo.append ("switch-to-workspace-last", _("Switch to new workspace"));
141+
combo.append ("custom-command", _("Execute custom command"));
142+
143+
command_entry = new Gtk.Entry () {
144+
primary_icon_name = "utilities-terminal-symbolic",
145+
};
146+
147+
var command_revealer = new Gtk.Revealer () {
148+
margin_top = 6,
149+
transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN
150+
};
151+
command_revealer.add (command_entry);
152+
153+
margin_bottom = 12;
154+
column_spacing = 12;
155+
attach (label, 0, 0, 1, 2);
156+
attach (combo, 1, 0);
157+
attach (command_revealer, 1, 1);
158+
159+
size_group.add_widget (label);
160+
161+
settings.bind ("hotcorner-" + position, combo, "active-id", SettingsBindFlags.DEFAULT);
162+
163+
settings.bind_with_mapping (
164+
"hotcorner-" + position, command_revealer, "reveal-child", SettingsBindFlags.GET,
165+
(value, variant, user_data) => {
166+
value.set_boolean (variant.get_string () == "custom-command");
167+
return true;
168+
},
169+
(value, expected_type, user_data) => {
170+
return new Variant.string ("custom-command");
171+
},
172+
null, null
173+
);
174+
175+
get_command_string ();
176+
177+
settings.changed["hotcorner-custom-command"].connect (() => {
178+
get_command_string ();
179+
});
180+
181+
command_entry.changed.connect (() => {
182+
var this_command = "hotcorner-%s:%s".printf (position, command_entry.text);
183+
184+
var setting_string = settings.get_string ("hotcorner-custom-command");
185+
186+
var found = false;
187+
string[] commands = setting_string.split (";;");
188+
for (int i = 0; i < commands.length ; i++) {
189+
if (commands[i].has_prefix ("hotcorner-" + position)) {
190+
found = true;
191+
commands[i] = this_command;
192+
}
193+
}
194+
195+
if (!found) {
196+
commands += this_command;
197+
}
198+
199+
settings.set_string ("hotcorner-custom-command", string.joinv (";;", commands));
200+
});
201+
}
151202

152-
private Gtk.ComboBoxText create_hotcorner () {
153-
var box = new Gtk.ComboBoxText ();
154-
box.append ("0", _("Do nothing")); // none
155-
box.append ("1", _("Multitasking View")); // show-workspace-view
156-
box.append ("2", _("Maximize current window")); // maximize-current
157-
box.append ("4", _("Show Applications Menu")); // open-launcher
158-
box.append ("7", _("Show all windows")); // window-overview-all
159-
box.append ("8", _("Switch to new workspace")); // switch-new-workspace
160-
box.append (CUSTOM_COMMAND_ID, _("Execute custom command")); // custom-command
161-
162-
return box;
203+
private void get_command_string () {
204+
var setting_string = settings.get_string ("hotcorner-custom-command");
205+
var this_command = "";
206+
207+
string[] commands = setting_string.split (";;");
208+
foreach (unowned string command in commands) {
209+
if (command.has_prefix ("hotcorner-" + position)) {
210+
this_command = command.replace ("hotcorner-%s:".printf (position), "");
211+
}
212+
}
213+
214+
command_entry.text = this_command;
215+
}
163216
}
164217
}

0 commit comments

Comments
 (0)