| 1 |
#ifndef _GSM_APPLICATION_H_ |
| 2 |
#define _GSM_APPLICATION_H_ |
| 3 |
|
| 4 |
#include <gtkmm.h> |
| 5 |
#include <glibtop/cpu.h> |
| 6 |
#include <adwaita.h> |
| 7 |
|
| 8 |
#include <algorithm> |
| 9 |
#include <mutex> |
| 10 |
|
| 11 |
struct LoadGraph; |
| 12 |
|
| 13 |
#include "legacy/treeview.h" |
| 14 |
#include "disks.h" |
| 15 |
#include "prettytable.h" |
| 16 |
#include "procinfo.h" |
| 17 |
#include "proclist.h" |
| 18 |
#include "smooth_refresh.h" |
| 19 |
#include "util.h" |
| 20 |
|
| 21 |
struct ProcConfig |
| 22 |
: private procman::NonCopyable |
| 23 |
{ |
| 24 |
ProcConfig () |
| 25 |
: current_tab (), |
| 26 |
update_interval (0), |
| 27 |
graph_update_interval (0), |
| 28 |
graph_data_points (0), |
| 29 |
mem_color (), |
| 30 |
swap_color (), |
| 31 |
net_in_color (), |
| 32 |
net_out_color (), |
| 33 |
disk_read_color (), |
| 34 |
disk_write_color (), |
| 35 |
bg_color (), |
| 36 |
frame_color (), |
| 37 |
num_cpus (0), |
| 38 |
solaris_mode (false), |
| 39 |
process_memory_in_iec (true), |
| 40 |
logarithmic_scale (false), |
| 41 |
draw_stacked (false), |
| 42 |
draw_smooth (true), |
| 43 |
resources_memory_in_iec (true), |
| 44 |
network_in_bits (false), |
| 45 |
network_total_in_bits (false) |
| 46 |
{ |
| 47 |
std::fill (&this->cpu_color[0], &this->cpu_color[GLIBTOP_NCPU], GdkRGBA ()); |
| 48 |
} |
| 49 |
|
| 50 |
Glib::ustring current_tab; |
| 51 |
int update_interval; |
| 52 |
int graph_update_interval; |
| 53 |
int graph_data_points; |
| 54 |
GdkRGBA cpu_color[GLIBTOP_NCPU]; |
| 55 |
GdkRGBA mem_color; |
| 56 |
GdkRGBA swap_color; |
| 57 |
GdkRGBA net_in_color; |
| 58 |
GdkRGBA net_out_color; |
| 59 |
GdkRGBA disk_read_color; |
| 60 |
GdkRGBA disk_write_color; |
| 61 |
GdkRGBA bg_color; |
| 62 |
GdkRGBA frame_color; |
| 63 |
gint num_cpus; |
| 64 |
bool solaris_mode; |
| 65 |
bool process_memory_in_iec; |
| 66 |
bool logarithmic_scale; |
| 67 |
bool draw_stacked; |
| 68 |
bool draw_smooth; |
| 69 |
bool resources_memory_in_iec; |
| 70 |
bool network_in_bits; |
| 71 |
bool network_total_in_bits; |
| 72 |
}; |
| 73 |
|
| 74 |
class GsmApplication final: public Gtk::Application, private procman::NonCopyable |
| 75 |
{ |
| 76 |
private: |
| 77 |
void load_settings (); |
| 78 |
void load_command_line_options(); |
| 79 |
|
| 80 |
void on_preferences_activate (const Glib::VariantBase&); |
| 81 |
void on_lsof_activate (const Glib::VariantBase&); |
| 82 |
void on_help_activate (const Glib::VariantBase&); |
| 83 |
void on_quit_activate (const Glib::VariantBase&); |
| 84 |
int handle_local_options (const Glib::RefPtr<Glib::VariantDict> &); |
| 85 |
|
| 86 |
GsmApplication(); |
| 87 |
|
| 88 |
void on_activate () override; |
| 89 |
int on_command_line (const Glib::RefPtr<Gio::ApplicationCommandLine>&command_line) override; |
| 90 |
void on_startup () override; |
| 91 |
public: |
| 92 |
static GsmApplication& get (); |
| 93 |
|
| 94 |
void save_config (); |
| 95 |
void shutdown (); |
| 96 |
|
| 97 |
Glib::RefPtr<Gio::Settings> settings; |
| 98 |
AdwApplicationWindow *main_window; |
| 99 |
AdwViewStack *stack; |
| 100 |
GtkMenuButton *app_menu_button; |
| 101 |
|
| 102 |
GMenuModel *generic_window_menu_model; |
| 103 |
GMenuModel *process_window_menu_model; |
| 104 |
|
| 105 |
ProcList processes; |
| 106 |
ProcConfig config; |
| 107 |
PrettyTable *pretty_table; |
| 108 |
GsmTreeView *tree; |
| 109 |
GtkRevealer *proc_actionbar_revealer; |
| 110 |
GtkPopover *proc_popover_menu; |
| 111 |
GtkButton *refresh_button; |
| 112 |
GtkButton *end_process_button; |
| 113 |
GtkToggleButton *search_button; |
| 114 |
GtkSearchEntry *search_entry; |
| 115 |
GtkSearchBar *search_bar; |
| 116 |
GtkTreePath *top_of_tree; |
| 117 |
|
| 118 |
gdouble last_vscroll_max; |
| 119 |
gdouble last_vscroll_value; |
| 120 |
guint timeout; |
| 121 |
guint64 cpu_total_time; |
| 122 |
guint64 cpu_total_time_last; |
| 123 |
unsigned frequency; |
| 124 |
|
| 125 |
LoadGraph *cpu_graph; |
| 126 |
LoadGraph *mem_graph; |
| 127 |
LoadGraph *net_graph; |
| 128 |
LoadGraph *disk_graph; |
| 129 |
|
| 130 |
GsmDisksView *disk_list; |
| 131 |
|
| 132 |
GtkTreeSelection *selection; |
| 133 |
|
| 134 |
SmoothRefresh *smooth_refresh; |
| 135 |
}; |
| 136 |
|
| 137 |
#endif |