Skip to content

Commit

Permalink
it compiles!
Browse files Browse the repository at this point in the history
  • Loading branch information
stsdc committed Nov 10, 2023
1 parent a396210 commit cd61899
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 61 deletions.
43 changes: 25 additions & 18 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
public class Monitor.MainWindow : Adw.ApplicationWindow {
public class Monitor.MainWindow : Gtk.ApplicationWindow {
// application reference
private Shortcuts shortcuts;

private Resources resources;

// Widgets
public Headerbar headerbar;
// public HeaderbarContent headerbar_content;

// public ProcessView process_view;
// public SystemView system_view;
public ContainerView container_view;
private Gtk.Stack stack;

private Statusbar statusbar;
// private Statusbar statusbar;

public DBusServer dbusserver;


// Constructs a main window
public MainWindow (MonitorApp app) {
Adw.init ();
// Adw.init ();
this.set_application (app);

setup_window_state ();
Expand Down Expand Up @@ -48,31 +48,38 @@ public class Monitor.MainWindow : Adw.ApplicationWindow {
stack_switcher.valign = Gtk.Align.CENTER;
stack_switcher.set_stack (stack);

headerbar = new Headerbar (this);
headerbar.set_title_widget (stack_switcher);
headerbar.preferences_grid.attach (new PreferencesView (), 0, 0, 1, 1);
var headerbar = new Gtk.HeaderBar () {
title_widget = stack_switcher,
hexpand = true
};

// headerbar.search_revealer.set_reveal_child (stack.visible_child_name == "process_view");
// stack.notify["visible-child-name"].connect (() => {
// headerbar.search_revealer.set_reveal_child (stack.visible_child_name == "process_view");
// });

// headerbar_content = new HeaderbarContent (this);
// headerbar.set_title_widget (stack_switcher);
// headerbar.preferences_grid.attach (new PreferencesView (), 0, 0, 1, 1);
// sv.show_all ();

statusbar = new Statusbar ();
// statusbar = new Statusbar ();

var grid = new Gtk.Grid () {
orientation = Gtk.Orientation.VERTICAL
};

grid.attach (headerbar, 0, 0, 1, 1);
grid.attach (stack, 0, 1, 1, 1);
grid.attach (statusbar, 0, 2, 1, 1);
// grid.attach (statusbar, 0, 2, 1, 1);

set_content (grid);
// set_content (grid);
set_child (grid);

present ();

dbusserver = DBusServer.get_default ();

headerbar.search_revealer.set_reveal_child (stack.visible_child_name == "process_view");
stack.notify["visible-child-name"].connect (() => {
headerbar.search_revealer.set_reveal_child (stack.visible_child_name == "process_view");
});

new Thread<void> ("upd", () => {
Timeout.add_seconds (MonitorApp.settings.get_int ("update-time"), () => {
Expand All @@ -86,7 +93,7 @@ public class Monitor.MainWindow : Adw.ApplicationWindow {
// system_view.update ();
dbusserver.indicator_state (MonitorApp.settings.get_boolean ("indicator-state"));
var res = resources.serialize ();
statusbar.update (res);
// statusbar.update (res);
dbusserver.update (res);
return false;
});
Expand All @@ -104,7 +111,7 @@ public class Monitor.MainWindow : Adw.ApplicationWindow {
});

shortcuts = new Shortcuts (this);
key_press_event.connect ((e) => shortcuts.handle (e));
// key_press_event.connect ((e) => shortcuts.handle (e));

app.window_removed.connect (() => {
int position_x, position_y;
Expand All @@ -113,8 +120,8 @@ public class Monitor.MainWindow : Adw.ApplicationWindow {
// get_position (out position_x, out position_y);
MonitorApp.settings.set_int ("window-width", window_width);
MonitorApp.settings.set_int ("window-height", window_height);
MonitorApp.settings.set_int ("position-x", position_x);
MonitorApp.settings.set_int ("position-y", position_y);
// MonitorApp.settings.set_int ("position-x", position_x);
// MonitorApp.settings.set_int ("position-y", position_y);
// MonitorApp.settings.set_boolean ("is-maximized", this.is_maximized);

MonitorApp.settings.set_string ("opened-view", stack.visible_child_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public class Monitor.ContainerInfoCharts : Gtk.Grid {
ram_chart.height_request = 60;

var cpu_graph_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
cpu_graph_box.add (cpu_chart);
cpu_graph_box.append (cpu_chart);

var mem_graph_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
mem_graph_box.add (ram_chart);
mem_graph_box.append (ram_chart);

cpu_label = new Gtk.Label ("CPU: " + Utils.NO_DATA);
cpu_label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Monitor.ContainerInfoHeader : Gtk.Grid {
regex = /(?i:^.*\.(xpm|png)$)/; // vala-lint=space-before-paren,
/* *INDENT-ON* */

icon = new Gtk.Image.from_icon_name ("application-x-executable", Gtk.IconSize.DIALOG);
icon = new Gtk.Image.from_icon_name ("application-x-executable");
icon.set_pixel_size (64);
icon.valign = Gtk.Align.END;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ public class Monitor.ContainerInfoView : Gtk.Grid {
private Gtk.Label ram_label;

construct {
this.expand = false;
// this.expand = false;
this.width_request = 200;

column_spacing = 6;
row_spacing = 6;
vexpand = false;
margin = 12;
margin_start = 12;
margin_end = 12;
margin_top = 12;
margin_bottom = 12;
column_homogeneous = true;
row_homogeneous = false;

Expand Down
8 changes: 4 additions & 4 deletions src/Views/ContainerView/ContainerView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ public class Monitor.ContainerView : Gtk.Box {

public ContainerView () {

var container_tree_view_scrolled = new Gtk.ScrolledWindow (null, null);
container_tree_view_scrolled.add (container_treeview);
var container_tree_view_scrolled = new Gtk.ScrolledWindow ();
container_tree_view_scrolled.set_child (container_treeview);

var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);
paned.pack1 (container_tree_view_scrolled, true, false);
paned.set_start_child (container_tree_view_scrolled);
// paned.pack2 (container_info_view, true, false);
paned.set_position (paned.max_position);


add (paned);
append (paned);
}

private void set_container_container_info_view (DockerContainer container) {
Expand Down
16 changes: 10 additions & 6 deletions src/Views/PreferencesView/PreferencesGeneralPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public PreferencesGeneralPage () {

var icon = new Gtk.Image.from_icon_name ("preferences-system", Gtk.IconSize.DND);
var icon = new Gtk.Image.from_icon_name ("preferences-system");

Object (
display_widget: icon,
Expand Down Expand Up @@ -66,10 +66,14 @@
hexpand = true
};

var content_area = new Gtk.Grid ();
content_area.column_spacing = 12;
content_area.row_spacing = 12;
content_area.margin = 12;
var content_area = new Gtk.Grid () {
column_spacing = 12,
row_spacing = 12,
margin_start = 12,
margin_end = 12,
margin_top = 12,
margin_bottom = 12,
};
content_area.attach (background_label, 0, 1, 1, 1);
content_area.attach (background_switch, 1, 1, 1, 1);
content_area.attach (enable_smooth_lines_label, 0, 2, 1, 1);
Expand All @@ -79,7 +83,7 @@
content_area.attach (enable_containers_view_label, 0, 5, 1, 1);
content_area.attach (enable_containers_view_switch, 1, 5, 1, 1);

add (content_area);
append (content_area);

background_switch.notify["active"].connect (() => {
MonitorApp.settings.set_boolean ("background-state", background_switch.state);
Expand Down
11 changes: 7 additions & 4 deletions src/Views/PreferencesView/PreferencesView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: LGPL-3.0-or-later
*/

public class Monitor.PreferencesView : Gtk.Paned {
public class Monitor.PreferencesView : Gtk.Box {
private PreferencesGeneralPage general_page = new PreferencesGeneralPage ();
private PreferencesIndicatorPage indicator_page = new PreferencesIndicatorPage ();

Expand All @@ -12,9 +12,11 @@
general_page.background_switch.notify["active"].connect (() => set_background_switch_state ());
indicator_page.status_switch.notify["active"].connect (() => set_background_switch_state ());

var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);

height_request = 300;
width_request = 500;
set_position (135);
paned.set_position (135);

var stack = new Gtk.Stack ();
stack.add_named (indicator_page, "indicator_page");
Expand All @@ -24,8 +26,9 @@
width_request = 135
};

pack1 (settings_sidebar, true, false);
pack2 (stack, true, false);
paned.set_start_child (settings_sidebar);
paned.set_end_child (stack);
append (paned);
}

private void set_background_switch_state () {
Expand Down
4 changes: 2 additions & 2 deletions src/Views/SystemView/SystemNetworkView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ public class Monitor.SystemNetworkView : Gtk.Grid {
private Chart network_chart;
private Network network;

private LabelH4 network_name_label;
private Gtk.Label network_name_label;
private LabelRoundy network_upload_label;
private LabelRoundy network_download_label;

Expand All @@ -18,7 +18,7 @@ public class Monitor.SystemNetworkView : Gtk.Grid {
public SystemNetworkView (Network _network) {
network = _network;

network_name_label = new LabelH4 (_("Network"));
network_name_label = new Gtk.Label (_("Network"));

network_download_label = new LabelRoundy (_("DOWN"));
network_download_label.val.set_width_chars (7);
Expand Down
4 changes: 2 additions & 2 deletions src/Views/SystemView/SystemStorageView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ public class Monitor.SystemStorageView : Gtk.Grid {
private Chart storage_chart;
private Storage storage;

private LabelH4 storage_name_label;
private Gtk.Label storage_name_label;
private LabelRoundy storage_read_label;
private LabelRoundy storage_write_label;

Expand All @@ -20,7 +20,7 @@ public class Monitor.SystemStorageView : Gtk.Grid {
public SystemStorageView (Storage _storage) {
storage = _storage;

storage_name_label = new LabelH4 (_("Storage"));
storage_name_label = new Gtk.Label (_("Storage"));

storage_write_label = new LabelRoundy (_("WRITE"));
storage_write_label.val.set_width_chars (7);
Expand Down
6 changes: 3 additions & 3 deletions src/Widgets/Chart/Chart.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Monitor.Chart : Gtk.Box {
};

live_chart = new LiveChart.Chart (config);
live_chart.expand = true;
// live_chart.expand = true;
live_chart.legend.visible = false;
live_chart.grid.visible = true;
live_chart.background.visible = false;
Expand Down Expand Up @@ -60,7 +60,7 @@ public class Monitor.Chart : Gtk.Box {

live_chart.add_serie (serie);
}
add (live_chart);
append (live_chart);
return this;
}

Expand All @@ -73,7 +73,7 @@ public class Monitor.Chart : Gtk.Box {
serie.line.color = colors.get_color_by_index (i);
live_chart.add_serie (serie);
}
add (live_chart);
append (live_chart);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class Monitor.Headerbar : Gtk.HeaderBar {
public class Monitor.HeaderbarContent {
private MainWindow window;

public Search search;
Expand All @@ -14,7 +14,7 @@ public class Monitor.Headerbar : Gtk.HeaderBar {
// title_widget = new Gtk.Label(_("Monitor"));
}

public Headerbar (MainWindow window) {
public HeaderbarContent (MainWindow window) {
this.window = window;

var preferences_button = new Gtk.MenuButton ();
Expand Down
14 changes: 7 additions & 7 deletions src/Widgets/Headerbar/Search.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ public class Monitor.Search : Gtk.SearchEntry {
private void connect_signal () {
this.search_changed.connect (() => {
// collapse tree only when search is focused and changed
if (this.is_focus) {
process_tree_view.collapse_all ();
}
// if (this.is_focus) {
// process_tree_view.collapse_all ();
// }

filter_model.refilter ();

// focus on child row to avoid the app crashes by clicking "Kill/End Process" buttons in headerbar
process_tree_view.focus_on_child_row ();
this.grab_focus ();

if (this.text != "") {
this.insert_at_cursor ("");
}
// if (this.text != "") {
// this.insert_at_cursor ("");
// }
});
}

Expand Down Expand Up @@ -87,7 +87,7 @@ public class Monitor.Search : Gtk.SearchEntry {
public void activate_entry (string search_text = "") {
this.text = "";
this.search_changed ();
this.insert_at_cursor (search_text);
// this.insert_at_cursor (search_text);
}

}
2 changes: 1 addition & 1 deletion src/Widgets/WidgetResource/WidgetResource.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public class Monitor.WidgetResource : Gtk.Box {
private LabelH4 _title = new LabelH4 (Utils.NO_DATA);
private Gtk.Label _title = new Gtk.Label (Utils.NO_DATA);

public string title {
set {
Expand Down
14 changes: 7 additions & 7 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ source_app_files = [
'Utils.vala',

# Views
'Views/ProcessView/ProcessView.vala',
'Views/ProcessView/ProcessInfoView/ProcessInfoView.vala',
# 'Views/ProcessView/ProcessView.vala',
# 'Views/ProcessView/ProcessInfoView/ProcessInfoView.vala',
'Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala',

'Views/PreferencesView/PreferencesView.vala',
Expand All @@ -27,19 +27,19 @@ source_app_files = [
'Views/ContainerView/ContainerInfoView/ContainerInfoCharts.vala',

# Widgets related only to ProcessInfoView
'Views/ProcessView/ProcessInfoView/Preventor.vala',
# 'Views/ProcessView/ProcessInfoView/Preventor.vala',
'Views/ProcessView/ProcessInfoView/ProcessInfoHeader.vala',
'Views/ProcessView/ProcessInfoView/ProcessInfoCPURAM.vala',
'Views/ProcessView/ProcessInfoView/ProcessInfoIOStats.vala',
'Views/ProcessView/ProcessInfoView/OpenFilesTreeView.vala',

# Widgets
'Widgets/Headerbar/Headerbar.vala',
'Widgets/Headerbar/Search.vala',
'Widgets/Statusbar/Statusbar.vala',
# 'Widgets/Headerbar/HeaderbarContent.vala',
# 'Widgets/Headerbar/Search.vala',
# 'Widgets/Statusbar/Statusbar.vala',
'Widgets/Labels/LabelVertical.vala',
'Widgets/Labels/LabelRoundy.vala',
'Widgets/Labels/LabelH4.vala',
# 'Widgets/Labels/LabelH4.vala',
'Widgets/Chart/Chart.vala',
'Widgets/WidgetResource/WidgetResource.vala',

Expand Down

0 comments on commit cd61899

Please sign in to comment.