diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 156adc92..c81e959d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,16 +20,14 @@ jobs: steps: - uses: actions/checkout@v4 - with: - submodules: true - name: Install Dependencies run: | apt update - apt install -y libgala-dev libgee-0.8-dev libglib2.0-dev libgranite-dev libgtk-3-dev libhandy-1-dev \ - libdbus-glib-1-dev libwnck-3-dev libgtop2-dev libwingpanel-3.0-dev libudisks2-dev \ + apt install -y libgala-dev libgee-0.8-dev libglib2.0-dev libgranite-dev libgtk-4-dev libadwaita-1-dev \ + libdbus-glib-1-dev libgtop2-dev libwingpanel-3.0-dev libudisks2-dev \ libxnvctrl0 libxnvctrl-dev libcurl4-gnutls-dev libflatpak-dev libjson-glib-dev \ - liblivechart-1-dev libpci-dev \ + liblivechart-2-dev libpci-dev \ meson valac sassc git - name: Build run: | diff --git a/meson.build b/meson.build index 8636cf10..5edc51a0 100644 --- a/meson.build +++ b/meson.build @@ -22,25 +22,23 @@ add_project_arguments(['-DWNCK_I_KNOW_THIS_IS_UNSTABLE', '-w'], language: 'c') # elementary_stylesheet = subproject('stylesheet') app_dependencies = [ - dependency('granite', version: '>= 5.2.0'), + dependency('granite-7'), dependency('glib-2.0'), - dependency('gtk+-3.0'), + dependency('gtk4'), dependency('gee-0.8'), dependency('gio-2.0'), dependency('gobject-2.0'), dependency('libgtop-2.0'), - dependency('libwnck-3.0'), - dependency('libhandy-1', version: '>=0.90.0'), - dependency('gdk-x11-3.0'), - dependency('x11'), + # dependency('libwnck-3.0'), + dependency('libadwaita-1', version: '>=1.0.0'), + dependency('gtk4-x11'), dependency('udisks2'), dependency('json-glib-1.0'), dependency('flatpak'), - # FIXME Bump required version to >= 1.10.0 when GTK 4 porting dependency( - 'livechart', - version: '< 1.10.0', + 'livechart-2', + version: '>= 1.10.0', fallback: ['live-chart', 'livechart_dep'], ), diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 8b0c00f5..45ced765 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -3,7 +3,8 @@ * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) */ -public class Monitor.MainWindow : Hdy.ApplicationWindow { + +public class Monitor.MainWindow : Gtk.ApplicationWindow { public Search search { get; private set; } public ProcessView process_view { get; private set; } @@ -32,15 +33,14 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow { valign = CENTER }; - var sv = new PreferencesView (); - sv.show_all (); + var preferences_view = new PreferencesView (); - var preferences_popover = new Gtk.Popover (null) { - child = sv + var preferences_popover = new Gtk.Popover () { + child = preferences_view }; var preferences_button = new Gtk.MenuButton () { - image = new Gtk.Image.from_icon_name ("open-menu", Gtk.IconSize.LARGE_TOOLBAR), + icon_name = "open-menu", popover = preferences_popover, tooltip_text = (_("Settings")) }; @@ -54,25 +54,20 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow { transition_type = SLIDE_LEFT }; - var headerbar = new Hdy.HeaderBar () { - has_subtitle = false, - show_close_button = true, - title = _("Monitor") - }; + var headerbar = new Adw.HeaderBar (); headerbar.pack_start (search_revealer); - headerbar.set_custom_title (stack_switcher); + headerbar.set_title_widget (stack_switcher); headerbar.pack_end (preferences_button); var statusbar = new Statusbar (); - var box = new Gtk.Box (VERTICAL, 0); - box.add (headerbar); - box.add (stack); - box.add (statusbar); + var main_container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - child = box; + set_titlebar (headerbar); + main_container.append (stack); + main_container.append (statusbar); - show_all (); + child = main_container; var dbusserver = DBusServer.get_default (); @@ -100,31 +95,26 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow { dbusserver.quit.connect (() => application.quit ()); dbusserver.show.connect (() => { - this.deiconify (); - this.present (); setup_window_state (); - this.show_all (); + present (); }); - key_press_event.connect (search.handle_event); - this.delete_event.connect (() => { - int window_width, window_height; - get_size (out window_width, out window_height); - MonitorApp.settings.set_int ("window-width", window_width); - MonitorApp.settings.set_int ("window-height", window_height); - MonitorApp.settings.set_boolean ("is-maximized", this.is_maximized); + application.window_removed.connect (() => { + MonitorApp.settings.set_int ("window-width", get_size (Gtk.Orientation.HORIZONTAL)); + MonitorApp.settings.set_int ("window-height", get_size (Gtk.Orientation.VERTICAL)); + + MonitorApp.settings.set_boolean ("is-maximized", this.is_maximized ()); MonitorApp.settings.set_string ("opened-view", stack.visible_child_name); if (MonitorApp.settings.get_boolean ("indicator-state")) { - this.hide_on_delete (); + // Read: https://discourse.gnome.org/t/how-to-hide-widget-instead-removing-them-in-gtk-4/8176 + this.hide (); } else { dbusserver.indicator_state (false); application.quit (); } - - return true; }); dbusserver.indicator_state (MonitorApp.settings.get_boolean ("indicator-state")); diff --git a/src/Managers/Process.vala b/src/Managers/Process.vala index 91f74f9d..0b5a845e 100644 --- a/src/Managers/Process.vala +++ b/src/Managers/Process.vala @@ -324,8 +324,9 @@ public class Monitor.Process : GLib.Object { // also if it is using X Window Server if (Gdk.Display.get_default () is Gdk.X11.Display) { - Wnck.ResourceUsage resu = Wnck.ResourceUsage.pid_read (Gdk.Display.get_default (), stat.pid); - mem_usage += (resu.total_bytes_estimate / 1024); + // @TODO figure this out for wayland and X11 in gtk4 + // Wnck.ResourceUsage resu = Wnck.ResourceUsage.pid_read (Gdk.Display.get_default (), stat.pid); + // mem_usage += (resu.total_bytes_estimate / 1024); } var total_installed_memory = (double) mem.total / 1024; diff --git a/src/Models/OpenFilesTreeViewModel.vala b/src/Models/OpenFilesTreeViewModel.vala index c2b5b910..bfecf40f 100644 --- a/src/Models/OpenFilesTreeViewModel.vala +++ b/src/Models/OpenFilesTreeViewModel.vala @@ -4,7 +4,7 @@ */ public class Monitor.OpenFilesTreeViewModel : Gtk.TreeStore { - private Gee.Map open_files_paths = new Gee.HashMap (); + private Gee.Map open_files_paths = new Gee.HashMap (); private Process _process; @@ -41,32 +41,27 @@ public class Monitor.OpenFilesTreeViewModel : Gtk.TreeStore { Gtk.TreeIter iter; append (out iter, null); - set (iter, - Column.NAME, path, - -1); + set (iter, Column.NAME, path, -1); - // open_files_paths.set (path, iter); + open_files_paths.set (path, iter); return true; } return false; } public void update_model (Process process) { - if (process.open_files_paths.size > 0) { - foreach (var path in process.open_files_paths) { + // if (process.open_files_paths.size > 0) { + // foreach (var path in process.open_files_paths) { - // print("sdsd"); - // Gtk.TreeIter iter = open_files_paths[path]; - print (path); - //// display only real paths - //// probably should be done in process class - // if (path.substring (0, 1) == "/") { - // set (iter, - // Column.NAME, path, - // -1); - // } - } - } + // Gtk.TreeIter iter = open_files_paths[path]; + // print (path); + //// display only real paths + //// probably should be done in process class + // if (path.substring (0, 1) == "/") { + // set (iter, Column.NAME, path, -1); + // } + // } + // } } } diff --git a/src/Monitor.vala b/src/Monitor.vala index dc80381c..064f0220 100644 --- a/src/Monitor.vala +++ b/src/Monitor.vala @@ -34,7 +34,8 @@ namespace Monitor { public override void startup () { base.startup (); - Hdy.init (); + Granite.init (); + Adw.init (); Appearance.set_prefered_style (); @@ -58,7 +59,6 @@ namespace Monitor { public override void activate () { // only have one window if (get_windows () != null) { - window.show_all (); window.present (); return; } @@ -89,7 +89,7 @@ namespace Monitor { window.hide (); MonitorApp.settings.set_boolean ("background-state", true); } else { - window.show_all (); + window.present (); } window.process_view.process_tree_view.focus_on_first_row (); @@ -108,6 +108,13 @@ namespace Monitor { PCIUtils.LIBPCI_PATCH_VER ); + print ( + "Gtk %d.%d.%d\n", + Gtk.MAJOR_VERSION, + Gtk.MINOR_VERSION, + Gtk.MICRO_VERSION + ); + // add command line options try { var opt_context = new OptionContext (""); diff --git a/src/Services/Appearance.vala b/src/Services/Appearance.vala index 36e8276f..1089a3a5 100644 --- a/src/Services/Appearance.vala +++ b/src/Services/Appearance.vala @@ -20,7 +20,7 @@ public class Monitor.Appearance : Object { provider.load_from_resource ("/io/elementary/monitor/monitor-light.css"); } - Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); // We listen to changes in Granite.Settings and update our app if the user changes their preference granite_settings.notify["prefers-color-scheme"].connect (() => { diff --git a/src/Views/PreferencesView.vala b/src/Views/PreferencesView.vala index 32891397..45474b71 100644 --- a/src/Views/PreferencesView.vala +++ b/src/Views/PreferencesView.vala @@ -3,7 +3,7 @@ * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) */ -public class Monitor.PreferencesView : Gtk.Bin { +public class Monitor.PreferencesView : Granite.Bin { private Gtk.Adjustment update_freq_adjustment; construct { @@ -23,8 +23,8 @@ public class Monitor.PreferencesView : Gtk.Bin { halign = START, margin_bottom = 6 }; - update_freq_description.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); - update_freq_description.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL); + update_freq_description.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); + update_freq_description.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL); update_freq_scale.add_mark (1.0, BOTTOM, _("1s")); update_freq_scale.add_mark (2.0, BOTTOM, _("2s")); @@ -38,9 +38,9 @@ public class Monitor.PreferencesView : Gtk.Bin { margin_top = 12, margin_bottom = 12 }; - update_freq_box.add (update_freq_label); - update_freq_box.add (update_freq_description); - update_freq_box.add (update_freq_scale); + update_freq_box.append (update_freq_label); + update_freq_box.append (update_freq_description); + update_freq_box.append (update_freq_scale); update_freq_adjustment.value_changed.connect (() => { MonitorApp.settings.set_int ("update-time", (int) update_freq_adjustment.get_value ()); @@ -112,18 +112,18 @@ public class Monitor.PreferencesView : Gtk.Bin { margin_bottom = 6, margin_start = 12 }; - indicator_options_box.add (cpu_check); - indicator_options_box.add (cpu_freq_check); - indicator_options_box.add (cpu_temp_check); - indicator_options_box.add (new Gtk.Separator (HORIZONTAL)); - indicator_options_box.add (memory_check); - indicator_options_box.add (new Gtk.Separator (HORIZONTAL)); - indicator_options_box.add (gpu_check); - indicator_options_box.add (gpu_memory_check); - indicator_options_box.add (gpu_temp_check); - indicator_options_box.add (new Gtk.Separator (HORIZONTAL)); - indicator_options_box.add (network_upload_check); - indicator_options_box.add (network_download_check); + indicator_options_box.append (cpu_check); + indicator_options_box.append (cpu_freq_check); + indicator_options_box.append (cpu_temp_check); + indicator_options_box.append (new Gtk.Separator (HORIZONTAL)); + indicator_options_box.append (memory_check); + indicator_options_box.append (new Gtk.Separator (HORIZONTAL)); + indicator_options_box.append (gpu_check); + indicator_options_box.append (gpu_memory_check); + indicator_options_box.append (gpu_temp_check); + indicator_options_box.append (new Gtk.Separator (HORIZONTAL)); + indicator_options_box.append (network_upload_check); + indicator_options_box.append (network_download_check); var indicator_options_revealer = new Gtk.Revealer () { child = indicator_options_box @@ -132,11 +132,11 @@ public class Monitor.PreferencesView : Gtk.Bin { var box = new Gtk.Box (VERTICAL, 0) { margin_bottom = 6 }; - box.add (update_freq_box); - box.add (enable_smooth_lines_switch); - box.add (background_switch); - box.add (indicator_switch); - box.add (indicator_options_revealer); + box.append (update_freq_box); + box.append (enable_smooth_lines_switch); + box.append (background_switch); + box.append (indicator_switch); + box.append (indicator_options_revealer); child = box; diff --git a/src/Views/ProcessView/ProcessInfoView/OpenFilesTreeView.vala b/src/Views/ProcessView/ProcessInfoView/OpenFilesTreeView.vala index 372e9ad8..70992c9e 100644 --- a/src/Views/ProcessView/ProcessInfoView/OpenFilesTreeView.vala +++ b/src/Views/ProcessView/ProcessInfoView/OpenFilesTreeView.vala @@ -6,15 +6,11 @@ public class Monitor.OpenFilesTreeView : Gtk.TreeView { public new OpenFilesTreeViewModel model; private Gtk.TreeViewColumn path_column; - private Regex ? regex; public signal void process_selected (Process process); - public OpenFilesTreeView (OpenFilesTreeViewModel model) { - this.model = model; - /* *INDENT-OFF* */ - regex = /(?i:^.*\.(xpm|png)$)/; // vala-lint=space-before-paren, - /* *INDENT-ON* */ + public OpenFilesTreeView () { + this.model = new OpenFilesTreeViewModel (); show_expanders = false; diff --git a/src/Views/ProcessView/ProcessInfoView/ProcessInfoCPURAM.vala b/src/Views/ProcessView/ProcessInfoView/ProcessInfoCPURAM.vala index d1fd6000..d4a375b6 100644 --- a/src/Views/ProcessView/ProcessInfoView/ProcessInfoCPURAM.vala +++ b/src/Views/ProcessView/ProcessInfoView/ProcessInfoCPURAM.vala @@ -26,17 +26,17 @@ public class Monitor.ProcessInfoCPURAM : 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); + cpu_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL); cpu_label.halign = Gtk.Align.START; ram_label = new Gtk.Label ("RAM: " + Utils.NO_DATA); - ram_label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL); + ram_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL); ram_label.halign = Gtk.Align.START; attach (cpu_label, 0, 0, 1, 1); diff --git a/src/Views/ProcessView/ProcessInfoView/ProcessInfoHeader.vala b/src/Views/ProcessView/ProcessInfoView/ProcessInfoHeader.vala index 7d966b4a..c206be21 100644 --- a/src/Views/ProcessView/ProcessInfoView/ProcessInfoHeader.vala +++ b/src/Views/ProcessView/ProcessInfoView/ProcessInfoHeader.vala @@ -19,7 +19,7 @@ public class Monitor.ProcessInfoHeader : Gtk.Grid { construct { column_spacing = 12; - icon = new Gtk.Image.from_icon_name ("application-x-executable", Gtk.IconSize.DIALOG) { + icon = new Gtk.Image.from_icon_name ("application-x-executable") { pixel_size = 64 }; @@ -27,7 +27,7 @@ public class Monitor.ProcessInfoHeader : Gtk.Grid { halign = START, valign = END }; - state.get_style_context ().add_class ("state_badge"); + state.add_css_class ("state_badge"); var icon_container = new Gtk.Overlay () { child = icon @@ -40,7 +40,7 @@ public class Monitor.ProcessInfoHeader : Gtk.Grid { valign = START, tooltip_text = _("N/A") }; - application_name.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + application_name.add_css_class (Granite.STYLE_CLASS_H2_LABEL); pid = new LabelRoundy (_("PID")); nice = new LabelRoundy (_("NI")); @@ -53,11 +53,11 @@ public class Monitor.ProcessInfoHeader : Gtk.Grid { username = new LabelRoundy (""); var wrapper = new Gtk.Box (HORIZONTAL, 0); - wrapper.add (pid); - wrapper.add (priority); - wrapper.add (nice); - wrapper.add (num_threads); - wrapper.add (username); + wrapper.append (pid); + wrapper.append (priority); + wrapper.append (nice); + wrapper.append (num_threads); + wrapper.append (username); attach (icon_container, 0, 0, 1, 2); attach (application_name, 1, 0, 3, 1); @@ -72,17 +72,17 @@ public class Monitor.ProcessInfoHeader : Gtk.Grid { priority.set_text (process.stat.priority.to_string ()); if (process.uid == 0) { - username.val.get_style_context ().add_class ("username-root"); - username.val.get_style_context ().remove_class ("username-other"); - username.val.get_style_context ().remove_class ("username-current"); + username.val.add_css_class ("username-root"); + username.val.remove_css_class ("username-other"); + username.val.remove_css_class ("username-current"); } else if (process.uid == (int) Posix.getuid ()) { - username.val.get_style_context ().add_class ("username-current"); - username.val.get_style_context ().remove_class ("username-other"); - username.val.get_style_context ().remove_class ("username-root"); + username.val.add_css_class ("username-current"); + username.val.remove_css_class ("username-other"); + username.val.remove_css_class ("username-root"); } else { - username.val.get_style_context ().add_class ("username-other"); - username.val.get_style_context ().remove_class ("username-root"); - username.val.get_style_context ().remove_class ("username-current"); + username.val.add_css_class ("username-other"); + username.val.remove_css_class ("username-root"); + username.val.remove_css_class ("username-current"); } username.set_text (process.username); diff --git a/src/Views/ProcessView/ProcessInfoView/ProcessInfoIOStats.vala b/src/Views/ProcessView/ProcessInfoView/ProcessInfoIOStats.vala index 6281ca53..ecb8ab86 100644 --- a/src/Views/ProcessView/ProcessInfoView/ProcessInfoIOStats.vala +++ b/src/Views/ProcessView/ProcessInfoView/ProcessInfoIOStats.vala @@ -21,26 +21,26 @@ public class Monitor.ProcessInfoIOStats : Gtk.Grid { row_homogeneous = false; var opened_files_label = create_label (_("Opened files")); - opened_files_label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL); + opened_files_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL); opened_files_label.margin_top = 24; var characters_label = create_label (_("Characters")); - characters_label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL); + characters_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL); rchar_label = create_label (_("N/A")); wchar_label = create_label (_("N/A")); var system_calls_label = create_label (_("System calls")); - system_calls_label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL); + system_calls_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL); syscr_label = create_label (_("N/A")); syscw_label = create_label (_("N/A")); var io_label = create_label (_("Read/Written")); - io_label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL); + io_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL); write_bytes_label = create_label (_("N/A")); read_bytes_label = create_label (_("N/A")); var cancelled_write_label = create_label (_("Cancelled write")); - cancelled_write_label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL); + cancelled_write_label.add_css_class (Granite.STYLE_CLASS_H4_LABEL); cancelled_write_bytes_label = create_label (Utils.NO_DATA); @@ -51,12 +51,12 @@ public class Monitor.ProcessInfoIOStats : Gtk.Grid { attach (cancelled_write_label, 1, 1, 1, 1); attach (cancelled_write_bytes_label, 1, 2, 1, 1); - // attach (opened_files_label, 0, 3, 3, 1); + attach (opened_files_label, 0, 3, 3, 1); - var model = new OpenFilesTreeViewModel (); - var open_files_tree_view_scrolled = new Gtk.ScrolledWindow (null, null); - open_files_tree_view = new OpenFilesTreeView (model); - open_files_tree_view_scrolled.add (open_files_tree_view); + open_files_tree_view = new OpenFilesTreeView (); + var open_files_tree_view_scrolled = new Gtk.ScrolledWindow () { + child = open_files_tree_view + }; attach (open_files_tree_view_scrolled, 0, 4, 3, 1); } diff --git a/src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala b/src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala index 8fa6f81f..d719a754 100644 --- a/src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala +++ b/src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala @@ -21,7 +21,6 @@ public class Monitor.ProcessInfoView : Gtk.Box { process_info_header.update (_process); - this.show_all (); if (_process.uid != Posix.getuid ()) { process_info_cpu_ram.hide (); process_info_io_stats.hide (); @@ -34,15 +33,21 @@ public class Monitor.ProcessInfoView : Gtk.Box { process_info_cpu_ram.clear_graphs (); process_info_cpu_ram.set_charts_data (_process); + // Setting visibility + process_info_cpu_ram.visible = true; + process_action_bar.visible = true; + process_info_io_stats.visible = true; + permission_error_infobar.revealed = false; process_info_io_stats.open_files_tree_view.model.process = _process; - process_info_io_stats.open_files_tree_view.show_all (); + process_info_io_stats.open_files_tree_view.visible = true; } } } public string ? icon_name; + // How to replace: https://docs.gtk.org/gtk4/class.InfoBar.html private Gtk.InfoBar permission_error_infobar; private Gtk.Label permission_error_label; @@ -56,26 +61,33 @@ public class Monitor.ProcessInfoView : Gtk.Box { orientation = Gtk.Orientation.VERTICAL; hexpand = true; - permission_error_infobar = new Gtk.InfoBar (); - permission_error_infobar.message_type = Gtk.MessageType.ERROR; - permission_error_infobar.revealed = false; + permission_error_infobar = new Gtk.InfoBar () { + message_type = Gtk.MessageType.ERROR, + revealed = false, + }; permission_error_label = new Gtk.Label (Utils.NO_DATA); - permission_error_infobar.get_content_area ().add (permission_error_label); - add (permission_error_infobar); + permission_error_infobar.add_child (permission_error_label); + append (permission_error_infobar); var grid = new Gtk.Grid () { - margin = 12, + margin_top = 12, + margin_bottom = 12, + margin_start = 12, + margin_end = 12, hexpand = true, column_spacing = 12 }; - add (grid); + append (grid); process_info_header = new ProcessInfoHeader (); grid.attach (process_info_header, 0, 0, 1, 1); var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) { - margin = 12, + margin_top = 12, + margin_bottom = 12, + margin_start = 12, + margin_end = 12, hexpand = true }; grid.attach (separator, 0, 1, 1, 1); @@ -93,7 +105,7 @@ public class Monitor.ProcessInfoView : Gtk.Box { kill_process_button = new Gtk.Button.with_label (_("Force Quit…")) { tooltip_markup = Granite.markup_accel_tooltip ({ "K" }) }; - kill_process_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); + kill_process_button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); process_action_bar = new Gtk.Box (HORIZONTAL, 12) { halign = END, @@ -101,8 +113,8 @@ public class Monitor.ProcessInfoView : Gtk.Box { homogeneous = true, margin_top = 12 }; - process_action_bar.add (end_process_button); - process_action_bar.add (kill_process_button); + process_action_bar.append (end_process_button); + process_action_bar.append (kill_process_button); kill_process_button.clicked.connect (() => { var confirmation_dialog = new Granite.MessageDialog ( @@ -110,18 +122,18 @@ public class Monitor.ProcessInfoView : Gtk.Box { _("This may lead to data loss. Only Force Quit if Shut Down has failed."), new ThemedIcon ("computer-fail"), Gtk.ButtonsType.CANCEL - ) { + ) { badge_icon = new ThemedIcon ("process-stop"), modal = true, - transient_for = (Gtk.Window) get_toplevel () + transient_for = (Gtk.Window) get_root () }; var accept_button = confirmation_dialog.add_button (_("Force Quit"), Gtk.ResponseType.ACCEPT); - accept_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); + accept_button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); confirmation_dialog.response.connect ((response) => { if (response == Gtk.ResponseType.ACCEPT) { - // TODO: maybe add a toast that process killed + // @TODO: maybe add a toast that process killed process.kill (); } @@ -137,14 +149,14 @@ public class Monitor.ProcessInfoView : Gtk.Box { _("The process will be asked to initiate shutdown tasks and close. In some cases the process may not quit."), new ThemedIcon ("system-shutdown"), Gtk.ButtonsType.CANCEL - ) { + ) { badge_icon = new ThemedIcon ("dialog-question"), modal = true, - transient_for = (Gtk.Window) get_toplevel () + transient_for = (Gtk.Window) get_root () }; var accept_button = confirmation_dialog.add_button (_("Shut Down"), Gtk.ResponseType.ACCEPT); - accept_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + accept_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); confirmation_dialog.response.connect ((response) => { if (response == Gtk.ResponseType.ACCEPT) { @@ -159,15 +171,10 @@ public class Monitor.ProcessInfoView : Gtk.Box { }); grid.attach (process_action_bar, 0, 5); - - show_all (); - process_info_cpu_ram.hide (); - process_info_io_stats.hide (); - process_action_bar.hide (); } private void show_permission_error_infobar (string error) { - if (permission_error_infobar.revealed == false) { + if (!permission_error_infobar.revealed) { permission_error_label.set_text (error); permission_error_infobar.revealed = true; } @@ -180,7 +187,8 @@ public class Monitor.ProcessInfoView : Gtk.Box { process_info_io_stats.update (process); process_info_io_stats.open_files_tree_view.model.process = _process; - process_info_io_stats.open_files_tree_view.show_all (); + + process_info_io_stats.open_files_tree_view.visible = true; } } diff --git a/src/Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala b/src/Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala index 4d6d12f3..e49c1476 100644 --- a/src/Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala +++ b/src/Views/ProcessView/ProcessTreeView/CPUProcessTreeView.vala @@ -9,15 +9,13 @@ public class Monitor.CPUProcessTreeView : Gtk.TreeView { private Gtk.TreeViewColumn pid_column; private Gtk.TreeViewColumn cpu_column; private Gtk.TreeViewColumn memory_column; - private Regex ? regex; public signal void process_selected (Process process); public CPUProcessTreeView (TreeViewModel model) { this.model = model; - /* *INDENT-OFF* */ - regex = /(?i:^.*\.(xpm|png)$)/; // vala-lint=space-before-paren, - /* *INDENT-ON* */ + + enable_search = false; // setup name column name_column = new Gtk.TreeViewColumn (); @@ -95,7 +93,8 @@ public class Monitor.CPUProcessTreeView : Gtk.TreeView { insert_action_group ("process", action_group); - var key_controller = new Gtk.EventControllerKey (this); + var key_controller = new Gtk.EventControllerKey (); + add_controller (key_controller); key_controller.key_released.connect ((keyval, keycode, state) => { switch (keyval) { case Gdk.Key.Left: @@ -112,16 +111,7 @@ public class Monitor.CPUProcessTreeView : Gtk.TreeView { model.get_value (iter, Column.ICON, out icon_name); string path = ((string) icon_name); - if (regex.match (path)) { - try { - Gdk.Pixbuf icon = new Gdk.Pixbuf.from_file_at_size (path, 16, -1); - ((Gtk.CellRendererPixbuf)icon_cell).pixbuf = icon; - } catch (Error e) { - warning (e.message); - } - } else { - ((Gtk.CellRendererPixbuf)icon_cell).icon_name = path; - } + ((Gtk.CellRendererPixbuf)icon_cell).icon_name = path; } public void cpu_usage_cell_layout (Gtk.CellLayout cell_layout, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { @@ -232,7 +222,7 @@ public class Monitor.CPUProcessTreeView : Gtk.TreeView { tree_model.get (iter, Column.PID, out pid); Process process = model.process_manager.get_process (pid); process_selected (process); - // debug ("cursor changed"); + debug ("cursor changed"); } } diff --git a/src/Views/ProcessView/ProcessView.vala b/src/Views/ProcessView/ProcessView.vala index 450992e7..e8281f66 100644 --- a/src/Views/ProcessView/ProcessView.vala +++ b/src/Views/ProcessView/ProcessView.vala @@ -10,10 +10,13 @@ public class Monitor.ProcessView : Gtk.Box { public ProcessInfoView process_info_view; construct { - process_info_view = new ProcessInfoView (); - - // hide on startup - process_info_view.no_show_all = true; + process_info_view = new ProcessInfoView () { + // This might be useless since first process is selected + // automatically and this triggers on_process_selected (). + // Keeping it just to not forget what was the OG behavior + // in GTK3 version. + visible = false, + }; } public ProcessView () { @@ -23,23 +26,25 @@ public class Monitor.ProcessView : Gtk.Box { process_tree_view.process_selected.connect ((process) => on_process_selected (process)); // making tree view scrollable - var process_tree_view_scrolled = new Gtk.ScrolledWindow (null, null); - process_tree_view_scrolled.add (process_tree_view); + var process_tree_view_scrolled = new Gtk.ScrolledWindow () { + child = process_tree_view + }; var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL); - paned.pack1 (process_tree_view_scrolled, true, false); - paned.pack2 (process_info_view, false, false); - // paned.set_min_position (200); - paned.set_position (paned.max_position); + paned.set_start_child (process_tree_view_scrolled); + paned.set_end_child (process_info_view); + paned.set_shrink_end_child (false); + paned.set_resize_end_child (false); + paned.set_position (paned.max_position - 200); paned.set_hexpand (true); - add (paned); + append (paned); } public void on_process_selected (Process process) { process_info_view.process = process; - process_info_view.no_show_all = false; - // process_info_view.show_all (); + + process_info_view.visible = true; } public void update () { diff --git a/src/Views/SystemView/SystemCPUInfoPopover.vala b/src/Views/SystemView/SystemCPUInfoPopover.vala index 418f9a59..a6ba8bc4 100755 --- a/src/Views/SystemView/SystemCPUInfoPopover.vala +++ b/src/Views/SystemView/SystemCPUInfoPopover.vala @@ -7,7 +7,10 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { private CPU cpu; construct { - margin = 12; + margin_top = 12; + margin_bottom = 12; + margin_start = 12; + margin_end = 12; orientation = Gtk.Orientation.VERTICAL; } @@ -33,8 +36,8 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { }; stack_switcher.set_stack (stack); - add (stack_switcher); - add (stack); + append (stack_switcher); + append (stack); } private Gtk.Label label (string text) { @@ -42,7 +45,10 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { halign = Gtk.Align.START, valign = Gtk.Align.CENTER, wrap = true, - margin = 6, + margin_top = 6, + margin_bottom = 6, + margin_start = 6, + margin_end = 6, }; return label; @@ -53,31 +59,31 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { activate_on_single_click = false }; - listbox.add (label (_("Model:") + " " + cpu.model)); - listbox.add (label (_("Family:") + " " + cpu.family)); - listbox.add (label (_("Microcode ver.:") + " " + cpu.microcode)); - listbox.add (label (_("Bogomips:") + " " + cpu.bogomips)); + listbox.append (label (_("Model:") + " " + cpu.model)); + listbox.append (label (_("Family:") + " " + cpu.family)); + listbox.append (label (_("Microcode ver.:") + " " + cpu.microcode)); + listbox.append (label (_("Bogomips:") + " " + cpu.bogomips)); if (cpu.core_list[0].caches.has_key ("L1Instruction")) { var value = cpu.cache_multipliers["L1Instruction"].to_string () + "×" + cpu.core_list[0].caches["L1Instruction"].size; - listbox.add (label (_("L1 Instruction cache: ") + value)); + listbox.append (label (_("L1 Instruction cache: ") + value)); } if (cpu.core_list[0].caches.has_key ("L1Data")) { var value = cpu.cache_multipliers["L1Data"].to_string () + "×" + cpu.core_list[0].caches["L1Data"].size; - listbox.add (label (_("L1 Data cache: ") + value)); + listbox.append (label (_("L1 Data cache: ") + value)); } if (cpu.core_list[0].caches.has_key ("L1")) { var value = cpu.cache_multipliers["L1"].to_string () + "×" + cpu.core_list[0].caches["L1"].size; - listbox.add (label (_("L1 cache: ") + value)); + listbox.append (label (_("L1 cache: ") + value)); } if (cpu.core_list[0].caches.has_key ("L2")) { - listbox.add (label (_("L2 Cache size: ") + cpu.cache_multipliers["L2"].to_string () + "×" + cpu.core_list[0].caches["L2"].size)); + listbox.append (label (_("L2 Cache size: ") + cpu.cache_multipliers["L2"].to_string () + "×" + cpu.core_list[0].caches["L2"].size)); } if (cpu.core_list[0].caches.has_key ("L3")) { - listbox.add (label (_("L3 Cache size: ") + cpu.cache_multipliers["L3"].to_string () + "×" + cpu.core_list[0].caches["L3"].size)); + listbox.append (label (_("L3 Cache size: ") + cpu.cache_multipliers["L3"].to_string () + "×" + cpu.core_list[0].caches["L3"].size)); } - listbox.add (label (_("Address sizes: ") + cpu.address_sizes)); + listbox.append (label (_("Address sizes: ") + cpu.address_sizes)); return listbox; } @@ -88,11 +94,12 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { }; foreach (var feature in cpu.features) { - listbox.add (create_row (feature.key, feature.value)); + listbox.append (create_row (feature.key, feature.value)); } - var scrolled_window = new Gtk.ScrolledWindow (null, null); - scrolled_window.add (listbox); + var scrolled_window = new Gtk.ScrolledWindow () { + child = listbox + }; return scrolled_window; } @@ -103,11 +110,12 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { }; foreach (var bug in cpu.bugs) { - listbox.add (create_row (bug.key, bug.value)); + listbox.append (create_row (bug.key, bug.value)); } - var scrolled_window = new Gtk.ScrolledWindow (null, null); - scrolled_window.add (listbox); + var scrolled_window = new Gtk.ScrolledWindow () { + child = listbox + }; return scrolled_window; } @@ -122,14 +130,17 @@ public class Monitor.SystemCPUInfoPopover : Gtk.Box { halign = Gtk.Align.START, valign = Gtk.Align.CENTER, wrap = true, - margin = 6, + margin_top = 6, + margin_bottom = 6, + margin_start = 6, + margin_end = 6, }; - flag_label.get_style_context ().add_class ("flags_badge"); + flag_label.add_css_class ("flags_badge"); grid.attach (flag_label, 0, 0, 1, 1); grid.attach (label (flag_description), 1, 0, 1, 1); - row.add (grid); + row.child = grid; return row; } diff --git a/src/Views/SystemView/SystemCPUView.vala b/src/Views/SystemView/SystemCPUView.vala index 6c9df8db..1647d3f6 100644 --- a/src/Views/SystemView/SystemCPUView.vala +++ b/src/Views/SystemView/SystemCPUView.vala @@ -14,18 +14,25 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { private Gtk.Grid grid_temperature_info = new Gtk.Grid (); - private Gee.ArrayList core_label_list; + private Gee.ArrayList core_label_list; construct { core_label_list = new Gee.ArrayList (); - cpu_frequency_label = new LabelRoundy (_("Frequency")); - cpu_frequency_label.margin = 6; - cpu_frequency_label.margin_top = 2; + cpu_frequency_label = new LabelRoundy (_("Frequency")) { + margin_top = 2, + margin_end = 6, + margin_bottom = 6, + margin_start = 6 + }; + + cpu_temperature_label = new LabelRoundy (_("Temperature")) { + margin_top = 2, + margin_end = 6, + margin_bottom = 6, + margin_start = 6 + }; - cpu_temperature_label = new LabelRoundy (_("Temperature")); - cpu_temperature_label.margin = 6; - cpu_temperature_label.margin_top = 2; cpu_frequency_chart = new Chart (1); cpu_frequency_chart.set_serie_color (0, Utils.Colors.get_rgba_color (Utils.Colors.LIME_500)); @@ -38,16 +45,16 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { grid_temperature_info.attach (cpu_temperature_label, 0, 0, 1, 1); + var smol_charts_container = new Gtk.Grid () { + width_request = 200, + hexpand = false, + halign = Gtk.Align.START, + row_spacing = 6, + margin_start = 6, + }; - - var smol_charts_container = new Gtk.Grid (); - smol_charts_container.width_request = 200; - smol_charts_container.hexpand = false; - smol_charts_container.halign = Gtk.Align.START; smol_charts_container.attach (grid_frequency_info, 0, 0, 1, 1); smol_charts_container.attach (grid_temperature_info, 0, 1, 1, 1); - smol_charts_container.row_spacing = 6; - smol_charts_container.margin_start = 6; add_charts_container (smol_charts_container); } @@ -75,12 +82,12 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { public void update () { cpu_frequency_chart.update (0, cpu.frequency); - // int temperature_index = 0; - // foreach (var temperature in cpu.paths_temperatures.values) { - // debug (temperature.input); - // cpu_temperature_chart.update (temperature_index, int.parse (temperature.input) / 1000); - // temperature_index++; - // }] + // int temperature_index = 0; + // foreach (var temperature in cpu.paths_temperatures.values) { + // debug (temperature.input); + // cpu_temperature_chart.update (temperature_index, int.parse (temperature.input) / 1000); + // temperature_index++; + // }] cpu_temperature_chart.update (0, cpu.temperature_mean); cpu_temperature_label.set_text (("%.2f %s").printf (cpu.temperature_mean, _("℃"))); @@ -105,26 +112,26 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { string percentage_formatted = ("% 3d%%").printf ((int) core_percentage); core_label_list[i].set_text (percentage_formatted); - core_label_list[i].get_style_context ().remove_class ("core_badge-mild-warning"); - core_label_list[i].get_style_context ().remove_class ("core_badge-strong-warning"); - core_label_list[i].get_style_context ().remove_class ("core_badge-critical-warning"); + core_label_list[i].remove_css_class ("core_badge-mild-warning"); + core_label_list[i].remove_css_class ("core_badge-strong-warning"); + core_label_list[i].remove_css_class ("core_badge-critical-warning"); if (core_percentage > 75.0) { - core_label_list[i].get_style_context ().add_class ("core_badge-mild-warning"); - core_label_list[i].get_style_context ().remove_class ("core_badge-strong-warning"); - core_label_list[i].get_style_context ().remove_class ("core_badge-critical-warning"); + core_label_list[i].add_css_class ("core_badge-mild-warning"); + core_label_list[i].remove_css_class ("core_badge-strong-warning"); + core_label_list[i].remove_css_class ("core_badge-critical-warning"); } if (core_percentage > 85.0) { - core_label_list[i].get_style_context ().add_class ("core_badge-strong-warning"); - core_label_list[i].get_style_context ().remove_class ("core_badge-mild-warning"); - core_label_list[i].get_style_context ().remove_class ("core_badge-critical-warning"); + core_label_list[i].add_css_class ("core_badge-strong-warning"); + core_label_list[i].remove_css_class ("core_badge-mild-warning"); + core_label_list[i].remove_css_class ("core_badge-critical-warning"); } if (core_percentage > 90.0) { - core_label_list[i].get_style_context ().add_class ("core_badge-critical-warning"); - core_label_list[i].get_style_context ().remove_class ("core_badge-mild-warning"); - core_label_list[i].get_style_context ().remove_class ("core_badge-strong-warning"); + core_label_list[i].add_css_class ("core_badge-critical-warning"); + core_label_list[i].remove_css_class ("core_badge-mild-warning"); + core_label_list[i].remove_css_class ("core_badge-strong-warning"); } } label_vertical_main_metric = ("%d%%").printf (cpu.percentage); @@ -135,7 +142,10 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { Gtk.Grid grid = new Gtk.Grid () { column_spacing = 8, row_spacing = 4, - margin = 6 + margin_top = 6, + margin_bottom = 6, + margin_start = 6, + margin_end = 6, }; int column = 0; @@ -143,7 +153,7 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { for (int i = 0; i < cpu.core_list.size; i++) { var core_label = new Gtk.Label (Utils.NO_DATA); core_label.set_width_chars (4); - core_label.get_style_context ().add_class ("core_badge"); + core_label.add_css_class ("core_badge"); // core_label.set_text (Utils.NO_DATA); core_label_list.add (core_label); @@ -156,9 +166,10 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { } } var threads_label = new Gtk.Label (_("THREADS")); - threads_label.get_style_context ().add_class ("small-text"); + threads_label.add_css_class ("small-text"); grid.attach (threads_label, 0, -1, column, 1); return grid; } + } diff --git a/src/Views/SystemView/SystemGPUView.vala b/src/Views/SystemView/SystemGPUView.vala index 2891145b..a9092c9b 100644 --- a/src/Views/SystemView/SystemGPUView.vala +++ b/src/Views/SystemView/SystemGPUView.vala @@ -14,13 +14,18 @@ public class Monitor.SystemGPUView : Monitor.WidgetResource { construct { - gpu_vram_percentage_label = new LabelRoundy (_("VRAM")); - gpu_vram_percentage_label.margin = 6; - gpu_vram_percentage_label.margin_top = 2; - - gpu_temperature_label = new LabelRoundy (_("TEMPERATURE")); - gpu_temperature_label.margin = 6; - gpu_temperature_label.margin_top = 2; + gpu_vram_percentage_label = new LabelRoundy (_("VRAM")) { + margin_top = 2, + margin_bottom = 6, + margin_start = 6, + margin_end = 6 + }; + gpu_temperature_label = new LabelRoundy (_("TEMPERATURE")) { + margin_top = 2, + margin_bottom = 6, + margin_start = 6, + margin_end = 6 + }; gpu_vram_percentage_chart = new Chart (1); gpu_vram_percentage_chart.set_serie_color (0, Utils.Colors.get_rgba_color (Utils.Colors.LIME_500)); @@ -68,7 +73,10 @@ public class Monitor.SystemGPUView : Monitor.WidgetResource { Gtk.Grid grid = new Gtk.Grid () { column_spacing = 8, row_spacing = 4, - margin = 6 + margin_top = 6, + margin_bottom = 6, + margin_start = 6, + margin_end = 6 }; return grid; diff --git a/src/Views/SystemView/SystemMemoryView.vala b/src/Views/SystemView/SystemMemoryView.vala index 30ac693f..dc7d1cda 100644 --- a/src/Views/SystemView/SystemMemoryView.vala +++ b/src/Views/SystemView/SystemMemoryView.vala @@ -41,7 +41,10 @@ public class Monitor.SystemMemoryView : Monitor.WidgetResource { Gtk.Grid grid = new Gtk.Grid () { column_spacing = 8, row_spacing = 4, - margin = 6 + margin_top = 6, + margin_bottom = 6, + margin_start = 6, + margin_end = 6, }; grid.attach (memory_used_label, 0, 0, 1, 1); diff --git a/src/Views/SystemView/SystemNetworkView.vala b/src/Views/SystemView/SystemNetworkView.vala index 010821d4..b41d1f10 100644 --- a/src/Views/SystemView/SystemNetworkView.vala +++ b/src/Views/SystemView/SystemNetworkView.vala @@ -12,7 +12,10 @@ public class Monitor.SystemNetworkView : Gtk.Grid { private LabelRoundy network_download_label; construct { - margin = 12; + margin_top = 12; + margin_bottom = 12; + margin_start = 12; + margin_end = 12; column_spacing = 12; set_vexpand (false); } @@ -33,18 +36,21 @@ public class Monitor.SystemNetworkView : Gtk.Grid { network_chart = new Chart (2); network_chart.config.y_axis.fixed_max = null; - network_chart.set_serie_color (0, { 155 / 255.0, 219 / 255.0, 77 / 255.0, 1.0 }); - network_chart.set_serie_color (1, { 100 / 255.0, 186 / 255.0, 255 / 255.0, 1.0 }); + network_chart.set_serie_color (0, { 155 / 255.0f, 219 / 255.0f, 77 / 255.0f, 1.0f }); + network_chart.set_serie_color (1, { 100 / 255.0f, 186 / 255.0f, 255 / 255.0f, 1.0f }); - var labels_grid = new Gtk.Grid (); - labels_grid.row_spacing = 6; - labels_grid.column_spacing = 6; - labels_grid.margin = 6; - labels_grid.attach (network_download_label, 0, 0, 1, 1); - labels_grid.attach (network_upload_label, 1, 0, 1, 1); + var labels_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { + margin_top = 6, + margin_end = 6, + margin_bottom = 6, + margin_start = 6 + }; + + labels_box.append (network_download_label); + labels_box.append (network_upload_label); attach (network_name_label, 0, 0, 1, 1); - attach (labels_grid, 0, 1, 2, 2); + attach (labels_box, 0, 1, 2, 2); attach (network_chart, 0, 1, 2, 2); } diff --git a/src/Views/SystemView/SystemStorageView.vala b/src/Views/SystemView/SystemStorageView.vala index bb679b3a..7c404cad 100644 --- a/src/Views/SystemView/SystemStorageView.vala +++ b/src/Views/SystemView/SystemStorageView.vala @@ -27,8 +27,8 @@ public class Monitor.SystemStorageView : Gtk.Box { storage_chart = new Chart (2); storage_chart.config.y_axis.fixed_max = null; - storage_chart.set_serie_color (0, { 155 / 255.0, 219 / 255.0, 77 / 255.0, 1.0 }); - storage_chart.set_serie_color (1, { 100 / 255.0, 186 / 255.0, 255 / 255.0, 1.0 }); + storage_chart.set_serie_color (0, { 155 / 255.0f, 219 / 255.0f, 77 / 255.0f, 1.0f }); + storage_chart.set_serie_color (1, { 100 / 255.0f, 186 / 255.0f, 255 / 255.0f, 1.0f }); var labels_box = new Gtk.Box (HORIZONTAL, 6) { margin_top = 6, @@ -36,8 +36,8 @@ public class Monitor.SystemStorageView : Gtk.Box { margin_bottom = 6, margin_start = 6 }; - labels_box.add (storage_write_label); - labels_box.add (storage_read_label); + labels_box.append (storage_write_label); + labels_box.append (storage_read_label); var chart_overlay = new Gtk.Overlay () { child = storage_chart @@ -55,12 +55,12 @@ public class Monitor.SystemStorageView : Gtk.Box { margin_start = 12; orientation = VERTICAL; - add (storage_name_label); - add (drive_cards_container); - add (chart_overlay); + append (storage_name_label); + append (drive_cards_container); + append (chart_overlay); storage.get_drives ().foreach ((drive) => { - drive_cards_container.add ( + drive_cards_container.append ( new DriveCard (drive) ); @@ -90,7 +90,7 @@ public class Monitor.SystemStorageView : Gtk.Box { var drive_name_label = new Gtk.Label (drive.model) { halign = START }; - drive_name_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL); + drive_name_label.add_css_class (Granite.STYLE_CLASS_H3_LABEL); string size_string = format_size ((uint64) drive.size, IEC_UNITS); string used_string = format_size ((uint64) (drive.size - drive.free), IEC_UNITS); @@ -105,19 +105,19 @@ public class Monitor.SystemStorageView : Gtk.Box { halign = START, margin_bottom = 6 }; - drive_block_name_and_size_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + drive_block_name_and_size_label.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); var drive_not_mounted_label = new Gtk.Label (_("Not mounted")) { halign = START }; - drive_not_mounted_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + drive_not_mounted_label.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); var usagebar = new Gtk.LevelBar () { max_value = 100.0, min_value = 0.0, margin_bottom = 6 }; - usagebar.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + usagebar.add_css_class (Granite.STYLE_CLASS_FLAT); usagebar.set_value (100.0 * (drive.size - drive.free) / drive.size); var drive_box = new Gtk.Box (VERTICAL, 0) { @@ -126,17 +126,17 @@ public class Monitor.SystemStorageView : Gtk.Box { margin_bottom = 6, margin_start = 12 }; - drive_box.add (drive_name_label); - drive_box.add (drive_block_name_and_size_label); + drive_box.append (drive_name_label); + drive_box.append (drive_block_name_and_size_label); if (drive.free == 0) { - drive_box.add (drive_not_mounted_label); + drive_box.append (drive_not_mounted_label); } else { - drive_box.add (usagebar); + drive_box.append (usagebar); } - get_style_context ().add_class (Granite.STYLE_CLASS_CARD); - get_style_context ().add_class (Granite.STYLE_CLASS_ROUNDED); - add (drive_box); + add_css_class (Granite.STYLE_CLASS_CARD); + add_css_class (Granite.STYLE_CLASS_ROUNDED); + append (drive_box); } } } diff --git a/src/Views/SystemView/SystemView.vala b/src/Views/SystemView/SystemView.vala index ab320b64..e2af50b6 100644 --- a/src/Views/SystemView/SystemView.vala +++ b/src/Views/SystemView/SystemView.vala @@ -25,28 +25,31 @@ public class Monitor.SystemView : Gtk.Box { network_view = new SystemNetworkView (resources.network); storage_view = new SystemStorageView (resources.storage); - var scrolled_window = new Gtk.ScrolledWindow (null, null); - var wrapper = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - wrapper.expand = true; - scrolled_window.add (wrapper); + var wrapper = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { + hexpand = true, + vexpand = true + }; + var scrolled_window = new Gtk.ScrolledWindow () { + child = wrapper + }; - wrapper.add (cpu_view); - wrapper.add (memory_view); - wrapper.add (network_view); - wrapper.add (storage_view); + wrapper.append (cpu_view); + wrapper.append (memory_view); + wrapper.append (network_view); + wrapper.append (storage_view); foreach (IGPU gpu in resources.gpu_list) { if (gpu is GPUIntel || gpu is GPUNvidia) { - wrapper.add (build_no_support_label (gpu.name)); + wrapper.append (build_no_support_label (gpu.name)); } else { var gpu_view = new SystemGPUView (gpu); gpu_views.append (gpu_view); - wrapper.add (gpu_view); + wrapper.append (gpu_view); } } - add (scrolled_window); + append (scrolled_window); } public void update () { @@ -60,8 +63,10 @@ public class Monitor.SystemView : Gtk.Box { private Granite.HeaderLabel build_no_support_label (string gpu_name) { string notification_text = _("The %s GPU was detected, but is not yet supported.").printf (gpu_name); return new Granite.HeaderLabel (notification_text) { - margin = 12, + margin_top = 12, + margin_end = 12, + margin_bottom = 12, + margin_start = 12 }; } - } diff --git a/src/Widgets/Chart/Chart.vala b/src/Widgets/Chart/Chart.vala index 7133f44c..04604967 100644 --- a/src/Widgets/Chart/Chart.vala +++ b/src/Widgets/Chart/Chart.vala @@ -11,7 +11,7 @@ public class Monitor.Chart : Gtk.Box { construct { - get_style_context ().add_class ("graph"); + add_css_class ("graph"); vexpand = true; height_request = 120; @@ -31,8 +31,10 @@ public class Monitor.Chart : Gtk.Box { left = -1 }; - live_chart = new LiveChart.Chart (config); - live_chart.expand = true; + live_chart = new LiveChart.Chart (config) { + hexpand = true, + vexpand = true, + }; live_chart.legend.visible = false; live_chart.grid.visible = true; live_chart.background.visible = false; @@ -65,7 +67,7 @@ public class Monitor.Chart : Gtk.Box { live_chart.add_serie (serie); } - add (live_chart); + append (live_chart); return this; } @@ -78,7 +80,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; } diff --git a/src/Widgets/Headerbar/Search.vala b/src/Widgets/Headerbar/Search.vala index b6b3316c..20cbac63 100644 --- a/src/Widgets/Headerbar/Search.vala +++ b/src/Widgets/Headerbar/Search.vala @@ -3,19 +3,28 @@ * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) */ -public class Monitor.Search : Gtk.SearchEntry { +public class Monitor.Search : Gtk.Box { public MainWindow window { get; construct; } private Gtk.TreeModelFilter filter_model; private CPUProcessTreeView process_tree_view; + private Gtk.SearchEntry search_entry; public Search (MainWindow window) { Object (window: window); } construct { + search_entry = new Gtk.SearchEntry () { + // Commented because there is no need to ctrl-f when you can just type? + // tooltip_markup = Granite.markup_accel_tooltip ({ "F" }, _("Type process name or PID to search")), + placeholder_text = _("Search Process") + }; + + append (search_entry); + search_entry.set_key_capture_widget (window); + + this.process_tree_view = window.process_view.process_tree_view; - this.placeholder_text = _("Search Process"); - this.tooltip_markup = Granite.markup_accel_tooltip ({ "F" }, _("Type process name or PID to search")); filter_model = new Gtk.TreeModelFilter (window.process_view.treeview_model, null); connect_signal (); @@ -27,9 +36,9 @@ public class Monitor.Search : Gtk.SearchEntry { } private void connect_signal () { - this.search_changed.connect (() => { + search_entry.search_changed.connect (() => { // collapse tree only when search is focused and changed - if (this.is_focus) { + if (search_entry.is_focus ()) { process_tree_view.collapse_all (); } @@ -38,13 +47,9 @@ public class Monitor.Search : Gtk.SearchEntry { // 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 (""); - } }); - activate.connect (() => { + search_entry.activate.connect (() => { window.process_view.process_tree_view.focus_on_first_row (); }); } @@ -54,7 +59,7 @@ public class Monitor.Search : Gtk.SearchEntry { int pid_haystack; string cmd_haystack; bool found = false; - var needle = this.text; + var needle = search_entry.text; // should help with assertion errors, donno // if (needle == null) return true; @@ -94,9 +99,8 @@ public class Monitor.Search : Gtk.SearchEntry { // reset filter, grab focus and insert the character public void activate_entry (string search_text = "") { - this.text = ""; - this.search_changed (); - this.insert_at_cursor (search_text); + search_entry.text = ""; + search_entry.search_changed (); } } diff --git a/src/Widgets/Labels/LabelRoundy.vala b/src/Widgets/Labels/LabelRoundy.vala index 220ef42b..a285b535 100644 --- a/src/Widgets/Labels/LabelRoundy.vala +++ b/src/Widgets/Labels/LabelRoundy.vala @@ -11,17 +11,17 @@ public class Monitor.LabelRoundy : Gtk.Fixed { val = new Gtk.Label (Utils.NO_DATA) { selectable = true }; - val.get_style_context ().add_class ("roundy-label"); + val.add_css_class ("roundy-label"); desc = new Gtk.Label (description.up ()); - desc.get_style_context ().add_class ("small-text"); + desc.add_css_class ("small-text"); put (val, 0, 12); put (desc, 6, 0); } public void set_color (string colorname) { - val.get_style_context ().add_class (colorname); + val.add_css_class (colorname); } public void set_text (string text) { diff --git a/src/Widgets/Labels/LabelVertical.vala b/src/Widgets/Labels/LabelVertical.vala index 7441ecc3..ab830d45 100644 --- a/src/Widgets/Labels/LabelVertical.vala +++ b/src/Widgets/Labels/LabelVertical.vala @@ -3,7 +3,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -public class Monitor.LabelVertical : Gtk.EventBox { +public class Monitor.LabelVertical : Gtk.Box { private Gtk.Grid grid; public signal void clicked (); @@ -16,27 +16,20 @@ public class Monitor.LabelVertical : Gtk.EventBox { margin_start = 12; margin_top = 6; - get_style_context ().add_class ("label-vertical"); + add_css_class ("label-vertical"); } public LabelVertical (string description) { val = new Gtk.Label (Utils.NO_DATA); - val.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + val.add_css_class (Granite.STYLE_CLASS_H2_LABEL); desc = new Gtk.Label (description.up ()); - desc.get_style_context ().add_class ("small-text"); + desc.add_css_class ("small-text"); grid.attach (desc, 0, 0, 1, 1); grid.attach (val, 0, 1, 1, 1); - add (grid); - - events |= Gdk.EventMask.BUTTON_RELEASE_MASK; - - button_release_event.connect ((event) => { - clicked (); - return false; - }); + append (grid); } public void set_text (string text) { diff --git a/src/Widgets/Statusbar/Statusbar.vala b/src/Widgets/Statusbar/Statusbar.vala index 24f9f0c5..64ab7568 100644 --- a/src/Widgets/Statusbar/Statusbar.vala +++ b/src/Widgets/Statusbar/Statusbar.vala @@ -3,55 +3,69 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -public class Monitor.Statusbar : Gtk.ActionBar { +public class Monitor.Statusbar : Gtk.Box { Gtk.Label cpu_usage_label; Gtk.Label memory_usage_label; Gtk.Label swap_usage_label; Gtk.Label gpu_usage_label; construct { - var cpu_icon = new Gtk.Image.from_icon_name ("cpu-symbolic", Gtk.IconSize.SMALL_TOOLBAR) { + var actionbar = new Gtk.ActionBar () { + hexpand = true, + }; + append (actionbar); + + var cpu_icon = new Gtk.Image.from_icon_name ("cpu-symbolic") { tooltip_text = _("CPU") }; - var ram_icon = new Gtk.Image.from_icon_name ("ram-symbolic", Gtk.IconSize.SMALL_TOOLBAR) { + var ram_icon = new Gtk.Image.from_icon_name ("ram-symbolic") { tooltip_text = _("Memory") }; - var swap_icon = new Gtk.Image.from_icon_name ("swap-symbolic", Gtk.IconSize.SMALL_TOOLBAR) { + var swap_icon = new Gtk.Image.from_icon_name ("swap-symbolic") { tooltip_text = _("Swap") }; - var gpu_icon = new Gtk.Image.from_icon_name ("gpu-symbolic", Gtk.IconSize.SMALL_TOOLBAR) { + var gpu_icon = new Gtk.Image.from_icon_name ("gpu-symbolic") { tooltip_text = _("GPU") }; - cpu_usage_label = new Gtk.Label (_("Calculating…")); - cpu_usage_label.set_width_chars (4); - cpu_usage_label.xalign = 0; - pack_start (cpu_icon); - pack_start (cpu_usage_label); - - memory_usage_label = new Gtk.Label (_("Calculating…")); - memory_usage_label.set_width_chars (4); - memory_usage_label.xalign = 0; - ram_icon.margin_start = 6; - pack_start (ram_icon); - pack_start (memory_usage_label); - - swap_usage_label = new Gtk.Label (_("Calculating…")); - swap_usage_label.set_width_chars (4); - swap_usage_label.xalign = 0; - swap_icon.margin_start = 6; - pack_start (swap_icon); - pack_start (swap_usage_label); - - gpu_usage_label = new Gtk.Label (_("Calculating…")); - gpu_usage_label.set_width_chars (4); - gpu_usage_label.xalign = 0; - gpu_icon.margin_start = 6; - pack_start (gpu_icon); - pack_start (gpu_usage_label); + cpu_usage_label = new Gtk.Label (_("Calculating…")) { + width_chars = 4, + xalign = 0, + margin_start = 6, + }; + + actionbar.pack_start (cpu_icon); + actionbar.pack_start (cpu_usage_label); + + memory_usage_label = new Gtk.Label (_("Calculating…")) { + width_chars = 4, + xalign = 0, + margin_start = 6, + }; + + actionbar.pack_start (ram_icon); + actionbar.pack_start (memory_usage_label); + + swap_usage_label = new Gtk.Label (_("Calculating…")) { + width_chars = 4, + xalign = 0, + margin_start = 6, + }; + + actionbar.pack_start (swap_icon); + actionbar.pack_start (swap_usage_label); + + gpu_usage_label = new Gtk.Label (_("Calculating…")) { + width_chars = 4, + xalign = 0, + margin_start = 6, + }; + + actionbar.pack_start (gpu_icon); + actionbar.pack_start (gpu_usage_label); var support_ua_label = new Gtk.LinkButton.with_label ("http://stand-with-ukraine.pp.ua/", _("🇺🇦")); var github_label = new Gtk.LinkButton.with_label ("https://github.com/elementary/monitor", _("Check on Github")); @@ -59,14 +73,14 @@ public class Monitor.Statusbar : Gtk.ActionBar { var version_label = new Gtk.Label ("%s".printf (VCS_TAG)) { selectable = true }; - version_label.get_style_context ().add_class ("dim-label"); + version_label.add_css_class ("dim-label"); // pack_end (build_separator_middot ()); - pack_end (github_label); - pack_end (build_separator_middot ()); - pack_end (version_label); - pack_end (build_separator_middot ()); - pack_end (support_ua_label); + actionbar.pack_end (github_label); + actionbar.pack_end (build_separator_middot ()); + actionbar.pack_end (version_label); + actionbar.pack_end (build_separator_middot ()); + actionbar.pack_end (support_ua_label); } @@ -75,7 +89,7 @@ public class Monitor.Statusbar : Gtk.ActionBar { margin_end = 6, margin_start = 6, }; - label.get_style_context ().add_class ("dim-label"); + label.add_css_class ("dim-label"); return label; } diff --git a/src/Widgets/WidgetResource/WidgetResource.vala b/src/Widgets/WidgetResource/WidgetResource.vala index 86020a88..1bfd4871 100644 --- a/src/Widgets/WidgetResource/WidgetResource.vala +++ b/src/Widgets/WidgetResource/WidgetResource.vala @@ -4,7 +4,9 @@ */ public class Monitor.WidgetResource : Gtk.Box { - private Granite.HeaderLabel _title = new Granite.HeaderLabel (Utils.NO_DATA); + private Granite.HeaderLabel _title = new Granite.HeaderLabel (Utils.NO_DATA) { + valign = Gtk.Align.CENTER, + }; public string title { set { @@ -12,7 +14,6 @@ public class Monitor.WidgetResource : Gtk.Box { } } - public Gtk.Popover popover_more_info; private LabelVertical _label_vertical_main_metric = new LabelVertical (_("UTILIZATION")); public string label_vertical_main_metric { @@ -29,7 +30,9 @@ public class Monitor.WidgetResource : Gtk.Box { construct { - margin = 12; + margin_start = 12; + margin_end = 12; + margin_bottom = 12; margin_top = 6; set_vexpand (false); orientation = Gtk.Orientation.VERTICAL; @@ -40,27 +43,30 @@ public class Monitor.WidgetResource : Gtk.Box { column_spacing = 6, }; grid_header.attach (_title, 0, 0, 1, 1); - add (grid_header); + append (grid_header); grid_main_chart_container = new Gtk.Grid (); grid_main_chart_container.attach (build_grid_main_onchart_info_container (), 0, 0, 1, 1); - charts_container.pack_start (grid_main_chart_container, true, true, 0); + charts_container.prepend (grid_main_chart_container); - add (charts_container); + append (charts_container); } private Gtk.Grid build_grid_main_onchart_info_container () { grid_main_onchart_info_container = new Gtk.Grid () { column_spacing = 6, - margin = 6, + margin_top = 6, + margin_end = 6, + margin_bottom = 6, + margin_start = 6, valign = Gtk.Align.START, halign = Gtk.Align.START, }; - grid_main_onchart_info_container.get_style_context ().add_class ("usage-label-container"); + grid_main_onchart_info_container.add_css_class ("usage-label-container"); grid_main_onchart_info_container.attach (_label_vertical_main_metric, 0, 0, 1, 1); return grid_main_onchart_info_container; @@ -75,32 +81,28 @@ public class Monitor.WidgetResource : Gtk.Box { } public void add_charts_container (Gtk.Widget widget) { - charts_container.pack_start (widget, false, false, 0); + charts_container.append (widget); } public void set_popover_more_info (Gtk.Widget widget) { - var button_more_info = new Gtk.ToggleButton () { - has_focus = false, - valign = Gtk.Align.START, - halign = Gtk.Align.START - }; - button_more_info.get_style_context ().add_class ("circular"); - // button_more_info.get_style_context ().add_class ("popup"); - var icon = new Gtk.Image (); - icon.gicon = new ThemedIcon ("dialog-information"); - icon.pixel_size = 16; - button_more_info.set_image (icon); - - popover_more_info = new Gtk.Popover (button_more_info) { + var popover_more_info = new Gtk.Popover () { position = Gtk.PositionType.BOTTOM, - modal = true, - visible = false, + // visible = false, + autohide = true, + child = widget, }; - popover_more_info.closed.connect (() => { button_more_info.set_active (false); }); - button_more_info.clicked.connect (() => { popover_more_info.show_all (); }); + var button_more_info = new Gtk.MenuButton () { + focusable = false, + icon_name = "dialog-information", + valign = Gtk.Align.START, + halign = Gtk.Align.START, + popover = popover_more_info, - popover_more_info.add (widget); + }; + button_more_info.add_css_class ("circular"); + button_more_info.add_css_class ("popup"); grid_header.attach (button_more_info, 1, 0, 1, 1); } + } diff --git a/subprojects/live-chart b/subprojects/live-chart new file mode 160000 index 00000000..1cdb953d --- /dev/null +++ b/subprojects/live-chart @@ -0,0 +1 @@ +Subproject commit 1cdb953dd6313d5102e441c65be8e35c3e12cc32 diff --git a/subprojects/live-chart.wrap b/subprojects/live-chart.wrap index 127b82f5..6de6241d 100644 --- a/subprojects/live-chart.wrap +++ b/subprojects/live-chart.wrap @@ -1,6 +1,6 @@ [wrap-git] url = https://github.com/elementary/live-chart.git -revision = 5a690045f2e3df1d78ff0ea1e5df6470a6760639 +revision = 1cdb953dd6313d5102e441c65be8e35c3e12cc32 depth = 1 [provide]