Commit eb416e12 authored by Petr Štětka's avatar Petr Štětka
Browse files

*respect naming conventions in vala

parent 214d5d7b
......@@ -20,14 +20,14 @@ vala_binary: src/gnome-usage
*vala_check_package: x11
c_library: gtop-2.0
*vala_source: application.vala
*vala_source: cpu-subview.vala
*vala_source: cpu-sub-view.vala
*vala_source: data-view.vala
*vala_source: gnome-usage.vala
*vala_source: headerbar.vala
*vala_source: header-bar.vala
*vala_source: performance-view.vala
*vala_source: power-view.vala
*vala_source: process-list.vala
*vala_source: ram-subview.vala
*vala_source: ram-sub-view.vala
*vala_source: storage-view.vala
*vala_source: system-monitor.vala
*vala_source: view.vala
......@@ -36,19 +36,19 @@ h_folder: /usr/include/libgtop-2.0
*po: po
*translate: vala src/header-bar.vala
*translate: vala src/performance-view.vala
*translate: vala src/view.vala
*translate: vala src/gnome-usage.vala
*translate: vala src/process-list.vala
*translate: vala src/storage-view.vala
*translate: vala src/cpu-subview.vala
*translate: vala src/data-view.vala
*translate: vala src/power-view.vala
*translate: vala src/system-monitor.vala
*translate: vala src/headerbar.vala
*translate: vala src/power-view.vala
*translate: vala src/cpu-sub-view.vala
*translate: vala src/process-list.vala
*translate: vala src/ram-sub-view.vala
*translate: vala src/data-view.vala
*translate: vala src/application.vala
*translate: vala src/window.vala
*translate: vala src/performance-view.vala
*translate: vala src/ram-subview.vala
*data: data/local
......
src/application.vala
src/cpu-subview.vala
src/cpu-sub-view.vala
src/data-view.vala
src/gnome-usage.vala
src/headerbar.vala
src/header-bar.vala
src/performance-view.vala
src/power-view.vala
src/process-list.vala
src/ram-subview.vala
src/ram-sub-view.vala
src/storage-view.vala
src/system-monitor.vala
src/view.vala
......
......@@ -36,14 +36,14 @@ set (VALA_PACKAGES ${VALA_PACKAGES} x11)
set (APP_SOURCES ${APP_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/Config.vala)
set (APP_SOURCES ${APP_SOURCES} application.vala)
set (APP_SOURCES ${APP_SOURCES} cpu-subview.vala)
set (APP_SOURCES ${APP_SOURCES} cpu-sub-view.vala)
set (APP_SOURCES ${APP_SOURCES} data-view.vala)
set (APP_SOURCES ${APP_SOURCES} gnome-usage.vala)
set (APP_SOURCES ${APP_SOURCES} headerbar.vala)
set (APP_SOURCES ${APP_SOURCES} header-bar.vala)
set (APP_SOURCES ${APP_SOURCES} performance-view.vala)
set (APP_SOURCES ${APP_SOURCES} power-view.vala)
set (APP_SOURCES ${APP_SOURCES} process-list.vala)
set (APP_SOURCES ${APP_SOURCES} ram-subview.vala)
set (APP_SOURCES ${APP_SOURCES} ram-sub-view.vala)
set (APP_SOURCES ${APP_SOURCES} storage-view.vala)
set (APP_SOURCES ${APP_SOURCES} system-monitor.vala)
set (APP_SOURCES ${APP_SOURCES} view.vala)
......
namespace Usage
{
public class CPUSubView : View
{
ProcessList process_list_box;
Gtk.Label cpu_load_label;
List<ProcessRow> process_row_list;
bool show_active_process = true;
public CPUSubView()
{
name = "CPU";
cpu_load_label = new Gtk.Label(null);
cpu_load_label.margin_right = 100;
var processor_label = new Gtk.Label("<b>" + _("Processor") + "</b>");
processor_label.set_use_markup(true);
var processor_text_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
processor_text_box.set_center_widget(processor_label);
processor_text_box.pack_end(cpu_load_label, false, true, 0);
processor_text_box.margin_top = 20;
process_list_box = new ProcessList();
var cpu_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
var process_list_box_frame = new Gtk.Frame(null);
process_list_box_frame.margin_start = 100;
process_list_box_frame.margin_end = 100;
process_list_box_frame.margin_bottom = 20;
process_list_box_frame.add(process_list_box);
cpu_box.pack_start(processor_text_box, false, false, 0);
cpu_box.pack_start(process_list_box_frame, true, false, 0);
var scrolled_window = new Gtk.ScrolledWindow(null, null);
scrolled_window.add(cpu_box);
scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
construct_menu_button();
add(scrolled_window);
Timeout.add(1000, update_process);
}
public bool update_process()
{
process_list_box.foreach((widget) => { widget.destroy(); });
cpu_load_label.set_text(((int) monitor.cpu_load).to_string() + " %");
process_row_list = new List<ProcessRow>();
foreach(unowned Process process in monitor.get_processes()) {
if(show_active_process)
{
if((int) process.cpu_load > 0)
insert_process_row(process);
} else
insert_process_row(process);
}
for(int i = 0; i < process_row_list.length(); i++)
{
process_list_box.add(process_row_list.data);
process_row_list =(owned) process_row_list.next;
}
return true;
}
public void insert_process_row(Process process)
{
var process_row = new ProcessRow(process.cmdline,(int) process.cpu_load);
process_row.sort_id =(int)(10 * process.cpu_load);
process_row_list.insert_sorted(process_row,(a, b) => {
return(b as ProcessRow).sort_id -(a as ProcessRow).sort_id;
});
}
private void construct_menu_button()
{
var popover_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
popover_box.margin = 5;
var active = new Gtk.RadioButton.with_label_from_widget(null, _("Active process"));
popover_box.pack_start(active, false, false, 0);
active.toggled.connect(() => {
monitor.set_process_mode(SystemMonitor.ProcessMode.ALL);
show_active_process = true;
update_process();
});
var all = new Gtk.RadioButton.with_label_from_widget(active, _("All process"));
popover_box.pack_start(all, false, false, 0);
all.toggled.connect(() => {
show_active_process = false;
monitor.set_process_mode(SystemMonitor.ProcessMode.ALL);
monitor.update();
update_process();
});
var my = new Gtk.RadioButton.with_label_from_widget(active, _("My process"));
popover_box.pack_start(my, false, false, 0);
my.toggled.connect(() => {
show_active_process = false;
monitor.set_process_mode(SystemMonitor.ProcessMode.USER);
monitor.update();
update_process();
});
popover_box.show_all();
header_bar.set_menu_button(popover_box);
}
public override void update_header_bar()
{
header_bar.clear();
header_bar.show_menu_button();
header_bar.show_stack_switcher();
}
}
}
namespace Usage
{
public class CPUsubView : View
{
ProcessList processListBox;
Gtk.Label CPULoadLabel;
List<ProcessRow> processRowList;
bool showActiveProcess = true;
public CPUsubView ()
{
name = ("CPU");
CPULoadLabel = new Gtk.Label(null);
CPULoadLabel.margin_right = 100;
var processorLabel = new Gtk.Label("<b>" + _("Processor") + "</b>");
processorLabel.set_use_markup(true);
var processorTextBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
processorTextBox.set_center_widget(processorLabel);
processorTextBox.pack_end(CPULoadLabel, false, true, 0);
processorTextBox.margin_top = 20;
processListBox = new ProcessList();
var CPUBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
var processListBoxFrame = new Gtk.Frame(null);
processListBoxFrame.margin_start = 100;
processListBoxFrame.margin_end = 100;
processListBoxFrame.margin_bottom = 20;
processListBoxFrame.add(processListBox);
CPUBox.pack_start(processorTextBox, false, false, 0);
CPUBox.pack_start(processListBoxFrame, true, false, 0);
var scrolledWindowCPU = new Gtk.ScrolledWindow(null, null);
scrolledWindowCPU.add(CPUBox);
scrolledWindowCPU.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
constructMenuButton();
add(scrolledWindowCPU);
Timeout.add(1000, updateProcess);
}
public bool updateProcess()
{
processListBox.foreach((widget) => { widget.destroy(); });
CPULoadLabel.set_text(((int) monitor.cpu_load).to_string() + " %");
processRowList = new List<ProcessRow>();
foreach(unowned Process process in monitor.get_processes()) {
if(showActiveProcess)
{
if((int) process.cpu_load > 0)
insertProcessRow(process);
} else
insertProcessRow(process);
}
for(int i = 0; i < processRowList.length(); i++)
{
processListBox.add(processRowList.data);
processRowList =(owned) processRowList.next;
}
return true;
}
public void insertProcessRow(Process process)
{
var processRow = new ProcessRow(process.cmdline,(int) process.cpu_load);
processRow.sortId =(int)(10 * process.cpu_load);
processRowList.insert_sorted(processRow,(a, b) => {
return(b as ProcessRow).sortId -(a as ProcessRow).sortId;
});
}
private void constructMenuButton()
{
var popoverBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
popoverBox.margin = 5;
var active = new Gtk.RadioButton.with_label_from_widget(null, _("Active process"));
popoverBox.pack_start(active, false, false, 0);
active.toggled.connect(() => {
monitor.setProcessMode(SystemMonitor.ProcessMode.ALL);
showActiveProcess = true;
updateProcess();
});
var all = new Gtk.RadioButton.with_label_from_widget(active, _("All process"));
popoverBox.pack_start(all, false, false, 0);
all.toggled.connect(() => {
showActiveProcess = false;
monitor.setProcessMode(SystemMonitor.ProcessMode.ALL);
monitor.update();
updateProcess();
});
var my = new Gtk.RadioButton.with_label_from_widget(active, _("My process"));
popoverBox.pack_start(my, false, false, 0);
my.toggled.connect(() => {
showActiveProcess = false;
monitor.setProcessMode(SystemMonitor.ProcessMode.USER);
monitor.update();
updateProcess();
});
popoverBox.show_all();
headerBar.setMenuButton(popoverBox);
}
public override void updateHeaderBar()
{
headerBar.clear();
headerBar.showMenuButton();
headerBar.showStackSwitcher();
}
}
}
......@@ -7,14 +7,14 @@ namespace Usage
name = ("DATA");
title = _("Data");
var label1 = new Gtk.Label("Page Data Content.");
add(label1);
var label = new Gtk.Label("Page Data Content.");
add(label);
}
public override void updateHeaderBar()
public override void update_header_bar()
{
headerBar.clear();
headerBar.showStackSwitcher();
header_bar.clear();
header_bar.show_stack_switcher();
}
}
}
......@@ -2,39 +2,39 @@ namespace Usage
{
public class HeaderBar : Gtk.HeaderBar
{
private Gtk.StackSwitcher stackSwitcher;
private Gtk.MenuButton menuButton;
private Gtk.StackSwitcher stack_switcher;
private Gtk.MenuButton menu_button;
public HeaderBar(Gtk.Stack stack)
{
show_close_button = true;
stackSwitcher = new Gtk.StackSwitcher();
stackSwitcher.halign = Gtk.Align.CENTER;
stackSwitcher.set_stack(stack);
menuButton = new Gtk.MenuButton();
menuButton.add(new Gtk.Image.from_icon_name("open-menu-symbolic", Gtk.IconSize.BUTTON));
stack_switcher = new Gtk.StackSwitcher();
stack_switcher.halign = Gtk.Align.CENTER;
stack_switcher.set_stack(stack);
menu_button = new Gtk.MenuButton();
menu_button.add(new Gtk.Image.from_icon_name("open-menu-symbolic", Gtk.IconSize.BUTTON));
}
public void setMenuButton(Gtk.Box? popoverBox)
public void set_menu_button(Gtk.Box? popover_box)
{
var popover = new Gtk.Popover(menuButton);
popover.add(popoverBox);
menuButton.popover = popover;
var popover = new Gtk.Popover(menu_button);
popover.add(popover_box);
menu_button.popover = popover;
}
public void showMenuButton()
public void show_menu_button()
{
pack_end(menuButton);
pack_end(menu_button);
}
public void hideMenuButton()
public void hide_menu_button()
{
remove(menuButton);
remove(menu_button);
}
public void showStackSwitcher()
public void show_stack_switcher()
{
set_custom_title(stackSwitcher);
set_custom_title(stack_switcher);
}
public void clear()
......
......@@ -2,64 +2,64 @@ namespace Usage
{
public class PerformanceView : View
{
Gtk.Stack performanceStack;
Gtk.Stack performance_stack;
public PerformanceView()
{
name = "PERFORMANCE";
title = _("Performance");
var CPUButton = new Gtk.Button.with_label("Processor");
var memoryButton = new Gtk.Button.with_label("Memory");
var diskButton = new Gtk.Button.with_label("Disk I/O");
var networkButton = new Gtk.Button.with_label("Network");
var panelBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
var cpu_button = new Gtk.Button.with_label("Processor");
var memory_button = new Gtk.Button.with_label("Memory");
var disk_button = new Gtk.Button.with_label("Disk I/O");
var network_button = new Gtk.Button.with_label("Network");
var panel_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
panelBox.pack_start(CPUButton, false, true, 0);
panelBox.pack_start(memoryButton, false, true, 0);
panelBox.pack_start(diskButton, false, true, 0);
panelBox.pack_start(networkButton, false, true, 0);
panel_box.pack_start(cpu_button, false, true, 0);
panel_box.pack_start(memory_button, false, true, 0);
panel_box.pack_start(disk_button, false, true, 0);
panel_box.pack_start(network_button, false, true, 0);
performanceStack = new Gtk.Stack();
performanceStack.set_transition_type(Gtk.StackTransitionType.SLIDE_UP_DOWN);
performanceStack.set_transition_duration(700);
performance_stack = new Gtk.Stack();
performance_stack.set_transition_type(Gtk.StackTransitionType.SLIDE_UP_DOWN);
performance_stack.set_transition_duration(700);
var subViews = new View[]
var sub_views = new View[]
{
new CPUsubView(),
new RAMsubView()
new CPUSubView(),
new RAMSubView()
};
foreach(var subView in subViews)
performanceStack.add_named(subView, subView.name);
foreach(var sub_view in sub_views)
performance_stack.add_named(sub_view, sub_view.name);
CPUButton.clicked.connect(() => {
performanceStack.set_visible_child_name(subViews[0].name);
((View) performanceStack.get_visible_child()).updateHeaderBar();
cpu_button.clicked.connect(() => {
performance_stack.set_visible_child_name(sub_views[0].name);
((View) performance_stack.get_visible_child()).update_header_bar();
});
memoryButton.clicked.connect(() => {
performanceStack.set_visible_child_name(subViews[1].name);
((View) performanceStack.get_visible_child()).updateHeaderBar();
memory_button.clicked.connect(() => {
performance_stack.set_visible_child_name(sub_views[1].name);
((View) performance_stack.get_visible_child()).update_header_bar();
});
diskButton.clicked.connect(() => {
performanceStack.set_visible_child_name("DISK");
headerBar.hideMenuButton();
disk_button.clicked.connect(() => {
performance_stack.set_visible_child_name("DISK");
header_bar.hide_menu_button();
});
networkButton.clicked.connect(() => {
performanceStack.set_visible_child_name("NETWORK");
headerBar.hideMenuButton();
network_button.clicked.connect(() => {
performance_stack.set_visible_child_name("NETWORK");
header_bar.hide_menu_button();
});
var paned = new Gtk.Paned(Gtk.Orientation.HORIZONTAL);
paned.add1(panelBox);
paned.add2(performanceStack);
paned.add1(panel_box);
paned.add2(performance_stack);
add(paned);
}
public override void updateHeaderBar()
public override void update_header_bar()
{
var visibleSubView = (View) performanceStack.get_visible_child();
visibleSubView.updateHeaderBar();
var visible_sub_view = (View) performance_stack.get_visible_child();
visible_sub_view.update_header_bar();
}
}
}
......@@ -7,14 +7,14 @@ namespace Usage
name = "POWER";
title = _("Power");
var label1 = new Gtk.Label("Page Power Content.");
add(label1);
var label = new Gtk.Label("Page Power Content.");
add(label);
}
public override void updateHeaderBar()
public override void update_header_bar()
{
headerBar.clear();
headerBar.showStackSwitcher();
header_bar.clear();
header_bar.show_stack_switcher();
}
}
}
......@@ -3,10 +3,10 @@ namespace Usage
public class ProcessRow : Gtk.ListBoxRow
{
private Gtk.Image icon;
private Gtk.Label titleLabel;
private Gtk.Label loadLabel;
private Gtk.Label title_label;
private Gtk.Label load_label;
public int sortId;
public int sort_id;
public bool is_headline { get; private set; }
......@@ -14,17 +14,17 @@ namespace Usage
{
var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
box.margin = 5;
titleLabel = new Gtk.Label(title);
loadLabel = new Gtk.Label(load.to_string() + " %");
title_label = new Gtk.Label(title);
load_label = new Gtk.Label(load.to_string() + " %");
icon = new Gtk.Image.from_icon_name("dialog-error", Gtk.IconSize.BUTTON);
box.pack_start(icon, false, false, 10);
box.pack_start(titleLabel, false, true, 5);
box.pack_end(loadLabel, false, true, 10);
box.pack_start(title_label, false, true, 5);
box.pack_end(load_label, false, true, 10);
add(box);
titleLabel.show();
loadLabel.show();
title_label.show();
load_label.show();
icon.show();
box.show();
show();
......
namespace Usage
{
public class RAMSubView : View
{
ProcessList process_list_box;
Gtk.Label cpu_load_label;
List<ProcessRow> process_row_list;
bool show_active_process = true;
public RAMSubView()
{
name = "RAM";
cpu_load_label = new Gtk.Label(null);
cpu_load_label.margin_right = 100;
var processor_label = new Gtk.Label("<b>" + _("Processor") + "</b>");
processor_label.set_use_markup(true);
var processor_text_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
processor_text_box.set_center_widget(processor_label);
processor_text_box.pack_end(cpu_load_label, false, true, 0);
processor_text_box.margin_top = 20;
process_list_box = new ProcessList();
var cpu_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
var process_list_box_frame = new Gtk.Frame(null);
process_list_box_frame.margin_start = 100;
process_list_box_frame.margin_end = 100;
process_list_box_frame.margin_bottom = 20;
process_list_box_frame.add(process_list_box);
cpu_box.pack_start(processor_text_box, false, false, 0);
cpu_box.pack_start(process_list_box_frame, true, false, 0);
var scrolled_window = new Gtk.ScrolledWindow(null, null);
scrolled_window.add(cpu_box);
scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
//construct_menu_button();
add(scrolled_window);
Timeout.add(1000, update_process);
}