shutdown: let's shutdown the same everywhere.
Also minor refactor in main.c
This commit is contained in:
parent
56859ad90f
commit
175034919a
23
src/main.c
23
src/main.c
|
@ -1,21 +1,24 @@
|
||||||
/* Copyright 2018. Alastair Poole <netstar@gmail.com>
|
/* Copyright 2018. Alastair Poole <netstar@gmail.com>
|
||||||
See LICENSE file for details.
|
See LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_win_del_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
_win_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
evas_object_del(obj);
|
Ui *ui;
|
||||||
ecore_main_loop_quit();
|
|
||||||
|
ui = data;
|
||||||
|
|
||||||
|
ui_shutdown(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_win_add(void)
|
_win_add(void)
|
||||||
{
|
{
|
||||||
|
Ui *ui;
|
||||||
Evas_Object *win, *icon;
|
Evas_Object *win, *icon;
|
||||||
|
|
||||||
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
||||||
|
@ -24,11 +27,13 @@ _win_add(void)
|
||||||
icon = elm_icon_add(win);
|
icon = elm_icon_add(win);
|
||||||
elm_icon_standard_set(icon, "evisum");
|
elm_icon_standard_set(icon, "evisum");
|
||||||
elm_win_icon_object_set(win, icon);
|
elm_win_icon_object_set(win, icon);
|
||||||
|
|
||||||
evas_object_resize(win, 768 * elm_config_scale_get(), 500 * elm_config_scale_get());
|
evas_object_resize(win, 768 * elm_config_scale_get(), 500 * elm_config_scale_get());
|
||||||
evas_object_smart_callback_add(win, "delete,request", _win_del_cb, NULL);
|
|
||||||
|
|
||||||
elm_win_title_set(win, "System Information");
|
elm_win_title_set(win, "System Information");
|
||||||
|
elm_win_center(win, EINA_TRUE, EINA_TRUE);
|
||||||
|
evas_object_show(win);
|
||||||
|
|
||||||
|
ui = ui_add(win);
|
||||||
|
evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ui);
|
||||||
|
|
||||||
return win;
|
return win;
|
||||||
}
|
}
|
||||||
|
@ -43,10 +48,6 @@ main(int argc, char **argv)
|
||||||
elm_init(argc, argv);
|
elm_init(argc, argv);
|
||||||
|
|
||||||
win = _win_add();
|
win = _win_add();
|
||||||
ui_add(win);
|
|
||||||
|
|
||||||
elm_win_center(win, EINA_TRUE, EINA_TRUE);
|
|
||||||
evas_object_show(win);
|
|
||||||
|
|
||||||
ecore_main_loop_begin();
|
ecore_main_loop_begin();
|
||||||
|
|
||||||
|
|
38
src/ui.c
38
src/ui.c
|
@ -21,6 +21,26 @@ static void _extra_view_update(Ui *ui, results_t *results);
|
||||||
static void _cpu_view_update(Ui *ui, results_t *results);
|
static void _cpu_view_update(Ui *ui, results_t *results);
|
||||||
static void _memory_view_update(Ui *ui, results_t *results);
|
static void _memory_view_update(Ui *ui, results_t *results);
|
||||||
|
|
||||||
|
void
|
||||||
|
ui_shutdown(Ui *ui)
|
||||||
|
{
|
||||||
|
evas_object_hide(ui->win);
|
||||||
|
|
||||||
|
if (ui->thread_system)
|
||||||
|
ecore_thread_cancel(ui->thread_system);
|
||||||
|
|
||||||
|
if (ui->thread_process)
|
||||||
|
ecore_thread_cancel(ui->thread_process);
|
||||||
|
|
||||||
|
if (ui->thread_system)
|
||||||
|
ecore_thread_wait(ui->thread_system, 1.0);
|
||||||
|
|
||||||
|
if (ui->thread_process)
|
||||||
|
ecore_thread_wait(ui->thread_process, 1.0);
|
||||||
|
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_system_stats_thread(void *data, Ecore_Thread *thread)
|
_system_stats_thread(void *data, Ecore_Thread *thread)
|
||||||
{
|
{
|
||||||
|
@ -387,6 +407,7 @@ _system_process_list(void *data, Ecore_Thread *thread)
|
||||||
{
|
{
|
||||||
if (ecore_thread_check(thread))
|
if (ecore_thread_check(thread))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -559,15 +580,7 @@ _btn_quit_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
|
||||||
{
|
{
|
||||||
Ui *ui = data;
|
Ui *ui = data;
|
||||||
|
|
||||||
evas_object_hide(ui->win);
|
ui_shutdown(ui);
|
||||||
|
|
||||||
ecore_thread_cancel(ui->thread_system);
|
|
||||||
ecore_thread_cancel(ui->thread_process);
|
|
||||||
|
|
||||||
ecore_thread_wait(ui->thread_system, 1.0);
|
|
||||||
ecore_thread_wait(ui->thread_process, 1.0);
|
|
||||||
|
|
||||||
ecore_main_loop_quit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1318,7 +1331,6 @@ _ui_system_view_add(Ui *ui)
|
||||||
frame = elm_frame_add(box);
|
frame = elm_frame_add(box);
|
||||||
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
elm_object_text_set(frame, "System Overview");
|
|
||||||
elm_object_style_set(frame, "pad_small");
|
elm_object_style_set(frame, "pad_small");
|
||||||
elm_box_pack_end(box, frame);
|
elm_box_pack_end(box, frame);
|
||||||
evas_object_show(frame);
|
evas_object_show(frame);
|
||||||
|
@ -2021,7 +2033,7 @@ _ui_tabs_add(Evas_Object *parent, Ui *ui)
|
||||||
button = elm_button_add(hbox);
|
button = elm_button_add(hbox);
|
||||||
evas_object_size_hint_weight_set(button, 1.0, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(button, 1.0, EVAS_HINT_EXPAND);
|
||||||
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
elm_object_text_set(button, "System Activity");
|
elm_object_text_set(button, "General");
|
||||||
evas_object_show(button);
|
evas_object_show(button);
|
||||||
elm_box_pack_end(hbox, button);
|
elm_box_pack_end(hbox, button);
|
||||||
evas_object_smart_callback_add(button, "clicked", _tab_system_activity_clicked_cb, ui);
|
evas_object_smart_callback_add(button, "clicked", _tab_system_activity_clicked_cb, ui);
|
||||||
|
@ -2087,7 +2099,7 @@ _ui_tabs_add(Evas_Object *parent, Ui *ui)
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
Ui *
|
||||||
ui_add(Evas_Object *parent)
|
ui_add(Evas_Object *parent)
|
||||||
{
|
{
|
||||||
Ui *ui;
|
Ui *ui;
|
||||||
|
@ -2131,5 +2143,7 @@ ui_add(Evas_Object *parent)
|
||||||
|
|
||||||
ui->thread_system = ecore_thread_feedback_run(_system_stats_thread, _system_stats_thread_feedback_cb, _thread_end_cb, _thread_error_cb, ui, EINA_FALSE);
|
ui->thread_system = ecore_thread_feedback_run(_system_stats_thread, _system_stats_thread_feedback_cb, _thread_end_cb, _thread_error_cb, ui, EINA_FALSE);
|
||||||
ui->thread_process = ecore_thread_feedback_run(_system_process_list, _system_process_list_feedback_cb, _thread_end_cb, _thread_error_cb, ui, EINA_FALSE);
|
ui->thread_process = ecore_thread_feedback_run(_system_process_list, _system_process_list_feedback_cb, _thread_end_cb, _thread_error_cb, ui, EINA_FALSE);
|
||||||
|
|
||||||
|
return ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue