Skip to content

Commit 9381b33

Browse files
danirabbitstsdc
andauthored
Shortcuts: gtk4 prep (#436)
* Search: focus tree view on activate * CPUProcessTreeView: handle collapse/expand with event controller * MainWindow: use search.handle_event --------- Co-authored-by: Stanisław <[email protected]>
1 parent 24d047d commit 9381b33

File tree

5 files changed

+17
-49
lines changed

5 files changed

+17
-49
lines changed

src/MainWindow.vala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
*/
55

66
public class Monitor.MainWindow : Hdy.ApplicationWindow {
7-
// application reference
8-
private Shortcuts shortcuts;
9-
107
private Resources resources;
118

129
// Widgets
@@ -123,8 +120,7 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow {
123120
this.show_all ();
124121
});
125122

126-
shortcuts = new Shortcuts (this);
127-
key_press_event.connect ((e) => shortcuts.handle (e));
123+
key_press_event.connect (search.handle_event);
128124

129125
this.delete_event.connect (() => {
130126
int window_width, window_height;

src/Services/Shortcuts.vala

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ public class Monitor.CPUProcessTreeView : Gtk.TreeView {
9494
action_group.add_action (kill_process_action);
9595

9696
insert_action_group ("process", action_group);
97+
98+
var key_controller = new Gtk.EventControllerKey (this);
99+
key_controller.key_released.connect ((keyval, keycode, state) => {
100+
switch (keyval) {
101+
case Gdk.Key.Left:
102+
collapse ();
103+
break;
104+
case Gdk.Key.Right:
105+
expanded ();
106+
break;
107+
}
108+
});
97109
}
98110
public void icon_cell_layout (Gtk.CellLayout cell_layout, Gtk.CellRenderer icon_cell, Gtk.TreeModel model, Gtk.TreeIter iter) {
99111
Value icon_name;

src/Widgets/Headerbar/Search.vala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public class Monitor.Search : Gtk.SearchEntry {
4343
this.insert_at_cursor ("");
4444
}
4545
});
46+
47+
activate.connect (() => {
48+
window.process_view.process_tree_view.focus_on_first_row ();
49+
});
4650
}
4751

4852
private bool filter_func (Gtk.TreeModel model, Gtk.TreeIter iter) {

src/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ source_app_files = [
4545
'Managers/ProcessUtils.vala',
4646

4747
# Services
48-
'Services/Shortcuts.vala',
4948
'Services/DBusServer.vala',
5049
'Services/Appearance.vala',
5150

0 commit comments

Comments
 (0)